feat: Schedule to compute items cost.

This commit is contained in:
Ahmed Bouhuolia
2020-08-19 01:30:12 +02:00
parent 52d01b4ed8
commit c2a60e6ba5
4 changed files with 175 additions and 175 deletions

View File

@@ -4,13 +4,14 @@ import InventoryService from '@/services/Inventory/Inventory';
export default class ComputeItemCostJob {
public async handler(job, done: Function): Promise<void> {
const Logger = Container.get('logger');
const { startingDate, itemId, costMethod } = job.attrs.data;
const { startingDate, itemId, costMethod = 'FIFO' } = job.attrs.data;
try {
await InventoryService.computeItemCost(startingDate, itemId, costMethod);
Logger.log(`Compute item cost: ${job.attrs.data}`);
done();
} catch(e) {
console.log(e);
Logger.error(`Compute item cost: ${job.attrs.data}, error: ${e}`);
done(e);
}