From d07e424315a3a6e0f32cb2b7f278eadd9f5cc12e Mon Sep 17 00:00:00 2001 From: AbleKSaju <126228406+AbleKSaju@users.noreply.github.com> Date: Sat, 28 Dec 2024 11:55:49 +0530 Subject: [PATCH] feat: calculate total tax amount --- models/baseModels/Invoice/Invoice.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/models/baseModels/Invoice/Invoice.ts b/models/baseModels/Invoice/Invoice.ts index dd7be0b1..840fb283 100644 --- a/models/baseModels/Invoice/Invoice.ts +++ b/models/baseModels/Invoice/Invoice.ts @@ -395,6 +395,13 @@ export abstract class Invoice extends Transactional { return taxArr; } + async getTotalTax() { + const taxArr = await this.getTaxSummary(); + return taxArr + .map(({ amount }) => amount) + .reduce((a, b) => a.add(b), this.fyo.pesa(0)); + } + async getTax(tax: string) { if (!this._taxes[tax]) { this._taxes[tax] = await this.fyo.doc.getDoc('Tax', tax);