Skip to content

Split a consolidation's carrier rate across its shipments by weight (#329) - #343

Merged
Connor-Finn merged 1 commit into
mainfrom
tms/329-consolidation-costs
Oct 5, 2026
Merged

Connor-Finn merged 1 commit into
mainfrom
tms/329-consolidation-costs

Conversation

@Connor-Finn

Copy link
Copy Markdown
Collaborator

Slice 4 of #329: cost allocation.

  • Consolidation.carrierRateCents + currency.
  • allocateConsolidationCost splits the rate by each shipment's order weight (even when nothing is weighed), largest-remainder so the parts sum to the rate, as pending cost/linehaul charges (source: 'consolidation'), and recalculates each shipment's financial summary. Re-runs on rate/currency change, add, remove and draft archive; refused once a share is approved; refuses mixed currencies. Emits charge.created per new share and consolidation.cost_allocated.
  • Summary recalculation extracted from CreateChargeCommand into a shared function.
  • Run page: carrier rate field; weight, cost share and margin per shipment.

Tested live: $1,000 over 300 kg / 100 kg shipments gave $750 / $250 (margins $150 each); removing one moved the full rate to the other and deleted its share. Full backend suite (2486), tsc, lints pass.

🤖 Generated with Claude Code

…329)

A consolidation takes the carrier's rate for the whole run (integer cents).
allocateConsolidationCost splits it by each shipment's order weight (evenly
when nothing is weighed), in whole cents that sum to the rate, as a pending
cost charge per shipment sourced from the consolidation, and recalculates
each shipment's financial summary so its margin reflects its share. The split
re-runs when the rate or the shipments change and is fixed once a share is
approved. The run page shows each shipment's weight, cost share and margin.

The shipment summary recalculation moves out of CreateChargeCommand into a
shared function both use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Connor-Finn
Connor-Finn merged commit 8af4f49 into main Oct 5, 2026
@Connor-Finn
Connor-Finn deleted the tms/329-consolidation-costs branch October 5, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant