mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
feat: add totalExcludingTax property and update GL entry calculations
This commit is contained in:
@@ -20,6 +20,8 @@ export interface IItemEntry {
|
||||
amount: number;
|
||||
|
||||
total: number;
|
||||
totalExcludingTax?: number;
|
||||
|
||||
subtotalInclusingTax: number;
|
||||
subtotalExcludingTax: number;
|
||||
discountAmount: number;
|
||||
|
||||
@@ -68,6 +68,14 @@ export default class ItemEntry extends TenantModel {
|
||||
return this.subtotal - this.discountAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Total (excluding tax).
|
||||
* @returns {number}
|
||||
*/
|
||||
get totalExcludingTax() {
|
||||
return this.subtotalExcludingTax - this.discountAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Item entry amount.
|
||||
* Amount of item entry that may include or exclude tax.
|
||||
|
||||
@@ -210,11 +210,11 @@ export default class CreditNoteGLEntries {
|
||||
index: number
|
||||
): ILedgerEntry => {
|
||||
const commonEntry = this.getCreditNoteCommonEntry(creditNote);
|
||||
const localAmount = entry.amount * creditNote.exchangeRate;
|
||||
const totalLocal = entry.totalExcludingTax * creditNote.exchangeRate;
|
||||
|
||||
return {
|
||||
...commonEntry,
|
||||
debit: localAmount,
|
||||
debit: totalLocal,
|
||||
accountId: entry.sellAccountId || entry.item.sellAccountId,
|
||||
note: entry.description,
|
||||
index: index + 2,
|
||||
|
||||
@@ -139,13 +139,12 @@ export class BillGLEntries {
|
||||
private getBillItemEntry = R.curry(
|
||||
(bill: IBill, entry: IItemEntry, index: number): ILedgerEntry => {
|
||||
const commonJournalMeta = this.getBillCommonEntry(bill);
|
||||
|
||||
const localAmount = bill.exchangeRate * entry.subtotalExcludingTax;
|
||||
const totalLocal = bill.exchangeRate * entry.totalExcludingTax;
|
||||
const landedCostAmount = sumBy(entry.allocatedCostEntries, 'cost');
|
||||
|
||||
return {
|
||||
...commonJournalMeta,
|
||||
debit: localAmount + landedCostAmount,
|
||||
debit: totalLocal + landedCostAmount,
|
||||
accountId:
|
||||
['inventory'].indexOf(entry.item.type) !== -1
|
||||
? entry.item.inventoryAccountId
|
||||
|
||||
@@ -77,11 +77,11 @@ export default class VendorCreditGLEntries {
|
||||
index: number
|
||||
): ILedgerEntry => {
|
||||
const commonEntity = this.getVendorCreditGLCommonEntry(vendorCredit);
|
||||
const localAmount = entry.amount * vendorCredit.exchangeRate;
|
||||
const totalLocal = entry.totalExcludingTax * vendorCredit.exchangeRate;
|
||||
|
||||
return {
|
||||
...commonEntity,
|
||||
credit: localAmount,
|
||||
credit: totalLocal,
|
||||
index: index + 2,
|
||||
itemId: entry.itemId,
|
||||
itemQuantity: entry.quantity,
|
||||
|
||||
@@ -199,7 +199,7 @@ export class SaleInvoiceGLEntries {
|
||||
index: number
|
||||
): ILedgerEntry => {
|
||||
const commonEntry = this.getInvoiceGLCommonEntry(saleInvoice);
|
||||
const localAmount = entry.total * saleInvoice.exchangeRate;
|
||||
const localAmount = entry.totalExcludingTax * saleInvoice.exchangeRate;
|
||||
|
||||
return {
|
||||
...commonEntry,
|
||||
|
||||
@@ -143,10 +143,10 @@ export class SaleReceiptGLEntries {
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve receipt income item GL entry.
|
||||
* @param {ISaleReceipt} saleReceipt -
|
||||
* @param {IItemEntry} entry -
|
||||
* @param {number} index -
|
||||
* Retrieve receipt income item G/L entry.
|
||||
* @param {ISaleReceipt} saleReceipt -
|
||||
* @param {IItemEntry} entry -
|
||||
* @param {number} index -
|
||||
* @returns {ILedgerEntry}
|
||||
*/
|
||||
private getReceiptIncomeItemEntry = R.curry(
|
||||
@@ -156,11 +156,11 @@ export class SaleReceiptGLEntries {
|
||||
index: number
|
||||
): ILedgerEntry => {
|
||||
const commonEntry = this.getIncomeGLCommonEntry(saleReceipt);
|
||||
const itemIncome = entry.amount * saleReceipt.exchangeRate;
|
||||
const totalLocal = entry.totalExcludingTax * saleReceipt.exchangeRate;
|
||||
|
||||
return {
|
||||
...commonEntry,
|
||||
credit: itemIncome,
|
||||
credit: totalLocal,
|
||||
accountId: entry.item.sellAccountId,
|
||||
note: entry.description,
|
||||
index: index + 2,
|
||||
|
||||
@@ -232,6 +232,7 @@ export function ReceiptPaperTemplate({
|
||||
</Text>
|
||||
</Stack>
|
||||
),
|
||||
thStyle: { width: '60%' },
|
||||
},
|
||||
{ label: lineQuantityLabel, accessor: 'quantity' },
|
||||
{ label: lineRateLabel, accessor: 'rate', align: 'right' },
|
||||
|
||||
Reference in New Issue
Block a user