Skip to main content

createMsRpaDownloadCimaLorryInOut

Version: Draft — Changes pending production deployment.


Overview

A cron job that runs every 2 hours to instruct the RPA to download CIMA Lorry In/Out reports (TRN and DST) from the CIMA portal. It creates two MicroserviceTasks that the RPA picks up, downloads the reports, and uploads them via POST /cimaLorryInOutReports/createWithFile.

Function createMsRpaDownloadCimaLorryInOut
Task Codes Download CIMA TRN Report, Download CIMA DST Report
Schedule Every 2 hours
Source File src/_cron/cron.service.ts

Changelog

Date Author Description
2026-02-25 sf Changed schedule from daily 6:00 AM MYT to every 2 hours; changed deliveryDateFrom from -7 days to -1 day to tighten the date range

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


Current Logic

Schedule

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

Processing Flow

Every 2 hours
  │
  └─ Compute date range (Malaysia timezone):
       deliveryDateTo   = today (dd/MM/yyyy)
       deliveryDateFrom = yesterday (dd/MM/yyyy)   ← -1 day
  │
  └─ Create 2 MicroserviceTasks in parallel:
       ┌─ code: 'Download CIMA TRN Report'
       │   value: { deliveryDateFrom, deliveryDateTo,
       │             productForm: 'Bulk', reportCode: 'TRN-DL01b' }
       │
       └─ code: 'Download CIMA DST Report'
           value: { deliveryDateFrom, deliveryDateTo,
                    productForm: 'Bulk', reportCode: 'DST-DL01' }
  │
  └─ RPA picks up tasks → downloads reports from CIMA portal
       └─ Calls POST /cimaLorryInOutReports/createWithFile
            └─ afterCreate hook → creates 'Process CIMA Lorry In_Out Report' task

Task Value Format

{
  "deliveryDateFrom": "24/02/2026",
  "deliveryDateTo":   "25/02/2026",
  "productForm":      "Bulk",
  "reportCode":       "TRN-DL01b"
}

Notes

  • referenceId is set to today's date in dd/MM/yyyy format for traceability.
  • Both tasks are created concurrently via Promise.all.
  • Date format uses Luxon dd/LL/yyyy (Malaysia local time via Asia/Kuala_Lumpur zone).