diff --git a/composer.json b/composer.json index 7a288f6..12aa6fb 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,8 @@ ], "require": { "php": "^8.1", - "illuminate/support": "^10.0|^11.0|^12.0" + "illuminate/support": "^10.0|^11.0|^12.0", + "psr/log": "^3.0.2" }, "require-dev": { "laravel/pint": "^1.0", diff --git a/src/Attributes/Resources/Properties/ApiFormatting/FloatPrecision.php b/src/Attributes/Resources/Properties/ApiFormatting/FloatPrecision.php new file mode 100644 index 0000000..eb845e8 --- /dev/null +++ b/src/Attributes/Resources/Properties/ApiFormatting/FloatPrecision.php @@ -0,0 +1,23 @@ +precision); + } +} diff --git a/src/Attributes/Resources/Properties/ApiFormatting/ResourceToPrimaryKey.php b/src/Attributes/Resources/Properties/ApiFormatting/ResourceToPrimaryKey.php index 6fd8f9c..f74ebc9 100644 --- a/src/Attributes/Resources/Properties/ApiFormatting/ResourceToPrimaryKey.php +++ b/src/Attributes/Resources/Properties/ApiFormatting/ResourceToPrimaryKey.php @@ -13,7 +13,7 @@ public function __construct() {} public function format($value): mixed { if (! is_a($value, Resource::class)) { - throw new \InvalidArgumentException('ResourceToArray can only be used on properties of type Resource'); + throw new \InvalidArgumentException('ResourceToPrimaryKey can only be used on properties of type Resource'); } return $value->getPrimaryKey(); diff --git a/src/DTOs/Invoice/ProductLine.php b/src/DTOs/Invoice/ProductLine.php index df32c86..d142f18 100644 --- a/src/DTOs/Invoice/ProductLine.php +++ b/src/DTOs/Invoice/ProductLine.php @@ -3,6 +3,7 @@ namespace Morningtrain\Economic\DTOs\Invoice; use Morningtrain\Economic\Abstracts\Resource; +use Morningtrain\Economic\Attributes\Resources\Properties\ApiFormatting\FloatPrecision; use Morningtrain\Economic\Attributes\Resources\Properties\ApiFormatting\ResourceToArray; use Morningtrain\Economic\Resources\DepartmentalDistribution; use Morningtrain\Economic\Resources\Product; @@ -16,6 +17,7 @@ class ProductLine extends Resource public ?string $description; + #[FloatPrecision(2)] public ?float $discountPercentage; public ?float $marginInBaseCurrency;