fix: re-schedule the jobs have date from the current moment

This commit is contained in:
Ahmed Bouhuolia
2024-08-29 10:05:38 +02:00
parent b87321c897
commit 84a0b8f495
2 changed files with 7 additions and 2 deletions

View File

@@ -157,7 +157,6 @@ export default class InventoryService {
...commonJobsQuery,
'data.startingDate': { $gte: startingDate },
});
// If the depends jobs cleared.
if (dependsJobs.length === 0) {
await agenda.schedule(
@@ -174,6 +173,13 @@ export default class InventoryService {
events.inventory.onComputeItemCostJobScheduled,
{ startingDate, itemId, tenantId } as IInventoryItemCostScheduledPayload
);
} else {
// Re-schedule the jobs that have higher date from current moment.
await Promise.all(
dependsJobs.map((job) =>
job.schedule(config.scheduleComputeItemCost).save()
)
);
}
}

View File

@@ -6,7 +6,6 @@ import {
ISaleInvoiceEditedPayload,
} from '@/interfaces';
import { SaleInvoiceGLEntries } from '@/services/Sales/Invoices/InvoiceGLEntries';
import { runAfterTransaction } from '@/services/UnitOfWork/TransactionsHooks';
@Service()
export default class SaleInvoiceWriteGLEntriesSubscriber {