132 lines
3.7 KiB
JavaScript
132 lines
3.7 KiB
JavaScript
import { Table } from "antd";
|
|
import Dinero from "dinero.js";
|
|
import React, { useMemo } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import { connect } from "react-redux";
|
|
import { createStructuredSelector } from "reselect";
|
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
|
const mapStateToProps = createStructuredSelector({
|
|
//currentUser: selectCurrentUser
|
|
bodyshop: selectBodyshop,
|
|
});
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
|
});
|
|
export default connect(
|
|
mapStateToProps,
|
|
mapDispatchToProps
|
|
)(JobTotalsTableTotals);
|
|
|
|
export function JobTotalsTableTotals({ bodyshop, job }) {
|
|
const { t } = useTranslation();
|
|
|
|
const data = useMemo(() => {
|
|
return [
|
|
{
|
|
key: t("jobs.labels.subtotal"),
|
|
total: job.job_totals.totals.subtotal,
|
|
bold: true,
|
|
},
|
|
|
|
...(job.job_totals.totals.us_sales_tax_breakdown
|
|
? [
|
|
{
|
|
key: bodyshop.md_responsibility_centers.taxes.tax_ty1.tax_type1,
|
|
total: job.job_totals.totals.us_sales_tax_breakdown.ty1Tax,
|
|
},
|
|
{
|
|
key: bodyshop.md_responsibility_centers.taxes.tax_ty2.tax_type2,
|
|
total: job.job_totals.totals.us_sales_tax_breakdown.ty2Tax,
|
|
},
|
|
{
|
|
key: bodyshop.md_responsibility_centers.taxes.tax_ty3.tax_type3,
|
|
total: job.job_totals.totals.us_sales_tax_breakdown.ty3Tax,
|
|
},
|
|
{
|
|
key: bodyshop.md_responsibility_centers.taxes.tax_ty4.tax_type4,
|
|
total: job.job_totals.totals.us_sales_tax_breakdown.ty4Tax,
|
|
},
|
|
{
|
|
key: bodyshop.md_responsibility_centers.taxes.tax_ty5.tax_type5,
|
|
total: job.job_totals.totals.us_sales_tax_breakdown.ty5Tax,
|
|
},
|
|
]
|
|
: [
|
|
{
|
|
key: t("jobs.labels.state_tax_amt"),
|
|
total: job.job_totals.totals.state_tax,
|
|
},
|
|
]),
|
|
{
|
|
key: t("jobs.labels.total_repairs"),
|
|
total: job.job_totals.totals.total_repairs,
|
|
bold: true,
|
|
},
|
|
{
|
|
key: t("jobs.fields.ded_amt"),
|
|
total: job.job_totals.totals.custPayable.deductible,
|
|
},
|
|
{
|
|
key: t("jobs.fields.federal_tax_payable"),
|
|
total: job.job_totals.totals.custPayable.federal_tax,
|
|
},
|
|
{
|
|
key: t("jobs.fields.other_amount_payable"),
|
|
total: job.job_totals.totals.custPayable.other_customer_amount,
|
|
},
|
|
{
|
|
key: t("jobs.fields.depreciation_taxes"),
|
|
total: job.job_totals.totals.custPayable.dep_taxes,
|
|
},
|
|
|
|
{
|
|
key: t("jobs.labels.total_cust_payable"),
|
|
total: job.job_totals.totals.custPayable.total,
|
|
bold: true,
|
|
},
|
|
{
|
|
key: t("jobs.labels.net_repairs"),
|
|
total: job.job_totals.totals.net_repairs,
|
|
bold: true,
|
|
},
|
|
];
|
|
}, [job.job_totals, t, bodyshop.md_responsibility_centers]);
|
|
|
|
const columns = [
|
|
{
|
|
//title: t("joblines.fields.part_type"),
|
|
dataIndex: "key",
|
|
key: "key",
|
|
width: "80%",
|
|
onCell: (record, rowIndex) => {
|
|
return { style: { fontWeight: record.bold && "bold" } };
|
|
},
|
|
},
|
|
{
|
|
title: t("joblines.fields.total"),
|
|
dataIndex: "total",
|
|
key: "total",
|
|
align: "right",
|
|
render: (text, record) => Dinero(record.total).toFormat(),
|
|
width: "20%",
|
|
onCell: (record, rowIndex) => {
|
|
return { style: { fontWeight: record.bold && "bold" } };
|
|
},
|
|
},
|
|
];
|
|
|
|
return (
|
|
<Table
|
|
columns={columns}
|
|
rowKey="key"
|
|
showHeader={false}
|
|
pagination={false}
|
|
dataSource={data}
|
|
scroll={{
|
|
x: true,
|
|
}}
|
|
/>
|
|
);
|
|
}
|