Repository navigation
Split a consolidation's carrier rate across its shipments by weight (#329) - #343
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slice 4 of #329: cost allocation.
Consolidation.carrierRateCents+currency.allocateConsolidationCostsplits the rate by each shipment's order weight (even when nothing is weighed), largest-remainder so the parts sum to the rate, as pendingcost/linehaulcharges (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. Emitscharge.createdper new share andconsolidation.cost_allocated.CreateChargeCommandinto a shared function.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