mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
feat(server): wip tax rate on sale invoice service
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user