mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
refactor: inventory to nestjs
This commit is contained in:
@@ -5,7 +5,7 @@ import { InventoryAdjustmentEntry } from './models/InventoryAdjustmentEntry';
|
||||
import { CreateQuickInventoryAdjustmentService } from './commands/CreateQuickInventoryAdjustment.service';
|
||||
import { PublishInventoryAdjustmentService } from './commands/PublishInventoryAdjustment.service';
|
||||
import { GetInventoryAdjustmentService } from './queries/GetInventoryAdjustment.service';
|
||||
// import { GetInventoryAdjustmentsService } from './queries/GetInventoryAdjustments.service';
|
||||
import { GetInventoryAdjustmentsService } from './queries/GetInventoryAdjustments.service';
|
||||
import { DeleteInventoryAdjustmentService } from './commands/DeleteInventoryAdjustment.service';
|
||||
import { InventoryAdjustmentsApplicationService } from './InventoryAdjustmentsApplication.service';
|
||||
import { InventoryAdjustmentsController } from './InventoryAdjustments.controller';
|
||||
@@ -13,23 +13,24 @@ 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';
|
||||
import { TenancyContext } from '../Tenancy/TenancyContext.service';
|
||||
import { InventoryAdjustmentInventoryTransactionsSubscriber } from './inventory/InventoryAdjustmentInventoryTransactionsSubscriber';
|
||||
import { InventoryAdjustmentInventoryTransactions } from './inventory/InventoryAdjustmentInventoryTransactions';
|
||||
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
||||
import { LedgerModule } from '../Ledger/Ledger.module';
|
||||
import { TenancyContext } from '../Tenancy/TenancyContext.service';
|
||||
|
||||
const models = [
|
||||
RegisterTenancyModel(InventoryAdjustment),
|
||||
RegisterTenancyModel(InventoryAdjustmentEntry),
|
||||
];
|
||||
@Module({
|
||||
imports: [BranchesModule, WarehousesModule, LedgerModule],
|
||||
imports: [BranchesModule, WarehousesModule, LedgerModule, DynamicListModule],
|
||||
controllers: [InventoryAdjustmentsController],
|
||||
providers: [
|
||||
...models,
|
||||
CreateQuickInventoryAdjustmentService,
|
||||
PublishInventoryAdjustmentService,
|
||||
// GetInventoryAdjustmentsService,
|
||||
GetInventoryAdjustmentsService,
|
||||
GetInventoryAdjustmentService,
|
||||
DeleteInventoryAdjustmentService,
|
||||
InventoryAdjustmentsApplicationService,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Knex } from 'knex';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import * as R from 'ramda';
|
||||
import * as moment from 'moment';
|
||||
import { omit } from 'lodash';
|
||||
@@ -20,6 +20,7 @@ import { WarehouseTransactionDTOTransform } from '@/modules/Warehouses/Integrati
|
||||
import { TenancyContext } from '@/modules/Tenancy/TenancyContext.service';
|
||||
import { ERRORS } from '../constants/InventoryAdjustments.constants';
|
||||
|
||||
@Injectable()
|
||||
export class CreateQuickInventoryAdjustmentService {
|
||||
constructor(
|
||||
@Inject(InventoryAdjustment.name)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Knex } from 'knex';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { events } from '@/common/events/events';
|
||||
@@ -10,6 +10,7 @@ import { UnitOfWork } from '@/modules/Tenancy/TenancyDB/UnitOfWork.service';
|
||||
import { InventoryAdjustmentEntry } from '../models/InventoryAdjustmentEntry';
|
||||
import { InventoryAdjustment } from '../models/InventoryAdjustment';
|
||||
|
||||
@Injectable()
|
||||
export class DeleteInventoryAdjustmentService {
|
||||
constructor(
|
||||
private readonly eventEmitter: EventEmitter2,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Knex } from 'knex';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import * as moment from 'moment';
|
||||
import { UnitOfWork } from '@/modules/Tenancy/TenancyDB/UnitOfWork.service';
|
||||
@@ -12,6 +12,7 @@ import { events } from '@/common/events/events';
|
||||
import { ServiceError } from '@/modules/Items/ServiceError';
|
||||
import { ERRORS } from '../constants/InventoryAdjustments.constants';
|
||||
|
||||
@Injectable()
|
||||
export class PublishInventoryAdjustmentService {
|
||||
constructor(
|
||||
private readonly eventEmitter: EventEmitter2,
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Knex } from 'knex';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { LedgerStorageService } from '../../../Ledger/LedgerStorage.service';
|
||||
import { InventoryAdjustment } from '../../models/InventoryAdjustment';
|
||||
import { TenancyContext } from '../../../Tenancy/TenancyContext.service';
|
||||
import { InventoryAdjustmentsGL } from './InventoryAdjustmentGL';
|
||||
|
||||
@Injectable()
|
||||
export class InventoryAdjustmentsGLEntries {
|
||||
constructor(
|
||||
private readonly ledgerStorage: LedgerStorageService,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { Knex } from "knex";
|
||||
import { InventoryAdjustment } from "../models/InventoryAdjustment";
|
||||
import { InventoryTransaction } from "@/modules/InventoryCost/models/InventoryTransaction";
|
||||
import { InventoryService } from "@/modules/InventoryCost/Inventory";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { InventoryTransactionsService } from "@/modules/InventoryCost/InventoryTransactions.service";
|
||||
|
||||
@Injectable()
|
||||
export class InventoryAdjustmentInventoryTransactions {
|
||||
constructor(
|
||||
private readonly inventoryService: InventoryService
|
||||
private readonly inventoryService: InventoryTransactionsService
|
||||
) {}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,21 +3,21 @@ import { InventoryAdjustmentEntry } from './InventoryAdjustmentEntry';
|
||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||
|
||||
export class InventoryAdjustment extends TenantBaseModel {
|
||||
date!: string;
|
||||
type!: string;
|
||||
adjustmentAccountId!: number;
|
||||
reason?: string;
|
||||
referenceNo!: string;
|
||||
description?: string;
|
||||
userId!: number;
|
||||
publishedAt?: string;
|
||||
public readonly date!: string;
|
||||
public readonly type!: string;
|
||||
public readonly adjustmentAccountId!: number;
|
||||
public readonly reason?: string;
|
||||
public readonly referenceNo!: string;
|
||||
public readonly description?: string;
|
||||
public readonly userId!: number;
|
||||
public readonly publishedAt?: string;
|
||||
|
||||
branchId!: number;
|
||||
warehouseId!: number;
|
||||
public readonly branchId!: number;
|
||||
public readonly warehouseId!: number;
|
||||
|
||||
createdAt!: Date | string;
|
||||
public readonly createdAt!: Date | string;
|
||||
|
||||
entries: InventoryAdjustmentEntry[];
|
||||
public readonly entries: InventoryAdjustmentEntry[];
|
||||
|
||||
/**
|
||||
* Table name
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { TransformerInjectable } from '@/modules/Transformer/TransformerInjectable.service';
|
||||
import { InventoryAdjustment } from '../models/InventoryAdjustment';
|
||||
import { InventoryAdjustmentTransformer } from '../InventoryAdjustmentTransformer';
|
||||
import { Inject } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class GetInventoryAdjustmentService {
|
||||
constructor(
|
||||
private readonly transformer: TransformerInjectable,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import * as R from 'ramda';
|
||||
import { IPaginationMeta } from '@/interfaces/Model';
|
||||
import { InventoryAdjustmentTransformer } from '../InventoryAdjustmentTransformer';
|
||||
@@ -7,9 +7,10 @@ import { IInventoryAdjustmentsFilter } from '../types/InventoryAdjustments.types
|
||||
import { TransformerInjectable } from '@/modules/Transformer/TransformerInjectable.service';
|
||||
import { DynamicListService } from '@/modules/DynamicListing/DynamicList.service';
|
||||
|
||||
@Injectable()
|
||||
export class GetInventoryAdjustmentsService {
|
||||
constructor(
|
||||
public readonly transformer: TransformerInjectable,
|
||||
private readonly transformer: TransformerInjectable,
|
||||
private readonly dynamicListService: DynamicListService,
|
||||
|
||||
@Inject(InventoryAdjustment.name)
|
||||
|
||||
Reference in New Issue
Block a user