minor fixes

This commit is contained in:
2026-06-29 18:55:37 +02:00
parent 84ad29d0a0
commit af2ce4732b
6 changed files with 66 additions and 16 deletions
+8 -4
View File
@@ -2,6 +2,7 @@
namespace App\Controller;
use App\Enum\MarketNames;
use App\Helper\Currency;
use App\Helper\DataNeed\NeedFileName;
use App\Services\CryptoService;
@@ -88,10 +89,10 @@ class TaxesController extends AbstractController
]);
}
#[Route(path: '/taxes/dividend/{hash}', name: 'app_taxes_dividend_show')]
public function showDividend(DividendsService $tax) : Response
#[Route(path: '/taxes/dividend/{hash}/{market}', name: 'app_taxes_dividend_show', defaults: ['market' => null])]
public function showDividend(DividendsService $tax, ?MarketNames $market) : Response
{
if ($tax->readFiles()) {
if ($tax->readFiles($market)) {
$gen = $tax->generate();
// dd($gen);
return $this->render("taxes/show.html.twig", [
@@ -100,6 +101,9 @@ class TaxesController extends AbstractController
"errorString" => $gen->getErrorString(),
"rawCount" => $gen->takeCountRawData(),
"markets" => $gen->getMarkets(),
"markets_all" => MarketNames::cases(),
"hash_param" => $tax->takeHash(),
"current_market" => $market,
]);
}
@@ -108,7 +112,7 @@ class TaxesController extends AbstractController
#[Route(path: '/taxes/crypto/{hash}', name: 'app_taxes_crypto_show')]
public function showCrypto(CryptoService $tax) : Response
{
if ($tax->readFiles()) {
if ($tax->readFiles(null)) {
$gen = $tax->generate();
if ($gen) {
return $this->render("taxes/show.html.twig", [
+24
View File
@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
final class ClearTypes
{
public static function clearInt($input) : int
{
if (is_int($input)) {
return $input;
}
return (int) $input;
}
public static function clearFloat($input): float
{
if (is_float($input)) {
return $input;
}
if (str_contains($input, '.')) {
return floatval($input);
}
return 0.0;
}
}
+1 -1
View File
@@ -5,7 +5,7 @@ namespace App\Helper\DataNeed;
class NeedFileName
{
const NAMES = [
"exante","ibkr"
"exante","ibkr", "mbank"
];
public static function check(string $fileName) : ?string
+12 -5
View File
@@ -4,6 +4,7 @@ namespace App\Logic\Dividends;
use App\Helper\Currency;
use App\Helper\DataNeed\DividendValues;
use ClearTypes;
use PhpOffice\PhpSpreadsheet\Shared\Date;
class SheetData extends SheetDataAll
@@ -45,21 +46,27 @@ class SheetData extends SheetDataAll
if (count($row) < 1) {
continue;
}
$tmpDate = intval($row['date']);
$date = &$row['date'];
if (is_int($date)) {
if ($tmpDate > 2100) {
$date = Date::excelToDateTimeObject($date);
} else if (is_string($date)) {
} else {
$date = new \DateTime(str_replace(".", "-", $date));
}
if (is_float($row['tax'])) {
$row['tax'] = intval(round($row['tax']*100));
}
$dividendObj = new DividendsData();
$dividendObj->setCount($row['count']);
$dividendObj->setIsin($row['isin']);
$dividendObj->setCurrency($row['currency']);
$dividendObj->setTax($row['tax']);
$dividendObj->setValue($row['value']);
$dividendObj->setTax(ClearTypes::clearInt($row['tax']));
$dividendObj->setCount(ClearTypes::clearInt($row['count']));
$dividendObj->setValue(ClearTypes::clearFloat($row['value']));
$dividendObj->setDateTime($date);
$ret[] = $dividendObj;
}
+15 -1
View File
@@ -2,6 +2,7 @@
declare(strict_types=1);
namespace App\Services;
use App\Enum\MarketNames;
use Doctrine\ORM\EntityManager;
class MasterServices
@@ -18,7 +19,7 @@ class MasterServices
$this->uploadPath = $path;
}
public function readFiles() : bool
public function readFiles(?MarketNames $market) : bool
{
$fileNames = [];
$dir=$this->uploadPath . "/" . $this->hashParam;
@@ -29,7 +30,20 @@ class MasterServices
}
}
closedir($handle);
if($market !== null) {
foreach ($fileNames as $key => $fileName) {
$fileMarket = MarketNames::tryFromCase($fileName);
if ($fileMarket !== $market) {
unset($fileNames[$key]);
}
}
}
$this->allFiles=$fileNames;
return count($fileNames) > 0;
}
public function takeHash(): string
{
return $this->hashParam;
}
}