CNR Modifications.
This commit is contained in:
@@ -159,11 +159,11 @@ function BillEnterModalContainer({
|
||||
});
|
||||
}
|
||||
|
||||
const markPolReceived = outstanding_returns.filter(
|
||||
(o) => o.cm_received === true
|
||||
);
|
||||
const markPolReceived =
|
||||
outstanding_returns &&
|
||||
outstanding_returns.filter((o) => o.cm_received === true);
|
||||
|
||||
if (markPolReceived.length > 0) {
|
||||
if (markPolReceived && markPolReceived.length > 0) {
|
||||
const r2 = await updatePartsOrderLines({
|
||||
variables: { partsLineIds: markPolReceived.map((p) => p.id) },
|
||||
});
|
||||
|
||||
@@ -26,6 +26,8 @@ export default function JobBillsTotalComponent({
|
||||
let billCms = Dinero();
|
||||
let lbrAdjustments = Dinero();
|
||||
let totalReturns = Dinero();
|
||||
let totalReturnsMarkedNotReceived = Dinero();
|
||||
let totalReturnsMarkedReceived = Dinero();
|
||||
|
||||
partsOrders.forEach((p) =>
|
||||
p.parts_order_lines.forEach((pol) => {
|
||||
@@ -35,6 +37,24 @@ export default function JobBillsTotalComponent({
|
||||
amount: Math.round((pol.act_price || 0) * 100),
|
||||
}).multiply(pol.quantity)
|
||||
);
|
||||
|
||||
if (pol.cm_received === null) {
|
||||
return; // Skip this calculation for bills posted prior to the CNR change.
|
||||
} else {
|
||||
if (pol.cm_received === false) {
|
||||
totalReturnsMarkedNotReceived = totalReturnsMarkedNotReceived.add(
|
||||
Dinero({
|
||||
amount: Math.round((pol.act_price || 0) * 100),
|
||||
}).multiply(pol.quantity)
|
||||
);
|
||||
} else {
|
||||
totalReturnsMarkedReceived = totalReturnsMarkedReceived.add(
|
||||
Dinero({
|
||||
amount: Math.round((pol.act_price || 0) * 100),
|
||||
}).multiply(pol.quantity)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
@@ -73,7 +93,7 @@ export default function JobBillsTotalComponent({
|
||||
const discrepWithLbrAdj = discrepancy.add(lbrAdjustments);
|
||||
|
||||
const discrepWithCms = discrepWithLbrAdj.add(totalReturns);
|
||||
const creditsNotReceived = totalReturns.subtract(billCms); //billCms is tracked as a negative number.
|
||||
const calculatedCreditsNotReceived = totalReturns.subtract(billCms); //billCms is tracked as a negative number.
|
||||
|
||||
return (
|
||||
<Row gutter={16}>
|
||||
@@ -213,6 +233,32 @@ export default function JobBillsTotalComponent({
|
||||
value={totalReturns.toFormat()}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip
|
||||
title={
|
||||
<div
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: t(
|
||||
"jobs.labels.plitooltips.calculatedcreditsnotreceived"
|
||||
),
|
||||
}}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Statistic
|
||||
title={t("bills.labels.calculatedcreditsnotreceived")}
|
||||
valueStyle={{
|
||||
color:
|
||||
calculatedCreditsNotReceived.getAmount() <= 0
|
||||
? "green"
|
||||
: "red",
|
||||
}}
|
||||
value={
|
||||
calculatedCreditsNotReceived.getAmount() >= 0
|
||||
? calculatedCreditsNotReceived.toFormat()
|
||||
: Dinero().toFormat()
|
||||
}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip
|
||||
title={
|
||||
<div
|
||||
@@ -225,11 +271,14 @@ export default function JobBillsTotalComponent({
|
||||
<Statistic
|
||||
title={t("bills.labels.creditsnotreceived")}
|
||||
valueStyle={{
|
||||
color: creditsNotReceived.getAmount() <= 0 ? "green" : "red",
|
||||
color:
|
||||
totalReturnsMarkedNotReceived.getAmount() <= 0
|
||||
? "green"
|
||||
: "red",
|
||||
}}
|
||||
value={
|
||||
creditsNotReceived.getAmount() >= 0
|
||||
? creditsNotReceived.toFormat()
|
||||
totalReturnsMarkedNotReceived.getAmount() >= 0
|
||||
? totalReturnsMarkedNotReceived.toFormat()
|
||||
: Dinero().toFormat()
|
||||
}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user