sossoldi icon indicating copy to clipboard operation
sossoldi copied to clipboard

perf(add_category): autoselect category type based on transaction type

Open gioisco opened this issue 9 months ago • 1 comments

🎯 Description

When creating a new category, the category type dropdown is preselected based on the transaction type (income or expense).

Closes: #390

📱 Changes

  • [x] Import the transaction provider in add_category
  • [x] Read the transaction type using the transaction provider and use it to set the category type
  • [x] Set the default category type to 'expense' if the transaction provider returns null
  • [x] Remove redundant "hide income" logic for selecting only the 'expense' category type in the initial setup (it is already handled during the dropdown load)

🧪 Testing Instructions

Expected Behavior

TEST 1 - Ensure correct default selection

  1. Add a new category from the Add Transaction screen with 'income' selected as the transaction type.
  2. The category type dropdown should default to 'income'.
  3. Repeat steps 1 and 2 with 'expense', and the dropdown should default to 'expense'.

TEST 2 - Remember the selected transaction type

  1. Open Add Transaction and select 'income' as the transaction type.
  2. Go to Settings → Categories → + (Add Category). The category type dropdown should default to 'income'.
  3. Repeat steps 1 and 2 with 'expense', and the dropdown should default to 'expense'.

TEST 3 - No side effects for 'transfer' transaction type

  1. Open Add Transaction and select 'transfer' as the transaction type.
  2. Go to Settings → Categories → + (Add Category). The category type dropdown should default to 'expense'.

TEST 4 - No side effects on the initial setup

  1. Set up the app for the first time.
  2. When creating the first category, the only available option should be 'expense'.

📸 Screen Recordings

Test Recordings: Creating a New Category

In initial setup

https://github.com/user-attachments/assets/83e7a4c0-b155-48e6-80cc-eea13bc0d6f9

From 'Expense' transaction

https://github.com/user-attachments/assets/8d8e3277-6fdf-47ff-8a1f-ae03a3cd6e04

From 'Income' transaction

https://github.com/user-attachments/assets/af635c06-3210-4187-b541-b08021a98495

From Categories (without conflicts)

https://github.com/user-attachments/assets/5c988ca0-1f6c-495e-b811-acc3af05beed

🔍 Checklist for Reviewers

  • [x] Code is properly formatted
  • [x] Tests are passing
  • [ ] New tests added (if necessary)
  • [ ] Style follows the Figma/designer's guidelines
  • Tested on:
    • [ ] iOS
    • [x] Android

✍️ Additional Context

None.

gioisco avatar Mar 30 '25 16:03 gioisco

@gioisco Hi, could you check the conflicts when you have time so we merge it?

napitek avatar Apr 29 '25 17:04 napitek

@napitek there are no more merge conflicts in the pull request and I also fixed the Dart format warning.

gioisco avatar May 02 '25 16:05 gioisco

Hi @gioisco , The PR looks good! I just noticed that the commits were made using a local Git configuration instead of your GitHub account, so they won’t be associated with your profile. Let me know if you'd like to redo the commits using the correct account. Otherwise if this is not a problem i will merge it.

lucaantonelli avatar May 04 '25 09:05 lucaantonelli

Hi @gioisco , The PR looks good! I just noticed that the commits were made using a local Git configuration instead of your GitHub account, so they won’t be associated with your profile. Let me know if you'd like to redo the commits using the correct account. Otherwise if this is not a problem i will merge it.

Thank you Luca! I didn't notice this. I’ve just added my commit email to this account, so from now on, my commits should be properly linked. I really appreciate your kindness. Let me know if you still see the same issue.

gioisco avatar May 04 '25 11:05 gioisco