fix: writing inventory transactions on invoice and bill created.

This commit is contained in:
a.bouhuolia
2020-12-19 19:48:38 +02:00
parent 5f8ecddd62
commit 1e8b00d8fe
7 changed files with 145 additions and 41 deletions

View File

@@ -108,4 +108,41 @@ export default class BillSubscriber {
oldBill.vendorId
);
}
/**
* Handles writing the inventory transactions once bill created.
*/
@On(events.bill.onCreated)
async handleWritingInventoryTransactions({ tenantId, bill }) {
this.logger.info('[bill] writing the inventory transactions', { tenantId });
this.billsService.recordInventoryTransactions(
tenantId,
bill,
);
}
/**
* Handles the overwriting the inventory transactions once bill edited.
*/
@On(events.bill.onEdited)
async handleOverwritingInventoryTransactions({ tenantId, bill }) {
this.logger.info('[bill] overwriting the inventory transactions.', { tenantId });
this.billsService.recordInventoryTransactions(
tenantId,
bill,
true,
);
}
/**
* Handles the reverting the inventory transactions once the bill deleted.
*/
@On(events.bill.onDeleted)
async handleRevertInventoryTransactions({ tenantId, billId }) {
this.logger.info('[bill] reverting the bill inventory transactions', { tenantId, billId });
this.billsService.revertInventoryTransactions(
tenantId,
billId,
);
}
}