-
Notifications
You must be signed in to change notification settings - Fork 185
feat(categories)!: Ability to delete Categories and consequences on transactions and recurring transactions #344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
napitek
wants to merge
35
commits into
RIP-Comm:main
Choose a base branch
from
napitek:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
f7ade5d
New "Uncategorized" Category, markAsDelete/Delete Dialog
napitek 733ed54
Merge branch 'RIP-Comm:main' into main
napitek bbe4a76
markedAsDelete - delete CategoryTransaction workflow
napitek 221f9e9
Reassign CategoryTransaction to recurring transactions
napitek 5351b3e
UNIQUE constraint failed: categoryTransaction.id, constraint failed (…
napitek 725722d
Fix ALL CATEGORIES section filter
napitek b357142
fix Uncategorized CategoryTransaction unselectable
napitek 7abd401
adapt the changes to the MigrationManager
napitek a67df8d
resolve dart format conflict
napitek 6584732
test conflict
napitek cb22393
conflicts
napitek e550eed
empty line conflict test
napitek a6b717c
empty line conflict test 2
napitek 13e1a2d
fix missing countNetWorth in bank_account_test
napitek f1549f2
another conflict
napitek 9881b3c
missing empty line
napitek c88a5e1
adapt inital_schema with markedAsDeleted
napitek efc30ab
Merge branch 'main' into main
napitek 7680807
RoundedIcon with "markedAsDeleted" subIcon
napitek 31d777c
delete budgets when category is markedAsDeleted/deleted
napitek be6ec53
Merge remote-tracking branch 'upstream/main'
napitek abcfb70
conflict settings
napitek e6af840
dart format
napitek 1569828
Delete category dialog review with ref.invalidates
napitek d9f501c
Alert by duplicated category and empty category name
napitek 8a0f6e1
restore temporary hided #178
napitek 08586b7
Merge branch 'main' into main
napitek 8673070
Merge branch 'RIP-Comm:main' into main
napitek 4fb8c7b
Patching for migrations workflow, RoundedIcon with "markedAsDeleted" …
napitek 8cca904
dart format bruh
napitek 7342c6e
fix migration names
napitek 7ee0b91
Merge branch 'main' into main
napitek ab22234
dart format bruh 2
napitek e622740
cat to category
napitek e556a0c
Merge branch 'RIP-Comm:main' into main
napitek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
lib/database/migrations/0004_category_marked_as_deleted.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// ignore_for_file: file_names | ||
|
||
import 'package:sqflite/sqflite.dart'; | ||
import '../migration_base.dart'; | ||
|
||
// Models | ||
import '/model/category_transaction.dart'; | ||
|
||
class CategoryMarkedAsDeleted extends Migration { | ||
CategoryMarkedAsDeleted() | ||
: super( | ||
version: 4, | ||
description: 'Add deleted column to CategoryTransaction model', | ||
); | ||
|
||
@override | ||
Future<void> up(Database db) async { | ||
const integerNotNull = 'INTEGER NOT NULL'; | ||
|
||
// CategoryTransactionTable | ||
await db.execute(''' | ||
ALTER TABLE `$categoryTransactionTable` ADD COLUMN `${CategoryTransactionFields.deleted}` $integerNotNull DEFAULT 0; | ||
'''); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
lib/database/migrations/0005_uncategorized_default_category.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// ignore_for_file: file_names | ||
|
||
import 'package:sqflite/sqflite.dart'; | ||
import '../migration_base.dart'; | ||
|
||
// Models | ||
import '/model/category_transaction.dart'; | ||
|
||
class UncategorizedDefaultCategory extends Migration { | ||
UncategorizedDefaultCategory() | ||
: super( | ||
version: 5, | ||
description: 'Create default "Uncategorized" category', | ||
); | ||
|
||
@override | ||
Future<void> up(Database db) async { | ||
// Default "Uncategorized" Category | ||
await db.execute(''' | ||
INSERT INTO `$categoryTransactionTable`(`${CategoryTransactionFields.id}`, `${CategoryTransactionFields.name}`, `${CategoryTransactionFields.type}`, `${CategoryTransactionFields.symbol}`, `${CategoryTransactionFields.color}`, `${CategoryTransactionFields.note}`, `${CategoryTransactionFields.parent}`, `${CategoryTransactionFields.deleted}`, `${CategoryTransactionFields.createdAt}`, `${CategoryTransactionFields.updatedAt}`) VALUES | ||
(0, "Uncategorized", "IN", "question_mark", 0, 'This is a default category for no categorized transactions', null, '0', '${DateTime.now()}', '${DateTime.now()}'), | ||
(1, "Uncategorized", "OUT", "question_mark", 0, 'This is a default category for no categorized transactions', null, '0', '${DateTime.now()}', '${DateTime.now()}'); | ||
'''); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a problem in migration 5:
Users who don't have the demo data (i.e. they went through onboarding by adding a budget, or started from scratch and added a category afterwards) already have a categoryTransaction with ID 1, so this query fails and the app doesn't open.
There are two ways to fix it:
We allow those categories to have any ID (I don't remember if they must be 0 and 1), and let the auto-increment assign them.
Before running the query, we check if category ID 1 already exists, and if so, we assign it a different ID and update all associated transactions. Only then we insert the new categories with IDs 0 and 1.
Any other ideas?