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 1344a7411..426e9709f 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 @@ -14,6 +14,7 @@ import { import { logImEXEvent } from "../../firebase/firebase.utils"; import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries"; import { useHistory } from "react-router-dom"; +import { useCookies } from "react-cookie"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -32,6 +33,7 @@ export function JobsCloseExportButton({ const [updateJob] = useMutation(UPDATE_JOB); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); const [loading, setLoading] = useState(false); + const [cookies] = useCookies(); const handleQbxml = async () => { //Check if it's a CDK setup. @@ -180,7 +182,16 @@ export function JobsCloseExportButton({ }; return ( - ); 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 780817ad5..8862bceeb 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 @@ -13,6 +13,7 @@ import { selectBodyshop, selectCurrentUser, } from "../../redux/user/user.selectors"; +import { useCookies } from "react-cookie"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -30,6 +31,7 @@ export function JobsExportAllButton({ const { t } = useTranslation(); const [updateJob] = useMutation(UPDATE_JOBS); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); + const [cookies] = useCookies(); const [loading, setLoading] = useState(false); const handleQbxml = async () => { @@ -173,7 +175,16 @@ export function JobsExportAllButton({ }; return ( - ); 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 44f82faab..95fd184b2 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 @@ -14,6 +14,7 @@ import { import { logImEXEvent } from "../../firebase/firebase.utils"; import _ from "lodash"; import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries"; +import { useCookies } from "react-cookie"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -32,6 +33,7 @@ export function PayableExportAll({ const [updateBill] = useMutation(UPDATE_BILLS); const [loading, setLoading] = useState(false); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); + const [cookies] = useCookies(); const handleQbxml = async () => { logImEXEvent("accounting_payables_export_all"); @@ -172,7 +174,16 @@ export function PayableExportAll({ }; return ( - ); 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 f54ff668a..70b115175 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 @@ -13,6 +13,7 @@ import { } from "../../redux/user/user.selectors"; import { logImEXEvent } from "../../firebase/firebase.utils"; import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries"; +import { useCookies } from "react-cookie"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -31,6 +32,7 @@ export function PayableExportButton({ const [updateBill] = useMutation(UPDATE_BILLS); const [loading, setLoading] = useState(false); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); + const [cookies] = useCookies(); const handleQbxml = async () => { logImEXEvent("accounting_export_payable"); @@ -174,7 +176,16 @@ export function PayableExportButton({ }; return ( - ); 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 2bc6ec19a..0d3a124ac 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 @@ -8,6 +8,8 @@ import { createStructuredSelector } from "reselect"; import { auth, logImEXEvent } from "../../firebase/firebase.utils"; import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries"; import { UPDATE_PAYMENTS } from "../../graphql/payments.queries"; +import { useCookies } from "react-cookie"; + import { selectBodyshop, selectCurrentUser, @@ -30,6 +32,7 @@ export function PaymentExportButton({ const [updatePayment] = useMutation(UPDATE_PAYMENTS); const [loading, setLoading] = useState(false); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); + const [cookies] = useCookies(); const handleQbxml = async () => { logImEXEvent("accounting_payment_export"); @@ -174,7 +177,16 @@ export function PaymentExportButton({ }; return ( - ); 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 6bb0f9fc6..35c58552a 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 @@ -8,6 +8,8 @@ import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries"; import { UPDATE_PAYMENTS } from "../../graphql/payments.queries"; +import { useCookies } from "react-cookie"; + import { selectBodyshop, selectCurrentUser, @@ -29,6 +31,7 @@ export function PaymentsExportAllButton({ const [updatePayments] = useMutation(UPDATE_PAYMENTS); const [loading, setLoading] = useState(false); const [insertExportLog] = useMutation(INSERT_EXPORT_LOG); + const [cookies] = useCookies(); const handleQbxml = async () => { setLoading(true); @@ -155,7 +158,16 @@ export function PaymentsExportAllButton({ }; return ( - ); diff --git a/client/src/components/qbo-authorize/qbo-authorize.component.jsx b/client/src/components/qbo-authorize/qbo-authorize.component.jsx index 0b9d48a11..2ebb75c6f 100644 --- a/client/src/components/qbo-authorize/qbo-authorize.component.jsx +++ b/client/src/components/qbo-authorize/qbo-authorize.component.jsx @@ -33,7 +33,10 @@ export default function QboAuthorizeComponent() { setCookie("qbo_realmId", realmId, { path: "/", expires, - domain: `.${window.location.host}`, + + ...(process.env.NODE_ENV !== "development" + ? { domain: `.${window.location.host}` } + : {}), }); history.push({ pathname: `/manage/accounting/receivables` }); diff --git a/server/accounting/qbo/qbo-receivables.js b/server/accounting/qbo/qbo-receivables.js index e28af80f2..fad3a686c 100644 --- a/server/accounting/qbo/qbo-receivables.js +++ b/server/accounting/qbo/qbo-receivables.js @@ -66,7 +66,7 @@ exports.default = async (req, res) => { //Replace this with a for-each loop to check every single Job that's included in the list. let insCoCustomerTier, ownerCustomerTier, jobTier; - if (isThreeTier || twoTierPref === "source") { + if (isThreeTier || (!isThreeTier && twoTierPref === "source")) { //Insert the insurance company tier. //Query for top level customer, the insurance company name. insCoCustomerTier = await QueryInsuranceCo(oauthClient, req, job); @@ -81,7 +81,7 @@ exports.default = async (req, res) => { } } - if (isThreeTier || twoTierPref === "name") { + 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, req, job); //Query for the owner itself. @@ -106,8 +106,8 @@ exports.default = async (req, res) => { oauthClient, req, job, - isThreeTier, - ownerCustomerTier + + ownerCustomerTier || insCoCustomerTier ); } @@ -279,7 +279,7 @@ async function QueryJob(oauthClient, req, job) { ); } exports.QueryJob = QueryJob; -async function InsertJob(oauthClient, req, job, isThreeTier, parentTierRef) { +async function InsertJob(oauthClient, req, job, parentTierRef) { const Customer = { DisplayName: job.ro_number, BillAddr: { @@ -289,14 +289,11 @@ async function InsertJob(oauthClient, req, job, isThreeTier, parentTierRef) { PostalCode: job.ownr_zip, CountrySubDivisionCode: job.ownr_st, }, - ...(isThreeTier - ? { - Job: true, - ParentRef: { - value: parentTierRef.Id, - }, - } - : {}), + + Job: true, + ParentRef: { + value: parentTierRef.Id, + }, }; try { const result = await oauthClient.makeApiCall({