From 7118abe28d60196533e7245fb28804e183161c74 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 13 Mar 2021 12:01:01 +0100 Subject: [PATCH] Fix some tests for account API --- .../Models/Account/StoreController.php | 1 + .../Requests/Models/Account/StoreRequest.php | 2 +- .../Models/Recurrence/UpdateRequest.php | 2 +- .../Commands/Correction/FixAccountOrder.php | 12 +- app/Factory/AccountFactory.php | 39 +- .../Controllers/Account/IndexController.php | 2 +- .../Account/AccountRepository.php | 35 +- .../Account/AccountRepositoryInterface.php | 11 +- .../PiggyBank/ModifiesPiggyBanks.php | 6 +- .../RuleGroup/RuleGroupRepository.php | 5 +- .../Internal/Support/AccountServiceTrait.php | 1 - .../Internal/Update/AccountUpdateService.php | 24 +- .../Internal/Update/BillUpdateService.php | 4 +- app/Support/Amount.php | 18 - app/Support/FireflyConfig.php | 16 +- app/Support/Twig/TransactionGroupTwig.php | 6 - app/Transformers/AccountTransformer.php | 2 +- composer.json | 5 +- composer.lock | 61 ++- config/firefly.php | 5 +- phpunit.xml | 15 +- .../Models/Account/StoreControllerTest.php | 238 +++++++++++ .../Models/Account/UpdateControllerTest.php | 53 +++ tests/TestCase.php | 2 - tests/Traits/CollectsValues.php | 393 +++++++++--------- tests/Traits/FakeValues.php | 34 ++ tests/Traits/MocksDefaultValues.php | 24 +- tests/Traits/RandomValues.php | 126 ++++++ tests/Traits/TestHelpers.php | 165 ++++++++ 29 files changed, 992 insertions(+), 315 deletions(-) create mode 100644 tests/Api/Models/Account/StoreControllerTest.php create mode 100644 tests/Api/Models/Account/UpdateControllerTest.php create mode 100644 tests/Traits/FakeValues.php create mode 100644 tests/Traits/RandomValues.php diff --git a/app/Api/V1/Controllers/Models/Account/StoreController.php b/app/Api/V1/Controllers/Models/Account/StoreController.php index f6f1c99335..a0d8d464ef 100644 --- a/app/Api/V1/Controllers/Models/Account/StoreController.php +++ b/app/Api/V1/Controllers/Models/Account/StoreController.php @@ -68,6 +68,7 @@ class StoreController extends Controller public function store(StoreRequest $request): JsonResponse { $data = $request->getAllAccountData(); + $this->repository->resetAccountOrder(); $account = $this->repository->store($data); $manager = $this->getManager(); diff --git a/app/Api/V1/Requests/Models/Account/StoreRequest.php b/app/Api/V1/Requests/Models/Account/StoreRequest.php index eb571e3d16..0049d2b350 100644 --- a/app/Api/V1/Requests/Models/Account/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Account/StoreRequest.php @@ -80,7 +80,7 @@ class StoreRequest extends FormRequest // append Location information. $data = $this->appendLocationData($data, null); - if ('liability' === $data['account_type']) { + if ('liability' === $data['account_type'] || 'liabilities' === $data['account_type']) { $data['opening_balance'] = bcmul($this->string('liability_amount'), '-1'); $data['opening_balance_date'] = $this->date('liability_start_date'); $data['account_type'] = $this->string('liability_type'); diff --git a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php index 3ddbff5b1c..b3ad05ea27 100644 --- a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php @@ -195,7 +195,7 @@ class UpdateRequest extends FormRequest { $validator->after( function (Validator $validator) { - $this->validateOneRecurrenceTransaction($validator); + //$this->validateOneRecurrenceTransaction($validator); $this->validateOneRepetitionUpdate($validator); $this->validateRecurrenceRepetition($validator); $this->validateRepetitionMoment($validator); diff --git a/app/Console/Commands/Correction/FixAccountOrder.php b/app/Console/Commands/Correction/FixAccountOrder.php index 3c9ebb53ee..1cf44a765a 100644 --- a/app/Console/Commands/Correction/FixAccountOrder.php +++ b/app/Console/Commands/Correction/FixAccountOrder.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace FireflyIII\Console\Commands\Correction; -use FireflyIII\Models\AccountType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\User; use Illuminate\Console\Command; @@ -62,16 +61,7 @@ class FixAccountOrder extends Command $users = User::get(); foreach ($users as $user) { $this->repository->setUser($user); - $sets = [ - [AccountType::DEFAULT, AccountType::ASSET], - [AccountType::EXPENSE, AccountType::BENEFICIARY], - [AccountType::REVENUE], - [AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE], - [AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION], - ]; - foreach ($sets as $set) { - $this->repository->resetAccountOrder($set); - } + $this->repository->resetAccountOrder(); } $end = round(microtime(true) - $start, 2); diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.php index 28f9620d84..be1164bba8 100644 --- a/app/Factory/AccountFactory.php +++ b/app/Factory/AccountFactory.php @@ -30,6 +30,7 @@ use FireflyIII\Models\AccountType; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Services\Internal\Support\AccountServiceTrait; use FireflyIII\Services\Internal\Support\LocationServiceTrait; +use FireflyIII\Services\Internal\Update\AccountUpdateService; use FireflyIII\User; use Log; @@ -42,12 +43,12 @@ class AccountFactory { use AccountServiceTrait, LocationServiceTrait; - protected AccountRepositoryInterface $accountRepository; - protected array $validAssetFields; - protected array $validCCFields; - protected array $validFields; - private array $canHaveVirtual; - private User $user; + protected AccountRepositoryInterface $accountRepository; + protected array $validAssetFields; + protected array $validCCFields; + protected array $validFields; + private array $canHaveVirtual; + private User $user; /** * AccountFactory constructor. @@ -73,9 +74,10 @@ class AccountFactory public function create(array $data): Account { $type = $this->getAccountType($data['account_type_id'] ?? null, $data['account_type'] ?? null); - if (null === $type) { - throw new FireflyException(sprintf('AccountFactory::create() was unable to find account type #%d ("%s").', $data['account_type_id'] ?? null, $data['account_type'] ?? null)); + throw new FireflyException( + sprintf('AccountFactory::create() was unable to find account type #%d ("%s").', $data['account_type_id'] ?? null, $data['account_type'] ?? null) + ); } $data['iban'] = $this->filterIban($data['iban'] ?? null); @@ -85,8 +87,13 @@ class AccountFactory $return = $this->find($data['name'], $type->type); if (null === $return) { + $this->accountRepository->resetAccountOrder(); + // create it: - $databaseData = ['user_id' => $this->user->id, 'account_type_id' => $type->id, 'name' => $data['name'], 'order' => $data['order'] ?? 0, 'virtual_balance' => $data['virtual_balance'] ?? null, 'active' => true === $data['active'], 'iban' => $data['iban'],]; + $databaseData = ['user_id' => $this->user->id, + 'account_type_id' => $type->id, + 'name' => $data['name'], 'order' => 0, + 'virtual_balance' => $data['virtual_balance'] ?? null, 'active' => true === $data['active'], 'iban' => $data['iban'],]; $currency = $this->getCurrency((int)($data['currency_id'] ?? null), (string)($data['currency_code'] ?? null)); unset($data['currency_code']); @@ -118,6 +125,15 @@ class AccountFactory // store location $this->storeNewLocation($return, $data); + + // set new order: + if (array_key_exists('order', $data)) { + $maxOrder = $this->accountRepository->maxOrder([$type->type]); + $order = $data['order'] > $maxOrder ? $maxOrder+1 : $data['order']; + $update = new AccountUpdateService; + $update->setUser($return->user); + $return = $update->updateAccountOrder($return,['order' => $order]); + } } return $return; @@ -152,7 +168,10 @@ class AccountFactory if (null === $return) { Log::debug('Found nothing. Will create a new one.'); - $return = $this->create(['user_id' => $this->user->id, 'name' => $accountName, 'account_type_id' => $type->id, 'account_type' => null, 'virtual_balance' => '0', 'iban' => null, 'active' => true,]); + $return = $this->create( + ['user_id' => $this->user->id, 'name' => $accountName, 'account_type_id' => $type->id, 'account_type' => null, 'virtual_balance' => '0', + 'iban' => null, 'active' => true,] + ); } return $return; diff --git a/app/Http/Controllers/Account/IndexController.php b/app/Http/Controllers/Account/IndexController.php index 02fa9aa43e..eb7dff2ca9 100644 --- a/app/Http/Controllers/Account/IndexController.php +++ b/app/Http/Controllers/Account/IndexController.php @@ -136,7 +136,7 @@ class IndexController extends Controller if (1 === random_int(0, 20)) { Log::debug('Will reset order.'); - $this->repository->resetAccountOrder($types); + $this->repository->resetAccountOrder(); } $collection = $this->repository->getActiveAccountsByType($types); diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index cd2910118b..82abfd1a69 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -586,16 +586,25 @@ class AccountRepository implements AccountRepositoryInterface /** * @inheritDoc */ - public function resetAccountOrder(array $types): void + public function resetAccountOrder(): void { - $list = $this->getAccountsByType($types); - /** - * @var int $index - * @var Account $account - */ - foreach ($list as $index => $account) { - $account->order = $index + 1; - $account->save(); + $sets = [ + [AccountType::DEFAULT, AccountType::ASSET], + [AccountType::EXPENSE, AccountType::BENEFICIARY], + [AccountType::REVENUE], + [AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE], + [AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION], + ]; + foreach ($sets as $set) { + $list = $this->getAccountsByType($set); + $index = 1; + foreach ($list as $account) { + if ($index !== $account->order) { + $account->order = $index; + $account->save(); + } + $index++; + } } } @@ -753,4 +762,12 @@ class AccountRepository implements AccountRepositoryInterface return $service->update($account, $data); } + + /** + * @inheritDoc + */ + public function maxOrder(array $types): int + { + return (int)$this->getAccountsByType($types)->max('order'); + } } diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php index c07e2efea1..fe8af00155 100644 --- a/app/Repositories/Account/AccountRepositoryInterface.php +++ b/app/Repositories/Account/AccountRepositoryInterface.php @@ -47,6 +47,13 @@ interface AccountRepositoryInterface */ public function count(array $types): int; + /** + * @param array $types + * + * @return int + */ + public function maxOrder(array $types): int; + /** * Moved here from account CRUD. * @@ -256,10 +263,8 @@ interface AccountRepositoryInterface /** * Reset order types of the mentioned accounts. - * - * @param array $types */ - public function resetAccountOrder(array $types): void; + public function resetAccountOrder(): void; /** * @param string $query diff --git a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php index 6738cd339f..fd3411542b 100644 --- a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php +++ b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php @@ -461,7 +461,8 @@ trait ModifiesPiggyBanks $user = $this->user; $user->piggyBanks()->where('piggy_banks.order', '<=', $newOrder)->where('piggy_banks.order', '>', $oldOrder) ->where('piggy_banks.id', '!=', $piggyBank->id) - ->update(['piggy_banks.order' => DB::raw('piggy_banks.order-1')]); + ->decrement('piggybanks.order',1); + $piggyBank->order = $newOrder; $piggyBank->save(); } @@ -474,7 +475,8 @@ trait ModifiesPiggyBanks $user = $this->user; $user->piggyBanks()->where('piggy_banks.order', '>=', $newOrder)->where('piggy_banks.order', '<', $oldOrder) ->where('piggy_banks.id', '!=', $piggyBank->id) - ->update(['piggy_banks.order' => DB::raw('piggy_banks.order+1')]); + ->increment('piggybanks.order',1); + $piggyBank->order = $newOrder; $piggyBank->save(); } diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.php index 0bff945f55..8b18dcc301 100644 --- a/app/Repositories/RuleGroup/RuleGroupRepository.php +++ b/app/Repositories/RuleGroup/RuleGroupRepository.php @@ -22,7 +22,6 @@ declare(strict_types=1); namespace FireflyIII\Repositories\RuleGroup; -use DB; use Exception; use FireflyIII\Models\Rule; use FireflyIII\Models\RuleGroup; @@ -458,14 +457,14 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface if ($newOrder > $oldOrder) { $this->user->ruleGroups()->where('order', '<=', $newOrder)->where('order', '>', $oldOrder) ->where('rule_groups.id', '!=', $ruleGroup->id) - ->update(['order' => DB::raw('rule_groups.order-1')]); + ->decrement('rule_groups.order', 1); $ruleGroup->order = $newOrder; $ruleGroup->save(); } if ($newOrder < $oldOrder) { $this->user->ruleGroups()->where('order', '>=', $newOrder)->where('order', '<', $oldOrder) ->where('rule_groups.id', '!=', $ruleGroup->id) - ->update(['order' => DB::raw('rule_groups.order+1')]); + ->increment('rule_groups.order', 1); $ruleGroup->order = $newOrder; $ruleGroup->save(); } diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.php index d427c37264..563d2b89aa 100644 --- a/app/Services/Internal/Support/AccountServiceTrait.php +++ b/app/Services/Internal/Support/AccountServiceTrait.php @@ -83,7 +83,6 @@ trait AccountServiceTrait public function updateMetaData(Account $account, array $data): void { $fields = $this->validFields; - if ($account->accountType->type === AccountType::ASSET) { $fields = $this->validAssetFields; } diff --git a/app/Services/Internal/Update/AccountUpdateService.php b/app/Services/Internal/Update/AccountUpdateService.php index 2393772dd6..52a7888634 100644 --- a/app/Services/Internal/Update/AccountUpdateService.php +++ b/app/Services/Internal/Update/AccountUpdateService.php @@ -52,9 +52,6 @@ class AccountUpdateService */ public function __construct() { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this))); - } // TODO move to configuration. $this->canHaveVirtual = [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD]; $this->accountRepository = app(AccountRepositoryInterface::class); @@ -63,6 +60,14 @@ class AccountUpdateService $this->validFields = ['account_number', 'currency_id', 'BIC', 'interest', 'interest_period', 'include_net_worth']; } + /** + * @param User $user + */ + public function setUser(User $user): void + { + $this->user = $user; + } + /** * Update account data. * @@ -73,6 +78,7 @@ class AccountUpdateService */ public function update(Account $account, array $data): Account { + Log::debug(sprintf('Now in %s',__METHOD__)); $this->accountRepository->setUser($account->user); $this->user = $account->user; $account = $this->updateAccount($account, $data); @@ -126,7 +132,7 @@ class AccountUpdateService } // update virtual balance (could be set to zero if empty string). - if (null !== $data['virtual_balance']) { + if (array_key_exists('virtual_balance', $data) && null !== $data['virtual_balance']) { $account->virtual_balance = '' === trim($data['virtual_balance']) ? '0' : $data['virtual_balance']; } @@ -175,7 +181,7 @@ class AccountUpdateService * * @return Account */ - private function updateAccountOrder(Account $account, array $data): Account + public function updateAccountOrder(Account $account, array $data): Account { // skip if no order info if (!array_key_exists('order', $data) || $data['order'] === $account->order) { @@ -195,20 +201,20 @@ class AccountUpdateService } if ($newOrder > $oldOrder) { - $this->user->accounts()->where('order', '<=', $newOrder)->where('order', '>', $oldOrder) + $this->user->accounts()->where('accounts.order', '<=', $newOrder)->where('accounts.order', '>', $oldOrder) ->where('accounts.id', '!=', $account->id) ->whereIn('accounts.account_type_id', $list) - ->update(['order' => DB::raw('accounts.order-1')]); + ->decrement('order', 1); $account->order = $newOrder; $account->save(); return $account; } - $this->user->accounts()->where('order', '>=', $newOrder)->where('order', '<', $oldOrder) + $this->user->accounts()->where('accounts.order', '>=', $newOrder)->where('accounts.order', '<', $oldOrder) ->where('accounts.id', '!=', $account->id) ->whereIn('accounts.account_type_id', $list) - ->update(['order' => DB::raw('accounts.order+1')]); + ->increment('order',1); $account->order = $newOrder; $account->save(); diff --git a/app/Services/Internal/Update/BillUpdateService.php b/app/Services/Internal/Update/BillUpdateService.php index 2aeffabf75..4db3e78c28 100644 --- a/app/Services/Internal/Update/BillUpdateService.php +++ b/app/Services/Internal/Update/BillUpdateService.php @@ -185,14 +185,14 @@ class BillUpdateService if ($newOrder > $oldOrder) { $this->user->bills()->where('order', '<=', $newOrder)->where('order', '>', $oldOrder) ->where('bills.id', '!=', $bill->id) - ->update(['order' => DB::raw('bills.order-1')]); + ->decrement('bills.order',1); $bill->order = $newOrder; $bill->save(); } if ($newOrder < $oldOrder) { $this->user->bills()->where('order', '>=', $newOrder)->where('order', '<', $oldOrder) ->where('bills.id', '!=', $bill->id) - ->update(['order' => DB::raw('bills.order+1')]); + ->increment('bills.order',1); $bill->order = $newOrder; $bill->save(); } diff --git a/app/Support/Amount.php b/app/Support/Amount.php index ede6ff8dc8..f7b73cd0a2 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -223,10 +223,6 @@ class Amount */ public function getAllCurrencies(): Collection { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__)); - } - return TransactionCurrency::orderBy('code', 'ASC')->get(); } @@ -235,10 +231,6 @@ class Amount */ public function getCurrencies(): Collection { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__)); - } - return TransactionCurrency::where('enabled', true)->orderBy('code', 'ASC')->get(); } @@ -247,9 +239,6 @@ class Amount */ public function getCurrencyCode(): string { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__)); - } $cache = new CacheProperties; $cache->addProperty('getCurrencyCode'); if ($cache->has()) { @@ -273,9 +262,6 @@ class Amount */ public function getDefaultCurrency(): TransactionCurrency { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__)); - } /** @var User $user */ $user = auth()->user(); @@ -287,10 +273,6 @@ class Amount */ public function getSystemCurrency(): TransactionCurrency { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__)); - } - return TransactionCurrency::where('code', 'EUR')->first(); } diff --git a/app/Support/FireflyConfig.php b/app/Support/FireflyConfig.php index 8711785f12..97504e757a 100644 --- a/app/Support/FireflyConfig.php +++ b/app/Support/FireflyConfig.php @@ -41,9 +41,6 @@ class FireflyConfig */ public function delete(string $name): void { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s("%s") should NOT be called in the TEST environment!', __METHOD__, $name)); - } $fullName = 'ff-config-' . $name; if (Cache::has($fullName)) { Cache::forget($fullName); @@ -75,9 +72,6 @@ class FireflyConfig */ public function get(string $name, $default = null): ?Configuration { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s("%s") should NOT be called in the TEST environment!', __METHOD__, $name)); - } $fullName = 'ff-config-' . $name; if (Cache::has($fullName)) { return Cache::get($fullName); @@ -111,9 +105,7 @@ class FireflyConfig */ public function getFresh(string $name, $default = null): ?Configuration { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__)); - } + $config = Configuration::where('name', $name)->first(['id', 'name', 'data']); if ($config) { @@ -135,9 +127,6 @@ class FireflyConfig */ public function put(string $name, $value): Configuration { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__)); - } return $this->set($name, $value); } @@ -151,9 +140,6 @@ class FireflyConfig */ public function set(string $name, $value): Configuration { - if ('testing' === config('app.env')) { - Log::warning(sprintf('%s should NOT be called in the TEST environment!', __METHOD__)); - } /** @var Configuration $config */ try { $config = Configuration::whereName($name)->first(); diff --git a/app/Support/Twig/TransactionGroupTwig.php b/app/Support/Twig/TransactionGroupTwig.php index 281d6b698b..934411517e 100644 --- a/app/Support/Twig/TransactionGroupTwig.php +++ b/app/Support/Twig/TransactionGroupTwig.php @@ -62,9 +62,6 @@ class TransactionGroupTwig extends AbstractExtension return new TwigFunction( 'journalGetMetaDate', static function (int $journalId, string $metaField) { - if ('testing' === config('app.env')) { - Log::warning('Twig TransactionGroup::journalGetMetaDate should NOT be called in the TEST environment!'); - } $entry = DB::table('journal_meta') ->where('name', $metaField) ->where('transaction_journal_id', $journalId) @@ -87,9 +84,6 @@ class TransactionGroupTwig extends AbstractExtension return new TwigFunction( 'journalGetMetaField', static function (int $journalId, string $metaField) { - if ('testing' === config('app.env')) { - Log::warning('Twig TransactionGroup::journalGetMetaField should NOT be called in the TEST environment!'); - } $entry = DB::table('journal_meta') ->where('name', $metaField) ->where('transaction_journal_id', $journalId) diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.php index 70d34c9ffe..554773e27f 100644 --- a/app/Transformers/AccountTransformer.php +++ b/app/Transformers/AccountTransformer.php @@ -91,7 +91,7 @@ class AccountTransformer extends AbstractTransformer 'created_at' => $account->created_at->toAtomString(), 'updated_at' => $account->updated_at->toAtomString(), 'active' => $account->active, - 'order' => $account->order, + 'order' => (int) $account->order, 'name' => $account->name, 'type' => strtolower($accountType), 'account_role' => $accountRole, diff --git a/composer.json b/composer.json index 362b8f0390..c324c9f230 100644 --- a/composer.json +++ b/composer.json @@ -100,7 +100,8 @@ "pragmarx/google2fa": "^8.0", "predis/predis": "^1.1", "ramsey/uuid": "^4.1", - "rcrowe/twigbridge": "^0.12.1" + "rcrowe/twigbridge": "^0.12.1", + "spatie/data-transfer-object": "^2.8" }, "require-dev": { "barryvdh/laravel-debugbar": "^3.3", @@ -108,7 +109,6 @@ "ergebnis/phpstan-rules": "^0.15.0", "filp/whoops": "2.*", "fakerphp/faker": "1.*", - "johnkary/phpunit-speedtrap": "^3.1", "mockery/mockery": "1.*", "nunomaduro/larastan": "^0.7.0", "phpstan/phpstan": "^0.12.34", @@ -125,6 +125,7 @@ "autoload": { "psr-4": { "FireflyIII\\": "app/", + "Domain\\": "domain/", "Database\\Factories\\": "database/factories/", "Database\\Seeders\\": "database/seeders/" } diff --git a/composer.lock b/composer.lock index 04fa765d0b..3d192a33bb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5d5b27d4e58ebc72b63359767f4c5763", + "content-hash": "7294670d4c743796b6929563ab61451d", "packages": [ { "name": "bacon/bacon-qr-code", @@ -4285,6 +4285,65 @@ }, "time": "2020-10-14T18:14:32+00:00" }, + { + "name": "spatie/data-transfer-object", + "version": "2.8.3", + "source": { + "type": "git", + "url": "https://github.com/spatie/data-transfer-object.git", + "reference": "2625a59566804ec63f01947d85947336237cbda6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/data-transfer-object/zipball/2625a59566804ec63f01947d85947336237cbda6", + "reference": "2625a59566804ec63f01947d85947336237cbda6", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "suggest": { + "phpstan/phpstan": "Take advantage of checkUninitializedProperties with \\Spatie\\DataTransferObject\\PHPstan\\PropertiesAreAlwaysInitializedExtension" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\DataTransferObject\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brent Roose", + "email": "brent@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Data transfer objects with batteries included", + "homepage": "https://github.com/spatie/data-transfer-object", + "keywords": [ + "data-transfer-object", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/data-transfer-object/issues", + "source": "https://github.com/spatie/data-transfer-object/tree/2.8.3" + }, + "funding": [ + { + "url": "https://www.patreon.com/spatie", + "type": "patreon" + } + ], + "time": "2021-02-12T08:46:52+00:00" + }, { "name": "swiftmailer/swiftmailer", "version": "v6.2.7", diff --git a/config/firefly.php b/config/firefly.php index f8042f4f49..ac4b49383b 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -54,8 +54,8 @@ use FireflyIII\Support\Binder\CLIToken; use FireflyIII\Support\Binder\CurrencyCode; use FireflyIII\Support\Binder\Date; use FireflyIII\Support\Binder\DynamicConfigKey; -use FireflyIII\Support\Binder\JournalList; use FireflyIII\Support\Binder\EitherConfigKey; +use FireflyIII\Support\Binder\JournalList; use FireflyIII\Support\Binder\TagList; use FireflyIII\Support\Binder\TagOrId; use FireflyIII\TransactionRules\Actions\AddTag; @@ -258,6 +258,9 @@ return [ 'initial' => [AccountType::INITIAL_BALANCE], 'import' => [AccountType::IMPORT], 'reconcile' => [AccountType::RECONCILIATION], + 'loan' => [AccountType::LOAN], + 'debt' => [AccountType::DEBT], + 'mortgage' => [AccountType::MORTGAGE], 'liabilities' => [AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE, AccountType::CREDITCARD], 'liability' => [AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE, AccountType::CREDITCARD], ], diff --git a/phpunit.xml b/phpunit.xml index aa554c3e3b..62175fb34e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -34,20 +34,9 @@ ./app - - - - - - 1000 - - - - - - - ./tests/Feature + + ./tests/Api/Models/Account