fix: record authorized user id for customer/vendor opening balance.

This commit is contained in:
a.bouhuolia
2021-01-02 15:48:59 +02:00
parent 149464fa7a
commit faa81e3c25
7 changed files with 398 additions and 258 deletions

View File

@@ -22,13 +22,15 @@ export default class VendorsSubscriber {
* Writes the open balance journal entries once the vendor created.
*/
@On(events.vendors.onCreated)
async handleWriteOpeningBalanceEntries({ tenantId, vendorId, vendor }) {
async handleWriteOpeningBalanceEntries({ tenantId, vendorId, vendor, authorizedUser }) {
// Writes the vendor opening balance journal entries.
if (vendor.openingBalance) {
await this.vendorsService.writeVendorOpeningBalanceJournal(
tenantId,
vendor.id,
vendor.openingBalance,
vendor.openingBalanceAt,
authorizedUser.id
);
}
}
@@ -37,7 +39,7 @@ export default class VendorsSubscriber {
* Revert the opening balance journal entries once the vendor deleted.
*/
@On(events.vendors.onDeleted)
async handleRevertOpeningBalanceEntries({ tenantId, vendorId }) {
async handleRevertOpeningBalanceEntries({ tenantId, vendorId, authorizedUser }) {
await this.vendorsService.revertOpeningBalanceEntries(
tenantId, vendorId,
);
@@ -47,7 +49,7 @@ export default class VendorsSubscriber {
* Revert the opening balance journal entries once the vendors deleted in bulk.
*/
@On(events.vendors.onBulkDeleted)
async handleBulkRevertOpeningBalanceEntries({ tenantId, vendorsIds }) {
async handleBulkRevertOpeningBalanceEntries({ tenantId, vendorsIds, authorizedUser }) {
await this.vendorsService.revertOpeningBalanceEntries(
tenantId, vendorsIds,
);