- Work types get an hourly rate (VAT 0), set on the work type form or in the hourly rate grid of the new Hinnasto page (/catalog/prices), which saves a cell when focus leaves it. - Fixed-price products with a unit from a list, consumer product flag and automatic hours, which need a work type. Products are moved and deactivated, never deleted. - The mileage rate is stored in a new settings table through the shared Settings contract. - Shared Money value object keeps amounts in cents, parses "85,50" and formats "85,50 €". - Prices are read only through PriceListQueries, not CatalogQueries, so personal money permissions can be added in one place next. - Only admins and management can open the pages for now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
31 lines
1.1 KiB
PHP
31 lines
1.1 KiB
PHP
<?php
|
|
|
|
use App\Modules\Shared\Domain\Exceptions\InvalidMoneyAmount;
|
|
use App\Modules\Shared\Domain\ValueObjects\Money;
|
|
|
|
it('parses euro amounts typed in Finnish or English notation', function (string $typed, int $cents) {
|
|
expect(Money::parse($typed)?->cents)->toBe($cents);
|
|
})->with([
|
|
'whole euros' => ['85', 8500],
|
|
'comma decimals' => ['85,50', 8550],
|
|
'one decimal' => ['85.5', 8550],
|
|
'thousands with a space' => ['1 200,00', 120000],
|
|
'with the euro sign' => ['0,59 €', 59],
|
|
'zero' => ['0', 0],
|
|
]);
|
|
|
|
it('treats an empty value as no amount', function () {
|
|
expect(Money::parse(' '))->toBeNull();
|
|
});
|
|
|
|
it('rejects amounts that are not euros with at most two decimals', function (string $typed) {
|
|
Money::parse($typed);
|
|
})->throws(InvalidMoneyAmount::class)->with(['-5', '1,234', 'abc', '1.000,00', '1000001']);
|
|
|
|
it('formats with a no-break space and the currency', function () {
|
|
$money = Money::fromCents(120050);
|
|
|
|
expect($money->format())->toBe("1\u{00A0}200,50\u{00A0}€")
|
|
->and($money->inputValue())->toBe('1200,50');
|
|
});
|