mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
refactor: warehouses to nestjs
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { Knex } from 'knex';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Item } from './models/Item';
|
||||
import { UnitOfWork } from '../Tenancy/TenancyDB/UnitOfWork.service';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { events } from '@/common/events/events';
|
||||
import { Knex } from 'knex';
|
||||
|
||||
@Injectable()
|
||||
export class ActivateItemService {
|
||||
|
||||
@@ -39,11 +39,10 @@ export class DeleteItemService {
|
||||
const oldItem = await this.itemModel
|
||||
.query()
|
||||
.findById(itemId)
|
||||
.throwIfNotFound()
|
||||
// @ts-expect-error
|
||||
.queryAndThrowIfHasRelations({
|
||||
type: ERRORS.ITEM_HAS_ASSOCIATED_TRANSACTIONS,
|
||||
});
|
||||
.throwIfNotFound();
|
||||
// .queryAndThrowIfHasRelations({
|
||||
// type: ERRORS.ITEM_HAS_ASSOCIATED_TRANSACTIONS,
|
||||
// });
|
||||
|
||||
// Delete item in unit of work.
|
||||
return this.uow.withTransaction(async (trx: Knex.Transaction) => {
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as F from 'fp-ts/function';
|
||||
import * as R from 'ramda';
|
||||
import { SearchableModel } from '@/modules/Search/SearchableMdel';
|
||||
import { BaseModel } from '@/models/Model';
|
||||
import { Warehouse } from '@/modules/Warehouses/models/Warehouse.model';
|
||||
// import { TenantModel } from '@/modules/System/models/TenantModel';
|
||||
|
||||
// const Extend = R.compose(SearchableModel)(TenantModel);
|
||||
@@ -21,6 +22,8 @@ export class Item extends BaseModel {
|
||||
public readonly inventoryAccountId: number;
|
||||
public readonly categoryId: number;
|
||||
|
||||
public readonly warehouse!: Warehouse;
|
||||
|
||||
static get tableName() {
|
||||
return 'items';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user