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 10 seconds |
| Source File | src/_cron/cron.service.ts |
Changelog
| Date | Author | Description |
|---|---|---|
order.sendTo = order.clientName — sendTo must not be overridden in any scenario |
Previous versions are preserved in Page Revisions (top-right menu → Revisions).
Current Logic
Schedule
EVERY_10_SECONDS
Task Input
The task value field (JSON):
{
"orderDocumentId": 123
}
Processing Flow
- Pick oldest Pending task and mark Running
- Parse
orderDocumentIdfrom task payload — if missing or 0, log warning and return - Within a single transaction:
- Step 1: Find
OrderDocumentbyorderDocumentId— if not found, log warning and return - Step 2: Find
CimaDeliveryInfobydeliveryOrderNumber = document.referenceKeyANDplateNo = document.plateNo— if not found, log error and return - Update
OrderDocument.documentStatus→Auto Approved - If order found: update Order fields
including(order.sendTo= order.clientName(unconditionalisoverride)not touched) - Step 3: Update
CimaDeliveryInfo.status→Completed; ifcimaInfo.saleOrderNois null, also setsaleOrderNo = order.saleOrderNo - Step 4: Insert record into
OrderJobTrackingLogwith actionCIMA Supplier Data Auto Update
- Step 1: Find
- Finally: update task status →
SuccessorFail
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 |