IO-792 Track lbr_adjustments and resolve errors on edit.

This commit is contained in:
Patrick Fic
2021-03-25 09:59:36 -07:00
parent 743ce25a72
commit 92df7f3ad4
13 changed files with 256 additions and 30 deletions

View File

@@ -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);

View File

@@ -73,6 +73,7 @@ function BillEnterModalContainer({
return {
...restI,
deductedfromlbr: deductedfromlbr,
lbr_adjustment,
joblineid: i.joblineid === "noline" ? null : i.joblineid,
};
}),

View File

@@ -255,14 +255,7 @@ export function BillEnterModalLinesComponent({
>
<Switch disabled={disabled} />
</Form.Item>
<Form.Item
shouldUpdate={(prev, cur) =>
prev.billlines[index] &&
prev.billlines[index].deductedfromlbr !==
cur.billlines[index] &&
cur.billlines[index].deductedfromlbr
}
>
<Form.Item shouldUpdate>
{() => {
if (
getFieldValue([

View File

@@ -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

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."billlines" DROP COLUMN "lbr_adjustment";
type: run_sql

View File

@@ -0,0 +1,5 @@
- args:
cascade: false
read_only: false
sql: ALTER TABLE "public"."billlines" ADD COLUMN "lbr_adjustment" jsonb NULL;
type: run_sql

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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