Added team pay calculator.
This commit is contained in:
@@ -10,7 +10,7 @@ import { onlyUnique } from "../../utils/arrayHelper";
|
||||
import { alphaSort } from "../../utils/sorters";
|
||||
import { TemplateList } from "../../utils/TemplateConstants";
|
||||
import PrintWrapperComponent from "../print-wrapper/print-wrapper.component";
|
||||
|
||||
import Dinero from "dinero.js";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
@@ -129,6 +129,16 @@ const JobRelatedTicketsTable = ({
|
||||
return acc;
|
||||
}, 0);
|
||||
|
||||
const pay = item.tickets
|
||||
.filter((ticket) => ticket.cost_center === costCenter)
|
||||
.reduce((acc, val) => {
|
||||
return acc.add(
|
||||
Dinero({ amount: Math.round(val.rate * 100) }).multiply(
|
||||
val.flat_rate ? val.productivehrs : val.actualhrs
|
||||
)
|
||||
);
|
||||
}, Dinero());
|
||||
|
||||
return {
|
||||
id: `${item.jobKey}${costCenter}`,
|
||||
costCenter,
|
||||
@@ -136,6 +146,7 @@ const JobRelatedTicketsTable = ({
|
||||
actHrs: actHrs.toFixed(1),
|
||||
prodHrs: prodHrs.toFixed(1),
|
||||
clockHrs,
|
||||
pay,
|
||||
};
|
||||
});
|
||||
})
|
||||
@@ -195,6 +206,15 @@ const JobRelatedTicketsTable = ({
|
||||
state.sortedInfo.columnKey === "clockHrs" && state.sortedInfo.order,
|
||||
render: (text, record) => record.clockHrs.toFixed(2),
|
||||
},
|
||||
{
|
||||
title: "Pay",
|
||||
dataIndex: "Pay",
|
||||
key: "Pay",
|
||||
sorter: (a, b) => a.clockHrs - b.clockHrs,
|
||||
sortOrder:
|
||||
state.sortedInfo.columnKey === "clockHrs" && state.sortedInfo.order,
|
||||
render: (text, record) => record.pay.toFormat("$0.00"),
|
||||
},
|
||||
{
|
||||
title: t("general.labels.actions"),
|
||||
dataIndex: "actions",
|
||||
|
||||
Reference in New Issue
Block a user