Learn from existing rules

TL;DR

Read the seeded rules as worked examples, and understand what they do and do not tell you.

Goal: understand the shapes a rule can take by reading ones that already exist.

The seeds are configured intent, not live configuration. They show how a rule is built. They are not a snapshot of what is active in production, and their rates are not a tariff reference.

Two kinds of seed

Value matrices, as delimited files: one rule per row, one shape per file. Commission per sales channel; payment fee per method and currency; shipping cost per shipper and country. Read one row and you understand the whole file.

Everything else, as structured rules carrying their own filter groups and impact entries, for shapes a matrix cannot express.

Both resolve their references by natural key rather than by id, because ids differ between installations.

The pairs worth studying

Four of the matrix files pair up, and the pairing teaches the most:

PairDiffer only in
Payment and payment refundThe transaction type: prepayment against credit memo
Shipping and shipping returnThe transaction type: invoice against return authorization

Same account, same impact shape, different transaction. That is the cleanest illustration of why the transaction type is the first thing you choose.

Commission stands alone, and takes its window from the seeder rather than per row.

Two details that look like mistakes

An empty method or currency means the rule does not filter on that field, and the rule's name drops that part with it. One refund row is like this today: a single rate on every credit memo, waiting to be split per method.

Its percentage is negative on purpose. The credit memo amount is already negative, so a positive percentage would credit margin instead of costing it. Worked through in calculation rules.

Expected result

You can name, for any seeded rule, what it matches, what it books, and why its sign is what it is.

Evidence

Seed shapes, the pairing and the natural-key resolution from AGENTS.md, Configuration and .env, and the files under config/seed/cm_calculationrules/. The seeded rates are current commercial terms, confirmed by the data owner. Basis: code-checked at 30f5313.

About this document
  • Type
    guide
  • Status
    active
  • Updated
    2026-09-14
  • Created
    2026-09-13