RO into IO merge as of 02/05/2024.

This commit is contained in:
Patrick Fic
2024-02-12 12:22:05 -08:00
211 changed files with 31134 additions and 25729 deletions

View File

@@ -16,6 +16,7 @@ const CalculateAllocations =
const CdkBase = require("../../web-sockets/web-socket");
const moment = require("moment-timezone");
const Dinero = require("dinero.js");
const { default: InstanceManager } = require("../../utils/instanceMgr");
const axios = AxiosLib.create();
axios.interceptors.request.use((x) => {
@@ -660,7 +661,7 @@ async function InsertAccountPostingData(socket) {
.toISOString(), //"0001-01-01T00:00:00.0000000Z",
Description: socket.txEnvelope.story,
//AdditionalInfo: "String",
Source: "ImEX Online",
Source: InstanceManager({imex: "ImEX Online", rome:"Rome Online"}),
Lines: wips,
},
},

View File

@@ -3,6 +3,7 @@ const DineroQbFormat = require("./accounting-constants").DineroQbFormat;
const Dinero = require("dinero.js");
const {DiscountNotAlreadyCounted} = require("../job/job-totals");
const logger = require("../utils/logger");
const InstanceManager = require("../utils/instanceMgr");
exports.default = function ({
bodyshop,
@@ -34,12 +35,8 @@ exports.default = function ({
}
//Parts Lines Mappings.
if (jobline.profitcenter_part) {
let DineroAmount = Dinero({
amount: Math.round((jobline.act_price || 0) * 100),
}).multiply(jobline.part_qty || 1);
// console.log("Have a part discount", jobline);
DineroAmount = DineroAmount.add(
//TODO:AIO This appears to be a net 0 change exept for default quantity as 0 instead of 1 for imex. Need to verify.
const discountAmount =
((jobline.prt_dsmk_m && jobline.prt_dsmk_m !== 0) ||
(jobline.prt_dsmk_p && jobline.prt_dsmk_p !== 0)) &&
DiscountNotAlreadyCounted(jobline, jobs_by_pk.joblines)
@@ -51,8 +48,13 @@ exports.default = function ({
.multiply(jobline.part_qty || 0)
.percentage(Math.abs(jobline.prt_dsmk_p || 0))
.multiply(jobline.prt_dsmk_p > 0 ? 1 : -1)
: Dinero()
);
: Dinero();
let DineroAmount = Dinero({
amount: Math.round((jobline.act_price || 0) * 100),
})
.multiply(jobline.part_qty || 0)
.add(discountAmount);
const account = responsibilityCenters.profits.find(
(i) => jobline.profitcenter_part.toLowerCase() === i.name.toLowerCase()
@@ -78,7 +80,7 @@ exports.default = function ({
const taxAccountCode = findTaxCode(
{
local: false,
federal: true,
federal: InstanceManager({imex: true, rome: false}),
state:
jobs_by_pk.state_tax_rate === 0
? false
@@ -93,7 +95,11 @@ exports.default = function ({
bodyshop.md_responsibility_centers.sales_tax_codes
);
const QboTaxId = taxCodes[taxAccountCode];
const QboTaxId = InstanceManager({imex:taxCodes[taxAccountCode], rome: CheckQBOUSATaxID({
jobline: jobline,
type: "part",
job: jobs_by_pk,
}) })
if (!invoiceLineHash[account.name]) invoiceLineHash[account.name] = {};
if (!invoiceLineHash[account.name][QboTaxId]) {
invoiceLineHash[account.name][QboTaxId] = {
@@ -123,9 +129,15 @@ exports.default = function ({
Desc: account.accountdesc,
Quantity: 1, //jobline.part_qty,
Amount: DineroAmount, //.toFormat(DineroQbFormat),
SalesTaxCodeRef: {
SalesTaxCodeRef:
InstanceManager({imex: {
FullName: "E",
},
}, rome:{
FullName:
bodyshop.md_responsibility_centers.taxes.itemexemptcode ||
"NON",
} })
,
};
} else {
invoiceLineHash[account.name].Amount =
@@ -156,13 +168,13 @@ exports.default = function ({
const taxAccountCode = findTaxCode(
{
local: false,
federal: true,
federal: InstanceManager({imex: true, rome: false}),
state: jobs_by_pk.state_tax_rate === 0 ? false : true,
},
bodyshop.md_responsibility_centers.sales_tax_codes
);
const QboTaxId = taxCodes[taxAccountCode];
const QboTaxId = InstanceManager({imex: taxCodes[taxAccountCode], rome: CheckQBOUSATaxID({jobline: jobline, type: "labor"})})
if (!invoiceLineHash[account.name]) invoiceLineHash[account.name] = {};
if (!invoiceLineHash[account.name][QboTaxId]) {
invoiceLineHash[account.name][QboTaxId] = {
@@ -193,9 +205,18 @@ exports.default = function ({
Quantity: 1, // jobline.mod_lb_hrs,
Amount: DineroAmount,
//Amount: DineroAmount.toFormat(DineroQbFormat),
SalesTaxCodeRef: {
FullName: "E",
SalesTaxCodeRef:
InstanceManager({imex: {
FullName:"E"
},
rome: {
FullName:
bodyshop.md_responsibility_centers.taxes.itemexemptcode ||
"NON",
}
})
,
};
} else {
invoiceLineHash[account.name].Amount =
@@ -221,13 +242,17 @@ exports.default = function ({
const taxAccountCode = findTaxCode(
{
local: false,
federal: true,
federal: InstanceManager({imex: true, rome: false}),
state: jobs_by_pk.state_tax_rate === 0 ? false : true,
},
bodyshop.md_responsibility_centers.sales_tax_codes
);
const QboTaxId = taxCodes[taxAccountCode];
const QboTaxId = InstanceManager({imex:taxCodes[taxAccountCode] , rome: CheckQBOUSATaxID({
// jobline: jobline,
job: jobs_by_pk,
type: "materials",
})});
if (!invoiceLineHash[mapaAccount.name])
invoiceLineHash[mapaAccount.name] = {};
if (!invoiceLineHash[mapaAccount.name][QboTaxId]) {
@@ -262,9 +287,16 @@ exports.default = function ({
Amount: Dinero(jobs_by_pk.job_totals.rates.mapa.total).toFormat(
DineroQbFormat
),
SalesTaxCodeRef: {
SalesTaxCodeRef:
InstanceManager({imex: {
FullName: "E",
},
rome: {
FullName:
bodyshop.md_responsibility_centers.taxes.itemexemptcode || "NON",
}
})
,
});
}
} else {
@@ -287,13 +319,17 @@ exports.default = function ({
const taxAccountCode = findTaxCode(
{
local: false,
federal: true,
federal: InstanceManager({imex: true, rome: false}),
state: jobs_by_pk.state_tax_rate === 0 ? false : true,
},
bodyshop.md_responsibility_centers.sales_tax_codes
);
const QboTaxId = taxCodes[taxAccountCode];
const QboTaxId = InstanceManager({imex:taxCodes[taxAccountCode], rome: CheckQBOUSATaxID({
// jobline: jobline,
job: jobs_by_pk,
type: "materials",
})});
if (!invoiceLineHash[mashAccount.name])
invoiceLineHash[mashAccount.name] = {};
if (!invoiceLineHash[mashAccount.name][QboTaxId]) {
@@ -328,9 +364,17 @@ exports.default = function ({
Amount: Dinero(jobs_by_pk.job_totals.rates.mash.total).toFormat(
DineroQbFormat
),
SalesTaxCodeRef: {
FullName: "E",
},
SalesTaxCodeRef:
InstanceManager({imex:
{
FullName: "E",
},
rome: {
FullName:
bodyshop.md_responsibility_centers.taxes.itemexemptcode || "NON",
}
})
,
});
}
} else {
@@ -363,13 +407,14 @@ exports.default = function ({
//Add Towing, storage and adjustment lines.
if (jobs_by_pk.towing_payable && jobs_by_pk.towing_payable !== 0) {
///TODO:AIO Check if this towing check works for imex and not just Rome.
if (jobs_by_pk.job_totals.additional.towing.amount > 0) {
if (qbo) {
//Going to always assume that we need to apply GST and PST for labor.
const taxAccountCode = findTaxCode(
{
local: false,
federal: true,
federal: InstanceManager({imex:true, rome:false}) ,
state: jobs_by_pk.state_tax_rate === 0 ? false : true,
},
bodyshop.md_responsibility_centers.sales_tax_codes
@@ -377,12 +422,18 @@ exports.default = function ({
const account = responsibilityCenters.profits.find(
(c) => c.name === responsibilityCenters.defaults.profits["TOW"]
);
const QboTaxId = taxCodes[taxAccountCode];
const QboTaxId = InstanceManager({imex:taxCodes[taxAccountCode], rome: CheckQBOUSATaxID({
// jobline: jobline,
job: jobs_by_pk,
type: "towing",
}) })
InvoiceLineAdd.push({
DetailType: "SalesItemLineDetail",
Amount: Dinero({
amount: Math.round((jobs_by_pk.towing_payable || 0) * 100),
}).toFormat(DineroQbFormat),
///TODO:AIO Check if this towing check works for imex and not just Rome.
Amount: Dinero(jobs_by_pk.job_totals.additional.towing).toFormat(
DineroQbFormat
),
SalesItemLineDetail: {
...(jobs_by_pk.class
? {ClassRef: {value: classes[jobs_by_pk.class]}}
@@ -405,22 +456,29 @@ exports.default = function ({
},
Desc: "Towing",
Quantity: 1,
Amount: Dinero({
amount: Math.round((jobs_by_pk.towing_payable || 0) * 100),
}).toFormat(DineroQbFormat),
SalesTaxCodeRef: {
///TODO:AIO Check if this towing check works for imex and not just Rome.
Amount: Dinero(jobs_by_pk.job_totals.additional.towing).toFormat(
DineroQbFormat
),
SalesTaxCodeRef:
InstanceManager({imex: {
FullName: "E",
},
rome: {
FullName:
bodyshop.md_responsibility_centers.taxes.itemexemptcode || "NON",
}}),
});
}
}
if (jobs_by_pk.storage_payable && jobs_by_pk.storage_payable !== 0) {
///TODO:AIO Check if this storage check works for imex and not just Rome.
if (jobs_by_pk.job_totals.additional.storage.amount > 0) {
if (qbo) {
//Going to always assume that we need to apply GST and PST for labor.
const taxAccountCode = findTaxCode(
{
local: false,
federal: true,
federal: InstanceManager({imex: true, rome:false }) ,
state: jobs_by_pk.state_tax_rate === 0 ? false : true,
},
bodyshop.md_responsibility_centers.sales_tax_codes
@@ -428,12 +486,18 @@ exports.default = function ({
const account = responsibilityCenters.profits.find(
(c) => c.name === responsibilityCenters.defaults.profits["TOW"]
);
const QboTaxId = taxCodes[taxAccountCode];
const QboTaxId = InstanceManager({imex:taxCodes[taxAccountCode], rome: CheckQBOUSATaxID({
// jobline: jobline,
job: jobs_by_pk,
type: "storage",
}) })
InvoiceLineAdd.push({
DetailType: "SalesItemLineDetail",
Amount: Dinero({
amount: Math.round((jobs_by_pk.storage_payable || 0) * 100),
}).toFormat(DineroQbFormat),
///TODO:AIO Check if this storage check works for imex and not just Rome.
Amount: Dinero(
jobs_by_pk.job_totals.additional.storage.amount
).toFormat(DineroQbFormat),
SalesItemLineDetail: {
...(jobs_by_pk.class
? {ClassRef: {value: classes[jobs_by_pk.class]}}
@@ -456,12 +520,19 @@ exports.default = function ({
},
Desc: "Storage",
Quantity: 1,
Amount: Dinero({
amount: Math.round((jobs_by_pk.storage_payable || 0) * 100),
}).toFormat(DineroQbFormat),
SalesTaxCodeRef: {
///TODO:AIO Check if this storage check works for imex and not just Rome.
Amount: Dinero(
jobs_by_pk.job_totals.additional.storage.amount
).toFormat(DineroQbFormat),
SalesTaxCodeRef:
InstanceManager({imex:{
FullName: "E",
},
}, rome: {
FullName:
bodyshop.md_responsibility_centers.taxes.itemexemptcode || "NON",
} })
,
});
}
}
@@ -474,13 +545,18 @@ exports.default = function ({
const taxAccountCode = findTaxCode(
{
local: false,
federal: true,
federal: InstanceManager({imex: true, rome: false}) ,
state: jobs_by_pk.state_tax_rate === 0 ? false : true,
},
bodyshop.md_responsibility_centers.sales_tax_codes
);
const QboTaxId = taxCodes[taxAccountCode];
const QboTaxId = InstanceManager({imex: taxCodes[taxAccountCode], rome: CheckQBOUSATaxID({
// jobline: jobline,
type: "adjustment",
job: jobs_by_pk,
})})
InvoiceLineAdd.push({
DetailType: "SalesItemLineDetail",
Amount: Dinero({
@@ -509,109 +585,118 @@ exports.default = function ({
Amount: Dinero({
amount: Math.round((jobs_by_pk.adjustment_bottom_line || 0) * 100),
}).toFormat(DineroQbFormat),
SalesTaxCodeRef: {
SalesTaxCodeRef:
InstanceManager({imex:{
FullName: "E",
},
rome: {
FullName:
bodyshop.md_responsibility_centers.taxes.itemexemptcode || "NON",
}
})
,
});
}
}
//Add tax lines
const job_totals = jobs_by_pk.job_totals;
const federal_tax = Dinero(job_totals.totals.federal_tax);
const state_tax = Dinero(job_totals.totals.state_tax);
const local_tax = Dinero(job_totals.totals.local_tax);
if (federal_tax.getAmount() > 0) {
if (qbo) {
// do qbo
} else {
InvoiceLineAdd.push({
ItemRef: {
FullName:
bodyshop.md_responsibility_centers.taxes.federal.accountitem,
},
Desc: bodyshop.md_responsibility_centers.taxes.federal.accountdesc,
Amount: federal_tax.toFormat(DineroQbFormat),
});
}
}
const RulesetToUse = InstanceManager({imex:"CANADA",rome: "US"})
if (state_tax.getAmount() > 0) {
if (qbo) {
// do qbo
} else {
InvoiceLineAdd.push({
ItemRef: {
FullName: bodyshop.md_responsibility_centers.taxes.state.accountitem,
},
Desc: bodyshop.md_responsibility_centers.taxes.state.accountdesc,
Amount: state_tax.toFormat(DineroQbFormat),
});
}
}
if (local_tax.getAmount() > 0) {
if (qbo) {
// do qbo
} else {
InvoiceLineAdd.push({
ItemRef: {
FullName: bodyshop.md_responsibility_centers.taxes.local.accountitem,
},
Desc: bodyshop.md_responsibility_centers.taxes.local.accountdesc,
Amount: local_tax.toFormat(DineroQbFormat),
});
}
}
//Region Specific
const {ca_bc_pvrt} = jobs_by_pk;
if (ca_bc_pvrt) {
if (qbo) {
InvoiceLineAdd.push({
DetailType: "SalesItemLineDetail",
Amount: Dinero({amount: (ca_bc_pvrt || 0) * 100}).toFormat(
DineroQbFormat
),
SalesItemLineDetail: {
...(jobs_by_pk.class
? {ClassRef: {value: classes[jobs_by_pk.class]}}
: {}),
if(RulesetToUse = "CANADA"){
if (federal_tax.getAmount() > 0) {
if (qbo) {
// do qbo
} else {
InvoiceLineAdd.push({
ItemRef: {
value: items["PVRT"],
FullName:
bodyshop.md_responsibility_centers.taxes.federal.accountitem,
},
Qty: 1,
TaxCodeRef: {
value:
taxCodes[
findTaxCode(
{
local: false,
federal: true,
state: false,
},
bodyshop.md_responsibility_centers.sales_tax_codes
)
],
},
},
});
} else {
InvoiceLineAdd.push({
ItemRef: {
FullName: bodyshop.md_responsibility_centers.taxes.state.accountitem,
},
Desc: "PVRT",
Amount: Dinero({amount: (ca_bc_pvrt || 0) * 100}).toFormat(
DineroQbFormat
),
});
Desc: bodyshop.md_responsibility_centers.taxes.federal.accountdesc,
Amount: federal_tax.toFormat(DineroQbFormat),
});
}
}
}
//QB USA with GST
if (state_tax.getAmount() > 0) {
if (qbo) {
// do qbo
} else {
InvoiceLineAdd.push({
ItemRef: {
FullName: bodyshop.md_responsibility_centers.taxes.state.accountitem,
},
Desc: bodyshop.md_responsibility_centers.taxes.state.accountdesc,
Amount: state_tax.toFormat(DineroQbFormat),
});
}
}
if (local_tax.getAmount() > 0) {
if (qbo) {
// do qbo
} else {
InvoiceLineAdd.push({
ItemRef: {
FullName: bodyshop.md_responsibility_centers.taxes.local.accountitem,
},
Desc: bodyshop.md_responsibility_centers.taxes.local.accountdesc,
Amount: local_tax.toFormat(DineroQbFormat),
});
}
}
//Region Specific
const {ca_bc_pvrt} = jobs_by_pk;
if (ca_bc_pvrt) {
if (qbo) {
InvoiceLineAdd.push({
DetailType: "SalesItemLineDetail",
Amount: Dinero({amount: (ca_bc_pvrt || 0) * 100}).toFormat(
DineroQbFormat
),
SalesItemLineDetail: {
...(jobs_by_pk.class
? {ClassRef: {value: classes[jobs_by_pk.class]}}
: {}),
ItemRef: {
value: items["PVRT"],
},
Qty: 1,
TaxCodeRef: {
value:
taxCodes[
findTaxCode(
{
local: false,
federal: true,
state: false,
},
bodyshop.md_responsibility_centers.sales_tax_codes
)
],
},
},
});
} else {
InvoiceLineAdd.push({
ItemRef: {
FullName: bodyshop.md_responsibility_centers.taxes.state.accountitem,
},
Desc: "PVRT",
Amount: Dinero({amount: (ca_bc_pvrt || 0) * 100}).toFormat(
DineroQbFormat
),
});
}
}
//QB USA with GST
//This was required for the No. 1 Collision Group.
if (
bodyshop.accountingconfig &&
@@ -636,6 +721,120 @@ exports.default = function ({
},
});
}
}
else{
//Handle insurance profile adjustments
Object.keys(job_totals.parts.adjustments).forEach((key) => {
if (qbo) {
//Going to always assume that we need to apply GST and PST for labor.
const taxAccountCode = findTaxCode(
{
local: false,
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 account = responsibilityCenters.profits.find(
(c) => c.name === responsibilityCenters.defaults.profits[key]
);
const QboTaxId =
process.env.COUNTRY === "USA"
? CheckQBOUSATaxID({
// jobline: jobline,
job: jobs_by_pk,
type: "storage",
})
: taxCodes[taxAccountCode];
InvoiceLineAdd.push({
DetailType: "SalesItemLineDetail",
Amount: Dinero(job_totals.parts.adjustments[key]).toFormat(
DineroQbFormat
),
Description: `${account.accountdesc} - Adjustment`,
SalesItemLineDetail: {
...(jobs_by_pk.class
? {ClassRef: {value: classes[jobs_by_pk.class]}}
: {}),
ItemRef: {
value: items[account.accountitem],
},
TaxCodeRef: {
value: QboTaxId,
},
Qty: 1,
},
});
} else {
InvoiceLineAdd.push({
ItemRef: {
FullName: responsibilityCenters.profits.find(
(c) => c.name === responsibilityCenters.defaults.profits[key]
).accountitem,
},
Desc: "Storage",
Quantity: 1,
Amount: Dinero(job_totals.parts.adjustments[key]).toFormat(
DineroQbFormat
),
SalesTaxCodeRef: {
FullName:
bodyshop.md_responsibility_centers.taxes.itemexemptcode || "NON",
},
});
}
});
const QboTaxId =
process.env.COUNTRY === "USA"
? CheckQBOUSATaxID({
// jobline: jobline,
type: "adjustment",
job: jobs_by_pk,
})
: taxCodes[taxAccountCode];
for (let tyCounter = 1; tyCounter <= 5; tyCounter++) {
const taxAmount = Dinero(
job_totals.totals.us_sales_tax_breakdown[`ty${tyCounter}Tax`]
);
console.log(`Tax ${tyCounter}`, taxAmount.toFormat());
if (taxAmount.getAmount() > 0) {
if (qbo) {
InvoiceLineAdd.push({
DetailType: "SalesItemLineDetail",
Amount: taxAmount.toFormat(DineroQbFormat),
SalesItemLineDetail: {
...(jobs_by_pk.class
? {ClassRef: {value: classes[jobs_by_pk.class]}}
: {}),
ItemRef: {
value:
items[
responsibilityCenters.taxes[`tax_ty${tyCounter}`].accountitem
],
},
TaxCodeRef: {
value: QboTaxId,
},
Qty: 1,
},
});
} else {
InvoiceLineAdd.push({
ItemRef: {
FullName:
bodyshop.md_responsibility_centers.taxes[`tax_ty${tyCounter}`]
.accountitem,
},
Desc: bodyshop.md_responsibility_centers.taxes[`tax_ty${tyCounter}`]
.accountdesc,
Amount: taxAmount.toFormat(DineroQbFormat),
});
}
}
}
}
if (!qbo && InvoiceLineAdd.length === 0) {
//Handle the scenario where there is a $0 sale invoice.
@@ -767,11 +966,34 @@ exports.createMultiQbPayerLines = function ({
Amount: Dinero({
amount: Math.round((payer.amount || 0) * 100),
}).toFormat(DineroQbFormat),
SalesTaxCodeRef: {
SalesTaxCodeRef:
InstanceManager({imex: {
FullName: "E",
},
}, rome:{
FullName:
bodyshop.md_responsibility_centers.taxes.itemexemptcode || "NON",
} })
});
}
return InvoiceLineAdd;
};
function CheckQBOUSATaxID({jobline, job, type}) {
//Replacing this to be all non-taxable items with the refactor of parts tax rates.
return "NON";
// 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

@@ -10,6 +10,7 @@ const OAuthClient = require("intuit-oauth");
const client = require("../../graphql-client/graphql-client").client;
const queries = require("../../graphql-client/queries");
const {parse, stringify} = require("querystring");
const InstanceManager = require("../../utils/instanceMgr");
const oauthClient = new OAuthClient({
clientId: process.env.QBO_CLIENT_ID,
@@ -21,10 +22,10 @@ const oauthClient = new OAuthClient({
let url;
if (process.env.NODE_ENV === "production") {
url = `https://imex.online`;
if (process.env.NODE_ENV === "production") { //TODO:AIO Add in QBO callbacks.
url = InstanceManager({imex: `https://imex.online`, rome: `https://romeonline.io`,});
} else if (process.env.NODE_ENV === "test") {
url = `https://test.imex.online`;
url = InstanceManager({imex: `https://test.imex.online`,rome: `https://test.romeonline.io`});
} else {
url = `http://localhost:3000`;
}

View File

@@ -18,6 +18,7 @@ const {
const OAuthClient = require("intuit-oauth");
const CreateInvoiceLines = require("../qb-receivables-lines").default;
const moment = require("moment-timezone");
const GraphQLClient = require("graphql-request").GraphQLClient;
const {generateOwnerTier} = require("../qbxml/qbxml-utils");
const {createMultiQbPayerLines} = require("../qb-receivables-lines");
@@ -240,6 +241,11 @@ exports.default = async (req, res) => {
(error && error.authResponse && error.authResponse.body) ||
(error && error.message),
});
console.log(error);
logger.log("qbo-receivable-create-error", "ERROR", req.user.email, {
error: error.message,
stack: error.stack,
});
//Add the export log error.
if (elgen) {
const result = await client
@@ -642,8 +648,7 @@ async function InsertInvoice(
],
...(bodyshop.accountingconfig &&
bodyshop.accountingconfig.qbo &&
bodyshop.accountingconfig.qbo_usa &&
bodyshop.region_config.includes("CA_") && {
bodyshop.accountingconfig.qbo_usa && {
TxnTaxDetail: {
TxnTaxCodeRef: {
value:

View File

@@ -7,6 +7,7 @@ const builder = require("xmlbuilder2");
const QbXmlUtils = require("./qbxml-utils");
const moment = require("moment-timezone");
const logger = require('../../utils/logger');
const InstanceManager = require("../../utils/instanceMgr");
require("dotenv").config({
path: path.resolve(
@@ -121,9 +122,14 @@ const generateBillLine = (billLine, responsibilityCenters, jobClass) => {
.multiply(billLine.quantity || 1)
.toFormat(DineroQbFormat),
...(jobClass ? {ClassRef: {FullName: jobClass}} : {}),
SalesTaxCodeRef: {
FullName: findTaxCode(billLine, responsibilityCenters.sales_tax_codes),
},
...InstanceManager({imex:{
SalesTaxCodeRef: {
FullName: findTaxCode(
billLine,
responsibilityCenters.sales_tax_codes
),
},
} })
};
};

View File

@@ -7,6 +7,7 @@ const builder = require("xmlbuilder2");
const QbXmlUtils = require("./qbxml-utils");
const CreateInvoiceLines = require("../qb-receivables-lines").default;
const logger = require('../../utils/logger');
const InstanceManager = require('../../utils/instanceMgr');
require("dotenv").config({
path: path.resolve(
@@ -280,6 +281,12 @@ const generateInvoiceQbxml = (
PostalCode: jobs_by_pk.ownr_zip,
},
PONumber: jobs_by_pk.clm_no,
...InstanceManager({rome: {
ItemSalesTaxRef: {
FullName:
bodyshop.md_responsibility_centers.taxes.invoiceexemptcode,
},
}}),
IsToBePrinted: bodyshop.accountingconfig.printlater,
...(jobs_by_pk.ownr_ea
? {IsToBeEmailed: bodyshop.accountingconfig.emaillater}