mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
31 lines
778 B
TypeScript
31 lines
778 B
TypeScript
import { Service, Inject } from 'typedi';
|
|
import events from '@/subscribers/events';
|
|
import BaseCreditNotes from './CreditNotes';
|
|
import { ICreditNoteCreatedPayload } from '@/interfaces';
|
|
|
|
@Service()
|
|
export default class CreditNoteAutoSerialSubscriber {
|
|
@Inject()
|
|
creditNotesService: BaseCreditNotes;
|
|
|
|
/**
|
|
* Attaches events with handlers.
|
|
*/
|
|
public attach(bus) {
|
|
bus.subscribe(
|
|
events.creditNote.onCreated,
|
|
this.autoSerialIncrementOnceCreated
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Auto serial increment once credit note created.
|
|
* @param {ICreditNoteCreatedPayload} payload -
|
|
*/
|
|
private autoSerialIncrementOnceCreated = async ({
|
|
tenantId,
|
|
}: ICreditNoteCreatedPayload) => {
|
|
await this.creditNotesService.incrementSerialNumber(tenantId);
|
|
};
|
|
}
|