Added sales tax codes & resolved no tax codes on payables export IO-453

This commit is contained in:
Patrick Fic
2021-02-16 21:04:14 -08:00
parent 3cfd8173a0
commit 01500e4c9c
6 changed files with 305 additions and 1 deletions

View File

@@ -91,6 +91,10 @@ const generateBill = (bill) => {
};
const generateBillLine = (billLine, responsibilityCenters) => {
console.log(
" findTaxCode(billLine, responsibilityCenters.sales_tax_codes)",
findTaxCode(billLine, responsibilityCenters.sales_tax_codes)
);
return {
AccountRef: {
FullName: responsibilityCenters.costs.find(
@@ -100,6 +104,9 @@ const generateBillLine = (billLine, responsibilityCenters) => {
Amount: Dinero({
amount: Math.round(billLine.actual_cost * 100),
}).toFormat(DineroQbFormat),
SalesTaxCodeRef: {
FullName: findTaxCode(billLine, responsibilityCenters.sales_tax_codes),
},
};
};
@@ -109,3 +116,20 @@ const generateBillLine = (billLine, responsibilityCenters) => {
// Amount: invoice.amount,
// },
// ],
const findTaxCode = (billLine, taxcode) => {
const {
applicable_taxes: { local, state, federal },
} = billLine;
const t = taxcode.filter(
(t) => t.local === local && t.state === state && t.federal === federal
);
if (t.length === 1) {
console.log(t);
return t[0].code;
} else if (t.length > 1) {
return "Multiple Tax Codes Match";
} else {
return "No Tax Code Matches";
}
};