Ensured that promo added line items are taxed
This commit is contained in:
parent
ff8d7a6f6e
commit
5238b9a987
2 changed files with 25 additions and 0 deletions
|
|
@ -112,6 +112,7 @@ export async function revalidatePromosAndValidateQueryStringPromo(
|
|||
pageNameToLog,
|
||||
false
|
||||
);
|
||||
|
||||
const revalidationErrorPromoCodes = revalidatePromoResponse.errors.map((x) => x.promoCode);
|
||||
baseMixin.methods.dispatchStoreAction(
|
||||
storeActions.SAVE_ACTIVE_AND_OR_INACTIVE_PROMOS,
|
||||
|
|
@ -122,6 +123,7 @@ export async function revalidatePromosAndValidateQueryStringPromo(
|
|||
false
|
||||
);
|
||||
}
|
||||
|
||||
if (hasNewPromo) {
|
||||
validatePromoResponse = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA,
|
||||
|
|
@ -132,6 +134,7 @@ export async function revalidatePromosAndValidateQueryStringPromo(
|
|||
pageNameToLog,
|
||||
false
|
||||
);
|
||||
|
||||
if (validatePromoResponse.errorCode == null) {
|
||||
// Save promo to store
|
||||
const activePromos = store.getters.order.lineItems.promos ?? [];
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ import { defineRule } from "vee-validate";
|
|||
import { required } from "@/helpers/validation-rules";
|
||||
import { errorMessages } from "@/constants/error-messages";
|
||||
import { AppointmentTypeStrings } from "@/constants/schedule-constants";
|
||||
import { partTypeStrings } from "@/constants/part-type-strings";
|
||||
import { mapTaxedLineItemsToStoreFormat } from "../../store";
|
||||
|
||||
defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
|
||||
|
|
@ -378,6 +379,27 @@ export default {
|
|||
);
|
||||
}
|
||||
|
||||
// Because we don't yet have a robust solution for part interchange ...
|
||||
// if there are front wiper line items in the revalidate response, we need to delete any existing front wiper line items from the store
|
||||
// and replace them with those that come back from revalidation.
|
||||
const revalidateResponseHasFrontWiperLineItems =
|
||||
revalidatePromoResponse.promoLineItems.find(
|
||||
lineItem => lineItem.partType == partTypeStrings.FRONT_WIPER).length > 0;
|
||||
|
||||
if (revalidateResponseHasFrontWiperLineItems) {
|
||||
const frontWiperLineItemsInStore = this.lineItems.vaps.find(lineItem => lineItem.partType == partTypeStrings.FRONT_WIPER);
|
||||
if (frontWiperLineItemsInStore.length > 0) {
|
||||
this.lineItems.vaps = this.lineItems.vaps.find(lineItem => lineItem.partType != partTypeStrings.FRONT_WIPER);
|
||||
}
|
||||
}
|
||||
|
||||
const vapsToAddToCart = getVapsThatNeedToBeAddedToSatisfyPromos(
|
||||
revalidatePromoResponse.promoLineItems,
|
||||
this.availableVaps,
|
||||
this.lineItems
|
||||
);
|
||||
this.lineItems.vaps.push(...vapsToAddToCart);
|
||||
|
||||
this.lineItems.promos = revalidatePromoResponse.promoLineItems;
|
||||
this.inactivePromos = revalidatePromoResponse.errors.map((x) =>
|
||||
getPromoCodeWithoutBundleIdentifier(x.promoCode)
|
||||
|
|
|
|||
Loading…
Reference in a new issue