fix: auto increment serial transactions

This commit is contained in:
Ahmed Bouhuolia
2025-11-02 21:08:28 +02:00
parent cca116f6bb
commit f64875404a
10 changed files with 95 additions and 34 deletions

View File

@@ -21,6 +21,7 @@ import { VendorCreditGLEntries } from './commands/VendorCreditGLEntries';
import { LedgerModule } from '../Ledger/Ledger.module';
import { AccountsModule } from '../Accounts/Accounts.module';
import { VendorCreditInventoryTransactionsSubscriber } from './subscribers/VendorCreditInventoryTransactionsSusbcriber';
import { VendorCreditAutoSerialSubscriber } from './subscribers/VendorCreditAutoSerialSubscriber';
import { VendorCreditInventoryTransactions } from './commands/VendorCreditInventoryTransactions';
import { GetVendorCreditsService } from './queries/GetVendorCredits.service';
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
@@ -57,6 +58,7 @@ import { VendorCreditsImportable } from './commands/VendorCreditsImportable';
VendorCreditGlEntriesSubscriber,
VendorCreditInventoryTransactions,
VendorCreditInventoryTransactionsSubscriber,
VendorCreditAutoSerialSubscriber,
VendorCreditsExportable,
VendorCreditsImportable,
],

View File

@@ -1,27 +1,21 @@
// import { Service, Inject } from 'typedi';
// import events from '@/subscribers/events';
// import BaseVendorCredit from '../commands/VendorCreditDTOTransform.service';
// import { IVendorCreditCreatedPayload } from '@/interfaces';
import { Injectable } from '@nestjs/common';
import { OnEvent } from '@nestjs/event-emitter';
import { events } from '@/common/events/events';
import { VendorCreditAutoIncrementService } from '../commands/VendorCreditAutoIncrement.service';
import { IVendorCreditCreatedPayload } from '../types/VendorCredit.types';
// @Service()
// export default class VendorCreditAutoSerialSubscriber {
// @Inject()
// vendorCreditService: BaseVendorCredit;
@Injectable()
export class VendorCreditAutoSerialSubscriber {
constructor(
private readonly vendorCreditIncrementService: VendorCreditAutoIncrementService,
) { }
// /**
// * Attaches events with handlers.
// */
// public attach(bus) {
// bus.subscribe(events.vendorCredit.onCreated, this.autoIncrementOnceCreated);
// }
// /**
// * Auto serial increment once the vendor credit created.
// * @param {IVendorCreditCreatedPayload} payload
// */
// private autoIncrementOnceCreated = ({
// tenantId,
// }: IVendorCreditCreatedPayload) => {
// this.vendorCreditService.incrementSerialNumber(tenantId);
// };
// }
/**
* Auto serial increment once vendor credit created.
* @param {IVendorCreditCreatedPayload} payload -
*/
@OnEvent(events.vendorCredit.onCreated)
async autoSerialIncrementOnceCreated({ }: IVendorCreditCreatedPayload) {
await this.vendorCreditIncrementService.incrementSerialNumber();
}
}