Skip to content

Fix price edge cases in BOM table#1

Open
MayNiklas wants to merge 2 commits intowhinis:add-bom-pricefrom
MayNiklas:my-add-bom-price
Open

Fix price edge cases in BOM table#1
MayNiklas wants to merge 2 commits intowhinis:add-bom-pricefrom
MayNiklas:my-add-bom-price

Conversation

@MayNiklas
Copy link
Copy Markdown

This PR addresses two edge cases discussed in Part-DB#1221:

  1. Prices below minimum order amount show as 0.00€

When a BOM entry quantity is lower than a part's minimum order amount, calculateAvgPrice() returns null (no price tier matches), causing the price to fall back to zero. This fix uses the minimum order amount as a floor for the price lookup, so the price of the smallest orderable quantity is shown instead.

  1. Very small prices display as 0.00€

Prices were previously truncated to 2 decimal places, so parts costing e.g. 0.004€ would display as 0.00€ — implying they are free. Prices are now rounded up (RoundingMode::UP) before display.

This also fixes a bug in the ext_price column where the quantity multiplication was lost during the rounding refactor — it now uses BigDecimal::multipliedBy() to preserve full precision before rounding.

Feel free to merge this PR - this way my changes would be appended to Part-DB#1221 :)

When a part has a minimum order amount greater than the BOM quantity,
calculateAvgPrice previously returned null (no price tier matched),
causing the price to fall back to zero. Now the minimum order amount
is used as a floor for the price lookup so a realistic price is shown.
Very small but non-zero prices would previously display as 0.00€ due to
truncation. Prices are now rounded up (RoundingMode::UP) to 2 decimal
places before display, so a part that costs e.g. 0.001€ shows as 0.01€.

It also now uses BigDecimal::multipliedBy() to keep full precision before rounding.
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