Compare commits
2 Commits
feature/IO
...
feature/IO
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
784378a999 | ||
|
|
0d502d4dd4 |
@@ -10,14 +10,12 @@ import JobsCreateOwnerInfoContainer from "../../components/jobs-create-owner-inf
|
||||
import JobsCreateVehicleInfoContainer from "../../components/jobs-create-vehicle-info/jobs-create-vehicle-info.container";
|
||||
import JobCreateContext from "../../pages/jobs-create/jobs-create.context";
|
||||
|
||||
export default function JobsCreateComponent({ form }) {
|
||||
export default function JobsCreateComponent({ form, isSubmitting }) {
|
||||
const [pageIndex, setPageIndex] = useState(0);
|
||||
|
||||
const [errorMessage, setErrorMessage] = useState(null);
|
||||
|
||||
const [state] = useContext(JobCreateContext);
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
const steps = [
|
||||
{
|
||||
title: t("jobs.labels.create.vehicleinfo"),
|
||||
@@ -42,11 +40,9 @@ export default function JobsCreateComponent({ form }) {
|
||||
|
||||
const next = () => {
|
||||
setPageIndex(pageIndex + 1);
|
||||
console.log("Next");
|
||||
};
|
||||
const prev = () => {
|
||||
setPageIndex(pageIndex - 1);
|
||||
console.log("Previous");
|
||||
};
|
||||
|
||||
const ProgressButtons = ({ top }) => {
|
||||
@@ -79,17 +75,19 @@ export default function JobsCreateComponent({ form }) {
|
||||
{pageIndex === steps.length - 1 && (
|
||||
<Button
|
||||
type="primary"
|
||||
loading={isSubmitting}
|
||||
onClick={() => {
|
||||
form
|
||||
.validateFields()
|
||||
.then(() => {
|
||||
// NO OP
|
||||
form.submit();
|
||||
})
|
||||
.catch((error) => console.log("error", error));
|
||||
form.submit();
|
||||
.catch((error) => {
|
||||
console.log("error", error);
|
||||
});
|
||||
}}
|
||||
>
|
||||
Done
|
||||
{t("general.actions.done")}
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
@@ -146,13 +144,11 @@ export default function JobsCreateComponent({ form }) {
|
||||
) : (
|
||||
<div>
|
||||
<ProgressButtons top />
|
||||
|
||||
{errorMessage ? (
|
||||
<div>
|
||||
<AlertComponent title={errorMessage} type="error" />
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{steps.map((item, idx) => (
|
||||
<div
|
||||
key={idx}
|
||||
|
||||
@@ -46,6 +46,7 @@ function JobsCreateContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, curr
|
||||
});
|
||||
const [form] = Form.useForm();
|
||||
const [state, setState] = contextState;
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [insertJob] = useMutation(INSERT_NEW_JOB);
|
||||
const [loadOwner, remoteOwnerData] = useLazyQuery(QUERY_OWNER_FOR_JOB_CREATION);
|
||||
|
||||
@@ -83,16 +84,19 @@ function JobsCreateContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, curr
|
||||
newJobId: resp.data.insert_jobs.returning[0].id
|
||||
});
|
||||
logImEXEvent("manual_job_create_completed", {});
|
||||
setIsSubmitting(false);
|
||||
})
|
||||
.catch((error) => {
|
||||
notification.error({
|
||||
title: t("jobs.errors.creating", { error: error })
|
||||
});
|
||||
setState({ ...state, error: error });
|
||||
setIsSubmitting(false);
|
||||
});
|
||||
};
|
||||
|
||||
const handleFinish = (values) => {
|
||||
setIsSubmitting(true);
|
||||
let job = Object.assign(
|
||||
{},
|
||||
values,
|
||||
@@ -297,7 +301,7 @@ function JobsCreateContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, curr
|
||||
})
|
||||
}}
|
||||
>
|
||||
<JobsCreateComponent form={form} />
|
||||
<JobsCreateComponent form={form} isSubmitting={isSubmitting} />
|
||||
</Form>
|
||||
</RbacWrapper>
|
||||
</JobCreateContext.Provider>
|
||||
|
||||
@@ -1295,6 +1295,7 @@
|
||||
"delete": "Delete",
|
||||
"deleteall": "Delete All",
|
||||
"deselectall": "Deselect All",
|
||||
"done": "Done",
|
||||
"download": "Download",
|
||||
"edit": "Edit",
|
||||
"gotoadmin": "Go to Admin Panel",
|
||||
|
||||
@@ -1295,6 +1295,7 @@
|
||||
"delete": "Borrar",
|
||||
"deleteall": "",
|
||||
"deselectall": "",
|
||||
"done": "",
|
||||
"download": "",
|
||||
"edit": "Editar",
|
||||
"gotoadmin": "",
|
||||
|
||||
@@ -1295,6 +1295,7 @@
|
||||
"delete": "Effacer",
|
||||
"deleteall": "",
|
||||
"deselectall": "",
|
||||
"done": "",
|
||||
"download": "",
|
||||
"edit": "modifier",
|
||||
"gotoadmin": "",
|
||||
|
||||
@@ -130,13 +130,12 @@ exports.default = async (req, res) => {
|
||||
|
||||
async function QueryVendorRecord(oauthClient, qbo_realmId, req, bill) {
|
||||
try {
|
||||
const url = urlBuilder(
|
||||
qbo_realmId,
|
||||
"query",
|
||||
`select * From vendor where DisplayName = '${StandardizeName(bill.vendor.name)}'`
|
||||
);
|
||||
const result = await oauthClient.makeApiCall({
|
||||
url: url,
|
||||
url: urlBuilder(
|
||||
qbo_realmId,
|
||||
"query",
|
||||
`select * From vendor where DisplayName = '${StandardizeName(bill.vendor.name)}'`
|
||||
),
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -151,11 +150,6 @@ async function QueryVendorRecord(oauthClient, qbo_realmId, req, bill) {
|
||||
bodyshopid: bill.job.shopid,
|
||||
email: req.user.email
|
||||
});
|
||||
logger.log("qbo-payables-query", "DEBUG", req.user.email, null, {
|
||||
method: "QueryVendorRecord",
|
||||
call: url,
|
||||
result: result.json
|
||||
});
|
||||
|
||||
return result.json?.QueryResponse?.Vendor?.[0];
|
||||
} catch (error) {
|
||||
@@ -173,9 +167,8 @@ async function InsertVendorRecord(oauthClient, qbo_realmId, req, bill) {
|
||||
DisplayName: StandardizeName(bill.vendor.name)
|
||||
};
|
||||
try {
|
||||
const url = urlBuilder(qbo_realmId, "vendor");
|
||||
const result = await oauthClient.makeApiCall({
|
||||
url: url,
|
||||
url: urlBuilder(qbo_realmId, "vendor"),
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -191,12 +184,6 @@ async function InsertVendorRecord(oauthClient, qbo_realmId, req, bill) {
|
||||
bodyshopid: bill.job.shopid,
|
||||
email: req.user.email
|
||||
});
|
||||
logger.log("qbo-payments-insert", "DEBUG", req.user.email, null, {
|
||||
method: "InsertVendorRecord",
|
||||
call: url,
|
||||
Vendor: Vendor,
|
||||
result: result.json
|
||||
});
|
||||
|
||||
if (result.status >= 400) {
|
||||
throw new Error(JSON.stringify(result.json.Fault));
|
||||
@@ -287,12 +274,11 @@ async function InsertBill(oauthClient, qbo_realmId, req, bill, vendor, bodyshop)
|
||||
VendorRef: {
|
||||
value: vendor.Id
|
||||
},
|
||||
...(vendor.TermRef &&
|
||||
!bill.is_credit_memo && {
|
||||
SalesTermRef: {
|
||||
value: vendor.TermRef.value
|
||||
}
|
||||
}),
|
||||
...(vendor.TermRef && !bill.is_credit_memo && {
|
||||
SalesTermRef: {
|
||||
value: vendor.TermRef.value
|
||||
}
|
||||
}),
|
||||
TxnDate: moment(bill.date)
|
||||
//.tz(bill.job.bodyshop.timezone)
|
||||
.format("YYYY-MM-DD"),
|
||||
@@ -332,9 +318,8 @@ async function InsertBill(oauthClient, qbo_realmId, req, bill, vendor, bodyshop)
|
||||
[logKey]: logValue
|
||||
});
|
||||
try {
|
||||
const url = urlBuilder(qbo_realmId, bill.is_credit_memo ? "vendorcredit" : "bill");
|
||||
const result = await oauthClient.makeApiCall({
|
||||
url: url,
|
||||
url: urlBuilder(qbo_realmId, bill.is_credit_memo ? "vendorcredit" : "bill"),
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -350,12 +335,6 @@ async function InsertBill(oauthClient, qbo_realmId, req, bill, vendor, bodyshop)
|
||||
bodyshopid: bill.job.shopid,
|
||||
email: req.user.email
|
||||
});
|
||||
logger.log("qbo-payables-insert", "DEBUG", req.user.email, null, {
|
||||
method: "InsertBill",
|
||||
call: url,
|
||||
postingObj: bill.is_credit_memo ? VendorCredit : billQbo,
|
||||
result: result.json
|
||||
});
|
||||
|
||||
if (result.status >= 400) {
|
||||
throw new Error(JSON.stringify(result.json.Fault));
|
||||
|
||||
@@ -82,7 +82,14 @@ exports.default = async (req, res) => {
|
||||
|
||||
if (isThreeTier || (!isThreeTier && twoTierPref === "name")) {
|
||||
//Insert the name/owner and account for whether the source should be the ins co in 3 tier..
|
||||
ownerCustomerTier = await QueryOwner(oauthClient, qbo_realmId, req, payment.job, insCoCustomerTier);
|
||||
ownerCustomerTier = await QueryOwner(
|
||||
oauthClient,
|
||||
qbo_realmId,
|
||||
req,
|
||||
payment.job,
|
||||
isThreeTier,
|
||||
insCoCustomerTier
|
||||
);
|
||||
//Query for the owner itself.
|
||||
if (!ownerCustomerTier) {
|
||||
ownerCustomerTier = await InsertOwner(
|
||||
@@ -222,9 +229,8 @@ async function InsertPayment(oauthClient, qbo_realmId, req, payment, parentRef)
|
||||
paymentQbo
|
||||
});
|
||||
try {
|
||||
const url = urlBuilder(qbo_realmId, "payment");
|
||||
const result = await oauthClient.makeApiCall({
|
||||
url: url,
|
||||
url: urlBuilder(qbo_realmId, "payment"),
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -240,12 +246,6 @@ async function InsertPayment(oauthClient, qbo_realmId, req, payment, parentRef)
|
||||
bodyshopid: payment.job.shopid,
|
||||
email: req.user.email
|
||||
});
|
||||
logger.log("qbo-payments-insert", "DEBUG", req.user.email, null, {
|
||||
method: "InsertPayment",
|
||||
call: url,
|
||||
paymentQbo: paymentQbo,
|
||||
result: result.json
|
||||
});
|
||||
|
||||
if (result.status >= 400) {
|
||||
throw new Error(JSON.stringify(result.json.Fault));
|
||||
@@ -428,9 +428,8 @@ async function InsertCreditMemo(oauthClient, qbo_realmId, req, payment, parentRe
|
||||
paymentQbo
|
||||
});
|
||||
try {
|
||||
const url = urlBuilder(qbo_realmId, "creditmemo");
|
||||
const result = await oauthClient.makeApiCall({
|
||||
url: url,
|
||||
url: urlBuilder(qbo_realmId, "creditmemo"),
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -446,12 +445,6 @@ async function InsertCreditMemo(oauthClient, qbo_realmId, req, payment, parentRe
|
||||
bodyshopid: req.user.bodyshopid,
|
||||
email: req.user.email
|
||||
});
|
||||
logger.log("qbo-metadata-query", "DEBUG", req.user.email, null, {
|
||||
method: "InsertCreditMemo",
|
||||
call: url,
|
||||
paymentQbo: paymentQbo,
|
||||
result: result.json
|
||||
});
|
||||
|
||||
if (result.status >= 400) {
|
||||
throw new Error(JSON.stringify(result.json.Fault));
|
||||
|
||||
@@ -213,13 +213,12 @@ exports.default = async (req, res) => {
|
||||
|
||||
async function QueryInsuranceCo(oauthClient, qbo_realmId, req, job) {
|
||||
try {
|
||||
const url = urlBuilder(
|
||||
qbo_realmId,
|
||||
"query",
|
||||
`select * From Customer where DisplayName = '${StandardizeName(job.ins_co_nm.trim())}' and Active = true`
|
||||
);
|
||||
const result = await oauthClient.makeApiCall({
|
||||
url: url,
|
||||
url: urlBuilder(
|
||||
qbo_realmId,
|
||||
"query",
|
||||
`select * From Customer where DisplayName = '${StandardizeName(job.ins_co_nm.trim())}' and Active = true`
|
||||
),
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -234,11 +233,6 @@ async function QueryInsuranceCo(oauthClient, qbo_realmId, req, job) {
|
||||
jobid: job.id,
|
||||
email: req.user.email
|
||||
});
|
||||
logger.log("qbo-receivables-query", "DEBUG", req.user.email, job.id, {
|
||||
method: "QueryInsuranceCo",
|
||||
call: url,
|
||||
result: result.json
|
||||
});
|
||||
|
||||
return result.json?.QueryResponse?.Customer?.[0];
|
||||
} catch (error) {
|
||||
@@ -272,9 +266,8 @@ async function InsertInsuranceCo(oauthClient, qbo_realmId, req, job, bodyshop) {
|
||||
}
|
||||
};
|
||||
try {
|
||||
const url = urlBuilder(qbo_realmId, "customer");
|
||||
const result = await oauthClient.makeApiCall({
|
||||
url: url,
|
||||
url: urlBuilder(qbo_realmId, "customer"),
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -290,12 +283,6 @@ async function InsertInsuranceCo(oauthClient, qbo_realmId, req, job, bodyshop) {
|
||||
jobid: job.id,
|
||||
email: req.user.email
|
||||
});
|
||||
logger.log("qbo-receivables-insert", "DEBUG", req.user.email, job.id, {
|
||||
method: "InsertInsuranceCo",
|
||||
call: url,
|
||||
customerObj: Customer,
|
||||
result: result.json
|
||||
});
|
||||
|
||||
return result.json?.Customer;
|
||||
} catch (error) {
|
||||
@@ -311,13 +298,12 @@ exports.InsertInsuranceCo = InsertInsuranceCo;
|
||||
|
||||
async function QueryOwner(oauthClient, qbo_realmId, req, job, parentTierRef) {
|
||||
const ownerName = generateOwnerTier(job, true, null);
|
||||
const url = urlBuilder(
|
||||
qbo_realmId,
|
||||
"query",
|
||||
`select * From Customer where DisplayName = '${StandardizeName(ownerName)}' and Active = true`
|
||||
);
|
||||
const result = await oauthClient.makeApiCall({
|
||||
url: url,
|
||||
url: urlBuilder(
|
||||
qbo_realmId,
|
||||
"query",
|
||||
`select * From Customer where DisplayName = '${StandardizeName(ownerName)}' and Active = true`
|
||||
),
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -332,11 +318,6 @@ async function QueryOwner(oauthClient, qbo_realmId, req, job, parentTierRef) {
|
||||
jobid: job.id,
|
||||
email: req.user.email
|
||||
});
|
||||
logger.log("qbo-receivables-query", "DEBUG", req.user.email, job.id, {
|
||||
method: "QueryOwner",
|
||||
call: url,
|
||||
result: result.json
|
||||
});
|
||||
|
||||
return result.json?.QueryResponse?.Customer?.find((x) => x.ParentRef?.value === parentTierRef?.Id);
|
||||
}
|
||||
@@ -366,9 +347,8 @@ async function InsertOwner(oauthClient, qbo_realmId, req, job, isThreeTier, pare
|
||||
: {})
|
||||
};
|
||||
try {
|
||||
const url = urlBuilder(qbo_realmId, "customer");
|
||||
const result = await oauthClient.makeApiCall({
|
||||
url: url,
|
||||
url: urlBuilder(qbo_realmId, "customer"),
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -384,12 +364,6 @@ async function InsertOwner(oauthClient, qbo_realmId, req, job, isThreeTier, pare
|
||||
jobid: job.id,
|
||||
email: req.user.email
|
||||
});
|
||||
logger.log("qbo-receivables-insert", "DEBUG", req.user.email, job.id, {
|
||||
method: "InsertOwner",
|
||||
call: url,
|
||||
customerObj: Customer,
|
||||
result: result.json
|
||||
});
|
||||
|
||||
return result.json?.Customer;
|
||||
} catch (error) {
|
||||
@@ -404,13 +378,12 @@ async function InsertOwner(oauthClient, qbo_realmId, req, job, isThreeTier, pare
|
||||
exports.InsertOwner = InsertOwner;
|
||||
|
||||
async function QueryJob(oauthClient, qbo_realmId, req, job, parentTierRef) {
|
||||
const url = urlBuilder(
|
||||
qbo_realmId,
|
||||
"query",
|
||||
`select * From Customer where DisplayName = '${job.ro_number}' and Active = true`
|
||||
);
|
||||
const result = await oauthClient.makeApiCall({
|
||||
url: url,
|
||||
url: urlBuilder(
|
||||
qbo_realmId,
|
||||
"query",
|
||||
`select * From Customer where DisplayName = '${job.ro_number}' and Active = true`
|
||||
),
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -425,11 +398,6 @@ async function QueryJob(oauthClient, qbo_realmId, req, job, parentTierRef) {
|
||||
jobid: job.id,
|
||||
email: req.user.email
|
||||
});
|
||||
logger.log("qbo-receivables-query", "DEBUG", req.user.email, job.id, {
|
||||
method: "QueryJob",
|
||||
call: url,
|
||||
result: result.json
|
||||
});
|
||||
|
||||
const customers = result.json?.QueryResponse?.Customer;
|
||||
return customers && (parentTierRef ? customers.find((x) => x.ParentRef.value === parentTierRef.Id) : customers[0]);
|
||||
@@ -455,9 +423,8 @@ async function InsertJob(oauthClient, qbo_realmId, req, job, parentTierRef) {
|
||||
}
|
||||
};
|
||||
try {
|
||||
const url = urlBuilder(qbo_realmId, "customer");
|
||||
const result = await oauthClient.makeApiCall({
|
||||
url: url,
|
||||
url: urlBuilder(qbo_realmId, "customer"),
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -473,12 +440,6 @@ async function InsertJob(oauthClient, qbo_realmId, req, job, parentTierRef) {
|
||||
jobid: job.id,
|
||||
email: req.user.email
|
||||
});
|
||||
logger.log("qbo-receivables-insert", "DEBUG", req.user.email, job.id, {
|
||||
method: "InsertJob",
|
||||
call: url,
|
||||
customerObj: Customer,
|
||||
result: result.json
|
||||
});
|
||||
|
||||
if (result.status >= 400) {
|
||||
throw new Error(JSON.stringify(result.json.Fault));
|
||||
|
||||
Reference in New Issue
Block a user