This commit is contained in:
@@ -365,6 +365,15 @@ todo: many biz objects are not using new PUT methodology
|
||||
CURRENTLY DOING: workorder round two electric boogaloo
|
||||
basics first then increasingly esoteric features
|
||||
|
||||
currently: request button implementations
|
||||
make the button actually do the work
|
||||
trigger a route that adds a request and then insert it into the object tree so it appears
|
||||
maybe though it's done from the parts form but signals to the svc-workorder header to do the actual work??
|
||||
or maybe better in the part form as a separation of concerns issue and part does have access to the full object so can
|
||||
easily insert it into the tree!!!!!!
|
||||
handle the case where the inventory changes after error but before click
|
||||
both ways: has enough all of a sudden or has even less all of a sudden
|
||||
|
||||
Biggies
|
||||
todo 3: actual inventory
|
||||
1961 / 3752- auto remove from inventory immediately when wo saved and re-instate if changed
|
||||
@@ -383,8 +392,9 @@ todo: No inventory setting *IMPORTANT* must test with inventory turned off for t
|
||||
so this must be replicated in v8 exactly and dynamically, not from server itself, but server must still check at last moment of save and return error if unavailable
|
||||
See v7 project workorderform.cs line 8878 for the code in question
|
||||
Proper error messages that are localized and must display correctly in UI at the source of the woitempart error
|
||||
|
||||
|
||||
todo: workorder save method is using a shallow clone by reference for each object NOT a copy as intended which is killing the error system as UID is being wiped
|
||||
See Part save for a clone method using json parse and stringify, but maybe that's shit and need something better
|
||||
|
||||
todo 3: service bank
|
||||
todo 3: notification
|
||||
|
||||
@@ -125,6 +125,26 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
///////////////////////////////
|
||||
// DEEP COPY FOR API UPDATE
|
||||
// Deep copy an object skipping all *Viz and named properties from object
|
||||
//
|
||||
deepCopySkip: function(source, skipNames) {
|
||||
if (skipNames == null) {
|
||||
skipNames = [];
|
||||
}
|
||||
let o = {};
|
||||
for (let key in source) {
|
||||
if (
|
||||
!key.endsWith("Viz") &&
|
||||
!skipNames.some(x => x == key) &&
|
||||
source.hasOwnProperty(key)
|
||||
) {
|
||||
o[key] = source[key];
|
||||
}
|
||||
}
|
||||
return o;
|
||||
},
|
||||
/**
|
||||
* Copy a string to clipboard
|
||||
* @param {String} string The string to be copied to clipboard
|
||||
|
||||
@@ -110,6 +110,20 @@
|
||||
].quantity`)
|
||||
"
|
||||
></gz-decimal>
|
||||
<template
|
||||
v-if="
|
||||
value.items[activeWoItemIndex].parts[activeItemIndex]
|
||||
.requestAmountViz != null
|
||||
"
|
||||
>
|
||||
<v-btn text @click="doRequest()">
|
||||
<v-icon left>
|
||||
$ayiParachuteBox
|
||||
</v-icon>
|
||||
|
||||
{{ requestMore }}
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-col>
|
||||
|
||||
<v-col
|
||||
@@ -466,6 +480,15 @@ export default {
|
||||
//---
|
||||
},
|
||||
computed: {
|
||||
requestMore: function() {
|
||||
return this.$ay
|
||||
.t("WorkOrderItemPartRequestMore")
|
||||
.replace(
|
||||
"{n}",
|
||||
this.value.items[this.activeWoItemIndex].parts[this.activeItemIndex]
|
||||
.requestAmountViz
|
||||
);
|
||||
},
|
||||
isDeleted: function() {
|
||||
if (
|
||||
this.value.items[this.activeWoItemIndex].parts[this.activeItemIndex] ==
|
||||
|
||||
@@ -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