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 |
| 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
(every 3 minutes)EVERY_10_SECONDS*/3 * * * *
Task Input
The task value field (JSON):
{
"orderDocumentId": 123
}
Processing Flow
Pick3oldestminutesPending│ └─ getTaskToProcess('Auto Update CIMA Supplier Data') └─ If no taskand→markreturnRunningearly
- │
└─ Parse
orderDocumentIdfrom task payload—└─ifIf missing or0,0 → log warning and return Within│a└─ executeInRunner (singletransactiontransaction):- │
- ├─ Step 1:
OrderDocumentbyorderDocumentId—│if└─ If notfound,found → log warning and return- │
├─ Step 2: Find
CimaDeliveryInfobywhere│ deliveryOrderNumber = document.referenceKeyAND│plateNo = document.plateNo—│if└─ If notfound,found → log error and return - │
├─ Update
OrderDocument.documentStatus→'AutoApprovedApproved'
- │
├─ Find Order by document.orderId
│ └─ If
orderfoundfound:→ update Order fields (sendToisnotNOT touched) - │
├─ Step 3: Update
→CimaDeliveryInfo.CimaDeliveryInfo: │ statusCompleted;'Completed'if│cimaInfo.saleOrderNois null, also setsaleOrderNo = order.saleOrderNo - (only if cimaInfo.saleOrderNo is null)
│
└─ Step 4: Insert
recordintoOrderJobTrackingLogwithaction:action'CIMA Supplier Data AutoUpdateUpdate'
│
└─ Finally:finally: update task status →'Success' orSuccessFail'Fail'
Every
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 |