What a line records
A line is aCommissionLine record (id prefix comline). It points at exactly one of item_id or shipping_method_id, and it stores the rate it came from and the amount.
system provider:
code: the code of the winning rate, kept so the line stays readable if the rate is renamed or deletedrate: the percent for a percentage rate, or the fixed amount for a fixed rateamount: the commission for the line, computed withMathBNdescription:Shipping Commissionon shipping lines, empty on item linesprovider_id: the provider that computed the line,systemby defaultdata: free JSON a custom provider can fill
When lines are written
Mercur writes lines at checkout and rewrites them when the order’s contents change. Both paths runrefreshOrderCommissionLinesWorkflow:
A refresh resolves against the rates that exist when it runs. Changing a rate doesn’t touch existing lines until the order is refreshed again.
A refresh replaces, it doesn’t append
Computed lines carry noid. The module’s upsertCommissionLines first deletes every existing line whose item_id or shipping_method_id is in the new set, then inserts the new lines in the same transaction. Running a refresh twice leaves one line per item and shipping method.
How payouts use the lines
createOrderPayoutsWorkflow reads every commission line whose item_id or shipping_method_id belongs to the order. It sums their amount and pays the order total minus that sum to the seller’s payout account. A refund taken back later is reduced by its share of the same sum. With the lines from the overview figure, an order total of € 92.00 and commission of € 10.14 pays the seller € 81.86.