IO-256 QBO Improvements.
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
|||||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||||
import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
|
import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
|
||||||
import { useHistory } from "react-router-dom";
|
import { useHistory } from "react-router-dom";
|
||||||
|
import { useCookies } from "react-cookie";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
@@ -32,6 +33,7 @@ export function JobsCloseExportButton({
|
|||||||
const [updateJob] = useMutation(UPDATE_JOB);
|
const [updateJob] = useMutation(UPDATE_JOB);
|
||||||
const [insertExportLog] = useMutation(INSERT_EXPORT_LOG);
|
const [insertExportLog] = useMutation(INSERT_EXPORT_LOG);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [cookies] = useCookies();
|
||||||
|
|
||||||
const handleQbxml = async () => {
|
const handleQbxml = async () => {
|
||||||
//Check if it's a CDK setup.
|
//Check if it's a CDK setup.
|
||||||
@@ -180,7 +182,16 @@ export function JobsCloseExportButton({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button onClick={handleQbxml} loading={loading} disabled={disabled}>
|
<Button
|
||||||
|
onClick={handleQbxml}
|
||||||
|
loading={loading}
|
||||||
|
disabled={
|
||||||
|
disabled ||
|
||||||
|
(bodyshop.accountingconfig &&
|
||||||
|
bodyshop.accountingconfig.qbo &&
|
||||||
|
!cookies.qbo_realmId)
|
||||||
|
}
|
||||||
|
>
|
||||||
{t("jobs.actions.export")}
|
{t("jobs.actions.export")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
selectBodyshop,
|
selectBodyshop,
|
||||||
selectCurrentUser,
|
selectCurrentUser,
|
||||||
} from "../../redux/user/user.selectors";
|
} from "../../redux/user/user.selectors";
|
||||||
|
import { useCookies } from "react-cookie";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
@@ -30,6 +31,7 @@ export function JobsExportAllButton({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [updateJob] = useMutation(UPDATE_JOBS);
|
const [updateJob] = useMutation(UPDATE_JOBS);
|
||||||
const [insertExportLog] = useMutation(INSERT_EXPORT_LOG);
|
const [insertExportLog] = useMutation(INSERT_EXPORT_LOG);
|
||||||
|
const [cookies] = useCookies();
|
||||||
|
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const handleQbxml = async () => {
|
const handleQbxml = async () => {
|
||||||
@@ -173,7 +175,16 @@ export function JobsExportAllButton({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button onClick={handleQbxml} loading={loading} disabled={disabled}>
|
<Button
|
||||||
|
onClick={handleQbxml}
|
||||||
|
loading={loading}
|
||||||
|
disabled={
|
||||||
|
disabled ||
|
||||||
|
(bodyshop.accountingconfig &&
|
||||||
|
bodyshop.accountingconfig.qbo &&
|
||||||
|
!cookies.qbo_realmId)
|
||||||
|
}
|
||||||
|
>
|
||||||
{t("jobs.actions.export")}
|
{t("jobs.actions.export")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
|
import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
|
||||||
|
import { useCookies } from "react-cookie";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
@@ -32,6 +33,7 @@ export function PayableExportAll({
|
|||||||
const [updateBill] = useMutation(UPDATE_BILLS);
|
const [updateBill] = useMutation(UPDATE_BILLS);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [insertExportLog] = useMutation(INSERT_EXPORT_LOG);
|
const [insertExportLog] = useMutation(INSERT_EXPORT_LOG);
|
||||||
|
const [cookies] = useCookies();
|
||||||
|
|
||||||
const handleQbxml = async () => {
|
const handleQbxml = async () => {
|
||||||
logImEXEvent("accounting_payables_export_all");
|
logImEXEvent("accounting_payables_export_all");
|
||||||
@@ -172,7 +174,16 @@ export function PayableExportAll({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button onClick={handleQbxml} loading={loading} disabled={disabled}>
|
<Button
|
||||||
|
onClick={handleQbxml}
|
||||||
|
loading={loading}
|
||||||
|
disabled={
|
||||||
|
disabled ||
|
||||||
|
(bodyshop.accountingconfig &&
|
||||||
|
bodyshop.accountingconfig.qbo &&
|
||||||
|
!cookies.qbo_realmId)
|
||||||
|
}
|
||||||
|
>
|
||||||
{t("jobs.actions.exportselected")}
|
{t("jobs.actions.exportselected")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
} from "../../redux/user/user.selectors";
|
} from "../../redux/user/user.selectors";
|
||||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||||
import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
|
import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
|
||||||
|
import { useCookies } from "react-cookie";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
@@ -31,6 +32,7 @@ export function PayableExportButton({
|
|||||||
const [updateBill] = useMutation(UPDATE_BILLS);
|
const [updateBill] = useMutation(UPDATE_BILLS);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [insertExportLog] = useMutation(INSERT_EXPORT_LOG);
|
const [insertExportLog] = useMutation(INSERT_EXPORT_LOG);
|
||||||
|
const [cookies] = useCookies();
|
||||||
|
|
||||||
const handleQbxml = async () => {
|
const handleQbxml = async () => {
|
||||||
logImEXEvent("accounting_export_payable");
|
logImEXEvent("accounting_export_payable");
|
||||||
@@ -174,7 +176,16 @@ export function PayableExportButton({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button onClick={handleQbxml} loading={loading} disabled={disabled}>
|
<Button
|
||||||
|
onClick={handleQbxml}
|
||||||
|
loading={loading}
|
||||||
|
disabled={
|
||||||
|
disabled ||
|
||||||
|
(bodyshop.accountingconfig &&
|
||||||
|
bodyshop.accountingconfig.qbo &&
|
||||||
|
!cookies.qbo_realmId)
|
||||||
|
}
|
||||||
|
>
|
||||||
{t("jobs.actions.export")}
|
{t("jobs.actions.export")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import { createStructuredSelector } from "reselect";
|
|||||||
import { auth, logImEXEvent } from "../../firebase/firebase.utils";
|
import { auth, logImEXEvent } from "../../firebase/firebase.utils";
|
||||||
import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
|
import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
|
||||||
import { UPDATE_PAYMENTS } from "../../graphql/payments.queries";
|
import { UPDATE_PAYMENTS } from "../../graphql/payments.queries";
|
||||||
|
import { useCookies } from "react-cookie";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
selectBodyshop,
|
selectBodyshop,
|
||||||
selectCurrentUser,
|
selectCurrentUser,
|
||||||
@@ -30,6 +32,7 @@ export function PaymentExportButton({
|
|||||||
const [updatePayment] = useMutation(UPDATE_PAYMENTS);
|
const [updatePayment] = useMutation(UPDATE_PAYMENTS);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [insertExportLog] = useMutation(INSERT_EXPORT_LOG);
|
const [insertExportLog] = useMutation(INSERT_EXPORT_LOG);
|
||||||
|
const [cookies] = useCookies();
|
||||||
|
|
||||||
const handleQbxml = async () => {
|
const handleQbxml = async () => {
|
||||||
logImEXEvent("accounting_payment_export");
|
logImEXEvent("accounting_payment_export");
|
||||||
@@ -174,7 +177,16 @@ export function PaymentExportButton({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button onClick={handleQbxml} loading={loading} disabled={disabled}>
|
<Button
|
||||||
|
onClick={handleQbxml}
|
||||||
|
loading={loading}
|
||||||
|
disabled={
|
||||||
|
disabled ||
|
||||||
|
(bodyshop.accountingconfig &&
|
||||||
|
bodyshop.accountingconfig.qbo &&
|
||||||
|
!cookies.qbo_realmId)
|
||||||
|
}
|
||||||
|
>
|
||||||
{t("jobs.actions.export")}
|
{t("jobs.actions.export")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import { connect } from "react-redux";
|
|||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
|
import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
|
||||||
import { UPDATE_PAYMENTS } from "../../graphql/payments.queries";
|
import { UPDATE_PAYMENTS } from "../../graphql/payments.queries";
|
||||||
|
import { useCookies } from "react-cookie";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
selectBodyshop,
|
selectBodyshop,
|
||||||
selectCurrentUser,
|
selectCurrentUser,
|
||||||
@@ -29,6 +31,7 @@ export function PaymentsExportAllButton({
|
|||||||
const [updatePayments] = useMutation(UPDATE_PAYMENTS);
|
const [updatePayments] = useMutation(UPDATE_PAYMENTS);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [insertExportLog] = useMutation(INSERT_EXPORT_LOG);
|
const [insertExportLog] = useMutation(INSERT_EXPORT_LOG);
|
||||||
|
const [cookies] = useCookies();
|
||||||
|
|
||||||
const handleQbxml = async () => {
|
const handleQbxml = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -155,7 +158,16 @@ export function PaymentsExportAllButton({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button onClick={handleQbxml} loading={loading} disabled={disabled}>
|
<Button
|
||||||
|
onClick={handleQbxml}
|
||||||
|
loading={loading}
|
||||||
|
disabled={
|
||||||
|
disabled ||
|
||||||
|
(bodyshop.accountingconfig &&
|
||||||
|
bodyshop.accountingconfig.qbo &&
|
||||||
|
!cookies.qbo_realmId)
|
||||||
|
}
|
||||||
|
>
|
||||||
{t("jobs.actions.exportselected")}
|
{t("jobs.actions.exportselected")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -33,7 +33,10 @@ export default function QboAuthorizeComponent() {
|
|||||||
setCookie("qbo_realmId", realmId, {
|
setCookie("qbo_realmId", realmId, {
|
||||||
path: "/",
|
path: "/",
|
||||||
expires,
|
expires,
|
||||||
domain: `.${window.location.host}`,
|
|
||||||
|
...(process.env.NODE_ENV !== "development"
|
||||||
|
? { domain: `.${window.location.host}` }
|
||||||
|
: {}),
|
||||||
});
|
});
|
||||||
|
|
||||||
history.push({ pathname: `/manage/accounting/receivables` });
|
history.push({ pathname: `/manage/accounting/receivables` });
|
||||||
|
|||||||
@@ -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.
|
//Replace this with a for-each loop to check every single Job that's included in the list.
|
||||||
|
|
||||||
let insCoCustomerTier, ownerCustomerTier, jobTier;
|
let insCoCustomerTier, ownerCustomerTier, jobTier;
|
||||||
if (isThreeTier || twoTierPref === "source") {
|
if (isThreeTier || (!isThreeTier && twoTierPref === "source")) {
|
||||||
//Insert the insurance company tier.
|
//Insert the insurance company tier.
|
||||||
//Query for top level customer, the insurance company name.
|
//Query for top level customer, the insurance company name.
|
||||||
insCoCustomerTier = await QueryInsuranceCo(oauthClient, req, job);
|
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..
|
//Insert the name/owner and account for whether the source should be the ins co in 3 tier..
|
||||||
ownerCustomerTier = await QueryOwner(oauthClient, req, job);
|
ownerCustomerTier = await QueryOwner(oauthClient, req, job);
|
||||||
//Query for the owner itself.
|
//Query for the owner itself.
|
||||||
@@ -106,8 +106,8 @@ exports.default = async (req, res) => {
|
|||||||
oauthClient,
|
oauthClient,
|
||||||
req,
|
req,
|
||||||
job,
|
job,
|
||||||
isThreeTier,
|
|
||||||
ownerCustomerTier
|
ownerCustomerTier || insCoCustomerTier
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +279,7 @@ async function QueryJob(oauthClient, req, job) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
exports.QueryJob = QueryJob;
|
exports.QueryJob = QueryJob;
|
||||||
async function InsertJob(oauthClient, req, job, isThreeTier, parentTierRef) {
|
async function InsertJob(oauthClient, req, job, parentTierRef) {
|
||||||
const Customer = {
|
const Customer = {
|
||||||
DisplayName: job.ro_number,
|
DisplayName: job.ro_number,
|
||||||
BillAddr: {
|
BillAddr: {
|
||||||
@@ -289,14 +289,11 @@ async function InsertJob(oauthClient, req, job, isThreeTier, parentTierRef) {
|
|||||||
PostalCode: job.ownr_zip,
|
PostalCode: job.ownr_zip,
|
||||||
CountrySubDivisionCode: job.ownr_st,
|
CountrySubDivisionCode: job.ownr_st,
|
||||||
},
|
},
|
||||||
...(isThreeTier
|
|
||||||
? {
|
Job: true,
|
||||||
Job: true,
|
ParentRef: {
|
||||||
ParentRef: {
|
value: parentTierRef.Id,
|
||||||
value: parentTierRef.Id,
|
},
|
||||||
},
|
|
||||||
}
|
|
||||||
: {}),
|
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const result = await oauthClient.makeApiCall({
|
const result = await oauthClient.makeApiCall({
|
||||||
|
|||||||
Reference in New Issue
Block a user