Added GST registrant BOD-389
This commit is contained in:
@@ -11,9 +11,9 @@ exports.default = async function (req, res) {
|
||||
parts: CalculatePartsTotals(job.joblines),
|
||||
rates: CalculateRatesTotals(job),
|
||||
additional: CalculateAdditional(job),
|
||||
custPayable: CalculateCustPayable(job),
|
||||
};
|
||||
ret.totals = CalculateTaxesTotals(job, ret);
|
||||
|
||||
// console.log("CalculateJob -> Final", ret);
|
||||
res.status(200).json(ret);
|
||||
} catch (error) {
|
||||
@@ -49,8 +49,7 @@ function CalculateAdditional(job) {
|
||||
}
|
||||
|
||||
function CalculateTaxesTotals(job, otherTotals) {
|
||||
const theObj = JSON.parse(JSON.stringify(otherTotals));
|
||||
|
||||
//const theObj = JSON.parse(JSON.stringify(otherTotals));
|
||||
const subtotal = otherTotals.parts.parts.subtotal
|
||||
.add(otherTotals.parts.sublets.subtotal)
|
||||
.add(otherTotals.rates.rates_subtotal)
|
||||
@@ -116,7 +115,22 @@ function CalculateTaxesTotals(job, otherTotals) {
|
||||
.add(ret.federal_tax)
|
||||
.add(ret.state_tax)
|
||||
.add(ret.local_tax);
|
||||
ret.net_repairs = ret.total_repairs.subtract(otherTotals.custPayable.total);
|
||||
|
||||
ret.custPayable = {
|
||||
deductible: Dinero({ amount: (job.ded_amt || 0) * 100 }) || 0,
|
||||
federal_tax: job.ca_gst_registrant ? ret.federal_tax : Dinero(),
|
||||
other_customer_amount: Dinero({
|
||||
amount: (job.other_amount_payable || 0) * 100,
|
||||
}),
|
||||
dep_taxes: Dinero({ amount: job.depreciation_taxes || 0 }),
|
||||
};
|
||||
|
||||
ret.custPayable.total = ret.custPayable.deductible
|
||||
.add(ret.custPayable.federal_tax)
|
||||
.add(ret.custPayable.other_customer_amount)
|
||||
.add(ret.custPayable.dep_taxes);
|
||||
|
||||
ret.net_repairs = ret.total_repairs.subtract(ret.custPayable.total);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -325,22 +339,3 @@ function CalculatePartsTotals(jobLines) {
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function CalculateCustPayable(job) {
|
||||
let ret = {
|
||||
deductible: Dinero({ amount: (job.ded_amt || 0) * 100 }) || 0,
|
||||
federal_tax: Dinero({ amount: (job.federal_tax_payable || 0) * 100 }), //TODO Should this be renamed to make it more clear this is customer GST?
|
||||
other_customer_amount: Dinero({
|
||||
amount: (job.other_amount_payable || 0) * 100,
|
||||
}),
|
||||
dep_taxes: Dinero({ amount: job.depreciation_taxes || 0 }),
|
||||
};
|
||||
|
||||
ret.total = ret.deductible
|
||||
.add(ret.federal_tax)
|
||||
.add(ret.federal_tax)
|
||||
.add(ret.other_customer_amount)
|
||||
.add(ret.dep_taxes);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user