feat: average rate cost method.

This commit is contained in:
a.bouhuolia
2020-12-22 22:27:54 +02:00
parent c327c79612
commit 061b50c671
21 changed files with 787 additions and 409 deletions

View File

@@ -117,7 +117,8 @@ export default class BillSubscriber {
this.logger.info('[bill] writing the inventory transactions', { tenantId });
this.billsService.recordInventoryTransactions(
tenantId,
bill,
bill.id,
bill.billDate,
);
}
@@ -129,7 +130,8 @@ export default class BillSubscriber {
this.logger.info('[bill] overwriting the inventory transactions.', { tenantId });
this.billsService.recordInventoryTransactions(
tenantId,
bill,
bill.id,
bill.billDate,
true,
);
}
@@ -145,4 +147,19 @@ export default class BillSubscriber {
billId,
);
}
/**
* Schedules items cost compute jobs once the inventory transactions created
* of the bill transaction.
*/
@On(events.bill.onInventoryTransactionsCreated)
public async handleComputeItemsCosts({ tenantId, billId }) {
this.logger.info('[bill] trying to compute the bill items cost.', {
tenantId, billId,
});
await this.billsService.scheduleComputeBillItemsCost(
tenantId,
billId,
);
}
}