Qeasy Cloud
Get Started

Sales Outbound Red-Stub to Kingdee Cloud Sales Return: A Single-Strategy Sync Playbook

· 谢锴斌· Integration Solutions· 11 views· 3 min read
吉客云Kingdee Cloud销售出库红字单据轻易云供应链集成私有化部署

What This Strategy Solves

A retail enterprise generates a large volume of sales outbound documents every day. Among them are normal blue-stub outbounds and, just as importantly, red-stub outbounds caused by returns, rejections, and mis-shipments. If red-stub documents are naively treated as ordinary outbounds, the downstream ERP will mis-handle inventory direction, receivables, and tax logic. What this strategy does is identify red-stub outbounds upstream and rewrite them as sales return vouchers in the downstream ERP, so that books and reality stay aligned and traceable.

Data Flow and Field Mapping

The flow is one-way: upstream → middleware (Qeasy) → downstream ERP. Upstream is pulled incrementally via a WebAPI; Qeasy handles field cleansing, code mapping, and organization resolution; downstream is written through a batchSave call into the sales return voucher.

Key field mapping (sanitized):

Business MeaningUpstream FieldDownstream FieldConversion Note
Document No.goodsdocNoidRequired, idempotency key
Outbound DateinOutDateFDatePass-through
Red/Blue Flaginouttype(Branch)Only red stubs, mapped to returns
Owner TypeownerTypeIdFOwnerTypeIdHeadDictionary mapping
Customer CodechannelCodeFRetcustIdResolved via mapping table
Sales OrgFBelongOrgIdFSaleOrgIdReverse-looked-up by customer + org
Stock OrgownerNameFStockOrgIdTaken from upstream line owner
Doc Type(Fixed)FBillTypeIDFixed as sales return doc type code

How to Configure in Qeasy

We use Qeasy to host this pipeline. Configuration is split into three parts:

  1. Source endpoint: API erp.storage.goodsdocout.v2, POST method, incremental window bound to system variables LAST_SYNC_TIME and CURRENT_TIME, pagination via pageIndex / pageSize, document number as idempotency key, idCheck enabled.
  2. Target endpoint: API batchSave, request body built per the downstream sales return voucher model. The three required fields (doc type, sales org, return customer) are sourced from the mapping table or upstream fields.
  3. Transformation scripts: Cross-system code mappings (upstream code → downstream code) are maintained centrally in mapping tables — this is a common Qeasy customer pattern: centralized code mapping, avoiding redundant definitions in every strategy.

Implementation Steps

We recommend a three-phase rollout:

  • Incremental baseline: First run a manual trigger with the "red-stub + document status" filter to verify the end-to-end flow and confirm there is no red/blue confusion.
  • Full backfill: On go-live day, widen the time window to backfill historical red-stub documents, then immediately switch back to incremental mode.
  • Scheduling cadence: The source runs on a high-frequency schedule 1 6-23/2 * * * (every 2 hours from 6 AM to 11 PM); the target writes once a day at 20 3 * * *. This is the dual-track pattern of incremental plus batch: high-frequency pull for increments, low-frequency batch write to avoid downstream table locking at night.

Pitfalls From the Field

  1. Red and blue mixed together: The upstream response typically contains both red and blue stubs; this is a classic trap. The robust approach is to filter for red stubs at the source side, not at the downstream.
  2. Customer code not found: Downstream FRetcustId must be the downstream ERP's own customer code; passing the upstream code will always fail. In Qeasy we use _mongoQuery for centralized mapping, with the customer master sync strategy running ahead of this one.
  3. Sales org many-to-one: One upstream customer may map to multiple downstream sales orgs; lookup by customer alone is not enough. We changed the rule to a joint reverse lookup by "customer code + stock org" to guarantee uniqueness.
  4. Return date earlier than outbound date: Upstream sometimes writes inOutDate as the approval date instead of the original outbound date, breaking downstream period logic. We added a date sanity check in the transformation layer that raises an alert if the gap exceeds 30 days from the original voucher.
  5. Idempotency key collision: If upstream re-pushes the same red-stub document, the downstream rejects it as a duplicate document number. Even with idCheck enabled, an explicit dedup at the transformation layer is still needed.

When to Use and When Not To

Use when: Upstream clearly distinguishes red and blue stubs, downstream ERP must carry negative business via a dedicated sales return voucher, and reconciliation is required at hourly granularity — typical retail, e-commerce, and wholesale scenarios.

Do not use when: Upstream does not distinguish red and blue stubs, or the downstream has no dedicated sales return voucher type (and red-stub outbounds are used as a workaround); also unsuitable for very high-volume, second-level-latency traffic, where a message bus beats scheduled polling.

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

Comments