This commit is contained in:
2021-06-04 19:13:06 +00:00
parent 8315845d85
commit 1d6f584647
3 changed files with 72 additions and 142 deletions

View File

@@ -365,21 +365,13 @@ 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
see PO back end for example of exactly this
SEEDER
make sure generated inventory and workorders are going to work with enough quantity etc
ODDS / ENDS
replicate new viz strip code to all children save like parts does now
INVENTORY
todo: No inventory setting *IMPORTANT* must test with inventory turned off for this and for PO system as well or whatever is necessary
make it work like v7
NOTE: In v7 selecting serial copied to description field for some reason, but v8 has dedicated serial field so this is probably an import issue i.e. make sure import copies serials to serials
@@ -387,11 +379,7 @@ todo: No inventory setting *IMPORTANT* must test with inventory turned off for t
NEED:
on WO must hide all serial number selection elements if useinventory is off
but it seems reasonable to leave the field to just hand enter them in if desired
WO part selection: if useinventory then must run CheckIfEnoughInventory and offer to request or set to zero
in v7 when useinventory=true you cannot enter a quantity that is more than is in stock, you either initiate a request or it sets it to zero and won't allow any other value
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

View File

@@ -379,12 +379,11 @@ export default {
},
methods: {
doRequest() {
//todo: remove the requestAmountViz and error on edit of partid, warehouse or quantity to prevent ordering the wrong part here if they click on the button after editing those things
const requestQuantity = this.value.items[this.activeWoItemIndex].parts[
this.activeItemIndex
].requestAmountViz;
].requestAmountViz; //set in svc-workorder.vue on save of part with insufficient qty
if (requestQuantity != null && requestQuantity > 0) {
//Get names for UI for request record so user knows it's the right one
let selectedPartWarehouse = this.$refs[
`Items[${this.activeWoItemIndex}].parts[${this.activeItemIndex}].partWarehouseId`
].getFullSelectionValue();
@@ -402,14 +401,14 @@ export default {
selectedPart = selectedPart.name;
}
//change the partquantity
//change the part quantity to the balance in stock
this.value.items[this.activeWoItemIndex].parts[
this.activeItemIndex
].quantity =
this.value.items[this.activeWoItemIndex].parts[this.activeItemIndex]
.quantity - requestQuantity;
//add a request record
//add a request record
this.value.items[this.activeWoItemIndex].partRequests.push({
id: 0,
concurrency: 0,
@@ -426,6 +425,7 @@ export default {
workOrderItemId: this.value.items[this.activeWoItemIndex].id,
uid: Date.now() //used for error tracking / display
});
this.$emit("change");
//clear the error but leave dirty and let user save it

View File

@@ -920,19 +920,18 @@ async function saveUnits(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].units.length; i++) {
if (vm.obj.items[woItemIndex].units[i].isDirty) {
const o = vm.obj.items[woItemIndex].units[i];
const uid = o.uid;
//strip out viz fields before sending
o.isDirty = undefined;
o.uid = undefined;
o.unitViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].units[i],
["uid", "isDirty"]
);
let res = await window.$gz.api.upsert(`${API_BASE_URL}items/units`, o);
if (res.error) {
handleSaveError(vm, {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "units",
childUid: uid
childUid: vm.obj.items[woItemIndex].units[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
@@ -956,13 +955,12 @@ async function saveScheduledUsers(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].scheduledUsers.length; i++) {
if (vm.obj.items[woItemIndex].scheduledUsers[i].isDirty) {
const o = vm.obj.items[woItemIndex].scheduledUsers[i];
const uid = o.uid;
//strip out viz fields before sending
o.isDirty = undefined;
o.uid = undefined;
o.serviceRateViz = undefined;
o.userViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].scheduledUsers[i],
["uid", "isDirty"]
);
const res = await window.$gz.api.upsert(
`${API_BASE_URL}items/scheduled-users`,
o
@@ -972,7 +970,7 @@ async function saveScheduledUsers(vm, woItemIndex) {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "scheduledUsers",
childUid: uid
childUid: vm.obj.items[woItemIndex].scheduledUsers[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
@@ -1028,13 +1026,11 @@ async function saveTasks(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].tasks.length; i++) {
if (vm.obj.items[woItemIndex].tasks[i].isDirty) {
const o = vm.obj.items[woItemIndex].tasks[i];
const uid = o.uid;
//strip out viz fields before sending
o.isDirty = undefined;
o.uid = undefined;
o.statusViz = undefined;
o.completedByUserViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].tasks[i],
["uid", "isDirty"]
);
const res = await window.$gz.api.upsert(`${API_BASE_URL}items/tasks`, o);
if (res.error) {
@@ -1042,7 +1038,7 @@ async function saveTasks(vm, woItemIndex) {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "tasks",
childUid: uid
childUid: vm.obj.items[woItemIndex].tasks[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
@@ -1124,11 +1120,10 @@ 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) {
//clone and skip viz and other fields
let o = window.$gz.util.deepCopySkip(vm.obj.items[woItemIndex].parts[i], [
"uid",
"cost",
"listPrice"
]);
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].parts[i],
["uid", "cost", "listPrice", "isDirty"]
);
const res = await window.$gz.api.upsert(`${API_BASE_URL}items/parts`, o);
if (res.error) {
@@ -1202,19 +1197,12 @@ async function savePartRequests(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].partRequests.length; i++) {
if (vm.obj.items[woItemIndex].partRequests[i].isDirty) {
const o = vm.obj.items[woItemIndex].partRequests[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.purchaseOrderViz = undefined;
o.purchaseOrderIdViz = undefined;
o.purchaseOrderDateViz = undefined;
o.purchaseOrderExpectedDateViz = undefined;
o.purchaseOrderOnOrderViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].partRequests[i],
["uid", "isDirty"]
);
const res = await window.$gz.api.upsert(
`${API_BASE_URL}items/part-requests`,
o
@@ -1224,7 +1212,7 @@ async function savePartRequests(vm, woItemIndex) {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "partRequests",
childUid: uid
childUid: vm.obj.items[woItemIndex].partRequests[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
@@ -1248,22 +1236,11 @@ async function saveLabors(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].labors.length; i++) {
if (vm.obj.items[woItemIndex].labors[i].isDirty) {
const o = vm.obj.items[woItemIndex].labors[i];
const uid = o.uid;
//strip out viz fields before sending
o.isDirty = undefined;
o.uid = undefined;
o.userViz = undefined;
o.serviceRateViz = undefined;
o.taxCodeSaleViz = undefined;
o.costViz = undefined;
o.listPriceViz = undefined;
o.unitOfMeasureViz = undefined;
o.priceViz = undefined;
o.netViz = undefined;
o.taxAViz = undefined;
o.taxBViz = undefined;
o.lineTotalViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].labors[i],
["uid", "isDirty"]
);
const res = await window.$gz.api.upsert(`${API_BASE_URL}items/labors`, o);
if (res.error) {
@@ -1271,7 +1248,7 @@ async function saveLabors(vm, woItemIndex) {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "labors",
childUid: uid
childUid: vm.obj.items[woItemIndex].labors[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
@@ -1323,22 +1300,11 @@ async function saveTravels(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].travels.length; i++) {
if (vm.obj.items[woItemIndex].travels[i].isDirty) {
const o = vm.obj.items[woItemIndex].travels[i];
const uid = o.uid;
//strip out viz fields before sending
o.isDirty = undefined;
o.uid = undefined;
o.userViz = undefined;
o.travelRateViz = undefined;
o.taxCodeSaleViz = undefined;
o.costViz = undefined;
o.listPriceViz = undefined;
o.unitOfMeasureViz = undefined;
o.priceViz = undefined;
o.netViz = undefined;
o.taxAViz = undefined;
o.taxBViz = undefined;
o.lineTotalViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].travels[i],
["uid", "isDirty"]
);
const res = await window.$gz.api.upsert(
`${API_BASE_URL}items/travels`,
@@ -1349,7 +1315,7 @@ async function saveTravels(vm, woItemIndex) {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "travels",
childUid: uid
childUid: vm.obj.items[woItemIndex].travels[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
@@ -1430,16 +1396,11 @@ async function saveExpenses(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].expenses.length; i++) {
if (vm.obj.items[woItemIndex].expenses[i].isDirty) {
const o = vm.obj.items[woItemIndex].expenses[i];
const uid = o.uid;
//strip out viz fields before sending
o.isDirty = undefined;
o.uid = undefined;
o.chargeTaxCodeViz = undefined;
o.userViz = undefined;
o.taxAViz = undefined;
o.taxBViz = undefined;
o.lineTotalViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].expenses[i],
["uid", "isDirty"]
);
const res = await window.$gz.api.upsert(
`${API_BASE_URL}items/expenses`,
@@ -1450,7 +1411,7 @@ async function saveExpenses(vm, woItemIndex) {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "expenses",
childUid: uid
childUid: vm.obj.items[woItemIndex].scheduledUsers[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
@@ -1503,27 +1464,18 @@ async function saveLoans(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].loans.length; i++) {
if (vm.obj.items[woItemIndex].loans[i].isDirty) {
const o = vm.obj.items[woItemIndex].loans[i];
const uid = o.uid;
//strip out viz fields before sending
o.isDirty = undefined;
o.uid = undefined;
o.taxCodeViz = undefined;
o.loanUnitViz = undefined;
o.unitOfMeasureViz = undefined;
o.priceViz = undefined;
o.netViz = undefined;
o.taxAViz = undefined;
o.taxBViz = undefined;
o.lineTotalViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].loans[i],
["uid", "isDirty"]
);
const res = await window.$gz.api.upsert(`${API_BASE_URL}items/loans`, o);
if (res.error) {
handleSaveError(vm, {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "loans",
childUid: uid
childUid: vm.obj.items[woItemIndex].loans[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here
@@ -1579,21 +1531,11 @@ async function saveOutsideServices(vm, woItemIndex) {
for (let i = 0; i < vm.obj.items[woItemIndex].outsideServices.length; i++) {
if (vm.obj.items[woItemIndex].outsideServices[i].isDirty) {
const o = vm.obj.items[woItemIndex].outsideServices[i];
const uid = o.uid;
//strip out viz fields before sending
o.isDirty = undefined;
o.uid = undefined;
o.unitViz = undefined;
o.vendorSentToViz = undefined;
o.vendorSentViaViz = undefined;
o.taxCodeViz = undefined;
o.costViz = undefined;
o.priceViz = undefined;
o.netViz = undefined;
o.taxAViz = undefined;
o.taxBViz = undefined;
o.lineTotalViz = undefined;
//clone and skip viz and other fields
const o = window.$gz.util.deepCopySkip(
vm.obj.items[woItemIndex].outsideServices[i],
["uid", "isDirty"]
);
const res = await window.$gz.api.upsert(
`${API_BASE_URL}items/outside-services`,
@@ -1604,7 +1546,7 @@ async function saveOutsideServices(vm, woItemIndex) {
error: res.error,
itemUid: vm.obj.items[woItemIndex].uid,
childKey: "outsideServices",
childUid: uid
childUid: vm.obj.items[woItemIndex].outsideServices[i].uid
});
} else {
//Server will update fields on put or post for most workorder graph objecs so need to update entire object here