feat: add local discount and adjustment calculations to financial models and transformers

- Introduced `discountAmountLocal` and `adjustmentLocal` properties across Bill, CreditNote, SaleInvoice, SaleReceipt, and VendorCredit models to calculate amounts in local currency.
- Updated transformers for CreditNote, PurchaseInvoice, and VendorCredit to include formatted representations of local discount and adjustment amounts.
- Enhanced GL entry services to handle discount and adjustment entries for SaleReceipt and CreditNote, ensuring accurate ledger entries.
- Improved overall consistency in handling financial calculations across various models and services.
This commit is contained in:
Ahmed Bouhuolia
2024-12-08 18:11:03 +02:00
parent 0a5115fc20
commit 994c441bb8
11 changed files with 351 additions and 30 deletions

View File

@@ -53,6 +53,7 @@ export default class SaleReceipt extends mixin(TenantModel, [
'adjustmentLocal',
'discountAmount',
'discountAmountLocal',
'discountPercentage',
'paid',
@@ -97,14 +98,20 @@ export default class SaleReceipt extends mixin(TenantModel, [
: this.subtotal * (this.discount / 100);
}
/**
* Discount amount in local currency.
* @returns {number | null}
*/
get discountAmountLocal() {
return this.discountAmount ? this.discountAmount * this.exchangeRate : null;
}
/**
* Discount percentage.
* @returns {number | null}
*/
get discountPercentage(): number | null {
return this.discountType === DiscountType.Percentage
? this.discount
: null;
return this.discountType === DiscountType.Percentage ? this.discount : null;
}
/**