Updates to QuickBooks and DMS export.
This commit is contained in:
@@ -574,123 +574,54 @@ exports.default = function ({
|
||||
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),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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] } }
|
||||
: {}),
|
||||
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`]
|
||||
);
|
||||
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: {
|
||||
value: items["PVRT"],
|
||||
FullName:
|
||||
bodyshop.md_responsibility_centers.taxes[`tax_ty${tyCounter}`]
|
||||
.accountitem,
|
||||
},
|
||||
Qty: 1,
|
||||
TaxCodeRef: {
|
||||
value:
|
||||
taxCodes[
|
||||
findTaxCode(
|
||||
{
|
||||
local: false,
|
||||
federal: process.env.COUNTRY === "USA" ? false : 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[`tax_ty${tyCounter}`]
|
||||
.accountdesc,
|
||||
Amount: taxAmount.toFormat(DineroQbFormat),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//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 (!qbo && InvoiceLineAdd.length === 0) {
|
||||
//Handle the scenario where there is a $0 sale invoice.
|
||||
InvoiceLineAdd.push({
|
||||
@@ -832,17 +763,19 @@ exports.createMultiQbPayerLines = function ({
|
||||
};
|
||||
|
||||
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} `);
|
||||
}
|
||||
//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} `);
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user