BOD-23 Added labor pages tab + finalized time ticket tab + created allocation calculations
This commit is contained in:
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user