From 0498c8781f35f234b5063ecc7f94f385706fb140 Mon Sep 17 00:00:00 2001
From: Patrick Fic <>
Date: Tue, 30 Mar 2021 11:00:15 -0700
Subject: [PATCH] IO-793 Add additional job totals calculations to pli.
---
bodyshop_translations.babel | 63 +++++++++++++++++++
.../job-bills-total.component.jsx | 37 ++++++++++-
.../jobs-detail-pli.component.jsx | 1 +
.../parts-order-list-table.component.jsx | 15 ++---
client/src/translations/en_us/common.json | 5 +-
client/src/translations/es/common.json | 5 +-
client/src/translations/fr/common.json | 5 +-
7 files changed, 118 insertions(+), 13 deletions(-)
diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel
index 0d2161130..9bdee7699 100644
--- a/bodyshop_translations.babel
+++ b/bodyshop_translations.babel
@@ -2055,6 +2055,48 @@
+
+ creditsnotreceived
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
+
+ creditsreceived
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
dedfromlbr
false
@@ -2370,6 +2412,27 @@
+
+ totalreturns
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
diff --git a/client/src/components/job-bills-total/job-bills-total.component.jsx b/client/src/components/job-bills-total/job-bills-total.component.jsx
index af8d68bd1..3646c4885 100644
--- a/client/src/components/job-bills-total/job-bills-total.component.jsx
+++ b/client/src/components/job-bills-total/job-bills-total.component.jsx
@@ -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 ;
@@ -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 (
@@ -95,6 +115,21 @@ export default function JobBillsTotalComponent({ loading, bills, jobTotals }) {
}}
value={discrepWithCms.toFormat()}
/>
+ {" "}
+
+
);
diff --git a/client/src/components/jobs-detail-pli/jobs-detail-pli.component.jsx b/client/src/components/jobs-detail-pli/jobs-detail-pli.component.jsx
index 955501962..d33ff31a5 100644
--- a/client/src/components/jobs-detail-pli/jobs-detail-pli.component.jsx
+++ b/client/src/components/jobs-detail-pli/jobs-detail-pli.component.jsx
@@ -23,6 +23,7 @@ export default function JobsDetailPliComponent({
diff --git a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx
index bf2792c46..c1c79c677 100644
--- a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx
+++ b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx
@@ -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) => (
- {record.db_price}
- ),
+ state.sortedInfo.columnKey === "quantity" && state.sortedInfo.order,
},
{
@@ -255,7 +252,7 @@ export function PartsOrderListTableComponent({
{record.act_price}
),
},
- ...(selectedPartsOrderRecord && selectedPartsOrderRecord.isReturn
+ ...(selectedPartsOrderRecord && selectedPartsOrderRecord.return
? [
{
title: t("parts_orders.fields.cost"),
diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json
index c6e6f6eb6..b862dd9f2 100644
--- a/client/src/translations/en_us/common.json
+++ b/client/src/translations/en_us/common.json
@@ -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.",
diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json
index 13b177892..d17627a8e 100644
--- a/client/src/translations/es/common.json
+++ b/client/src/translations/es/common.json
@@ -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": "",
diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json
index 2d10305e2..76251f7e0 100644
--- a/client/src/translations/fr/common.json
+++ b/client/src/translations/fr/common.json
@@ -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": "",