mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat(FinancialReports): compute journal cost is running state.
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
import { Container } from 'typedi';
|
||||
import {EventDispatcher} from "event-dispatch";
|
||||
// import {
|
||||
// EventDispatcher,
|
||||
// } from 'decorators/eventDispatcher';
|
||||
import events from 'subscribers/events';
|
||||
import InventoryService from 'services/Inventory/Inventory';
|
||||
|
||||
@@ -11,7 +8,7 @@ export default class ComputeItemCostJob {
|
||||
eventDispatcher: EventDispatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
* Constructor method.
|
||||
* @param agenda
|
||||
*/
|
||||
constructor(agenda) {
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
import { Container } from 'typedi';
|
||||
import {EventDispatcher} from "event-dispatch";
|
||||
import events from 'subscribers/events';
|
||||
import SalesInvoicesCost from 'services/Sales/SalesInvoicesCost';
|
||||
|
||||
export default class WriteInvoicesJournalEntries {
|
||||
eventDispatcher: EventDispatcher;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
*/
|
||||
constructor(agenda) {
|
||||
const eventName = 'rewrite-invoices-journal-entries';
|
||||
this.eventDispatcher = new EventDispatcher();
|
||||
|
||||
agenda.define(
|
||||
'rewrite-invoices-journal-entries',
|
||||
eventName,
|
||||
{ priority: 'normal', concurrency: 1 },
|
||||
this.handler.bind(this)
|
||||
);
|
||||
agenda.on(`complete:${eventName}`, this.onJobCompleted.bind(this));
|
||||
}
|
||||
|
||||
public async handler(job, done: Function): Promise<void> {
|
||||
@@ -36,4 +47,16 @@ export default class WriteInvoicesJournalEntries {
|
||||
done(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the job complete.
|
||||
*/
|
||||
async onJobCompleted(job) {
|
||||
const { startingDate, itemId, tenantId } = job.attrs.data;
|
||||
|
||||
await this.eventDispatcher.dispatch(
|
||||
events.inventory.onInventoryCostEntriesWritten,
|
||||
{ startingDate, itemId, tenantId }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user