Add price columns to project BOM table and build price summary#1345
Merged
jbtronics merged 6 commits intoPart-DB:masterfrom Apr 15, 2026
Merged
Add price columns to project BOM table and build price summary#1345jbtronics merged 6 commits intoPart-DB:masterfrom
jbtronics merged 6 commits intoPart-DB:masterfrom
Conversation
Adds two optional columns to the project BOM datatable (hidden by default, toggleable via column visibility): - **Price**: unit price for the BOM entry in the base currency, looked up via PricedetailHelper. For parts whose BOM quantity falls below the minimum order amount the minimum order amount is used for the price tier lookup so that a price is always returned. - **Extended Price**: unit price multiplied by the BOM quantity. Prices are rendered via MoneyFormatter (locale-aware, with currency symbol). Both columns round up to 2 decimal places to avoid displaying 0.00 for very small prices.
Adds the English translation "Extended Price" for the new BOM extended price column. Other languages are marked needs-translation and will be picked up by Crowdin.
Displays the total BOM price for N builds on the project info page, using the existing price-tier logic from PricedetailHelper. The user can adjust the number of builds via a small form; the unit price is also shown when N > 1. New backend: - ProjectBuildHelper gains calculateTotalBuildPrice(), calculateUnitBuildPrice(), roundedTotalBuildPrice(), and roundedUnitBuildPrice() — bulk-order quantities are factored in so that price tiers apply correctly across N builds. - ProjectController::info() now reads ?n= and passes number_of_builds to the template. Template (_info.html.twig): - Adds price badge (hidden when no pricing data is available). - Adds number-of-builds form that reloads the info page.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1345 +/- ##
============================================
+ Coverage 57.08% 57.12% +0.04%
- Complexity 8381 8393 +12
============================================
Files 615 615
Lines 26994 27046 +52
============================================
+ Hits 15410 15451 +41
- Misses 11584 11595 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Covers calculateTotalBuildPrice(), calculateUnitBuildPrice(), roundedTotalBuildPrice(), and the private getBomEntryUnitPrice() helper. Scenarios tested: empty project, no pricing data, non-part BOM entries with manual prices, part entries with pricedetails, mixed entries, rounding-up of sub-cent prices, and minimum order amount floor for price tier lookup.
The private getBomEntryUnitPrice() in ProjectBomEntriesDataTable was identical to the one in ProjectBuildHelper. Replaced it with a new public getEntryUnitPrice() on ProjectBuildHelper (returns BigDecimal, never null) and delegate to it from the DataTable. This eliminates the duplicate code and brings the DataTable lines under the existing ProjectBuildHelper test coverage. Added three tests for getEntryUnitPrice() covering the no-pricing, non-part, and part cases.
Member
|
Looks good. Thank you. |
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.
This is a continuation of #1221, which went stale.
The implementation has been improved with the suggestions I made under the original PR and rebased onto the current master and several issues from the review have been addressed.
Thanks for @whinis for the idea!
BOM table:
Project info tab:
Shows the total BOM price for N builds as a badge on the info tab
Adjustable via a small "number of builds" input; bulk pricing tiers are taken into account (ordering 10× a part may yield a lower per-unit price)
When N > 1, the per-unit project price is shown alongside the total Implementation notes
When a BOM entry's quantity falls below the part's minimum order amount, the minimum order amount is used for the price tier lookup (otherwise calculateAvgPrice returns null and the price would silently show as 0)
Prices are rounded up to 2 decimal places (e.g. 0.001 € → 0.01 €) to avoid displaying 0.00 for very cheap parts
All price rendering goes through MoneyFormatter for locale-aware formatting with the correct currency symbol