Qeasy Cloud
Get Started

Purchase Receipt Reversal Sync in Practice: One-Way Integration from JKY to Kingdee Cloud Sky

· 钟家寿· Integration Solutions· 11 views· 4 min read
吉客云Kingdee Cloud供应链集成采购入库红冲单据轻易云

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 MeaningSource (JKY)Middle-Layer VariableTarget (Kingdee Cloud Sky)
Document NumbergoodsdocNo{{goodsdocNo}}FJKYNo (JKY number written back)
Business DateinOutDate{{inOutDate}}FDate
SuppliervendCustomerCode{{vendCustomerCode}}FSupplierID
WarehousewarehouseCode{{warehouseCode}}FStockID (via mapping)
Reversal FlagredStatusconditional branchcontrols write direction
Material CodegoodsDocDetailList.goodsNoloop variableFMaterialID (via mapping)
QuantitygoodsDocDetailList.quantityloop variableFQty (with sign)
CostgoodsDocDetailList.estCostloop variableFPrice

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 goodsdocNo is the unique identifier; combined with Qeasy's idCheck, repeated execution of the same document will not create duplicates.
  • Time variables: Use LAST_SYNC_TIME rather than a hard-coded date to avoid missed and duplicate records.
  • Field minimization: The source selelctFields should 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:

  1. Reversal flag not transmitted. An early version missed the redStatus field, 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.
  2. 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.
  3. Hard-coded time window. Running with a fixed date caused missed records across year or month boundaries. Always use the platform's time variables.
  4. 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.
  5. Ignoring the finance status field. Not checking financeBillStatus caused 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.

Original content. Please credit the source when reposting: https://www.qeasy.cloud/insights/solutions/strat-p2ea595-kingdee-cloud-5924-nf202895c-441b2722

Comments