Normalize allocation_value to integer cents #16
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
allocation_valueis stored asdecimal:2(dollars) while all other currency fields (starting_amount,Draw.amount,Inflow.amount,Outflow.amount) are stored as integers (cents). This unit mismatch causesPipelineAllocationServiceto treatgetEffectiveCapacity()(dollars) as cents, producing wildly incorrect allocations (e.g., a $500 bucket only receives $5).The preview endpoint (#12) surfaces this bug directly — users see wrong amounts.
Approach
Convert
allocation_valueto integer (cents) storage. All backend calculations happen on cent amounts. Only the API response layer converts cents→dollars (on the way out) and request handlers convert dollars→cents (on the way in).Scope
allocation_valuefromdecimal(10,2)tounsignedBigInteger, multiply existing values by 100'decimal:2'to'integer', updategetEffectiveCapacity()to return centsfixedLimit()andpercentage()values to centsStoreBucketRequest/UpdateBucketRequestrules (accept dollars from frontend, convert to cents)allocation_valueas dollars (divide by 100)calculateFixedAllocationandcalculatePercentageAllocationremainingCapacity()— should be clean once units are consistentallocation_valueAcceptance criteria
PipelineAllocationServiceproduces correct allocations (e.g., $500 bucket receives $500 from a $3000 income, not $5)