Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Remove credit card liability type from system.
James Cole3d91a186d54d
diff --git a/app/Console/Commands/UpgradeDatabase.php b/app/Console/Commands/UpgradeDatabase.phpindex 246222edfa..a5de3d1e7b 100644--- a/app/Console/Commands/UpgradeDatabase.php+++ b/app/Console/Commands/UpgradeDatabase.php@@ -98,6 +98,7 @@ class UpgradeDatabase extends Command$this->migrateAttachmentData();$this->migrateBillsToRules();$this->budgetLimitCurrency();+ $this->removeCCLiabilities();$this->info('Firefly III database is up to date.');@@ -535,6 +536,28 @@ class UpgradeDatabase extends Command}}+ /**+ *+ */+ private function removeCCLiabilities(): void+ {+ $ccType = AccountType::where('type', AccountType::CREDITCARD)->first();+ $debtType =AccountType::where('type', AccountType::DEBT)->first();+ if(null === $ccType || null === $debtType) {+ return;+ }+ /** @var Collection $accounts */+ $accounts = Account::where('account_type_id', $ccType->id)->get();+ foreach($accounts as $account) {+ $account->account_type_id = $debtType->id;+ $account->save();+ $this->line(sprintf('Converted credit card liability account "%s" (#%d) to generic debt liability.', $account->name, $account->id));+ }+ if($accounts->count() > 0) {+ $this->info('Credit card liability types are no longer supported and have been converted to generic debts. See: http://bit.ly/FF3-credit-cards');+ }+ }+/*** This method makes sure that the transaction journal uses the currency given in the transaction.*diff --git a/app/Http/Controllers/Account/CreateController.php b/app/Http/Controllers/Account/CreateController.phpindex 6440aae26b..02c32fb94b 100644--- a/app/Http/Controllers/Account/CreateController.php+++ b/app/Http/Controllers/Account/CreateController.php@@ -83,12 +83,10 @@ class CreateController extends Controller$debt = $this->repository->getAccountTypeByType(AccountType::DEBT);$loan = $this->repository->getAccountTypeByType(AccountType::LOAN);$mortgage = $this->repository->getAccountTypeByType(AccountType::MORTGAGE);- $creditCard = $this->repository->getAccountTypeByType(AccountType::CREDITCARD);$liabilityTypes = [$debt->id => (string)trans('firefly.account_type_' . AccountType::DEBT),$loan->id => (string)trans('firefly.account_type_' . AccountType::LOAN),$mortgage->id => (string)trans('firefly.account_type_' . AccountType::MORTGAGE),- $creditCard->id => (string)trans('firefly.account_type_' . AccountType::CREDITCARD),];asort($liabilityTypes);diff --git a/app/Http/Controllers/Account/EditController.php b/app/Http/Controllers/Account/EditController.phpindex 2ce4d98aa7..b984efb5cb 100644--- a/app/Http/Controllers/Account/EditController.php+++ b/app/Http/Controllers/Account/EditController.php@@ -90,12 +90,10 @@ class EditController extends Controller$debt = $this->repository->getAccountTypeByType(AccountType::DEBT);$loan = $this->repository->getAccountTypeByType(AccountType::LOAN);$mortgage = $this->repository->getAccountTypeByType(AccountType::MORTGAGE);- $creditCard = $this->repository->getAccountTypeByType(AccountType::CREDITCARD);$liabilityTypes = [$debt->id => (string)trans('firefly.account_type_' . AccountType::DEBT),$loan->id => (string)trans('firefly.account_type_' . AccountType::LOAN),$mortgage->id => (string)trans('firefly.account_type_' . AccountType::MORTGAGE),- $creditCard->id => (string)trans('firefly.account_type_' . AccountType::CREDITCARD),];asort($liabilityTypes);diff --git a/database/seeds/AccountTypeSeeder.php b/database/seeds/AccountTypeSeeder.phpindex f695c310d8..c3bb0287e9 100644--- a/database/seeds/AccountTypeSeeder.php+++ b/database/seeds/AccountTypeSeeder.php@@ -28,7 +28,7 @@ use Illuminate\Database\Seeder;*/class AccountTypeSeeder extends Seeder{- public function run()+ public function run(): void{$types = [AccountType::DEFAULT,@@ -42,8 +42,7 @@ class AccountTypeSeeder extends SeederAccountType::LOAN,AccountType::RECONCILIATION,AccountType::DEBT,- AccountType::MORTGAGE,- AccountType::CREDITCARD,+ AccountType::MORTGAGE];foreach ($types as $type) {try {diff --git a/tests/Feature/Controllers/Account/CreateControllerTest.php b/tests/Feature/Controllers/Account/CreateControllerTest.phpindex 33879f295f..9d558d8b25 100644--- a/tests/Feature/Controllers/Account/CreateControllerTest.php+++ b/tests/Feature/Controllers/Account/CreateControllerTest.php@@ -73,7 +73,6 @@ class CreateControllerTest extends TestCase$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Debt'])->andReturn(AccountType::find(11))->once();$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Loan'])->andReturn(AccountType::find(9))->once();$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Mortgage'])->andReturn(AccountType::find(12))->once();- $accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Credit card'])->andReturn(AccountType::find(13))->once();$this->be($this->user());$response = $this->get(route('accounts.create', ['asset']));diff --git a/tests/Feature/Controllers/Account/EditControllerTest.php b/tests/Feature/Controllers/Account/EditControllerTest.phpindex 44cf046a7b..cdcb965e36 100644--- a/tests/Feature/Controllers/Account/EditControllerTest.php+++ b/tests/Feature/Controllers/Account/EditControllerTest.php@@ -86,7 +86,6 @@ class EditControllerTest extends TestCase$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Debt'])->andReturn(AccountType::find(11))->once();$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Loan'])->andReturn(AccountType::find(9))->once();$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Mortgage'])->andReturn(AccountType::find(12))->once();- $accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Credit card'])->andReturn(AccountType::find(13))->once();$this->be($this->user());@@ -131,7 +130,6 @@ class EditControllerTest extends TestCase$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Debt'])->andReturn(AccountType::find(11))->once();$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Loan'])->andReturn(AccountType::find(9))->once();$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Mortgage'])->andReturn(AccountType::find(12))->once();- $accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Credit card'])->andReturn(AccountType::find(13))->once();$this->be($this->user());