mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Various fixes for sqlite databases
This commit is contained in:
parent
da88e02be0
commit
f2166b97b8
@ -128,8 +128,8 @@ class CorrectsNativeAmounts extends Command
|
||||
|
||||
foreach ($piggyBank->accounts as $account) {
|
||||
$account->pivot->native_current_amount = null;
|
||||
if (0 !== bccomp($account->pivot->current_amount, '0')) {
|
||||
$account->pivot->native_current_amount = $converter->convert($piggyBank->transactionCurrency, $currency, today(), $account->pivot->current_amount);
|
||||
if (0 !== bccomp((string) $account->pivot->current_amount, '0')) {
|
||||
$account->pivot->native_current_amount = $converter->convert($piggyBank->transactionCurrency, $currency, today(), (string) $account->pivot->current_amount);
|
||||
}
|
||||
$account->pivot->save();
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ class UpgradesTransferCurrencies extends Command
|
||||
use ShowsFriendlyMessages;
|
||||
|
||||
public const string CONFIG_NAME = '480_transfer_currencies';
|
||||
protected $description = 'Updates transfer currency information.';
|
||||
protected $signature = 'upgrade:480-transfer-currencies {--F|force : Force the execution of this command.}';
|
||||
protected $description = 'Updates transfer currency information.';
|
||||
protected $signature = 'upgrade:480-transfer-currencies {--F|force : Force the execution of this command.}';
|
||||
private array $accountCurrencies;
|
||||
private AccountRepositoryInterface $accountRepos;
|
||||
private JournalCLIRepositoryInterface $cliRepos;
|
||||
@ -68,9 +68,9 @@ class UpgradesTransferCurrencies extends Command
|
||||
|
||||
$this->startUpdateRoutine();
|
||||
$this->markAsExecuted();
|
||||
|
||||
$this->friendlyInfo(sprintf('Verified currency information of %d transfer(s).', $this->count));
|
||||
|
||||
if ($this->count > 0) {
|
||||
$this->friendlyInfo(sprintf('Verified currency information of %d transfer(s).', $this->count));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -211,14 +211,14 @@ class UpgradesTransferCurrencies extends Command
|
||||
|
||||
private function getCurrency(Account $account): ?TransactionCurrency
|
||||
{
|
||||
$accountId = $account->id;
|
||||
$accountId = $account->id;
|
||||
if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) {
|
||||
return null;
|
||||
}
|
||||
if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {
|
||||
return $this->accountCurrencies[$accountId];
|
||||
}
|
||||
$currency = $this->accountRepos->getAccountCurrency($account);
|
||||
$currency = $this->accountRepos->getAccountCurrency($account);
|
||||
if (null === $currency) {
|
||||
$this->accountCurrencies[$accountId] = 0;
|
||||
|
||||
@ -290,8 +290,7 @@ class UpgradesTransferCurrencies extends Command
|
||||
if (null === $this->sourceTransaction->transaction_currency_id && null !== $this->sourceCurrency) {
|
||||
$this->sourceTransaction
|
||||
->transaction_currency_id
|
||||
= $this->sourceCurrency->id
|
||||
;
|
||||
= $this->sourceCurrency->id;
|
||||
$message = sprintf(
|
||||
'Transaction #%d has no currency setting, now set to %s.',
|
||||
$this->sourceTransaction->id,
|
||||
@ -313,7 +312,7 @@ class UpgradesTransferCurrencies extends Command
|
||||
&& null === $this->sourceTransaction->foreign_amount
|
||||
&& (int) $this->sourceTransaction->transaction_currency_id !== $this->sourceCurrency->id
|
||||
) {
|
||||
$message = sprintf(
|
||||
$message = sprintf(
|
||||
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
|
||||
$this->sourceTransaction->id,
|
||||
$this->sourceTransaction->transaction_currency_id,
|
||||
@ -336,8 +335,7 @@ class UpgradesTransferCurrencies extends Command
|
||||
if (null === $this->destinationTransaction->transaction_currency_id && null !== $this->destinationCurrency) {
|
||||
$this->destinationTransaction
|
||||
->transaction_currency_id
|
||||
= $this->destinationCurrency->id
|
||||
;
|
||||
= $this->destinationCurrency->id;
|
||||
$message = sprintf(
|
||||
'Transaction #%d has no currency setting, now set to %s.',
|
||||
$this->destinationTransaction->id,
|
||||
@ -359,7 +357,7 @@ class UpgradesTransferCurrencies extends Command
|
||||
&& null === $this->destinationTransaction->foreign_amount
|
||||
&& (int) $this->destinationTransaction->transaction_currency_id !== $this->destinationCurrency->id
|
||||
) {
|
||||
$message = sprintf(
|
||||
$message = sprintf(
|
||||
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
|
||||
$this->destinationTransaction->id,
|
||||
$this->destinationTransaction->transaction_currency_id,
|
||||
@ -382,8 +380,8 @@ class UpgradesTransferCurrencies extends Command
|
||||
{
|
||||
if ($this->destinationCurrency->id === $this->sourceCurrency->id) {
|
||||
// update both transactions to match:
|
||||
$this->sourceTransaction->foreign_amount = null;
|
||||
$this->sourceTransaction->foreign_currency_id = null;
|
||||
$this->sourceTransaction->foreign_amount = null;
|
||||
$this->sourceTransaction->foreign_currency_id = null;
|
||||
|
||||
$this->destinationTransaction->foreign_amount = null;
|
||||
$this->destinationTransaction->foreign_currency_id = null;
|
||||
|
@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Handlers\Observer;
|
||||
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
@ -56,7 +56,7 @@ class TransactionObserver
|
||||
|
||||
public function updated(Transaction $transaction): void
|
||||
{
|
||||
Log::debug('Observe "updated" of a transaction.');
|
||||
// Log::debug('Observe "updated" of a transaction.');
|
||||
if (config('firefly.feature_flags.running_balance_column') && self::$recalculate) {
|
||||
if (1 === bccomp($transaction->amount, '0')) {
|
||||
Log::debug('Trigger recalculateForJournal');
|
||||
|
@ -90,6 +90,7 @@ class EditController extends Controller
|
||||
$latitude = null !== $location ? $location->latitude : config('firefly.default_location.latitude');
|
||||
$longitude = null !== $location ? $location->longitude : config('firefly.default_location.longitude');
|
||||
$zoomLevel = null !== $location ? $location->zoom_level : config('firefly.default_location.zoom_level');
|
||||
$canEditCurrency = $account->piggyBanks()->count() === 0;
|
||||
$hasLocation = null !== $location;
|
||||
$locations = [
|
||||
'location' => [
|
||||
@ -162,7 +163,7 @@ class EditController extends Controller
|
||||
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
|
||||
return view('accounts.edit', compact('account', 'currency', 'showNetWorth', 'subTitle', 'subTitleIcon', 'locations', 'liabilityDirections', 'objectType', 'roles', 'preFilled', 'liabilityTypes', 'interestPeriods'));
|
||||
return view('accounts.edit', compact('account', 'currency','canEditCurrency', 'showNetWorth', 'subTitle', 'subTitleIcon', 'locations', 'liabilityDirections', 'objectType', 'roles', 'preFilled', 'liabilityTypes', 'interestPeriods'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,6 +30,7 @@ use FireflyIII\Models\CurrencyExchangeRate;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\Support\Facades\Steam;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@ -72,7 +73,7 @@ class ExchangeRateConverter
|
||||
}
|
||||
$rate = $this->getCurrencyRate($from, $to, $date);
|
||||
|
||||
return bcmul($amount, $rate);
|
||||
return Steam::bcround(bcmul($amount, $rate), $to->decimal_places);
|
||||
}
|
||||
|
||||
public function enabled(): bool
|
||||
|
@ -136,7 +136,7 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
$return[] = [
|
||||
'id' => $account->id,
|
||||
'name' => $account->name,
|
||||
'current_amount' => $account->pivot->current_amount,
|
||||
'current_amount' => (string) $account->pivot->current_amount,
|
||||
// TODO add balance, add left to save.
|
||||
];
|
||||
}
|
||||
|
@ -1913,6 +1913,7 @@ return [
|
||||
'extension_date_is' => 'Extension date is {date}',
|
||||
|
||||
// accounts:
|
||||
'account_locked_currency' => 'The currency of this account must remain :name as long as piggy banks are linked to it.',
|
||||
'i_am_owed_amount' => 'I am owed amount',
|
||||
'i_owe_amount' => 'I owe amount',
|
||||
'inactive_account_link' => 'You have :count inactive (archived) account, which you can view on this separate page.|You have :count inactive (archived) accounts, which you can view on this separate page.',
|
||||
|
@ -27,9 +27,12 @@
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{{ ExpandedForm.text('name', account.name) }}
|
||||
{% if account.accountType.type == 'Default account' or account.accountType.type == 'Asset account' or objectType == 'liabilities' %}
|
||||
{% if canEditCurrency and (account.accountType.type == 'Default account' or account.accountType.type == 'Asset account' or objectType == 'liabilities') %}
|
||||
{{ CurrencyForm.currencyList('currency_id', null, {helpText:'account_default_currency'|_}) }}
|
||||
|
||||
{% endif %}
|
||||
{% if not canEditCurrency and (account.accountType.type == 'Default account' or account.accountType.type == 'Asset account' or objectType == 'liabilities') %}
|
||||
<input type="hidden" name="currency_id" value="{{ currency.id }}"/>
|
||||
{{ ExpandedForm.staticText('currency_id', trans('firefly.account_locked_currency', {name: currency.name})) }}
|
||||
{% endif %}
|
||||
|
||||
{% if objectType == 'liabilities' %}
|
||||
|
Loading…
Reference in New Issue
Block a user