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