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