Qeasy Cloud
Get Started

Reverse Historical Data Sync Playbook: Sales Refunds → Settlement Refund Vouchers

· 卢剑航· Integration Solutions· 4 views· 4 min read
GuanYi ERPKingdee Cloud供应链集成历史数据回灌退款单同步逆向同步

What This Strategy Solves

When a retail enterprise migrates its finance stack to Kingdee Cloud Stellar, the finance team often discovers that a large volume of historical sales refund documents still lives in Guanyi ERP. These must be back-filled into Kingdee as opening-period settlement refund vouchers. A pure incremental sync would leave the new system permanently short of history; a naive full sync risks duplicates. The safe approach is to fix a "reverse historical" window, batch-pull audited refunds from Guanyi month by month, and write them into Kingdee as settlement refund vouchers. This strategy is built exactly for that back-fill scenario.

Data Flow and Field Mapping

Data Flow: Guanyi ERP (source) → Qeasy Data Integration Platform (middleware) → Kingdee Cloud Stellar (target).

Key source-side parameters (API gy.erp.finance.billFlowList.get):

FieldMeaningValue
recordedTimeBeginPosting time startFirst day of previous month 00:00:00
recordedTimeEndPosting time endLast day of previous month 23:59:59
verifyStatusWrite-off statusEmpty = all
auditStatusAudit statusHard-coded 2 (audited)
pageSizePage size150 recommended

Key target-side fields (API batchSave, voucher type SKTKDLX01_SYS):

Source (Guanyi)Target (Kingdee)Note
codeFBillNoVoucher number passed through, used as idempotency key
recordedTimeFDATEBusiness date from posting time
shop.codeFSETTLEORGID / FSALEORGIDSettlement org and sales org from store code
FCONTACTUNITTYPEContact unit typeFixed to customer
Amount fieldsFRECAMOUNT / FREFUNDAMOUNTSplit by direction into receipt vs refund

The middleware is responsible for translating store codes into Kingdee org IDs and customer codes into Kingdee contact units. We strongly recommend maintaining a centralized "code mapping" table in Qeasy that all strategies share, rather than letting each strategy maintain its own copy.

How to Configure in Qeasy

  1. Create the source connection: register gy.erp.finance.billFlowList.get as a query-type data source against Guanyi ERP, with page size locked at 150.
  2. Create the target connection: register Kingdee's batchSave as an execute-type action and set voucher type SKTKDLX01_SYS as the default template.
  3. Field mapping and expressions: use Qeasy's drag-and-drop mapping panel for the table above; for idempotency keys like code and recordedTime, add a trim() in the expression to avoid dedup misses caused by whitespace.
  4. Dedup and idempotency: configure code as the unique key and enable Qeasy's "dedup by primary key" switch — re-running the same refund will not produce duplicates.
  5. Exception handling: enable retry (3 attempts, exponential backoff recommended); any non-zero response is written to an "exception pool" for manual follow-up.

Implementation Steps

We recommend splitting this strategy into a three-phase schedule:

  • Phase 1 — Incremental starting point. Before the first run, manually validate a one-month window, e.g., Sep 1 00:00:00 to Sep 30 23:59:59, and confirm there are no gaps in the source.
  • Phase 2 — Full back-fill trigger. Use Qeasy's "manual trigger + historical replay" mode to ingest the past several months at once. After each month completes, reconcile the voucher count in the target system before moving on.
  • Phase 3 — Schedule downgrade. Once history is back-filled, lower the strategy's crontab frequency or disable it; if remaining gaps need patching, switch to on-demand manual trigger to avoid polluting the future incremental path.

This "incremental start → full trigger → schedule downgrade" pattern is very common among Qeasy customers and prevents historical back-fill from disturbing daily increments.

Pitfalls We Have Seen

  1. Wrong audit status: leaving auditStatus empty pulls drafts alongside audited records, and Kingdee will reject them. Hard-code 2 and add a filter on the source side.
  2. Miscomputed window boundaries: a common trap is using DATE_SUB(CURDATE(), INTERVAL 1 MONTH) for "previous month," which can lose a day across boundaries like Mar/Apr or May/Jun. Use DATE_FORMAT(DATE_SUB(...),'%Y-%m-01') to explicitly pin the month start.
  3. Store code passed as org ID directly: Guanyi's shop.code is a short store name; Kingdee expects the org archive ID. Passing it raw will be rejected. Maintain a centralized "store code ↔ Kingdee org" mapping in Qeasy.
  4. Partial success in batchSave: Kingdee's batch save is atomic per batch — one bad record rolls the whole batch back. Split batches into smaller chunks (e.g., 50 per batch) inside Qeasy for precise failure isolation.
  5. Truncated idempotency keys: some Kingdee fields are length-sensitive; an over-long code gets truncated and duplicates slip in. Validate length in the mapping layer and hash-compress any value over 30 chars.

When to Use and When Not to Use

Use when: a retail or e-commerce enterprise is mid-ERP migration and needs to back-fill historical refunds into the new system as opening-period data, or when first connecting to Kingdee and a historical period needs to be reconstructed. Do not use when: the goal is daily incremental sync (build a separate forward strategy), or when sub-second single-document latency is required — batchSave's batch-oriented nature is not suited to millisecond-real-time delivery.


This "reverse historical data" strategy is essentially a one-time data migration. The success criteria are idempotency, traceability, and re-runnability — not throughput. Get mapping, dedup, and batching right in Qeasy, and the back-fill will be stable.

Original content. Please credit the source when reposting: https://www.qeasy.cloud/insights/solutions/strat-guanyi-kingdee-cloud-4203-n229ddf7d-8a61a6e3

Comments