mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
37 lines
901 B
TypeScript
37 lines
901 B
TypeScript
import { Inject, Service } from 'typedi';
|
|
import events from '@/subscribers/events';
|
|
import { IBillEditedPayload } from '@/interfaces';
|
|
import { BillPaymentsGLEntriesRewrite } from './BillPaymentsGLEntriesRewrite';
|
|
|
|
@Service()
|
|
export class BillPaymentsGLEntriesRewriteSubscriber {
|
|
@Inject()
|
|
private billPaymentGLEntriesRewrite: BillPaymentsGLEntriesRewrite;
|
|
|
|
/**
|
|
* Attachs events with handles.
|
|
*/
|
|
public attach(bus) {
|
|
bus.subscribe(
|
|
events.bill.onEdited,
|
|
this.handlerRewritePaymentsGLOnBillEdited
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Handles writing journal entries once bill created.
|
|
* @param {IBillCreatedPayload} payload -
|
|
*/
|
|
private handlerRewritePaymentsGLOnBillEdited = async ({
|
|
tenantId,
|
|
billId,
|
|
trx,
|
|
}: IBillEditedPayload) => {
|
|
await this.billPaymentGLEntriesRewrite.rewriteBillPaymentsGLEntries(
|
|
tenantId,
|
|
billId,
|
|
trx
|
|
);
|
|
};
|
|
}
|