diff --git a/app/Api/V1/Controllers/Chart/AccountController.php b/app/Api/V1/Controllers/Chart/AccountController.php index 5c554c17f2..24f5e5d777 100644 --- a/app/Api/V1/Controllers/Chart/AccountController.php +++ b/app/Api/V1/Controllers/Chart/AccountController.php @@ -31,7 +31,6 @@ use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; -use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Support\Http\Api\ApiSupport; use FireflyIII\User; use Illuminate\Http\JsonResponse; @@ -46,8 +45,7 @@ class AccountController extends Controller { use ApiSupport; - private CurrencyRepositoryInterface $currencyRepository; - private AccountRepositoryInterface $repository; + private AccountRepositoryInterface $repository; /** * AccountController constructor. @@ -64,9 +62,6 @@ class AccountController extends Controller $this->repository = app(AccountRepositoryInterface::class); $this->repository->setUser($user); - $this->currencyRepository = app(CurrencyRepositoryInterface::class); - $this->currencyRepository->setUser($user); - return $next($request); } ); diff --git a/app/Api/V1/Controllers/Insight/Expense/AccountController.php b/app/Api/V1/Controllers/Insight/Expense/AccountController.php index ad9d660d5e..e79d6097af 100644 --- a/app/Api/V1/Controllers/Insight/Expense/AccountController.php +++ b/app/Api/V1/Controllers/Insight/Expense/AccountController.php @@ -28,7 +28,6 @@ use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Insight\GenericRequest; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\OperationsRepositoryInterface; -use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Support\Http\Api\ApiSupport; use Illuminate\Http\JsonResponse; @@ -43,7 +42,6 @@ class AccountController extends Controller { use ApiSupport; - private CurrencyRepositoryInterface $currencyRepository; private OperationsRepositoryInterface $opsRepository; private AccountRepositoryInterface $repository; @@ -61,9 +59,6 @@ class AccountController extends Controller $this->repository = app(AccountRepositoryInterface::class); $this->repository->setUser($user); - $this->currencyRepository = app(CurrencyRepositoryInterface::class); - $this->currencyRepository->setUser($user); - $this->opsRepository = app(OperationsRepositoryInterface::class); $this->opsRepository->setUser($user); diff --git a/app/Api/V1/Controllers/Insight/Income/AccountController.php b/app/Api/V1/Controllers/Insight/Income/AccountController.php index 5d8aabc7f3..91ab40a071 100644 --- a/app/Api/V1/Controllers/Insight/Income/AccountController.php +++ b/app/Api/V1/Controllers/Insight/Income/AccountController.php @@ -28,7 +28,6 @@ use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Requests\Insight\GenericRequest; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\OperationsRepositoryInterface; -use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Support\Http\Api\ApiSupport; use Illuminate\Http\JsonResponse; @@ -43,7 +42,6 @@ class AccountController extends Controller { use ApiSupport; - private CurrencyRepositoryInterface $currencyRepository; private OperationsRepositoryInterface $opsRepository; private AccountRepositoryInterface $repository; @@ -61,9 +59,6 @@ class AccountController extends Controller $this->repository = app(AccountRepositoryInterface::class); $this->repository->setUser($user); - $this->currencyRepository = app(CurrencyRepositoryInterface::class); - $this->currencyRepository->setUser($user); - $this->opsRepository = app(OperationsRepositoryInterface::class); $this->opsRepository->setUser($user); diff --git a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php index 093223fe36..5a34f8f091 100644 --- a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php +++ b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php @@ -31,7 +31,6 @@ use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; -use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use Illuminate\Console\Command; @@ -46,13 +45,12 @@ class OtherCurrenciesCorrections extends Command use ShowsFriendlyMessages; public const CONFIG_NAME = '480_other_currencies'; - protected $description = 'Update all journal currency information.'; - protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}'; + protected $description = 'Update all journal currency information.'; + protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}'; private array $accountCurrencies; private AccountRepositoryInterface $accountRepos; private JournalCLIRepositoryInterface $cliRepos; private int $count; - private CurrencyRepositoryInterface $currencyRepos; private JournalRepositoryInterface $journalRepos; /** @@ -93,7 +91,6 @@ class OtherCurrenciesCorrections extends Command $this->count = 0; $this->accountCurrencies = []; $this->accountRepos = app(AccountRepositoryInterface::class); - $this->currencyRepos = app(CurrencyRepositoryInterface::class); $this->journalRepos = app(JournalRepositoryInterface::class); $this->cliRepos = app(JournalCLIRepositoryInterface::class); } @@ -138,7 +135,6 @@ class OtherCurrenciesCorrections extends Command { $this->accountRepos->setUser($journal->user); $this->journalRepos->setUser($journal->user); - $this->currencyRepos->setUser($journal->user); $this->cliRepos->setUser($journal->user); $leadTransaction = $this->getLeadTransaction($journal); diff --git a/app/Factory/BillFactory.php b/app/Factory/BillFactory.php index c2bf305d3a..3e456c3e2a 100644 --- a/app/Factory/BillFactory.php +++ b/app/Factory/BillFactory.php @@ -55,7 +55,7 @@ class BillFactory Log::debug(sprintf('Now in %s', __METHOD__), $data); $factory = app(TransactionCurrencyFactory::class); $currency = $factory->find((int)($data['currency_id'] ?? null), (string)($data['currency_code'] ?? null)) ?? - app('amount')->getDefaultCurrencyByUser($this->user); + app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup); try { $skip = array_key_exists('skip', $data) ? $data['skip'] : 0; diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php index 14b71ee641..24b08614f6 100644 --- a/app/Factory/TransactionJournalFactory.php +++ b/app/Factory/TransactionJournalFactory.php @@ -479,7 +479,7 @@ class TransactionJournalFactory $preference = $this->accountRepository->getAccountCurrency($account); if (null === $preference && null === $currency) { // return user's default: - return app('amount')->getDefaultCurrencyByUser($this->user); + return app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup); } $result = ($preference ?? $currency) ?? app('amount')->getSystemCurrency(); Log::debug(sprintf('Currency is now #%d (%s) because of account #%d (%s)', $result->id, $result->code, $account->id, $account->name)); diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index 7c3ae8dd94..52e78dba52 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -38,7 +38,8 @@ use FireflyIII\Models\RuleAction; use FireflyIII\Models\RuleTrigger; use FireflyIII\Models\TransactionType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; -use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; +use FireflyIII\Repositories\Currency\CurrencyRepository; +use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface; use FireflyIII\Services\Internal\Destroy\BudgetDestroyService; use FireflyIII\User; use Illuminate\Contracts\Auth\Authenticatable; @@ -429,6 +430,7 @@ class BudgetRepository implements BudgetRepositoryInterface // set or update the currency. if (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) { + /** @var CurrencyRepositoryInterface $repos */ $repos = app(CurrencyRepositoryInterface::class); $currencyId = (int)($data['currency_id'] ?? 0); $currencyCode = (string)($data['currency_code'] ?? ''); @@ -837,6 +839,7 @@ class BudgetRepository implements BudgetRepositoryInterface $type = AutoBudget::AUTO_BUDGET_ADJUSTED; } + /** @var CurrencyRepositoryInterface $repos */ $repos = app(CurrencyRepositoryInterface::class); $currency = null; if (array_key_exists('currency_id', $data)) { diff --git a/app/Repositories/Currency/CurrencyRepositoryInterface.php b/app/Repositories/Currency/CurrencyRepositoryInterface.php index 26475fb7aa..3202ee18a3 100644 --- a/app/Repositories/Currency/CurrencyRepositoryInterface.php +++ b/app/Repositories/Currency/CurrencyRepositoryInterface.php @@ -24,7 +24,6 @@ declare(strict_types=1); namespace FireflyIII\Repositories\Currency; use Carbon\Carbon; -use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\CurrencyExchangeRate; use FireflyIII\Models\TransactionCurrency; use FireflyIII\User; diff --git a/app/Repositories/UserGroups/Currency/CurrencyRepository.php b/app/Repositories/UserGroups/Currency/CurrencyRepository.php index b7aafdbbb1..5556f67954 100644 --- a/app/Repositories/UserGroups/Currency/CurrencyRepository.php +++ b/app/Repositories/UserGroups/Currency/CurrencyRepository.php @@ -173,6 +173,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface /** * Get the user group's currencies. + * * @return Collection */ public function get(): Collection @@ -291,7 +292,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface * * @return TransactionCurrency|null */ - private function findByCode(string $currencyCode): ?TransactionCurrency + public function findByCode(string $currencyCode): ?TransactionCurrency { return TransactionCurrency::where('code', $currencyCode)->first(); } @@ -307,6 +308,16 @@ class CurrencyRepository implements CurrencyRepositoryInterface $currency->save(); } + /** + * @param array $ids + * + * @return Collection + */ + public function getByIds(array $ids): Collection + { + return TransactionCurrency::orderBy('code', 'ASC')->whereIn('id', $ids)->get(); + } + /** * @inheritDoc */ diff --git a/app/Repositories/UserGroups/Currency/CurrencyRepositoryInterface.php b/app/Repositories/UserGroups/Currency/CurrencyRepositoryInterface.php index 8e61214c31..9ac532976f 100644 --- a/app/Repositories/UserGroups/Currency/CurrencyRepositoryInterface.php +++ b/app/Repositories/UserGroups/Currency/CurrencyRepositoryInterface.php @@ -55,6 +55,13 @@ interface CurrencyRepositoryInterface */ public function find(int $currencyId): ?TransactionCurrency; + /** + * @param string $currencyCode + * + * @return TransactionCurrency|null + */ + public function findByCode(string $currencyCode): ?TransactionCurrency; + /** * Find by object, ID or code. Returns user default or system default. * @@ -89,6 +96,13 @@ interface CurrencyRepositoryInterface */ public function getAll(): Collection; + /** + * @param array $ids + * + * @return Collection + */ + public function getByIds(array $ids): Collection; + /** * @param TransactionCurrency $currency * diff --git a/app/Transformers/PiggyBankEventTransformer.php b/app/Transformers/PiggyBankEventTransformer.php index 0ab17a4f07..66e72cb579 100644 --- a/app/Transformers/PiggyBankEventTransformer.php +++ b/app/Transformers/PiggyBankEventTransformer.php @@ -26,7 +26,6 @@ namespace FireflyIII\Transformers; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\PiggyBankEvent; use FireflyIII\Repositories\Account\AccountRepositoryInterface; -use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; use JsonException; @@ -35,7 +34,6 @@ use JsonException; */ class PiggyBankEventTransformer extends AbstractTransformer { - private CurrencyRepositoryInterface $currencyRepos; private PiggyBankRepositoryInterface $piggyRepos; private AccountRepositoryInterface $repository; @@ -46,9 +44,8 @@ class PiggyBankEventTransformer extends AbstractTransformer */ public function __construct() { - $this->repository = app(AccountRepositoryInterface::class); - $this->currencyRepos = app(CurrencyRepositoryInterface::class); - $this->piggyRepos = app(PiggyBankRepositoryInterface::class); + $this->repository = app(AccountRepositoryInterface::class); + $this->piggyRepos = app(PiggyBankRepositoryInterface::class); } /** @@ -67,7 +64,6 @@ class PiggyBankEventTransformer extends AbstractTransformer // set up repositories. $this->repository->setUser($account->user); - $this->currencyRepos->setUser($account->user); $this->piggyRepos->setUser($account->user); // get associated currency or fall back to the default: diff --git a/app/Transformers/PiggyBankTransformer.php b/app/Transformers/PiggyBankTransformer.php index 0af30de935..43770a8924 100644 --- a/app/Transformers/PiggyBankTransformer.php +++ b/app/Transformers/PiggyBankTransformer.php @@ -27,7 +27,6 @@ use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\ObjectGroup; use FireflyIII\Models\PiggyBank; use FireflyIII\Repositories\Account\AccountRepositoryInterface; -use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; use JsonException; @@ -37,7 +36,6 @@ use JsonException; class PiggyBankTransformer extends AbstractTransformer { private AccountRepositoryInterface $accountRepos; - private CurrencyRepositoryInterface $currencyRepos; private PiggyBankRepositoryInterface $piggyRepos; /** @@ -47,9 +45,8 @@ class PiggyBankTransformer extends AbstractTransformer */ public function __construct() { - $this->accountRepos = app(AccountRepositoryInterface::class); - $this->currencyRepos = app(CurrencyRepositoryInterface::class); - $this->piggyRepos = app(PiggyBankRepositoryInterface::class); + $this->accountRepos = app(AccountRepositoryInterface::class); + $this->piggyRepos = app(PiggyBankRepositoryInterface::class); } /** @@ -67,7 +64,6 @@ class PiggyBankTransformer extends AbstractTransformer // set up repositories $this->accountRepos->setUser($account->user); - $this->currencyRepos->setUser($account->user); $this->piggyRepos->setUser($account->user); // get currency from account, or use default. diff --git a/app/Transformers/V2/AccountTransformer.php b/app/Transformers/V2/AccountTransformer.php index 74b198976b..4a2ab80572 100644 --- a/app/Transformers/V2/AccountTransformer.php +++ b/app/Transformers/V2/AccountTransformer.php @@ -30,7 +30,7 @@ use FireflyIII\Models\Account; use FireflyIII\Models\AccountMeta; use FireflyIII\Models\AccountType; use FireflyIII\Models\TransactionCurrency; -use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; +use FireflyIII\Repositories\UserGroups\Currency\CurrencyRepositoryInterface; use Illuminate\Support\Collection; /** @@ -56,6 +56,8 @@ class AccountTransformer extends AbstractTransformer $this->accountTypes = []; $this->balances = app('steam')->balancesByAccounts($objects, $this->getDate()); $this->convertedBalances = app('steam')->balancesByAccountsConverted($objects, $this->getDate()); + + /** @var CurrencyRepositoryInterface $repository */ $repository = app(CurrencyRepositoryInterface::class); $this->default = app('amount')->getDefaultCurrency(); diff --git a/changelog.md b/changelog.md index c28367f30d..ae59582ee3 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,41 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## 6.0.28 - 2023-10-28 + +### Added + +- #8076 Clone and edit button +- #7204 ability to + +### Changed + +- New actions for GitHub +- Currencies are now linked to users, and can be enabled per user +- Refactored upgrade commands +- You can no longer edit vital parts of reconciled transactions + +### Deprecated + +- Remove old v3 layout. + +### Removed + +- Initial release. + +### Fixed + +- Bad math in the order of piggy banks +- #8084 @JoSchrader fixed an issue with a duplicate button + +### Security + +- Initial release. + +### API + +- Initial release. + ## v6.0.27 - 2023-10-16 ### Added diff --git a/config/firefly.php b/config/firefly.php index 9f4c726108..ea4b43e6eb 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -112,8 +112,8 @@ return [ 'handle_debts' => true, // see cer.php for exchange rates feature flag. ], - 'version' => '6.0.27', - 'api_version' => '2.0.10', + 'version' => '6.0.28', + 'api_version' => '2.0.11', 'db_version' => 21, // generic settings