minor fixes
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Enum\MarketNames;
|
||||||
use App\Helper\Currency;
|
use App\Helper\Currency;
|
||||||
use App\Helper\DataNeed\NeedFileName;
|
use App\Helper\DataNeed\NeedFileName;
|
||||||
use App\Services\CryptoService;
|
use App\Services\CryptoService;
|
||||||
@@ -88,10 +89,10 @@ class TaxesController extends AbstractController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/taxes/dividend/{hash}', name: 'app_taxes_dividend_show')]
|
#[Route(path: '/taxes/dividend/{hash}/{market}', name: 'app_taxes_dividend_show', defaults: ['market' => null])]
|
||||||
public function showDividend(DividendsService $tax) : Response
|
public function showDividend(DividendsService $tax, ?MarketNames $market) : Response
|
||||||
{
|
{
|
||||||
if ($tax->readFiles()) {
|
if ($tax->readFiles($market)) {
|
||||||
$gen = $tax->generate();
|
$gen = $tax->generate();
|
||||||
// dd($gen);
|
// dd($gen);
|
||||||
return $this->render("taxes/show.html.twig", [
|
return $this->render("taxes/show.html.twig", [
|
||||||
@@ -100,6 +101,9 @@ class TaxesController extends AbstractController
|
|||||||
"errorString" => $gen->getErrorString(),
|
"errorString" => $gen->getErrorString(),
|
||||||
"rawCount" => $gen->takeCountRawData(),
|
"rawCount" => $gen->takeCountRawData(),
|
||||||
"markets" => $gen->getMarkets(),
|
"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')]
|
#[Route(path: '/taxes/crypto/{hash}', name: 'app_taxes_crypto_show')]
|
||||||
public function showCrypto(CryptoService $tax) : Response
|
public function showCrypto(CryptoService $tax) : Response
|
||||||
{
|
{
|
||||||
if ($tax->readFiles()) {
|
if ($tax->readFiles(null)) {
|
||||||
$gen = $tax->generate();
|
$gen = $tax->generate();
|
||||||
if ($gen) {
|
if ($gen) {
|
||||||
return $this->render("taxes/show.html.twig", [
|
return $this->render("taxes/show.html.twig", [
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ namespace App\Helper\DataNeed;
|
|||||||
class NeedFileName
|
class NeedFileName
|
||||||
{
|
{
|
||||||
const NAMES = [
|
const NAMES = [
|
||||||
"exante","ibkr"
|
"exante","ibkr", "mbank"
|
||||||
];
|
];
|
||||||
|
|
||||||
public static function check(string $fileName) : ?string
|
public static function check(string $fileName) : ?string
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Logic\Dividends;
|
|||||||
|
|
||||||
use App\Helper\Currency;
|
use App\Helper\Currency;
|
||||||
use App\Helper\DataNeed\DividendValues;
|
use App\Helper\DataNeed\DividendValues;
|
||||||
|
use ClearTypes;
|
||||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
||||||
|
|
||||||
class SheetData extends SheetDataAll
|
class SheetData extends SheetDataAll
|
||||||
@@ -45,21 +46,27 @@ class SheetData extends SheetDataAll
|
|||||||
if (count($row) < 1) {
|
if (count($row) < 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
$tmpDate = intval($row['date']);
|
||||||
$date = &$row['date'];
|
$date = &$row['date'];
|
||||||
if (is_int($date)) {
|
if ($tmpDate > 2100) {
|
||||||
$date = Date::excelToDateTimeObject($date);
|
$date = Date::excelToDateTimeObject($date);
|
||||||
} else if (is_string($date)) {
|
} else {
|
||||||
$date = new \DateTime(str_replace(".", "-", $date));
|
$date = new \DateTime(str_replace(".", "-", $date));
|
||||||
}
|
}
|
||||||
if (is_float($row['tax'])) {
|
if (is_float($row['tax'])) {
|
||||||
$row['tax'] = intval(round($row['tax']*100));
|
$row['tax'] = intval(round($row['tax']*100));
|
||||||
}
|
}
|
||||||
|
|
||||||
$dividendObj = new DividendsData();
|
$dividendObj = new DividendsData();
|
||||||
$dividendObj->setCount($row['count']);
|
|
||||||
$dividendObj->setIsin($row['isin']);
|
$dividendObj->setIsin($row['isin']);
|
||||||
$dividendObj->setCurrency($row['currency']);
|
$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);
|
$dividendObj->setDateTime($date);
|
||||||
$ret[] = $dividendObj;
|
$ret[] = $dividendObj;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Enum\MarketNames;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
|
|
||||||
class MasterServices
|
class MasterServices
|
||||||
@@ -18,7 +19,7 @@ class MasterServices
|
|||||||
$this->uploadPath = $path;
|
$this->uploadPath = $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function readFiles() : bool
|
public function readFiles(?MarketNames $market) : bool
|
||||||
{
|
{
|
||||||
$fileNames = [];
|
$fileNames = [];
|
||||||
$dir=$this->uploadPath . "/" . $this->hashParam;
|
$dir=$this->uploadPath . "/" . $this->hashParam;
|
||||||
@@ -29,7 +30,20 @@ class MasterServices
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
|
if($market !== null) {
|
||||||
|
foreach ($fileNames as $key => $fileName) {
|
||||||
|
$fileMarket = MarketNames::tryFromCase($fileName);
|
||||||
|
if ($fileMarket !== $market) {
|
||||||
|
unset($fileNames[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$this->allFiles=$fileNames;
|
$this->allFiles=$fileNames;
|
||||||
return count($fileNames) > 0;
|
return count($fileNames) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function takeHash(): string
|
||||||
|
{
|
||||||
|
return $this->hashParam;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,15 +6,16 @@
|
|||||||
<div class="row justify-content-md-center" >
|
<div class="row justify-content-md-center" >
|
||||||
<div class="col col-md-6">
|
<div class="col col-md-6">
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
|
{% for market in markets_all %}
|
||||||
|
{% set isHaveMarket = market.value in markets|keys %}
|
||||||
|
{% set isCurrentMarket = market == current_market %}
|
||||||
|
|
||||||
{% for market in markets %}
|
|
||||||
{# <h3>{{ market.name }}</h3>#}
|
|
||||||
<li class="nav-item ">
|
<li class="nav-item ">
|
||||||
<a class="nav-link" aria-current="page" href="#">{{ market.name }}</a>
|
<a class="nav-link {% if isHaveMarket = 0 %}disabled{% endif %} {% if isCurrentMarket %}active{% endif %}" aria-current="page" href="{{ path("app_taxes_dividend_show",{hash:hash_param, market:market.value}) }}">{{ market.name }}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link active" aria-current="page" href="#">All</a>
|
<a class="nav-link {% if current_market is null %}active{% endif %}" aria-current="page" href="{{ path("app_taxes_dividend_show",{hash:hash_param, market:null}) }}">All</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
{# <li class="nav-item">#}
|
{# <li class="nav-item">#}
|
||||||
|
|||||||
Reference in New Issue
Block a user