Partial fixes to jobline upsert & totals calculation. IO-730
This commit is contained in:
@@ -300,40 +300,43 @@ export function JobLinesComponent({
|
|||||||
dataIndex: "actions",
|
dataIndex: "actions",
|
||||||
key: "actions",
|
key: "actions",
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Space>
|
<div>
|
||||||
<Button
|
|
||||||
disabled={jobRO}
|
|
||||||
onClick={() => {
|
|
||||||
setJobLineEditContext({
|
|
||||||
actions: { refetch: refetch, submit: form && form.submit },
|
|
||||||
context: record,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{t("general.actions.edit")}
|
|
||||||
</Button>
|
|
||||||
{record.manual_line && (
|
{record.manual_line && (
|
||||||
<Button
|
<Space >
|
||||||
onClick={() =>
|
<Button
|
||||||
deleteJobLine({
|
disabled={jobRO}
|
||||||
variables: { joblineId: record.id },
|
onClick={() => {
|
||||||
update(cache) {
|
setJobLineEditContext({
|
||||||
cache.modify({
|
actions: { refetch: refetch, submit: form && form.submit },
|
||||||
id: cache.identify(job),
|
context: record,
|
||||||
fields: {
|
});
|
||||||
joblines(existingJobLines, { readField }) {
|
}}
|
||||||
return existingJobLines.filter(
|
>
|
||||||
(jlRef) => record.id !== readField("id", jlRef)
|
{t("general.actions.edit")}
|
||||||
);
|
</Button>
|
||||||
|
<Button
|
||||||
|
disabled={jobRO}
|
||||||
|
onClick={() =>
|
||||||
|
deleteJobLine({
|
||||||
|
variables: { joblineId: record.id },
|
||||||
|
update(cache) {
|
||||||
|
cache.modify({
|
||||||
|
id: cache.identify(job),
|
||||||
|
fields: {
|
||||||
|
joblines(existingJobLines, { readField }) {
|
||||||
|
return existingJobLines.filter(
|
||||||
|
(jlRef) => record.id !== readField("id", jlRef)
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
});
|
},
|
||||||
},
|
})
|
||||||
})
|
}
|
||||||
}
|
>
|
||||||
>
|
<DeleteFilled />
|
||||||
<DeleteFilled />
|
</Button>
|
||||||
</Button>
|
</Space>
|
||||||
)}
|
)}
|
||||||
{
|
{
|
||||||
// <AllocationsAssignmentContainer
|
// <AllocationsAssignmentContainer
|
||||||
@@ -343,7 +346,7 @@ export function JobLinesComponent({
|
|||||||
// hours={record.mod_lb_hrs}
|
// hours={record.mod_lb_hrs}
|
||||||
// />
|
// />
|
||||||
}
|
}
|
||||||
</Space>
|
</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
} from "../../graphql/jobs-lines.queries";
|
} from "../../graphql/jobs-lines.queries";
|
||||||
import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
||||||
import { selectJobLineEditModal } from "../../redux/modals/modals.selectors";
|
import { selectJobLineEditModal } from "../../redux/modals/modals.selectors";
|
||||||
|
import UndefinedToNull from "../../utils/undefinedtonull";
|
||||||
import JobLinesUpdsertModal from "./job-lines-upsert-modal.component";
|
import JobLinesUpdsertModal from "./job-lines-upsert-modal.component";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
@@ -39,7 +40,7 @@ function JobLinesUpsertModalContainer({
|
|||||||
manual_line: !(
|
manual_line: !(
|
||||||
jobLineEditModal.context && jobLineEditModal.context.id
|
jobLineEditModal.context && jobLineEditModal.context.id
|
||||||
),
|
),
|
||||||
...values,
|
...UndefinedToNull(values),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export function JobsDetailGeneral({ bodyshop, jobRO, job, form }) {
|
|||||||
label={t("jobs.fields.referralsource")}
|
label={t("jobs.fields.referralsource")}
|
||||||
name="referral_source"
|
name="referral_source"
|
||||||
>
|
>
|
||||||
<Select disabled={jobRO}>
|
<Select disabled={jobRO} allowClear>
|
||||||
{bodyshop.md_referral_sources.map((s) => (
|
{bodyshop.md_referral_sources.map((s) => (
|
||||||
<Select.Option key={s} value={s}>
|
<Select.Option key={s} value={s}>
|
||||||
{s}
|
{s}
|
||||||
@@ -106,7 +106,7 @@ export function JobsDetailGeneral({ bodyshop, jobRO, job, form }) {
|
|||||||
</Select>
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label={t("jobs.fields.alt_transport")} name="alt_transport">
|
<Form.Item label={t("jobs.fields.alt_transport")} name="alt_transport">
|
||||||
<Select disabled={jobRO}>
|
<Select disabled={jobRO} allowClear>
|
||||||
{bodyshop.appt_alt_transport.map((s) => (
|
{bodyshop.appt_alt_transport.map((s) => (
|
||||||
<Select.Option key={s} value={s}>
|
<Select.Option key={s} value={s}>
|
||||||
{s}
|
{s}
|
||||||
|
|||||||
6
client/src/utils/undefinedtonull.js
Normal file
6
client/src/utils/undefinedtonull.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export default function UndefinedToNull(obj) {
|
||||||
|
Object.keys(obj).forEach((key) => {
|
||||||
|
if (obj[key] === undefined) obj[key] = null;
|
||||||
|
});
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
@@ -325,7 +325,7 @@ function CalculateTaxesTotals(job, otherTotals) {
|
|||||||
job.joblines
|
job.joblines
|
||||||
.filter((jl) => !jl.removed)
|
.filter((jl) => !jl.removed)
|
||||||
.forEach((val) => {
|
.forEach((val) => {
|
||||||
if (!val.tax_part || !val.part_type || IsAdditionalCost(val)) {
|
if (!val.tax_part || (!val.part_type && IsAdditionalCost(val))) {
|
||||||
additionalItemsTax = additionalItemsTax.add(
|
additionalItemsTax = additionalItemsTax.add(
|
||||||
Dinero({ amount: Math.round((val.act_price || 0) * 100) })
|
Dinero({ amount: Math.round((val.act_price || 0) * 100) })
|
||||||
.multiply(val.part_qty || 1)
|
.multiply(val.part_qty || 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user