Refactored job closing to be line based instead of totals based. BOD-383
This commit is contained in:
@@ -149,3 +149,30 @@ export const GET_JOB_LINES_TO_ENTER_INVOICE = gql`
|
||||
// act_price: {
|
||||
// _gt: "0";
|
||||
// }
|
||||
|
||||
export const generateJobLinesUpdatesForInvoicing = (joblines) => {
|
||||
console.log("generateJobLinesUpdatesForInvoicing -> joblines", joblines);
|
||||
const updates = joblines.reduce((acc, jl, idx) => {
|
||||
return (
|
||||
acc +
|
||||
`a${idx}:update_joblines(where: {id: {_eq: "${
|
||||
jl.id
|
||||
}"}}, _set: {profitcenter_labor: "${
|
||||
jl.profitcenter_labor || ""
|
||||
}", profitcenter_part: "${jl.profitcenter_part || ""}"}) {
|
||||
returning {
|
||||
line_desc
|
||||
profitcenter_part
|
||||
profitcenter_labor
|
||||
id
|
||||
}
|
||||
}`
|
||||
);
|
||||
}, "");
|
||||
|
||||
return gql`
|
||||
mutation UPDATE_JOBLINES_FOR_INVOICING{
|
||||
${updates}
|
||||
}
|
||||
`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user