mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-26 05:26:17 +00:00
Extra fix to cover for #1091
This commit is contained in:
@@ -146,6 +146,7 @@ class UpgradeDatabase extends Command
|
|||||||
|
|
||||||
// both 0? set to default currency:
|
// both 0? set to default currency:
|
||||||
if (0 === $accountCurrency && 0 === $obCurrency) {
|
if (0 === $accountCurrency && 0 === $obCurrency) {
|
||||||
|
AccountMeta::where('account_id', $account->id)->where('name', 'currency_id')->forceDelete();
|
||||||
AccountMeta::create(['account_id' => $account->id, 'name' => 'currency_id', 'data' => $defaultCurrency->id]);
|
AccountMeta::create(['account_id' => $account->id, 'name' => 'currency_id', 'data' => $defaultCurrency->id]);
|
||||||
$this->line(sprintf('Account #%d ("%s") now has a currency setting (%s).', $account->id, $account->name, $defaultCurrencyCode));
|
$this->line(sprintf('Account #%d ("%s") now has a currency setting (%s).', $account->id, $account->name, $defaultCurrencyCode));
|
||||||
|
|
||||||
@@ -508,11 +509,13 @@ class UpgradeDatabase extends Command
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function var_dump_ret($mixed = null): string {
|
private function var_dump_ret($mixed = null): string
|
||||||
|
{
|
||||||
ob_start();
|
ob_start();
|
||||||
var_dump($mixed);
|
var_dump($mixed);
|
||||||
$content = ob_get_contents();
|
$content = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class JournalFormRequest extends Request
|
|||||||
$rules = [
|
$rules = [
|
||||||
'what' => 'required|in:withdrawal,deposit,transfer',
|
'what' => 'required|in:withdrawal,deposit,transfer',
|
||||||
'date' => 'required|date',
|
'date' => 'required|date',
|
||||||
|
'amount_currency_id_amount' => 'exists:transaction_currencies,id|required',
|
||||||
// then, custom fields:
|
// then, custom fields:
|
||||||
'interest_date' => 'date|nullable',
|
'interest_date' => 'date|nullable',
|
||||||
'book_date' => 'date|nullable',
|
'book_date' => 'date|nullable',
|
||||||
|
|||||||
@@ -249,6 +249,10 @@ trait SupportJournalsTrait
|
|||||||
case TransactionType::WITHDRAWAL:
|
case TransactionType::WITHDRAWAL:
|
||||||
// continue:
|
// continue:
|
||||||
$nativeCurrencyId = intval($accounts[$check]->getMeta('currency_id'));
|
$nativeCurrencyId = intval($accounts[$check]->getMeta('currency_id'));
|
||||||
|
if ($nativeCurrencyId === 0) {
|
||||||
|
// fall back to given ID (not everybody upgrades nicely).
|
||||||
|
$nativeCurrencyId = $submittedCurrencyId;
|
||||||
|
}
|
||||||
|
|
||||||
// does not match? Then user has submitted amount in a foreign currency:
|
// does not match? Then user has submitted amount in a foreign currency:
|
||||||
if ($nativeCurrencyId !== $submittedCurrencyId) {
|
if ($nativeCurrencyId !== $submittedCurrencyId) {
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ class Steam
|
|||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d'))
|
||||||
->where('transactions.foreign_currency_id', $currencyId)
|
->where('transactions.foreign_currency_id', $currencyId)
|
||||||
|
->where('transactions.transaction_currency_id', '!=', $currencyId)
|
||||||
->sum('transactions.foreign_amount')
|
->sum('transactions.foreign_amount')
|
||||||
);
|
);
|
||||||
$balance = bcadd($nativeBalance, $foreignBalance);
|
$balance = bcadd($nativeBalance, $foreignBalance);
|
||||||
@@ -114,6 +115,7 @@ class Steam
|
|||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d'))
|
||||||
->where('transactions.foreign_currency_id', $currencyId)
|
->where('transactions.foreign_currency_id', $currencyId)
|
||||||
|
->where('transactions.transaction_currency_id', '!=', $currencyId)
|
||||||
->sum('transactions.foreign_amount')
|
->sum('transactions.foreign_amount')
|
||||||
);
|
);
|
||||||
$balance = bcadd($nativeBalance, $foreignBalance);
|
$balance = bcadd($nativeBalance, $foreignBalance);
|
||||||
|
|||||||
Reference in New Issue
Block a user