mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-18 02:03:40 +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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -91,33 +91,33 @@ class JournalFormRequest extends Request
|
|||||||
{
|
{
|
||||||
$what = $this->get('what');
|
$what = $this->get('what');
|
||||||
$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',
|
||||||
'process_date' => 'date|nullable',
|
'process_date' => 'date|nullable',
|
||||||
'due_date' => 'date|nullable',
|
'due_date' => 'date|nullable',
|
||||||
'payment_date' => 'date|nullable',
|
'payment_date' => 'date|nullable',
|
||||||
'invoice_date' => 'date|nullable',
|
'invoice_date' => 'date|nullable',
|
||||||
'internal_reference' => 'min:1,max:255|nullable',
|
'internal_reference' => 'min:1,max:255|nullable',
|
||||||
'notes' => 'min:1,max:50000|nullable',
|
'notes' => 'min:1,max:50000|nullable',
|
||||||
// and then transaction rules:
|
// and then transaction rules:
|
||||||
'description' => 'required|between:1,255',
|
'description' => 'required|between:1,255',
|
||||||
'amount' => 'numeric|required|more:0',
|
'amount' => 'numeric|required|more:0',
|
||||||
'budget_id' => 'mustExist:budgets,id|belongsToUser:budgets,id|nullable',
|
'budget_id' => 'mustExist:budgets,id|belongsToUser:budgets,id|nullable',
|
||||||
'category' => 'between:1,255|nullable',
|
'category' => 'between:1,255|nullable',
|
||||||
'source_account_id' => 'numeric|belongsToUser:accounts,id|nullable',
|
'source_account_id' => 'numeric|belongsToUser:accounts,id|nullable',
|
||||||
'source_account_name' => 'between:1,255|nullable',
|
'source_account_name' => 'between:1,255|nullable',
|
||||||
'destination_account_id' => 'numeric|belongsToUser:accounts,id|nullable',
|
'destination_account_id' => 'numeric|belongsToUser:accounts,id|nullable',
|
||||||
'destination_account_name' => 'between:1,255|nullable',
|
'destination_account_name' => 'between:1,255|nullable',
|
||||||
'piggy_bank_id' => 'between:1,255|nullable',
|
'piggy_bank_id' => 'between:1,255|nullable',
|
||||||
|
|
||||||
// foreign currency amounts
|
// foreign currency amounts
|
||||||
'native_amount' => 'numeric|more:0|nullable',
|
'native_amount' => 'numeric|more:0|nullable',
|
||||||
'source_amount' => 'numeric|more:0|nullable',
|
'source_amount' => 'numeric|more:0|nullable',
|
||||||
'destination_amount' => 'numeric|more:0|nullable',
|
'destination_amount' => 'numeric|more:0|nullable',
|
||||||
];
|
];
|
||||||
|
|
||||||
// some rules get an upgrade depending on the type of data:
|
// some rules get an upgrade depending on the type of data:
|
||||||
|
@@ -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