Part-DB-server/tests
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
..
API /api/part_lots: add user_barcode filter (#1280) 2026-03-07 19:31:47 +01:00
assets Added custom part status (#1053) 2025-10-27 21:58:16 +01:00
Command Enhance KiCad integration: API v2, batch EDA editing, field export control (#1241) 2026-03-01 22:10:13 +01:00
Controller Add custom KiCad autocomplete list settings (#1342) 2026-04-15 00:01:00 +02:00
DataTables/Filters Ran rector and made tests final 2026-02-14 23:32:43 +01:00
Doctrine Added tests for custom doctrine functions 2026-03-22 21:50:15 +01:00
Entity Show HTML files in the HTML sandbox if enabled 2026-02-24 22:40:23 +01:00
EnvVarProcessors Ran rector and made tests final 2026-02-14 23:32:43 +01:00
EventListener Ran rector and made tests final 2026-02-14 23:32:43 +01:00
EventSubscriber Ran rector and made tests final 2026-02-14 23:32:43 +01:00
Exceptions Ran rector and made tests final 2026-02-14 23:32:43 +01:00
Form/InfoProviderSystem Ran rector and made tests final 2026-02-14 23:32:43 +01:00
Helpers Ran rector and made tests final 2026-02-14 23:32:43 +01:00
Repository Ran rector and made tests final 2026-02-14 23:32:43 +01:00
Security Ran rector and made tests final 2026-02-14 23:32:43 +01:00
Serializer Correctly denormalize parent-child relationships in import, when only children not parent fields are given 2026-03-07 21:08:32 +01:00
Services Add price columns to project BOM table and build price summary (#1345) 2026-04-15 22:13:07 +02:00
Settings Ran rector and made tests final 2026-02-14 23:32:43 +01:00
Twig Moved remaining twig extensions to new attributes system 2026-02-15 00:23:30 +01:00
Validator Ran rector and made tests final 2026-02-14 23:32:43 +01:00
.gitignore Initial commit 2019-02-23 16:49:38 +01:00
ApplicationAvailabilityFunctionalTest.php Add custom KiCad autocomplete list settings (#1342) 2026-04-15 00:01:00 +02:00
bootstrap.php Updated phpunit recipe 2025-07-13 16:53:41 +02:00
DatatablesAvailabilityTest.php Ran rector and made tests final 2026-02-14 23:32:43 +01:00
object-manager.php Fixed PHPstan issues 2023-08-28 22:39:29 +02:00
SettingsTestHelper.php Run rector 2025-07-14 00:26:40 +02:00
symfony-container.php Added declare strict types to all files 2023-06-11 18:59:07 +02:00