feat: writing journal entries of payment receive.

This commit is contained in:
a.bouhuolia
2021-01-02 18:29:34 +02:00
parent 53ccd56f2b
commit f18ab184e2
4 changed files with 142 additions and 48 deletions

View File

@@ -10,7 +10,6 @@ export default class PaymentReceivesSubscriber {
tenancy: TenancyService;
logger: any;
paymentReceivesService: PaymentReceiveService;
settingsService: SettingsService;
constructor() {
@@ -20,6 +19,26 @@ export default class PaymentReceivesSubscriber {
this.settingsService = Container.get(SettingsService);
}
/**
* Handle journal entries writing once the payment receive created.
*/
@On(events.paymentReceive.onCreated)
async handleWriteJournalEntriesOnceCreated({
tenantId,
paymentReceiveId,
paymentReceive,
authorizedUser,
}) {
this.logger.info('[payment_receive] trying to write journal entries.', {
tenantId, paymentReceiveId,
});
await this.paymentReceivesService.recordPaymentReceiveJournalEntries(
tenantId,
paymentReceive,
authorizedUser.id,
);
}
/**
* Handle customer balance decrement once payment receive created.
*/
@@ -75,6 +94,27 @@ export default class PaymentReceivesSubscriber {
);
}
/**
* Handle journal entries writing once the payment receive edited.
*/
@On(events.paymentReceive.onEdited)
async handleOverwriteJournalEntriesOnceEdited({
tenantId,
paymentReceiveId,
paymentReceive,
authorizedUser,
}) {
this.logger.info('[payment_receive] trying to overwrite journal entries.', {
tenantId, paymentReceiveId,
});
await this.paymentReceivesService.recordPaymentReceiveJournalEntries(
tenantId,
paymentReceive,
authorizedUser.id,
true
);
}
/**
* Handle sale invoice increment/decrement payment amount once created, edited or deleted.
*/
@@ -119,6 +159,24 @@ export default class PaymentReceivesSubscriber {
);
}
/**
* Handles revert journal entries once deleted.
*/
@On(events.paymentReceive.onDeleted)
async handleRevertJournalEntriesOnceDeleted({
tenantId,
paymentReceiveId,
}) {
this.logger.info('[payment_receive] trying to revert journal entries.', {
tenantId,
paymentReceiveId,
});
await this.paymentReceivesService.revertPaymentReceiveJournalEntries(
tenantId,
paymentReceiveId
)
}
/**
* Handles increment next number of payment receive once be created.
*/