Reverse Historical Data Sync Playbook: Sales Refunds → Settlement Refund Vouchers
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):
| Field | Meaning | Value |
|---|---|---|
| recordedTimeBegin | Posting time start | First day of previous month 00:00:00 |
| recordedTimeEnd | Posting time end | Last day of previous month 23:59:59 |
| verifyStatus | Write-off status | Empty = all |
| auditStatus | Audit status | Hard-coded 2 (audited) |
| pageSize | Page size | 150 recommended |
Key target-side fields (API batchSave, voucher type SKTKDLX01_SYS):
| Source (Guanyi) | Target (Kingdee) | Note |
|---|---|---|
| code | FBillNo | Voucher number passed through, used as idempotency key |
| recordedTime | FDATE | Business date from posting time |
| shop.code | FSETTLEORGID / FSALEORGID | Settlement org and sales org from store code |
| FCONTACTUNITTYPE | Contact unit type | Fixed to customer |
| Amount fields | FRECAMOUNT / FREFUNDAMOUNT | Split 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
- Create the source connection: register
gy.erp.finance.billFlowList.getas a query-type data source against Guanyi ERP, with page size locked at 150. - Create the target connection: register Kingdee's
batchSaveas an execute-type action and set voucher typeSKTKDLX01_SYSas the default template. - Field mapping and expressions: use Qeasy's drag-and-drop mapping panel for the table above; for idempotency keys like
codeandrecordedTime, add atrim()in the expression to avoid dedup misses caused by whitespace. - Dedup and idempotency: configure
codeas the unique key and enable Qeasy's "dedup by primary key" switch — re-running the same refund will not produce duplicates. - 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
crontabfrequency 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
- Wrong audit status: leaving
auditStatusempty pulls drafts alongside audited records, and Kingdee will reject them. Hard-code2and add a filter on the source side. - 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. UseDATE_FORMAT(DATE_SUB(...),'%Y-%m-01')to explicitly pin the month start. - Store code passed as org ID directly: Guanyi's
shop.codeis 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. - 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. - Truncated idempotency keys: some Kingdee fields are length-sensitive; an over-long
codegets 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.