Job costing improvements. IO-527

This commit is contained in:
Patrick Fic
2021-02-04 19:36:41 -08:00
parent 89d59d256c
commit 7a21721034
6 changed files with 66 additions and 16 deletions

View File

@@ -8,7 +8,7 @@ import { selectBodyshop } from "../../redux/user/user.selectors";
import JobCostingPartsTable from "../job-costing-parts-table/job-costing-parts-table.component";
import JobCostingStatistics from "../job-costing-statistics/job-costing-statistics.component";
import JobCostingPie from "./job-costing-modal.pie.component";
import _ from "lodash";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
});
@@ -18,6 +18,11 @@ const mapDispatchToProps = (dispatch) => ({
export function JobCostingModalComponent({ bodyshop, job }) {
const defaultProfits = bodyshop.md_responsibility_centers.defaults.profits;
const allProfitCenters = _.union(
bodyshop.md_responsibility_centers.profits.map((p) => p.name),
bodyshop.md_responsibility_centers.costs.map((p) => p.name)
);
// const defaultCosts = bodyshop.md_responsibility_centers.defaults.costs;
const { t } = useTranslation();
const jobLineTotalsByProfitCenter =
@@ -71,6 +76,7 @@ export function JobCostingModalComponent({ bodyshop, job }) {
.multiply(line_val.quantity)
.multiply(bill_val.is_credit_memo ? -1 : 1)
);
return null;
});
return bill_acc;
@@ -107,8 +113,8 @@ export function JobCostingModalComponent({ bodyshop, job }) {
gppercentFormatted: null,
};
const costCenterData = Object.keys(defaultProfits).map((key, idx) => {
const ccVal = defaultProfits[key];
const costCenterData = allProfitCenters.map((key, idx) => {
const ccVal = key; // defaultProfits[key];
const sale_labor =
jobLineTotalsByProfitCenter.labor[ccVal] || Dinero({ amount: 0 });
const sale_parts =
@@ -178,7 +184,11 @@ export function JobCostingModalComponent({ bodyshop, job }) {
return (
<div>
<JobCostingStatistics job={job} summaryData={summaryData} />
<JobCostingPartsTable job={job} data={costCenterData} />
<JobCostingPartsTable
job={job}
data={costCenterData}
summaryData={summaryData}
/>
<div className="imex-flex-row">
<div style={{ flex: 1 }}>
<Typography.Title level={4}>

View File

@@ -37,7 +37,9 @@ export function JobCostingModalContainer({
<Modal
visible={visible}
title={t("jobs.labels.jobcosting")}
onOk={() => toggleModalVisible()}
onCancel={() => toggleModalVisible()}
cancelButtonProps={{ style: { display: "none" } }}
width="90%"
destroyOnClose
>

View File

@@ -44,8 +44,6 @@ export default function JobCostingPieComponent({
Calculatedata,
]);
console.log(type, memoizedData);
return (
<ResponsiveContainer width="100%" height={175}>
<PieChart>