diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 53a04fe72..3eb75a3de 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -8927,6 +8927,48 @@ + + md_to_emails + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + md_to_emails_emails + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + messagingpresets false @@ -14017,6 +14059,27 @@ + + external_id + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + first_name false @@ -36695,6 +36758,32 @@ + + special + + + attendance_detail_csv + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + subjects diff --git a/client/src/components/accounting-payables-table/accounting-payables-table.component.jsx b/client/src/components/accounting-payables-table/accounting-payables-table.component.jsx index ed3a7b24c..71939895e 100644 --- a/client/src/components/accounting-payables-table/accounting-payables-table.component.jsx +++ b/client/src/components/accounting-payables-table/accounting-payables-table.component.jsx @@ -28,7 +28,7 @@ export default connect( mapDispatchToProps )(AccountingPayablesTableComponent); -export function AccountingPayablesTableComponent({ bodyshop, loading, bills }) { +export function AccountingPayablesTableComponent({ bodyshop, loading, bills, refetch }) { const { t } = useTranslation(); const [selectedBills, setSelectedBills] = useState([]); const [transInProgress, setTransInProgress] = useState(false); @@ -149,6 +149,7 @@ export function AccountingPayablesTableComponent({ bodyshop, loading, bills }) { disabled={transInProgress || !!record.exported} loadingCallback={setTransInProgress} setSelectedBills={setSelectedBills} + refetch={refetch} /> ), @@ -181,6 +182,7 @@ export function AccountingPayablesTableComponent({ bodyshop, loading, bills }) { disabled={transInProgress || selectedBills.length === 0} loadingCallback={setTransInProgress} completedCallback={setSelectedBills} + refetch={refetch} /> {bodyshop.accountingconfig && bodyshop.accountingconfig.qbo && ( diff --git a/client/src/components/accounting-payments-table/accounting-payments-table.component.jsx b/client/src/components/accounting-payments-table/accounting-payments-table.component.jsx index 3a8c0c6b4..05e5277dd 100644 --- a/client/src/components/accounting-payments-table/accounting-payments-table.component.jsx +++ b/client/src/components/accounting-payments-table/accounting-payments-table.component.jsx @@ -32,6 +32,7 @@ export function AccountingPayablesTableComponent({ bodyshop, loading, payments, + refetch, }) { const { t } = useTranslation(); const [selectedPayments, setSelectedPayments] = useState([]); @@ -147,6 +148,7 @@ export function AccountingPayablesTableComponent({ disabled={transInProgress || !!record.exportedat} loadingCallback={setTransInProgress} setSelectedPayments={setSelectedPayments} + refetch={refetch} /> ), }, @@ -187,6 +189,7 @@ export function AccountingPayablesTableComponent({ disabled={transInProgress || selectedPayments.length === 0} loadingCallback={setTransInProgress} completedCallback={setSelectedPayments} + refetch={refetch} /> {bodyshop.accountingconfig && bodyshop.accountingconfig.qbo && ( diff --git a/client/src/components/accounting-receivables-table/accounting-receivables-table.component.jsx b/client/src/components/accounting-receivables-table/accounting-receivables-table.component.jsx index d954448d4..082d42da2 100644 --- a/client/src/components/accounting-receivables-table/accounting-receivables-table.component.jsx +++ b/client/src/components/accounting-receivables-table/accounting-receivables-table.component.jsx @@ -31,6 +31,7 @@ export function AccountingReceivablesTableComponent({ bodyshop, loading, jobs, + refetch, }) { const { t } = useTranslation(); const [selectedJobs, setSelectedJobs] = useState([]); @@ -155,6 +156,7 @@ export function AccountingReceivablesTableComponent({ jobId={record.id} disabled={!!record.date_exported} setSelectedJobs={setSelectedJobs} + refetch={refetch} /> @@ -205,6 +207,7 @@ export function AccountingReceivablesTableComponent({ disabled={transInProgress || selectedJobs.length === 0} loadingCallback={setTransInProgress} completedCallback={setSelectedJobs} + refetch={refetch} /> )} {bodyshop.accountingconfig && bodyshop.accountingconfig.qbo && ( diff --git a/client/src/components/email-overlay/email-overlay.component.jsx b/client/src/components/email-overlay/email-overlay.component.jsx index baf52d376..0c7fefc78 100644 --- a/client/src/components/email-overlay/email-overlay.component.jsx +++ b/client/src/components/email-overlay/email-overlay.component.jsx @@ -42,7 +42,12 @@ export function EmailOverlayComponent({ const { t } = useTranslation(); const handleClick = ({ item, key, keyPath }) => { const email = item.props.value; - form.setFieldsValue({ to: _.uniq([...form.getFieldValue("to"), email]) }); + form.setFieldsValue({ + to: _.uniq([ + ...form.getFieldValue("to"), + ...(typeof email === "string" ? [email] : email), + ]), + }); }; const menu = ( @@ -55,6 +60,11 @@ export function EmailOverlayComponent({ {`${e.first_name} ${e.last_name}`} ))} + {bodyshop.md_to_emails.map((e, idx) => ( + + {e.label} + + ))} ); diff --git a/client/src/components/jobs-close-export-button/jobs-close-export-button.component.jsx b/client/src/components/jobs-close-export-button/jobs-close-export-button.component.jsx index 8d783557e..1c95b9975 100644 --- a/client/src/components/jobs-close-export-button/jobs-close-export-button.component.jsx +++ b/client/src/components/jobs-close-export-button/jobs-close-export-button.component.jsx @@ -15,7 +15,6 @@ import { logImEXEvent } from "../../firebase/firebase.utils"; import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries"; import { useHistory } from "react-router-dom"; - const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, currentUser: selectCurrentUser, @@ -27,6 +26,7 @@ export function JobsCloseExportButton({ jobId, disabled, setSelectedJobs, + refetch, }) { const history = useHistory(); const { t } = useTranslation(); @@ -46,13 +46,10 @@ export function JobsCloseExportButton({ //Check if it's a QBO Setup. let PartnerResponse; if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) { - PartnerResponse = await axios.post( - `/qbo/receivables`, - { - jobIds: [jobId], - }, - - ); + PartnerResponse = await axios.post(`/qbo/receivables`, { + jobIds: [jobId], + elgen: true, + }); } else { //Default is QBD @@ -117,58 +114,64 @@ export function JobsCloseExportButton({ }); }); - await insertExportLog({ - variables: { - logs: [ - { - bodyshopid: bodyshop.id, - jobid: jobId, - successful: false, - message: JSON.stringify( - failedTransactions.map((ft) => ft.errorMessage) - ), - useremail: currentUser.email, - }, - ], - }, - }); + if (!(bodyshop.accountingconfig && bodyshop.accountingconfig.qbo)) { + //QBO Logs are handled server side. + await insertExportLog({ + variables: { + logs: [ + { + bodyshopid: bodyshop.id, + jobid: jobId, + successful: false, + message: JSON.stringify( + failedTransactions.map((ft) => ft.errorMessage) + ), + useremail: currentUser.email, + }, + ], + }, + }); + } } else { //Insert success export log. - await insertExportLog({ - variables: { - logs: [ - { - bodyshopid: bodyshop.id, - jobid: jobId, - successful: true, - useremail: currentUser.email, - }, - ], - }, - }); - - const jobUpdateResponse = await updateJob({ - variables: { - jobId: jobId, - job: { - status: bodyshop.md_ro_statuses.default_exported || "Exported*", - date_exported: new Date(), + if (!(bodyshop.accountingconfig && bodyshop.accountingconfig.qbo)) { + //QBO Logs are handled server side. + await insertExportLog({ + variables: { + logs: [ + { + bodyshopid: bodyshop.id, + jobid: jobId, + successful: true, + useremail: currentUser.email, + }, + ], }, - }, - }); + }); - if (!jobUpdateResponse.errors) { - notification.open({ - type: "success", - key: "jobsuccessexport", - message: t("jobs.successes.exported"), - }); - } else { - notification["error"]({ - message: t("jobs.errors.exporting", { - error: JSON.stringify(jobUpdateResponse.error), - }), + const jobUpdateResponse = await updateJob({ + variables: { + jobId: jobId, + job: { + status: bodyshop.md_ro_statuses.default_exported || "Exported*", + date_exported: new Date(), + }, + }, }); + + if (!jobUpdateResponse.errors) { + notification.open({ + type: "success", + key: "jobsuccessexport", + message: t("jobs.successes.exported"), + }); + } else { + notification["error"]({ + message: t("jobs.errors.exporting", { + error: JSON.stringify(jobUpdateResponse.error), + }), + }); + } } if (setSelectedJobs) { setSelectedJobs((selectedJobs) => { @@ -176,7 +179,7 @@ export function JobsCloseExportButton({ }); } } - + if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) refetch(); setLoading(false); }; diff --git a/client/src/components/jobs-export-all-button/jobs-export-all-button.component.jsx b/client/src/components/jobs-export-all-button/jobs-export-all-button.component.jsx index 80aa92f7f..f4effbe2c 100644 --- a/client/src/components/jobs-export-all-button/jobs-export-all-button.component.jsx +++ b/client/src/components/jobs-export-all-button/jobs-export-all-button.component.jsx @@ -26,6 +26,7 @@ export function JobsExportAllButton({ disabled, loadingCallback, completedCallback, + refetch, }) { const { t } = useTranslation(); const [updateJob] = useMutation(UPDATE_JOBS); @@ -39,6 +40,7 @@ export function JobsExportAllButton({ if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) { PartnerResponse = await axios.post(`/qbo/receivables`, { jobIds: jobIds, + elgen: true, }); } else { let QbXmlResponse; @@ -83,6 +85,7 @@ export function JobsExportAllButton({ return; } } + console.log("PartnerResponse", PartnerResponse); const groupedData = _.groupBy( PartnerResponse.data, @@ -106,61 +109,70 @@ export function JobsExportAllButton({ }); //Call is not awaited as it is not critical to finish before proceeding. }); - await insertExportLog({ - variables: { - logs: [ - { - bodyshopid: bodyshop.id, - jobid: key, - successful: false, - message: JSON.stringify( - failedTransactions.map((ft) => ft.errorMessage) - ), - useremail: currentUser.email, - }, - ], - }, - }); - } else { - await insertExportLog({ - variables: { - logs: [ - { - bodyshopid: bodyshop.id, - jobid: key, - successful: true, - useremail: currentUser.email, - }, - ], - }, - }); - const jobUpdateResponse = await updateJob({ - variables: { - jobIds: [key], - fields: { - status: bodyshop.md_ro_statuses.default_exported || "Exported*", - date_exported: new Date(), + if (!(bodyshop.accountingconfig && bodyshop.accountingconfig.qbo)) { + //QBO Logs are handled server side. + await insertExportLog({ + variables: { + logs: [ + { + bodyshopid: bodyshop.id, + jobid: key, + successful: false, + message: JSON.stringify( + failedTransactions.map((ft) => ft.errorMessage) + ), + useremail: currentUser.email, + }, + ], }, - }, - }); + }); + } + } else { + if (!(bodyshop.accountingconfig && bodyshop.accountingconfig.qbo)) { + //QBO Logs are handled server side. + await insertExportLog({ + variables: { + logs: [ + { + bodyshopid: bodyshop.id, + jobid: key, + successful: true, + useremail: currentUser.email, + }, + ], + }, + }); - if (!jobUpdateResponse.errors) { - notification.open({ - type: "success", - key: "jobsuccessexport", - message: t("jobs.successes.exported"), - }); - } else { - notification["error"]({ - message: t("jobs.errors.exporting", { - error: JSON.stringify(jobUpdateResponse.error), - }), + const jobUpdateResponse = await updateJob({ + variables: { + jobIds: [key], + fields: { + status: + bodyshop.md_ro_statuses.default_exported || "Exported*", + date_exported: new Date(), + }, + }, }); + + if (!jobUpdateResponse.errors) { + notification.open({ + type: "success", + key: "jobsuccessexport", + message: t("jobs.successes.exported"), + }); + } else { + notification["error"]({ + message: t("jobs.errors.exporting", { + error: JSON.stringify(jobUpdateResponse.error), + }), + }); + } } } }) ); + if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) refetch(); if (!!completedCallback) completedCallback([]); if (!!loadingCallback) loadingCallback(false); diff --git a/client/src/components/parts-order-delete-line/parts-order-delete-line.component.jsx b/client/src/components/parts-order-delete-line/parts-order-delete-line.component.jsx new file mode 100644 index 000000000..0edad9bb5 --- /dev/null +++ b/client/src/components/parts-order-delete-line/parts-order-delete-line.component.jsx @@ -0,0 +1,47 @@ +import React from "react"; +import { Button, Popconfirm } from "antd"; +import { DeleteFilled } from "@ant-design/icons"; +import { useTranslation } from "react-i18next"; +import { DELETE_PARTS_ORDER_LINE } from "../../graphql/parts-orders.queries"; +import { useMutation } from "@apollo/client"; + +export default function PartsOrderDeleteLine({ + disabled, + partsLineId, + partsOrderId, +}) { + const { t } = useTranslation(); + const [deletePartsOrderLine] = useMutation(DELETE_PARTS_ORDER_LINE); + return ( + { + //Delete the parts return.! + + await deletePartsOrderLine({ + variables: { partsOrderLineId: partsLineId }, + update(cache) { + cache.modify({ + id: cache.identify({ + __typename: "parts_orders", + id: partsOrderId, + }), + fields: { + parts_order_lines(cached, { readField }) { + return cached.filter((c) => { + return readField("id", c) !== partsLineId; + }); + }, + }, + }); + }, + }); + }} + > + + + ); +} diff --git a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx index 9806b6cca..ed66ecdd7 100644 --- a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx +++ b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx @@ -30,6 +30,7 @@ import { TemplateList } from "../../utils/TemplateConstants"; import DataLabel from "../data-label/data-label.component"; import PartsOrderBackorderEta from "../parts-order-backorder-eta/parts-order-backorder-eta.component"; import PartsOrderCmReceived from "../parts-order-cm-received/parts-order-cm-received.component"; +import PartsOrderDeleteLine from "../parts-order-delete-line/parts-order-delete-line.component"; import PartsOrderLineBackorderButton from "../parts-order-line-backorder-button/parts-order-line-backorder-button.component"; import PartsReceiveModalContainer from "../parts-receive-modal/parts-receive-modal.container"; import PrintWrapper from "../print-wrapper/print-wrapper.component"; @@ -391,12 +392,21 @@ export function PartsOrderListTableComponent({ dataIndex: "actions", key: "actions", render: (text, record) => ( - + + + + ), }, ]; diff --git a/client/src/components/payable-export-all-button/payable-export-all-button.component.jsx b/client/src/components/payable-export-all-button/payable-export-all-button.component.jsx index 0cfe607df..fdebc2335 100644 --- a/client/src/components/payable-export-all-button/payable-export-all-button.component.jsx +++ b/client/src/components/payable-export-all-button/payable-export-all-button.component.jsx @@ -27,6 +27,7 @@ export function PayableExportAll({ disabled, loadingCallback, completedCallback, + refetch, }) { const { t } = useTranslation(); const [updateBill] = useMutation(UPDATE_BILLS); @@ -42,6 +43,7 @@ export function PayableExportAll({ if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) { PartnerResponse = await axios.post(`/qbo/payables`, { bills: billids, + elgen: true, }); } else { let QbXmlResponse; @@ -104,57 +106,62 @@ export function PayableExportAll({ }), }) ); - - await insertExportLog({ - variables: { - logs: [ - { - bodyshopid: bodyshop.id, - billid: key, - successful: false, - message: JSON.stringify( - failedTransactions.map((ft) => ft.errorMessage) - ), - useremail: currentUser.email, - }, - ], - }, - }); - } else { - await insertExportLog({ - variables: { - logs: [ - { - bodyshopid: bodyshop.id, - billid: key, - successful: true, - useremail: currentUser.email, - }, - ], - }, - }); - - const billUpdateResponse = await updateBill({ - variables: { - billIdList: [key], - bill: { - exported: true, - exported_at: new Date(), + if (!(bodyshop.accountingconfig && bodyshop.accountingconfig.qbo)) { + //QBO Logs are handled server side. + await insertExportLog({ + variables: { + logs: [ + { + bodyshopid: bodyshop.id, + billid: key, + successful: false, + message: JSON.stringify( + failedTransactions.map((ft) => ft.errorMessage) + ), + useremail: currentUser.email, + }, + ], }, - }, - }); - if (!!!billUpdateResponse.errors) { - notification.open({ - type: "success", - key: "billsuccessexport", - message: t("bills.successes.exported"), }); - } else { - notification["error"]({ - message: t("bills.errors.exporting", { - error: JSON.stringify(billUpdateResponse.error), - }), + } + } else { + if (!(bodyshop.accountingconfig && bodyshop.accountingconfig.qbo)) { + //QBO Logs are handled server side. + await insertExportLog({ + variables: { + logs: [ + { + bodyshopid: bodyshop.id, + billid: key, + successful: true, + useremail: currentUser.email, + }, + ], + }, }); + + const billUpdateResponse = await updateBill({ + variables: { + billIdList: [key], + bill: { + exported: true, + exported_at: new Date(), + }, + }, + }); + if (!!!billUpdateResponse.errors) { + notification.open({ + type: "success", + key: "billsuccessexport", + message: t("bills.successes.exported"), + }); + } else { + notification["error"]({ + message: t("bills.errors.exporting", { + error: JSON.stringify(billUpdateResponse.error), + }), + }); + } } } })() @@ -164,6 +171,8 @@ export function PayableExportAll({ await Promise.all(proms); if (!!completedCallback) completedCallback([]); if (!!loadingCallback) loadingCallback(false); + if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) refetch(); + setLoading(false); }; diff --git a/client/src/components/payable-export-button/payable-export-button.component.jsx b/client/src/components/payable-export-button/payable-export-button.component.jsx index 17a2acedb..6f24d0a59 100644 --- a/client/src/components/payable-export-button/payable-export-button.component.jsx +++ b/client/src/components/payable-export-button/payable-export-button.component.jsx @@ -26,6 +26,7 @@ export function PayableExportButton({ disabled, loadingCallback, setSelectedBills, + refetch, }) { const { t } = useTranslation(); const [updateBill] = useMutation(UPDATE_BILLS); @@ -43,6 +44,7 @@ export function PayableExportButton({ if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) { PartnerResponse = await axios.post(`/qbo/payables`, { bills: [billId], + elgen: true, }); } else { //Default is QBD @@ -100,64 +102,72 @@ export function PayableExportButton({ }), }) ); - await insertExportLog({ - variables: { - logs: [ - { - bodyshopid: bodyshop.id, - billid: billId, - successful: false, - message: JSON.stringify( - failedTransactions.map((ft) => ft.errorMessage) - ), - useremail: currentUser.email, - }, - ], - }, - }); - } - if (successfulTransactions.length > 0) { - await insertExportLog({ - variables: { - logs: [ - { - bodyshopid: bodyshop.id, - billid: billId, - successful: true, - useremail: currentUser.email, - }, - ], - }, - }); - const billUpdateResponse = await updateBill({ - variables: { - billIdList: successfulTransactions.map( - (st) => - st[ - bodyshop.accountingconfig && bodyshop.accountingconfig.qbo - ? "billid" - : "id" - ] - ), - bill: { - exported: true, - exported_at: new Date(), + if (!(bodyshop.accountingconfig && bodyshop.accountingconfig.qbo)) { + //QBO Logs are handled server side. + await insertExportLog({ + variables: { + logs: [ + { + bodyshopid: bodyshop.id, + billid: billId, + successful: false, + message: JSON.stringify( + failedTransactions.map((ft) => ft.errorMessage) + ), + useremail: currentUser.email, + }, + ], }, - }, - }); - if (!!!billUpdateResponse.errors) { - notification.open({ - type: "success", - key: "billsuccessexport", - message: t("bills.successes.exported"), - }); - } else { - notification["error"]({ - message: t("bills.errors.exporting", { - error: JSON.stringify(billUpdateResponse.error), - }), }); } + } + if (successfulTransactions.length > 0) { + if (!(bodyshop.accountingconfig && bodyshop.accountingconfig.qbo)) { + //QBO Logs are handled server side. + await insertExportLog({ + variables: { + logs: [ + { + bodyshopid: bodyshop.id, + billid: billId, + successful: true, + useremail: currentUser.email, + }, + ], + }, + }); + const billUpdateResponse = await updateBill({ + variables: { + billIdList: successfulTransactions.map( + (st) => + st[ + bodyshop.accountingconfig && bodyshop.accountingconfig.qbo + ? "billid" + : "id" + ] + ), + bill: { + exported: true, + exported_at: new Date(), + }, + }, + }); + if (!!!billUpdateResponse.errors) { + notification.open({ + type: "success", + key: "billsuccessexport", + message: t("bills.successes.exported"), + }); + } else { + notification["error"]({ + message: t("bills.errors.exporting", { + error: JSON.stringify(billUpdateResponse.error), + }), + }); + } + } + if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) refetch(); + if (setSelectedBills) { setSelectedBills((selectedBills) => { return selectedBills.filter((i) => i !== billId); diff --git a/client/src/components/payment-export-button/payment-export-button.component.jsx b/client/src/components/payment-export-button/payment-export-button.component.jsx index 0d50032c4..5e5868579 100644 --- a/client/src/components/payment-export-button/payment-export-button.component.jsx +++ b/client/src/components/payment-export-button/payment-export-button.component.jsx @@ -26,6 +26,7 @@ export function PaymentExportButton({ disabled, loadingCallback, setSelectedPayments, + refetch, }) { const { t } = useTranslation(); const [updatePayment] = useMutation(UPDATE_PAYMENTS); @@ -40,6 +41,7 @@ export function PaymentExportButton({ if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) { PartnerResponse = await axios.post(`/qbo/payments`, { payments: [paymentId], + elgen: true, }); } else { //Default is QBD @@ -100,63 +102,68 @@ export function PaymentExportButton({ }), }) ); - - await insertExportLog({ - variables: { - logs: [ - { - bodyshopid: bodyshop.id, - paymentid: paymentId, - successful: false, - message: JSON.stringify( - failedTransactions.map((ft) => ft.errorMessage) - ), - useremail: currentUser.email, - }, - ], - }, - }); - } else { - await insertExportLog({ - variables: { - logs: [ - { - bodyshopid: bodyshop.id, - paymentid: paymentId, - successful: true, - useremail: currentUser.email, - }, - ], - }, - }); - - const paymentUpdateResponse = await updatePayment({ - variables: { - paymentIdList: successfulTransactions.map( - (st) => - st[ - bodyshop.accountingconfig && bodyshop.accountingconfig.qbo - ? "paymentid" - : "id" - ] - ), - payment: { - exportedat: new Date(), + if (!(bodyshop.accountingconfig && bodyshop.accountingconfig.qbo)) { + //QBO Logs are handled server side. + await insertExportLog({ + variables: { + logs: [ + { + bodyshopid: bodyshop.id, + paymentid: paymentId, + successful: false, + message: JSON.stringify( + failedTransactions.map((ft) => ft.errorMessage) + ), + useremail: currentUser.email, + }, + ], }, - }, - }); - if (!!!paymentUpdateResponse.errors) { - notification.open({ - type: "success", - key: "paymentsuccessexport", - message: t("payments.successes.exported"), }); - } else { - notification["error"]({ - message: t("payments.errors.exporting", { - error: JSON.stringify(paymentUpdateResponse.error), - }), + } + } else { + if (!(bodyshop.accountingconfig && bodyshop.accountingconfig.qbo)) { + //QBO Logs are handled server side. + await insertExportLog({ + variables: { + logs: [ + { + bodyshopid: bodyshop.id, + paymentid: paymentId, + successful: true, + useremail: currentUser.email, + }, + ], + }, }); + + const paymentUpdateResponse = await updatePayment({ + variables: { + paymentIdList: successfulTransactions.map( + (st) => + st[ + bodyshop.accountingconfig && bodyshop.accountingconfig.qbo + ? "paymentid" + : "id" + ] + ), + payment: { + exportedat: new Date(), + }, + }, + }); + if (!!!paymentUpdateResponse.errors) { + notification.open({ + type: "success", + key: "paymentsuccessexport", + message: t("payments.successes.exported"), + }); + } else { + notification["error"]({ + message: t("payments.errors.exporting", { + error: JSON.stringify(paymentUpdateResponse.error), + }), + }); + } } if (setSelectedPayments) { @@ -165,7 +172,7 @@ export function PaymentExportButton({ }); } } - + if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) refetch(); if (!!loadingCallback) loadingCallback(false); setLoading(false); }; diff --git a/client/src/components/payments-export-all-button/payments-export-all-button.component.jsx b/client/src/components/payments-export-all-button/payments-export-all-button.component.jsx index b24536210..3f9d7fffd 100644 --- a/client/src/components/payments-export-all-button/payments-export-all-button.component.jsx +++ b/client/src/components/payments-export-all-button/payments-export-all-button.component.jsx @@ -25,6 +25,7 @@ export function PaymentsExportAllButton({ disabled, loadingCallback, completedCallback, + refetch }) { const { t } = useTranslation(); const [updatePayments] = useMutation(UPDATE_PAYMENTS); @@ -38,6 +39,7 @@ export function PaymentsExportAllButton({ if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) { PartnerResponse = await axios.post(`/qbo/payments`, { payments: paymentIds, + elgen: true, }); } else { let QbXmlResponse; @@ -92,54 +94,61 @@ export function PaymentsExportAllButton({ }), }) ); - await insertExportLog({ - variables: { - logs: [ - { - bodyshopid: bodyshop.id, - paymentid: key, - successful: false, - message: JSON.stringify( - failedTransactions.map((ft) => ft.errorMessage) - ), - useremail: currentUser.email, - }, - ], - }, - }); - } else { - await insertExportLog({ - variables: { - logs: [ - { - bodyshopid: bodyshop.id, - paymentid: key, - successful: true, - useremail: currentUser.email, - }, - ], - }, - }); - const paymentUpdateResponse = await updatePayments({ - variables: { - paymentIdList: [key], - payment: { - exportedat: new Date(), + if (!(bodyshop.accountingconfig && bodyshop.accountingconfig.qbo)) { + //QBO Logs are handled server side. + await insertExportLog({ + variables: { + logs: [ + { + bodyshopid: bodyshop.id, + paymentid: key, + successful: false, + message: JSON.stringify( + failedTransactions.map((ft) => ft.errorMessage) + ), + useremail: currentUser.email, + }, + ], }, - }, - }); - if (!!!paymentUpdateResponse.errors) { - notification.open({ - type: "success", - key: "paymentsuccessexport", - message: t("payments.successes.exported"), }); - } else { - notification["error"]({ - message: t("payments.errors.exporting", { - error: JSON.stringify(paymentUpdateResponse.error), - }), + } + } else { + if (!(bodyshop.accountingconfig && bodyshop.accountingconfig.qbo)) { + //QBO Logs are handled server side. + + await insertExportLog({ + variables: { + logs: [ + { + bodyshopid: bodyshop.id, + paymentid: key, + successful: true, + useremail: currentUser.email, + }, + ], + }, }); + const paymentUpdateResponse = await updatePayments({ + variables: { + paymentIdList: [key], + payment: { + exportedat: new Date(), + }, + }, + }); + if (!!!paymentUpdateResponse.errors) { + notification.open({ + type: "success", + key: "paymentsuccessexport", + message: t("payments.successes.exported"), + }); + } else { + notification["error"]({ + message: t("payments.errors.exporting", { + error: JSON.stringify(paymentUpdateResponse.error), + }), + }); + } } } })() @@ -148,6 +157,7 @@ export function PaymentsExportAllButton({ await Promise.all(proms); if (!!completedCallback) completedCallback([]); if (!!loadingCallback) loadingCallback(false); + if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) refetch(); setLoading(false); }; diff --git a/client/src/components/shop-employees/shop-employees-form.component.jsx b/client/src/components/shop-employees/shop-employees-form.component.jsx index 2282d62ef..82fafb1aa 100644 --- a/client/src/components/shop-employees/shop-employees-form.component.jsx +++ b/client/src/components/shop-employees/shop-employees-form.component.jsx @@ -328,6 +328,12 @@ export function ShopEmployeesFormComponent({ bodyshop }) { > + + + {(fields, { add, remove, move }) => { diff --git a/client/src/components/shop-info/shop-info.general.component.jsx b/client/src/components/shop-info/shop-info.general.component.jsx index 0eeb78d4a..92e99791b 100644 --- a/client/src/components/shop-info/shop-info.general.component.jsx +++ b/client/src/components/shop-info/shop-info.general.component.jsx @@ -1393,6 +1393,60 @@ export default function ShopInfoGeneral({ form }) { }} + + + {(fields, { add, remove, move }) => { + return ( +
+ {fields.map((field, index) => ( + + + + + + +