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>
</translations>
</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>
<name>retailtotal</name>
<definition_loaded>false</definition_loaded>

View File

@@ -41,6 +41,7 @@ export function BillFormComponent({
loadLines,
billEdit,
disableInvNumber,
job,
}) {
const { t } = useTranslation();
const client = useApolloClient();
@@ -89,7 +90,7 @@ export function BillFormComponent({
<JobSearchSelect
disabled={billEdit || disabled}
convertedOnly
// notExported={false}
notExported={false}
onBlur={() => {
if (form.getFieldValue("jobid") !== null) {
loadLines({ variables: { id: form.getFieldValue("jobid") } });
@@ -187,6 +188,23 @@ export function BillFormComponent({
label={t("bills.fields.is_credit_memo")}
name="is_credit_memo"
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 />
</Form.Item>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -765,7 +765,7 @@ export const TemplateList = (type, context) => {
disabled: false,
rangeFilter: {
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: {