CSR-1391 combine like line items for pia
This commit is contained in:
parent
8fdc9da392
commit
12459ecc97
1 changed files with 14 additions and 5 deletions
|
|
@ -509,17 +509,26 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getPiaLineItems() {
|
getPiaLineItems() {
|
||||||
let itemsForPia = "";
|
const itemMap = new Map();
|
||||||
const glassParts = store.getters.order.lineItems.glassParts;
|
const glassParts = store.getters.order.lineItems.glassParts;
|
||||||
const supportingItems = store.getters.order.lineItems.supportingItems;
|
const supportingItems = store.getters.order.lineItems.supportingItems;
|
||||||
const vaps = store.getters.order.lineItems.vaps;
|
const vaps = store.getters.order.lineItems.vaps;
|
||||||
const items = [...(glassParts ?? []), ...(supportingItems ?? []), ...(vaps ?? [])];
|
const items = [...(glassParts ?? []), ...(supportingItems ?? []), ...(vaps ?? [])];
|
||||||
|
|
||||||
for (let i = 0; i < items.length; i++) {
|
for (const item of items) {
|
||||||
const amount = items[i].laborAmount + items[i].sellingPrice;
|
const amount = item.laborAmount + item.sellingPrice;
|
||||||
itemsForPia += items[i].partType + "|" + amount + "|1|";
|
const key = `${item.partType}|${amount}`;
|
||||||
|
|
||||||
|
if (itemMap.has(key)) {
|
||||||
|
itemMap.get(key).quantity++;
|
||||||
|
} else {
|
||||||
|
itemMap.set(key, { partType: item.partType, amount, quantity: 1 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return itemsForPia;
|
|
||||||
|
return Array.from(itemMap.values())
|
||||||
|
.map((item) => `${item.partType}|${item.amount}|${item.quantity}`)
|
||||||
|
.join("||");
|
||||||
},
|
},
|
||||||
getAmountDue() {
|
getAmountDue() {
|
||||||
return baseMixin.methods.getAmountDue(store.getters.order.lineItems);
|
return baseMixin.methods.getAmountDue(store.getters.order.lineItems);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue