This commit is contained in:
2021-06-02 16:02:03 +00:00
parent 1d199ac678
commit 579b2addd3
2 changed files with 83 additions and 5 deletions

View File

@@ -482,7 +482,7 @@ export default {
// serviceStopDate: window.$gz.locale.nowUTC8601String(), //TODO:sb now plus one hour to match v7
serviceRateId: null,
serviceDetails: null,
serviceRateQuantity: 1,
serviceRateQuantity: 0,
noChargeQuantity: 0,
serviceBankId: null,
taxCodeSaleId: null,
@@ -605,7 +605,6 @@ export default {
} else {
//Existing record or both dates filled, just update quantity
if (dStart != null) {
console.log("setting serviceRateQuantity");
this.value.items[this.activeWoItemIndex].labors[
this.activeItemIndex
].serviceRateQuantity = window.$gz.locale.diffHoursFromUTC8601String(

View File

@@ -475,11 +475,11 @@ export default {
id: 0,
concurrency: 0,
userId: null,
travelStartDate: window.$gz.locale.nowUTC8601String(),
travelStopDate: window.$gz.locale.nowUTC8601String(), //TODO:sb now plus one hour to match v7
travelStartDate: null,
travelStopDate: null,
travelRateId: null,
travelDetails: null,
travelRateQuantity: 1,
travelRateQuantity: 0,
noChargeQuantity: 0,
serviceBankId: null,
taxCodeSaleId: null,
@@ -530,6 +530,85 @@ export default {
this.activeItemIndex
].isDirty = true;
window.$gz.form.fieldValueChanged(this.pvm, ref);
//------- SPECIAL HANDLING OF CHANGES -----------
const isNew =
this.value.items[this.activeWoItemIndex].travels[this.activeItemIndex]
.id == 0;
//Auto calculate dates / quantities / global defaults
const dStart = this.value.items[this.activeWoItemIndex].travels[
this.activeItemIndex
].travelStartDate;
const dStop = this.value.items[this.activeWoItemIndex].travels[
this.activeItemIndex
].travelStopDate;
if (ref.includes("travelStartDate") && dStart != null) {
this.handleStartDateChange(isNew, dStart, dStop);
}
if (ref.includes("travelStopDate") && dStop != null) {
this.handleStopDateChange(isNew, dStart, dStop);
}
//------------------------------------------------------
}
},
handleStartDateChange: function(isNew, dStart, dStop) {
const globalMinutes =
window.$gz.store.state.globalSettings.workOrderTravelDefaultMinutes;
if (isNew && dStop == null) {
if (globalMinutes != 0) {
//set stop date based on start date and global minutes
this.value.items[this.activeWoItemIndex].travels[
this.activeItemIndex
].travelStopDate = window.$gz.locale.addMinutesToUTC8601String(
dStart,
globalMinutes
);
this.value.items[this.activeWoItemIndex].travels[
this.activeItemIndex
].travelRateQuantity = globalMinutes;
}
} else {
//Existing record or both dates filled, just update quantity
if (dStop != null) {
this.value.items[this.activeWoItemIndex].travels[
this.activeItemIndex
].travelRateQuantity = window.$gz.locale.diffHoursFromUTC8601String(
dStart,
dStop
);
}
}
},
handleStopDateChange: function(isNew, dStart, dStop) {
const globalMinutes =
window.$gz.store.state.globalSettings.workOrderTravelDefaultMinutes;
if (isNew && dStart == null) {
if (globalMinutes != 0) {
//set start date based on stop date and global minutes
this.value.items[this.activeWoItemIndex].travels[
this.activeItemIndex
].travelStartDate = window.$gz.locale.addMinutesToUTC8601String(
dStop,
0 - globalMinutes
);
this.value.items[this.activeWoItemIndex].travels[
this.activeItemIndex
].travelRateQuantity = globalMinutes;
}
} else {
//Existing record or both dates filled, just update quantity
if (dStart != null) {
this.value.items[this.activeWoItemIndex].travels[
this.activeItemIndex
].travelRateQuantity = window.$gz.locale.diffHoursFromUTC8601String(
dStart,
dStop
);
}
}
},
itemRowClasses: function(item) {