Merge pull request #1548 from Safelite/feature/CSR-1391.1

Feature/csr 1391.1
This commit is contained in:
Matt Caimi 2023-11-20 11:47:07 -05:00 committed by GitHub
commit fce28e8041
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,6 +25,7 @@
<hr />
<cart
ref="cart"
:damage="damageInfo"
:availableVaps="availableVaps"
:allowItemRemoval="false"
@ -227,7 +228,7 @@ export default {
invoiceNumber: this.getInvoiceNumber(),
totalAmount: this.getAmountDue(),
displayAmount: this.getDisplayAmountDue(),
piaLineItems: this.getPiaLineItems(),
piaLineItems: "",
paypalPayment: this.isPaypal(),
lineItems: [],
availableVaps: [],
@ -357,11 +358,18 @@ export default {
// Call the "next" function to complete the transition to this page.
next(async (vm) => {
vm.setCmsContent(resultMap.cmsContent);
vm.fetchSignatureInfo(resultMap.signature);
vm.setIFrameListener();
vm.availableVaps = taxedVaps;
vm.lineItems = lineItems;
vm.$nextTick(() => {
if (vm.$refs.cart) {
const cartItems = vm.$refs.cart.cartItems;
vm.getPiaLineItems(cartItems);
}
vm.fetchSignatureInfo(resultMap.signature);
vm.setIFrameListener();
});
});
},
computed: {
@ -506,27 +514,23 @@ export default {
return store.getters.payment.piaType;
}
},
getPiaLineItems() {
const itemMap = new Map();
getPiaLineItems(cartItems) {
const glassParts = store.getters.order.lineItems.glassParts;
const supportingItems = store.getters.order.lineItems.supportingItems;
const vaps = store.getters.order.lineItems.vaps;
const items = [...(glassParts ?? []), ...(supportingItems ?? []), ...(vaps ?? [])];
let lineItems = [];
for (const item of items) {
const amount = item.laborAmount + item.sellingPrice;
const key = `${item.partType}|${amount}`;
if (itemMap.has(key)) {
itemMap.get(key).quantity++;
} else {
itemMap.set(key, { partType: item.partType, amount, quantity: 1 });
}
if (glassParts === null) {
lineItems = ["Labor|0|1", "Repair supplies|0|1"];
} else {
lineItems = ["Parts and labor|0|1"];
}
return Array.from(itemMap.values())
.map((item) => `${item.partType}|${item.amount}|${item.quantity}`)
.join("||");
cartItems.forEach((item) => {
if (item.name !== null) {
lineItems.push(`${item.name}|${(item.salesTax + item.subTotal).toFixed(2)}|1`);
}
});
this.piaLineItems = lineItems.join("||");
},
getAmountDue() {
return baseMixin.methods.getAmountDue(store.getters.order.lineItems);