feat: Add invoice items element with dynamic pricing from pricing table

- Add new 'invoice-items-muh' element to invoice template
- Add 'Positionen' category back to palette groups
- Create helper functions to format price and generate invoice content
- Add /current endpoint to SystemPricingController for authenticated users
- Load pricing when creating starter layout and display:
  - Monatliche Systemgebühr MUH with net price
  - Umsatzsteuer (19%)
  - Gesamtsumme (brutto)
- Update starter layout positioning for new element
This commit is contained in:
2026-03-18 12:02:38 +01:00
parent 3d9b807261
commit dc35995e64
2 changed files with 65 additions and 10 deletions

View File

@@ -9,7 +9,6 @@ import java.util.Optional;
@RestController
@RequestMapping("/api/admin/pricing")
@PreAuthorize("hasRole('ADMIN')")
public class SystemPricingController {
private final SystemPricingService systemPricingService;
@@ -19,13 +18,23 @@ public class SystemPricingController {
}
@GetMapping
@PreAuthorize("hasRole('ADMIN')")
public PricingResponse getPricing() {
Optional<SystemPricing> pricing = systemPricingService.getCurrentPricing();
return pricing.map(p -> new PricingResponse(p.monthlyPrice(), p.updatedAt().toString()))
.orElseGet(() -> new PricingResponse(null, null));
}
@GetMapping("/current")
@PreAuthorize("isAuthenticated()")
public PricingResponse getCurrentPricing() {
Optional<SystemPricing> pricing = systemPricingService.getCurrentPricing();
return pricing.map(p -> new PricingResponse(p.monthlyPrice(), p.updatedAt().toString()))
.orElseGet(() -> new PricingResponse(null, null));
}
@PostMapping
@PreAuthorize("hasRole('ADMIN')")
public PricingResponse savePricing(@RequestBody PricingRequest request) {
SystemPricing saved = systemPricingService.savePricing(request.monthlyPrice());
return new PricingResponse(saved.monthlyPrice(), saved.updatedAt().toString());