diff --git a/ayanova/src/api/gzutil.js b/ayanova/src/api/gzutil.js index 57eb5c22..766578d0 100644 --- a/ayanova/src/api/gzutil.js +++ b/ayanova/src/api/gzutil.js @@ -187,7 +187,7 @@ export default { } let wasNegative = number < 0; if (wasNegative) { - number = Match.abs(number); //make sure it's positive because rounding negative numbers is weird in JS + number = Math.abs(number); //make sure it's positive because rounding negative numbers is weird in JS } number = Number( Math.round(number + "e" + decimalPlaces) + "e-" + decimalPlaces diff --git a/ayanova/src/components/work-order-item-scheduled-users.vue b/ayanova/src/components/work-order-item-scheduled-users.vue index 4ef3a424..e8b7c749 100644 --- a/ayanova/src/components/work-order-item-scheduled-users.vue +++ b/ayanova/src/components/work-order-item-scheduled-users.vue @@ -402,10 +402,10 @@ export default { const dStop = this.value.items[this.activeWoItemIndex].scheduledUsers[ this.activeItemIndex ].stopDate; - if (ref.includes("startDate")) { + if (ref.includes("startDate") && dStart != null) { this.handleStartDateChange(isNew, dStart, dStop); } - if (ref.includes("stopDate")) { + if (ref.includes("stopDate") && dStop != null) { this.handleStopDateChange(isNew, dStart, dStop); } if (ref.includes("estimatedQuantity")) { @@ -414,27 +414,33 @@ export default { } }, handleStartDateChange: function(isNew, dStart, dStop) { - if (isNew) { - // (ONLY IF GLOBAL DEFAULT QTY) enter start date when stop date is null then it will add global default to start and set stop and qty + const globalMinutes = + window.$gz.store.state.globalSettings.workLaborScheduleDefaultMinutes; - // If no global default then it acts like existing and updates qty or stop date when qty changes (if there are dates to go on) + if (isNew && dStop == null) { + if (globalMinutes != 0) { + //set stop date based on start date and global minutes + this.value.items[this.activeWoItemIndex].scheduledUsers[ + this.activeItemIndex + ].stopDate = window.$gz.locale.addMinutesToUTC8601String( + dStart, + globalMinutes + ); - const globalMinutes = - window.$gz.store.state.globalSettings.workLaborScheduleDefaultMinutes; - if (globalMinutes == 0) { - return; + this.value.items[this.activeWoItemIndex].scheduledUsers[ + this.activeItemIndex + ].estimatedQuantity = globalMinutes; } - let d = window.$gz.locale.addMinutesToUTC8601String(dStart); } else { - // Existing - // update quantity when dates change or update stop date when quantity changes to match - // no consideration for global default, once it's made that shit doesn't apply - this.value.items[this.activeWoItemIndex].scheduledUsers[ - this.activeItemIndex - ].estimatedQuantity = window.$gz.locale.diffHoursFromUTC8601String( - dStart, - dStop - ); + //Existing record or both dates filled, just update quantity + if (dStop != null) { + this.value.items[this.activeWoItemIndex].scheduledUsers[ + this.activeItemIndex + ].estimatedQuantity = window.$gz.locale.diffHoursFromUTC8601String( + dStart, + dStop + ); + } } }, handleStopDateChange: function(isNew, dStart, dStop) {