mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
refactor: events tracker to nestjs
This commit is contained in:
@@ -12,13 +12,15 @@ import { InventoryAdjustmentsController } from './InventoryAdjustments.controlle
|
||||
import { BranchesModule } from '../Branches/Branches.module';
|
||||
import { WarehousesModule } from '../Warehouses/Warehouses.module';
|
||||
import { InventoryAdjustmentsGLSubscriber } from './subscribers/InventoryAdjustmentGL.subscriber';
|
||||
import { InventoryAdjustmentsGLEntries } from './commands/ledger/InventoryAdjustmentsGLEntries';
|
||||
import { LedgerModule } from '../Ledger/Ledger.module';
|
||||
|
||||
const models = [
|
||||
RegisterTenancyModel(InventoryAdjustment),
|
||||
RegisterTenancyModel(InventoryAdjustmentEntry),
|
||||
];
|
||||
@Module({
|
||||
imports: [BranchesModule, WarehousesModule],
|
||||
imports: [BranchesModule, WarehousesModule, LedgerModule],
|
||||
controllers: [InventoryAdjustmentsController],
|
||||
providers: [
|
||||
...models,
|
||||
@@ -29,6 +31,7 @@ const models = [
|
||||
DeleteInventoryAdjustmentService,
|
||||
InventoryAdjustmentsApplicationService,
|
||||
InventoryAdjustmentsGLSubscriber,
|
||||
InventoryAdjustmentsGLEntries,
|
||||
],
|
||||
exports: [...models],
|
||||
})
|
||||
|
||||
@@ -4,7 +4,6 @@ import * as R from 'ramda';
|
||||
import { omit } from 'lodash';
|
||||
import { events } from '@/common/events/events';
|
||||
import { InventoryAdjustment } from '../models/InventoryAdjustment';
|
||||
import { InventoryAdjustmentEntry } from '../models/InventoryAdjustmentEntry';
|
||||
import {
|
||||
IInventoryAdjustmentCreatingPayload,
|
||||
IInventoryAdjustmentEventCreatedPayload,
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { UnitOfWork } from '@/modules/Tenancy/TenancyDB/UnitOfWork.service';
|
||||
import { Knex } from 'knex';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { UnitOfWork } from '@/modules/Tenancy/TenancyDB/UnitOfWork.service';
|
||||
import { InventoryAdjustment } from '../models/InventoryAdjustment';
|
||||
import { InventoryAdjustmentEntry } from '../models/InventoryAdjustmentEntry';
|
||||
import {
|
||||
IInventoryAdjustmentEventPublishedPayload,
|
||||
IInventoryAdjustmentPublishingPayload,
|
||||
} from '../types/InventoryAdjustments.types';
|
||||
import { events } from '@/common/events/events';
|
||||
import { Knex } from 'knex';
|
||||
import { ServiceError } from '@/modules/Items/ServiceError';
|
||||
|
||||
export class PublishInventoryAdjustmentService {
|
||||
@@ -22,8 +21,7 @@ export class PublishInventoryAdjustmentService {
|
||||
|
||||
/**
|
||||
* Publish the inventory adjustment transaction.
|
||||
* @param {number} tenantId
|
||||
* @param {number} inventoryAdjustmentId
|
||||
* @param {number} inventoryAdjustmentId - Inventory adjustment ID.
|
||||
*/
|
||||
public async publishInventoryAdjustment(
|
||||
inventoryAdjustmentId: number,
|
||||
|
||||
@@ -13,7 +13,12 @@ export class InventoryAdjustmentsGL {
|
||||
this.inventoryAdjustment = inventoryAdjustmentModel;
|
||||
}
|
||||
|
||||
setBaseCurrency(baseCurrency: string) {
|
||||
/**
|
||||
* Sets the base currency.
|
||||
* @param {string} baseCurrency - Base currency.
|
||||
* @returns {InventoryAdjustmentsGL}
|
||||
*/
|
||||
public setBaseCurrency(baseCurrency: string) {
|
||||
this.baseCurrency = baseCurrency;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
const ERRORS = {
|
||||
INVENTORY_ADJUSTMENT_NOT_FOUND: 'INVENTORY_ADJUSTMENT_NOT_FOUND',
|
||||
ITEM_SHOULD_BE_INVENTORY_TYPE: 'ITEM_SHOULD_BE_INVENTORY_TYPE',
|
||||
INVENTORY_ADJUSTMENT_ALREADY_PUBLISHED:
|
||||
'INVENTORY_ADJUSTMENT_ALREADY_PUBLISHED',
|
||||
};
|
||||
Reference in New Issue
Block a user