diff --git a/Admin/Install/Media/bill.pdf.php b/Admin/Install/Media/bill.pdf.php index 17e7ca0..721c526 100755 --- a/Admin/Install/Media/bill.pdf.php +++ b/Admin/Install/Media/bill.pdf.php @@ -18,9 +18,10 @@ use phpOMS\Localization\ISO3166TwoEnum; use phpOMS\Localization\Money; /** @var \phpOMS\Views\View $this */ -require_once $this->getData('defaultTemplates') - ->findFile('.pdf.php') - ->getAbsolutePath(); +/** @var \Modules\Media\Models\Collection $media */ +$media = $this->getData('defaultTemplates'); + +require_once $media->findFile('.pdf.php')->getAbsolutePath(); /** @var \Modules\Billing\Models\Bill $bill */ $bill = $this->data['bill'] ?? new NullBill(); diff --git a/Controller/ApiBillController.php b/Controller/ApiBillController.php index 7733fff..64fafde 100755 --- a/Controller/ApiBillController.php +++ b/Controller/ApiBillController.php @@ -534,6 +534,7 @@ final class ApiBillController extends Controller $path = $this->createBillDir($bill); + /** @var \Modules\Media\Models\Collection[] */ $billCollection = CollectionMapper::getAll() ->where('virtual', $path) ->execute(); @@ -1060,7 +1061,7 @@ final class ApiBillController extends Controller if ($client->getAttribute('bill_emails')->value->getValue() === 1) { $email = empty($tmp = $client->getAttribute('bill_email_address')->value->getValue()) - ? $tmp + ? (string) $tmp : $client->account->getEmail(); $this->sendBillEmail($media, $email, $response->header->l11n->language); diff --git a/Controller/ApiPriceController.php b/Controller/ApiPriceController.php index a6fec08..7c304a6 100755 --- a/Controller/ApiPriceController.php +++ b/Controller/ApiPriceController.php @@ -153,7 +153,7 @@ final class ApiPriceController extends Controller // Find base price (@todo: probably not a good solution) $bestBasePrice = null; foreach ($prices as $price) { - if ($price->price !== 0 && $price->priceNew === 0 + if ($price->price->value !== 0 && $price->priceNew === 0 && $price->item->id !== 0 && $price->itemgroup->id === 0 && $price->itemsegment->id === 0 @@ -165,7 +165,7 @@ final class ApiPriceController extends Controller && $price->clientsection->id === 0 && $price->clienttype->id === 0 && $price->promocode === '' - && $price->price < ($bestBasePrice?->price ?? \PHP_INT_MAX) + && $price->price->value < ($bestBasePrice?->price->value ?? \PHP_INT_MAX) ) { $bestBasePrice = $price; } @@ -178,10 +178,10 @@ final class ApiPriceController extends Controller $bestPriceValue = \PHP_INT_MAX; foreach ($prices as $price) { - $newPrice = $bestBasePrice->price; + $newPrice = $bestBasePrice->price->value; - if ($price->price < $newPrice) { - $newPrice = $price->price; + if ($price->price->value < $newPrice) { + $newPrice = $price->price->value; } if ($price->priceNew < $newPrice) { diff --git a/Controller/ApiPurchaseController.php b/Controller/ApiPurchaseController.php index 92a5207..91057ab 100755 --- a/Controller/ApiPurchaseController.php +++ b/Controller/ApiPurchaseController.php @@ -100,8 +100,11 @@ final class ApiPurchaseController extends Controller /** @var \Modules\Media\Models\Media[] $uploaded */ $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)) { throw new \Exception(); } diff --git a/Controller/ApiTaxController.php b/Controller/ApiTaxController.php index d657891..2b7a040 100755 --- a/Controller/ApiTaxController.php +++ b/Controller/ApiTaxController.php @@ -277,11 +277,20 @@ final class ApiTaxController extends Controller __DIR__ . '/../Admin/Install/Taxes' ) ) { + $this->createInvalidUpdateResponse($request, $response, []); + + return; + } + + $content = \file_get_contents($path); + if ($content === false) { + $this->createInvalidUpdateResponse($request, $response, []); + return; } /** @var array $combinations */ - $combinations = \json_decode(\file_get_contents($path), true); + $combinations = \json_decode($content, true); foreach ($combinations as $combination) { /** @var TaxCombination[] $old */