IO-1059 Prevent posting bills to closed jobs.

This commit is contained in:
Patrick Fic
2021-06-07 13:16:31 -07:00
parent 979ba1c142
commit e801a03984
8 changed files with 49 additions and 2 deletions

View File

@@ -2370,6 +2370,27 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>onlycmforinvoiced</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node> <concept_node>
<name>retailtotal</name> <name>retailtotal</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>

View File

@@ -41,6 +41,7 @@ export function BillFormComponent({
loadLines, loadLines,
billEdit, billEdit,
disableInvNumber, disableInvNumber,
job,
}) { }) {
const { t } = useTranslation(); const { t } = useTranslation();
const client = useApolloClient(); const client = useApolloClient();
@@ -89,7 +90,7 @@ export function BillFormComponent({
<JobSearchSelect <JobSearchSelect
disabled={billEdit || disabled} disabled={billEdit || disabled}
convertedOnly convertedOnly
// notExported={false} notExported={false}
onBlur={() => { onBlur={() => {
if (form.getFieldValue("jobid") !== null) { if (form.getFieldValue("jobid") !== null) {
loadLines({ variables: { id: form.getFieldValue("jobid") } }); loadLines({ variables: { id: form.getFieldValue("jobid") } });
@@ -187,6 +188,23 @@ export function BillFormComponent({
label={t("bills.fields.is_credit_memo")} label={t("bills.fields.is_credit_memo")}
name="is_credit_memo" name="is_credit_memo"
valuePropName="checked" valuePropName="checked"
dependencies={["jobid"]}
rules={[
({ getFieldValue }) => ({
validator(rule, value) {
if (
(job.status === bodyshop.md_ro_statuses.default_invoiced ||
job.status === bodyshop.md_ro_statuses.default_exported ||
job.status === bodyshop.md_ro_statuses.default_void) &&
(value === false || !value)
) {
return Promise.reject(t("bills.labels.onlycmforinvoiced"));
}
return Promise.resolve();
},
}),
]}
> >
<Switch /> <Switch />
</Form.Item> </Form.Item>

View File

@@ -34,6 +34,7 @@ export function BillFormContainer({
} }
loadLines={loadLines} loadLines={loadLines}
lineData={lineData ? lineData.joblines : []} lineData={lineData ? lineData.joblines : []}
job={lineData ? lineData.jobs_by_pk : null}
responsibilityCenters={bodyshop.md_responsibility_centers || null} responsibilityCenters={bodyshop.md_responsibility_centers || null}
disableInvNumber={disableInvNumber} disableInvNumber={disableInvNumber}
/> />

View File

@@ -186,6 +186,10 @@ export const GET_JOB_LINES_TO_ENTER_BILL = gql`
lbr_amt lbr_amt
op_code_desc op_code_desc
} }
jobs_by_pk(id: $id) {
id
status
}
} }
`; `;
// oem_partno: { // oem_partno: {

View File

@@ -156,6 +156,7 @@
"markforreexport": "Mark for Re-export", "markforreexport": "Mark for Re-export",
"new": "New Bill", "new": "New Bill",
"noneselected": "No bill selected.", "noneselected": "No bill selected.",
"onlycmforinvoiced": "Only credit memos can be entered for any job that has been invoiced.",
"retailtotal": "Bills Retail Total", "retailtotal": "Bills Retail Total",
"state_tax": "Provincial/State Tax", "state_tax": "Provincial/State Tax",
"subtotal": "Subtotal", "subtotal": "Subtotal",

View File

@@ -156,6 +156,7 @@
"markforreexport": "", "markforreexport": "",
"new": "", "new": "",
"noneselected": "", "noneselected": "",
"onlycmforinvoiced": "",
"retailtotal": "", "retailtotal": "",
"state_tax": "", "state_tax": "",
"subtotal": "", "subtotal": "",

View File

@@ -156,6 +156,7 @@
"markforreexport": "", "markforreexport": "",
"new": "", "new": "",
"noneselected": "", "noneselected": "",
"onlycmforinvoiced": "",
"retailtotal": "", "retailtotal": "",
"state_tax": "", "state_tax": "",
"subtotal": "", "subtotal": "",

View File

@@ -765,7 +765,7 @@ export const TemplateList = (type, context) => {
disabled: false, disabled: false,
rangeFilter: { rangeFilter: {
object: i18n.t("reportcenter.labels.objects.jobs"), object: i18n.t("reportcenter.labels.objects.jobs"),
field: i18n.t("jobs.fields.date_invoiced"), field: i18n.t("jobs.fields.date_open"),
}, },
}, },
job_costing_ro_date_summary: { job_costing_ro_date_summary: {