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) => {
|
const handleFinish = async (values) => {
|
||||||
setUpdateLoading(true);
|
setUpdateLoading(true);
|
||||||
|
//let adjustmentsToInsert = {};
|
||||||
|
|
||||||
const { billlines, upload, ...bill } = values;
|
const { billlines, upload, ...bill } = values;
|
||||||
const updates = [];
|
const updates = [];
|
||||||
updates.push(
|
updates.push(
|
||||||
@@ -39,8 +41,22 @@ export default function BillDetailEditcontainer() {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
billlines.forEach((il) => {
|
billlines.forEach((billline) => {
|
||||||
|
const { deductfromlabor, ...il } = billline;
|
||||||
delete il.__typename;
|
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) {
|
if (il.id) {
|
||||||
updates.push(
|
updates.push(
|
||||||
updateBillLine({
|
updateBillLine({
|
||||||
@@ -48,6 +64,7 @@ export default function BillDetailEditcontainer() {
|
|||||||
billLineId: il.id,
|
billLineId: il.id,
|
||||||
billLine: {
|
billLine: {
|
||||||
...il,
|
...il,
|
||||||
|
deductedfromlbr: deductfromlabor,
|
||||||
joblineid: il.joblineid === "noline" ? null : il.joblineid,
|
joblineid: il.joblineid === "noline" ? null : il.joblineid,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -61,6 +78,7 @@ export default function BillDetailEditcontainer() {
|
|||||||
billLines: [
|
billLines: [
|
||||||
{
|
{
|
||||||
...il,
|
...il,
|
||||||
|
deductedfromlbr: deductfromlabor,
|
||||||
billid: search.billid,
|
billid: search.billid,
|
||||||
joblineid: il.joblineid === "noline" ? null : il.joblineid,
|
joblineid: il.joblineid === "noline" ? null : il.joblineid,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user