Skip to main content

processCimaLorryInoutReports

Overview

A cron job that picks up queued tasks to parse uploaded CIMA Lorry In/Out Report files. On success, it triggers the next step in Flow A by creating an Auto Update CIMA Supplier Data By Supplier Data task.

Function processCimaLorryInoutReports
Task Code Process CIMA Lorry In_Out Report
Schedule Every 2 hours
Source File src/_cron/cron.service.ts

Changelog

Date Author Description
2026-02-25 sf Changed schedule from EVERY_10_SECONDS to every 2 hours (0 */2 * * *)

Previous versions are preserved in Page Revisions (top-right menu → Revisions).


Current Logic

Schedule

0 */2 * * * (every 2 hours)

Processing Flow

Every 2 hours
  │
  └─ Fetch ALL Pending tasks where code = 'Process CIMA Lorry In_Out Report'
       └─ If none → return early
  │
  └─ Bulk mark all fetched tasks → Running
  │
  └─ For each task:
       │
       ├─ Parse value: { cima_lorry_in_out_report_id }
       ├─ Find CimaLorryInOutReport by id
       │    └─ If not found → skip (no status update, no error logged)
       │
       ├─ Call cimaLorryInOutReportService.processCimaLorryInOutReport(inOutReport)
       │    └─ Parses file → populates CimaDeliveryInfo records
       │
       ├─ On success (result = true):
       │    ├─ Mark task → 'Success'
       │    └─ Creates MicroserviceTask:
       │         code: 'Auto Update CIMA Supplier Data By Supplier Data'
       │         (picked up by autoUpdateCIMASupplierDataBySupplierData on next 10-min run)
       │
       └─ On failure (result = false or exception):
            └─ Mark task → 'Fail'

Task Input

{
  "cima_lorry_in_out_report_id": 123
}

Notes

  • Tasks are bulk-marked Running before the loop — not per-task. If the server crashes mid-loop, remaining tasks stay as Running and are never retried.
  • If CimaLorryInOutReport record is not found, the task is silently skipped with no status update (stays Running indefinitely).
  • On success, immediately chains to autoUpdateCIMASupplierDataBySupplierData via a new microservice task.