Merge remote-tracking branch 'origin/release/2023.12.07' into feature/skiener/CSR-1841
This commit is contained in:
commit
981d9ba02b
4 changed files with 28 additions and 9 deletions
|
|
@ -19,6 +19,7 @@ const queryStrings = {
|
||||||
AUTH_CODE: "auth_code",
|
AUTH_CODE: "auth_code",
|
||||||
TRANSACTION_ID: "transaction_id",
|
TRANSACTION_ID: "transaction_id",
|
||||||
TRANS_REFERENCE_NUMBER: "auth_trans_ref_no",
|
TRANS_REFERENCE_NUMBER: "auth_trans_ref_no",
|
||||||
|
DISPLAY_PIA_ALERT: "displayPiaAlert",
|
||||||
};
|
};
|
||||||
|
|
||||||
export { queryStrings };
|
export { queryStrings };
|
||||||
|
|
|
||||||
|
|
@ -213,16 +213,33 @@ export function buildToastMessagesFromRevalidateOrValidatePromoResponse(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPromosThatMatchLineItemsOnOrder(promos, lineItemsOnOrder) {
|
export function getPromosThatMatchLineItemsOnOrder(promos, lineItemsOnOrder) {
|
||||||
|
const matchingPromoCodes = [];
|
||||||
const matchingPromos = [];
|
const matchingPromos = [];
|
||||||
|
const consolidatedPromosWithIds = {};
|
||||||
|
// Combine bundle promos to make sure each part of the bundle is satisfied
|
||||||
promos.forEach((promo) => {
|
promos.forEach((promo) => {
|
||||||
|
const cleanPromoCode = getPromoCodeWithoutBundleIdentifier(promo.promoCode);
|
||||||
|
if (consolidatedPromosWithIds[cleanPromoCode]) {
|
||||||
|
consolidatedPromosWithIds[cleanPromoCode].push(...promo.discountedLineItemIds);
|
||||||
|
} else {
|
||||||
|
consolidatedPromosWithIds[cleanPromoCode] = promo.discountedLineItemIds.slice(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Object.keys(consolidatedPromosWithIds).forEach((promoCode) => {
|
||||||
let allIdsMatch = true;
|
let allIdsMatch = true;
|
||||||
promo.discountedLineItemIds.forEach((id) => {
|
consolidatedPromosWithIds[promoCode].forEach((id) => {
|
||||||
if (lineItemsOnOrder.filter((x) => x.id === id).length === 0) {
|
if (lineItemsOnOrder.filter((x) => x.id === id).length === 0) {
|
||||||
allIdsMatch = false;
|
allIdsMatch = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (allIdsMatch) {
|
if (allIdsMatch) {
|
||||||
|
matchingPromoCodes.push(promoCode);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
promos.forEach((promo) => {
|
||||||
|
const cleanPromoCode = getPromoCodeWithoutBundleIdentifier(promo.promoCode);
|
||||||
|
if (matchingPromoCodes.includes(cleanPromoCode)) {
|
||||||
matchingPromos.push(promo);
|
matchingPromos.push(promo);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,7 @@ import {
|
||||||
getNewlyInactivatedPromos,
|
getNewlyInactivatedPromos,
|
||||||
} from "@/helpers/promotions-helper";
|
} from "@/helpers/promotions-helper";
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
import { queryStrings } from "@/constants/query-strings";
|
||||||
|
import { routerParams } from "@/router/router-constants/router-params";
|
||||||
import { getQuerystringParameter } from "@/helpers/querystring-helper";
|
import { getQuerystringParameter } from "@/helpers/querystring-helper";
|
||||||
import { deepClone } from "@/helpers/object-helper";
|
import { deepClone } from "@/helpers/object-helper";
|
||||||
|
|
||||||
|
|
@ -421,7 +422,7 @@ export default {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("error: response from pia submit work order:" + error.message);
|
console.log("error: response from pia submit work order:" + error.message);
|
||||||
this.dispatchStoreAction(storeActions.RESET_SAVE_SESSION_PROMISE);
|
this.dispatchStoreAction(storeActions.RESET_SAVE_SESSION_PROMISE);
|
||||||
this.$route.params[this.routerParams.DISPLAY_PIA_ALERT] = true;
|
this.$route.params[routerParams.DISPLAY_PIA_ALERT] = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -469,7 +470,10 @@ export default {
|
||||||
return this.paymentMethodInternalModel;
|
return this.paymentMethodInternalModel;
|
||||||
},
|
},
|
||||||
shouldDisplayPiaAlert() {
|
shouldDisplayPiaAlert() {
|
||||||
return this.$route.params[this.routerParams.DISPLAY_PIA_ALERT];
|
return (
|
||||||
|
this.$route.query[queryStrings.DISPLAY_PIA_ALERT] ||
|
||||||
|
this.$route.params[routerParams.DISPLAY_PIA_ALERT]
|
||||||
|
);
|
||||||
},
|
},
|
||||||
// Necessary to make the watcher of lineItems work
|
// Necessary to make the watcher of lineItems work
|
||||||
// JavaScript does not keep a record of the old value, only a reference to it's location in the memory.
|
// JavaScript does not keep a record of the old value, only a reference to it's location in the memory.
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,9 @@ export default {
|
||||||
|
|
||||||
if (piaError) {
|
if (piaError) {
|
||||||
console.log("Error during payment: " + piaError);
|
console.log("Error during payment: " + piaError);
|
||||||
this.$router.navigateWithoutSaving(
|
this.$router.navigateWithoutSaving(this.navigationScenarios.PIA_ERROR, this.$route, {
|
||||||
this.navigationScenarios.PIA_ERROR,
|
[queryStrings.DISPLAY_PIA_ALERT]: true,
|
||||||
this.$route,
|
});
|
||||||
{},
|
|
||||||
{ [routerParams.DISPLAY_PIA_ALERT]: true }
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
switch (store.getters.order.payment.piaType) {
|
switch (store.getters.order.payment.piaType) {
|
||||||
case paymentMethods.CREDIT_CARD:
|
case paymentMethods.CREDIT_CARD:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue