QBO USA Changes for tax and non tax items.

This commit is contained in:
Patrick Fic
2023-04-24 13:13:32 -07:00
parent f6be133a78
commit 648e8aaae0
9 changed files with 168 additions and 50 deletions

View File

@@ -1,4 +1,4 @@
<babeledit_project version="1.2" be_version="2.7.1"> <babeledit_project be_version="2.7.1" version="1.2">
<!-- <!--
BabelEdit project file BabelEdit project file
@@ -7246,6 +7246,48 @@
</translation> </translation>
</translations> </translations>
</concept_node> </concept_node>
<concept_node>
<name>invoiceexemptcode</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>itemexemptcode</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node> <concept_node>
<name>la1</name> <name>la1</name>
<definition_loaded>false</definition_loaded> <definition_loaded>false</definition_loaded>

View File

@@ -1,14 +1,15 @@
import { DeleteFilled, DollarCircleFilled } from "@ant-design/icons"; import { DeleteFilled, DollarCircleFilled } from "@ant-design/icons";
import { useTreatments } from "@splitsoftware/splitio-react"; import { useTreatments } from "@splitsoftware/splitio-react";
import { import {
Button, Form, Button,
Form,
Input, Input,
InputNumber, InputNumber,
Select, Select,
Space, Space,
Switch, Switch,
Table, Table,
Tooltip Tooltip,
} from "antd"; } from "antd";
import React from "react"; import React from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
@@ -466,7 +467,7 @@ export function BillEnterModalLinesComponent({
return { return {
key: `${field.index}fedtax`, key: `${field.index}fedtax`,
valuePropName: "checked", valuePropName: "checked",
initialValue: true, // initialValue: true,
name: [field.name, "applicable_taxes", "federal"], name: [field.name, "applicable_taxes", "federal"],
}; };
}, },

View File

@@ -456,6 +456,8 @@
"federal_tax": "Federal Tax", "federal_tax": "Federal Tax",
"federal_tax_itc": "Federal Tax Credit", "federal_tax_itc": "Federal Tax Credit",
"gst_override": "GST Override Account #", "gst_override": "GST Override Account #",
"invoiceexemptcode": "QuickBooks US - Invoice Tax Exempt Code",
"itemexemptcode": "QuickBooks US - Line Item Tax Exempt Code",
"la1": "LA1", "la1": "LA1",
"la2": "LA2", "la2": "LA2",
"la3": "LA3", "la3": "LA3",

View File

@@ -456,6 +456,8 @@
"federal_tax": "", "federal_tax": "",
"federal_tax_itc": "", "federal_tax_itc": "",
"gst_override": "", "gst_override": "",
"invoiceexemptcode": "",
"itemexemptcode": "",
"la1": "", "la1": "",
"la2": "", "la2": "",
"la3": "", "la3": "",

View File

@@ -456,6 +456,8 @@
"federal_tax": "", "federal_tax": "",
"federal_tax_itc": "", "federal_tax_itc": "",
"gst_override": "", "gst_override": "",
"invoiceexemptcode": "",
"itemexemptcode": "",
"la1": "", "la1": "",
"la2": "", "la2": "",
"la3": "", "la3": "",

View File

@@ -78,7 +78,7 @@ exports.default = function ({
const taxAccountCode = findTaxCode( const taxAccountCode = findTaxCode(
{ {
local: false, local: false,
federal: true, federal: process.env.COUNTRY === "USA" ? false : true,
state: state:
jobs_by_pk.state_tax_rate === 0 jobs_by_pk.state_tax_rate === 0
? false ? false
@@ -93,7 +93,14 @@ exports.default = function ({
bodyshop.md_responsibility_centers.sales_tax_codes bodyshop.md_responsibility_centers.sales_tax_codes
); );
const QboTaxId = taxCodes[taxAccountCode]; const QboTaxId =
process.env.COUNTRY === "USA"
? CheckQBOUSATaxID({
jobline: jobline,
type: "part",
job: jobs_by_pk,
})
: taxCodes[taxAccountCode];
if (!invoiceLineHash[account.name]) invoiceLineHash[account.name] = {}; if (!invoiceLineHash[account.name]) invoiceLineHash[account.name] = {};
if (!invoiceLineHash[account.name][QboTaxId]) { if (!invoiceLineHash[account.name][QboTaxId]) {
invoiceLineHash[account.name][QboTaxId] = { invoiceLineHash[account.name][QboTaxId] = {
@@ -158,13 +165,16 @@ exports.default = function ({
const taxAccountCode = findTaxCode( const taxAccountCode = findTaxCode(
{ {
local: false, local: false,
federal: true, federal: process.env.COUNTRY === "USA" ? false : true,
state: jobs_by_pk.state_tax_rate === 0 ? false : true, state: jobs_by_pk.state_tax_rate === 0 ? false : true,
}, },
bodyshop.md_responsibility_centers.sales_tax_codes bodyshop.md_responsibility_centers.sales_tax_codes
); );
const QboTaxId = taxCodes[taxAccountCode]; const QboTaxId =
process.env.COUNTRY === "USA"
? CheckQBOUSATaxID({ jobline: jobline, type: "labor" })
: taxCodes[taxAccountCode];
if (!invoiceLineHash[account.name]) invoiceLineHash[account.name] = {}; if (!invoiceLineHash[account.name]) invoiceLineHash[account.name] = {};
if (!invoiceLineHash[account.name][QboTaxId]) { if (!invoiceLineHash[account.name][QboTaxId]) {
invoiceLineHash[account.name][QboTaxId] = { invoiceLineHash[account.name][QboTaxId] = {
@@ -225,13 +235,20 @@ exports.default = function ({
const taxAccountCode = findTaxCode( const taxAccountCode = findTaxCode(
{ {
local: false, local: false,
federal: true, federal: process.env.COUNTRY === "USA" ? false : true,
state: jobs_by_pk.state_tax_rate === 0 ? false : true, state: jobs_by_pk.state_tax_rate === 0 ? false : true,
}, },
bodyshop.md_responsibility_centers.sales_tax_codes bodyshop.md_responsibility_centers.sales_tax_codes
); );
const QboTaxId = taxCodes[taxAccountCode]; const QboTaxId =
process.env.COUNTRY === "USA"
? CheckQBOUSATaxID({
// jobline: jobline,
job: jobs_by_pk,
type: "materials",
})
: taxCodes[taxAccountCode];
if (!invoiceLineHash[mapaAccount.name]) if (!invoiceLineHash[mapaAccount.name])
invoiceLineHash[mapaAccount.name] = {}; invoiceLineHash[mapaAccount.name] = {};
if (!invoiceLineHash[mapaAccount.name][QboTaxId]) { if (!invoiceLineHash[mapaAccount.name][QboTaxId]) {
@@ -292,13 +309,20 @@ exports.default = function ({
const taxAccountCode = findTaxCode( const taxAccountCode = findTaxCode(
{ {
local: false, local: false,
federal: true, federal: process.env.COUNTRY === "USA" ? false : true,
state: jobs_by_pk.state_tax_rate === 0 ? false : true, state: jobs_by_pk.state_tax_rate === 0 ? false : true,
}, },
bodyshop.md_responsibility_centers.sales_tax_codes bodyshop.md_responsibility_centers.sales_tax_codes
); );
const QboTaxId = taxCodes[taxAccountCode]; const QboTaxId =
process.env.COUNTRY === "USA"
? CheckQBOUSATaxID({
// jobline: jobline,
job: jobs_by_pk,
type: "materials",
})
: taxCodes[taxAccountCode];
if (!invoiceLineHash[mashAccount.name]) if (!invoiceLineHash[mashAccount.name])
invoiceLineHash[mashAccount.name] = {}; invoiceLineHash[mashAccount.name] = {};
if (!invoiceLineHash[mashAccount.name][QboTaxId]) { if (!invoiceLineHash[mashAccount.name][QboTaxId]) {
@@ -375,7 +399,7 @@ exports.default = function ({
const taxAccountCode = findTaxCode( const taxAccountCode = findTaxCode(
{ {
local: false, local: false,
federal: true, federal: process.env.COUNTRY === "USA" ? false : true,
state: jobs_by_pk.state_tax_rate === 0 ? false : true, state: jobs_by_pk.state_tax_rate === 0 ? false : true,
}, },
bodyshop.md_responsibility_centers.sales_tax_codes bodyshop.md_responsibility_centers.sales_tax_codes
@@ -383,7 +407,14 @@ exports.default = function ({
const account = responsibilityCenters.profits.find( const account = responsibilityCenters.profits.find(
(c) => c.name === responsibilityCenters.defaults.profits["TOW"] (c) => c.name === responsibilityCenters.defaults.profits["TOW"]
); );
const QboTaxId = taxCodes[taxAccountCode]; const QboTaxId =
process.env.COUNTRY === "USA"
? CheckQBOUSATaxID({
// jobline: jobline,
job: jobs_by_pk,
type: "towing",
})
: taxCodes[taxAccountCode];
InvoiceLineAdd.push({ InvoiceLineAdd.push({
DetailType: "SalesItemLineDetail", DetailType: "SalesItemLineDetail",
Amount: Dinero({ Amount: Dinero({
@@ -427,7 +458,7 @@ exports.default = function ({
const taxAccountCode = findTaxCode( const taxAccountCode = findTaxCode(
{ {
local: false, local: false,
federal: true, federal: process.env.COUNTRY === "USA" ? false : true,
state: jobs_by_pk.state_tax_rate === 0 ? false : true, state: jobs_by_pk.state_tax_rate === 0 ? false : true,
}, },
bodyshop.md_responsibility_centers.sales_tax_codes bodyshop.md_responsibility_centers.sales_tax_codes
@@ -435,7 +466,14 @@ exports.default = function ({
const account = responsibilityCenters.profits.find( const account = responsibilityCenters.profits.find(
(c) => c.name === responsibilityCenters.defaults.profits["TOW"] (c) => c.name === responsibilityCenters.defaults.profits["TOW"]
); );
const QboTaxId = taxCodes[taxAccountCode]; const QboTaxId =
process.env.COUNTRY === "USA"
? CheckQBOUSATaxID({
// jobline: jobline,
job: jobs_by_pk,
type: "storage",
})
: taxCodes[taxAccountCode];
InvoiceLineAdd.push({ InvoiceLineAdd.push({
DetailType: "SalesItemLineDetail", DetailType: "SalesItemLineDetail",
Amount: Dinero({ Amount: Dinero({
@@ -482,13 +520,20 @@ exports.default = function ({
const taxAccountCode = findTaxCode( const taxAccountCode = findTaxCode(
{ {
local: false, local: false,
federal: true, federal: process.env.COUNTRY === "USA" ? false : true,
state: jobs_by_pk.state_tax_rate === 0 ? false : true, state: jobs_by_pk.state_tax_rate === 0 ? false : true,
}, },
bodyshop.md_responsibility_centers.sales_tax_codes bodyshop.md_responsibility_centers.sales_tax_codes
); );
const QboTaxId = taxCodes[taxAccountCode]; const QboTaxId =
process.env.COUNTRY === "USA"
? CheckQBOUSATaxID({
// jobline: jobline,
type: "adjustment",
job: jobs_by_pk,
})
: taxCodes[taxAccountCode];
InvoiceLineAdd.push({ InvoiceLineAdd.push({
DetailType: "SalesItemLineDetail", DetailType: "SalesItemLineDetail",
Amount: Dinero({ Amount: Dinero({
@@ -598,7 +643,7 @@ exports.default = function ({
findTaxCode( findTaxCode(
{ {
local: false, local: false,
federal: true, federal: process.env.COUNTRY === "USA" ? false : true,
state: false, state: false,
}, },
bodyshop.md_responsibility_centers.sales_tax_codes bodyshop.md_responsibility_centers.sales_tax_codes
@@ -622,29 +667,29 @@ exports.default = function ({
//QB USA with GST //QB USA with GST
//This was required for the No. 1 Collision Group. //This was required for the No. 1 Collision Group.
if ( // if (
bodyshop.accountingconfig && // bodyshop.accountingconfig &&
bodyshop.accountingconfig.qbo && // bodyshop.accountingconfig.qbo &&
bodyshop.accountingconfig.qbo_usa && // bodyshop.accountingconfig.qbo_usa &&
bodyshop.region_config.includes("CA_") // bodyshop.region_config.includes("CA_")
) { // ) {
InvoiceLineAdd.push({ // InvoiceLineAdd.push({
DetailType: "SalesItemLineDetail", // DetailType: "SalesItemLineDetail",
Amount: Dinero(jobs_by_pk.job_totals.totals.federal_tax).toFormat( // Amount: Dinero(jobs_by_pk.job_totals.totals.federal_tax).toFormat(
DineroQbFormat // DineroQbFormat
), // ),
SalesItemLineDetail: { // SalesItemLineDetail: {
...(jobs_by_pk.class // ...(jobs_by_pk.class
? { ClassRef: { value: classes[jobs_by_pk.class] } } // ? { ClassRef: { value: classes[jobs_by_pk.class] } }
: {}), // : {}),
ItemRef: { // ItemRef: {
value: // value:
items[bodyshop.md_responsibility_centers.taxes.federal.accountitem], // items[bodyshop.md_responsibility_centers.taxes.federal.accountitem],
}, // },
Qty: 1, // Qty: 1,
}, // },
}); // });
} // }
if (!qbo && InvoiceLineAdd.length === 0) { if (!qbo && InvoiceLineAdd.length === 0) {
//Handle the scenario where there is a $0 sale invoice. //Handle the scenario where there is a $0 sale invoice.
@@ -785,3 +830,19 @@ exports.createMultiQbPayerLines = function ({
return InvoiceLineAdd; return InvoiceLineAdd;
}; };
function CheckQBOUSATaxID({ jobline, job, type }) {
if (type === "labor") {
return jobline.lbr_tax ? "TAX" : "NON";
} else if (type === "part") {
return jobline.tax_part ? "TAX" : "NON";
} else if (type === "materials") {
return job.tax_paint_mat_rt > 0 ? "TAX" : "NON";
} else if (type === " towing") {
return true ? "TAX" : "NON";
} else if (type === "adjustment") {
return false ? "TAX" : "NON";
} else {
throw new Error(`Unknown type to calculate tax id: ${type} `);
}
}

View File

@@ -18,7 +18,6 @@ const {
const OAuthClient = require("intuit-oauth"); const OAuthClient = require("intuit-oauth");
const CreateInvoiceLines = require("../qb-receivables-lines").default; const CreateInvoiceLines = require("../qb-receivables-lines").default;
const moment = require("moment-timezone"); const moment = require("moment-timezone");
const GraphQLClient = require("graphql-request").GraphQLClient; const GraphQLClient = require("graphql-request").GraphQLClient;
const { generateOwnerTier } = require("../qbxml/qbxml-utils"); const { generateOwnerTier } = require("../qbxml/qbxml-utils");
const { createMultiQbPayerLines } = require("../qb-receivables-lines"); const { createMultiQbPayerLines } = require("../qb-receivables-lines");
@@ -635,8 +634,7 @@ async function InsertInvoice(
], ],
...(bodyshop.accountingconfig && ...(bodyshop.accountingconfig &&
bodyshop.accountingconfig.qbo && bodyshop.accountingconfig.qbo &&
bodyshop.accountingconfig.qbo_usa && bodyshop.accountingconfig.qbo_usa && {
bodyshop.region_config.includes("CA_") && {
TxnTaxDetail: { TxnTaxDetail: {
TxnTaxCodeRef: { TxnTaxCodeRef: {
value: value:

View File

@@ -124,9 +124,16 @@ const generateBillLine = (billLine, responsibilityCenters, jobClass) => {
.multiply(billLine.quantity || 1) .multiply(billLine.quantity || 1)
.toFormat(DineroQbFormat), .toFormat(DineroQbFormat),
...(jobClass ? { ClassRef: { FullName: jobClass } } : {}), ...(jobClass ? { ClassRef: { FullName: jobClass } } : {}),
SalesTaxCodeRef: { ...(process.env.COUNTRY !== "USA"
FullName: findTaxCode(billLine, responsibilityCenters.sales_tax_codes), ? {
}, SalesTaxCodeRef: {
FullName: findTaxCode(
billLine,
responsibilityCenters.sales_tax_codes
),
},
}
: {}),
}; };
}; };

View File

@@ -225,6 +225,8 @@ query QUERY_JOBS_FOR_RECEIVABLES_EXPORT($ids: [uuid!]!) {
adjustment_bottom_line adjustment_bottom_line
state_tax_rate state_tax_rate
qb_multiple_payers qb_multiple_payers
tax_paint_mat_rt
tax_lbr_rt
owner { owner {
accountingid accountingid
} }
@@ -243,6 +245,7 @@ query QUERY_JOBS_FOR_RECEIVABLES_EXPORT($ids: [uuid!]!) {
prt_dsmk_p prt_dsmk_p
prt_dsmk_m prt_dsmk_m
tax_part tax_part
lbr_tax
line_ref line_ref
unq_seq unq_seq
lbr_op lbr_op
@@ -1770,8 +1773,8 @@ exports.GET_JOB_FOR_PPC = `query GET_JOB_FOR_PPC($jobid: uuid!) {
timezone timezone
} }
} }
` `;
exports.QUERY_PARTS_SCAN = `query QUERY_PARTS_SCAN ($id: uuid!) { exports.QUERY_PARTS_SCAN = `query QUERY_PARTS_SCAN ($id: uuid!) {
jobs_by_pk(id: $id) { jobs_by_pk(id: $id) {
bodyshop { bodyshop {