Fixed bugs on parts allocations + added totals BOD-131
This commit is contained in:
@@ -1,28 +1,18 @@
|
||||
import Dinero from "dinero.js";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import AllocationButton from "../jobs-close-allocation-button/jobs-close-allocation-button.component";
|
||||
import Dinero from "dinero.js";
|
||||
import AllocationTags from "../jobs-close-allocation-tags/jobs-close-allocation-tags.component";
|
||||
|
||||
import { List } from "antd";
|
||||
|
||||
export default function JobCloseLabMatAllocation({
|
||||
labmatAllocations,
|
||||
setLabmatAllocations,
|
||||
labMatTotalAllocation
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const allocatedTotalsArray = Object.keys(labmatAllocations)
|
||||
.filter((i) => !i.includes("subtotal"))
|
||||
.map((i) => labmatAllocations[i].allocations)
|
||||
.flat();
|
||||
|
||||
const allocatedTotal = Dinero({
|
||||
amount: allocatedTotalsArray.reduce((acc, val) => {
|
||||
console.log("acc", acc);
|
||||
return (acc = acc + val.amount.getAmount());
|
||||
}, 0),
|
||||
});
|
||||
|
||||
return (
|
||||
<div style={{ display: "flex" }}>
|
||||
@@ -81,22 +71,12 @@ export default function JobCloseLabMatAllocation({
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>{labmatAllocations.subtotal.toFormat()}</td>
|
||||
<td>{allocatedTotal.toFormat()}</td>
|
||||
<td>{labMatTotalAllocation.toFormat()}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div>
|
||||
<List>
|
||||
{allocatedTotalsArray.map((i, idx) => (
|
||||
<List.Item key={idx}>{`${
|
||||
i.center
|
||||
} ${i.amount.toFormat()}`}</List.Item>
|
||||
))}
|
||||
</List>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user