Partial fixes to jobline upsert & totals calculation. IO-730

This commit is contained in:
Patrick Fic
2021-03-04 15:43:11 -08:00
parent 0d317578b2
commit f7d1ea0a49
5 changed files with 47 additions and 37 deletions

View File

@@ -300,40 +300,43 @@ export function JobLinesComponent({
dataIndex: "actions",
key: "actions",
render: (text, record) => (
<Space>
<Button
disabled={jobRO}
onClick={() => {
setJobLineEditContext({
actions: { refetch: refetch, submit: form && form.submit },
context: record,
});
}}
>
{t("general.actions.edit")}
</Button>
<div>
{record.manual_line && (
<Button
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)
);
<Space >
<Button
disabled={jobRO}
onClick={() => {
setJobLineEditContext({
actions: { refetch: refetch, submit: form && form.submit },
context: record,
});
}}
>
{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 />
</Button>
});
},
})
}
>
<DeleteFilled />
</Button>
</Space>
)}
{
// <AllocationsAssignmentContainer
@@ -343,7 +346,7 @@ export function JobLinesComponent({
// hours={record.mod_lb_hrs}
// />
}
</Space>
</div>
),
},
];

View File

@@ -10,6 +10,7 @@ import {
} from "../../graphql/jobs-lines.queries";
import { toggleModalVisible } from "../../redux/modals/modals.actions";
import { selectJobLineEditModal } from "../../redux/modals/modals.selectors";
import UndefinedToNull from "../../utils/undefinedtonull";
import JobLinesUpdsertModal from "./job-lines-upsert-modal.component";
const mapStateToProps = createStructuredSelector({
@@ -39,7 +40,7 @@ function JobLinesUpsertModalContainer({
manual_line: !(
jobLineEditModal.context && jobLineEditModal.context.id
),
...values,
...UndefinedToNull(values),
},
],
},

View File

@@ -97,7 +97,7 @@ export function JobsDetailGeneral({ bodyshop, jobRO, job, form }) {
label={t("jobs.fields.referralsource")}
name="referral_source"
>
<Select disabled={jobRO}>
<Select disabled={jobRO} allowClear>
{bodyshop.md_referral_sources.map((s) => (
<Select.Option key={s} value={s}>
{s}
@@ -106,7 +106,7 @@ export function JobsDetailGeneral({ bodyshop, jobRO, job, form }) {
</Select>
</Form.Item>
<Form.Item label={t("jobs.fields.alt_transport")} name="alt_transport">
<Select disabled={jobRO}>
<Select disabled={jobRO} allowClear>
{bodyshop.appt_alt_transport.map((s) => (
<Select.Option key={s} value={s}>
{s}

View File

@@ -0,0 +1,6 @@
export default function UndefinedToNull(obj) {
Object.keys(obj).forEach((key) => {
if (obj[key] === undefined) obj[key] = null;
});
return obj;
}

View File

@@ -325,7 +325,7 @@ function CalculateTaxesTotals(job, otherTotals) {
job.joblines
.filter((jl) => !jl.removed)
.forEach((val) => {
if (!val.tax_part || !val.part_type || IsAdditionalCost(val)) {
if (!val.tax_part || (!val.part_type && IsAdditionalCost(val))) {
additionalItemsTax = additionalItemsTax.add(
Dinero({ amount: Math.round((val.act_price || 0) * 100) })
.multiply(val.part_qty || 1)