This commit is contained in:
2021-05-10 17:33:33 +00:00
parent 021af706cf
commit 56f7b57930
2 changed files with 153 additions and 114 deletions

View File

@@ -36,7 +36,7 @@
</v-col> </v-col>
<template v-if="showTable"> <template v-if="showTable">
<!-- ################################ SCHEDULED USERS TABLE ############################### --> <!-- ############################################################### -->
<v-col cols="12" class="mb-10"> <v-col cols="12" class="mb-10">
<v-data-table <v-data-table
:headers="headerList" :headers="headerList"
@@ -48,7 +48,7 @@
disable-filtering disable-filtering
disable-sort disable-sort
hide-default-footer hide-default-footer
data-cy="scheduledUsersTable" data-cy="expensesTable"
dense dense
:item-class="itemRowClasses" :item-class="itemRowClasses"
@click:row="handleRowClick" @click:row="handleRowClick"
@@ -69,123 +69,118 @@
> >
<v-col <v-col
v-if="form().showMe(this, 'WorkOrderItemScheduledUserStartDate')" v-if="form().showMe(this, 'WorkOrderItemExpenseTotalCost')"
cols="12" cols="12"
sm="6" sm="6"
lg="4" lg="4"
xl="3" xl="3"
> >
<gz-date-time-picker <gz-currency
:label="$ay.t('WorkOrderItemScheduledUserStartDate')"
v-model=" v-model="
value.items[activeWoItemIndex].scheduledUsers[activeItemIndex] value.items[activeWoItemIndex].expenses[activeItemIndex].totalCost
.startDate
"
:readonly="formState.readOnly"
:disabled="isDeleted"
:ref="
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].startDate`
"
data-cy="startDate"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].startDate`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].startDate`
)
"
></gz-date-time-picker>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemScheduledUserStopDate')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-date-time-picker
:label="$ay.t('WorkOrderItemScheduledUserStopDate')"
v-model="
value.items[activeWoItemIndex].scheduledUsers[activeItemIndex]
.stopDate
"
:readonly="formState.readOnly"
:disabled="isDeleted"
:ref="
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].stopDate`
"
data-cy="stopDate"
:rules="[
form().datePrecedence(
this,
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].startDate`,
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].stopDate`
)
]"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].stopDate`
)
"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].stopDate`
)
"
></gz-date-time-picker>
</v-col>
<v-col
v-if="
form().showMe(this, 'WorkOrderItemScheduledUserEstimatedQuantity')
"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-decimal
v-model="
value.items[activeWoItemIndex].scheduledUsers[activeItemIndex]
.estimatedQuantity
" "
:readonly="formState.readOnly || isDeleted" :readonly="formState.readOnly || isDeleted"
:disabled="isDeleted" :disabled="isDeleted"
:label="$ay.t('WorkOrderItemScheduledUserEstimatedQuantity')" :label="$ay.t('WorkOrderItemExpenseTotalCost')"
:ref=" :ref="
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].estimatedQuantity` `Items[${activeWoItemIndex}].expenses[${activeItemIndex}].totalCost`
" "
data-cy="scheduledUsers.EstimatedQuantity" data-cy="scheduledUsers.EstimatedQuantity"
:error-messages=" :error-messages="
form().serverErrors( form().serverErrors(
this, this,
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].estimatedQuantity` `Items[${activeWoItemIndex}].expenses[${activeItemIndex}].totalCost`
) )
" "
:rules="[ :rules="[
form().decimalValid( form().decimalValid(
this, this,
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].estimatedQuantity` `Items[${activeWoItemIndex}].expenses[${activeItemIndex}].totalCost`
), ),
form().required( form().required(
this, this,
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].estimatedQuantity` `Items[${activeWoItemIndex}].expenses[${activeItemIndex}].totalCost`
) )
]" ]"
@input=" @input="
fieldValueChanged(`Items[${activeWoItemIndex}].scheduledUsers[ fieldValueChanged(`Items[${activeWoItemIndex}].expenses[
${activeItemIndex} ${activeItemIndex}
].estimatedQuantity`) ].totalCost`)
" "
></gz-decimal> ></gz-currency>
</v-col> </v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemExpenseName')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<v-text-field
v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex].name
"
:readonly="formState.readOnly"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseName')"
:ref="
`Items[${activeWoItemIndex}].expenses[
${activeItemIndex}
].name`
"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].expenses[
${activeItemIndex}
].name`
)
"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].expenses[
${activeItemIndex}
].name`)
"
></v-text-field>
</v-col>
<v-col
v-if="form().showMe(this, 'WorkOrderItemExpenseDescription')"
cols="12"
>
<v-textarea
v-model="
value.items[activeWoItemIndex].expenses[activeItemIndex]
.description
"
:readonly="formState.readOnly"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemExpenseDescription')"
:error-messages="
form().serverErrors(
this,
`Items[${activeWoItemIndex}].expenses[
${activeItemIndex}
].description`
)
"
:ref="
`Items[${activeWoItemIndex}].expenses[
${activeItemIndex}
].description`
"
data-cy="expenseDescription"
@input="
fieldValueChanged(`Items[${activeWoItemIndex}].expenses[
${activeItemIndex}
].description`)
"
auto-grow
></v-textarea>
</v-col>
-----------------------------------------------------------------------------
<v-col <v-col
v-if="form().showMe(this, 'WorkOrderItemScheduledUserUserID')" v-if="form().showMe(this, 'WorkOrderItemScheduledUserUserID')"
cols="12" cols="12"
@@ -198,25 +193,24 @@
variant="tech" variant="tech"
:show-edit-icon="true" :show-edit-icon="true"
v-model=" v-model="
value.items[activeWoItemIndex].scheduledUsers[activeItemIndex] value.items[activeWoItemIndex].expenses[activeItemIndex].userId
.userId
" "
:readonly="formState.readOnly || isDeleted" :readonly="formState.readOnly || isDeleted"
:disabled="isDeleted" :disabled="isDeleted"
:label="$ay.t('WorkOrderItemScheduledUserUserID')" :label="$ay.t('WorkOrderItemScheduledUserUserID')"
:ref=" :ref="
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].userId` `Items[${activeWoItemIndex}].expenses[${activeItemIndex}].userId`
" "
data-cy="scheduledUsers.userid" data-cy="scheduledUsers.userid"
:error-messages=" :error-messages="
form().serverErrors( form().serverErrors(
this, this,
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].userId` `Items[${activeWoItemIndex}].expenses[${activeItemIndex}].userId`
) )
" "
@input=" @input="
fieldValueChanged( fieldValueChanged(
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].userId` `Items[${activeWoItemIndex}].expenses[${activeItemIndex}].userId`
) )
" "
@update:name="userChange" @update:name="userChange"
@@ -234,25 +228,25 @@
:aya-type="$ay.ayt().ServiceRate" :aya-type="$ay.ayt().ServiceRate"
:show-edit-icon="true" :show-edit-icon="true"
v-model=" v-model="
value.items[activeWoItemIndex].scheduledUsers[activeItemIndex] value.items[activeWoItemIndex].expenses[activeItemIndex]
.serviceRateId .serviceRateId
" "
:readonly="formState.readOnly || isDeleted" :readonly="formState.readOnly || isDeleted"
:disabled="isDeleted" :disabled="isDeleted"
:label="$ay.t('WorkOrderItemScheduledUserServiceRateID')" :label="$ay.t('WorkOrderItemScheduledUserServiceRateID')"
:ref=" :ref="
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].serviceRateId` `Items[${activeWoItemIndex}].expenses[${activeItemIndex}].serviceRateId`
" "
data-cy="scheduledUsers.serviceRateId" data-cy="scheduledUsers.serviceRateId"
:error-messages=" :error-messages="
form().serverErrors( form().serverErrors(
this, this,
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].serviceRateId` `Items[${activeWoItemIndex}].expenses[${activeItemIndex}].serviceRateId`
) )
" "
@input=" @input="
fieldValueChanged( fieldValueChanged(
`Items[${activeWoItemIndex}].scheduledUsers[${activeItemIndex}].serviceRateId` `Items[${activeWoItemIndex}].expenses[${activeItemIndex}].serviceRateId`
) )
" "
@update:name="rateChange" @update:name="rateChange"
@@ -267,8 +261,54 @@
/* XXXeslint-disable */ /* XXXeslint-disable */
//////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* /*
l.Add(new FormField { TKey = "WorkOrderItemExpenseChargeAmount", FieldKey = "WorkOrderItemExpenseChargeAmount", TKeySection = "WorkOrderItemExpense" });
l.Add(new FormField { TKey = "WorkOrderItemExpenseChargeTaxCodeID", FieldKey = "WorkOrderItemExpenseChargeTaxCodeID", TKeySection = "WorkOrderItemExpense" });
l.Add(new FormField { TKey = "WorkOrderItemExpenseTaxPaid", FieldKey = "WorkOrderItemExpenseTaxPaid", TKeySection = "WorkOrderItemExpense" });
l.Add(new FormField { TKey = "WorkOrderItemExpenseChargeToCustomer", FieldKey = "WorkOrderItemExpenseChargeToCustomer", TKeySection = "WorkOrderItemExpense" });
l.Add(new FormField { TKey = "WorkOrderItemExpenseDescription", FieldKey = "WorkOrderItemExpenseDescription", TKeySection = "WorkOrderItemExpense" });
l.Add(new FormField { TKey = "WorkOrderItemExpenseName", FieldKey = "WorkOrderItemExpenseName", TKeySection = "WorkOrderItemExpense" });
l.Add(new FormField { TKey = "WorkOrderItemExpenseReimburseUser", FieldKey = "WorkOrderItemExpenseReimburseUser", TKeySection = "WorkOrderItemExpense" });
l.Add(new FormField { TKey = "WorkOrderItemExpenseTotalCost", FieldKey = "WorkOrderItemExpenseTotalCost", TKeySection = "WorkOrderItemExpense" });
l.Add(new FormField { TKey = "WorkOrderItemExpenseUserID", FieldKey = "WorkOrderItemExpenseUserID", TKeySection = "WorkOrderItemExpense" });
*/
public string Description { get; set; }
public string Name { get; set; }
[Required]
public decimal TotalCost { get; set; }
[Required]
public decimal ChargeAmount { get; set; }
[Required]
public decimal TaxPaid { get; set; }
public long? ChargeTaxCodeId { get; set; }
[NotMapped]
public string ChargeTaxCodeViz { get; set; }
public bool ReimburseUser { get; set; } = false;
public long? UserId { get; set; }
[NotMapped]
public string UserViz { get; set; }
public bool ChargeToCustomer { get; set; } = false;
await ExecQueryAsync("CREATE TABLE aworkorderitemexpense (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid BIGINT NOT NULL REFERENCES aworkorderitem (id), "
+ "description TEXT, name TEXT, totalcost DECIMAL(38,18) NOT NULL default 0, chargeamount DECIMAL(38,18) NOT NULL default 0, taxpaid DECIMAL(38,18) NOT NULL default 0, "
+ "chargetaxcodeid BIGINT REFERENCES ataxcode, reimburseuser BOOL NOT NULL, userid BIGINT REFERENCES auser, chargetocustomer BOOL NOT NULL"
+ ")");
"WorkOrderItemExpenseChargeAmount": "Charge Amount",
"WorkOrderItemExpenseChargeTaxCodeID": "Charge Tax Code",
"WorkOrderItemExpenseChargeToCustomer": "Charge to customer?",
"WorkOrderItemExpenseDescription": "Description",
"WorkOrderItemExpenseList": "Expenses",
"WorkOrderItemExpenseName": "Misc Exp Summary",
"WorkOrderItemExpenseReimburseUser": "Reimburse User?",
"WorkOrderItemExpenseTaxPaid": "Tax Paid",
"WorkOrderItemExpenseTotalCost": "Total Cost",
"WorkOrderItemExpenseUser": "User",
"WorkOrderItemExpenseUserID": "User",
*/
export default { export default {
created() { created() {
this.setDefaultView(); this.setDefaultView();
@@ -302,12 +342,12 @@ export default {
}, },
methods: { methods: {
userChange(newName) { userChange(newName) {
this.value.items[this.activeWoItemIndex].scheduledUsers[ this.value.items[this.activeWoItemIndex].expenses[
this.activeItemIndex this.activeItemIndex
].userViz = newName; ].userViz = newName;
}, },
rateChange(newName) { rateChange(newName) {
this.value.items[this.activeWoItemIndex].scheduledUsers[ this.value.items[this.activeWoItemIndex].expenses[
this.activeItemIndex this.activeItemIndex
].serviceRateViz = newName; ].serviceRateViz = newName;
}, },
@@ -332,13 +372,13 @@ export default {
this.activeItemIndex = newIndex; this.activeItemIndex = newIndex;
}, },
unDeleteItem() { unDeleteItem() {
this.value.items[this.activeWoItemIndex].scheduledUsers[ this.value.items[this.activeWoItemIndex].expenses[
this.activeItemIndex this.activeItemIndex
].deleted = false; ].deleted = false;
this.setDefaultView(); this.setDefaultView();
}, },
deleteItem() { deleteItem() {
this.value.items[this.activeWoItemIndex].scheduledUsers[ this.value.items[this.activeWoItemIndex].expenses[
this.activeItemIndex this.activeItemIndex
].deleted = true; ].deleted = true;
this.setDefaultView(); this.setDefaultView();
@@ -364,7 +404,7 @@ export default {
fieldValueChanged(ref) { fieldValueChanged(ref) {
if (!this.formState.loading && !this.formState.readonly) { if (!this.formState.loading && !this.formState.readonly) {
//flag this record dirty so it gets picked up by save //flag this record dirty so it gets picked up by save
this.value.items[this.activeWoItemIndex].scheduledUsers[ this.value.items[this.activeWoItemIndex].expenses[
this.activeItemIndex this.activeItemIndex
].isDirty = true; ].isDirty = true;
window.$gz.form.fieldValueChanged(this.pvm, ref); window.$gz.form.fieldValueChanged(this.pvm, ref);
@@ -378,7 +418,7 @@ export default {
itemRowClasses: function(item) { itemRowClasses: function(item) {
let ret = ""; let ret = "";
const isDeleted = const isDeleted =
this.value.items[this.activeWoItemIndex].scheduledUsers[item.index] this.value.items[this.activeWoItemIndex].expenses[item.index]
.deleted === true; .deleted === true;
const hasError = this.form().childRowHasError( const hasError = this.form().childRowHasError(
@@ -398,7 +438,7 @@ export default {
computed: { computed: {
isDeleted: function() { isDeleted: function() {
if ( if (
this.value.items[this.activeWoItemIndex].scheduledUsers[ this.value.items[this.activeWoItemIndex].expenses[
this.activeItemIndex this.activeItemIndex
] == null ] == null
) { ) {
@@ -406,9 +446,8 @@ export default {
return true; return true;
} }
return ( return (
this.value.items[this.activeWoItemIndex].scheduledUsers[ this.value.items[this.activeWoItemIndex].expenses[this.activeItemIndex]
this.activeItemIndex .deleted === true
].deleted === true
); );
}, },
parentDeleted: function() { parentDeleted: function() {

View File

@@ -361,16 +361,16 @@
@change="$emit('change')" @change="$emit('change')"
/> />
</v-col> </v-col>
<v-col cols="12"> <v-col cols="12">
<GzWoItemScheduledUsers <GzWoItemExpenses
v-if=" v-if="
pvm.subRights.scheduledUsers.visible && pvm.subRights.expenses.visible &&
form().showMe(this, 'WorkOrderItemScheduledUserList') form().showMe(this, 'WorkOrderItemExpenseList')
" "
v-model="value" v-model="value"
:pvm="pvm" :pvm="pvm"
:active-wo-item-index="activeItemIndex" :active-wo-item-index="activeItemIndex"
data-cy="woItemScheduledUsers" data-cy="woItemExpenses"
@change="$emit('change')" @change="$emit('change')"
/> />
</v-col> </v-col>