refactor(materials): moved for better sturcture
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
import {ConsoleLogWriter} from "drizzle-orm";
|
||||
import {prodEndpointCreation} from "../../../globalUtils/createUrl.js";
|
||||
import {createLog} from "../../logger/logger.js";
|
||||
import {query} from "../../sqlServer/prodSqlServer.js";
|
||||
import {labelData} from "../../sqlServer/querys/materialHelpers/labelInfo.js";
|
||||
import axios from "axios";
|
||||
import { labelData } from "../../../sqlServer/querys/materialHelpers/labelInfo.js";
|
||||
|
||||
import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||
import { createLog } from "../../../logger/logger.js";
|
||||
|
||||
import { prodEndpointCreation } from "../../../../globalUtils/createUrl.js";
|
||||
|
||||
type Data = {
|
||||
runningNr: string;
|
||||
lotNum: number;
|
||||
};
|
||||
export const consumeMaterial = async (data: Data, prod: any) => {
|
||||
const {runningNr, lotNum} = data;
|
||||
const { runningNr, lotNum } = data;
|
||||
// replace the rn
|
||||
|
||||
const rnReplace = labelData.replaceAll("[rn]", runningNr);
|
||||
@@ -21,7 +22,12 @@ export const consumeMaterial = async (data: Data, prod: any) => {
|
||||
barcode = await query(rnReplace, "labelData");
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
createLog("error", prod.user.username, "logistics", `Error getting barcode: ${error}`);
|
||||
createLog(
|
||||
"error",
|
||||
prod.user.username,
|
||||
"logistics",
|
||||
`Error getting barcode: ${error}`
|
||||
);
|
||||
}
|
||||
|
||||
if (barcode.length === 0) {
|
||||
@@ -32,7 +38,9 @@ export const consumeMaterial = async (data: Data, prod: any) => {
|
||||
//throw Error("The provided runningNr is not in stock");
|
||||
}
|
||||
// create the url to post
|
||||
const url = await prodEndpointCreation("/public/v1.0/IssueMaterial/ConsumeNonPreparedManualMaterial");
|
||||
const url = await prodEndpointCreation(
|
||||
"/public/v1.0/IssueMaterial/ConsumeNonPreparedManualMaterial"
|
||||
);
|
||||
|
||||
const consumeSomething = {
|
||||
productionLot: lotNum,
|
||||
@@ -47,8 +55,16 @@ export const consumeMaterial = async (data: Data, prod: any) => {
|
||||
},
|
||||
});
|
||||
//console.log(results);
|
||||
return {success: true, message: "Material was consumed", status: results.status};
|
||||
return {
|
||||
success: true,
|
||||
message: "Material was consumed",
|
||||
status: results.status,
|
||||
};
|
||||
} catch (error: any) {
|
||||
return {success: false, status: 200, message: error.response?.data.errors[0].message};
|
||||
return {
|
||||
success: false,
|
||||
status: 200,
|
||||
message: error.response?.data.errors[0].message,
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -1,12 +1,10 @@
|
||||
import { ConsoleLogWriter } from "drizzle-orm";
|
||||
import { prodEndpointCreation } from "../../../globalUtils/createUrl.js";
|
||||
import { createLog } from "../../logger/logger.js";
|
||||
import { query } from "../../sqlServer/prodSqlServer.js";
|
||||
import { labelData } from "../../sqlServer/querys/materialHelpers/labelInfo.js";
|
||||
import axios from "axios";
|
||||
import { laneInfo } from "../../sqlServer/querys/materialHelpers/laneInfo.js";
|
||||
import { tryCatch } from "../../../globalUtils/tryCatch.js";
|
||||
|
||||
import { labelData } from "../../../sqlServer/querys/materialHelpers/labelInfo.js";
|
||||
import { laneInfo } from "../../../sqlServer/querys/materialHelpers/laneInfo.js";
|
||||
import { query } from "../../../sqlServer/prodSqlServer.js";
|
||||
import { createLog } from "../../../logger/logger.js";
|
||||
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
|
||||
import { prodEndpointCreation } from "../../../../globalUtils/createUrl.js";
|
||||
type Data = {
|
||||
runningNr: string;
|
||||
laneName: string;
|
||||
Reference in New Issue
Block a user