Added Adblue Calculation
This commit is contained in:
@@ -589,13 +589,18 @@ const documentTotal = computed(() => {
|
|||||||
const processDieselPosition = () => {
|
const processDieselPosition = () => {
|
||||||
let agricultureData = {
|
let agricultureData = {
|
||||||
dieselUsageTotal: 0,
|
dieselUsageTotal: 0,
|
||||||
dieselPriceTotal: 0
|
dieselPriceTotal: 0,
|
||||||
|
adblueUsageTotal: 0,
|
||||||
|
adbluePriceTotal: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
itemInfo.value.rows.forEach(row => {
|
itemInfo.value.rows.forEach(row => {
|
||||||
if(row.agriculture && row.agriculture.dieselUsage) {
|
if(row.agriculture && row.agriculture.dieselUsage) {
|
||||||
agricultureData.dieselUsageTotal += Number(row.agriculture.dieselUsage)
|
agricultureData.dieselUsageTotal += Number(row.agriculture.dieselUsage)
|
||||||
agricultureData.dieselPriceTotal += Number(row.agriculture.dieselPrice) * Number(row.agriculture.dieselUsage)
|
agricultureData.dieselPriceTotal += Number(row.agriculture.dieselPrice || 0) * Number(row.agriculture.dieselUsage)
|
||||||
|
|
||||||
|
agricultureData.adblueUsageTotal += Number(row.agriculture.dieselUsage * 0.04)
|
||||||
|
agricultureData.adbluePriceTotal += Number(row.agriculture.dieselPrice || 0) * Number(row.agriculture.dieselUsage * 0.04)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -610,10 +615,18 @@ const processDieselPosition = () => {
|
|||||||
text: `${agricultureData.dieselUsageTotal} L Diesel`,
|
text: `${agricultureData.dieselUsageTotal} L Diesel`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let existingAdblueIndex = itemInfo.value.rows.findIndex(i => i.key === "adbluePos")
|
||||||
|
|
||||||
|
itemInfo.value.rows[existingAdblueIndex] = {
|
||||||
|
...itemInfo.value.rows[existingAdblueIndex],
|
||||||
|
price: agricultureData.adbluePriceTotal,
|
||||||
|
text: `${agricultureData.adblueUsageTotal} L Diesel`,
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
itemInfo.value.rows.push({
|
itemInfo.value.rows.push({
|
||||||
mode: "free",
|
mode: "free",
|
||||||
text: `${agricultureData.dieselUsageTotal} L Diesel`,
|
text: `${(agricultureData.dieselUsageTotal).toFixed(2).replace(".",",")} L Diesel`,
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
unit: 10,
|
unit: 10,
|
||||||
price: agricultureData.dieselPriceTotal,
|
price: agricultureData.dieselPriceTotal,
|
||||||
@@ -622,6 +635,17 @@ const processDieselPosition = () => {
|
|||||||
key: "dieselPos"
|
key: "dieselPos"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
itemInfo.value.rows.push({
|
||||||
|
mode: "free",
|
||||||
|
text: `${(agricultureData.adblueUsageTotal).toFixed(2).replace(".",",")} L AdBlue`,
|
||||||
|
quantity: 1,
|
||||||
|
unit: 10,
|
||||||
|
price: agricultureData.adbluePriceTotal,
|
||||||
|
taxPercent: 19,
|
||||||
|
discountPercent: 0,
|
||||||
|
key: "adbluePos"
|
||||||
|
})
|
||||||
|
|
||||||
setPosNumbers()
|
setPosNumbers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user