autoUpdateCIMASupplierData
Overview
A cron job that processes a queued task to sync CIMA supplier delivery data into a specific order document and its associated order. Unlike the autoUpdateCIMASupplierDataBySupplierData sibling, this function is triggered per order document (one task = one document).
| Function | autoUpdateCIMASupplierData |
| Task Code | Auto Update CIMA Supplier Data |
| Schedule | Every 3 minutes |
| Source File | src/_cron/cron.service.ts |
Changelog
| Date | Author | Description |
|---|---|---|
| 2026-02-25 | sf | Removed order.sendTo = order.clientName — sendTo must not be overridden in any scenario |
| 2026-02-25 | sf | Changed schedule from EVERY_10_SECONDS to every 3 minutes (*/3 * * * *) |
Previous versions are preserved in Page Revisions (top-right menu → Revisions).
Current Logic
Schedule
*/3 * * * * (every 3 minutes)
Task Input
The task value field (JSON):
{
"orderDocumentId": 123
}
Processing Flow
Every 3 minutes
│
└─ getTaskToProcess('Auto Update CIMA Supplier Data')
└─ If no task → return early
│
└─ Parse orderDocumentId from task payload
└─ If missing or 0 → log warning and return
│
└─ executeInRunner (single transaction):
│
├─ Step 1: Find OrderDocument by orderDocumentId
│ └─ If not found → log warning and return
│
├─ Step 2: Find CimaDeliveryInfo where
│ deliveryOrderNumber = document.referenceKey
│ plateNo = document.plateNo
│ └─ If not found → log error and return
│
├─ Update OrderDocument.documentStatus → 'Auto Approved'
│
├─ Find Order by document.orderId
│ └─ If found → update Order fields (sendTo is NOT touched)
│
├─ Step 3: Update CimaDeliveryInfo:
│ status → 'Completed'
│ saleOrderNo = order.saleOrderNo (only if cimaInfo.saleOrderNo is null)
│
└─ Step 4: Insert into OrderJobTrackingLog
action: 'CIMA Supplier Data Auto Update'
│
└─ finally: update task status → 'Success' or 'Fail'
Order Fields Updated
| Field | Source |
|---|---|
| actualLoadedQuantity | cimaInfo.netWeight |
| grossWeight | cimaInfo.grossWeight |
| netWeight | cimaInfo.netWeight |
| tareWeight | cimaInfo.tareWeight |
| sealNumber | cimaInfo.sealNo |
| supplierDoDatetime | cimaInfo.deliveryDatetime |
| supplierDoPlateNo | cimaInfo.plateNo |
| deliveryOrderNumber | cimaInfo.deliveryOrderNumber |
| updatedBy | System |
sendTois not updated — preserved from original order value.
CimaDeliveryInfo Fields Updated
| Field | Condition | Value |
|---|---|---|
| status | always | Completed |
| saleOrderNo | only if cimaInfo.saleOrderNo is null |
order.saleOrderNo |
Key Differences vs Sibling Function
autoUpdateCIMASupplierData |
autoUpdateCIMASupplierDataBySupplierData |
|
|---|---|---|
| Trigger | Per orderDocumentId (one task = one doc) |
Batch — all Pending CimaDeliveryInfo |
| OrderDocument lookup | By id (direct) |
By referenceKey + plateNo + autoUpdateFor |
| OrderDocument status | Always set to Auto Approved |
Only set if Pending Auto Update (CIMA) |
| saleOrderNo backfill | Yes — if cimaInfo.saleOrderNo is null | No |