Skip to content

Delete day#10

Merged
jnfire merged 6 commits into
mainfrom
delete-day
Apr 26, 2026
Merged

Delete day#10
jnfire merged 6 commits into
mainfrom
delete-day

Conversation

@jnfire

@jnfire jnfire commented Apr 26, 2026

Copy link
Copy Markdown
Owner

This pull request introduces a new feature for deleting workday records, improves balance recalculation and cache handling (especially for NULL balances), and enhances project isolation to prevent cross-project data contamination. It also adds comprehensive tests for the new behaviors, updates documentation, and bumps the version to 0.5.1.

Major Features and Improvements:

Delete Workday Feature & UX:

  • Added a complete workflow for deleting daily time records from the history view, including confirmation dialogs displaying date, hours, and balance impact, with all operations isolated per project. [1] [2] [3] [4]

Balance Calculation and Cache Handling:

  • Updated balance cache logic to use COALESCE(total_balance, 0) instead of filtering out NULLs, ensuring correct cache updates even after imports or restores with NULL balances. [1] [2]
  • Recalculation of balances now only affects the active project, preventing unintended cross-project updates.

Testing and Quality:

Testing Enhancements:

  • Added a new test suite (tests/test_coalesce_null_balance.py) with 9 tests specifically targeting NULL balance handling, verifying cache resilience and project isolation.
  • Expanded overall test coverage for delete and recalculate flows.

Documentation and Versioning:

Documentation Updates:

  • Updated README.md, README.es.md, and feature lists to document the new delete feature, improved cache handling, and project isolation. [1] [2] [3] [4]
  • Added detailed changelog for version 0.5.1.

Version Bump:

  • Incremented version to 0.5.1.

jnfire and others added 6 commits April 26, 2026 20:05
- Add _delete_record_flow() function to handle delete workflow
  - Request exact date (YYYY-MM-DD format)
  - Validate record existence
  - Show confirmation with full record details (date, hours, minutes, balance)
  - Require explicit user confirmation (y/n or s/n in Spanish)
  - Call db.delete_record() for safe deletion
  - Update balance cache automatically

- Integrate 'D. Delete workday' option into view_history pagination menu
  - Appears alongside V (back), N (next), P (prev) options
  - Works in both English and Spanish

- Add i18n strings for delete feature:
  - delete_record_option: Menu label
  - delete_date_prompt: Input prompt
  - delete_record_not_found: Error message
  - delete_record_confirm: Confirmation with details
  - delete_success: Success message

Key features:
✓ Project isolation - only affects active project
✓ Balance cache update - automatic via db.delete_record()
✓ Error handling - validates dates, checks existence
✓ User confirmation - shows all details before deletion
✓ Multi-language - full English and Spanish support

All 27 tests pass, including existing functionality tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
FIXES:

1. Balance recalculation now only affects active project
   - Changed _handle_recalculate_balances() to call recalculate_project_balance(active_id)
   - Instead of recalculate_all_balances() which was affecting all projects
   - Prevents unintended balance recalculations for other projects
   - Message updated to reflect single project operation

2. Improved delete flow UX to show records in context
   - Display table of recent records (last 10) when entering delete flow
   - User can see available dates before entering date to delete
   - Maintains visual context throughout deletion process
   - Better user experience: can review records before selecting one to delete
   - Still shows confirmation with full details before actual deletion

VERIFICATION:
✓ Recalculate only affects active project (verified)
✓ Delete flow displays all recent records (verified)
✓ Delete functionality still works correctly (verified)
✓ All 27 existing tests pass

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
New test suite: tests/test_delete_and_recalculate.py

DELETES TESTS (9 tests):
- Delete single record updates balance correctly
- Delete positive difference records
- Delete negative difference records
- Delete zero difference records
- Delete all records clears balance
- Delete nonexistent record doesn't error
- Delete updates cached balance in projects table

RECALCULATE TESTS (6 tests):
- Single project recalculation has no cross-project contamination
- Recalculate corrects corrupted balance cache
- Recalculate handles many records (100+)
- Recalculate handles mixed positive/negative differences
- Recalculate only affects target project, not others
- Reset balance forces recalculation on next access

INTEGRATION TESTS (2 tests):
- Delete and recalculate produce consistent results
- Multiple deletes followed by recalculate remain consistent

All tests verify:
✓ Balance calculations always square after deletions
✓ No project contamination when recalculating
✓ Cache is properly updated
✓ Edge cases handled correctly

RESULTS:
- 15 new tests added, all passing
- Total test suite: 42/42 passing
- No regressions in existing tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…hting new delete workday feature and improvements in balance handling
- Delete workday feature complete
- COALESCE NULL balance handling
- Project-isolated recalculation
- 24 new tests added
- All standards validated

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jnfire jnfire merged commit fe5ea1a into main Apr 26, 2026
1 check passed
@jnfire jnfire deleted the delete-day branch April 26, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant