Improved bill totals reconciliation IO-583
This commit is contained in:
@@ -74,6 +74,7 @@ function BillEnterModalContainer({
|
||||
}
|
||||
return {
|
||||
...restI,
|
||||
deductedfromlbr: deductfromlabor,
|
||||
joblineid: i.joblineid === "noline" ? null : i.joblineid,
|
||||
};
|
||||
}),
|
||||
|
||||
@@ -17,16 +17,33 @@ export default function JobBillsTotalComponent({ loading, bills, jobTotals }) {
|
||||
|
||||
const totals = jobTotals;
|
||||
|
||||
let billTotals = Dinero({ amount: 0 });
|
||||
let billTotals = Dinero();
|
||||
let billCms = Dinero();
|
||||
let lbrAdjustments = Dinero();
|
||||
|
||||
bills.forEach((i) =>
|
||||
i.billlines.forEach((il) => {
|
||||
billTotals = billTotals.add(
|
||||
Dinero({
|
||||
amount: Math.round(
|
||||
(il.actual_cost || 0) * (i.is_credit_memo ? -1 : 1) * 100
|
||||
),
|
||||
}).multiply(il.quantity)
|
||||
);
|
||||
if (!i.is_credit_memo) {
|
||||
billTotals = billTotals.add(
|
||||
Dinero({
|
||||
amount: Math.round((il.actual_price || 0) * 100),
|
||||
}).multiply(il.quantity)
|
||||
);
|
||||
} else {
|
||||
billCms = billCms.add(
|
||||
Dinero({
|
||||
amount: Math.round((il.actual_price || 0) * -100),
|
||||
}).multiply(il.quantity)
|
||||
);
|
||||
}
|
||||
if (il.deductedfromlbr) {
|
||||
console.log(i, "Deducting from labor.");
|
||||
lbrAdjustments = lbrAdjustments.add(
|
||||
Dinero({
|
||||
amount: Math.round((il.actual_price || 0) * 100),
|
||||
}).multiply(il.quantity)
|
||||
);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@@ -35,10 +52,13 @@ export default function JobBillsTotalComponent({ loading, bills, jobTotals }) {
|
||||
);
|
||||
const discrepancy = totalPartsSublet.subtract(billTotals);
|
||||
|
||||
const discrepWithLbrAdj = discrepancy.add(lbrAdjustments);
|
||||
|
||||
const discrepWithCms = discrepWithLbrAdj.subtract(billCms);
|
||||
return (
|
||||
<div className="job-bills-totals-container">
|
||||
<Statistic
|
||||
title={t("jobs.labels.partstotal")}
|
||||
title={t("jobs.labels.rosaletotal")}
|
||||
value={totalPartsSublet.toFormat()}
|
||||
/>
|
||||
<Statistic
|
||||
@@ -52,6 +72,28 @@ export default function JobBillsTotalComponent({ loading, bills, jobTotals }) {
|
||||
}}
|
||||
value={discrepancy.toFormat()}
|
||||
/>
|
||||
<Statistic
|
||||
title={t("bills.labels.dedfromlbr")}
|
||||
value={lbrAdjustments.toFormat()}
|
||||
/>
|
||||
<Statistic
|
||||
title={t("bills.labels.discrepwithlbradj")}
|
||||
valueStyle={{
|
||||
color: discrepWithLbrAdj.getAmount === 0 ? "green" : "red",
|
||||
}}
|
||||
value={discrepWithLbrAdj.toFormat()}
|
||||
/>
|
||||
<Statistic
|
||||
title={t("bills.labels.billcmtotal")}
|
||||
value={billCms.toFormat()}
|
||||
/>
|
||||
<Statistic
|
||||
title={t("bills.labels.discrepwithcms")}
|
||||
valueStyle={{
|
||||
color: discrepWithCms.getAmount === 0 ? "green" : "red",
|
||||
}}
|
||||
value={discrepWithCms.toFormat()}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { MailFilled, PrinterFilled, SyncOutlined } from "@ant-design/icons";
|
||||
import { Button, Input, Space, Table, Typography } from "antd";
|
||||
import { Button, Checkbox, Input, Space, Table, Typography } from "antd";
|
||||
import queryString from "query-string";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -76,6 +76,15 @@ export function PartsOrderListTableComponent({
|
||||
<DateFormatter>{record.order_date}</DateFormatter>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("parts_orders.fields.return"),
|
||||
dataIndex: "return",
|
||||
key: "return",
|
||||
sorter: (a, b) => a.return - b.return,
|
||||
sortOrder:
|
||||
state.sortedInfo.columnKey === "return" && state.sortedInfo.order,
|
||||
render: (text, record) => <Checkbox checked={record.return} />,
|
||||
},
|
||||
{
|
||||
title: t("parts_orders.fields.deliver_by"),
|
||||
dataIndex: "deliver_by",
|
||||
@@ -104,11 +113,13 @@ export function PartsOrderListTableComponent({
|
||||
job: job,
|
||||
bill: {
|
||||
vendorid: record.vendor.id,
|
||||
is_credit_memo: record.return,
|
||||
billlines: record.parts_order_lines.map((pol) => {
|
||||
return {
|
||||
joblineid: pol.job_line_id,
|
||||
line_desc: pol.line_desc,
|
||||
quantity: pol.quantity,
|
||||
|
||||
actual_price: pol.act_price,
|
||||
cost_center: pol.jobline.part_type
|
||||
? responsibilityCenters.defaults.costs[
|
||||
|
||||
@@ -82,6 +82,7 @@ export function PartsOrderModalContainer({
|
||||
...values,
|
||||
jobid: jobId,
|
||||
user_email: currentUser.email,
|
||||
return: isReturn,
|
||||
status: bodyshop.md_order_statuses.default_ordered || "Ordered*",
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user