IO-793 Add additional job totals calculations to pli.
This commit is contained in:
@@ -2055,6 +2055,48 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>creditsnotreceived</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>creditsreceived</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>dedfromlbr</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -2370,6 +2412,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>totalreturns</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
</children>
|
||||
</folder_node>
|
||||
<folder_node>
|
||||
|
||||
@@ -6,7 +6,12 @@ import AlertComponent from "../alert/alert.component";
|
||||
import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component";
|
||||
import "./job-bills-total.styles.scss";
|
||||
|
||||
export default function JobBillsTotalComponent({ loading, bills, jobTotals }) {
|
||||
export default function JobBillsTotalComponent({
|
||||
loading,
|
||||
bills,
|
||||
partsOrders,
|
||||
jobTotals,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
if (loading) return <LoadingSkeleton />;
|
||||
@@ -20,6 +25,19 @@ export default function JobBillsTotalComponent({ loading, bills, jobTotals }) {
|
||||
let billTotals = Dinero();
|
||||
let billCms = Dinero();
|
||||
let lbrAdjustments = Dinero();
|
||||
let totalReturns = Dinero();
|
||||
|
||||
partsOrders.forEach((p) =>
|
||||
p.parts_order_lines.forEach((pol) => {
|
||||
if (p.return) {
|
||||
totalReturns = totalReturns.add(
|
||||
Dinero({
|
||||
amount: Math.round((pol.cost || 0) * 100),
|
||||
}).multiply(pol.quantity)
|
||||
);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
bills.forEach((i) =>
|
||||
i.billlines.forEach((il) => {
|
||||
@@ -50,11 +68,13 @@ export default function JobBillsTotalComponent({ loading, bills, jobTotals }) {
|
||||
const totalPartsSublet = Dinero(totals.parts.parts.total).add(
|
||||
Dinero(totals.parts.sublets.total)
|
||||
);
|
||||
|
||||
const discrepancy = totalPartsSublet.subtract(billTotals);
|
||||
|
||||
const discrepWithLbrAdj = discrepancy.add(lbrAdjustments);
|
||||
|
||||
const discrepWithCms = discrepWithLbrAdj.subtract(billCms);
|
||||
const creditsNotReceived = totalReturns.subtract(billCms);
|
||||
return (
|
||||
<Card title={t("jobs.labels.jobtotals")}>
|
||||
<Space wrap size="large">
|
||||
@@ -95,6 +115,21 @@ export default function JobBillsTotalComponent({ loading, bills, jobTotals }) {
|
||||
}}
|
||||
value={discrepWithCms.toFormat()}
|
||||
/>
|
||||
<Statistic
|
||||
title={t("bills.labels.totalreturns")}
|
||||
value={totalReturns.toFormat()}
|
||||
/>{" "}
|
||||
<Statistic
|
||||
title={t("bills.labels.creditsreceived")}
|
||||
value={billCms.toFormat()}
|
||||
/>
|
||||
<Statistic
|
||||
title={t("bills.labels.creditsnotreceived")}
|
||||
valueStyle={{
|
||||
color: creditsNotReceived.getAmount === 0 ? "green" : "red",
|
||||
}}
|
||||
value={creditsNotReceived.toFormat()}
|
||||
/>
|
||||
</Space>
|
||||
</Card>
|
||||
);
|
||||
|
||||
@@ -23,6 +23,7 @@ export default function JobsDetailPliComponent({
|
||||
<Col span={24}>
|
||||
<JobBillsTotal
|
||||
bills={billsQuery.data ? billsQuery.data.bills : []}
|
||||
partsOrders={billsQuery.data ? billsQuery.data.parts_orders : []}
|
||||
loading={billsQuery.loading}
|
||||
jobTotals={job.job_totals}
|
||||
/>
|
||||
|
||||
@@ -233,15 +233,12 @@ export function PartsOrderListTableComponent({
|
||||
state.sortedInfo.columnKey === "line_desc" && state.sortedInfo.order,
|
||||
},
|
||||
{
|
||||
title: t("parts_orders.fields.db_price"),
|
||||
dataIndex: "db_price",
|
||||
key: "db_price",
|
||||
sorter: (a, b) => a.db_price - b.db_price,
|
||||
title: t("parts_orders.fields.quantity"),
|
||||
dataIndex: "quantity",
|
||||
key: "quantity",
|
||||
sorter: (a, b) => a.quantity - b.quantity,
|
||||
sortOrder:
|
||||
state.sortedInfo.columnKey === "db_price" && state.sortedInfo.order,
|
||||
render: (text, record) => (
|
||||
<CurrencyFormatter>{record.db_price}</CurrencyFormatter>
|
||||
),
|
||||
state.sortedInfo.columnKey === "quantity" && state.sortedInfo.order,
|
||||
},
|
||||
|
||||
{
|
||||
@@ -255,7 +252,7 @@ export function PartsOrderListTableComponent({
|
||||
<CurrencyFormatter>{record.act_price}</CurrencyFormatter>
|
||||
),
|
||||
},
|
||||
...(selectedPartsOrderRecord && selectedPartsOrderRecord.isReturn
|
||||
...(selectedPartsOrderRecord && selectedPartsOrderRecord.return
|
||||
? [
|
||||
{
|
||||
title: t("parts_orders.fields.cost"),
|
||||
|
||||
@@ -141,6 +141,8 @@
|
||||
"bill_total": "Bill Total Amount",
|
||||
"billcmtotal": "Retail Total of Credit Memos",
|
||||
"bills": "Bills",
|
||||
"creditsnotreceived": "Credits Not Received",
|
||||
"creditsreceived": "Credits Received",
|
||||
"dedfromlbr": "Deducted from Labor",
|
||||
"deleteconfirm": "Are you sure you want to delete this bill? It cannot be undone. If this bill has deductions from labors, manual changes may be required.",
|
||||
"discrepancy": "Discrepancy",
|
||||
@@ -155,7 +157,8 @@
|
||||
"noneselected": "No bill selected.",
|
||||
"retailtotal": "Retail Total of Bill (Ex. Taxes)",
|
||||
"state_tax": "State Tax",
|
||||
"subtotal": "Subtotal"
|
||||
"subtotal": "Subtotal",
|
||||
"totalreturns": "Total Returns"
|
||||
},
|
||||
"successes": {
|
||||
"created": "Invoice added successfully.",
|
||||
|
||||
@@ -141,6 +141,8 @@
|
||||
"bill_total": "",
|
||||
"billcmtotal": "",
|
||||
"bills": "",
|
||||
"creditsnotreceived": "",
|
||||
"creditsreceived": "",
|
||||
"dedfromlbr": "",
|
||||
"deleteconfirm": "",
|
||||
"discrepancy": "",
|
||||
@@ -155,7 +157,8 @@
|
||||
"noneselected": "",
|
||||
"retailtotal": "",
|
||||
"state_tax": "",
|
||||
"subtotal": ""
|
||||
"subtotal": "",
|
||||
"totalreturns": ""
|
||||
},
|
||||
"successes": {
|
||||
"created": "",
|
||||
|
||||
@@ -141,6 +141,8 @@
|
||||
"bill_total": "",
|
||||
"billcmtotal": "",
|
||||
"bills": "",
|
||||
"creditsnotreceived": "",
|
||||
"creditsreceived": "",
|
||||
"dedfromlbr": "",
|
||||
"deleteconfirm": "",
|
||||
"discrepancy": "",
|
||||
@@ -155,7 +157,8 @@
|
||||
"noneselected": "",
|
||||
"retailtotal": "",
|
||||
"state_tax": "",
|
||||
"subtotal": ""
|
||||
"subtotal": "",
|
||||
"totalreturns": ""
|
||||
},
|
||||
"successes": {
|
||||
"created": "",
|
||||
|
||||
Reference in New Issue
Block a user