IO-791 Bill edit deduct from labor WIP.
This commit is contained in:
@@ -31,6 +31,8 @@ export default function BillDetailEditcontainer() {
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
setUpdateLoading(true);
|
||||
//let adjustmentsToInsert = {};
|
||||
|
||||
const { billlines, upload, ...bill } = values;
|
||||
const updates = [];
|
||||
updates.push(
|
||||
@@ -39,8 +41,22 @@ export default function BillDetailEditcontainer() {
|
||||
})
|
||||
);
|
||||
|
||||
billlines.forEach((il) => {
|
||||
billlines.forEach((billline) => {
|
||||
const { deductfromlabor, ...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.deductfromlabor !== deductfromlabor) {
|
||||
//There's a different
|
||||
}
|
||||
}
|
||||
|
||||
if (il.id) {
|
||||
updates.push(
|
||||
updateBillLine({
|
||||
@@ -48,6 +64,7 @@ export default function BillDetailEditcontainer() {
|
||||
billLineId: il.id,
|
||||
billLine: {
|
||||
...il,
|
||||
deductedfromlbr: deductfromlabor,
|
||||
joblineid: il.joblineid === "noline" ? null : il.joblineid,
|
||||
},
|
||||
},
|
||||
@@ -61,6 +78,7 @@ export default function BillDetailEditcontainer() {
|
||||
billLines: [
|
||||
{
|
||||
...il,
|
||||
deductedfromlbr: deductfromlabor,
|
||||
billid: search.billid,
|
||||
joblineid: il.joblineid === "noline" ? null : il.joblineid,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user