mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Auto commit for release 'develop' on 2024-12-28
This commit is contained in:
parent
f2166b97b8
commit
6c655634bc
@ -59,8 +59,9 @@ class CorrectsNativeAmounts extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
if(!config('cer.enabled')) {
|
if (!config('cer.enabled')) {
|
||||||
$this->friendlyInfo('This command will not run because currency exchange rates are disabled.');
|
$this->friendlyInfo('This command will not run because currency exchange rates are disabled.');
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Log::debug('Will update all native amounts. This may take some time.');
|
Log::debug('Will update all native amounts. This may take some time.');
|
||||||
|
@ -39,8 +39,8 @@ class UpgradesTransferCurrencies extends Command
|
|||||||
use ShowsFriendlyMessages;
|
use ShowsFriendlyMessages;
|
||||||
|
|
||||||
public const string CONFIG_NAME = '480_transfer_currencies';
|
public const string CONFIG_NAME = '480_transfer_currencies';
|
||||||
protected $description = 'Updates transfer currency information.';
|
protected $description = 'Updates transfer currency information.';
|
||||||
protected $signature = 'upgrade:480-transfer-currencies {--F|force : Force the execution of this command.}';
|
protected $signature = 'upgrade:480-transfer-currencies {--F|force : Force the execution of this command.}';
|
||||||
private array $accountCurrencies;
|
private array $accountCurrencies;
|
||||||
private AccountRepositoryInterface $accountRepos;
|
private AccountRepositoryInterface $accountRepos;
|
||||||
private JournalCLIRepositoryInterface $cliRepos;
|
private JournalCLIRepositoryInterface $cliRepos;
|
||||||
@ -71,6 +71,7 @@ class UpgradesTransferCurrencies extends Command
|
|||||||
if ($this->count > 0) {
|
if ($this->count > 0) {
|
||||||
$this->friendlyInfo(sprintf('Verified currency information of %d transfer(s).', $this->count));
|
$this->friendlyInfo(sprintf('Verified currency information of %d transfer(s).', $this->count));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,14 +212,14 @@ class UpgradesTransferCurrencies extends Command
|
|||||||
|
|
||||||
private function getCurrency(Account $account): ?TransactionCurrency
|
private function getCurrency(Account $account): ?TransactionCurrency
|
||||||
{
|
{
|
||||||
$accountId = $account->id;
|
$accountId = $account->id;
|
||||||
if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) {
|
if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {
|
if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {
|
||||||
return $this->accountCurrencies[$accountId];
|
return $this->accountCurrencies[$accountId];
|
||||||
}
|
}
|
||||||
$currency = $this->accountRepos->getAccountCurrency($account);
|
$currency = $this->accountRepos->getAccountCurrency($account);
|
||||||
if (null === $currency) {
|
if (null === $currency) {
|
||||||
$this->accountCurrencies[$accountId] = 0;
|
$this->accountCurrencies[$accountId] = 0;
|
||||||
|
|
||||||
@ -290,7 +291,8 @@ class UpgradesTransferCurrencies extends Command
|
|||||||
if (null === $this->sourceTransaction->transaction_currency_id && null !== $this->sourceCurrency) {
|
if (null === $this->sourceTransaction->transaction_currency_id && null !== $this->sourceCurrency) {
|
||||||
$this->sourceTransaction
|
$this->sourceTransaction
|
||||||
->transaction_currency_id
|
->transaction_currency_id
|
||||||
= $this->sourceCurrency->id;
|
= $this->sourceCurrency->id
|
||||||
|
;
|
||||||
$message = sprintf(
|
$message = sprintf(
|
||||||
'Transaction #%d has no currency setting, now set to %s.',
|
'Transaction #%d has no currency setting, now set to %s.',
|
||||||
$this->sourceTransaction->id,
|
$this->sourceTransaction->id,
|
||||||
@ -312,7 +314,7 @@ class UpgradesTransferCurrencies extends Command
|
|||||||
&& null === $this->sourceTransaction->foreign_amount
|
&& null === $this->sourceTransaction->foreign_amount
|
||||||
&& (int) $this->sourceTransaction->transaction_currency_id !== $this->sourceCurrency->id
|
&& (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.',
|
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
|
||||||
$this->sourceTransaction->id,
|
$this->sourceTransaction->id,
|
||||||
$this->sourceTransaction->transaction_currency_id,
|
$this->sourceTransaction->transaction_currency_id,
|
||||||
@ -335,7 +337,8 @@ class UpgradesTransferCurrencies extends Command
|
|||||||
if (null === $this->destinationTransaction->transaction_currency_id && null !== $this->destinationCurrency) {
|
if (null === $this->destinationTransaction->transaction_currency_id && null !== $this->destinationCurrency) {
|
||||||
$this->destinationTransaction
|
$this->destinationTransaction
|
||||||
->transaction_currency_id
|
->transaction_currency_id
|
||||||
= $this->destinationCurrency->id;
|
= $this->destinationCurrency->id
|
||||||
|
;
|
||||||
$message = sprintf(
|
$message = sprintf(
|
||||||
'Transaction #%d has no currency setting, now set to %s.',
|
'Transaction #%d has no currency setting, now set to %s.',
|
||||||
$this->destinationTransaction->id,
|
$this->destinationTransaction->id,
|
||||||
@ -357,7 +360,7 @@ class UpgradesTransferCurrencies extends Command
|
|||||||
&& null === $this->destinationTransaction->foreign_amount
|
&& null === $this->destinationTransaction->foreign_amount
|
||||||
&& (int) $this->destinationTransaction->transaction_currency_id !== $this->destinationCurrency->id
|
&& (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.',
|
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
|
||||||
$this->destinationTransaction->id,
|
$this->destinationTransaction->id,
|
||||||
$this->destinationTransaction->transaction_currency_id,
|
$this->destinationTransaction->transaction_currency_id,
|
||||||
@ -380,8 +383,8 @@ class UpgradesTransferCurrencies extends Command
|
|||||||
{
|
{
|
||||||
if ($this->destinationCurrency->id === $this->sourceCurrency->id) {
|
if ($this->destinationCurrency->id === $this->sourceCurrency->id) {
|
||||||
// update both transactions to match:
|
// update both transactions to match:
|
||||||
$this->sourceTransaction->foreign_amount = null;
|
$this->sourceTransaction->foreign_amount = null;
|
||||||
$this->sourceTransaction->foreign_currency_id = null;
|
$this->sourceTransaction->foreign_currency_id = null;
|
||||||
|
|
||||||
$this->destinationTransaction->foreign_amount = null;
|
$this->destinationTransaction->foreign_amount = null;
|
||||||
$this->destinationTransaction->foreign_currency_id = null;
|
$this->destinationTransaction->foreign_currency_id = null;
|
||||||
|
@ -68,9 +68,7 @@ class Handler extends ExceptionHandler
|
|||||||
/**
|
/**
|
||||||
* Register the exception handling callbacks for the application.
|
* Register the exception handling callbacks for the application.
|
||||||
*/
|
*/
|
||||||
public function register(): void
|
public function register(): void {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render an exception into an HTTP response. It's complex but lucky for us, we never use it because
|
* Render an exception into an HTTP response. It's complex but lucky for us, we never use it because
|
||||||
|
@ -44,7 +44,7 @@ class AccountObserver
|
|||||||
|
|
||||||
private function updateNativeAmount(Account $account): void
|
private function updateNativeAmount(Account $account): void
|
||||||
{
|
{
|
||||||
if(!Amount::convertToNative($account->user)) {
|
if (!Amount::convertToNative($account->user)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);
|
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);
|
||||||
|
@ -45,7 +45,7 @@ class AutoBudgetObserver
|
|||||||
|
|
||||||
private function updateNativeAmount(AutoBudget $autoBudget): void
|
private function updateNativeAmount(AutoBudget $autoBudget): void
|
||||||
{
|
{
|
||||||
if(!Amount::convertToNative($autoBudget->budget->user)) {
|
if (!Amount::convertToNative($autoBudget->budget->user)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($autoBudget->budget->user->userGroup);
|
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($autoBudget->budget->user->userGroup);
|
||||||
|
@ -45,7 +45,7 @@ class AvailableBudgetObserver
|
|||||||
|
|
||||||
private function updateNativeAmount(AvailableBudget $availableBudget): void
|
private function updateNativeAmount(AvailableBudget $availableBudget): void
|
||||||
{
|
{
|
||||||
if(!Amount::convertToNative($availableBudget->user)) {
|
if (!Amount::convertToNative($availableBudget->user)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($availableBudget->user->userGroup);
|
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($availableBudget->user->userGroup);
|
||||||
|
@ -56,7 +56,7 @@ class BillObserver
|
|||||||
|
|
||||||
private function updateNativeAmount(Bill $bill): void
|
private function updateNativeAmount(Bill $bill): void
|
||||||
{
|
{
|
||||||
if(!Amount::convertToNative($bill->user)) {
|
if (!Amount::convertToNative($bill->user)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($bill->user->userGroup);
|
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($bill->user->userGroup);
|
||||||
|
@ -45,7 +45,7 @@ class BudgetLimitObserver
|
|||||||
|
|
||||||
private function updateNativeAmount(BudgetLimit $budgetLimit): void
|
private function updateNativeAmount(BudgetLimit $budgetLimit): void
|
||||||
{
|
{
|
||||||
if(!Amount::convertToNative($budgetLimit->budget->user)) {
|
if (!Amount::convertToNative($budgetLimit->budget->user)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($budgetLimit->budget->user->userGroup);
|
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($budgetLimit->budget->user->userGroup);
|
||||||
|
@ -45,7 +45,7 @@ class PiggyBankEventObserver
|
|||||||
|
|
||||||
private function updateNativeAmount(PiggyBankEvent $event): void
|
private function updateNativeAmount(PiggyBankEvent $event): void
|
||||||
{
|
{
|
||||||
if(!Amount::convertToNative($event->piggyBank->accounts()->first()->user)) {
|
if (!Amount::convertToNative($event->piggyBank->accounts()->first()->user)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($event->piggyBank->accounts()->first()->user->userGroup);
|
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($event->piggyBank->accounts()->first()->user->userGroup);
|
||||||
|
@ -56,7 +56,7 @@ class TransactionObserver
|
|||||||
|
|
||||||
public function updated(Transaction $transaction): void
|
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 (config('firefly.feature_flags.running_balance_column') && self::$recalculate) {
|
||||||
if (1 === bccomp($transaction->amount, '0')) {
|
if (1 === bccomp($transaction->amount, '0')) {
|
||||||
Log::debug('Trigger recalculateForJournal');
|
Log::debug('Trigger recalculateForJournal');
|
||||||
@ -68,7 +68,7 @@ class TransactionObserver
|
|||||||
|
|
||||||
private function updateNativeAmount(Transaction $transaction): void
|
private function updateNativeAmount(Transaction $transaction): void
|
||||||
{
|
{
|
||||||
if(!Amount::convertToNative($transaction->transactionJournal->user)) {
|
if (!Amount::convertToNative($transaction->transactionJournal->user)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($transaction->transactionJournal->user->userGroup);
|
$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($transaction->transactionJournal->user->userGroup);
|
||||||
|
@ -90,7 +90,7 @@ class EditController extends Controller
|
|||||||
$latitude = null !== $location ? $location->latitude : config('firefly.default_location.latitude');
|
$latitude = null !== $location ? $location->latitude : config('firefly.default_location.latitude');
|
||||||
$longitude = null !== $location ? $location->longitude : config('firefly.default_location.longitude');
|
$longitude = null !== $location ? $location->longitude : config('firefly.default_location.longitude');
|
||||||
$zoomLevel = null !== $location ? $location->zoom_level : config('firefly.default_location.zoom_level');
|
$zoomLevel = null !== $location ? $location->zoom_level : config('firefly.default_location.zoom_level');
|
||||||
$canEditCurrency = $account->piggyBanks()->count() === 0;
|
$canEditCurrency = 0 === $account->piggyBanks()->count();
|
||||||
$hasLocation = null !== $location;
|
$hasLocation = null !== $location;
|
||||||
$locations = [
|
$locations = [
|
||||||
'location' => [
|
'location' => [
|
||||||
@ -163,7 +163,7 @@ class EditController extends Controller
|
|||||||
|
|
||||||
$request->session()->flash('preFilled', $preFilled);
|
$request->session()->flash('preFilled', $preFilled);
|
||||||
|
|
||||||
return view('accounts.edit', compact('account', 'currency','canEditCurrency', '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'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -197,11 +197,11 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
$chartData[$inKey]
|
$chartData[$inKey]
|
||||||
= [
|
= [
|
||||||
'label' => sprintf('%s (%s)', (string) trans('firefly.earned'), $currencyInfo['currency_name']),
|
'label' => sprintf('%s (%s)', (string) trans('firefly.earned'), $currencyInfo['currency_name']),
|
||||||
'entries' => [],
|
'entries' => [],
|
||||||
'type' => 'bar',
|
'type' => 'bar',
|
||||||
'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green
|
'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green
|
||||||
];
|
];
|
||||||
// loop empty periods:
|
// loop empty periods:
|
||||||
foreach (array_keys($periods) as $period) {
|
foreach (array_keys($periods) as $period) {
|
||||||
$label = $periods[$period];
|
$label = $periods[$period];
|
||||||
|
@ -47,7 +47,7 @@ class IndexController extends Controller
|
|||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if(!config('cer.enabled')) {
|
if (!config('cer.enabled')) {
|
||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface
|
|||||||
$journals = $collector->getExtractedJournals();
|
$journals = $collector->getExtractedJournals();
|
||||||
$array = [];
|
$array = [];
|
||||||
// default currency information for native stuff.
|
// default currency information for native stuff.
|
||||||
$convertToNative = Amount::convertToNative($this->user);;
|
$convertToNative = Amount::convertToNative($this->user);
|
||||||
$default = Amount::getDefaultCurrency();
|
$default = Amount::getDefaultCurrency();
|
||||||
|
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
|
@ -331,7 +331,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionTypeEnum::WITHDRAWAL->value]);
|
$collector->setUser($this->user)->setRange($start, $end)->setTypes([TransactionTypeEnum::WITHDRAWAL->value]);
|
||||||
|
|
||||||
// default currency information for native stuff.
|
// default currency information for native stuff.
|
||||||
$convertToNative = Amount::convertToNative($this->user);;
|
$convertToNative = Amount::convertToNative($this->user);
|
||||||
$default = Amount::getDefaultCurrency();
|
$default = Amount::getDefaultCurrency();
|
||||||
if (null !== $accounts && $accounts->count() > 0) {
|
if (null !== $accounts && $accounts->count() > 0) {
|
||||||
$collector->setAccounts($accounts);
|
$collector->setAccounts($accounts);
|
||||||
@ -411,7 +411,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
|||||||
}
|
}
|
||||||
$collector->setCategories($categories);
|
$collector->setCategories($categories);
|
||||||
$journals = $collector->getExtractedJournals();
|
$journals = $collector->getExtractedJournals();
|
||||||
$convertToNative = Amount::convertToNative($this->user);;
|
$convertToNative = Amount::convertToNative($this->user);
|
||||||
$default = Amount::getDefaultCurrency();
|
$default = Amount::getDefaultCurrency();
|
||||||
$array = [];
|
$array = [];
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ use FireflyIII\Models\TransactionJournal;
|
|||||||
use FireflyIII\Models\UserGroup;
|
use FireflyIII\Models\UserGroup;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use FireflyIII\Support\Facades\Preferences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Amount.
|
* Class Amount.
|
||||||
@ -70,9 +71,10 @@ class Amount
|
|||||||
public function convertToNative(?User $user = null): bool
|
public function convertToNative(?User $user = null): bool
|
||||||
{
|
{
|
||||||
if (null === $user) {
|
if (null === $user) {
|
||||||
return \FireflyIII\Support\Facades\Preferences::get('convert_to_native', false)->data && config('cer.enabled');
|
return Preferences::get('convert_to_native', false)->data && config('cer.enabled');
|
||||||
}
|
}
|
||||||
return \FireflyIII\Support\Facades\Preferences::getForUser($user, 'convert_to_native', false)->data && config('cer.enabled');
|
|
||||||
|
return Preferences::getForUser($user, 'convert_to_native', false)->data && config('cer.enabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,16 +83,16 @@ class Amount
|
|||||||
*/
|
*/
|
||||||
public function getAmountFromJournalObject(TransactionJournal $journal): string
|
public function getAmountFromJournalObject(TransactionJournal $journal): string
|
||||||
{
|
{
|
||||||
$convertToNative = $this->convertToNative();
|
$convertToNative = $this->convertToNative();
|
||||||
$currency = $this->getDefaultCurrency();
|
$currency = $this->getDefaultCurrency();
|
||||||
$field = $convertToNative && $currency->id !== $journal->transaction_currency_id ? 'native_amount' : 'amount';
|
$field = $convertToNative && $currency->id !== $journal->transaction_currency_id ? 'native_amount' : 'amount';
|
||||||
|
|
||||||
/** @var null|Transaction $sourceTransaction */
|
/** @var null|Transaction $sourceTransaction */
|
||||||
$sourceTransaction = $journal->transactions()->where('amount', '<', 0)->first();
|
$sourceTransaction = $journal->transactions()->where('amount', '<', 0)->first();
|
||||||
if (null === $sourceTransaction) {
|
if (null === $sourceTransaction) {
|
||||||
return '0';
|
return '0';
|
||||||
}
|
}
|
||||||
$amount = $sourceTransaction->{$field} ?? '0';
|
$amount = $sourceTransaction->{$field} ?? '0';
|
||||||
if ((int) $sourceTransaction->foreign_currency_id === $currency->id) {
|
if ((int) $sourceTransaction->foreign_currency_id === $currency->id) {
|
||||||
// use foreign amount instead!
|
// use foreign amount instead!
|
||||||
$amount = (string) $sourceTransaction->foreign_amount; // hard coded to be foreign amount.
|
$amount = (string) $sourceTransaction->foreign_amount; // hard coded to be foreign amount.
|
||||||
@ -109,15 +111,15 @@ class Amount
|
|||||||
*/
|
*/
|
||||||
public function formatFlat(string $symbol, int $decimalPlaces, string $amount, ?bool $coloured = null): string
|
public function formatFlat(string $symbol, int $decimalPlaces, string $amount, ?bool $coloured = null): string
|
||||||
{
|
{
|
||||||
$locale = app('steam')->getLocale();
|
$locale = app('steam')->getLocale();
|
||||||
$rounded = app('steam')->bcround($amount, $decimalPlaces);
|
$rounded = app('steam')->bcround($amount, $decimalPlaces);
|
||||||
$coloured ??= true;
|
$coloured ??= true;
|
||||||
|
|
||||||
$fmt = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
|
$fmt = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
|
||||||
$fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $symbol);
|
$fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $symbol);
|
||||||
$fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $decimalPlaces);
|
$fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $decimalPlaces);
|
||||||
$fmt->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, $decimalPlaces);
|
$fmt->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, $decimalPlaces);
|
||||||
$result = (string) $fmt->format((float) $rounded); // intentional float
|
$result = (string) $fmt->format((float) $rounded); // intentional float
|
||||||
|
|
||||||
if (true === $coloured) {
|
if (true === $coloured) {
|
||||||
if (1 === bccomp($rounded, '0')) {
|
if (1 === bccomp($rounded, '0')) {
|
||||||
@ -163,7 +165,7 @@ class Amount
|
|||||||
|
|
||||||
public function getDefaultCurrencyByUserGroup(UserGroup $userGroup): TransactionCurrency
|
public function getDefaultCurrencyByUserGroup(UserGroup $userGroup): TransactionCurrency
|
||||||
{
|
{
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty('getDefaultCurrencyByGroup');
|
$cache->addProperty('getDefaultCurrencyByGroup');
|
||||||
$cache->addProperty($userGroup->id);
|
$cache->addProperty($userGroup->id);
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
@ -226,20 +228,20 @@ class Amount
|
|||||||
private function getLocaleInfo(): array
|
private function getLocaleInfo(): array
|
||||||
{
|
{
|
||||||
// get config from preference, not from translation:
|
// get config from preference, not from translation:
|
||||||
$locale = app('steam')->getLocale();
|
$locale = app('steam')->getLocale();
|
||||||
$array = app('steam')->getLocaleArray($locale);
|
$array = app('steam')->getLocaleArray($locale);
|
||||||
|
|
||||||
setlocale(LC_MONETARY, $array);
|
setlocale(LC_MONETARY, $array);
|
||||||
$info = localeconv();
|
$info = localeconv();
|
||||||
|
|
||||||
// correct variables
|
// correct variables
|
||||||
$info['n_cs_precedes'] = $this->getLocaleField($info, 'n_cs_precedes');
|
$info['n_cs_precedes'] = $this->getLocaleField($info, 'n_cs_precedes');
|
||||||
$info['p_cs_precedes'] = $this->getLocaleField($info, 'p_cs_precedes');
|
$info['p_cs_precedes'] = $this->getLocaleField($info, 'p_cs_precedes');
|
||||||
|
|
||||||
$info['n_sep_by_space'] = $this->getLocaleField($info, 'n_sep_by_space');
|
$info['n_sep_by_space'] = $this->getLocaleField($info, 'n_sep_by_space');
|
||||||
$info['p_sep_by_space'] = $this->getLocaleField($info, 'p_sep_by_space');
|
$info['p_sep_by_space'] = $this->getLocaleField($info, 'p_sep_by_space');
|
||||||
|
|
||||||
$fmt = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
|
$fmt = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
|
||||||
|
|
||||||
$info['mon_decimal_point'] = $fmt->getSymbol(\NumberFormatter::MONETARY_SEPARATOR_SYMBOL);
|
$info['mon_decimal_point'] = $fmt->getSymbol(\NumberFormatter::MONETARY_SEPARATOR_SYMBOL);
|
||||||
$info['mon_thousands_sep'] = $fmt->getSymbol(\NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL);
|
$info['mon_thousands_sep'] = $fmt->getSymbol(\NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL);
|
||||||
@ -262,7 +264,7 @@ class Amount
|
|||||||
public static function getAmountJsConfig(bool $sepBySpace, int $signPosn, string $sign, bool $csPrecedes): string
|
public static function getAmountJsConfig(bool $sepBySpace, int $signPosn, string $sign, bool $csPrecedes): string
|
||||||
{
|
{
|
||||||
// negative first:
|
// negative first:
|
||||||
$space = ' ';
|
$space = ' ';
|
||||||
|
|
||||||
// require space between symbol and amount?
|
// require space between symbol and amount?
|
||||||
if (false === $sepBySpace) {
|
if (false === $sepBySpace) {
|
||||||
@ -271,11 +273,11 @@ class Amount
|
|||||||
|
|
||||||
// there are five possible positions for the "+" or "-" sign (if it is even used)
|
// there are five possible positions for the "+" or "-" sign (if it is even used)
|
||||||
// pos_a and pos_e could be the ( and ) symbol.
|
// pos_a and pos_e could be the ( and ) symbol.
|
||||||
$posA = ''; // before everything
|
$posA = ''; // before everything
|
||||||
$posB = ''; // before currency symbol
|
$posB = ''; // before currency symbol
|
||||||
$posC = ''; // after currency symbol
|
$posC = ''; // after currency symbol
|
||||||
$posD = ''; // before amount
|
$posD = ''; // before amount
|
||||||
$posE = ''; // after everything
|
$posE = ''; // after everything
|
||||||
|
|
||||||
// format would be (currency before amount)
|
// format would be (currency before amount)
|
||||||
// AB%sC_D%vE
|
// AB%sC_D%vE
|
||||||
@ -317,11 +319,11 @@ class Amount
|
|||||||
}
|
}
|
||||||
|
|
||||||
// default is amount before currency
|
// default is amount before currency
|
||||||
$format = $posA . $posD . '%v' . $space . $posB . '%s' . $posC . $posE;
|
$format = $posA.$posD.'%v'.$space.$posB.'%s'.$posC.$posE;
|
||||||
|
|
||||||
if ($csPrecedes) {
|
if ($csPrecedes) {
|
||||||
// alternative is currency before amount
|
// alternative is currency before amount
|
||||||
$format = $posA . $posB . '%s' . $posC . $space . $posD . '%v' . $posE;
|
$format = $posA.$posB.'%s'.$posC.$space.$posD.'%v'.$posE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $format;
|
return $format;
|
||||||
|
@ -576,13 +576,13 @@ trait PeriodOverview
|
|||||||
}
|
}
|
||||||
$entries[]
|
$entries[]
|
||||||
= [
|
= [
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'route' => route('transactions.index', [$transactionType, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]),
|
'route' => route('transactions.index', [$transactionType, $currentDate['start']->format('Y-m-d'), $currentDate['end']->format('Y-m-d')]),
|
||||||
'total_transactions' => count($spent) + count($earned) + count($transferred),
|
'total_transactions' => count($spent) + count($earned) + count($transferred),
|
||||||
'spent' => $this->groupByCurrency($spent),
|
'spent' => $this->groupByCurrency($spent),
|
||||||
'earned' => $this->groupByCurrency($earned),
|
'earned' => $this->groupByCurrency($earned),
|
||||||
'transferred' => $this->groupByCurrency($transferred),
|
'transferred' => $this->groupByCurrency($transferred),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $entries;
|
return $entries;
|
||||||
|
@ -31,6 +31,7 @@ use FireflyIII\Models\TransactionCurrency;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use FireflyIII\Support\Facades\Amount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Steam.
|
* Class Steam.
|
||||||
@ -310,8 +311,8 @@ class Steam
|
|||||||
public function finalAccountBalance(Account $account, Carbon $date): array
|
public function finalAccountBalance(Account $account, Carbon $date): array
|
||||||
{
|
{
|
||||||
Log::debug(sprintf('Now in finalAccountBalance(#%d, "%s", "%s")', $account->id, $account->name, $date->format('Y-m-d H:i:s')));
|
Log::debug(sprintf('Now in finalAccountBalance(#%d, "%s", "%s")', $account->id, $account->name, $date->format('Y-m-d H:i:s')));
|
||||||
$native = \FireflyIII\Support\Facades\Amount::getDefaultCurrencyByUserGroup($account->user->userGroup);
|
$native = Amount::getDefaultCurrencyByUserGroup($account->user->userGroup);
|
||||||
$convertToNative = \FireflyIII\Support\Facades\Amount::convertToNative($account->user);
|
$convertToNative = Amount::convertToNative($account->user);
|
||||||
$accountCurrency = $this->getAccountCurrency($account);
|
$accountCurrency = $this->getAccountCurrency($account);
|
||||||
$hasCurrency = null !== $accountCurrency;
|
$hasCurrency = null !== $accountCurrency;
|
||||||
$currency = $hasCurrency ? $accountCurrency : $native;
|
$currency = $hasCurrency ? $accountCurrency : $native;
|
||||||
|
18
changelog.md
18
changelog.md
@ -10,17 +10,17 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Multi-currency support. If you set `ENABLE_EXCHANGE_RATES=true` and optionally `ENABLE_EXTERNAL_RATES=true` Firefly III will try to calculate all foreign currencies back to your native currency. This is a work in progress, not all fields and all places will support this yet. Please check out the [documentation](https://docs.firefly-iii.org/explanation/financial-concepts/exchange-rates/).
|
- Multi-currency support. If you set `ENABLE_EXCHANGE_RATES=true` and optionally `ENABLE_EXTERNAL_RATES=true` Firefly III will try to calculate all foreign currencies back to your native currency. This is a work in progress, not all fields and all places will support this yet. Please check out the [documentation](https://docs.firefly-iii.org/explanation/financial-concepts/exchange-rates/).
|
||||||
- Notifications support Nfty, Pushover, Slack and Discord.
|
- Notifications support Nfty, Pushover, Slack and Discord.
|
||||||
- Many new security related notifications.
|
- Many new security related notifications.
|
||||||
- #5523
|
- [Issue 5523](https://github.com/firefly-iii/firefly-iii/issues/5523) (Add comment on a budget for a given month) reported by @n-serrette
|
||||||
- #8531
|
- [Issue 8531](https://github.com/firefly-iii/firefly-iii/issues/8531) (Add `notes` to transaction audit report) reported by @clouserw
|
||||||
- #8307
|
- [Issue 8307](https://github.com/firefly-iii/firefly-iii/issues/8307) (Notification support for Ntfy (and other push notification tools)) reported by @ragnarkarlsson
|
||||||
- #7945
|
- [Issue 7945](https://github.com/firefly-iii/firefly-iii/issues/7945) ("Rules" that only trigger manually) reported by @SekoiaTree
|
||||||
- #6760
|
- [Issue 6760](https://github.com/firefly-iii/firefly-iii/issues/6760) (Add a new trigger for automated rules) reported by @Gsyltc
|
||||||
- #6557
|
- [Issue 6557](https://github.com/firefly-iii/firefly-iii/issues/6557) (Piggy Banks - Draw Funds from Multiple Accounts) reported by @BugPhobic
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Firefly III requires PHP 8.4.
|
- Firefly III requires PHP 8.4.
|
||||||
- #9501
|
- [Issue 9501](https://github.com/firefly-iii/firefly-iii/issues/9501) (PHP8.4 support) reported by @JC5
|
||||||
- Docker container no longer runs under root.
|
- Docker container no longer runs under root.
|
||||||
- "Bills" are now called "subscriptions" to better reflect their purpose.
|
- "Bills" are now called "subscriptions" to better reflect their purpose.
|
||||||
|
|
||||||
@ -31,8 +31,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- #9532
|
- [Issue 9532](https://github.com/firefly-iii/firefly-iii/issues/9532) (ReportSum Integrity Check fails due to empty foreign_amount) reported by @SircasticFox
|
||||||
- #7288
|
- [Issue 7288](https://github.com/firefly-iii/firefly-iii/issues/7288) (currentMonthStart/currentMonthEnd not working for no-budget view) reported by @bradsk88
|
||||||
|
|
||||||
### API
|
### API
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ return [
|
|||||||
'running_balance_column' => env('USE_RUNNING_BALANCE', false),
|
'running_balance_column' => env('USE_RUNNING_BALANCE', false),
|
||||||
// see cer.php for exchange rates feature flag.
|
// see cer.php for exchange rates feature flag.
|
||||||
],
|
],
|
||||||
'version' => 'develop/2024-12-27',
|
'version' => 'develop/2024-12-28',
|
||||||
'api_version' => '2.1.0', // field is no longer used.
|
'api_version' => '2.1.0', // field is no longer used.
|
||||||
'db_version' => 25,
|
'db_version' => 25,
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
return new class () extends Migration {
|
return new class () extends Migration {
|
||||||
/**
|
/**
|
||||||
@ -19,7 +20,7 @@ return new class () extends Migration {
|
|||||||
$table->dropForeign('piggy_banks_account_id_foreign');
|
$table->dropForeign('piggy_banks_account_id_foreign');
|
||||||
});
|
});
|
||||||
} catch (RuntimeException $e) {
|
} catch (RuntimeException $e) {
|
||||||
\Illuminate\Support\Facades\Log::error('Could not drop foreign key "piggy_banks_account_id_foreign". Probably not an issue.');
|
Log::error('Could not drop foreign key "piggy_banks_account_id_foreign". Probably not an issue.');
|
||||||
}
|
}
|
||||||
Schema::table('piggy_banks', static function (Blueprint $table): void {
|
Schema::table('piggy_banks', static function (Blueprint $table): void {
|
||||||
// 2. make column nullable.
|
// 2. make column nullable.
|
||||||
|
@ -1913,7 +1913,7 @@ return [
|
|||||||
'extension_date_is' => 'Extension date is {date}',
|
'extension_date_is' => 'Extension date is {date}',
|
||||||
|
|
||||||
// accounts:
|
// accounts:
|
||||||
'account_locked_currency' => 'The currency of this account must remain :name as long as piggy banks are linked to it.',
|
'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_am_owed_amount' => 'I am owed amount',
|
||||||
'i_owe_amount' => 'I owe 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.',
|
'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.',
|
||||||
|
Loading…
Reference in New Issue
Block a user