mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat(server): wip sale invoice tax rate GL entries
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
import moment from 'moment';
|
||||
import { castArray, sumBy, toArray } from 'lodash';
|
||||
import { IBill, ISystemUser, IAccount } from '@/interfaces';
|
||||
import { castArray } from 'lodash';
|
||||
import JournalPoster from './JournalPoster';
|
||||
import JournalEntry from './JournalEntry';
|
||||
import { IExpense, IExpenseCategory } from '@/interfaces';
|
||||
import { increment } from 'utils';
|
||||
|
||||
export default class JournalCommands {
|
||||
journal: JournalPoster;
|
||||
models: any;
|
||||
@@ -16,7 +12,6 @@ export default class JournalCommands {
|
||||
*/
|
||||
constructor(journal: JournalPoster) {
|
||||
this.journal = journal;
|
||||
|
||||
this.repositories = this.journal.repositories;
|
||||
this.models = this.journal.models;
|
||||
}
|
||||
|
||||
@@ -234,6 +234,9 @@ export default class Ledger implements ILedger {
|
||||
entryId: entry.id,
|
||||
branchId: entry.branchId,
|
||||
projectId: entry.projectId,
|
||||
|
||||
taxRateId: entry.taxRateId,
|
||||
taxRate: entry.taxRate,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -32,5 +32,8 @@ export const transformLedgerEntryToTransaction = (
|
||||
projectId: entry.projectId,
|
||||
|
||||
costable: entry.costable,
|
||||
|
||||
taxRateId: entry.taxRateId,
|
||||
taxRate: entry.taxRate,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -53,7 +53,7 @@ export class SaleInvoiceGLEntries {
|
||||
saleInvoice,
|
||||
ARAccount.id,
|
||||
taxPayableAccount.id
|
||||
);
|
||||
);
|
||||
// Commits the ledger entries to the storage as UOW.
|
||||
await this.ledegrRepository.commit(tenantId, ledger, trx);
|
||||
};
|
||||
@@ -190,6 +190,8 @@ export class SaleInvoiceGLEntries {
|
||||
itemQuantity: entry.quantity,
|
||||
accountNormal: AccountNormal.CREDIT,
|
||||
projectId: entry.projectId || saleInvoice.projectId,
|
||||
taxRateId: entry.taxRateId,
|
||||
taxRate: entry.taxRate,
|
||||
};
|
||||
}
|
||||
);
|
||||
@@ -201,15 +203,22 @@ export class SaleInvoiceGLEntries {
|
||||
* @returns {ILedgerEntry}
|
||||
*/
|
||||
private getInvoiceTaxEntry = R.curry(
|
||||
(saleInvoice: ISaleInvoice, taxPayableAccountId: number): ILedgerEntry => {
|
||||
(
|
||||
saleInvoice: ISaleInvoice,
|
||||
taxPayableAccountId: number,
|
||||
entry: IItemEntry,
|
||||
index: number
|
||||
): ILedgerEntry => {
|
||||
const commonEntry = this.getInvoiceGLCommonEntry(saleInvoice);
|
||||
|
||||
return {
|
||||
...commonEntry,
|
||||
credit: saleInvoice.taxAmountWithheld,
|
||||
credit: entry.taxAmount,
|
||||
accountId: taxPayableAccountId,
|
||||
index: saleInvoice.entries.length + 3,
|
||||
index: index + 3,
|
||||
accountNormal: AccountNormal.CREDIT,
|
||||
taxRateId: entry.taxRateId,
|
||||
taxRate : entry.taxRate,
|
||||
};
|
||||
}
|
||||
);
|
||||
@@ -230,10 +239,13 @@ export class SaleInvoiceGLEntries {
|
||||
ARAccountId
|
||||
);
|
||||
const transformItemEntry = this.getInvoiceItemEntry(saleInvoice);
|
||||
|
||||
const transformTaxEntry = this.getInvoiceTaxEntry(
|
||||
saleInvoice,
|
||||
taxPayableAccountId
|
||||
);
|
||||
const creditEntries = saleInvoice.entries.map(transformItemEntry);
|
||||
const taxEntry = this.getInvoiceTaxEntry(saleInvoice, taxPayableAccountId);
|
||||
const taxEntries = saleInvoice.entries.map(transformTaxEntry);
|
||||
|
||||
return [receivableEntry, ...creditEntries, taxEntry];
|
||||
return [receivableEntry, ...creditEntries, ...taxEntries];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ export class PaymentReceivesApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
* deletes the given payment receive.
|
||||
* Deletes the given payment receive.
|
||||
* @param {number} tenantId
|
||||
* @param {number} paymentReceiveId
|
||||
* @param {ISystemUser} authorizedUser
|
||||
@@ -126,7 +126,7 @@ export class PaymentReceivesApplication {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Retrieves the given payment receive.
|
||||
* @param {number} tenantId
|
||||
* @param {number} paymentReceiveId
|
||||
* @returns {Promise<IPaymentReceive>}
|
||||
|
||||
Reference in New Issue
Block a user