Part-DB-server/src/Services
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
..
Attachments Allow to disable the NoPrivateNetwork protection for attachment downloads via an env variable 2026-04-05 23:14:18 +02:00
Cache Do not use the wrong language for trees when no user is logged in 2026-01-18 23:44:11 +01:00
Doctrine Show in server info page which natural sorting method is used 2024-07-28 14:13:34 +02:00
EDA Add custom KiCad autocomplete list settings (#1342) 2026-04-15 00:01:00 +02:00
EntityMergers Fixed PHPstan issue 2026-02-08 19:37:44 +01:00
Formatters Fixed warning on PHP8.5 2025-10-17 22:39:58 +02:00
ImportExportSystem Automatically detect the delimiter of generic BOM imports 2026-03-15 21:35:38 +01:00
InfoProviderSystem Fix creating parts from TME if the SPN contains percent signs (#1337) 2026-04-06 14:42:54 +02:00
LabelSystem Implement parsing of TME QR codes (#1324) 2026-03-29 14:53:31 +02:00
LogSystem Moved remaining twig extensions to new attributes system 2026-02-15 00:23:30 +01:00
Misc Centralized git logic from InstallationTypeDetector and UpdateChecker in GitVersionInfoProvider service 2026-02-02 18:18:36 +01:00
OAuth Applied rector suggestions 2024-06-22 00:31:43 +02:00
Parameters Dont split up links when extracting parameters from notes and description 2024-01-06 15:14:07 +01:00
Parts Enhance KiCad integration: API v2, batch EDA editing, field export control (#1241) 2026-03-01 22:10:13 +01:00
ProjectSystem Add price columns to project BOM table and build price summary (#1345) 2026-04-15 22:13:07 +02:00
System Add manual backup creation and delete buttons to Update Manager (#1255) 2026-03-07 19:31:00 +01:00
Tools Use central banks of czechia, turkey and romania as a free provider for their currencies exchange rates 2025-09-05 19:56:01 +02:00
TranslationExtractor Applied rector with PHP8.1 migration rules 2023-06-11 14:17:19 +02:00
Trees Use different symbol for update manager 2026-02-02 20:49:21 +01:00
UserSystem Automatically set the stocktake permission if a user can already add and withdraw from a lot 2026-02-10 23:24:40 +01:00
ElementTypeNameGenerator.php Implemented the ability to set user-defined synonyms/labels for internal element types 2025-11-12 21:35:02 +01:00
ElementTypes.php Implemented the ability to set user-defined synonyms/labels for internal element types 2025-11-12 21:35:02 +01:00
EntityURLGenerator.php Added custom part status (#1053) 2025-10-27 21:58:16 +01:00