autoUpdateCIMASupplierDataBySupplierData
Version: Draft — Changes pending production deployment.
Overview
A cron job that processes queued tasks to sync CIMA supplier delivery data into the Order table. It matches CIMA records against order documents and updates order fields with the supplier-provided data.
| Function | autoUpdateCIMASupplierDataBySupplierData |
| Task Code | Auto Update CIMA Supplier Data By Supplier Data |
| Schedule | Every 10 minutes |
| Source File | src/_cron/cron.service.ts |
Changelog
| Date | Author | Description |
|---|---|---|
| 2026-02-25 | sf | Fixed transaction scope, added null guards, added plateNo matching, restored schedule to 10 min, removed sendTo override, added deliveryDatetime 1-month filter |
Previous versions are preserved in Page Revisions (top-right menu → Revisions).
Current Logic
Schedule
EVERY_10_MINUTES
Processing Flow
Every 10 min
└─ getTaskToProcess('Auto Update CIMA Supplier Data By Supplier Data')
└─ If task found:
│
├─ Step 1: Fetch CimaDeliveryInfo where
│ status = 'Pending'
│ deliveryDatetime >= now - 1 month
│ ORDER BY id ASC
│
└─ For each supplierData — each in its OWN transaction:
│
├─ Step 2: Find OrderDocument where
│ referenceKey = supplierData.deliveryOrderNumber
│ autoUpdateFor = 'CIMA'
│ plateNo = supplierData.plateNo
│
├─ If NOT found → log warning and skip
│
├─ If found, check documentStatus:
│ Allowed: 'Approved' | 'Auto Approved' | 'Pending Auto Update (CIMA)'
│ Otherwise → log debug and skip
│
├─ Find Order by orderDocument.orderId
├─ If NOT found → log warning and skip (Steps 4–6 not executed)
│
├─ Step 3: Update Order fields:
│ actualLoadedQuantity = supplierData.netWeight
│ grossWeight, netWeight, tareWeight
│ sealNumber = supplierData.sealNo
│ supplierDoDatetime = supplierData.deliveryDatetime
│ supplierDoPlateNo = supplierData.plateNo
│ deliveryOrderNumber = supplierData.deliveryOrderNumber
│ (sendTo is NOT overridden)
│
├─ Step 4: Update CimaDeliveryInfo.status → 'Completed'
│
├─ Step 5: If documentStatus = 'Pending Auto Update (CIMA)'
│ → Update OrderDocument.documentStatus → 'Auto Approved'
│ (skipped if already 'Approved' or 'Auto Approved')
│
└─ Step 6: Log to OrderJobTrackingLog
action: 'CIMA Supplier Data Auto Update by Supplier Data'
└─ finally: update task status → 'Success' or 'Fail'
Allowed documentStatus values
ApprovedAuto ApprovedPending Auto Update (CIMA)
Order Fields Updated
| Field | Source |
|---|---|
| actualLoadedQuantity | supplierData.netWeight |
| grossWeight | supplierData.grossWeight |
| netWeight | supplierData.netWeight |
| tareWeight | supplierData.tareWeight |
| sealNumber | supplierData.sealNo |
| supplierDoDatetime | supplierData.deliveryDatetime |
| supplierDoPlateNo | supplierData.plateNo |
| deliveryOrderNumber | supplierData.deliveryOrderNumber |
| updatedBy | System |
sendTois not updated — preserved from original order value.