Added invoice number checkingBOD-411
This commit is contained in:
@@ -2146,6 +2146,32 @@
|
||||
</concept_node>
|
||||
</children>
|
||||
</folder_node>
|
||||
<folder_node>
|
||||
<name>validation</name>
|
||||
<children>
|
||||
<concept_node>
|
||||
<name>unique_invoice_number</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>
|
||||
</children>
|
||||
</folder_node>
|
||||
</children>
|
||||
</folder_node>
|
||||
<folder_node>
|
||||
|
||||
@@ -10,9 +10,11 @@ import {
|
||||
Upload,
|
||||
} from "antd";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useApolloClient } from "react-apollo";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { CHECK_BILL_INVOICE_NUMBER } from "../../graphql/bills.queries";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import FormDatePicker from "../form-date-picker/form-date-picker.component";
|
||||
@@ -38,7 +40,7 @@ export function BillFormComponent({
|
||||
billEdit,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const client = useApolloClient();
|
||||
const [discount, setDiscount] = useState(0);
|
||||
|
||||
const handleVendorSelect = (props, opt) => {
|
||||
@@ -106,11 +108,36 @@ export function BillFormComponent({
|
||||
<Form.Item
|
||||
label={t("bills.fields.invoice_number")}
|
||||
name="invoice_number"
|
||||
validateTrigger="onBlur"
|
||||
hasFeedback
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
({ getFieldValue }) => ({
|
||||
async validator(rule, value) {
|
||||
const vendorid = getFieldValue("vendorid");
|
||||
if (vendorid) {
|
||||
const response = await client.query({
|
||||
query: CHECK_BILL_INVOICE_NUMBER,
|
||||
variables: {
|
||||
invoice_number: value,
|
||||
vendorid: vendorid,
|
||||
},
|
||||
});
|
||||
|
||||
if (response.data.bills_aggregate.aggregate.count === 0) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return Promise.reject(
|
||||
t("bills.validation.unique_invoice_number")
|
||||
);
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
},
|
||||
}),
|
||||
]}
|
||||
>
|
||||
<Input disabled={disabled} />
|
||||
|
||||
@@ -33,6 +33,8 @@ const JobSearchSelect = ({ value, onChange, onBlur, disabled }, ref) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (value === option && value) {
|
||||
console.log("Calling");
|
||||
console.log("value, option :>> ", value, option);
|
||||
callIdSearch({ variables: { id: value } });
|
||||
}
|
||||
}, [value, option, callIdSearch]);
|
||||
|
||||
@@ -214,3 +214,20 @@ export const UPDATE_BILLS = gql`
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const CHECK_BILL_INVOICE_NUMBER = gql`
|
||||
query CHECK_BILL_INVOICE_NUMBER($invoice_number: String!, $vendorid: uuid!) {
|
||||
bills_aggregate(
|
||||
where: {
|
||||
_and: {
|
||||
invoice_number: { _eq: $invoice_number }
|
||||
vendorid: { _eq: $vendorid }
|
||||
}
|
||||
}
|
||||
) {
|
||||
aggregate {
|
||||
count
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -147,6 +147,9 @@
|
||||
},
|
||||
"successes": {
|
||||
"created": "Invoice added successfully."
|
||||
},
|
||||
"validation": {
|
||||
"unique_invoice_number": "This invoice number has already been entered for this vendor."
|
||||
}
|
||||
},
|
||||
"bodyshop": {
|
||||
|
||||
@@ -147,6 +147,9 @@
|
||||
},
|
||||
"successes": {
|
||||
"created": ""
|
||||
},
|
||||
"validation": {
|
||||
"unique_invoice_number": ""
|
||||
}
|
||||
},
|
||||
"bodyshop": {
|
||||
|
||||
@@ -147,6 +147,9 @@
|
||||
},
|
||||
"successes": {
|
||||
"created": ""
|
||||
},
|
||||
"validation": {
|
||||
"unique_invoice_number": ""
|
||||
}
|
||||
},
|
||||
"bodyshop": {
|
||||
|
||||
Reference in New Issue
Block a user