22 lines
717 B
PHP
22 lines
717 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use Illuminate\Validation\ValidationException;
|
|
use InvalidArgumentException;
|
|
|
|
class QuotationPricing
|
|
{
|
|
/** Discount applies to the unit price before VAT; the net unit is rounded once to cents.
|
|
* @return array{gross_unit_minor: int, discount_type: string, discount_value: string, net_unit_minor: int}
|
|
*/
|
|
public function unit(string $price, string $type = 'none', string $value = '0'): array
|
|
{
|
|
try {
|
|
return (new \Tempo\Purchasing\Economic\QuotationPricing)->unit($price, $type, $value);
|
|
} catch (InvalidArgumentException $error) {
|
|
throw ValidationException::withMessages(['items' => $error->getMessage()]);
|
|
}
|
|
}
|
|
}
|