IO-813 Calculation updates to include adjustments
This commit is contained in:
@@ -46,13 +46,13 @@ export function JobsTotalsTableComponent({ jobRO, job }) {
|
|||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
<Col {...colSpan}>
|
<Col {...colSpan}>
|
||||||
<Row gutter={[0, 32]}>
|
<Row gutter={[16, 16]}>
|
||||||
<Col span={24}>
|
<Col sm={24} md={12}>
|
||||||
<Card title={t("jobs.labels.partstotal")}>
|
<Card title={t("jobs.labels.partstotal")}>
|
||||||
<JobTotalsTableParts job={job} />
|
<JobTotalsTableParts job={job} />
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={24}>
|
<Col sm={24} md={12}>
|
||||||
<Card title={t("jobs.labels.othertotal")}>
|
<Card title={t("jobs.labels.othertotal")}>
|
||||||
<JobTotalsTableOther job={job} />
|
<JobTotalsTableOther job={job} />
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -17,9 +17,29 @@ export default function JobTotalsTableOther({ job }) {
|
|||||||
key: t("jobs.labels.subletstotal"),
|
key: t("jobs.labels.subletstotal"),
|
||||||
total: job.job_totals.parts.sublets.total,
|
total: job.job_totals.parts.sublets.total,
|
||||||
},
|
},
|
||||||
|
...((job.job_totals.additional.additionalCostItems &&
|
||||||
|
job.job_totals.additional.additionalCostItems.map((i) => {
|
||||||
|
return {
|
||||||
|
key: i.key,
|
||||||
|
total: i.total,
|
||||||
|
};
|
||||||
|
})) ||
|
||||||
|
[]),
|
||||||
{
|
{
|
||||||
key: t("jobs.labels.additionaltotal"),
|
key: t("jobs.fields.adjustment_bottom_line"),
|
||||||
total: job.job_totals.additional,
|
total: job.job_totals.additional.adjustments,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: t("jobs.fields.towing"),
|
||||||
|
total: job.job_totals.additional.towing,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: t("jobs.fields.storage"),
|
||||||
|
total: job.job_totals.additional.storage,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: t("jobs.fields.pvrt"),
|
||||||
|
total: job.job_totals.additional.pvrt,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}, [job.job_totals, t]);
|
}, [job.job_totals, t]);
|
||||||
@@ -67,7 +87,7 @@ export default function JobTotalsTableOther({ job }) {
|
|||||||
|
|
||||||
<Table.Summary.Cell>
|
<Table.Summary.Cell>
|
||||||
<strong>
|
<strong>
|
||||||
{Dinero(job.job_totals.parts.parts.total).toFormat()}
|
{Dinero(job.job_totals.additional.total).toFormat()}
|
||||||
</strong>
|
</strong>
|
||||||
</Table.Summary.Cell>
|
</Table.Summary.Cell>
|
||||||
</Table.Summary.Row>
|
</Table.Summary.Row>
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ const generateInvoiceQbxml = (
|
|||||||
(i) => jobline.profitcenter_part.toLowerCase() === i.name.toLowerCase()
|
(i) => jobline.profitcenter_part.toLowerCase() === i.name.toLowerCase()
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!!!account) {
|
if (!account) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`A matching account does not exist for the allocation. Center: ${center}`
|
`A matching account does not exist for the allocation. Center: ${center}`
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -279,31 +279,41 @@ function IsAdditionalCost(jobLine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function CalculateAdditional(job) {
|
function CalculateAdditional(job) {
|
||||||
let ret = job.joblines
|
let ret = {
|
||||||
|
additionalCosts: null,
|
||||||
|
additionalCostItems: [],
|
||||||
|
adjustments: null,
|
||||||
|
towing: null,
|
||||||
|
storage: null,
|
||||||
|
pvrt: null,
|
||||||
|
total: null,
|
||||||
|
};
|
||||||
|
ret.additionalCosts = job.joblines
|
||||||
.filter((jl) => !jl.removed && IsAdditionalCost(jl))
|
.filter((jl) => !jl.removed && IsAdditionalCost(jl))
|
||||||
.reduce((acc, val) => {
|
.reduce((acc, val) => {
|
||||||
return acc.add(
|
const lineValue = Dinero({
|
||||||
Dinero({ amount: Math.round((val.act_price || 0) * 100) }).multiply(
|
amount: Math.round((val.act_price || 0) * 100),
|
||||||
val.part_qty || 1
|
}).multiply(val.part_qty || 1);
|
||||||
)
|
ret.additionalCostItems.push({ key: val.line_desc, total: lineValue });
|
||||||
);
|
return acc.add(lineValue);
|
||||||
}, Dinero());
|
}, Dinero());
|
||||||
ret = ret
|
ret.adjustments = Dinero({
|
||||||
.add(
|
amount: Math.round((job.adjustment_bottom_line || 0) * 100),
|
||||||
Dinero({
|
});
|
||||||
amount: Math.round((job.towing_payable || 0) * 100),
|
ret.towing = Dinero({
|
||||||
})
|
amount: Math.round((job.towing_payable || 0) * 100),
|
||||||
)
|
});
|
||||||
.add(
|
ret.storage = Dinero({
|
||||||
Dinero({
|
amount: Math.round((job.storage_payable || 0) * 100),
|
||||||
amount: Math.round((job.storage_payable || 0) * 100),
|
});
|
||||||
})
|
ret.pvrt = Dinero({
|
||||||
)
|
amount: Math.round((job.ca_bc_pvrt || 0) * 100),
|
||||||
.add(
|
});
|
||||||
Dinero({
|
ret.total = ret.additionalCosts
|
||||||
amount: Math.round((job.ca_bc_pvrt || 0) * 100),
|
.add(ret.adjustments) //IO-813 Adjustment takes care of GST & PST at labor rate.
|
||||||
})
|
.add(ret.towing)
|
||||||
);
|
.add(ret.storage)
|
||||||
|
.add(ret.pvrt);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -312,7 +322,7 @@ function CalculateTaxesTotals(job, otherTotals) {
|
|||||||
const subtotal = otherTotals.parts.parts.subtotal
|
const subtotal = otherTotals.parts.parts.subtotal
|
||||||
.add(otherTotals.parts.sublets.subtotal)
|
.add(otherTotals.parts.sublets.subtotal)
|
||||||
.add(otherTotals.rates.subtotal) //No longer using just rates subtotal to include mapa/mash.
|
.add(otherTotals.rates.subtotal) //No longer using just rates subtotal to include mapa/mash.
|
||||||
.add(otherTotals.additional);
|
.add(otherTotals.additional.total);
|
||||||
// .add(Dinero({ amount: (job.towing_payable || 0) * 100 }))
|
// .add(Dinero({ amount: (job.towing_payable || 0) * 100 }))
|
||||||
// .add(Dinero({ amount: (job.storage_payable || 0) * 100 }));
|
// .add(Dinero({ amount: (job.storage_payable || 0) * 100 }));
|
||||||
|
|
||||||
@@ -371,14 +381,15 @@ function CalculateTaxesTotals(job, otherTotals) {
|
|||||||
otherTotals.rates.subtotal.percentage((job.tax_lbr_rt || 0) * 100) // THis is currently using the lbr tax rate from PFH not PFL.
|
otherTotals.rates.subtotal.percentage((job.tax_lbr_rt || 0) * 100) // THis is currently using the lbr tax rate from PFH not PFL.
|
||||||
)
|
)
|
||||||
.add(
|
.add(
|
||||||
Dinero({
|
otherTotals.additional.adjustments.percentage(
|
||||||
amount: Math.round((job.towing_payable || 0) * 100),
|
(job.tax_lbr_rt || 0) * 100
|
||||||
}).percentage((job.tax_tow_rt || 0) * 100)
|
)
|
||||||
)
|
)
|
||||||
.add(
|
.add(
|
||||||
Dinero({
|
otherTotals.additional.towing.percentage((job.tax_tow_rt || 0) * 100)
|
||||||
amount: Math.round((job.storage_payable || 0) * 100),
|
)
|
||||||
}).percentage((job.tax_str_rt || 0) * 100)
|
.add(
|
||||||
|
otherTotals.additional.storage.percentage((job.tax_str_rt || 0) * 100)
|
||||||
)
|
)
|
||||||
.add(additionalItemsTax),
|
.add(additionalItemsTax),
|
||||||
local_tax: subtotal.percentage((job.local_tax_rate || 0) * 100),
|
local_tax: subtotal.percentage((job.local_tax_rate || 0) * 100),
|
||||||
|
|||||||
Reference in New Issue
Block a user