Fix rounding and conversion issues on statistics
This commit is contained in:
parent
cce3b0f85c
commit
74d851ea7a
@ -51,7 +51,7 @@
|
|||||||
$print[$id]['payment_method_name'] = $payment_methods[$paymentMethodId]['name'];
|
$print[$id]['payment_method_name'] = $payment_methods[$paymentMethodId]['name'];
|
||||||
$print[$id]['category_id'] = $subscription['category_id'];
|
$print[$id]['category_id'] = $subscription['category_id'];
|
||||||
$print[$id]['payer_user_id'] = $subscription['payer_user_id'];
|
$print[$id]['payer_user_id'] = $subscription['payer_user_id'];
|
||||||
$print[$id]['price'] = $subscription['price'];
|
$print[$id]['price'] = floatval($subscription['price']);
|
||||||
|
|
||||||
if (isset($_COOKIE['convertCurrency']) && $_COOKIE['convertCurrency'] === 'true' && $currencyId != $mainCurrencyId) {
|
if (isset($_COOKIE['convertCurrency']) && $_COOKIE['convertCurrency'] === 'true' && $currencyId != $mainCurrencyId) {
|
||||||
$print[$id]['price'] = getPriceConverted($print[$id]['price'], $currencyId, $db);
|
$print[$id]['price'] = getPriceConverted($print[$id]['price'], $currencyId, $db);
|
||||||
|
|||||||
@ -50,11 +50,11 @@
|
|||||||
return $price;
|
return $price;
|
||||||
} else {
|
} else {
|
||||||
$fromRate = $exchangeRate['rate'];
|
$fromRate = $exchangeRate['rate'];
|
||||||
return number_format($price / $fromRate, 2);
|
return $price / $fromRate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function printSubscriptons($subscriptions, $sort, $categories) {
|
function printSubscriptons($subscriptions, $sort, $categories, $members) {
|
||||||
if ($sort === "price") {
|
if ($sort === "price") {
|
||||||
usort($subscriptions, function($a, $b) {
|
usort($subscriptions, function($a, $b) {
|
||||||
return $a['price'] < $b['price'] ? 1 : -1;
|
return $a['price'] < $b['price'] ? 1 : -1;
|
||||||
@ -62,6 +62,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$currentCategory = 0;
|
$currentCategory = 0;
|
||||||
|
$currentPayerUserId = 0;
|
||||||
foreach ($subscriptions as $subscription) {
|
foreach ($subscriptions as $subscription) {
|
||||||
if ($sort == "category_id" && $subscription['category_id'] != $currentCategory) {
|
if ($sort == "category_id" && $subscription['category_id'] != $currentCategory) {
|
||||||
?>
|
?>
|
||||||
@ -71,6 +72,14 @@
|
|||||||
<?php
|
<?php
|
||||||
$currentCategory = $subscription['category_id'];
|
$currentCategory = $subscription['category_id'];
|
||||||
}
|
}
|
||||||
|
if ($sort == "payer_user_id" && $subscription['payer_user_id'] != $currentPayerUserId) {
|
||||||
|
?>
|
||||||
|
<div class="subscription-list-title">
|
||||||
|
<?= $members[$subscription['payer_user_id']]['name'] ?>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
$currentPayerUserId = $subscription['payer_user_id'];
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<div class="subscription">
|
<div class="subscription">
|
||||||
<span class="logo <?= $subscription['hidelogo'] ?>"><img src="<?= $subscription['logo'] ?>"></span>
|
<span class="logo <?= $subscription['hidelogo'] ?>"><img src="<?= $subscription['logo'] ?>"></span>
|
||||||
|
|||||||
@ -79,7 +79,7 @@
|
|||||||
$print[$id]['payment_method_name'] = $payment_methods[$paymentMethodId]['name'];
|
$print[$id]['payment_method_name'] = $payment_methods[$paymentMethodId]['name'];
|
||||||
$print[$id]['category_id'] = $subscription['category_id'];
|
$print[$id]['category_id'] = $subscription['category_id'];
|
||||||
$print[$id]['payer_user_id'] = $subscription['payer_user_id'];
|
$print[$id]['payer_user_id'] = $subscription['payer_user_id'];
|
||||||
$print[$id]['price'] = $subscription['price'];
|
$print[$id]['price'] = floatval($subscription['price']);
|
||||||
|
|
||||||
if (isset($_COOKIE['convertCurrency']) && $_COOKIE['convertCurrency'] === 'true' && $currencyId != $mainCurrencyId) {
|
if (isset($_COOKIE['convertCurrency']) && $_COOKIE['convertCurrency'] === 'true' && $currencyId != $mainCurrencyId) {
|
||||||
$print[$id]['price'] = getPriceConverted($print[$id]['price'], $currencyId, $db);
|
$print[$id]['price'] = getPriceConverted($print[$id]['price'], $currencyId, $db);
|
||||||
|
|||||||
@ -38,7 +38,7 @@
|
|||||||
return $price;
|
return $price;
|
||||||
} else {
|
} else {
|
||||||
$fromRate = $exchangeRate['rate'];
|
$fromRate = $exchangeRate['rate'];
|
||||||
return number_format($price * $fromRate, 2, ".", "");
|
return $price / $fromRate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ if ($result) {
|
|||||||
<div class="title">Most Expensive Subscription Cost</div>
|
<div class="title">Most Expensive Subscription Cost</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="statistic">
|
<div class="statistic">
|
||||||
<span><?= $amountDueThisMonth ?><?= $symbol ?></span>
|
<span><?= number_format($amountDueThisMonth, 2, ".", "") ?><?= $symbol ?></span>
|
||||||
<div class="title">Amount due this month</div>
|
<div class="title">Amount due this month</div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user