This commit is contained in:
@@ -244,6 +244,7 @@ export default {
|
||||
"ErrorAPI2010",
|
||||
"ErrorAPI2020",
|
||||
"ErrorAPI2030",
|
||||
"ErrorAPI2040",
|
||||
"ErrorAPI2200",
|
||||
"ErrorAPI2201",
|
||||
"ErrorAPI2202",
|
||||
|
||||
@@ -1123,7 +1123,8 @@ 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) {
|
||||
const o = vm.obj.items[woItemIndex].parts[i];
|
||||
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;
|
||||
@@ -1144,7 +1145,32 @@ async function saveParts(vm, woItemIndex) {
|
||||
|
||||
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]
|
||||
});
|
||||
}
|
||||
|
||||
// {
|
||||
// "code": "2200",
|
||||
// "details": [
|
||||
// {
|
||||
// "message": "available:93.00000",
|
||||
// "target": "Balance",
|
||||
// "error": "2040"
|
||||
// }
|
||||
// ],
|
||||
// "message": "ErrorAPI2200"
|
||||
// }
|
||||
}
|
||||
|
||||
handleSaveError(vm, {
|
||||
//todo handle insufficient quantity error 2040
|
||||
error: res.error,
|
||||
itemUid: vm.obj.items[woItemIndex].uid,
|
||||
childKey: "parts",
|
||||
|
||||
Reference in New Issue
Block a user