This commit is contained in:
2022-03-25 17:41:26 +01:00
parent 34685838bc
commit 5cd788c765
+50 -9
View File
@@ -20,20 +20,61 @@ class Crypto extends Main
/** @var MainObject $item */
foreach ($all as $item) {
if (!in_array($item->getCurrency(), Currency::$currencies)) {
if ($item->getValue() == 0) {
continue;
if ($item->getValue() == 0) {
continue;
}
// if (!isset($sum[$item->getCurrency()])) {
// $sum[$item->getCurrency()] = [];
// if (!isset($sum[$item->getCurrency()][$item->getDateTime()->format("Y-m-d")])){
// $sum[$item->getCurrency()][$item->getDateTime()->format("Y-m-d")] = [];
// }
// }
// $sum[$item->getCurrency()][$item->getDateTime()->format("Y-m-d")][] = $item;
$date = $item->getDateTime()->format("Y-m-d");
if (!isset($sum[$date])) {
$sum[$date] = [];
}
if (!isset($sum[$date][$item->getCurrency()])){
$sum[$date][$item->getCurrency()] = [];
}
$sum[$date][$item->getCurrency()][] = $item;
}
$test=[];
foreach ($sum as $date => $items) {
$keys = array_keys($items);
$crypto="";
$succ=false;
foreach ($keys as $key) {
if ($key === "PLN") {
$succ = true;
} else {
$crypto = $key;
}
if (!isset($sum[$item->getCurrency()])) {
$sum[$item->getCurrency()] = [];
if (!isset($sum[$item->getCurrency()][$item->getDateTime()->format("Y-m-d")])){
$sum[$item->getCurrency()][$item->getDateTime()->format("Y-m-d")] = [];
}
if (!$succ) {
continue;
}
if (!isset($test[$crypto])) {
$test[$crypto] = [];
}
$arr = [
"crypto" => 0,
"pln" => 0
];
/** @var MainObject $obj */
foreach ($items as $currency => $obj1) {
foreach ($obj1 as $obj) {
if ($currency === $crypto) {
$arr['crypto'] += $obj->getValue();
} else {
$arr['pln'] += $obj->getValue();
}
}
$sum[$item->getCurrency()][$item->getDateTime()->format("Y-m-d")][] = $item;
}
$test[$crypto] = $arr;
}
return $sum;
return $test;
}
}