diff --git a/client/src/components/bill-detail-edit/bill-detail-edit.container.jsx b/client/src/components/bill-detail-edit/bill-detail-edit.container.jsx
index 4d5316370..2b4b83541 100644
--- a/client/src/components/bill-detail-edit/bill-detail-edit.container.jsx
+++ b/client/src/components/bill-detail-edit/bill-detail-edit.container.jsx
@@ -32,7 +32,11 @@ export default function BillDetailEditcontainer() {
const handleSave = () => {
//It's got a previously deducted bill line!
- if (data.bills_by_pk.billlines.filter((b) => b.deductedfromlbr).length > 0)
+ if (
+ data.bills_by_pk.billlines.filter((b) => b.deductedfromlbr).length > 0 ||
+ form.getFieldValue("billlines").filter((b) => b.deductedfromlbr).length >
+ 0
+ )
setVisible(true);
else {
form.submit();
@@ -55,18 +59,6 @@ export default function BillDetailEditcontainer() {
const { deductedfromlbr, ...il } = billline;
delete il.__typename;
- //Need to compare this line to the previous version of the line to see if there is a change in the adjustments.
- const theOldBillLine = data.bills_by_pk.billlines.find(
- (bl) => bl.id === billline.id
- );
-
- if (theOldBillLine) {
- //It was there! Need to change the diff.
- if (theOldBillLine.deductedfromlbr !== deductedfromlbr) {
- //There's a different
- }
- }
-
if (il.id) {
updates.push(
updateBillLine({
@@ -101,7 +93,7 @@ export default function BillDetailEditcontainer() {
await Promise.all(updates);
await refetch();
- form.resetFields();
+ form.setFieldsValue(transformData(data));
form.resetFields();
setVisible(false);
setUpdateLoading(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 bfaf625ef..8e41fcee6 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
@@ -73,6 +73,7 @@ function BillEnterModalContainer({
return {
...restI,
deductedfromlbr: deductedfromlbr,
+ lbr_adjustment,
joblineid: i.joblineid === "noline" ? null : i.joblineid,
};
}),
diff --git a/client/src/components/bill-form/bill-form.lines.component.jsx b/client/src/components/bill-form/bill-form.lines.component.jsx
index 276612e8e..3663198de 100644
--- a/client/src/components/bill-form/bill-form.lines.component.jsx
+++ b/client/src/components/bill-form/bill-form.lines.component.jsx
@@ -255,14 +255,7 @@ export function BillEnterModalLinesComponent({
>
-
- prev.billlines[index] &&
- prev.billlines[index].deductedfromlbr !==
- cur.billlines[index] &&
- cur.billlines[index].deductedfromlbr
- }
- >
+
{() => {
if (
getFieldValue([
diff --git a/client/src/graphql/bills.queries.js b/client/src/graphql/bills.queries.js
index ab629993d..5bb4f0099 100644
--- a/client/src/graphql/bills.queries.js
+++ b/client/src/graphql/bills.queries.js
@@ -50,14 +50,6 @@ export const QUERY_ALL_BILLS_PAGINATED = gql`
id
ro_number
}
- billlines {
- actual_price
- quantity
- actual_cost
- cost_center
- id
- line_desc
- }
}
search_bills_aggregate(args: { search: $search }) {
aggregate {
@@ -129,6 +121,7 @@ export const QUERY_BILLS_BY_JOBID = gql`
line_desc
applicable_taxes
deductedfromlbr
+ lbr_adjustment
}
}
}
@@ -167,6 +160,7 @@ export const QUERY_BILL_BY_PK = gql`
joblineid
applicable_taxes
deductedfromlbr
+ lbr_adjustment
}
documents {
id
diff --git a/hasura/migrations/1616690848634_alter_table_public_billlines_add_column_lbr_adjustment/down.yaml b/hasura/migrations/1616690848634_alter_table_public_billlines_add_column_lbr_adjustment/down.yaml
new file mode 100644
index 000000000..c5d2f8246
--- /dev/null
+++ b/hasura/migrations/1616690848634_alter_table_public_billlines_add_column_lbr_adjustment/down.yaml
@@ -0,0 +1,5 @@
+- args:
+ cascade: false
+ read_only: false
+ sql: ALTER TABLE "public"."billlines" DROP COLUMN "lbr_adjustment";
+ type: run_sql
diff --git a/hasura/migrations/1616690848634_alter_table_public_billlines_add_column_lbr_adjustment/up.yaml b/hasura/migrations/1616690848634_alter_table_public_billlines_add_column_lbr_adjustment/up.yaml
new file mode 100644
index 000000000..ebe3a00bd
--- /dev/null
+++ b/hasura/migrations/1616690848634_alter_table_public_billlines_add_column_lbr_adjustment/up.yaml
@@ -0,0 +1,5 @@
+- args:
+ cascade: false
+ read_only: false
+ sql: ALTER TABLE "public"."billlines" ADD COLUMN "lbr_adjustment" jsonb NULL;
+ type: run_sql
diff --git a/hasura/migrations/1616690903375_update_permission_user_public_table_billlines/down.yaml b/hasura/migrations/1616690903375_update_permission_user_public_table_billlines/down.yaml
new file mode 100644
index 000000000..283c766e9
--- /dev/null
+++ b/hasura/migrations/1616690903375_update_permission_user_public_table_billlines/down.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/1616690903375_update_permission_user_public_table_billlines/up.yaml b/hasura/migrations/1616690903375_update_permission_user_public_table_billlines/up.yaml
new file mode 100644
index 000000000..507c967e2
--- /dev/null
+++ b/hasura/migrations/1616690903375_update_permission_user_public_table_billlines/up.yaml
@@ -0,0 +1,39 @@
+- 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
+ - lbr_adjustment
+ - line_desc
+ - quantity
+ - updated_at
+ set: {}
+ role: user
+ table:
+ name: billlines
+ schema: public
+ type: create_insert_permission
diff --git a/hasura/migrations/1616690912315_update_permission_user_public_table_billlines/down.yaml b/hasura/migrations/1616690912315_update_permission_user_public_table_billlines/down.yaml
new file mode 100644
index 000000000..7e1690469
--- /dev/null
+++ b/hasura/migrations/1616690912315_update_permission_user_public_table_billlines/down.yaml
@@ -0,0 +1,39 @@
+- args:
+ role: user
+ table:
+ name: billlines
+ schema: public
+ type: drop_select_permission
+- args:
+ permission:
+ allow_aggregations: true
+ 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/1616690912315_update_permission_user_public_table_billlines/up.yaml b/hasura/migrations/1616690912315_update_permission_user_public_table_billlines/up.yaml
new file mode 100644
index 000000000..0d2daa4d5
--- /dev/null
+++ b/hasura/migrations/1616690912315_update_permission_user_public_table_billlines/up.yaml
@@ -0,0 +1,40 @@
+- args:
+ role: user
+ table:
+ name: billlines
+ schema: public
+ type: drop_select_permission
+- args:
+ permission:
+ allow_aggregations: true
+ columns:
+ - actual_cost
+ - actual_price
+ - applicable_taxes
+ - billid
+ - cost_center
+ - created_at
+ - deductedfromlbr
+ - id
+ - joblineid
+ - lbr_adjustment
+ - 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/1616690919696_update_permission_user_public_table_billlines/down.yaml b/hasura/migrations/1616690919696_update_permission_user_public_table_billlines/down.yaml
new file mode 100644
index 000000000..a3942892a
--- /dev/null
+++ b/hasura/migrations/1616690919696_update_permission_user_public_table_billlines/down.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/1616690919696_update_permission_user_public_table_billlines/up.yaml b/hasura/migrations/1616690919696_update_permission_user_public_table_billlines/up.yaml
new file mode 100644
index 000000000..95a79d99a
--- /dev/null
+++ b/hasura/migrations/1616690919696_update_permission_user_public_table_billlines/up.yaml
@@ -0,0 +1,39 @@
+- 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
+ - lbr_adjustment
+ - 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 24d0c1da1..2ccc1c911 100644
--- a/hasura/migrations/metadata.yaml
+++ b/hasura/migrations/metadata.yaml
@@ -394,6 +394,7 @@ tables:
- deductedfromlbr
- id
- joblineid
+ - lbr_adjustment
- line_desc
- quantity
- updated_at
@@ -410,6 +411,7 @@ tables:
- deductedfromlbr
- id
- joblineid
+ - lbr_adjustment
- line_desc
- quantity
- updated_at
@@ -438,6 +440,7 @@ tables:
- deductedfromlbr
- id
- joblineid
+ - lbr_adjustment
- line_desc
- quantity
- updated_at