This commit is contained in:
2021-05-10 19:05:12 +00:00
parent 56f7b57930
commit 5736152864

View File

@@ -68,48 +68,6 @@
}}<v-icon right large>$ayiTrashRestoreAlt</v-icon></v-btn }}<v-icon right large>$ayiTrashRestoreAlt</v-icon></v-btn
> >
<v-col
v-if="form().showMe(this, 'WorkOrderItemExpenseTotalCost')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-currency
v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex].totalCost
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseTotalCost')"
:ref="
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].totalCost`
"
data-cy="scheduledUsers.EstimatedQuantity"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].totalCost`
)
"
:rules="[
form().decimalValid(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].totalCost`
),
form().required(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].totalCost`
)
]"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].expenses[
${activeItemIndex}
].totalCost`)
"
></gz-currency>
</v-col>
<v-col <v-col
v-if="form().showMe(this, 'WorkOrderItemExpenseName')" v-if="form().showMe(this, 'WorkOrderItemExpenseName')"
cols="12" cols="12"
@@ -145,6 +103,271 @@
></v-text-field> ></v-text-field>
</v-col> </v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemExpenseTotalCost')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-currency
v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex].totalCost
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseTotalCost')"
:ref="
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].totalCost`
"
data-cy="expenseTotalCost"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].totalCost`
)
"
:rules="[
form().decimalValid(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].totalCost`
),
form().required(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].totalCost`
)
]"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].expenses[
${activeItemIndex}
].totalCost`)
"
></gz-currency>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemExpenseChargeAmount')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-currency
v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex]
.chargeAmount
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseChargeAmount')"
:ref="
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeAmount`
"
data-cy="expenseChargeAmount"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeAmount`
)
"
:rules="[
form().decimalValid(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeAmount`
),
form().required(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeAmount`
)
]"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].expenses[
${activeItemIndex}
].chargeAmount`)
"
></gz-currency>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemExpenseChargeToCustomer')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<v-checkbox
v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex]
.chargeToCustomer
"
:readonly="formState.readOnly"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseChargeToCustomer')"
:ref="
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeToCustomer`
"
data-cy="chargeToCustomer"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeToCustomer`
)
"
@change="
fieldValueChanged(`Items[${activeWoItemIndex}].expenses[
${activeItemIndex}
].chargeToCustomer`)
"
></v-checkbox>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemExpenseTaxPaid')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-currency
v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex].taxPaid
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseTaxPaid')"
:ref="
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].taxPaid`
"
data-cy="expenseTaxPaid"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].taxPaid`
)
"
:rules="[
form().decimalValid(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].taxPaid`
),
form().required(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].taxPaid`
)
]"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].expenses[
${activeItemIndex}
].taxPaid`)
"
></gz-currency>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemExpenseChargeTaxCodeID')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-pick-list
:aya-type="$ay.ayt().TaxCode"
:show-edit-icon="true"
v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex]
.chargeTaxCodeId
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseChargeTaxCodeID')"
:ref="
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeTaxCodeId`
"
data-cy="expenseChargeTaxCode"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeTaxCodeId`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].chargeTaxCodeId`
)
"
@update:name="taxCodeChange"
></gz-pick-list>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemExpenseReimburseUser')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<v-checkbox
v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex]
.reimburseUser
"
:readonly="formState.readOnly"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseReimburseUser')"
:ref="
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].reimburseUser`
"
data-cy="expenseReimburseUser"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].reimburseUser`
)
"
@change="
fieldValueChanged(`Items[${activeWoItemIndex}].expenses[
${activeItemIndex}
].reimburseUser`)
"
></v-checkbox>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemExpenseUserID')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-pick-list
:aya-type="$ay.ayt().User"
variant="tech"
:show-edit-icon="true"
v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex].userId
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseUserID')"
:ref="
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].userId`
"
data-cy="expenseUser"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].userId`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].userId`
)
"
@update:name="userChange"
></gz-pick-list>
</v-col>
<v-col <v-col
v-if="form().showMe(this, 'WorkOrderItemExpenseDescription')" v-if="form().showMe(this, 'WorkOrderItemExpenseDescription')"
cols="12" cols="12"
@@ -181,77 +404,6 @@
</v-col> </v-col>
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
<v-col
v-if="form().showMe(this, 'WorkOrderItemScheduledUserUserID')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-pick-list
:aya-type="$ay.ayt().User"
variant="tech"
:show-edit-icon="true"
v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex].userId
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemScheduledUserUserID')"
:ref="
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].userId`
"
data-cy="scheduledUsers.userid"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].userId`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].userId`
)
"
@update:name="userChange"
></gz-pick-list>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemScheduledUserServiceRateID')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-pick-list
:aya-type="$ay.ayt().ServiceRate"
:show-edit-icon="true"
v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex]
.serviceRateId
"
:readonly="formState.readOnly || isDeleted"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemScheduledUserServiceRateID')"
:ref="
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].serviceRateId`
"
data-cy="scheduledUsers.serviceRateId"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].serviceRateId`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].expenses[${activeItemIndex}].serviceRateId`
)
"
@update:name="rateChange"
></gz-pick-list>
</v-col>
</template> </template>
</v-row> </v-row>
</div> </div>
@@ -346,16 +498,15 @@ export default {
this.activeItemIndex this.activeItemIndex
].userViz = newName; ].userViz = newName;
}, },
rateChange(newName) { taxCodeChange(newName) {
this.value.items[this.activeWoItemIndex].expenses[ this.value.items[this.activeWoItemIndex].expenses[
this.activeItemIndex this.activeItemIndex
].serviceRateViz = newName; ].chargeTaxCodeViz = newName;
}, },
newItem() { newItem() {
let newIndex = this.value.items[this.activeWoItemIndex].scheduledUsers let newIndex = this.value.items[this.activeWoItemIndex].expenses.length;
.length;
this.value.items[this.activeWoItemIndex].scheduledUsers.push({ this.value.items[this.activeWoItemIndex].expenses.push({
id: 0, id: 0,
concurrency: 0, concurrency: 0,
userId: null, userId: null,
@@ -386,7 +537,7 @@ export default {
}, },
setDefaultView: function() { setDefaultView: function() {
//if only one record left then display it otherwise just let the datatable show what the user can click on //if only one record left then display it otherwise just let the datatable show what the user can click on
if (this.value.items[this.activeWoItemIndex].scheduledUsers.length == 1) { if (this.value.items[this.activeWoItemIndex].expenses.length == 1) {
this.selectedRow = [{ index: 0 }]; this.selectedRow = [{ index: 0 }];
this.activeItemIndex = 0; this.activeItemIndex = 0;
} else { } else {
@@ -423,7 +574,7 @@ export default {
const hasError = this.form().childRowHasError( const hasError = this.form().childRowHasError(
this, this,
`Items[${this.activeWoItemIndex}].ScheduledUsers[${item.index}].` `Items[${this.activeWoItemIndex}].Expenses[${item.index}].`
); );
if (isDeleted) { if (isDeleted) {
@@ -461,77 +612,99 @@ export default {
*/ */
let headers = []; let headers = [];
if (this.form().showMe(this, "WorkOrderItemScheduledUserStartDate")) { if (this.form().showMe(this, "WorkOrderItemExpenseName")) {
headers.push({ headers.push({
text: this.$ay.t("WorkOrderItemScheduledUserStartDate"), text: this.$ay.t("WorkOrderItemExpenseName"),
align: "right", align: "left",
value: "startDate" value: "name"
}); });
} }
if (this.form().showMe(this, "WorkOrderItemScheduledUserStopDate")) { if (this.form().showMe(this, "WorkOrderItemExpenseTotalCost")) {
headers.push({ headers.push({
text: this.$ay.t("WorkOrderItemScheduledUserStopDate"), text: this.$ay.t("WorkOrderItemExpenseTotalCost"),
align: "right", align: "right",
value: "stopDate" value: "totalCost"
}); });
} }
if ( if (this.form().showMe(this, "WorkOrderItemExpenseChargeAmount")) {
this.form().showMe(this, "WorkOrderItemScheduledUserEstimatedQuantity")
) {
headers.push({ headers.push({
text: this.$ay.t("WorkOrderItemScheduledUserEstimatedQuantity"), text: this.$ay.t("WorkOrderItemExpenseChargeAmount"),
align: "right", align: "right",
value: "estimatedQuantity" value: "chargeAmount"
}); });
} }
if (this.form().showMe(this, "WorkOrderItemScheduledUserUserID")) { if (this.form().showMe(this, "WorkOrderItemExpenseChargeToCustomer")) {
headers.push({ headers.push({
text: this.$ay.t("WorkOrderItemScheduledUserUserID"), text: this.$ay.t("WorkOrderItemExpenseChargeToCustomer"),
align: "center",
value: "chargeToCustomer"
});
}
if (this.form().showMe(this, "WorkOrderItemExpenseTaxPaid")) {
headers.push({
text: this.$ay.t("WorkOrderItemExpenseTaxPaid"),
align: "right",
value: "taxPaid"
});
}
if (this.form().showMe(this, "WorkOrderItemExpenseChargeTaxCodeID")) {
headers.push({
text: this.$ay.t("WorkOrderItemExpenseChargeTaxCodeID"),
align: "left",
value: "chargeTaxCodeViz"
});
}
if (this.form().showMe(this, "WorkOrderItemExpenseReimburseUser")) {
headers.push({
text: this.$ay.t("WorkOrderItemExpenseReimburseUser"),
align: "center",
value: "reimburseUser"
});
}
if (this.form().showMe(this, "WorkOrderItemExpenseUserID")) {
headers.push({
text: this.$ay.t("WorkOrderItemExpenseUserID"),
align: "left", align: "left",
value: "userViz" value: "userViz"
}); });
} }
if (this.form().showMe(this, "WorkOrderItemScheduledUserServiceRateID")) {
headers.push({
text: this.$ay.t("WorkOrderItemScheduledUserServiceRateID"),
align: "left",
value: "serviceRateViz"
});
}
return headers; return headers;
}, },
itemList: function() { itemList: function() {
return this.value.items[this.activeWoItemIndex].scheduledUsers.map( return this.value.items[this.activeWoItemIndex].expenses.map((x, i) => {
(x, i) => { return {
return { index: i,
index: i, id: x.id,
id: x.id, name: x.name,
startDate: window.$gz.locale.utcDateToShortDateAndTimeLocalized( totalCost: window.$gz.locale.currencyLocalized(
x.startDate, x.totalCost,
this.pvm.timeZoneName, this.pvm.languageName,
this.pvm.languageName, this.pvm.currencyName
this.pvm.hour12 ),
), chargeAmount: window.$gz.locale.currencyLocalized(
stopDate: window.$gz.locale.utcDateToShortDateAndTimeLocalized( x.chargeAmount,
x.stopDate, this.pvm.languageName,
this.pvm.timeZoneName, this.pvm.currencyName
this.pvm.languageName, ),
this.pvm.hour12 chargeToCustomer: x.chargeToCustomer,
), taxPaid: window.$gz.locale.currencyLocalized(
estimatedQuantity: window.$gz.locale.decimalLocalized( x.taxPaid,
x.estimatedQuantity, this.pvm.languageName,
this.pvm.languageName this.pvm.currencyName
), ),
userViz: x.userViz, chargeTaxCodeViz: x.chargeTaxCodeViz,
serviceRateViz: x.serviceRateViz reimburseUser: x.reimburseUser,
}; userViz: x.userViz
} };
); });
}, },
formState: function() { formState: function() {
return this.pvm.formState; return this.pvm.formState;
@@ -540,16 +713,16 @@ export default {
return this.pvm.formCustomTemplateKey; return this.pvm.formCustomTemplateKey;
}, },
showTable: function() { showTable: function() {
return this.value.items[this.activeWoItemIndex].scheduledUsers.length > 1; return this.value.items[this.activeWoItemIndex].expenses.length > 1;
}, },
canAdd: function() { canAdd: function() {
return this.pvm.rights.change && this.pvm.subRights.scheduledUsers.create; return this.pvm.rights.change && this.pvm.subRights.expenses.create;
}, },
canDelete: function() { canDelete: function() {
return ( return (
this.activeItemIndex != null && this.activeItemIndex != null &&
this.pvm.rights.change && this.pvm.rights.change &&
this.pvm.subRights.scheduledUsers.delete this.pvm.subRights.expenses.delete
); );
} }
} }