CC Conversion Corrections IO-463
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
import React, { useState } from "react";
|
||||
import { Button, notification, Popover, Radio, Form, InputNumber } from "antd";
|
||||
import {
|
||||
Button,
|
||||
notification,
|
||||
Popover,
|
||||
Radio,
|
||||
Form,
|
||||
InputNumber,
|
||||
Space,
|
||||
} from "antd";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useMutation } from "react-apollo";
|
||||
import { INSERT_NEW_JOB } from "../../graphql/jobs.queries";
|
||||
@@ -11,6 +19,8 @@ import {
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import { useHistory } from "react-router-dom";
|
||||
import axios from "axios";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -20,7 +30,12 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
});
|
||||
|
||||
export function ContractConvertToRo({ bodyshop, currentUser, contract }) {
|
||||
export function ContractConvertToRo({
|
||||
bodyshop,
|
||||
currentUser,
|
||||
contract,
|
||||
disabled,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -46,6 +61,7 @@ export function ContractConvertToRo({ bodyshop, currentUser, contract }) {
|
||||
part_type: "CCDR",
|
||||
tax_part: true,
|
||||
mod_lb_hrs: 0,
|
||||
db_ref: "io-ccdr",
|
||||
// mod_lbr_ty: "PAL",
|
||||
},
|
||||
];
|
||||
@@ -63,6 +79,7 @@ export function ContractConvertToRo({ bodyshop, currentUser, contract }) {
|
||||
part_type: "CCM",
|
||||
part_qty: mileageDiff,
|
||||
tax_part: true,
|
||||
db_ref: "io-ccm",
|
||||
mod_lb_hrs: 0,
|
||||
});
|
||||
}
|
||||
@@ -78,6 +95,7 @@ export function ContractConvertToRo({ bodyshop, currentUser, contract }) {
|
||||
part_qty: values.refuelqty,
|
||||
part_type: "CCF",
|
||||
tax_part: true,
|
||||
db_ref: "io-ccf",
|
||||
mod_lb_hrs: 0,
|
||||
});
|
||||
}
|
||||
@@ -92,6 +110,7 @@ export function ContractConvertToRo({ bodyshop, currentUser, contract }) {
|
||||
part_qty: 1,
|
||||
part_type: "CCC",
|
||||
tax_part: true,
|
||||
db_ref: "io-ccc",
|
||||
mod_lb_hrs: 0,
|
||||
});
|
||||
}
|
||||
@@ -107,6 +126,7 @@ export function ContractConvertToRo({ bodyshop, currentUser, contract }) {
|
||||
part_type: "CCD",
|
||||
part_qty: 1,
|
||||
tax_part: true,
|
||||
db_ref: "io-ccd",
|
||||
mod_lb_hrs: 0,
|
||||
});
|
||||
}
|
||||
@@ -119,8 +139,8 @@ export function ContractConvertToRo({ bodyshop, currentUser, contract }) {
|
||||
federal_tax_rate: bodyshop.bill_tax_rates.federal_tax_rate / 100,
|
||||
state_tax_rate: bodyshop.bill_tax_rates.state_tax_rate / 100,
|
||||
local_tax_rate: bodyshop.bill_tax_rates.local_tax_rate / 100,
|
||||
converted: true,
|
||||
clm_no: `${contract.job.clm_no}-CC`,
|
||||
clm_total: 1234,
|
||||
ownr_fn: contract.job.owner.ownr_fn,
|
||||
ownr_ln: contract.job.owner.ownr_ln,
|
||||
ownr_co_nm: contract.job.owner.ownr_co_nm,
|
||||
@@ -151,7 +171,7 @@ export function ContractConvertToRo({ bodyshop, currentUser, contract }) {
|
||||
prt_mktyp: false,
|
||||
prt_mkupp: 0,
|
||||
prt_tax_in: true,
|
||||
prt_tax_rt: 0.07,
|
||||
prt_tax_rt: bodyshop.bill_tax_rates.state_tax_rate / 100,
|
||||
},
|
||||
CCF: {
|
||||
prt_type: "CCF",
|
||||
@@ -159,7 +179,7 @@ export function ContractConvertToRo({ bodyshop, currentUser, contract }) {
|
||||
prt_mktyp: false,
|
||||
prt_mkupp: 0,
|
||||
prt_tax_in: true,
|
||||
prt_tax_rt: 0.07,
|
||||
prt_tax_rt: bodyshop.bill_tax_rates.state_tax_rate / 100,
|
||||
},
|
||||
CCM: {
|
||||
prt_type: "CCM",
|
||||
@@ -167,7 +187,7 @@ export function ContractConvertToRo({ bodyshop, currentUser, contract }) {
|
||||
prt_mktyp: false,
|
||||
prt_mkupp: 0,
|
||||
prt_tax_in: true,
|
||||
prt_tax_rt: 0.07,
|
||||
prt_tax_rt: bodyshop.bill_tax_rates.state_tax_rate / 100,
|
||||
},
|
||||
CCC: {
|
||||
prt_type: "CCC",
|
||||
@@ -175,7 +195,7 @@ export function ContractConvertToRo({ bodyshop, currentUser, contract }) {
|
||||
prt_mktyp: false,
|
||||
prt_mkupp: 0,
|
||||
prt_tax_in: true,
|
||||
prt_tax_rt: 0.07,
|
||||
prt_tax_rt: bodyshop.bill_tax_rates.state_tax_rate / 100,
|
||||
},
|
||||
CCD: {
|
||||
prt_type: "CCD",
|
||||
@@ -183,10 +203,22 @@ export function ContractConvertToRo({ bodyshop, currentUser, contract }) {
|
||||
prt_mktyp: false,
|
||||
prt_mkupp: 0,
|
||||
prt_tax_in: true,
|
||||
prt_tax_rt: 0.07,
|
||||
prt_tax_rt: bodyshop.bill_tax_rates.state_tax_rate / 100,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
//Calcualte the new job totals.
|
||||
|
||||
const newTotals = (
|
||||
await axios.post("/job/totals", {
|
||||
job: { ...newJob, joblines: billingLines },
|
||||
})
|
||||
).data;
|
||||
|
||||
newJob.clm_total = newTotals.totals.total_repairs.amount / 100;
|
||||
newJob.job_totals = newTotals;
|
||||
|
||||
const result = await insertJob({
|
||||
variables: { job: [newJob] },
|
||||
// refetchQueries: ["GET_JOB_BY_PK"],
|
||||
@@ -244,12 +276,14 @@ export function ContractConvertToRo({ bodyshop, currentUser, contract }) {
|
||||
>
|
||||
<InputNumber precision={0} min={0} />
|
||||
</Form.Item>
|
||||
<Button type="primary" htmlType="submit">
|
||||
{t("contracts.actions.convertoro")}
|
||||
</Button>
|
||||
<Button onClick={() => setVisible(false)}>
|
||||
{t("general.actions.close")}
|
||||
</Button>
|
||||
<Space>
|
||||
<Button type="primary" htmlType="submit" loading={loading}>
|
||||
{t("contracts.actions.convertoro")}
|
||||
</Button>
|
||||
<Button onClick={() => setVisible(false)}>
|
||||
{t("general.actions.close")}
|
||||
</Button>
|
||||
</Space>
|
||||
</Form>
|
||||
</div>
|
||||
);
|
||||
@@ -257,7 +291,11 @@ export function ContractConvertToRo({ bodyshop, currentUser, contract }) {
|
||||
return (
|
||||
<div>
|
||||
<Popover content={popContent} visible={visible}>
|
||||
<Button onClick={() => setVisible(true)} loading={loading}>
|
||||
<Button
|
||||
onClick={() => setVisible(true)}
|
||||
loading={loading}
|
||||
disabled={!contract.dailyrate || disabled}
|
||||
>
|
||||
{t("contracts.actions.convertoro")}
|
||||
</Button>
|
||||
</Popover>
|
||||
|
||||
@@ -253,13 +253,13 @@
|
||||
// total: acc.parts.list[value.part_type].total.add(
|
||||
// Dinero({
|
||||
// amount: Math.round((value.act_price || 0) * 100),
|
||||
// }).multiply(value.part_qty || 1)
|
||||
// }).multiply(value.part_qty || 0)
|
||||
// ),
|
||||
// }
|
||||
// : {
|
||||
// total: Dinero({
|
||||
// amount: Math.round((value.act_price || 0) * 100),
|
||||
// }).multiply(value.part_qty || 1),
|
||||
// }).multiply(value.part_qty || 0),
|
||||
// },
|
||||
// },
|
||||
// subtotal: acc.parts.subtotal.add(
|
||||
|
||||
Reference in New Issue
Block a user