mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
feat: writing journal entries of payment receive.
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user