remove early bird from supporting items if it exists but not needed because the appointment changed
This commit is contained in:
CarlNation 2023-06-07 13:07:41 -04:00
parent 7b1f394fae
commit 07079997f0

View file

@ -352,12 +352,13 @@ export default {
}, },
updateSupportingItems() { updateSupportingItems() {
const supportingItems = store.getters.lineItems.supportingItems;
// if we have a premium fee(early bird), then save/update supporting items // if we have a premium fee(early bird), then save/update supporting items
if ( if (
this.appointmentType === AppointmentTypeStrings.MOBILE && this.appointmentType === AppointmentTypeStrings.MOBILE &&
this.selectedTimeSlotData?.isPremiumAppointment this.selectedTimeSlotData?.isPremiumAppointment
) { ) {
const supportingItems = store.getters.lineItems.supportingItems;
const earlyBirdIndex = supportingItems.findIndex( const earlyBirdIndex = supportingItems.findIndex(
(item) => item.partNumber == PREMIUM_FEE_PART_TYPE (item) => item.partNumber == PREMIUM_FEE_PART_TYPE
); );
@ -379,6 +380,17 @@ export default {
false false
); );
} }
else {
// if it's not a mobile and/or premium early bird, then make sure we remove any that may have beedn added
const removeEarlyBirdIndex = supportingItems.findIndex(
(item) => item.partNumber == PREMIUM_FEE_PART_TYPE
);
if (removeEarlyBirdIndex >= 0) {
supportingItems.splice(removeEarlyBirdIndex, 1)
this.dispatchStoreAction(this.storeActions.SAVE_SUPPORTING_ITEMS, supportingItems, false);
}
}
}, },
}, },
watch: { watch: {