Added sales tax codes & resolved no tax codes on payables export IO-453
This commit is contained in:
@@ -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";
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user