minor fixesgs
This commit is contained in:
@@ -102,7 +102,8 @@ class TaxesController extends AbstractController
|
|||||||
"taxes" => $gen->getSummaryByCountry(),
|
"taxes" => $gen->getSummaryByCountry(),
|
||||||
"errorDividend" => $gen->getErrorDividend(),
|
"errorDividend" => $gen->getErrorDividend(),
|
||||||
"errorString" => $gen->getErrorString(),
|
"errorString" => $gen->getErrorString(),
|
||||||
"rawCount" => $gen->takeCountRawData()
|
"rawCount" => $gen->takeCountRawData(),
|
||||||
|
"markets" => $gen->getMarkets(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
namespace App\Logic\Dividends;
|
namespace App\Logic\Dividends;
|
||||||
|
|
||||||
|
use App\Enum\MarketNames;
|
||||||
use App\Helper\Currency;
|
use App\Helper\Currency;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
|
|
||||||
@@ -18,12 +19,23 @@ class DividendsSummary
|
|||||||
private array $allData=[];
|
private array $allData=[];
|
||||||
private array $countryToCurrency=[];
|
private array $countryToCurrency=[];
|
||||||
private int $realCalculatedRows = 0;
|
private int $realCalculatedRows = 0;
|
||||||
|
/** @var array|MarketNames $markets */
|
||||||
|
private array $markets=[];
|
||||||
|
|
||||||
public function __construct(EntityManager $manager)
|
public function __construct(EntityManager $manager)
|
||||||
{
|
{
|
||||||
$this->currencyObj = new Currency($manager);
|
$this->currencyObj = new Currency($manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addMarket(?MarketNames $names)
|
||||||
|
{
|
||||||
|
$this->markets[] = $names ?? MarketNames::MBANK;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMarkets(): array
|
||||||
|
{
|
||||||
|
return $this->markets;
|
||||||
|
}
|
||||||
public function getSummaryByCountry() : array
|
public function getSummaryByCountry() : array
|
||||||
{
|
{
|
||||||
$return=[];
|
$return=[];
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ class ExanteSheet extends SheetDataAll
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$operationType = strtolower($rawDatum[$operationKey]);
|
$operationType = strtolower($rawDatum[$operationKey]);
|
||||||
|
|
||||||
if (!str_contains($operationType,"dividend")) {
|
if (!str_contains($operationType,"dividend")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class IbkrSheet extends SheetDataAll
|
|||||||
$taxArr = [];
|
$taxArr = [];
|
||||||
$test = [];
|
$test = [];
|
||||||
foreach ($this->getRawData() as $index => $rawDatum) {
|
foreach ($this->getRawData() as $index => $rawDatum) {
|
||||||
if ($index < 2) {
|
if ($index < 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$row=[];
|
$row=[];
|
||||||
@@ -39,7 +39,7 @@ class IbkrSheet extends SheetDataAll
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$test[$row['groupId']][] = $row['amount'];
|
$test[$row['groupId']][] = $row['amount'];
|
||||||
if (strpos($row['type'], "Dividend") !== false) {
|
if (str_contains($row['type'], "Dividend")) {
|
||||||
$dividendArr[$row['groupId']] = $row;
|
$dividendArr[$row['groupId']] = $row;
|
||||||
} else {
|
} else {
|
||||||
if (!isset($taxArr[$row['groupId']])) {
|
if (!isset($taxArr[$row['groupId']])) {
|
||||||
@@ -49,16 +49,18 @@ class IbkrSheet extends SheetDataAll
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($dividendArr as $groupId => $dividend) {
|
foreach ($dividendArr as $groupId => $dividend) {
|
||||||
if (!isset($taxArr[$groupId])) {
|
if (isset($taxArr[$groupId])) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$taxGet = $taxArr[$groupId]['amount'];
|
$taxGet = $taxArr[$groupId]['amount'];
|
||||||
// $dividend['amount'] += $taxGet;
|
|
||||||
$taxPercentage = intval(round(abs($taxGet) / $dividend['amount'], 2) * 100);
|
$taxPercentage = intval(round(abs($taxGet) / $dividend['amount'], 2) * 100);
|
||||||
if ($taxPercentage === 14) {
|
if ($taxPercentage === 14) {
|
||||||
$taxPercentage = 15;
|
$taxPercentage = 15;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$taxPercentage = 19;
|
||||||
|
}
|
||||||
|
|
||||||
$separate = explode(" ", $dividend['description']);
|
$separate = explode(" ", $dividend['description']);
|
||||||
$perShare = floatval($separate[4]);
|
$perShare = floatval($separate[4]);
|
||||||
if (!$perShare) {
|
if (!$perShare) {
|
||||||
@@ -71,6 +73,10 @@ class IbkrSheet extends SheetDataAll
|
|||||||
if (substr_count($date, "-") !== 2) {
|
if (substr_count($date, "-") !== 2) {
|
||||||
$date = substr($date, 0, 4) . "-" . substr($date, 4, 2) . "-" . substr($date, 6, 2);
|
$date = substr($date, 0, 4) . "-" . substr($date, 4, 2) . "-" . substr($date, 6, 2);
|
||||||
}
|
}
|
||||||
|
$dateObj = new \DateTime($date);
|
||||||
|
if ($dateObj->format("Y") !== (new \DateTime())->modify("-1 year")->format("Y")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// trigger_error(var_export($date,true));
|
// trigger_error(var_export($date,true));
|
||||||
$dividendObj = new DividendsData();
|
$dividendObj = new DividendsData();
|
||||||
$dividendObj->setCount(intval($dividend['amount'] / $perShare));
|
$dividendObj->setCount(intval($dividend['amount'] / $perShare));
|
||||||
@@ -78,7 +84,7 @@ class IbkrSheet extends SheetDataAll
|
|||||||
$dividendObj->setCurrency($dividend['currency']);
|
$dividendObj->setCurrency($dividend['currency']);
|
||||||
$dividendObj->setTax($taxPercentage);
|
$dividendObj->setTax($taxPercentage);
|
||||||
$dividendObj->setValue($perShare);
|
$dividendObj->setValue($perShare);
|
||||||
$dividendObj->setDateTime(new \DateTime($date));
|
$dividendObj->setDateTime($dateObj);
|
||||||
|
|
||||||
$ret[] = $dividendObj;
|
$ret[] = $dividendObj;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ abstract class SheetDataAll
|
|||||||
* @var array|DividendsData $data
|
* @var array|DividendsData $data
|
||||||
*/
|
*/
|
||||||
protected array $data = [];
|
protected array $data = [];
|
||||||
|
protected array $dataNotCalculate = [];
|
||||||
private array $rawData;
|
private array $rawData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,11 +21,6 @@ class DividendsService extends MasterServices
|
|||||||
$extension = pathinfo($file)['extension'];
|
$extension = pathinfo($file)['extension'];
|
||||||
$market = MarketNames::tryFromCase($file);
|
$market = MarketNames::tryFromCase($file);
|
||||||
|
|
||||||
|
|
||||||
$isExante = str_contains($file, "exante");
|
|
||||||
$isIbkr = str_contains($file, "ibkr");
|
|
||||||
|
|
||||||
|
|
||||||
if (in_array($extension, ['xlsx','csv'])) {
|
if (in_array($extension, ['xlsx','csv'])) {
|
||||||
if ($market === MarketNames::EXANTE) {
|
if ($market === MarketNames::EXANTE) {
|
||||||
$delimiter = ";";
|
$delimiter = ";";
|
||||||
@@ -48,6 +43,7 @@ class DividendsService extends MasterServices
|
|||||||
$summaryObj->addSheetData($item);
|
$summaryObj->addSheetData($item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$summaryObj->addMarket($market);
|
||||||
}
|
}
|
||||||
if ($extension === "xml") {
|
if ($extension === "xml") {
|
||||||
$obj = new XMLReader($file);
|
$obj = new XMLReader($file);
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
{% block body %}
|
{% block body %}
|
||||||
<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">
|
||||||
|
{% for market in markets %}
|
||||||
|
<h3>{{ market.name }}</h3>
|
||||||
|
{% endfor %}
|
||||||
{% if taxes %}
|
{% if taxes %}
|
||||||
<table class="table table-dark table-striped">
|
<table class="table table-dark table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
Reference in New Issue
Block a user