Merge pull request #1986 from Safelite/feature/Digital/CSR-1629

CSR-1629
This commit is contained in:
hiteshkumar87 2024-09-20 13:44:25 +05:30 committed by GitHub
commit 45bb5257d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -545,7 +545,7 @@ export default {
let accountType = ""; let accountType = "";
let amount = 0; let amount = 0;
let cjEvent = ""; let cjEvent = "";
if (store.getters.applicationUser.affiliateCookies) { if (store.getters.applicationUser.affiliateCookies?.length > 0) {
const affiliateCookies = store.getters.applicationUser.affiliateCookies; const affiliateCookies = store.getters.applicationUser.affiliateCookies;
var cookieArray = []; var cookieArray = [];
affiliateCookies.forEach((item) => { affiliateCookies.forEach((item) => {
@ -557,48 +557,55 @@ export default {
new Date(b.timestamp.replace("/", "T")) - new Date(b.timestamp.replace("/", "T")) -
new Date(a.timestamp.replace("/", "T")) new Date(a.timestamp.replace("/", "T"))
); );
cjEvent = sortedCookies?.[0]?.tagEvent; const filteredCookie = sortedCookies?.find(
const hasSubmittedOrder = baseMixin.methods.hasSubmittedOrder(); (x) => x.tagEvent?.length > 0 && x.batchEvent?.length > 0
const submittedOrder = baseMixin.methods.getSubmittedOrder(); );
if (filteredCookie?.length > 0) {
cjEvent = filteredCookie.tagEvent;
const hasSubmittedOrder = baseMixin.methods.hasSubmittedOrder();
const submittedOrder = baseMixin.methods.getSubmittedOrder();
if (hasSubmittedOrder) { if (hasSubmittedOrder) {
repairReplace = submittedOrder.damage.isRepair ? "Repair" : "Replace"; repairReplace = submittedOrder.damage.isRepair ? "Repair" : "Replace";
const promos = submittedOrder.lineItems.promos ?? []; const promos = submittedOrder.lineItems.promos ?? [];
if (promos.length === 0) { if (promos.length === 0) {
coupons = ""; coupons = "";
} else { } else {
const promoCodes = promos.map((promo) => promo.promoCode); const promoCodes = promos.map((promo) => promo.promoCode);
const promoString = promoCodes.reduce((prev, next) => `${prev}_${next}`); const promoString = promoCodes.reduce(
coupons = promoString; (prev, next) => `${prev}_${next}`
} );
refSequenceNum = submittedOrder.referralSequenceNumber; coupons = promoString;
}
refSequenceNum = submittedOrder.referralSequenceNumber;
if (isDefined(submittedOrder.payment.isInsurance)) { if (isDefined(submittedOrder.payment.isInsurance)) {
accountType = submittedOrder.payment.isInsurance ? "insurance" : "cash"; accountType = submittedOrder.payment.isInsurance ? "insurance" : "cash";
} else { } else {
accountType = ""; accountType = "";
} }
const lineItems = submittedOrder.lineItems ?? {}; const lineItems = submittedOrder.lineItems ?? {};
const combinedLineItems = [ const combinedLineItems = [
...(lineItems.glassParts ?? []), ...(lineItems.glassParts ?? []),
...(lineItems.supportingItems ?? []), ...(lineItems.supportingItems ?? []),
...(lineItems.vaps ?? []), ...(lineItems.vaps ?? []),
...(lineItems.promos ?? []), ...(lineItems.promos ?? []),
]; ];
const isPricingAvailable = const isPricingAvailable =
combinedLineItems.length > 0 && combinedLineItems.length > 0 &&
combinedLineItems.every( combinedLineItems.every(
(lineItem) => (lineItem) =>
isDefined(lineItem.kitPrice) && isDefined(lineItem.kitPrice) &&
isDefined(lineItem.laborAmount) && isDefined(lineItem.laborAmount) &&
isDefined(lineItem.sellingPrice) isDefined(lineItem.sellingPrice)
); );
if (accountType == "cash" && isPricingAvailable) { if (accountType == "cash" && isPricingAvailable) {
const quoteAmountWithDiscount = baseMixin.methods const quoteAmountWithDiscount = baseMixin.methods
.getTotalPriceOfAllLineItemsAndChildParts(combinedLineItems, false) .getTotalPriceOfAllLineItemsAndChildParts(combinedLineItems, false)
.toFixed(2); .toFixed(2);
amount = parseFloat(quoteAmountWithDiscount); amount = parseFloat(quoteAmountWithDiscount);
}
} }
} }
} }