mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Finalise boxes.
This commit is contained in:
@@ -163,7 +163,7 @@ class BasicController extends Controller
|
|||||||
'sum' => '0',
|
'sum' => '0',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$newIncomes = [
|
$newIncomes = [
|
||||||
$default->id => [
|
$default->id => [
|
||||||
'currency_id' => $default->id,
|
'currency_id' => $default->id,
|
||||||
'currency_code' => $default->code,
|
'currency_code' => $default->code,
|
||||||
@@ -172,7 +172,7 @@ class BasicController extends Controller
|
|||||||
'sum' => '0',
|
'sum' => '0',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$sums = [
|
$sums = [
|
||||||
$default->id => [
|
$default->id => [
|
||||||
'currency_id' => $default->id,
|
'currency_id' => $default->id,
|
||||||
'currency_code' => $default->code,
|
'currency_code' => $default->code,
|
||||||
@@ -184,7 +184,7 @@ class BasicController extends Controller
|
|||||||
|
|
||||||
$converter = new ExchangeRateConverter();
|
$converter = new ExchangeRateConverter();
|
||||||
// loop over income and expenses
|
// loop over income and expenses
|
||||||
foreach([$expenses, $incomes] as $index => $array) {
|
foreach ([$expenses, $incomes] as $index => $array) {
|
||||||
|
|
||||||
// loop over either one.
|
// loop over either one.
|
||||||
foreach ($array as $entry) {
|
foreach ($array as $entry) {
|
||||||
@@ -194,10 +194,10 @@ class BasicController extends Controller
|
|||||||
$sums[$default->id]['sum'] = bcadd($entry['sum'], $sums[$default->id]['sum']);
|
$sums[$default->id]['sum'] = bcadd($entry['sum'], $sums[$default->id]['sum']);
|
||||||
|
|
||||||
// don't forget to add it to newExpenses and newIncome
|
// don't forget to add it to newExpenses and newIncome
|
||||||
if(0 === $index) {
|
if (0 === $index) {
|
||||||
$newExpenses[$default->id]['sum'] = bcadd($newExpenses[$default->id]['sum'], $entry['sum']);
|
$newExpenses[$default->id]['sum'] = bcadd($newExpenses[$default->id]['sum'], $entry['sum']);
|
||||||
}
|
}
|
||||||
if(1 === $index) {
|
if (1 === $index) {
|
||||||
$newIncomes[$default->id]['sum'] = bcadd($newIncomes[$default->id]['sum'], $entry['sum']);
|
$newIncomes[$default->id]['sum'] = bcadd($newIncomes[$default->id]['sum'], $entry['sum']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,22 +207,22 @@ class BasicController extends Controller
|
|||||||
$currencies[$entry['currency_id']] ??= $this->currencyRepos->find($entry['currency_id']);
|
$currencies[$entry['currency_id']] ??= $this->currencyRepos->find($entry['currency_id']);
|
||||||
$convertedSum = $converter->convert($currencies[$entry['currency_id']], $default, $start, $entry['sum']);
|
$convertedSum = $converter->convert($currencies[$entry['currency_id']], $default, $start, $entry['sum']);
|
||||||
$sums[$default->id]['sum'] = bcadd($sums[$default->id]['sum'], $convertedSum);
|
$sums[$default->id]['sum'] = bcadd($sums[$default->id]['sum'], $convertedSum);
|
||||||
if(0 === $index) {
|
if (0 === $index) {
|
||||||
$newExpenses[$default->id]['sum'] = bcadd($newExpenses[$default->id]['sum'], $convertedSum);
|
$newExpenses[$default->id]['sum'] = bcadd($newExpenses[$default->id]['sum'], $convertedSum);
|
||||||
}
|
}
|
||||||
if(1 === $index) {
|
if (1 === $index) {
|
||||||
$newIncomes[$default->id]['sum'] = bcadd($newIncomes[$default->id]['sum'], $convertedSum);
|
$newIncomes[$default->id]['sum'] = bcadd($newIncomes[$default->id]['sum'], $convertedSum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$incomes = $newIncomes;
|
$incomes = $newIncomes;
|
||||||
$expenses = $newExpenses;
|
$expenses = $newExpenses;
|
||||||
}
|
}
|
||||||
if(!$convertToNative) {
|
if (!$convertToNative) {
|
||||||
foreach([$expenses, $incomes] as $array) {
|
foreach ([$expenses, $incomes] as $array) {
|
||||||
foreach ($array as $entry) {
|
foreach ($array as $entry) {
|
||||||
$currencyId = $entry['currency_id'];
|
$currencyId = $entry['currency_id'];
|
||||||
$sums[$currencyId] ??= [
|
$sums[$currencyId] ??= [
|
||||||
'currency_id' => $entry['currency_id'],
|
'currency_id' => $entry['currency_id'],
|
||||||
'currency_code' => $entry['currency_code'],
|
'currency_code' => $entry['currency_code'],
|
||||||
'currency_symbol' => $entry['currency_symbol'],
|
'currency_symbol' => $entry['currency_symbol'],
|
||||||
@@ -333,54 +333,54 @@ class BasicController extends Controller
|
|||||||
*/
|
*/
|
||||||
$paidAmount = $this->billRepository->sumPaidInRange($start, $end);
|
$paidAmount = $this->billRepository->sumPaidInRange($start, $end);
|
||||||
$unpaidAmount = $this->billRepository->sumUnpaidInRange($start, $end);
|
$unpaidAmount = $this->billRepository->sumUnpaidInRange($start, $end);
|
||||||
$currencies = [
|
$currencies = [
|
||||||
$this->nativeCurrency->id => $this->nativeCurrency,
|
$this->nativeCurrency->id => $this->nativeCurrency,
|
||||||
];
|
];
|
||||||
|
|
||||||
if($this->convertToNative) {
|
if ($this->convertToNative) {
|
||||||
$converter = new ExchangeRateConverter();
|
$converter = new ExchangeRateConverter();
|
||||||
$newPaidAmount = [[
|
$newPaidAmount = [[
|
||||||
'id' => $this->nativeCurrency->id,
|
'id' => $this->nativeCurrency->id,
|
||||||
'name' => $this->nativeCurrency->name,
|
'name' => $this->nativeCurrency->name,
|
||||||
'symbol' => $this->nativeCurrency->symbol,
|
'symbol' => $this->nativeCurrency->symbol,
|
||||||
'code' => $this->nativeCurrency->code,
|
'code' => $this->nativeCurrency->code,
|
||||||
'decimal_places' => $this->nativeCurrency->decimal_places,
|
'decimal_places' => $this->nativeCurrency->decimal_places,
|
||||||
'sum' => '0'
|
'sum' => '0',
|
||||||
]];
|
]];
|
||||||
|
|
||||||
$newUnpaidAmount = [[
|
$newUnpaidAmount = [[
|
||||||
'id' => $this->nativeCurrency->id,
|
'id' => $this->nativeCurrency->id,
|
||||||
'name' => $this->nativeCurrency->name,
|
'name' => $this->nativeCurrency->name,
|
||||||
'symbol' => $this->nativeCurrency->symbol,
|
'symbol' => $this->nativeCurrency->symbol,
|
||||||
'code' => $this->nativeCurrency->code,
|
'code' => $this->nativeCurrency->code,
|
||||||
'decimal_places' => $this->nativeCurrency->decimal_places,
|
'decimal_places' => $this->nativeCurrency->decimal_places,
|
||||||
'sum' => '0'
|
'sum' => '0',
|
||||||
]];
|
]];
|
||||||
foreach([$paidAmount, $unpaidAmount] as $index => $array) {
|
foreach ([$paidAmount, $unpaidAmount] as $index => $array) {
|
||||||
foreach($array as $item) {
|
foreach ($array as $item) {
|
||||||
$currencyId = (int)$item['id'];
|
$currencyId = (int) $item['id'];
|
||||||
if(0 === $index) {
|
if (0 === $index) {
|
||||||
// paid amount
|
// paid amount
|
||||||
if($currencyId === $this->nativeCurrency->id) {
|
if ($currencyId === $this->nativeCurrency->id) {
|
||||||
$newPaidAmount[0]['sum'] = bcadd($newPaidAmount[0]['sum'], $item['sum']);
|
$newPaidAmount[0]['sum'] = bcadd($newPaidAmount[0]['sum'], $item['sum']);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$currencies[$currencyId] ??= $this->currencyRepos->find($currencyId);
|
$currencies[$currencyId] ??= $this->currencyRepos->find($currencyId);
|
||||||
$convertedAmount = $converter->convert($currencies[$currencyId], $this->nativeCurrency, $start, $item['sum']);
|
$convertedAmount = $converter->convert($currencies[$currencyId], $this->nativeCurrency, $start, $item['sum']);
|
||||||
$newPaidAmount[0]['sum'] = bcadd($newPaidAmount[0]['sum'], $convertedAmount);
|
$newPaidAmount[0]['sum'] = bcadd($newPaidAmount[0]['sum'], $convertedAmount);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// unpaid amount
|
// unpaid amount
|
||||||
if($currencyId === $this->nativeCurrency->id) {
|
if ($currencyId === $this->nativeCurrency->id) {
|
||||||
$newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], $item['sum']);
|
$newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], $item['sum']);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$currencies[$currencyId] ??= $this->currencyRepos->find($currencyId);
|
$currencies[$currencyId] ??= $this->currencyRepos->find($currencyId);
|
||||||
$convertedAmount = $converter->convert($currencies[$currencyId], $this->nativeCurrency, $start, $item['sum']);
|
$convertedAmount = $converter->convert($currencies[$currencyId], $this->nativeCurrency, $start, $item['sum']);
|
||||||
$newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], $convertedAmount);
|
$newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], $convertedAmount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$paidAmount = $newPaidAmount;
|
$paidAmount = $newPaidAmount;
|
||||||
$unpaidAmount = $newUnpaidAmount;
|
$unpaidAmount = $newUnpaidAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -138,7 +138,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface, U
|
|||||||
->where('end_date', $end->format('Y-m-d'))->get()
|
->where('end_date', $end->format('Y-m-d'))->get()
|
||||||
;
|
;
|
||||||
|
|
||||||
Log::debug(sprintf('Found %d available budgets', $availableBudgets->count()));
|
Log::debug(sprintf('Found %d available budgets (already converted)', $availableBudgets->count()));
|
||||||
|
|
||||||
// use native amount if necessary?
|
// use native amount if necessary?
|
||||||
$convertToNative = Amount::convertToNative($this->user);
|
$convertToNative = Amount::convertToNative($this->user);
|
||||||
|
Reference in New Issue
Block a user