Part-DB-server/src/Controller
Niklas c17cf5e83c
Add price columns to project BOM table and build price summary (#1345)
* Add unit price and extended price columns to project BOM table

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.

* Add translation key for project.bom.ext_price

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.

* Add build price summary to project info tab

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.

* Add tests for build price calculation in ProjectBuildHelper

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.

* Deduplicate BOM entry price logic into ProjectBuildHelper

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.

* Added type hint to service

---------

Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
2026-04-15 22:13:07 +02:00
..
AdminPages Check for good measure again, that a user is able to edit an entity in an admin form 2026-03-04 23:06:01 +01:00
ErrorHandling Show the error page in a pop up in prod environment too 2024-03-10 00:12:54 +01:00
.gitignore Initial commit 2019-02-23 16:49:38 +01:00
AttachmentFileController.php Allow to load external images and styles in the HTML sandbox 2026-02-24 23:05:09 +01:00
BatchEdaController.php Enhance KiCad integration: API v2, batch EDA editing, field export control (#1241) 2026-03-01 22:10:13 +01:00
BulkInfoProviderImportController.php Added tests for new DTO objects 2025-09-21 23:07:45 +02:00
GroupController.php Use the route attribute from the correct namespace 2024-03-03 20:37:33 +01:00
HomepageController.php Merged functionality from UpdateAvailableManager and UpdateChecker 2026-02-02 18:44:44 +01:00
InfoProviderController.php Added an web page to quickly add a new part from a web URL 2026-02-01 18:18:58 +01:00
KiCadApiController.php Enhance KiCad integration: API v2, batch EDA editing, field export control (#1241) 2026-03-01 22:10:13 +01:00
KicadListEditorController.php Add custom KiCad autocomplete list settings (#1342) 2026-04-15 00:01:00 +02:00
LabelController.php Fixed tests 2025-09-07 00:26:24 +02:00
LogController.php Allow to configure default table page length via Settings UI 2024-08-21 22:15:26 +02:00
OAuthClientController.php Applied rector suggestions 2024-06-22 00:31:43 +02:00
PartController.php Add a flash notice when automatically creating a part lot from scan 2026-03-07 22:01:50 +01:00
PartImportExportController.php Fixed exception when trying to export an empty entity list 2025-02-01 20:57:27 +01:00
PartListsController.php Added ID to search options. Fixed seach option by using equal to instead of like for the ID. 2026-01-09 11:37:30 +01:00
ProjectController.php Add price columns to project BOM table and build price summary (#1345) 2026-04-15 22:13:07 +02:00
RedirectController.php Moved default language, default timezone and base currency settings to new settings system 2024-08-03 23:14:29 +02:00
ScanController.php Label Scanner Enhancements: LCSC barcode, create part, augmented scanning (#1194) 2026-02-22 21:26:44 +01:00
SecurityController.php Use a symfony form for login form 2026-03-07 00:46:34 +01:00
SelectAPIController.php Added way to batch edit the location of parts with a single stock 2025-03-29 16:21:10 +01:00
SettingsController.php Require full authentication for the system settings, as some of the settings are quite critical 2026-04-15 00:04:52 +02:00
StatisticsController.php Use the route attribute from the correct namespace 2024-03-03 20:37:33 +01:00
ToolsController.php Merged functionality from UpdateAvailableManager and UpdateChecker 2026-02-02 18:44:44 +01:00
TreeController.php Use the route attribute from the correct namespace 2024-03-03 20:37:33 +01:00
TypeaheadController.php Ensure that user has read permission to part and category to prevent IPN info leakage 2026-03-04 23:54:18 +01:00
UpdateManagerController.php Add manual backup creation and delete buttons to Update Manager (#1255) 2026-03-07 19:31:00 +01:00
UserController.php Use the route attribute from the correct namespace 2024-03-03 20:37:33 +01:00
UserSettingsController.php Ran rector to convert some our twig extensions to use #[AsTwigXX] attributes 2026-02-14 23:53:31 +01:00
WebauthnKeyRegistrationController.php Use the route attribute from the correct namespace 2024-03-03 20:37:33 +01:00