commit compras 2711
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-27 13:49:31 +02:00
parent dc73540558
commit e709d900d1
81 changed files with 5352 additions and 107 deletions
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Services;
/** Converts cumulative documentary amounts with the frozen rate of one origin. */
final class OrderPartsReference
{
/** @return array{subtotal_minor:int,tax_minor:int,total_minor:int} */
public static function portion(int $beforeNet, int $beforeTax, int $net, int $tax, string $rate): array
{
if (min($beforeNet, $beforeTax, $net, $tax) < 0
|| $beforeNet > PHP_INT_MAX - $net || $beforeTax > PHP_INT_MAX - $tax) {
throw new \InvalidArgumentException('Base cambial cumulativa inválida.');
}
$exchange = new QuotationExchange;
$subtotal = $exchange->convert($beforeNet + $net, $rate) - $exchange->convert($beforeNet, $rate);
$vat = $exchange->convert($beforeTax + $tax, $rate) - $exchange->convert($beforeTax, $rate);
return ['subtotal_minor' => $subtotal, 'tax_minor' => $vat, 'total_minor' => $subtotal + $vat];
}
}