fix tests

This commit is contained in:
Dennis Eichhorn 2023-09-22 23:25:20 +00:00
parent 3c987e4b9c
commit 7089904e59
5 changed files with 25 additions and 11 deletions

View File

@ -18,9 +18,10 @@ use phpOMS\Localization\ISO3166TwoEnum;
use phpOMS\Localization\Money; use phpOMS\Localization\Money;
/** @var \phpOMS\Views\View $this */ /** @var \phpOMS\Views\View $this */
require_once $this->getData('defaultTemplates') /** @var \Modules\Media\Models\Collection $media */
->findFile('.pdf.php') $media = $this->getData('defaultTemplates');
->getAbsolutePath();
require_once $media->findFile('.pdf.php')->getAbsolutePath();
/** @var \Modules\Billing\Models\Bill $bill */ /** @var \Modules\Billing\Models\Bill $bill */
$bill = $this->data['bill'] ?? new NullBill(); $bill = $this->data['bill'] ?? new NullBill();

View File

@ -534,6 +534,7 @@ final class ApiBillController extends Controller
$path = $this->createBillDir($bill); $path = $this->createBillDir($bill);
/** @var \Modules\Media\Models\Collection[] */
$billCollection = CollectionMapper::getAll() $billCollection = CollectionMapper::getAll()
->where('virtual', $path) ->where('virtual', $path)
->execute(); ->execute();
@ -1060,7 +1061,7 @@ final class ApiBillController extends Controller
if ($client->getAttribute('bill_emails')->value->getValue() === 1) { if ($client->getAttribute('bill_emails')->value->getValue() === 1) {
$email = empty($tmp = $client->getAttribute('bill_email_address')->value->getValue()) $email = empty($tmp = $client->getAttribute('bill_email_address')->value->getValue())
? $tmp ? (string) $tmp
: $client->account->getEmail(); : $client->account->getEmail();
$this->sendBillEmail($media, $email, $response->header->l11n->language); $this->sendBillEmail($media, $email, $response->header->l11n->language);

View File

@ -153,7 +153,7 @@ final class ApiPriceController extends Controller
// Find base price (@todo: probably not a good solution) // Find base price (@todo: probably not a good solution)
$bestBasePrice = null; $bestBasePrice = null;
foreach ($prices as $price) { foreach ($prices as $price) {
if ($price->price !== 0 && $price->priceNew === 0 if ($price->price->value !== 0 && $price->priceNew === 0
&& $price->item->id !== 0 && $price->item->id !== 0
&& $price->itemgroup->id === 0 && $price->itemgroup->id === 0
&& $price->itemsegment->id === 0 && $price->itemsegment->id === 0
@ -165,7 +165,7 @@ final class ApiPriceController extends Controller
&& $price->clientsection->id === 0 && $price->clientsection->id === 0
&& $price->clienttype->id === 0 && $price->clienttype->id === 0
&& $price->promocode === '' && $price->promocode === ''
&& $price->price < ($bestBasePrice?->price ?? \PHP_INT_MAX) && $price->price->value < ($bestBasePrice?->price->value ?? \PHP_INT_MAX)
) { ) {
$bestBasePrice = $price; $bestBasePrice = $price;
} }
@ -178,10 +178,10 @@ final class ApiPriceController extends Controller
$bestPriceValue = \PHP_INT_MAX; $bestPriceValue = \PHP_INT_MAX;
foreach ($prices as $price) { foreach ($prices as $price) {
$newPrice = $bestBasePrice->price; $newPrice = $bestBasePrice->price->value;
if ($price->price < $newPrice) { if ($price->price->value < $newPrice) {
$newPrice = $price->price; $newPrice = $price->price->value;
} }
if ($price->priceNew < $newPrice) { if ($price->priceNew < $newPrice) {

View File

@ -100,8 +100,11 @@ final class ApiPurchaseController extends Controller
/** @var \Modules\Media\Models\Media[] $uploaded */ /** @var \Modules\Media\Models\Media[] $uploaded */
$uploaded = $mediaResponse->get('')['response']['upload']; $uploaded = $mediaResponse->get('')['response']['upload'];
$in = \reset($uploaded)->getAbsolutePath(); // pdf is parsed in $in->content if (empty($uploaded)) {
throw new \Exception();
}
$in = \reset($uploaded)->getAbsolutePath(); // pdf parsed content is available in $in->content
if (!\is_file($in)) { if (!\is_file($in)) {
throw new \Exception(); throw new \Exception();
} }

View File

@ -277,11 +277,20 @@ final class ApiTaxController extends Controller
__DIR__ . '/../Admin/Install/Taxes' __DIR__ . '/../Admin/Install/Taxes'
) )
) { ) {
$this->createInvalidUpdateResponse($request, $response, []);
return;
}
$content = \file_get_contents($path);
if ($content === false) {
$this->createInvalidUpdateResponse($request, $response, []);
return; return;
} }
/** @var array $combinations */ /** @var array $combinations */
$combinations = \json_decode(\file_get_contents($path), true); $combinations = \json_decode($content, true);
foreach ($combinations as $combination) { foreach ($combinations as $combination) {
/** @var TaxCombination[] $old */ /** @var TaxCombination[] $old */