This commit is contained in:
2025-03-18 15:04:41 +01:00
parent fc1ef6f3ec
commit aa52f216bd
14 changed files with 107 additions and 53 deletions
@@ -104,6 +104,6 @@ final class DividendsData
*/
public function setCurrency(string $currency): void
{
$this->currency = $currency;
$this->currency = trim($currency);
}
}
@@ -81,13 +81,15 @@ class DividendsSummary
if (!isset($test[$country]['incomes'][$val->getTax()])) {
$test[$country]['incomes'][$val->getTax()] = 0;
}
if ($this->getRate($val) < 1) {
die("Rate for date: ".$val->getDateTime()->format("Y-m-d")." / ".$val->getCurrency() . " is 0");
}
$income = round($val->getCount()*$val->getValue()*$this->getRate($val),5);
$test[$country]['incomeAll'] += $income;
$test[$country]['tax'] += round($this->count($val),5);
$test[$country]['destiny_tax'] += round($this->count($val,true),5);
$test[$country]['tax_cost'] += round($this->countTaxPrice($val),5);
$test[$country]['incomes'][$val->getTax()] += $income;
if (!isset($countryToCurrency[$country])) {
$countryToCurrency[$country] = $val->getCurrency();
}
+9 -7
View File
@@ -14,10 +14,11 @@ class ExanteSheet extends SheetDataAll
continue;
}
foreach ($rawDatum as $key => $value) {
if (strpos($value, "Comment") !== false) {
$value = strtolower($value);
if (str_contains($value, "comment")) {
$commentKey = $key;
}
if (strpos($value, "Operation type") !== false) {
if (str_contains($value, "operation type")) {
$operationKey = $key;
}
}
@@ -27,10 +28,15 @@ class ExanteSheet extends SheetDataAll
if ($index<2) {
continue;
}
if (strtolower($rawDatum[$operationKey]) === "tax") {
$operationType = strtolower($rawDatum[$operationKey]);
if (!str_contains($operationType,"dividend")) {
continue;
}
$comment = $rawDatum[$commentKey];
if (!str_contains($comment, "dividend")) {
continue;
}
$separate = explode(" ",$comment);
$tax = intval(str_replace(["(","-","%",")"],"",$separate[16]));
$value = floatval(str_replace(["(",")"],"",$separate[10]));
@@ -44,10 +50,6 @@ class ExanteSheet extends SheetDataAll
$dividendObj->setValue($value);
$ret[] = $dividendObj;
}
if ($commentKey === -1) {
trigger_error(var_export("false",true));
return [];
}
return $ret;
}
+14 -4
View File
@@ -28,9 +28,8 @@ class IbkrSheet extends SheetDataAll
$dividendArr = [];
$taxArr = [];
$test = [];
foreach ($this->getRawData() as $index => $rawDatum) {
if ($index < 1) {
if ($index < 2) {
continue;
}
$row=[];
@@ -50,18 +49,29 @@ 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;
}
$separate = explode(" ", $dividend['description']);
$perShare = floatval($separate[4]);
if (!$perShare) {
$perShare = floatval($separate[5]);
}
if (!$perShare) {
continue;
}
$date = explode(";", $dividend['date'])[0];
$date = substr($date, 0, 4) . "-" . substr($date, 4, 2) . "-" . substr($date, 6, 2);
if (substr_count($date, "-") !== 2) {
$date = substr($date, 0, 4) . "-" . substr($date, 4, 2) . "-" . substr($date, 6, 2);
}
// trigger_error(var_export($date,true));
$dividendObj = new DividendsData();
$dividendObj->setCount(intval($dividend['amount'] / $perShare));
$dividendObj->setIsin($dividend['isin']);
@@ -2,6 +2,8 @@
namespace App\Logic\Dividends;
use function Symfony\Component\Translation\t;
abstract class SheetDataAll
{
protected int $countData;