feat(FinancialReports): compute journal cost is running state.

This commit is contained in:
a.bouhuolia
2021-03-13 19:49:15 +02:00
parent 828f4bb32e
commit 88eaaa3968
27 changed files with 411 additions and 106 deletions

View File

@@ -2,25 +2,52 @@ import { Container } from 'typedi';
import { EventSubscriber, On } from 'event-dispatch';
import { map, head } from 'lodash';
import events from 'subscribers/events';
import TenancyService from 'services/Tenancy/TenancyService';
import SaleInvoicesCost from 'services/Sales/SalesInvoicesCost';
import InventoryItemsQuantitySync from 'services/Inventory/InventoryItemsQuantitySync';
import { InventoryTransaction } from 'models';
import InventoryService from 'services/Inventory/Inventory';
@EventSubscriber()
export class InventorySubscriber {
depends: number = 0;
startingDate: Date;
saleInvoicesCost: SaleInvoicesCost;
tenancy: TenancyService;
itemsQuantitySync: InventoryItemsQuantitySync;
inventoryService: InventoryService;
agenda: any;
/**
* Constructor method.
*/
constructor() {
this.saleInvoicesCost = Container.get(SaleInvoicesCost);
this.itemsQuantitySync = Container.get(InventoryItemsQuantitySync);
this.inventoryService = Container.get(InventoryService);
this.tenancy = Container.get(TenancyService);
this.agenda = Container.get('agenda');
}
/**
* Marks items cost compute running state.
*/
@On(events.inventory.onComputeItemCostJobScheduled)
async markGlobalSettingsComputeItems({
tenantId
}) {
await this.inventoryService.markItemsCostComputeRunning(tenantId, true);
}
/**
* Marks items cost compute as completed.
*/
@On(events.inventory.onInventoryCostEntriesWritten)
async markGlobalSettingsComputeItemsCompeted({
tenantId
}) {
await this.inventoryService.markItemsCostComputeRunning(tenantId, false);
}
/**
* Handle run writing the journal entries once the compute items jobs completed.
*/

View File

@@ -190,7 +190,9 @@ export default {
onComputeItemCostJobScheduled: 'onComputeItemCostJobScheduled',
onComputeItemCostJobStarted: 'onComputeItemCostJobStarted',
onComputeItemCostJobCompleted: 'onComputeItemCostJobCompleted'
onComputeItemCostJobCompleted: 'onComputeItemCostJobCompleted',
onInventoryCostEntriesWritten: 'onInventoryCostEntriesWritten'
},
/**