QBO USA Changes for tax and non tax items.
This commit is contained in:
@@ -78,7 +78,7 @@ exports.default = function ({
|
||||
const taxAccountCode = findTaxCode(
|
||||
{
|
||||
local: false,
|
||||
federal: true,
|
||||
federal: process.env.COUNTRY === "USA" ? false : true,
|
||||
state:
|
||||
jobs_by_pk.state_tax_rate === 0
|
||||
? false
|
||||
@@ -93,7 +93,14 @@ exports.default = function ({
|
||||
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][QboTaxId]) {
|
||||
invoiceLineHash[account.name][QboTaxId] = {
|
||||
@@ -158,13 +165,16 @@ exports.default = function ({
|
||||
const taxAccountCode = findTaxCode(
|
||||
{
|
||||
local: false,
|
||||
federal: true,
|
||||
federal: process.env.COUNTRY === "USA" ? false : true,
|
||||
state: jobs_by_pk.state_tax_rate === 0 ? false : true,
|
||||
},
|
||||
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][QboTaxId]) {
|
||||
invoiceLineHash[account.name][QboTaxId] = {
|
||||
@@ -225,13 +235,20 @@ exports.default = function ({
|
||||
const taxAccountCode = findTaxCode(
|
||||
{
|
||||
local: false,
|
||||
federal: true,
|
||||
federal: process.env.COUNTRY === "USA" ? false : true,
|
||||
state: jobs_by_pk.state_tax_rate === 0 ? false : true,
|
||||
},
|
||||
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])
|
||||
invoiceLineHash[mapaAccount.name] = {};
|
||||
if (!invoiceLineHash[mapaAccount.name][QboTaxId]) {
|
||||
@@ -292,13 +309,20 @@ exports.default = function ({
|
||||
const taxAccountCode = findTaxCode(
|
||||
{
|
||||
local: false,
|
||||
federal: true,
|
||||
federal: process.env.COUNTRY === "USA" ? false : true,
|
||||
state: jobs_by_pk.state_tax_rate === 0 ? false : true,
|
||||
},
|
||||
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])
|
||||
invoiceLineHash[mashAccount.name] = {};
|
||||
if (!invoiceLineHash[mashAccount.name][QboTaxId]) {
|
||||
@@ -375,7 +399,7 @@ exports.default = function ({
|
||||
const taxAccountCode = findTaxCode(
|
||||
{
|
||||
local: false,
|
||||
federal: true,
|
||||
federal: process.env.COUNTRY === "USA" ? false : true,
|
||||
state: jobs_by_pk.state_tax_rate === 0 ? false : true,
|
||||
},
|
||||
bodyshop.md_responsibility_centers.sales_tax_codes
|
||||
@@ -383,7 +407,14 @@ exports.default = function ({
|
||||
const account = responsibilityCenters.profits.find(
|
||||
(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({
|
||||
DetailType: "SalesItemLineDetail",
|
||||
Amount: Dinero({
|
||||
@@ -427,7 +458,7 @@ exports.default = function ({
|
||||
const taxAccountCode = findTaxCode(
|
||||
{
|
||||
local: false,
|
||||
federal: true,
|
||||
federal: process.env.COUNTRY === "USA" ? false : true,
|
||||
state: jobs_by_pk.state_tax_rate === 0 ? false : true,
|
||||
},
|
||||
bodyshop.md_responsibility_centers.sales_tax_codes
|
||||
@@ -435,7 +466,14 @@ exports.default = function ({
|
||||
const account = responsibilityCenters.profits.find(
|
||||
(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({
|
||||
DetailType: "SalesItemLineDetail",
|
||||
Amount: Dinero({
|
||||
@@ -482,13 +520,20 @@ exports.default = function ({
|
||||
const taxAccountCode = findTaxCode(
|
||||
{
|
||||
local: false,
|
||||
federal: true,
|
||||
federal: process.env.COUNTRY === "USA" ? false : true,
|
||||
state: jobs_by_pk.state_tax_rate === 0 ? false : true,
|
||||
},
|
||||
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({
|
||||
DetailType: "SalesItemLineDetail",
|
||||
Amount: Dinero({
|
||||
@@ -598,7 +643,7 @@ exports.default = function ({
|
||||
findTaxCode(
|
||||
{
|
||||
local: false,
|
||||
federal: true,
|
||||
federal: process.env.COUNTRY === "USA" ? false : true,
|
||||
state: false,
|
||||
},
|
||||
bodyshop.md_responsibility_centers.sales_tax_codes
|
||||
@@ -622,29 +667,29 @@ exports.default = function ({
|
||||
|
||||
//QB USA with GST
|
||||
//This was required for the No. 1 Collision Group.
|
||||
if (
|
||||
bodyshop.accountingconfig &&
|
||||
bodyshop.accountingconfig.qbo &&
|
||||
bodyshop.accountingconfig.qbo_usa &&
|
||||
bodyshop.region_config.includes("CA_")
|
||||
) {
|
||||
InvoiceLineAdd.push({
|
||||
DetailType: "SalesItemLineDetail",
|
||||
Amount: Dinero(jobs_by_pk.job_totals.totals.federal_tax).toFormat(
|
||||
DineroQbFormat
|
||||
),
|
||||
SalesItemLineDetail: {
|
||||
...(jobs_by_pk.class
|
||||
? { ClassRef: { value: classes[jobs_by_pk.class] } }
|
||||
: {}),
|
||||
ItemRef: {
|
||||
value:
|
||||
items[bodyshop.md_responsibility_centers.taxes.federal.accountitem],
|
||||
},
|
||||
Qty: 1,
|
||||
},
|
||||
});
|
||||
}
|
||||
// if (
|
||||
// bodyshop.accountingconfig &&
|
||||
// bodyshop.accountingconfig.qbo &&
|
||||
// bodyshop.accountingconfig.qbo_usa &&
|
||||
// bodyshop.region_config.includes("CA_")
|
||||
// ) {
|
||||
// InvoiceLineAdd.push({
|
||||
// DetailType: "SalesItemLineDetail",
|
||||
// Amount: Dinero(jobs_by_pk.job_totals.totals.federal_tax).toFormat(
|
||||
// DineroQbFormat
|
||||
// ),
|
||||
// SalesItemLineDetail: {
|
||||
// ...(jobs_by_pk.class
|
||||
// ? { ClassRef: { value: classes[jobs_by_pk.class] } }
|
||||
// : {}),
|
||||
// ItemRef: {
|
||||
// value:
|
||||
// items[bodyshop.md_responsibility_centers.taxes.federal.accountitem],
|
||||
// },
|
||||
// Qty: 1,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
if (!qbo && InvoiceLineAdd.length === 0) {
|
||||
//Handle the scenario where there is a $0 sale invoice.
|
||||
@@ -785,3 +830,19 @@ exports.createMultiQbPayerLines = function ({
|
||||
|
||||
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} `);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user