mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
feat: wip migrate to nestjs
This commit is contained in:
@@ -13,8 +13,10 @@ import {
|
||||
IVendorNewDTO,
|
||||
IVendorOpeningBalanceEditDTO,
|
||||
} from './types/Vendors.types';
|
||||
import { PublicRoute } from '../Auth/Jwt.guard';
|
||||
|
||||
@Controller('vendors')
|
||||
@PublicRoute()
|
||||
export class VendorsController {
|
||||
constructor(private vendorsApplication: VendorsApplication) {}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export class DeleteVendorService {
|
||||
constructor(
|
||||
private eventPublisher: EventEmitter2,
|
||||
private uow: UnitOfWork,
|
||||
@Inject(Vendor.name) private contactModel: typeof Vendor,
|
||||
@Inject(Vendor.name) private vendorModel: typeof Vendor,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -29,9 +29,8 @@ export class DeleteVendorService {
|
||||
*/
|
||||
public async deleteVendor(vendorId: number) {
|
||||
// Retrieves the old vendor or throw not found service error.
|
||||
const oldVendor = await this.contactModel
|
||||
const oldVendor = await this.vendorModel
|
||||
.query()
|
||||
.modify('vendor')
|
||||
.findById(vendorId)
|
||||
.throwIfNotFound();
|
||||
// .queryAndThrowIfHasRelations({
|
||||
@@ -47,7 +46,7 @@ export class DeleteVendorService {
|
||||
// Deletes vendor contact under unit-of-work.
|
||||
return this.uow.withTransaction(async (trx: Knex.Transaction) => {
|
||||
// Deletes the vendor contact from the storage.
|
||||
await this.contactModel.query(trx).findById(vendorId).delete();
|
||||
await this.vendorModel.query(trx).findById(vendorId).delete();
|
||||
|
||||
// Triggers `onVendorDeleted` event.
|
||||
await this.eventPublisher.emitAsync(events.vendors.onDeleted, {
|
||||
|
||||
@@ -170,7 +170,7 @@ export class Vendor extends BaseModel {
|
||||
return {
|
||||
bills: {
|
||||
relation: Model.HasManyRelation,
|
||||
modelClass: Bill.default,
|
||||
modelClass: Bill,
|
||||
join: {
|
||||
from: 'contacts.id',
|
||||
to: 'bills.vendorId',
|
||||
@@ -178,7 +178,7 @@ export class Vendor extends BaseModel {
|
||||
},
|
||||
overdueBills: {
|
||||
relation: Model.HasManyRelation,
|
||||
modelClass: Bill.default,
|
||||
modelClass: Bill,
|
||||
join: {
|
||||
from: 'contacts.id',
|
||||
to: 'bills.vendorId',
|
||||
|
||||
@@ -18,7 +18,6 @@ export class GetVendorService {
|
||||
const vendor = await this.vendorModel
|
||||
.query()
|
||||
.findById(vendorId)
|
||||
.modify('vendor')
|
||||
.throwIfNotFound();
|
||||
|
||||
// Transformes the vendor.
|
||||
|
||||
Reference in New Issue
Block a user