CSR-1642 | Mobile fee not being saved to supporting items fix
This commit is contained in:
parent
89d6e8eb8b
commit
2da09b11b7
1 changed files with 47 additions and 0 deletions
|
|
@ -116,6 +116,8 @@ import store from "@/store";
|
||||||
import { defineRule } from "vee-validate";
|
import { defineRule } from "vee-validate";
|
||||||
import { errorMessages } from "@/constants/error-messages";
|
import { errorMessages } from "@/constants/error-messages";
|
||||||
|
|
||||||
|
const MOBILE_FEE_PART_TYPE = "MOBILE FEE";
|
||||||
|
|
||||||
// DEFINE VALIDATION RULES
|
// DEFINE VALIDATION RULES
|
||||||
defineRule("mobile-location-required", (value) => {
|
defineRule("mobile-location-required", (value) => {
|
||||||
if (
|
if (
|
||||||
|
|
@ -375,6 +377,49 @@ export default {
|
||||||
backButtonAction() {
|
backButtonAction() {
|
||||||
this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
|
this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
|
||||||
},
|
},
|
||||||
|
updateAndSaveSupportingItems() {
|
||||||
|
const supportingItems = store.getters.lineItems.supportingItems;
|
||||||
|
// if we have a mobile fee, then save/update supporting items
|
||||||
|
if (
|
||||||
|
this.selectedAppointmentType == "Mobile"
|
||||||
|
) {
|
||||||
|
const mobileFeeIndex = supportingItems.findIndex(
|
||||||
|
(item) => item.partType == MOBILE_FEE_PART_TYPE
|
||||||
|
);
|
||||||
|
// If it already exists, update the price with latest data
|
||||||
|
if (mobileFeeIndex >= 0) {
|
||||||
|
supportingItems[mobileFeeIndex].laborAmount =
|
||||||
|
this.mobileFeePart.laborAmount;
|
||||||
|
supportingItems[mobileFeeIndex].selingPrice =
|
||||||
|
this.mobileFeePart.selingPrice;
|
||||||
|
supportingItems[mobileFeeIndex].kitPrice =
|
||||||
|
this.mobileFeePart.kitPrice;
|
||||||
|
} else {
|
||||||
|
supportingItems.push(this.mobileFeePart);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dispatchStoreAction(
|
||||||
|
this.storeActions.SAVE_SUPPORTING_ITEMS_SUPPRESSING_STATE_RESETTING,
|
||||||
|
supportingItems,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// if it's not a mobile, then make sure we remove any that may have been added
|
||||||
|
const removeMobileFeeIndex = supportingItems.findIndex(
|
||||||
|
(item) => item.partType == MOBILE_FEE_PART_TYPE
|
||||||
|
);
|
||||||
|
|
||||||
|
if (removeMobileFeeIndex >= 0) {
|
||||||
|
supportingItems.splice(removeMobileFeeIndex, 1);
|
||||||
|
this.dispatchStoreAction(
|
||||||
|
this.storeActions.SAVE_SUPPORTING_ITEMS_SUPPRESSING_STATE_RESETTING,
|
||||||
|
supportingItems,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
await this.dispatchStoreAction(
|
await this.dispatchStoreAction(
|
||||||
this.storeActions.SAVE_SERVICE_LOCATION,
|
this.storeActions.SAVE_SERVICE_LOCATION,
|
||||||
|
|
@ -401,6 +446,8 @@ export default {
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.updateAndSaveSupportingItems();
|
||||||
|
|
||||||
this.$router.navigateWithSaving(
|
this.$router.navigateWithSaving(
|
||||||
this.navigationScenarios.SELECTED_LOCATION,
|
this.navigationScenarios.SELECTED_LOCATION,
|
||||||
this.$route
|
this.$route
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue