Part-DB-server/templates
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
..
admin fixed intendation of force visibility checkbox in category admin 2026-03-07 23:58:32 +01:00
attachments Allow file downloads and modals in HTML sandbox 2026-02-24 22:57:48 +01:00
bundles/TwigBundle/Exception Add cache pool clear hint to error pages 2026-03-04 23:27:06 +01:00
components Enhance KiCad integration: API v2, batch EDA editing, field export control (#1241) 2026-03-01 22:10:13 +01:00
form Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
info_providers Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
label_system Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
log_system Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
mail Use new settings system to configure the instance Name and homepage banner 2024-05-20 21:14:32 +02:00
parts Fixed 500 error with displaying part prices, when a user has a currency preference different of base currency, and there is no conversion rate known for it 2026-03-15 22:02:10 +01:00
projects Add price columns to project BOM table and build price summary (#1345) 2026-04-15 22:13:07 +02:00
security add data-tube=false to SAML auth button (#1308) 2026-03-11 11:28:09 +01:00
settings Add custom KiCad autocomplete list settings (#1342) 2026-04-15 00:01:00 +02:00
tools Merge branch 'master' into settings-bundle 2025-01-17 22:06:18 +01:00
users Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
_navbar.html.twig Added a "create from label scan button to navbar" 2026-02-22 22:03:46 +01:00
_sidebar.html.twig Allow to configure sidebar menu via the new settings system 2024-08-07 00:41:06 +02:00
_toast.html.twig Improved styling of a info level flash toast in darkmode 2023-07-03 22:01:39 +02:00
_toast_container.html.twig Fixed toast position on large screens 2023-02-06 22:47:41 +01:00
_turbo_control.html.twig Fixed flash messages in admin pages 2026-03-04 23:24:29 +01:00
attachment_list.html.twig Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
base.html.twig Navigate only the content frame when submitting the global barcode scan label 2026-03-01 16:56:47 +01:00
helper.twig Add manual backup creation and delete buttons to Update Manager (#1255) 2026-03-07 19:31:00 +01:00
homepage.html.twig Allow to hide the version number on homepage 2025-09-07 19:43:23 +02:00
main_card.html.twig Added a very basic import dialog for Parts 2023-03-12 19:53:55 +01:00
vars.macro.twig Fixed old usages of base_currency 2024-08-03 23:19:09 +02:00