- fix: Schedule write journal entries after item compute cost.

- fix: active vouchers query.
- fix: remove babel loader in server-side.
This commit is contained in:
Ahmed Bouhuolia
2020-08-29 22:11:42 +02:00
parent e4270dc039
commit 74321a2886
12 changed files with 217 additions and 104 deletions

View File

@@ -348,10 +348,18 @@ export default class BillsService extends SalesInvoicesCost {
* @param {IBill} bill
* @return {Promise}
*/
static scheduleComputeBillItemsCost(bill) {
return this.scheduleComputeItemsCost(
bill.entries.map((e) => e.item_id),
bill.bill_date,
);
static async scheduleComputeBillItemsCost(bill) {
const billItemsIds = bill.entries.map((entry) => entry.item_id);
// Retrieves inventory items only.
const inventoryItems = await Item.tenant().query()
.whereIn('id', billItemsIds)
.where('type', 'inventory');
const inventoryItemsIds = inventoryItems.map(i => i.id);
if (inventoryItemsIds.length > 0) {
await this.scheduleComputeItemsCost(inventoryItemsIds, bill.bill_date);
}
}
}