BOD-23 Added labor pages tab + finalized time ticket tab + created allocation calculations

This commit is contained in:
Patrick Fic
2020-04-15 15:39:05 -07:00
parent 325a82ac86
commit 8e12320c19
20 changed files with 724 additions and 132 deletions

View File

@@ -0,0 +1,29 @@
export const CalculateAllocationsTotals = (
responsibilitycenters,
joblines,
timetickets
) => {
const jobCodes = joblines
.map((item) => item.mod_lbr_ty)
.filter((value, index, self) => self.indexOf(value) === index && !!value);
const ticketCodes = timetickets
.map((item) => item.cieca_code)
.filter((value, index, self) => self.indexOf(value) === index && !!value);
const allCodes = [...jobCodes, ...ticketCodes];
const r = allCodes.reduce((acc, value) => {
acc.push({
opcode: value,
cost_center: responsibilitycenters.defaults[value],
total: joblines.reduce((acc2, val2) => {
return val2.mod_lbr_ty === value ? acc2 + val2.mod_lb_hrs : acc2;
}, 0),
claimed: timetickets.reduce((acc3, val3) => {
return val3.ciecacode === value ? acc3 + val3.productivehrs : acc3;
}, 0),
});
return acc;
}, []);
return r;
};