mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
feat(FinancialReports): compute journal cost is running state.
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -190,7 +190,9 @@ export default {
|
||||
|
||||
onComputeItemCostJobScheduled: 'onComputeItemCostJobScheduled',
|
||||
onComputeItemCostJobStarted: 'onComputeItemCostJobStarted',
|
||||
onComputeItemCostJobCompleted: 'onComputeItemCostJobCompleted'
|
||||
onComputeItemCostJobCompleted: 'onComputeItemCostJobCompleted',
|
||||
|
||||
onInventoryCostEntriesWritten: 'onInventoryCostEntriesWritten'
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user