From dfa95927555fe81122c4317bfda8faeb8038ae75 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Fri, 24 Sep 2021 17:17:23 -0700 Subject: [PATCH] IO-256 Add PVRT handling for QBO. --- .../qbo-authorize/qbo-authorize.component.jsx | 1 - .../qbo-authorize/qbo-authorize.scss | 8 ------ server/accounting/qb-receivables-lines.js | 26 +++++++++++++++++- server/accounting/qbo/qbo-receivables.js | 27 +++++++------------ 4 files changed, 34 insertions(+), 28 deletions(-) delete mode 100644 client/src/components/qbo-authorize/qbo-authorize.scss diff --git a/client/src/components/qbo-authorize/qbo-authorize.component.jsx b/client/src/components/qbo-authorize/qbo-authorize.component.jsx index 682e5ebe0..1f159afb0 100644 --- a/client/src/components/qbo-authorize/qbo-authorize.component.jsx +++ b/client/src/components/qbo-authorize/qbo-authorize.component.jsx @@ -5,7 +5,6 @@ import React, { useEffect } from "react"; import { useCookies } from "react-cookie"; import { useHistory, useLocation } from "react-router-dom"; import QboSignIn from "../../assets/qbo/C2QB_green_btn_med_default.svg"; -import "./qbo-authorize.scss"; export default function QboAuthorizeComponent() { const location = useLocation(); diff --git a/client/src/components/qbo-authorize/qbo-authorize.scss b/client/src/components/qbo-authorize/qbo-authorize.scss deleted file mode 100644 index b4016ae80..000000000 --- a/client/src/components/qbo-authorize/qbo-authorize.scss +++ /dev/null @@ -1,8 +0,0 @@ -.qbo-sign-in { - background-image: url("../../assets/qbo/C2QB_green_btn_med_default.svg"); - width: 274px; - height: 48px; - &:hover { - background-image: url("../../assets/qbo/C2QB_green_btn_med_hover.svg"); - } -} diff --git a/server/accounting/qb-receivables-lines.js b/server/accounting/qb-receivables-lines.js index f013600a1..2aabf11e1 100644 --- a/server/accounting/qb-receivables-lines.js +++ b/server/accounting/qb-receivables-lines.js @@ -521,7 +521,31 @@ module.exports = function ({ const { ca_bc_pvrt } = jobs_by_pk; if (ca_bc_pvrt) { if (qbo) { - // do qbo + InvoiceLineAdd.push({ + DetailType: "SalesItemLineDetail", + Amount: Dinero({ amount: (ca_bc_pvrt || 0) * 100 }).toFormat( + DineroQbFormat + ), + SalesItemLineDetail: { + ItemRef: { + value: items["PVRT"], + }, + Qty: 1, + TaxCodeRef: { + value: + taxCodes[ + findTaxCode( + { + local: false, + federal: false, + state: false, + }, + bodyshop.md_responsibility_centers.sales_tax_codes + ) + ], + }, + }, + }); } else { InvoiceLineAdd.push({ ItemRef: { diff --git a/server/accounting/qbo/qbo-receivables.js b/server/accounting/qbo/qbo-receivables.js index b1f981f97..010266812 100644 --- a/server/accounting/qbo/qbo-receivables.js +++ b/server/accounting/qbo/qbo-receivables.js @@ -15,6 +15,7 @@ const { } = require("./qbo-callback"); const OAuthClient = require("intuit-oauth"); const CreateInvoiceLines = require("../qb-receivables-lines"); +const moment = require("moment"); const GraphQLClient = require("graphql-request").GraphQLClient; const { generateOwnerTier } = require("../qbxml/qbxml-utils"); @@ -364,28 +365,18 @@ async function InsertInvoice(oauthClient, req, job, bodyshop, parentTierRef) { }); const invoiceObj = { - // Line: [ - // { - // DetailType: "SalesItemLineDetail", - // Amount: 100, - // SalesItemLineDetail: { - // ItemRef: { - // // name: "Services", - // value: "1", - // }, - // TaxCodeRef: { - // value: "2", - // }, - // Qty: 1, - // UnitPrice: 100, - // }, - // }, - // ], Line: InvoiceLineAdd, - + TxnDate: moment(job.date_invoiced).format("YYYY-MM-DD"), + DocNumber: job.ro_number, CustomerRef: { value: parentTierRef.Id, }, + ...(bodyshop.accountingconfig.printlater + ? { PrintStatus: "NeedToPrint" } + : {}), + ...(bodyshop.accountingconfig.emaillater + ? { EmailStatus: "NeedToSend" } + : {}), }; try {