Introduce missing methods

This commit is contained in:
James Cole 2023-10-28 14:59:16 +02:00
parent 1d138eed8d
commit fa920fed4e
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
15 changed files with 79 additions and 42 deletions

View File

@ -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);
}
);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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));

View File

@ -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)) {

View File

@ -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;

View File

@ -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
*/

View File

@ -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
*

View File

@ -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:

View File

@ -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.

View File

@ -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();

View File

@ -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

View File

@ -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