From d789228038f17e07f50a75cfbba8c6bf72949428 Mon Sep 17 00:00:00 2001 From: "a.bouhuolia" Date: Tue, 26 Jan 2021 12:51:13 +0200 Subject: [PATCH] fix: accounts types with new design. --- client/src/components/DataTable.js | 6 +- client/src/components/Datatable/TableCell.js | 59 +++++++++++-------- client/src/components/Datatable/TablePage.js | 4 +- .../BalanceSheet/BalanceSheetTable.js | 2 +- .../ProfitLossSheet/ProfitLossSheetTable.js | 1 + server/src/data/BalanceSheetStructure.ts | 29 +++++---- ...2647_create_accounts_transactions_table.js | 3 + server/src/database/seeds/data/accounts.js | 10 ++-- server/src/interfaces/Account.ts | 2 + server/src/models/Account.js | 12 ++-- server/src/repositories/AccountRepository.ts | 9 +++ .../AccountTransactionRepository.ts | 2 +- .../services/Accounting/JournalCommands.ts | 2 +- .../src/services/Accounting/JournalPoster.ts | 7 +-- .../BalanceSheet/BalanceSheet.ts | 2 +- .../BalanceSheet/BalanceSheetService.ts | 2 +- .../GeneralLedger/GeneralLedger.ts | 9 ++- .../GeneralLedger/GeneralLedgerService.ts | 2 +- .../ProfitLossSheet/ProfitLossSheet.ts | 11 ++-- .../ProfitLossSheet/ProfitLossSheetService.ts | 2 +- .../TrialBalanceSheet/TrialBalanceSheet.ts | 2 +- .../TrialBalanceSheetService.ts | 2 +- server/src/services/Purchases/BillPayments.ts | 2 +- server/src/subscribers/items.ts | 19 ------ 24 files changed, 101 insertions(+), 100 deletions(-) diff --git a/client/src/components/DataTable.js b/client/src/components/DataTable.js index 2926da665..2abbe1047 100644 --- a/client/src/components/DataTable.js +++ b/client/src/components/DataTable.js @@ -50,7 +50,6 @@ export default function DataTable(props) { rowClassNames, payload, expandable = false, - expandToggleColumn = 2, noInitialFetch = false, pagesCount: controlledPageCount, @@ -58,8 +57,6 @@ export default function DataTable(props) { // Pagination props. initialPageIndex = 0, initialPageSize = 10, - rowContextMenu, - expandColumnSpace = 1.5, updateDebounceTime = 200, selectionColumnWidth = 42, @@ -180,6 +177,9 @@ DataTable.defaultProps = { pagination: false, spinnerProps: { size: 30 }, + expandToggleColumn: 1, + expandColumnSpace: 0.8, + autoResetPage: true, autoResetExpanded: true, autoResetGroupBy: true, diff --git a/client/src/components/Datatable/TableCell.js b/client/src/components/Datatable/TableCell.js index 684070615..d8122a5c1 100644 --- a/client/src/components/Datatable/TableCell.js +++ b/client/src/components/Datatable/TableCell.js @@ -7,11 +7,17 @@ import TableContext from './TableContext'; /** * Tabl cell. */ -export default function TableCell({ cell, row, index }) { +export default function TableCell({ + cell, + row: { depth, getToggleRowExpandedProps, isExpanded }, + index, +}) { const { - props: { expandToggleColumn, expandable } + props: { expandToggleColumn, expandColumnSpace, expandable }, } = useContext(TableContext); + const isExpandColumn = expandToggleColumn === index; + return (
- { - // Use the row.canExpand and row.getToggleRowExpandedProps prop getter - // to build the toggle for expanding a row - } - + { + // Use the row.canExpand and row.getToggleRowExpandedProps prop getter + // to build the toggle for expanding a row } - > - - - - + + + + + - {children}} - > {cell.render('Cell')} - +
); } diff --git a/client/src/components/Datatable/TablePage.js b/client/src/components/Datatable/TablePage.js index 189580f43..2d6a2771f 100644 --- a/client/src/components/Datatable/TablePage.js +++ b/client/src/components/Datatable/TablePage.js @@ -12,7 +12,7 @@ export default function TablePage() { loading, TableRowsRenderer, TableLoadingRenderer, - TableNoResultsRow, + TableNoResultsRowRenderer, }, } = useContext(TableContext); @@ -20,7 +20,7 @@ export default function TablePage() { return ; } if (page.length === 0) { - return ; + return ; } return (); } diff --git a/client/src/containers/FinancialStatements/BalanceSheet/BalanceSheetTable.js b/client/src/containers/FinancialStatements/BalanceSheet/BalanceSheetTable.js index c3c2044d5..42d373f5c 100644 --- a/client/src/containers/FinancialStatements/BalanceSheet/BalanceSheetTable.js +++ b/client/src/containers/FinancialStatements/BalanceSheet/BalanceSheetTable.js @@ -103,7 +103,7 @@ function BalanceSheetTable({ expanded={expandedRows} expandToggleColumn={1} expandColumnSpace={0.8} - sticky={true} + // sticky={true} /> ); diff --git a/client/src/containers/FinancialStatements/ProfitLossSheet/ProfitLossSheetTable.js b/client/src/containers/FinancialStatements/ProfitLossSheet/ProfitLossSheetTable.js index afbb795e3..06fb2fded 100644 --- a/client/src/containers/FinancialStatements/ProfitLossSheet/ProfitLossSheetTable.js +++ b/client/src/containers/FinancialStatements/ProfitLossSheet/ProfitLossSheetTable.js @@ -101,6 +101,7 @@ function ProfitLossSheetTable({ rowClassNames={rowClassNames} expandable={true} expandToggleColumn={1} + sticky={true} /> diff --git a/server/src/data/BalanceSheetStructure.ts b/server/src/data/BalanceSheetStructure.ts index bdb785000..0e90a720c 100644 --- a/server/src/data/BalanceSheetStructure.ts +++ b/server/src/data/BalanceSheetStructure.ts @@ -1,4 +1,7 @@ import { IBalanceSheetStructureSection } from 'interfaces'; +import { + ACCOUNT_TYPE +} from 'data/AccountTypes'; const balanceSheetStructure: IBalanceSheetStructureSection[] = [ { @@ -14,22 +17,22 @@ const balanceSheetStructure: IBalanceSheetStructureSection[] = [ { name: 'Cash and cash equivalents', type: 'accounts_section', - accountsTypes: ['cash', 'bank'], + accountsTypes: [ACCOUNT_TYPE.CASH, ACCOUNT_TYPE.BANK], }, { name: 'Accounts Receivable', type: 'accounts_section', - accountsTypes: ['accounts_receivable'], + accountsTypes: [ACCOUNT_TYPE.ACCOUNTS_RECEIVABLE], }, { name: 'Inventories', type: 'accounts_section', - accountsTypes: ['inventory'], + accountsTypes: [ACCOUNT_TYPE.INVENTORY], }, { name: 'Other current assets', type: 'accounts_section', - accountsTypes: ['other_current_asset'], + accountsTypes: [ACCOUNT_TYPE.OTHER_CURRENT_ASSET], }, ], alwaysShow: true, @@ -37,12 +40,12 @@ const balanceSheetStructure: IBalanceSheetStructureSection[] = [ { name: 'Fixed Asset', type: 'accounts_section', - accountsTypes: ['fixed_asset'], + accountsTypes: [ACCOUNT_TYPE.FIXED_ASSET], }, { name: 'Non-Current Assets', type: 'accounts_section', - accountsTypes: ['non_current_asset'], + accountsTypes: [ACCOUNT_TYPE.NON_CURRENT_ASSET], } ], alwaysShow: true, @@ -61,21 +64,21 @@ const balanceSheetStructure: IBalanceSheetStructureSection[] = [ name: 'Current Liabilties', type: 'accounts_section', accountsTypes: [ - 'accounts_payable', - 'tax_payable', - 'credit_card', - 'other_current_liability' + ACCOUNT_TYPE.ACCOUNTS_PAYABLE, + ACCOUNT_TYPE.TAX_PAYABLE, + ACCOUNT_TYPE.CREDIT_CARD, + ACCOUNT_TYPE.OTHER_CURRENT_LIABILITY, ], }, { name: 'Long-Term Liabilities', type: 'accounts_section', - accountsTypes: ['long_term_liability'], + accountsTypes: [ACCOUNT_TYPE.LOGN_TERM_LIABILITY], }, { name: 'Non-Current Liabilities', type: 'accounts_section', - accountsTypes: ['non_current_liability'], + accountsTypes: [ACCOUNT_TYPE.NON_CURRENT_LIABILITY], } ], }, @@ -83,7 +86,7 @@ const balanceSheetStructure: IBalanceSheetStructureSection[] = [ name: 'Equity', sectionType: 'equity', type: 'accounts_section', - accountsTypes: ['equity'], + accountsTypes: [ACCOUNT_TYPE.EQUITY], }, ], alwaysShow: true, diff --git a/server/src/database/migrations/20200104232647_create_accounts_transactions_table.js b/server/src/database/migrations/20200104232647_create_accounts_transactions_table.js index f4f4ff3e7..490786266 100644 --- a/server/src/database/migrations/20200104232647_create_accounts_transactions_table.js +++ b/server/src/database/migrations/20200104232647_create_accounts_transactions_table.js @@ -10,6 +10,9 @@ exports.up = function(knex) { table.integer('account_id').unsigned().index().references('id').inTable('accounts'); table.string('contact_type').nullable().index(); table.integer('contact_id').unsigned().nullable().index(); + table.string('transaction_number').nullable().index(); + table.string('reference_number').nullable().index(); + table.integer('item_id').unsigned().nullable().index(); table.string('note'); table.integer('user_id').unsigned().index(); table.integer('index').unsigned(); diff --git a/server/src/database/seeds/data/accounts.js b/server/src/database/seeds/data/accounts.js index a0c8382a9..fb6bf6c07 100644 --- a/server/src/database/seeds/data/accounts.js +++ b/server/src/database/seeds/data/accounts.js @@ -118,8 +118,8 @@ export default [ predefined: 0, }, { - name:'Opening Balance Adjustments', - slug: 'opening-balance-adjustments', + name:'Opening Balance Liabilities', + slug: 'opening-balance-liabilities', account_type: 'other-current-liability', code: '20004', description:'This account will hold the difference in the debits and credits entered during the opening balance..', @@ -193,9 +193,9 @@ export default [ // Expenses { - name:'Uncategorized Expenses', - slug: 'uncategorized-expense', - account_type: 'expense', + name:'Other Expenses', + slug: 'other-expenses', + account_type: 'other-expense', parent_account_id: null, code: '40001', description: '', diff --git a/server/src/interfaces/Account.ts b/server/src/interfaces/Account.ts index 28e22617e..fd48ae3da 100644 --- a/server/src/interfaces/Account.ts +++ b/server/src/interfaces/Account.ts @@ -24,6 +24,8 @@ export interface IAccount { currencyCode: string, transactions?: any[], type?: any[], + accountNormal: string, + accountParentType: string, }; export interface IAccountsFilter extends IDynamicListFilterDTO { diff --git a/server/src/models/Account.js b/server/src/models/Account.js index adef91d9b..f181ea162 100644 --- a/server/src/models/Account.js +++ b/server/src/models/Account.js @@ -179,14 +179,6 @@ export default class Account extends TenantModel { return this.isProfitLossSheet(); } - static collectJournalEntries(accounts) { - return flatten(accounts.map((account) => account.transactions.map((transaction) => ({ - accountId: account.id, - ...transaction, - accountNormal: account.type.normal, - })))); - } - /** * Converts flatten accounts list to nested array. * @param {Array} accounts @@ -196,6 +188,10 @@ export default class Account extends TenantModel { return flatToNestedArray(accounts, { id: 'id', parentId: 'parentAccountId' }) } + /** + * Transformes the accounts list to depenedency graph structure. + * @param {IAccount[]} accounts + */ static toDependencyGraph(accounts) { return DependencyGraph.fromArray( accounts, { itemId: 'id', parentItemId: 'parentAccountId' } diff --git a/server/src/repositories/AccountRepository.ts b/server/src/repositories/AccountRepository.ts index 2660f8697..dd7399e2c 100644 --- a/server/src/repositories/AccountRepository.ts +++ b/server/src/repositories/AccountRepository.ts @@ -23,6 +23,15 @@ export default class AccountRepository extends TenantRepository { return this.model.toDependencyGraph(accounts); }); } + + /** + * Retrieve. + * @param {string} slug + * @return {Promise} + */ + findBySlug(slug: string) { + return this.findOne({ slug }); + } /** * Changes account balance. diff --git a/server/src/repositories/AccountTransactionRepository.ts b/server/src/repositories/AccountTransactionRepository.ts index 25e160a1d..9daf0fc56 100644 --- a/server/src/repositories/AccountTransactionRepository.ts +++ b/server/src/repositories/AccountTransactionRepository.ts @@ -31,7 +31,7 @@ export default class AccountTransactionsRepository extends TenantRepository { return this.model.query() .modify('filterAccounts', filter.accountsIds) .modify('filterDateRange', filter.fromDate, filter.toDate) - .withGraphFetched('account.type') + .withGraphFetched('account') .onBuild((query) => { if (filter.sumationCreditDebit) { query.modify('sumationCreditDebit'); diff --git a/server/src/services/Accounting/JournalCommands.ts b/server/src/services/Accounting/JournalCommands.ts index d9db78487..17cf153ba 100644 --- a/server/src/services/Accounting/JournalCommands.ts +++ b/server/src/services/Accounting/JournalCommands.ts @@ -269,7 +269,7 @@ export default class JournalCommands { 'reference_id', Array.isArray(referenceId) ? referenceId : [referenceId] ) - .withGraphFetched('account.type'); + .withGraphFetched('account'); this.journal.fromTransactions(transactions); this.journal.removeEntries(); diff --git a/server/src/services/Accounting/JournalPoster.ts b/server/src/services/Accounting/JournalPoster.ts index ddf8e855a..5f6299d90 100644 --- a/server/src/services/Accounting/JournalPoster.ts +++ b/server/src/services/Accounting/JournalPoster.ts @@ -165,7 +165,6 @@ export default class JournalPoster implements IJournalPoster { private async convertBalanceChangesToArr( accountsChange: IAccountsChange ) : Promise<{ account: number, change: number }[]>{ - const { accountTypeRepository } = this.repositories; const mappedList: { account: number, change: number }[] = []; const accountsIds: number[] = Object.keys(accountsChange).map(id => parseInt(id, 10)); @@ -173,8 +172,8 @@ export default class JournalPoster implements IJournalPoster { accountsIds.map(async (account: number) => { const accountChange = accountsChange[account]; const accountNode = this.accountsDepGraph.getNodeData(account); - const accountTypeMeta = await accountTypeRepository.findOneById(accountNode.accountTypeId); - const { normal }: { normal: TEntryType } = accountTypeMeta; + + const { normal }: { normal: TEntryType } = accountNode.accountNormal; let change = 0; if (accountChange.credit) { @@ -333,7 +332,7 @@ export default class JournalPoster implements IJournalPoster { ...transaction, referenceTypeFormatted: transaction.referenceTypeFormatted, account: transaction.accountId, - accountNormal: get(transaction, 'account.type.normal'), + accountNormal: get(transaction, 'account.accountNormal'), }); }); } diff --git a/server/src/services/FinancialStatements/BalanceSheet/BalanceSheet.ts b/server/src/services/FinancialStatements/BalanceSheet/BalanceSheet.ts index 62141bb7a..614b4f9bb 100644 --- a/server/src/services/FinancialStatements/BalanceSheet/BalanceSheet.ts +++ b/server/src/services/FinancialStatements/BalanceSheet/BalanceSheet.ts @@ -184,7 +184,7 @@ export default class BalanceSheetStatement extends FinancialSheet { const filteredAccounts = accounts // Filter accounts that associated to the section accounts types. .filter( - (account) => sectionAccountsTypes.indexOf(account.type.key) !== -1 + (account) => sectionAccountsTypes.indexOf(account.accountType) !== -1 ) .map((account) => this.balanceSheetAccountMapper(account)) // Filter accounts that have no transaction when `noneTransactions` is on. diff --git a/server/src/services/FinancialStatements/BalanceSheet/BalanceSheetService.ts b/server/src/services/FinancialStatements/BalanceSheet/BalanceSheetService.ts index 8af288074..3c6daa5aa 100644 --- a/server/src/services/FinancialStatements/BalanceSheet/BalanceSheetService.ts +++ b/server/src/services/FinancialStatements/BalanceSheet/BalanceSheetService.ts @@ -70,7 +70,7 @@ export default class BalanceSheetStatementService this.logger.info('[balance_sheet] trying to calculate the report.', { filter, tenantId }); // Retrieve all accounts on the storage. - const accounts = await accountRepository.all('type'); + const accounts = await accountRepository.all(); const accountsGraph = await accountRepository.getDependencyGraph(); // Retrieve all journal transactions based on the given query. diff --git a/server/src/services/FinancialStatements/GeneralLedger/GeneralLedger.ts b/server/src/services/FinancialStatements/GeneralLedger/GeneralLedger.ts index 48df05ef8..0c4a88eaa 100644 --- a/server/src/services/FinancialStatements/GeneralLedger/GeneralLedger.ts +++ b/server/src/services/FinancialStatements/GeneralLedger/GeneralLedger.ts @@ -6,7 +6,6 @@ import { IGeneralLedgerSheetAccountTransaction, IAccount, IJournalPoster, - IAccountType, IJournalEntry, IContact, } from 'interfaces'; @@ -130,7 +129,7 @@ export default class GeneralLedgerSheet extends FinancialSheet { * @return {IGeneralLedgerSheetAccountTransaction[]} */ private accountTransactionsMapper( - account: IAccount & { type: IAccountType }, + account: IAccount, openingBalance: number ): IGeneralLedgerSheetAccountTransaction[] { const entries = this.transactions.getAccountEntries(account.id); @@ -184,7 +183,7 @@ export default class GeneralLedgerSheet extends FinancialSheet { * @return {IGeneralLedgerSheetAccount} */ private accountMapper( - account: IAccount & { type: IAccountType } + account: IAccount ): IGeneralLedgerSheetAccount { const openingBalance = this.accountOpeningBalance(account); const closingBalance = this.accountClosingBalance(account); @@ -210,11 +209,11 @@ export default class GeneralLedgerSheet extends FinancialSheet { * @return {IGeneralLedgerSheetAccount[]} */ private accountsWalker( - accounts: IAccount & { type: IAccountType }[] + accounts: IAccount[] ): IGeneralLedgerSheetAccount[] { return ( accounts - .map((account: IAccount & { type: IAccountType }) => + .map((account: IAccount) => this.accountMapper(account) ) // Filter general ledger accounts that have no transactions diff --git a/server/src/services/FinancialStatements/GeneralLedger/GeneralLedgerService.ts b/server/src/services/FinancialStatements/GeneralLedger/GeneralLedgerService.ts index 8fd09ac5f..6c2ec00e7 100644 --- a/server/src/services/FinancialStatements/GeneralLedger/GeneralLedgerService.ts +++ b/server/src/services/FinancialStatements/GeneralLedger/GeneralLedgerService.ts @@ -89,7 +89,7 @@ export default class GeneralLedgerService { key: 'base_currency', }); // Retrieve all accounts with associated type from the storage. - const accounts = await accountRepository.all('type'); + const accounts = await accountRepository.all(); const accountsGraph = await accountRepository.getDependencyGraph(); // Retrieve all contacts on the storage. diff --git a/server/src/services/FinancialStatements/ProfitLossSheet/ProfitLossSheet.ts b/server/src/services/FinancialStatements/ProfitLossSheet/ProfitLossSheet.ts index d5d16232b..6f1478570 100644 --- a/server/src/services/FinancialStatements/ProfitLossSheet/ProfitLossSheet.ts +++ b/server/src/services/FinancialStatements/ProfitLossSheet/ProfitLossSheet.ts @@ -12,6 +12,7 @@ import { IProfitLossSheetTotalSection, } from 'interfaces'; import { flatToNestedArray, dateRangeCollection } from 'utils'; +import { ACCOUNT_TYPE } from 'data/AccountTypes'; export default class ProfitLossSheet extends FinancialSheet { tenantId: number; @@ -51,7 +52,7 @@ export default class ProfitLossSheet extends FinancialSheet { } get otherIncomeAccounts() { - return this.accounts.filter((a) => a.type.key === 'other_income'); + return this.accounts.filter((a) => a.accountType === ACCOUNT_TYPE.OTHER_INCOME); } /** @@ -59,7 +60,7 @@ export default class ProfitLossSheet extends FinancialSheet { * @return {IAccount & { type: IAccountType }[]} */ get incomeAccounts() { - return this.accounts.filter((a) => a.type.key === 'income'); + return this.accounts.filter((a) => a.accountType === ACCOUNT_TYPE.INCOME); } /** @@ -67,7 +68,7 @@ export default class ProfitLossSheet extends FinancialSheet { * @return {IAccount & { type: IAccountType }[]} */ get expensesAccounts() { - return this.accounts.filter((a) => a.type.key === 'expense'); + return this.accounts.filter((a) => a.accountType === ACCOUNT_TYPE.EXPENSE); } /** @@ -75,7 +76,7 @@ export default class ProfitLossSheet extends FinancialSheet { * @return {IAccount & { type: IAccountType }[]}} */ get otherExpensesAccounts() { - return this.accounts.filter((a) => a.type.key === 'other_expense'); + return this.accounts.filter((a) => a.accountType === ACCOUNT_TYPE.OTHER_EXPENSE); } /** @@ -83,7 +84,7 @@ export default class ProfitLossSheet extends FinancialSheet { * @return {IAccount & { type: IAccountType }[]} */ get costOfSalesAccounts() { - return this.accounts.filter((a) => a.type.key === 'cost_of_goods_sold'); + return this.accounts.filter((a) => a.accountType === ACCOUNT_TYPE.COST_OF_GOODS_SOLD); } /** diff --git a/server/src/services/FinancialStatements/ProfitLossSheet/ProfitLossSheetService.ts b/server/src/services/FinancialStatements/ProfitLossSheet/ProfitLossSheetService.ts index fac09cc68..7f90eee73 100644 --- a/server/src/services/FinancialStatements/ProfitLossSheet/ProfitLossSheetService.ts +++ b/server/src/services/FinancialStatements/ProfitLossSheet/ProfitLossSheetService.ts @@ -77,7 +77,7 @@ export default class ProfitLossSheetService { key: 'base_currency', }); // Retrieve all accounts on the storage. - const accounts = await accountRepository.all('type'); + const accounts = await accountRepository.all(); const accountsGraph = await accountRepository.getDependencyGraph(); // Retrieve all journal transactions based on the given query. diff --git a/server/src/services/FinancialStatements/TrialBalanceSheet/TrialBalanceSheet.ts b/server/src/services/FinancialStatements/TrialBalanceSheet/TrialBalanceSheet.ts index 86020ea0b..b28d14f5f 100644 --- a/server/src/services/FinancialStatements/TrialBalanceSheet/TrialBalanceSheet.ts +++ b/server/src/services/FinancialStatements/TrialBalanceSheet/TrialBalanceSheet.ts @@ -65,7 +65,7 @@ export default class TrialBalanceSheet extends FinancialSheet { parentAccountId: account.parentAccountId, name: account.name, code: account.code, - accountNormal: account.type.normal, + accountNormal: account.accountNormal, hasTransactions: entries.length > 0, credit: trial.credit, diff --git a/server/src/services/FinancialStatements/TrialBalanceSheet/TrialBalanceSheetService.ts b/server/src/services/FinancialStatements/TrialBalanceSheet/TrialBalanceSheetService.ts index 3fab2408e..9f96dbc57 100644 --- a/server/src/services/FinancialStatements/TrialBalanceSheet/TrialBalanceSheetService.ts +++ b/server/src/services/FinancialStatements/TrialBalanceSheet/TrialBalanceSheetService.ts @@ -69,7 +69,7 @@ export default class TrialBalanceSheetService extends FinancialSheet { filter, }); // Retrieve all accounts on the storage. - const accounts = await accountRepository.all('type'); + const accounts = await accountRepository.all(); const accountsGraph = await accountRepository.getDependencyGraph(); // Retrieve all journal transactions based on the given query. diff --git a/server/src/services/Purchases/BillPayments.ts b/server/src/services/Purchases/BillPayments.ts index 91c36155b..c66aa678a 100644 --- a/server/src/services/Purchases/BillPayments.ts +++ b/server/src/services/Purchases/BillPayments.ts @@ -513,7 +513,7 @@ export default class BillPaymentsService { const transactions = await AccountTransaction.query() .whereIn('reference_type', ['BillPayment']) .where('reference_id', billPayment.id) - .withGraphFetched('account.type'); + .withGraphFetched('account'); journal.loadEntries(transactions); journal.removeEntries(); diff --git a/server/src/subscribers/items.ts b/server/src/subscribers/items.ts index c68374c73..5ded804af 100644 --- a/server/src/subscribers/items.ts +++ b/server/src/subscribers/items.ts @@ -10,23 +10,4 @@ export default class ItemsSubscriber{ constructor() { this.itemsService = Container.get(ItemsService); }; - - /** - * Handle writing opening item inventory transaction. - */ - @On(events.item.onCreated) - handleWriteOpeningInventoryTransaction({ tenantId, item }) { - // Can't continue if the opeing cost, quantity or opening date was empty. - if (!item.openingCost || !item.openingQuantity || !item.openingDate) { - return; - } - // Records the opeing items inventory transaction once the item created. - this.itemsService.recordOpeningItemsInventoryTransaction( - tenantId, - item.id, - item.openingQuantity, - item.openingCost, - item.openingDate, - ) - } } \ No newline at end of file