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