feat: implement discount display in various detail drawers

- Added discount amount and percentage display in Bill, Credit Note, Estimate, Invoice, Receipt, and Vendor Credit detail tables.
- Updated models to include discount-related attributes for better data handling.
- Enhanced user interface to show discount information when applicable, improving clarity in financial documents.
This commit is contained in:
Ahmed Bouhuolia
2024-11-30 16:01:29 +02:00
parent dd1392cdc8
commit 73ab92e693
8 changed files with 91 additions and 13 deletions

View File

@@ -53,6 +53,10 @@ export default class Bill extends mixin(TenantModel, [
'localAllocatedCostAmount',
'billableAmount',
'amountLocal',
'discountAmount',
'discountPercentage',
'subtotal',
'subtotalLocal',
'subtotalExludingTax',

View File

@@ -26,14 +26,6 @@ export default class VendorCredit extends mixin(TenantModel, [
static get tableName() {
return 'vendor_credits';
}
/**
* Virtual attributes.
*/
static get virtualAttributes() {
return ['localAmount'];
}
/**
* Vendor credit amount in local currency.
* @returns {number}
@@ -81,9 +73,10 @@ export default class VendorCredit extends mixin(TenantModel, [
* @returns {number}
*/
get total() {
const discountAmount = this.discountType === DiscountType.Amount
? this.discount
: this.subtotal * (this.discount / 100);
const discountAmount =
this.discountType === DiscountType.Amount
? this.discount
: this.subtotal * (this.discount / 100);
return this.subtotal - discountAmount - this.adjustment;
}
@@ -182,7 +175,21 @@ export default class VendorCredit extends mixin(TenantModel, [
* Virtual attributes.
*/
static get virtualAttributes() {
return ['isDraft', 'isPublished', 'isOpen', 'isClosed', 'creditsRemaining'];
return [
'isDraft',
'isPublished',
'isOpen',
'isClosed',
'creditsRemaining',
'localAmount',
'discountAmount',
'discountPercentage',
'total',
'totalLocal',
];
}
/**