mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-25 18:30:55 -06:00
Extra fix to cover for #1091
This commit is contained in:
parent
fa676f60fb
commit
cdeabaaf9a
@ -146,6 +146,7 @@ class UpgradeDatabase extends Command
|
||||
|
||||
// both 0? set to default currency:
|
||||
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]);
|
||||
$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
|
||||
*/
|
||||
private function var_dump_ret($mixed = null): string {
|
||||
private function var_dump_ret($mixed = null): string
|
||||
{
|
||||
ob_start();
|
||||
var_dump($mixed);
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
@ -91,33 +91,33 @@ class JournalFormRequest extends Request
|
||||
{
|
||||
$what = $this->get('what');
|
||||
$rules = [
|
||||
'what' => 'required|in:withdrawal,deposit,transfer',
|
||||
'date' => 'required|date',
|
||||
|
||||
'what' => 'required|in:withdrawal,deposit,transfer',
|
||||
'date' => 'required|date',
|
||||
'amount_currency_id_amount' => 'exists:transaction_currencies,id|required',
|
||||
// then, custom fields:
|
||||
'interest_date' => 'date|nullable',
|
||||
'book_date' => 'date|nullable',
|
||||
'process_date' => 'date|nullable',
|
||||
'due_date' => 'date|nullable',
|
||||
'payment_date' => 'date|nullable',
|
||||
'invoice_date' => 'date|nullable',
|
||||
'internal_reference' => 'min:1,max:255|nullable',
|
||||
'notes' => 'min:1,max:50000|nullable',
|
||||
'interest_date' => 'date|nullable',
|
||||
'book_date' => 'date|nullable',
|
||||
'process_date' => 'date|nullable',
|
||||
'due_date' => 'date|nullable',
|
||||
'payment_date' => 'date|nullable',
|
||||
'invoice_date' => 'date|nullable',
|
||||
'internal_reference' => 'min:1,max:255|nullable',
|
||||
'notes' => 'min:1,max:50000|nullable',
|
||||
// and then transaction rules:
|
||||
'description' => 'required|between:1,255',
|
||||
'amount' => 'numeric|required|more:0',
|
||||
'budget_id' => 'mustExist:budgets,id|belongsToUser:budgets,id|nullable',
|
||||
'category' => 'between:1,255|nullable',
|
||||
'source_account_id' => 'numeric|belongsToUser:accounts,id|nullable',
|
||||
'source_account_name' => 'between:1,255|nullable',
|
||||
'destination_account_id' => 'numeric|belongsToUser:accounts,id|nullable',
|
||||
'destination_account_name' => 'between:1,255|nullable',
|
||||
'piggy_bank_id' => 'between:1,255|nullable',
|
||||
'description' => 'required|between:1,255',
|
||||
'amount' => 'numeric|required|more:0',
|
||||
'budget_id' => 'mustExist:budgets,id|belongsToUser:budgets,id|nullable',
|
||||
'category' => 'between:1,255|nullable',
|
||||
'source_account_id' => 'numeric|belongsToUser:accounts,id|nullable',
|
||||
'source_account_name' => 'between:1,255|nullable',
|
||||
'destination_account_id' => 'numeric|belongsToUser:accounts,id|nullable',
|
||||
'destination_account_name' => 'between:1,255|nullable',
|
||||
'piggy_bank_id' => 'between:1,255|nullable',
|
||||
|
||||
// foreign currency amounts
|
||||
'native_amount' => 'numeric|more:0|nullable',
|
||||
'source_amount' => 'numeric|more:0|nullable',
|
||||
'destination_amount' => 'numeric|more:0|nullable',
|
||||
'native_amount' => 'numeric|more:0|nullable',
|
||||
'source_amount' => 'numeric|more:0|nullable',
|
||||
'destination_amount' => 'numeric|more:0|nullable',
|
||||
];
|
||||
|
||||
// some rules get an upgrade depending on the type of data:
|
||||
|
@ -249,6 +249,10 @@ trait SupportJournalsTrait
|
||||
case TransactionType::WITHDRAWAL:
|
||||
// continue:
|
||||
$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:
|
||||
if ($nativeCurrencyId !== $submittedCurrencyId) {
|
||||
|
@ -72,6 +72,7 @@ class Steam
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d'))
|
||||
->where('transactions.foreign_currency_id', $currencyId)
|
||||
->where('transactions.transaction_currency_id', '!=', $currencyId)
|
||||
->sum('transactions.foreign_amount')
|
||||
);
|
||||
$balance = bcadd($nativeBalance, $foreignBalance);
|
||||
@ -114,6 +115,7 @@ class Steam
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d'))
|
||||
->where('transactions.foreign_currency_id', $currencyId)
|
||||
->where('transactions.transaction_currency_id', '!=', $currencyId)
|
||||
->sum('transactions.foreign_amount')
|
||||
);
|
||||
$balance = bcadd($nativeBalance, $foreignBalance);
|
||||
|
Loading…
Reference in New Issue
Block a user