feat: discount formatted attributes of sale transactions

This commit is contained in:
Ahmed Bouhuolia
2024-11-28 17:59:09 +02:00
parent df8391201f
commit e02ad1e795
12 changed files with 246 additions and 25 deletions

View File

@@ -72,16 +72,32 @@ export default class CreditNote extends mixin(TenantModel, [
return this.subtotal * this.exchangeRate;
}
/**
* Discount amount.
* @returns {number}
*/
get discountAmount() {
return this.discountType === DiscountType.Amount
? this.discount
: this.subtotal * (this.discount / 100);
}
/**
* Discount percentage.
* @returns {number | null}
*/
get discountPercentage(): number | null {
return this.discountType === DiscountType.Percentage
? this.discount
: null;
}
/**
* Credit note total.
* @returns {number}
*/
get total() {
const discountAmount = this.discountType === DiscountType.Amount
? this.discount
: this.subtotal * (this.discount / 100);
return this.subtotal - discountAmount - this.adjustment;
return this.subtotal - this.discountAmount - this.adjustment;
}
/**