diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel
index 0b3033d4c..6af4875a0 100644
--- a/bodyshop_translations.babel
+++ b/bodyshop_translations.babel
@@ -1971,6 +1971,27 @@
+
+ billcmtotal
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
bills
false
@@ -1992,6 +2013,27 @@
+
+ dedfromlbr
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
discrepancy
false
@@ -2013,6 +2055,48 @@
+
+ discrepwithcms
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
+
+ discrepwithlbradj
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
entered_total
false
@@ -18328,6 +18412,27 @@
+
+ rosaletotal
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
sale_labor
false
@@ -21964,6 +22069,27 @@
+
+ return
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
status
false
diff --git a/client/src/components/bill-enter-modal/bill-enter-modal.container.jsx b/client/src/components/bill-enter-modal/bill-enter-modal.container.jsx
index d2440b6d1..1caf66328 100644
--- a/client/src/components/bill-enter-modal/bill-enter-modal.container.jsx
+++ b/client/src/components/bill-enter-modal/bill-enter-modal.container.jsx
@@ -74,6 +74,7 @@ function BillEnterModalContainer({
}
return {
...restI,
+ deductedfromlbr: deductfromlabor,
joblineid: i.joblineid === "noline" ? null : i.joblineid,
};
}),
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 ada6ec809..1407cd37a 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
@@ -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 (
+
+
+
+
);
}
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 8d10749bc..fb8f2153c 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
@@ -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({
{record.order_date}
),
},
+ {
+ 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) => ,
+ },
{
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[
diff --git a/client/src/components/parts-order-modal/parts-order-modal.container.jsx b/client/src/components/parts-order-modal/parts-order-modal.container.jsx
index 2729a89a2..8fbf0f900 100644
--- a/client/src/components/parts-order-modal/parts-order-modal.container.jsx
+++ b/client/src/components/parts-order-modal/parts-order-modal.container.jsx
@@ -82,6 +82,7 @@ export function PartsOrderModalContainer({
...values,
jobid: jobId,
user_email: currentUser.email,
+ return: isReturn,
status: bodyshop.md_order_statuses.default_ordered || "Ordered*",
},
],
diff --git a/client/src/graphql/bills.queries.js b/client/src/graphql/bills.queries.js
index dbd16e0bf..247005449 100644
--- a/client/src/graphql/bills.queries.js
+++ b/client/src/graphql/bills.queries.js
@@ -70,6 +70,7 @@ export const QUERY_BILLS_BY_JOBID = gql`
}
order_date
deliver_by
+ return
parts_order_lines {
id
act_price
@@ -114,6 +115,7 @@ export const QUERY_BILLS_BY_JOBID = gql`
joblineid
line_desc
applicable_taxes
+ deductedfromlbr
}
}
}
diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json
index 6a02ffc12..be6f35bde 100644
--- a/client/src/translations/en_us/common.json
+++ b/client/src/translations/en_us/common.json
@@ -137,8 +137,12 @@
"actions": "Actions",
"bill_lines": "Bill Lines",
"bill_total": "Bill Total Amount",
+ "billcmtotal": "Retail Total of Credit Memos",
"bills": "Bills",
+ "dedfromlbr": "Deducted from Labor",
"discrepancy": "Discrepancy",
+ "discrepwithcms": "Discrepancy including Credit Memos",
+ "discrepwithlbradj": "Discrepancy including Lbr. Adj.",
"entered_total": "Total of Entered Lines",
"enteringcreditmemo": "You are entering a credit memo. Please ensure you are also entering positive values.",
"federal_tax": "Federal Tax",
@@ -1115,6 +1119,7 @@
"multiplebillsforactprice": "Found more than 1 bill matching ${{act_price}} retail price."
},
"reconciliationheader": "Parts & Sublet Reconciliation",
+ "rosaletotal": "Total RO Sale",
"sale_labor": "Sales - Labor",
"sale_parts": "Sales - Parts",
"sales": "Sales",
@@ -1341,6 +1346,7 @@
"order_date": "Order Date",
"order_number": "Order Number",
"quantity": "Qty.",
+ "return": "Return",
"status": "Status"
},
"labels": {
diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json
index 3682b55c7..9ef29d1b6 100644
--- a/client/src/translations/es/common.json
+++ b/client/src/translations/es/common.json
@@ -137,8 +137,12 @@
"actions": "",
"bill_lines": "",
"bill_total": "",
+ "billcmtotal": "",
"bills": "",
+ "dedfromlbr": "",
"discrepancy": "",
+ "discrepwithcms": "",
+ "discrepwithlbradj": "",
"entered_total": "",
"enteringcreditmemo": "",
"federal_tax": "",
@@ -1115,6 +1119,7 @@
"multiplebillsforactprice": ""
},
"reconciliationheader": "",
+ "rosaletotal": "",
"sale_labor": "",
"sale_parts": "",
"sales": "",
@@ -1341,6 +1346,7 @@
"order_date": "",
"order_number": "",
"quantity": "",
+ "return": "",
"status": ""
},
"labels": {
diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json
index b1b6bc11b..9dbd8d97d 100644
--- a/client/src/translations/fr/common.json
+++ b/client/src/translations/fr/common.json
@@ -137,8 +137,12 @@
"actions": "",
"bill_lines": "",
"bill_total": "",
+ "billcmtotal": "",
"bills": "",
+ "dedfromlbr": "",
"discrepancy": "",
+ "discrepwithcms": "",
+ "discrepwithlbradj": "",
"entered_total": "",
"enteringcreditmemo": "",
"federal_tax": "",
@@ -1115,6 +1119,7 @@
"multiplebillsforactprice": ""
},
"reconciliationheader": "",
+ "rosaletotal": "",
"sale_labor": "",
"sale_parts": "",
"sales": "",
@@ -1341,6 +1346,7 @@
"order_date": "",
"order_number": "",
"quantity": "",
+ "return": "",
"status": ""
},
"labels": {
diff --git a/hasura/migrations/1611175609588_alter_table_public_billlines_add_column_deductedfromlbr/down.yaml b/hasura/migrations/1611175609588_alter_table_public_billlines_add_column_deductedfromlbr/down.yaml
new file mode 100644
index 000000000..03d974c9e
--- /dev/null
+++ b/hasura/migrations/1611175609588_alter_table_public_billlines_add_column_deductedfromlbr/down.yaml
@@ -0,0 +1,5 @@
+- args:
+ cascade: false
+ read_only: false
+ sql: ALTER TABLE "public"."billlines" DROP COLUMN "deductedfromlbr";
+ type: run_sql
diff --git a/hasura/migrations/1611175609588_alter_table_public_billlines_add_column_deductedfromlbr/up.yaml b/hasura/migrations/1611175609588_alter_table_public_billlines_add_column_deductedfromlbr/up.yaml
new file mode 100644
index 000000000..febcecd76
--- /dev/null
+++ b/hasura/migrations/1611175609588_alter_table_public_billlines_add_column_deductedfromlbr/up.yaml
@@ -0,0 +1,6 @@
+- args:
+ cascade: false
+ read_only: false
+ sql: ALTER TABLE "public"."billlines" ADD COLUMN "deductedfromlbr" boolean NOT
+ NULL DEFAULT false;
+ type: run_sql
diff --git a/hasura/migrations/1611175625070_update_permission_user_public_table_billlines/down.yaml b/hasura/migrations/1611175625070_update_permission_user_public_table_billlines/down.yaml
new file mode 100644
index 000000000..b8f6ce79a
--- /dev/null
+++ b/hasura/migrations/1611175625070_update_permission_user_public_table_billlines/down.yaml
@@ -0,0 +1,37 @@
+- args:
+ role: user
+ table:
+ name: billlines
+ schema: public
+ type: drop_insert_permission
+- args:
+ permission:
+ check:
+ bill:
+ job:
+ bodyshop:
+ associations:
+ _and:
+ - user:
+ authid:
+ _eq: X-Hasura-User-Id
+ - active:
+ _eq: true
+ columns:
+ - actual_cost
+ - actual_price
+ - applicable_taxes
+ - cost_center
+ - created_at
+ - id
+ - billid
+ - joblineid
+ - line_desc
+ - quantity
+ - updated_at
+ set: {}
+ role: user
+ table:
+ name: billlines
+ schema: public
+ type: create_insert_permission
diff --git a/hasura/migrations/1611175625070_update_permission_user_public_table_billlines/up.yaml b/hasura/migrations/1611175625070_update_permission_user_public_table_billlines/up.yaml
new file mode 100644
index 000000000..283c766e9
--- /dev/null
+++ b/hasura/migrations/1611175625070_update_permission_user_public_table_billlines/up.yaml
@@ -0,0 +1,38 @@
+- args:
+ role: user
+ table:
+ name: billlines
+ schema: public
+ type: drop_insert_permission
+- args:
+ permission:
+ check:
+ bill:
+ job:
+ bodyshop:
+ associations:
+ _and:
+ - user:
+ authid:
+ _eq: X-Hasura-User-Id
+ - active:
+ _eq: true
+ columns:
+ - actual_cost
+ - actual_price
+ - applicable_taxes
+ - billid
+ - cost_center
+ - created_at
+ - deductedfromlbr
+ - id
+ - joblineid
+ - line_desc
+ - quantity
+ - updated_at
+ set: {}
+ role: user
+ table:
+ name: billlines
+ schema: public
+ type: create_insert_permission
diff --git a/hasura/migrations/1611175633677_update_permission_user_public_table_billlines/down.yaml b/hasura/migrations/1611175633677_update_permission_user_public_table_billlines/down.yaml
new file mode 100644
index 000000000..07d0a8f77
--- /dev/null
+++ b/hasura/migrations/1611175633677_update_permission_user_public_table_billlines/down.yaml
@@ -0,0 +1,38 @@
+- args:
+ role: user
+ table:
+ name: billlines
+ schema: public
+ type: drop_select_permission
+- args:
+ permission:
+ allow_aggregations: false
+ columns:
+ - actual_cost
+ - actual_price
+ - applicable_taxes
+ - cost_center
+ - created_at
+ - id
+ - billid
+ - joblineid
+ - line_desc
+ - quantity
+ - updated_at
+ computed_fields: []
+ filter:
+ bill:
+ job:
+ bodyshop:
+ associations:
+ _and:
+ - user:
+ authid:
+ _eq: X-Hasura-User-Id
+ - active:
+ _eq: true
+ role: user
+ table:
+ name: billlines
+ schema: public
+ type: create_select_permission
diff --git a/hasura/migrations/1611175633677_update_permission_user_public_table_billlines/up.yaml b/hasura/migrations/1611175633677_update_permission_user_public_table_billlines/up.yaml
new file mode 100644
index 000000000..4404c8657
--- /dev/null
+++ b/hasura/migrations/1611175633677_update_permission_user_public_table_billlines/up.yaml
@@ -0,0 +1,39 @@
+- args:
+ role: user
+ table:
+ name: billlines
+ schema: public
+ type: drop_select_permission
+- args:
+ permission:
+ allow_aggregations: false
+ columns:
+ - actual_cost
+ - actual_price
+ - applicable_taxes
+ - billid
+ - cost_center
+ - created_at
+ - deductedfromlbr
+ - id
+ - joblineid
+ - line_desc
+ - quantity
+ - updated_at
+ computed_fields: []
+ filter:
+ bill:
+ job:
+ bodyshop:
+ associations:
+ _and:
+ - user:
+ authid:
+ _eq: X-Hasura-User-Id
+ - active:
+ _eq: true
+ role: user
+ table:
+ name: billlines
+ schema: public
+ type: create_select_permission
diff --git a/hasura/migrations/1611175641709_update_permission_user_public_table_billlines/down.yaml b/hasura/migrations/1611175641709_update_permission_user_public_table_billlines/down.yaml
new file mode 100644
index 000000000..ed7ecc9b1
--- /dev/null
+++ b/hasura/migrations/1611175641709_update_permission_user_public_table_billlines/down.yaml
@@ -0,0 +1,37 @@
+- args:
+ role: user
+ table:
+ name: billlines
+ schema: public
+ type: drop_update_permission
+- args:
+ permission:
+ columns:
+ - actual_cost
+ - actual_price
+ - applicable_taxes
+ - cost_center
+ - created_at
+ - id
+ - billid
+ - joblineid
+ - line_desc
+ - quantity
+ - updated_at
+ filter:
+ bill:
+ job:
+ bodyshop:
+ associations:
+ _and:
+ - user:
+ authid:
+ _eq: X-Hasura-User-Id
+ - active:
+ _eq: true
+ set: {}
+ role: user
+ table:
+ name: billlines
+ schema: public
+ type: create_update_permission
diff --git a/hasura/migrations/1611175641709_update_permission_user_public_table_billlines/up.yaml b/hasura/migrations/1611175641709_update_permission_user_public_table_billlines/up.yaml
new file mode 100644
index 000000000..a3942892a
--- /dev/null
+++ b/hasura/migrations/1611175641709_update_permission_user_public_table_billlines/up.yaml
@@ -0,0 +1,38 @@
+- args:
+ role: user
+ table:
+ name: billlines
+ schema: public
+ type: drop_update_permission
+- args:
+ permission:
+ columns:
+ - actual_cost
+ - actual_price
+ - applicable_taxes
+ - billid
+ - cost_center
+ - created_at
+ - deductedfromlbr
+ - id
+ - joblineid
+ - line_desc
+ - quantity
+ - updated_at
+ filter:
+ bill:
+ job:
+ bodyshop:
+ associations:
+ _and:
+ - user:
+ authid:
+ _eq: X-Hasura-User-Id
+ - active:
+ _eq: true
+ set: {}
+ role: user
+ table:
+ name: billlines
+ schema: public
+ type: create_update_permission
diff --git a/hasura/migrations/metadata.yaml b/hasura/migrations/metadata.yaml
index a57f88a39..cd7148eab 100644
--- a/hasura/migrations/metadata.yaml
+++ b/hasura/migrations/metadata.yaml
@@ -385,10 +385,11 @@ tables:
- actual_cost
- actual_price
- applicable_taxes
+ - billid
- cost_center
- created_at
+ - deductedfromlbr
- id
- - billid
- joblineid
- line_desc
- quantity
@@ -400,10 +401,11 @@ tables:
- actual_cost
- actual_price
- applicable_taxes
+ - billid
- cost_center
- created_at
+ - deductedfromlbr
- id
- - billid
- joblineid
- line_desc
- quantity
@@ -426,10 +428,11 @@ tables:
- actual_cost
- actual_price
- applicable_taxes
+ - billid
- cost_center
- created_at
+ - deductedfromlbr
- id
- - billid
- joblineid
- line_desc
- quantity