feat: subscription management#67
Merged
Merged
Conversation
- Requirements: 7 user stories with 31 acceptance criteria - Design: Database schema, composables, components, 23 correctness properties - Tasks: 16 top-level tasks with comprehensive property-based testing - Features: Multi-currency support, auto-renewal, lifecycle tracking - API integration: exchangerate-api.com with localStorage caching
- Add subscriptions table with RLS policies and constraints - Add user_preferences table for storing user settings - Add TypeScript interfaces for Subscription, Currency, ExchangeRate, UserPreference - Add display models and component prop/emit interfaces - Add indexes and triggers for both tables Implements task 1: Set up database schema and types Requirements: 1.1, 1.2, 1.3, 1.5, 2.1, 2.2, 2.3, 4.1, 4.2
…tion - Add useCurrency composable with full currency conversion functionality - Implement fetchExchangeRates to call exchangerate-api.com - Add localStorage caching with 24-hour validity - Implement convert and getExchangeRate functions with inverse fallback - Add loadUserCurrencyPreference and setMainCurrency for database integration - Define supported currencies: CNY, USD, EUR, GBP, JPY, HKD - Add comprehensive unit tests (20 tests passing) - Validates Requirements 4.1, 4.2, 4.3, 4.4, 4.5 Task: 2.1 Create useCurrency composable with exchange rate API integration
- Install fast-check for property-based testing - Implement Property 10: Currency conversion accuracy test - Test validates that convert(amount, from, to) = amount × exchangeRate - Runs 100 iterations across all supported currency pairs - Validates Requirements 4.1, 4.3, 4.4
- Implement property-based test for same currency display - Validates that when original currency matches main currency, no conversion is applied - Tests that convert() returns original amount and getExchangeRate() returns 1 - Runs 100 iterations across all supported currencies - Validates Requirements 4.5
- Implement useCurrency composable with exchange rate API integration - Add localStorage caching with 24-hour validity for exchange rates - Implement currency conversion functions (convert, getExchangeRate) - Add user preference management (loadUserCurrencyPreference, setMainCurrency) - Support 6 currencies: CNY, USD, EUR, GBP, JPY, HKD - Add Property 10: Currency conversion accuracy test (100 iterations) - Add Property 12: Same currency display test (100 iterations) - All 22 tests passing Validates Requirements: 4.1, 4.2, 4.3, 4.4, 4.5 Completes task 2 and subtasks 2.1, 2.2, 2.3
- Add loadSubscriptions function to fetch from database - Add createSubscription with comprehensive validation - Add updateSubscription with validation - Add deleteSubscription function - Add calculateNextBillingDate for monthly/yearly frequencies - Add snake_case to camelCase conversion utilities - Validate required fields, billing frequency, and auto-renew/end date relationship - Include proper error handling with Chinese error messages Task: 3.1 Create useSubscriptions composable with CRUD operations Requirements: 1.1, 1.2, 1.3, 1.4, 1.5, 2.1, 2.2, 2.3, 2.4, 2.5, 3.1, 3.3
- Implement property-based test validating subscription creation with valid data - Test runs 100 iterations with randomly generated valid inputs - Validates Requirements 1.1 and 1.4 - Fix bug: convertKeysToCamelCase now properly converts null to undefined for endDate field - All 96 tests passing
- Implements Property 2: Required field validation - Validates Requirements 1.2 - Tests that subscription creation rejects data with missing required fields - Verifies appropriate error messages are thrown for validation failures - Runs 100 iterations with various combinations of missing fields - All tests passing
- Implements Property 3: Billing frequency validation - Validates Requirements 1.3 - Tests that only 'monthly' or 'yearly' are accepted as valid billing frequencies - Generates 100 test cases with invalid billing frequency values - Verifies proper error handling and Chinese error messages - All tests passing
- Implement Property 4 test validating Requirements 1.5 - Test verifies invalid combinations are rejected (auto-renew with end date, non-auto-renew without end date) - Test verifies valid combinations are accepted - Runs 100 iterations with randomly generated subscription data - All tests passing
- Implement Property 6 test validating Requirements 2.2 - Test ensures end date is required when changing from auto-renew to fixed end date - Validates both rejection (no end date) and acceptance (with end date) cases - Runs 100 iterations with randomly generated subscription data - All tests passing
- Implements property-based test validating Requirements 2.3 - Tests that changing subscription from fixed end date to auto-renew clears the end date - Verifies end date is set to undefined when transitioning to auto-renew - Runs 100 iterations with random subscription data - All tests passing
- Implements Property 8: Currency change recalculation test - Validates Requirement 2.5: currency modification and display amount recalculation - Tests that subscription currency updates are properly persisted - Runs 100 iterations across different currency combinations - All tests passing
- Implement Property 9: Subscription deletion test - Validates Requirements 3.1, 3.3 - Tests that deleted subscriptions are removed from both database and list - Verifies other subscriptions remain unaffected - Runs 100 iterations with random subscription data - All tests passing
- Add calculateMonthlyEquivalent and calculateYearlyEquivalent functions - Add isExpired, isEndingSoon, and getDaysUntilEnd lifecycle checks - Add calculateTotalCosts for aggregate subscription calculations - Excludes expired subscriptions from totals - Supports 30-day threshold for ending soon detection Implements task 4.1 from subscription-management spec Requirements: 6.3, 6.4, 6.5, 7.1, 7.2, 7.3, 7.4, 7.5, 7.6
- Implement Property 19: Expiration detection tests (3 variants) - Test expired subscriptions (past end dates) - Test auto-renew subscriptions never expire - Test future end dates are not expired - Implement Property 18: Ending soon detection tests (4 variants) - Test subscriptions ending within 30 days - Test auto-renew subscriptions never ending soon - Test far future end dates not ending soon - Test expired subscriptions not ending soon - Implement Property 21: Monthly total calculation test - Validates sum of monthly + yearly/12 subscriptions - Implement Property 22: Yearly total calculation test - Validates sum of yearly + monthly*12 subscriptions - Implement Property 23: Expired subscription exclusion test - Validates expired subscriptions excluded from totals - Validates active subscriptions included in totals All tests run 100 iterations and validate requirements 6.3, 6.4, 6.5, 7.1-7.6
- Create SubscriptionForm.vue with all required fields - Add form validation for required fields and positive amounts - Implement conditional end date field based on renewal type - Add currency selector with supported currencies - Add billing frequency and renewal type radio buttons - Handle both create and edit modes - Emit save and update events - Validate future dates for end date field - Calculate next billing date automatically Implements task 5.1 from subscription-management spec Validates requirements: 1.1, 1.2, 1.3, 1.5, 2.1, 2.2, 2.3, 2.5
- Add SubscriptionCard.vue component with full display features - Display subscription name, amount, and billing frequency - Show original currency when different from main currency - Display auto-renew indicator or end date - Show warning for subscriptions ending soon - Display expired badge for past end dates - Show next billing date for active subscriptions - Add edit and delete action buttons with proper emits - Follow existing Vuetify styling patterns - Include Chinese labels consistent with app - Add ARIA labels for accessibility Implements task 6.1 from subscription-management spec Validates requirements: 4.2, 4.5, 5.3, 6.1, 6.2, 6.3, 6.4, 6.5
- Implement Property 11: Dual currency display validation - Implement Property 14: Subscription display information validation - Implement Property 16: Auto-renew indicator validation - Implement Property 17: End date display validation - Implement Property 20: Next billing date calculation validation All tests use fast-check with 100 iterations and verify correctness properties for subscription display data structures. Validates Requirements: 4.2, 5.3, 6.1, 6.2, 6.5
- Add SubscriptionList.vue component with active/expired grouping - Display loading state with spinner and Chinese text - Show empty state when no subscriptions exist - Group subscriptions by status (active/expired) with counts - Forward edit and delete events from SubscriptionCard - Follow existing codebase patterns and Chinese localization - Mark task 7.1 as completed Validates Requirements 5.1, 5.3
- Implement Property 13: Subscription list completeness - Validates Requirements 5.1 - Tests that all subscriptions are displayed when navigating to subscriptions tab - Verifies grouping logic maintains completeness (no lost/duplicated subscriptions) - Runs 100 iterations with random subscription data - Test passes successfully
- Add SubscriptionSummary.vue component with card layout - Display total monthly and yearly costs - Show active subscription count - Display currency indicator with localized names - Include currency formatting utilities - Responsive grid layout for mobile and desktop - Mark task 8.1 as completed in tasks.md Requirements: 7.1, 7.2
- Add CurrencySettings.vue component with currency selector - Display current main currency with symbol, code, and name - Provide dropdown with all supported currencies (CNY, USD, EUR, GBP, JPY, HKD) - Emit update event when currency changes - Include help text explaining currency conversion - Follow existing Vuetify card-based design pattern - Implement proper TypeScript types and v-model pattern - Complete task 9.1 from subscription management spec Requirements: 4.1, 4.3
- Implement main SubscriptionsView component with full CRUD operations - Add currency settings, subscription summary, and list display - Implement delete confirmation dialog - Add comprehensive error handling and loading states - Fix useSubscriptions composable to use module-level refs for state persistence - Add Property 15 test validating state persistence across navigation - All tests passing (10/10) Validates Requirements: 1.1, 1.4, 2.1, 2.4, 3.1, 3.3, 4.1, 4.3, 5.1, 5.5
- Add subscriptions button with mdi-sync icon - Add Chinese label '订阅' (subscriptions) - Update route mapping to handle Subscriptions route - Implements task 11.1 (Requirements 5.2, 5.4)
- Add /subscriptions route with requiresAuth meta flag - Import SubscriptionsView component in router - Complete task 11: Add subscriptions tab to navigation - Validates Requirements 5.1, 5.2
…y in db/schema.sql
- Implement Vuetify confirmation dialog in SubscriptionsView - Display subscription name in confirmation message - Add cancel and confirm actions with loading state - Include proper error handling and user feedback - Validates Requirements 3.2 Task 14.1 complete
… center FAB, optimize layout
…og, loading state, and fix HKD symbol consistency
…empty or passwords don't match
- Add start_date field to subscriptions table and TypeScript types - Update SubscriptionForm to include start date input - Calculate next billing date based on start date - Improve SubscriptionCard layout: - Display badges (billing frequency, auto-renew, expiring soon) inline - Hide next billing date when end date is before next billing - Show '下次续订' for auto-renew vs '下次扣费' for fixed end - Reduce spacing between edit/delete icons - Update ExpenseList to match icon spacing - Update empty state text to reflect centered FAB position
- Import and use getTodayDate() and formatDateToLocal() from dateUtils - Ensures dates are handled in local timezone, preventing day shifts - Matches the date handling approach used in expense form
- Add info icons next to monthly and yearly total costs - Show breakdown of each active subscription's contribution - Display calculation method (e.g., '年费 ÷ 12' or '月费 × 12') - Include billing frequency badges for each subscription - Show total at bottom of breakdown
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.