Merge branch 'develop' into nation/CASH-1637
This commit is contained in:
commit
e65a6ca96d
3 changed files with 11 additions and 114 deletions
|
|
@ -35,7 +35,7 @@
|
||||||
:isNoComp="isNoComp"
|
:isNoComp="isNoComp"
|
||||||
:isExpandedOnLoad="false"
|
:isExpandedOnLoad="false"
|
||||||
:isMSRFeeApplicable="isMSRFeeApplicable"
|
:isMSRFeeApplicable="isMSRFeeApplicable"
|
||||||
@itemRemoved="reTaxItemsOnOrder" />
|
@itemRemoved="evaluatePromosAndTaxItemsOnOrder" />
|
||||||
|
|
||||||
<afterpayBreakout
|
<afterpayBreakout
|
||||||
v-if="isAfterpayBreakoutDisplay"
|
v-if="isAfterpayBreakoutDisplay"
|
||||||
|
|
@ -589,7 +589,13 @@ export default {
|
||||||
this.pageName
|
this.pageName
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
async reTaxItemsOnOrder() {
|
async evaluatePromosAndTaxItemsOnOrder() {
|
||||||
|
//Revalidate promos if there are any inactive, or active promos
|
||||||
|
const hasInactivePromos = this.inactivePromos.length > 0;
|
||||||
|
const hasActivePromos = this.lineItems.promos.length > 0;
|
||||||
|
if (hasInactivePromos || hasActivePromos) {
|
||||||
|
await this.revalidatePromos();
|
||||||
|
}
|
||||||
this.lineItems = await baseMixin.methods.dispatchStoreActionWithLogging(
|
this.lineItems = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
storeActions.TAX_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
storeActions.TAX_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,6 @@ describe("payment.vue", () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(vmMock.availableVaps).not.toBeUndefined();
|
|
||||||
expect(vmMock.lineItems).not.toBeUndefined();
|
expect(vmMock.lineItems).not.toBeUndefined();
|
||||||
|
|
||||||
expect(vmMock.setCmsContent).toBeCalled();
|
expect(vmMock.setCmsContent).toBeCalled();
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
<cart
|
<cart
|
||||||
ref="cart"
|
ref="cart"
|
||||||
:damage="damageInfo"
|
:damage="damageInfo"
|
||||||
:availableVaps="availableVaps"
|
:availableVaps="[]"
|
||||||
:allowItemRemoval="false"
|
:allowItemRemoval="false"
|
||||||
v-model="lineItems"
|
v-model="lineItems"
|
||||||
servicePackageOptionsCmsName="ServicePackageTitle"
|
servicePackageOptionsCmsName="ServicePackageTitle"
|
||||||
|
|
@ -237,25 +237,11 @@ import { applicationConfig } from "@/constants/application-config";
|
||||||
import { paymentMethods } from "@/constants/payment-method-constants";
|
import { paymentMethods } from "@/constants/payment-method-constants";
|
||||||
import { AppointmentTypeStrings } from "@/constants/schedule-constants";
|
import { AppointmentTypeStrings } from "@/constants/schedule-constants";
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
import { mapTaxedLineItemsToStoreFormat } from "../../store";
|
|
||||||
import {
|
|
||||||
revalidatePromosAndValidateQueryStringPromo,
|
|
||||||
getAddableVapsFromAvailableLineItems,
|
|
||||||
getVapsThatNeedToBeAddedToSatisfyPromos,
|
|
||||||
} from "@/helpers/promotions-helper";
|
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
|
||||||
import { getQuerystringParameter } from "@/helpers/querystring-helper";
|
|
||||||
import { deepClone } from "@/helpers/object-helper";
|
import { deepClone } from "@/helpers/object-helper";
|
||||||
import { submitWorkOrder } from "@/helpers/heritage-integration/order-helper.js";
|
import { submitWorkOrder } from "@/helpers/heritage-integration/order-helper.js";
|
||||||
import iframeResize from "../../../node_modules/iframe-resizer/js/iframeResizer.js";
|
import iframeResize from "../../../node_modules/iframe-resizer/js/iframeResizer.js";
|
||||||
import { coverageStatus } from "@/constants/insurance";
|
import { coverageStatus } from "@/constants/insurance";
|
||||||
import { getBoolFromString } from "@/helpers/boolean-helper.js";
|
import { getDisplayAmountDue, getAmountDue } from "@/helpers/pricing-helper.js";
|
||||||
import {
|
|
||||||
getDisplayAmountDue,
|
|
||||||
getAmountDue,
|
|
||||||
getSubTotal,
|
|
||||||
getSalesTax,
|
|
||||||
} from "@/helpers/pricing-helper.js";
|
|
||||||
import { debugLog } from "@/helpers/debug-log-helper.js";
|
import { debugLog } from "@/helpers/debug-log-helper.js";
|
||||||
import buttonQuestion from "@/digital-components/button-question/button-question";
|
import buttonQuestion from "@/digital-components/button-question/button-question";
|
||||||
import paymentMethodListButton from "@/layouts/payment-method/payment-method-question/payment-method-list-button/payment-method-list-button";
|
import paymentMethodListButton from "@/layouts/payment-method/payment-method-question/payment-method-list-button/payment-method-list-button";
|
||||||
|
|
@ -290,7 +276,6 @@ export default {
|
||||||
displayAmount: this.getDisplayAmountDue(),
|
displayAmount: this.getDisplayAmountDue(),
|
||||||
piaLineItems: "",
|
piaLineItems: "",
|
||||||
lineItems: [],
|
lineItems: [],
|
||||||
availableVaps: [],
|
|
||||||
shouldBlockInteraction: false,
|
shouldBlockInteraction: false,
|
||||||
paymentMethodListButton: paymentMethodListButton,
|
paymentMethodListButton: paymentMethodListButton,
|
||||||
showSwitchPaymentMethod: !this.isAfterpay(),
|
showSwitchPaymentMethod: !this.isAfterpay(),
|
||||||
|
|
@ -321,21 +306,6 @@ export default {
|
||||||
"payment"
|
"payment"
|
||||||
);
|
);
|
||||||
|
|
||||||
const wipersPromise = baseMixin.methods.dispatchStoreActionWithLogging(
|
|
||||||
storeActions.GET_WIPERS,
|
|
||||||
{
|
|
||||||
serviceZipCode: store.getters.order.serviceLocation.zipCode,
|
|
||||||
carId: store.getters.vehicle.carId,
|
|
||||||
},
|
|
||||||
"payment"
|
|
||||||
);
|
|
||||||
|
|
||||||
const rainRepelPromise = baseMixin.methods.dispatchStoreActionWithLogging(
|
|
||||||
storeActions.GET_RAIN_REPEL,
|
|
||||||
null,
|
|
||||||
"payment"
|
|
||||||
);
|
|
||||||
|
|
||||||
const promiseResultMap = [
|
const promiseResultMap = [
|
||||||
{
|
{
|
||||||
resultKey: "cmsContent",
|
resultKey: "cmsContent",
|
||||||
|
|
@ -345,92 +315,14 @@ export default {
|
||||||
resultKey: "signature",
|
resultKey: "signature",
|
||||||
promise: signaturePromise,
|
promise: signaturePromise,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
resultKey: "wipers",
|
|
||||||
promise: wipersPromise,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resultKey: "rainRepel",
|
|
||||||
promise: rainRepelPromise,
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const resultMap = await settleAllPromises(promiseResultMap);
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
const lineItemsFromStore = deepClone(store.getters.order.lineItems);
|
|
||||||
const glassParts = lineItemsFromStore.glassParts ?? [];
|
|
||||||
const supportingItems = lineItemsFromStore.supportingItems ?? [];
|
|
||||||
|
|
||||||
const lineItemsToTax = [
|
|
||||||
resultMap.rainRepel,
|
|
||||||
...supportingItems,
|
|
||||||
...resultMap.wipers,
|
|
||||||
...glassParts,
|
|
||||||
];
|
|
||||||
const availableVaps = [resultMap.rainRepel, ...resultMap.wipers];
|
|
||||||
|
|
||||||
const pricedLineItemsToTax = await baseMixin.methods.dispatchStoreActionWithLogging(
|
|
||||||
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
|
||||||
{
|
|
||||||
availableLineItems: lineItemsToTax,
|
|
||||||
},
|
|
||||||
"payment",
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
// Promo logic
|
|
||||||
const promoCodeFromQueryString = getQuerystringParameter(queryStrings.PROMO);
|
|
||||||
|
|
||||||
const { validatePromoResponse, revalidatePromoResponse } =
|
|
||||||
await revalidatePromosAndValidateQueryStringPromo(
|
|
||||||
promoCodeFromQueryString,
|
|
||||||
pricedLineItemsToTax,
|
|
||||||
"payment"
|
|
||||||
);
|
|
||||||
|
|
||||||
const newValidatedPromos = validatePromoResponse?.orderPromos ?? [];
|
|
||||||
newValidatedPromos.push(
|
|
||||||
...(revalidatePromoResponse ? revalidatePromoResponse.promoLineItems : [])
|
|
||||||
);
|
|
||||||
|
|
||||||
pricedLineItemsToTax.push(...newValidatedPromos);
|
|
||||||
// End of promo logic
|
|
||||||
|
|
||||||
const taxedLineItems = await baseMixin.methods.dispatchStoreActionWithLogging(
|
|
||||||
storeActions.TAX_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
|
||||||
{
|
|
||||||
billToAccountNumber: store.getters.payment.billToAccountNumber,
|
|
||||||
providerNumber: store.getters.order.serviceLocation.provider.providerNumber,
|
|
||||||
appointmentType: store.getters.order.serviceLocation.appointmentType,
|
|
||||||
serviceLocationCity: store.getters.order.serviceLocation.city,
|
|
||||||
serviceLocationState: store.getters.order.serviceLocation.state,
|
|
||||||
serviceLocationZipCode: store.getters.order.serviceLocation.zipCode,
|
|
||||||
pricedLineItems: pricedLineItemsToTax,
|
|
||||||
},
|
|
||||||
"payment",
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
// Match all line items to the line items as they are in the store
|
|
||||||
// and rebuild the original structure.
|
|
||||||
const lineItems = mapTaxedLineItemsToStoreFormat(taxedLineItems, lineItemsFromStore);
|
|
||||||
const taxedVaps = mapTaxedLineItemsToStoreFormat(taxedLineItems, availableVaps);
|
|
||||||
|
|
||||||
// Add items that were not in the store yet but added via query string promo validation
|
|
||||||
//newValidatedPromos contains both validated and revalidated promos.
|
|
||||||
lineItems.promos = Array.from(newValidatedPromos);
|
|
||||||
const vapsToAddToCart = getVapsThatNeedToBeAddedToSatisfyPromos(
|
|
||||||
newValidatedPromos,
|
|
||||||
taxedVaps,
|
|
||||||
lineItems
|
|
||||||
);
|
|
||||||
lineItems.vaps = lineItems.vaps ?? [];
|
|
||||||
lineItems.vaps.push(...vapsToAddToCart);
|
|
||||||
|
|
||||||
// Call the "next" function to complete the transition to this page.
|
// Call the "next" function to complete the transition to this page.
|
||||||
next(async (vm) => {
|
next(async (vm) => {
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
vm.availableVaps = taxedVaps;
|
vm.lineItems = deepClone(store.getters.order.lineItems);
|
||||||
vm.lineItems = lineItems;
|
|
||||||
|
|
||||||
vm.$nextTick(() => {
|
vm.$nextTick(() => {
|
||||||
if (vm.$refs.cart) {
|
if (vm.$refs.cart) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue