rector fixes + bug fixes

This commit is contained in:
Dennis Eichhorn 2023-05-27 03:06:45 +00:00
parent 9a9aecd785
commit cf73c37e21
5 changed files with 107 additions and 109 deletions

View File

@ -82,9 +82,9 @@ $toCountry = \is_string($countryEnumName) && ($country = ISO3166NameEnum::get
$addressString = \trim(
$bill->billTo . "\n"
. (!empty($bill->billAddress) ? ($bill->billAddress . "\n") : '')
. (!empty($bill->billCity) ? ($bill->billCity . "\n") : '')
. (!empty($toCountry) ? ($toCountry . "\n") : ''),
. (empty($bill->billAddress) ? '' : ($bill->billAddress . "\n"))
. (empty($bill->billCity) ? '' : ($bill->billCity . "\n"))
. (empty($toCountry) ? '' : ($toCountry . "\n")),
"\n "
);

View File

@ -39,7 +39,6 @@ use Modules\SupplierManagement\Models\NullSupplier;
use Modules\SupplierManagement\Models\Supplier;
use Modules\SupplierManagement\Models\SupplierMapper;
use phpOMS\Autoloader;
use phpOMS\Localization\ISO3166TwoEnum;
use phpOMS\Localization\ISO4217CharEnum;
use phpOMS\Localization\ISO639x1Enum;
use phpOMS\Message\Http\RequestStatusCode;
@ -265,7 +264,7 @@ final class ApiBillController extends Controller
$billLanguage = $accountBillLanguage;
} else {
$accountLanguages = ISO639x1Enum::languageFromCountry($account->mainAddress->getCountry());
$accountLanguage = !empty($accountLanguages) ? $accountLanguages[0] : '';
$accountLanguage = empty($accountLanguages) ? '' : $accountLanguages[0];
if (\in_array($accountLanguage, $validLanguages)) {
$billLanguage = $accountLanguage;
@ -350,9 +349,7 @@ final class ApiBillController extends Controller
->execute();
}
$bill = $this->createBaseBill($account, $request);
return $bill;
return $this->createBaseBill($account, $request);
}
/**
@ -867,8 +864,8 @@ final class ApiBillController extends Controller
$path = $this->createBillDir($bill);
$pdfDir = __DIR__ . '/../../../Modules/Media/Files' . $path;
$status = !\is_dir($pdfDir) ? \mkdir($pdfDir, 0755, true) : true;
if ($status === false) {
$status = \is_dir($pdfDir) ? true : \mkdir($pdfDir, 0755, true);
if (!$status) {
// @codeCoverageIgnoreStart
$response->set($request->uri->__toString(), new FormValidation(['status' => $status]));
$response->header->status = RequestStatusCode::R_400;

View File

@ -167,12 +167,11 @@ final class ApiPriceController extends Controller
&& $price->clientsection->id === 0
&& $price->clienttype->id === 0
&& $price->promocode === ''
&& $price->price < ($bestBasePrice?->price ?? \PHP_INT_MAX)
) {
if ($price->price < ($bestBasePrice?->price ?? \PHP_INT_MAX)) {
$bestBasePrice = $price;
}
}
}
// @todo: implement prices which cannot be improved even if there are better prices available (i.e. some customer groups may not get better prices, Dentagen Beispiel)
// alternatively set prices as 'improvable' => which whitelists a price as can be improved or 'alwaysimproces' which always overwrites other prices

View File

@ -113,11 +113,12 @@ final class ApiPurchaseController extends Controller
$this->app->moduleManager->get('Billing', 'Api')->apiBillPdfArchiveCreate($billRequest, $billResponse);
// Offload bill parsing to cli
$cliPath = \realpath(__DIR__ . '/../../../Cli/cli.php');
$cliPath = \realpath(__DIR__ . '/../../../cli.php');
if ($cliPath === false) {
return;
}
try {
SystemUtils::runProc(
OperatingSystem::getSystem() === SystemType::WIN ? 'php.exe' : 'php',
\escapeshellarg($cliPath)
@ -125,6 +126,9 @@ final class ApiPurchaseController extends Controller
. '-i ' . \escapeshellarg((string) $billId),
true
);
} catch (\Throwable $t) {
$this->app->logger->error($t->getMessage());
}
}
}
}

View File

@ -347,8 +347,6 @@ final class CliController extends Controller
*/
private function matchSupplier(string $content, array $suppliers) : int
{
$bestMatch = 0;
// bill_match_pattern
foreach ($suppliers as $supplier) {
// @todo: consider to support regex?
@ -373,16 +371,16 @@ final class CliController extends Controller
// name1 + city || address
foreach ($suppliers as $supplier) {
if (\stripos($content, $supplier->account->name1) !== false) {
if ((!empty($supplier->mainAddress->city)
if (\stripos($content, $supplier->account->name1) !== false
&& ((!empty($supplier->mainAddress->city)
&& \stripos($content, $supplier->mainAddress->city) !== false)
|| (!empty( $supplier->mainAddress->address)
&& \stripos($content, $supplier->mainAddress->address) !== false)
)
) {
return $supplier->id;
}
}
}
// name1
foreach ($suppliers as $supplier) {
@ -391,7 +389,7 @@ final class CliController extends Controller
}
}
return $bestMatch;
return 0;
}
/**