minor fixes
This commit is contained in:
@@ -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", [
|
||||
|
||||
@@ -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
|
||||
{
|
||||
const NAMES = [
|
||||
"exante","ibkr"
|
||||
"exante","ibkr", "mbank"
|
||||
];
|
||||
|
||||
public static function check(string $fileName) : ?string
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,16 @@
|
||||
<div class="row justify-content-md-center" >
|
||||
<div class="col col-md-6">
|
||||
<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 ">
|
||||
<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>
|
||||
{% endfor %}
|
||||
<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 class="nav-item">#}
|
||||
|
||||
Reference in New Issue
Block a user