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..ea1b6c870 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, @@ -30,7 +29,7 @@ export function JobsCloseExportButton({ }) { const history = useHistory(); const { t } = useTranslation(); - const [updateJob] = useMutation(UPDATE_JOB); + const [updateJob] = useMutation(UPDATE_JOB, {}); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); const [loading, setLoading] = useState(false); @@ -46,13 +45,9 @@ 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], + }); } else { //Default is QBD @@ -155,6 +150,7 @@ export function JobsCloseExportButton({ date_exported: new Date(), }, }, + refetchQueries: ["QUERY_JOBS_FOR_EXPORT "], }); if (!jobUpdateResponse.errors) { 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..074b312cc 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 @@ -28,7 +28,9 @@ export function JobsExportAllButton({ completedCallback, }) { const { t } = useTranslation(); - const [updateJob] = useMutation(UPDATE_JOBS); + const [updateJob] = useMutation(UPDATE_JOBS, { + refetchQueries: ["QUERY_JOBS_FOR_EXPORT "], + }); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); const [loading, setLoading] = useState(false); 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..cb0593ec4 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 @@ -29,7 +29,9 @@ export function PayableExportAll({ completedCallback, }) { const { t } = useTranslation(); - const [updateBill] = useMutation(UPDATE_BILLS); + const [updateBill] = useMutation(UPDATE_BILLS, { + refetchQueries: ["QUERY_BILLS_FOR_EXPORT "], + }); const [loading, setLoading] = useState(false); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); 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..4b3135a26 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 @@ -28,7 +28,9 @@ export function PayableExportButton({ setSelectedBills, }) { const { t } = useTranslation(); - const [updateBill] = useMutation(UPDATE_BILLS); + const [updateBill] = useMutation(UPDATE_BILLS, { + refetchQueries: ["QUERY_BILLS_FOR_EXPORT "], + }); const [loading, setLoading] = useState(false); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); 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..4927ca3d9 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 @@ -28,7 +28,9 @@ export function PaymentExportButton({ setSelectedPayments, }) { const { t } = useTranslation(); - const [updatePayment] = useMutation(UPDATE_PAYMENTS); + const [updatePayment] = useMutation(UPDATE_PAYMENTS, { + refetchQueries: ["QUERY_PAYMENTS_FOR_EXPORT "], + }); const [loading, setLoading] = useState(false); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); 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..c8f769ec4 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 @@ -27,7 +27,9 @@ export function PaymentsExportAllButton({ completedCallback, }) { const { t } = useTranslation(); - const [updatePayments] = useMutation(UPDATE_PAYMENTS); + const [updatePayments] = useMutation(UPDATE_PAYMENTS, { + refetchQueries: ["QUERY_PAYMENTS_FOR_EXPORT "], + }); const [loading, setLoading] = useState(false); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); diff --git a/client/src/pages/jobs-close/jobs-close.component.jsx b/client/src/pages/jobs-close/jobs-close.component.jsx index 058e9be74..71d961c99 100644 --- a/client/src/pages/jobs-close/jobs-close.component.jsx +++ b/client/src/pages/jobs-close/jobs-close.component.jsx @@ -146,11 +146,13 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) { {t("general.actions.close")} - - - + {(bodyshop.pbs_serialnumber || bodyshop.cdk_dealerid) && ( + + + + )} } diff --git a/server/accounting/pbs/pbs-job-export.js b/server/accounting/pbs/pbs-job-export.js index 58c577038..89114751a 100644 --- a/server/accounting/pbs/pbs-job-export.js +++ b/server/accounting/pbs/pbs-job-export.js @@ -15,7 +15,7 @@ const CalculateAllocations = require("../../cdk/cdk-calculate-allocations").default; const CdkBase = require("../../web-sockets/web-socket"); const moment = require("moment"); - +const Dinero = require("dinero.js"); const axios = AxiosLib.create(); axios.interceptors.request.use((x) => { const socket = x.socket; @@ -116,8 +116,9 @@ exports.PbsSelectedCustomer = async function PbsSelectedCustomer( ); await UpsertVehicleData(socket, ownerRef.ReferenceId); CdkBase.createLogEvent(socket, "DEBUG", `Inserting account data.`); - return; + await InsertAccountPostingData(socket); + CdkBase.createLogEvent(socket, "DEBUG", `Marking job as exported.`); await MarkJobExported(socket, socket.JobData.id); @@ -535,7 +536,7 @@ async function InsertAccountPostingData(socket) { const item = { Account: alloc.profitCenter.dms_acctnumber, ControlNumber: socket.JobData.ro_number, - Amount: alloc.sale.multiply(-1).toFormat("0.0"), + Amount: alloc.sale.multiply(-1).toFormat("0.00"), //Comment: "String", //AdditionalInfo: "String", InvoiceNumber: socket.JobData.ro_number, @@ -549,7 +550,7 @@ async function InsertAccountPostingData(socket) { const item = { Account: alloc.costCenter.dms_acctnumber, ControlNumber: socket.JobData.ro_number, - Amount: alloc.cost.toFormat("0.0"), + Amount: alloc.cost.toFormat("0.00"), //Comment: "String", //AdditionalInfo: "String", InvoiceNumber: socket.JobData.ro_number, @@ -560,7 +561,7 @@ async function InsertAccountPostingData(socket) { const itemWip = { Account: alloc.costCenter.dms_wip_acctnumber, ControlNumber: socket.JobData.ro_number, - Amount: alloc.cost.multiply(-1).toFormat("0.0"), + Amount: alloc.cost.multiply(-1).toFormat("0.00"), //Comment: "String", //AdditionalInfo: "String", InvoiceNumber: socket.JobData.ro_number, @@ -575,7 +576,7 @@ async function InsertAccountPostingData(socket) { const item2 = { Account: alloc.profitCenter.dms_acctnumber, ControlNumber: socket.JobData.ro_number, - Amount: alloc.sale.multiply(-1).toFormat("0.0"), + Amount: alloc.sale.multiply(-1).toFormat("0.00"), //Comment: "String", //AdditionalInfo: "String", InvoiceNumber: socket.JobData.ro_number, @@ -585,6 +586,21 @@ async function InsertAccountPostingData(socket) { } } }); + socket.txEnvelope.payers.forEach((payer) => { + const item = { + Account: payer.dms_acctnumber, + ControlNumber: payer.controlnumber, + Amount: Dinero({ amount: Math.round(payer.amount * 100) }).toFormat( + "0.0" + ), + //Comment: "String", + //AdditionalInfo: "String", + InvoiceNumber: socket.JobData.ro_number, + InvoiceDate: moment(socket.JobData.date_invoiced).toISOString(), + }; + + wips.push(item); + }); const { data: AccountPostingChange } = await axios.post( PBS_ENDPOINTS.AccountingPostingChange,