mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 14:50:32 +00:00
37 lines
903 B
TypeScript
37 lines
903 B
TypeScript
import { Inject, Service } from 'typedi';
|
|
import { AutoApplyPrepardExpenses } from '../AutoApplyPrepardExpenses';
|
|
import events from '@/subscribers/events';
|
|
import { IBillCreatedPayload } from '@/interfaces';
|
|
|
|
@Service()
|
|
export class AutoApplyPrepardExpensesOnBillCreated {
|
|
@Inject()
|
|
private autoApplyPrepardExpenses: AutoApplyPrepardExpenses;
|
|
|
|
/**
|
|
* Constructor method.
|
|
*/
|
|
public attach(bus) {
|
|
bus.subscribe(
|
|
events.bill.onCreated,
|
|
this.handleAutoApplyPrepardExpensesOnBillCreated.bind(this)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Handles the auto apply prepard expenses on bill created.
|
|
* @param {IBillCreatedPayload} payload -
|
|
*/
|
|
private async handleAutoApplyPrepardExpensesOnBillCreated({
|
|
tenantId,
|
|
billId,
|
|
trx,
|
|
}: IBillCreatedPayload) {
|
|
await this.autoApplyPrepardExpenses.autoApplyPrepardExpensesToBill(
|
|
tenantId,
|
|
billId,
|
|
trx
|
|
);
|
|
}
|
|
}
|