diff --git a/project/src/Helper/FIFO/Crypto.php b/project/src/Helper/FIFO/Crypto.php index b370a05..5935151 100644 --- a/project/src/Helper/FIFO/Crypto.php +++ b/project/src/Helper/FIFO/Crypto.php @@ -25,6 +25,8 @@ class Crypto extends Main if ($item->getValue() == 0) { continue; } + if ($item->getCurrency() === "BTC") + dd($item,$item->getValueCrypto()); // if (!isset($sum[$item->getCurrency()])) { // $sum[$item->getCurrency()] = []; // if (!isset($sum[$item->getCurrency()][$item->getDateTime()->format("Y-m-d")])){ diff --git a/project/src/Helper/FIFO/Main.php b/project/src/Helper/FIFO/Main.php index 5954b1a..b51b90a 100644 --- a/project/src/Helper/FIFO/Main.php +++ b/project/src/Helper/FIFO/Main.php @@ -40,12 +40,10 @@ class Main $obj = new MainObject(); foreach ($names as $key => $name) { if ($name === "setValue") { -// if ($datum[$key]!=="0,00") dd(); - $data = $datum[$key]; - if (is_string($data)) { - $data = strtr($data,",","."); - } - $datum[$key] = floatval($data); + $data = "$datum[$key]"; + $data = str_replace(",","",$data); + $data = str_replace(".","",$data); + $datum[$key] = $data; } if ($name === "setDateTime") { $datum[$key] = new \DateTime($datum[$key]); diff --git a/project/src/Logic/Crypto/MainObject.php b/project/src/Logic/Crypto/MainObject.php index 76e48cc..d34f9b8 100644 --- a/project/src/Logic/Crypto/MainObject.php +++ b/project/src/Logic/Crypto/MainObject.php @@ -8,7 +8,7 @@ class MainObject { private \DateTime $dateTime; private string $desc; - private float $value; + private string $value; private string $currency; private ?string $realCurrency=null; private float $realValue=0; @@ -79,17 +79,17 @@ class MainObject } /** - * @return float + * @return int */ - public function getValue(): float + public function getValue(): string { return $this->value; } /** - * @param float $value + * @param int $value */ - public function setValue(float $value): void + public function setValue(string $value): void { $this->value = $value; } @@ -110,7 +110,7 @@ class MainObject $this->currency = $currency; } - public function addValue(float $val) : void + public function addValue(int $val) : void { $this->value += $val; } @@ -132,4 +132,9 @@ class MainObject { return $this->price; } + + public function getValueCrypto() : float + { + return intval($this->value) / 100000000; + } } \ No newline at end of file