feat(server): wip tax rate on sale invoice service

This commit is contained in:
Ahmed Bouhuolia
2023-08-14 14:59:10 +02:00
parent a7644e6481
commit d1121f0b81
18 changed files with 514 additions and 74 deletions

View File

@@ -2,6 +2,8 @@ import { Model } from 'objection';
import TenantModel from 'models/TenantModel';
export default class ItemEntry extends TenantModel {
public taxRate: number;
/**
* Table name.
*/
@@ -17,7 +19,7 @@ export default class ItemEntry extends TenantModel {
}
static get virtualAttributes() {
return ['amount'];
return ['amount', 'taxAmount'];
}
get amount() {
@@ -31,6 +33,22 @@ export default class ItemEntry extends TenantModel {
return discount ? total - total * discount * 0.01 : total;
}
/**
* Tag rate fraction.
* @returns {number}
*/
get tagRateFraction() {
return this.taxRate / 100;
}
/**
* Tax amount withheld.
* @returns {number}
*/
get taxAmount() {
return this.amount * this.tagRateFraction;
}
static get relationMappings() {
const Item = require('models/Item');
const BillLandedCostEntry = require('models/BillLandedCostEntry');