Refactored job closing to be line based instead of totals based. BOD-383

This commit is contained in:
Patrick Fic
2020-09-14 13:54:11 -07:00
parent e3f108c567
commit eff49e3d25
34 changed files with 1030 additions and 822 deletions

View File

@@ -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}
}
`;
};