mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-16 01:06:46 +00:00
Fix currency seeder, add some debug logs.
This commit is contained in:
@@ -91,7 +91,7 @@ class IndexController extends Controller
|
|||||||
public function index(?Carbon $start = null, ?Carbon $end = null)
|
public function index(?Carbon $start = null, ?Carbon $end = null)
|
||||||
{
|
{
|
||||||
$this->abRepository->cleanup();
|
$this->abRepository->cleanup();
|
||||||
app('log')->debug(sprintf('Start of IndexController::index("%s", "%s")', $start?->format('Y-m-d'), $end?->format('Y-m-d')));
|
Log::debug(sprintf('Start of IndexController::index("%s", "%s")', $start?->format('Y-m-d'), $end?->format('Y-m-d')));
|
||||||
|
|
||||||
// collect some basic vars:
|
// collect some basic vars:
|
||||||
$range = app('navigation')->getViewRange(true);
|
$range = app('navigation')->getViewRange(true);
|
||||||
@@ -199,12 +199,12 @@ class IndexController extends Controller
|
|||||||
// get all budgets, and paginate them into $budgets.
|
// get all budgets, and paginate them into $budgets.
|
||||||
$collection = $this->repository->getActiveBudgets();
|
$collection = $this->repository->getActiveBudgets();
|
||||||
$budgets = [];
|
$budgets = [];
|
||||||
app('log')->debug(sprintf('7) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
Log::debug(sprintf('(getAllBudgets) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||||
|
|
||||||
// complement budget with budget limits in range, and expenses in currency X in range.
|
// complement budget with budget limits in range, and expenses in currency X in range.
|
||||||
/** @var Budget $current */
|
/** @var Budget $current */
|
||||||
foreach ($collection as $current) {
|
foreach ($collection as $current) {
|
||||||
app('log')->debug(sprintf('Working on budget #%d ("%s")', $current->id, $current->name));
|
Log::debug(sprintf('Working on budget #%d ("%s")', $current->id, $current->name));
|
||||||
$array = $current->toArray();
|
$array = $current->toArray();
|
||||||
$array['spent'] = [];
|
$array['spent'] = [];
|
||||||
$array['spent_total'] = [];
|
$array['spent_total'] = [];
|
||||||
@@ -215,7 +215,7 @@ class IndexController extends Controller
|
|||||||
|
|
||||||
/** @var BudgetLimit $limit */
|
/** @var BudgetLimit $limit */
|
||||||
foreach ($budgetLimits as $limit) {
|
foreach ($budgetLimits as $limit) {
|
||||||
app('log')->debug(sprintf('Working on budget limit #%d', $limit->id));
|
Log::debug(sprintf('Working on budget limit #%d', $limit->id));
|
||||||
$currency = $limit->transactionCurrency ?? $defaultCurrency;
|
$currency = $limit->transactionCurrency ?? $defaultCurrency;
|
||||||
$amount = app('steam')->bcround($limit->amount, $currency->decimal_places);
|
$amount = app('steam')->bcround($limit->amount, $currency->decimal_places);
|
||||||
$array['budgeted'][] = [
|
$array['budgeted'][] = [
|
||||||
@@ -231,9 +231,11 @@ class IndexController extends Controller
|
|||||||
'currency_name' => $currency->name,
|
'currency_name' => $currency->name,
|
||||||
'currency_decimal_places' => $currency->decimal_places,
|
'currency_decimal_places' => $currency->decimal_places,
|
||||||
];
|
];
|
||||||
app('log')->debug(sprintf('The amount budgeted for budget limit #%d is %s %s', $limit->id, $currency->code, $amount));
|
Log::debug(sprintf('The amount budgeted for budget limit #%d is %s %s', $limit->id, $currency->code, $amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #10463
|
||||||
|
|
||||||
/** @var TransactionCurrency $currency */
|
/** @var TransactionCurrency $currency */
|
||||||
foreach ($currencies as $currency) {
|
foreach ($currencies as $currency) {
|
||||||
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, new Collection([$current]), $currency, false);
|
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, new Collection([$current]), $currency, false);
|
||||||
@@ -260,6 +262,7 @@ class IndexController extends Controller
|
|||||||
|
|
||||||
/** @var array $budget */
|
/** @var array $budget */
|
||||||
foreach ($budgets as $budget) {
|
foreach ($budgets as $budget) {
|
||||||
|
Log::debug(sprintf('Now working on budget #%d ("%s")', $budget['id'], $budget['name']));
|
||||||
/** @var array $spent */
|
/** @var array $spent */
|
||||||
foreach ($budget['spent'] as $spent) {
|
foreach ($budget['spent'] as $spent) {
|
||||||
$currencyId = $spent['currency_id'];
|
$currencyId = $spent['currency_id'];
|
||||||
|
@@ -204,7 +204,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
|
|||||||
?TransactionCurrency $currency = null,
|
?TransactionCurrency $currency = null,
|
||||||
bool $convertToNative = false
|
bool $convertToNative = false
|
||||||
): array {
|
): array {
|
||||||
Log::debug(sprintf('Start of %s(date, date, array, array, "%s", "%s").', __METHOD__, $currency?->code, var_export($convertToNative, true)));
|
Log::debug(sprintf('Start of %s(date, date, array, array, "%s", %s).', __METHOD__, $currency?->code, var_export($convertToNative, true)));
|
||||||
// this collector excludes all transfers TO liabilities (which are also withdrawals)
|
// this collector excludes all transfers TO liabilities (which are also withdrawals)
|
||||||
// because those expenses only become expenses once they move from the liability to the friend.
|
// because those expenses only become expenses once they move from the liability to the friend.
|
||||||
// 2024-12-24 disable the exclusion for now.
|
// 2024-12-24 disable the exclusion for now.
|
||||||
|
@@ -70,6 +70,7 @@ interface OperationsRepositoryInterface
|
|||||||
Carbon $end,
|
Carbon $end,
|
||||||
?Collection $accounts = null,
|
?Collection $accounts = null,
|
||||||
?Collection $budgets = null,
|
?Collection $budgets = null,
|
||||||
?TransactionCurrency $currency = null
|
?TransactionCurrency $currency = null,
|
||||||
|
bool $convertToNative = false
|
||||||
): array;
|
): array;
|
||||||
}
|
}
|
||||||
|
@@ -51,7 +51,7 @@ class TransactionSummarizer
|
|||||||
|
|
||||||
public function groupByCurrencyId(array $journals, string $method = 'negative', bool $includeForeign = true): array
|
public function groupByCurrencyId(array $journals, string $method = 'negative', bool $includeForeign = true): array
|
||||||
{
|
{
|
||||||
Log::debug(sprintf('Now in groupByCurrencyId([%d journals], "%s")', count($journals), $method));
|
Log::debug(sprintf('Now in groupByCurrencyId([%d journals], "%s", %s)', count($journals), $method, var_export($includeForeign, true)));
|
||||||
$array = [];
|
$array = [];
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$field = 'amount';
|
$field = 'amount';
|
||||||
|
@@ -66,7 +66,8 @@ class TransactionCurrencySeeder extends Seeder
|
|||||||
|
|
||||||
// asian currencies
|
// asian currencies
|
||||||
$currencies[] = ['code' => 'JPY', 'name' => 'Japanese yen', 'symbol' => '¥', 'decimal_places' => 0];
|
$currencies[] = ['code' => 'JPY', 'name' => 'Japanese yen', 'symbol' => '¥', 'decimal_places' => 0];
|
||||||
$currencies[] = ['code' => 'CNY', 'name' => 'Chinese yuan', 'symbol' => '¥', 'decimal_places' => 2];
|
//$currencies[] = ['code' => 'CNY', 'name' => 'Chinese yuan', 'symbol' => '¥', 'decimal_places' => 2];
|
||||||
|
$currencies[] = ['code' => 'RMB', 'name' => 'Chinese yuan', 'symbol' => '¥', 'decimal_places' => 2];
|
||||||
$currencies[] = ['code' => 'RUB', 'name' => 'Russian ruble', 'symbol' => '₽', 'decimal_places' => 2];
|
$currencies[] = ['code' => 'RUB', 'name' => 'Russian ruble', 'symbol' => '₽', 'decimal_places' => 2];
|
||||||
$currencies[] = ['code' => 'INR', 'name' => 'Indian rupee', 'symbol' => '₹', 'decimal_places' => 2];
|
$currencies[] = ['code' => 'INR', 'name' => 'Indian rupee', 'symbol' => '₹', 'decimal_places' => 2];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user