CSR-1391 parts and labor in afterpay line items

This commit is contained in:
Matt Caimi 2023-11-20 11:40:44 -05:00
parent d869962652
commit aa8a88b819

View file

@ -515,26 +515,22 @@ export default {
}
},
getPiaLineItems(cartItems) {
const itemMap = new Map();
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"];
}
this.piaLineItems = 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);