Purchase Receipt Reversal Sync in Practice: One-Way Integration from JKY to Kingdee Cloud Sky
What This Strategy Solves
A retail company running a private deployment uses JKY as the front-end business system and Kingdee Cloud Sky as the back-end finance and inventory ledger. When a purchase receipt is reversed, the numbers often drift: JKY marks the document as reversed while Kingdee Cloud Sky still holds the original positive receipt, causing gaps between the inventory account and the finance account. This strategy does one thing only — it pulls reversed purchase receipt documents from JKY incrementally and writes them into Kingdee Cloud Sky as the corresponding red-letter documents, keeping both sides aligned.
Data Flow and Field Mapping
The flow is one-way: JKY → Qeasy Data Integration Platform → Kingdee Cloud Sky. The source side uses a query API to pull increments by time window; the target side uses batchSave to write. We use a table to clarify the key field mapping:
| Business Meaning | Source (JKY) | Middle-Layer Variable | Target (Kingdee Cloud Sky) |
|---|---|---|---|
| Document Number | goodsdocNo | {{goodsdocNo}} | FJKYNo (JKY number written back) |
| Business Date | inOutDate | {{inOutDate}} | FDate |
| Supplier | vendCustomerCode | {{vendCustomerCode}} | FSupplierID |
| Warehouse | warehouseCode | {{warehouseCode}} | FStockID (via mapping) |
| Reversal Flag | redStatus | conditional branch | controls write direction |
| Material Code | goodsDocDetailList.goodsNo | loop variable | FMaterialID (via mapping) |
| Quantity | goodsDocDetailList.quantity | loop variable | FQty (with sign) |
| Cost | goodsDocDetailList.estCost | loop variable | FPrice |
The code mapping must be managed centrally. In Qeasy we maintain a dedicated "Code Mapping Table" that maps JKY's material codes, supplier codes, and warehouse codes to Kingdee Cloud Sky's base data IDs. This is the prerequisite for the finance ledger to close properly.
How to Configure in Qeasy
Source configuration: API erp.storage.goodsdocin.v2, POST request, pagination pageSize=50, time window from {{LAST_SYNC_TIME}} to {{CURRENT_TIME}}, only select the required return fields — never pull the full table. In the request header, set idCheck=true so the platform uses the document number as the idempotency key.
Target configuration: API batchSave on Kingdee Cloud Sky, document type corresponds to reversed purchase receipt. In the request body, FJKYNo is bound directly to {{goodsdocNo}} for future traceability; FDate binds to {{inOutDate}}; the body writes in a loop, each line carrying material, quantity, and cost.
A few typical configuration points:
- Idempotency key: The source
goodsdocNois the unique identifier; combined with Qeasy'sidCheck, repeated execution of the same document will not create duplicates. - Time variables: Use
LAST_SYNC_TIMErather than a hard-coded date to avoid missed and duplicate records. - Field minimization: The source
selelctFieldsshould only include business-required fields. Pull less whenever possible — the performance difference is noticeable. - Error retry: Qeasy retries network-class errors by default; business-class errors go to the exception queue and require manual intervention.
Implementation Steps
We advance in three phases — this is the safe approach:
Phase 1: Align the incremental starting point. Manually specify a LAST_SYNC_TIME (usually 23:59:59 of the day before the first run), run one incremental pass, and confirm that document numbers, amounts, and materials match on both sides.
Phase 2: Full-volume trigger and backfill. If needed, switch to full-volume mode and backfill historical reversed documents into Kingdee Cloud Sky at once. In Qeasy we temporarily widen the time window, then immediately switch back to incremental after the run. Running incremental and full-volume on parallel tracks is a common pattern for handling legacy data.
Phase 3: Scheduling frequency and monitoring. The source schedules 3 6-23/2 * * * (minute 3, every 2 hours from 06:00 to 23:00); the target schedules 20 */2 * * * (minute 20, every 2 hours). The source pulls first, the target writes later — leaving a window for transformation and mapping. After running for a while, review Qeasy's run logs and resolve exception documents one by one.
Lessons Learned
These are the places where we actually got burned:
- Reversal flag not transmitted. An early version missed the
redStatusfield, causing positive receipts to be written into Kingdee Cloud Sky as red-letter documents, flipping inventory negative. The safe approach is to always select the field on the source side and add a conditional check in the transformation layer. - Code mapping scattered across scripts. In v1 the mapping logic was written into transformation scripts. When a material code changed later, we had to search everywhere. After centralizing the mapping, maintenance cost dropped by half.
- Hard-coded time window. Running with a fixed date caused missed records across year or month boundaries. Always use the platform's time variables.
- Header and body processed together causing partial failures. When the header succeeded but one body line failed, the entire document ended up in an inconsistent state. The safe approach is to commit header and body in separate stages and roll back the whole document if the body fails.
- Ignoring the finance status field. Not checking
financeBillStatuscaused already-posted documents downstream to be rolled back. We recommend checking this field before sync; posted documents should go through a special channel.
Applicable and Non-Applicable Scenarios
Applicable: one-way integration, private deployment, low frequency of purchase receipt reversals, T+1 reconciliation requirements. Not applicable: two-way sync, real-time inventory linkage needs, or scenarios where Kingdee Cloud Sky documents are heavily manually edited — the latter will break the idempotency logic.