This commit is contained in:
@@ -1123,50 +1123,26 @@ async function saveParts(vm, woItemIndex) {
|
||||
|
||||
for (let i = 0; i < vm.obj.items[woItemIndex].parts.length; i++) {
|
||||
if (vm.obj.items[woItemIndex].parts[i].isDirty) {
|
||||
let o = JSON.parse(JSON.stringify(vm.obj.items[woItemIndex].parts[i]));
|
||||
// const o = vm.obj.items[woItemIndex].parts[i];
|
||||
const uid = o.uid;
|
||||
//strip out viz fields before sending
|
||||
o.isDirty = undefined;
|
||||
o.uid = undefined;
|
||||
o.partViz = undefined;
|
||||
o.upcViz = undefined;
|
||||
o.partWarehouseViz = undefined;
|
||||
o.taxPartSaleViz = undefined;
|
||||
o.cost = undefined;
|
||||
o.listPrice = undefined;
|
||||
o.unitOfMeasureViz = undefined;
|
||||
o.priceViz = undefined;
|
||||
o.netViz = undefined;
|
||||
o.taxAViz = undefined;
|
||||
o.taxBViz = undefined;
|
||||
o.partVizlineTotalViz = undefined;
|
||||
o.lineTotalViz = undefined;
|
||||
//clone and skip viz and other fields
|
||||
let o = window.$gz.util.deepCopySkip(vm.obj.items[woItemIndex].parts[i], [
|
||||
"uid",
|
||||
"cost",
|
||||
"listPrice"
|
||||
]);
|
||||
|
||||
const res = await window.$gz.api.upsert(`${API_BASE_URL}items/parts`, o);
|
||||
if (res.error) {
|
||||
//insufficient stock?
|
||||
console.log("part save error:", JSON.parse(JSON.stringify(res.error)));
|
||||
if (res.error.details) {
|
||||
const balanceError = res.error.details.find(z => z.error == "2040");
|
||||
if (balanceError && balanceError.message) {
|
||||
console.log("Insufficient stock ", {
|
||||
balance: Number(balanceError.message.split(":")[1]),
|
||||
obj: vm.obj.items[woItemIndex].parts[i]
|
||||
});
|
||||
//set the amount requestable so it surfaces in the UI and can be requested
|
||||
let balance = window.$gz.util.stringToFloat(balanceError.message);
|
||||
if (balance != null || balance != 0) {
|
||||
vm.obj.items[woItemIndex].parts[i].requestAmountViz =
|
||||
vm.obj.items[woItemIndex].parts[i].quantity - balance;
|
||||
}
|
||||
}
|
||||
|
||||
// {
|
||||
// "code": "2200",
|
||||
// "details": [
|
||||
// {
|
||||
// "message": "available:93.00000",
|
||||
// "target": "Balance",
|
||||
// "error": "2040"
|
||||
// }
|
||||
// ],
|
||||
// "message": "ErrorAPI2200"
|
||||
// }
|
||||
}
|
||||
|
||||
handleSaveError(vm, {
|
||||
@@ -1174,7 +1150,7 @@ async function saveParts(vm, woItemIndex) {
|
||||
error: res.error,
|
||||
itemUid: vm.obj.items[woItemIndex].uid,
|
||||
childKey: "parts",
|
||||
childUid: uid
|
||||
childUid: vm.obj.items[woItemIndex].parts[i].uid
|
||||
});
|
||||
} else {
|
||||
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
|
||||
@@ -2094,6 +2070,7 @@ async function fetchTranslatedText(vm) {
|
||||
"WorkOrderItemPartRequestPartID",
|
||||
"WorkOrderItemPartRequestPartWarehouseID",
|
||||
"WorkOrderItemPartRequestQuantity",
|
||||
"WorkOrderItemPartRequestMore",
|
||||
"PurchaseOrder",
|
||||
"PurchaseOrderExpectedReceiveDate",
|
||||
"PurchaseOrderOrderedDate",
|
||||
|
||||
Reference in New Issue
Block a user