mirror of
https://github.com/Komediruzecki/token-circles.git
synced 2026-10-20 09:46:43 +02:00
Added 18 E2E test specifications following EARS format for all backend modules: New Specs Created: - tags.spec.md (56 tests) - Tag CRUD, hierarchy, filtering, grouping - receipts.spec.md (57 tests) - Receipts, OCR, splitting, sharing, export - recurring.spec.md (57 tests) - Recurrence patterns, scheduling, timezone - reports.spec.md (62 tests) - Custom reports, export, scheduling, comparison - calculator.spec.md (54 tests) - Financial calculators, conversions, schedules Existing Specs Reviewed: - All existing backend specs validated and organized - Each spec includes Must/Should priorities, test types, steps, validations - Consistent formatting across all 18 specifications Each spec covers: - CRUD operations - Data validation - Performance testing - Error handling - Integration tests - Cross-user data isolation - Acceptance criteria Format: EARS-compliant with test IDs, priorities, types (Positive/Negative/Integration/Performance), detailed steps, validations, and expected results.
7.2 KiB
7.2 KiB
Loans Specification
Module: Loans Version: 2.0 Status: Active Priority: Must
1. Overview
Loans represent debts with interest calculations, payments, and amortization tracking.
2. Functional Requirements
2.1. CRUD Operations
| ID | Description | Type |
|---|---|---|
| L-001 | Get all loans must return list of loans | Must |
| L-002 | Get single loan by ID must return loan data | Must |
| L-003 | Create loan must validate required fields | Must |
| L-004 | Create loan must return newly created loan | Must |
| L-005 | Update loan must allow updating loan data | Must |
| L-006 | Update loan must return updated loan | Must |
| L-007 | Delete loan must remove loan | Must |
| L-008 | Calculate loan amortization must be supported | Must |
2.2. Loan Data
| ID | Description | Type |
|---|---|---|
| L-010 | Loan must have required fields (name, principal, annualRate) | Must |
| L-011 | Loan must have principal amount | Must |
| L-012 | Loan must have annual interest rate | Must |
| L-013 | Loan must have monthly payment amount | Must |
| L-014 | Loan must have remaining balance | Must |
| L-015 | Loan must have total payments made | Must |
| L-016 | Loan must have total payments remaining | Must |
| L-017 | Loan must have term in months | Must |
| L-018 | Loan must have account for payment | Must |
| L-019 | Loan must have icon | Should |
| L-020 | Loan must support additional payments (prepayments) | Should |
| L-021 | Loan must support interest rate changes | Should |
2.3. Loan Calculation
| ID | Description | Type |
|---|---|---|
| L-030 | Calculate monthly payment must use standard formula | Must |
| L-031 | Calculate amortization schedule must be supported | Must |
| L-032 | Prepayments must reduce principal and interest | Should |
| L-033 | Rate changes must update calculations | Should |
2.4. Loan History
| ID | Description | Type |
|---|---|---|
| L-040 | Loan must track payment history | Must |
| L-041 | Payment history must show date, amount, principal, interest | Must |
| L-042 | Amortization table must be available | Must |
| L-043 | Prepayments must be tracked | Should |
| L-044 | Rate changes must be tracked | Should |
2.5. Loan Management
| ID | Description | Type |
|---|---|---|
| L-050 | Add payment must update loan status | Must |
| L-051 | Add prepayment must reduce balance | Should |
| L-052 | Update rate must recalculate future payments | Should |
3. Non-Functional Requirements
3.1. Performance
| ID | Description | Target |
|---|---|---|
| NFR-001 | Get all loans must complete within 100ms | 100ms |
| NFR-002 | Calculate loan must complete within 100ms | 100ms |
| NFR-003 | Create loan must complete within 50ms | 50ms |
3.2. Data Consistency
| ID | Description | Requirement |
|---|---|---|
| NFR-003 | Loan calculations must be accurate | Always |
| NFR-004 | Payment history must be accurate | Always |
3.3. Security
| ID | Description | Requirement |
|---|---|---|
| NFR-005 | Loan access must be scoped to user | Always |
4. API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/api/loans |
GET | Get all loans |
/api/loans |
POST | Create new loan |
/api/loans/:id |
GET | Get single loan |
/api/loans/:id |
PUT | Update loan |
/api/loans/:id |
DELETE | Delete loan |
/api/loans/:id/calculate |
POST | Calculate loan amortization |
/api/loans/:id/prepayments |
POST | Add prepayment |
/api/loans/:id/prepayments/:prepayId |
DELETE | Remove prepayment |
/api/loans/:id/rates |
POST | Add interest rate change |
/api/loans/:id/rates/:rateId |
DELETE | Remove interest rate change |
5. Data Models
Loan:
id: string- Loan UUIDname: string- Loan nameprincipal: number- Loan principal amountannualRate: number- Annual interest rate (percentage)monthlyPayment: number- Scheduled monthly paymentremainingBalance: number- Remaining principal balancetotalPaymentsMade: number- Number of payments madetotalPaymentsRemaining: number- Number of payments remainingtotalPayments: number- Total payments for loanaccount: string- Account for paymentsicon: string- Loan icon (optional)notes: string- Loan notes (optional)createdAt: ISO8601- Creation timestampupdatedAt: ISO8601- Last update timestamp
LoanPayment:
id: string- Payment UUIDloanId: string- Associated loan IDdate: ISO8601- Payment dateamount: number- Payment amountprincipal: number- Principal portioninterest: number- Interest portion
LoanAmortization:
month: number- Payment numberdate: ISO8601- Scheduled datepayment: number- Payment amountprincipal: number- Principal reductioninterest: number- Interest chargedbalance: number- Remaining balance
Prepayment:
id: string- Prepayment UUIDloanId: string- Associated loan IDdate: ISO8601- Prepayment dateamount: number- Prepayment amountprincipal: number- Principal applied
RateChange:
id: string- Rate change UUIDloanId: string- Associated loan IDeffectiveDate: ISO8601- Effective datenewRate: number- New interest rate
6. User Flows
6.1. Create Loan
- User opens Loans page
- User clicks "Add Loan" button
- Modal displays loan creation form
- User enters required fields (name, principal, annual rate, monthly payment, term in months)
- User selects optional fields (account, icon, notes)
- System validates input
- System calculates amortization schedule
- System creates loan
- System returns loan with confirmation
6.2. View Loan Amortization
- User selects loan
- User clicks "Amortization" tab
- System displays amortization table
- System shows monthly breakdown
6.3. Add Loan Payment
- User opens loan details
- User clicks "Add Payment" button
- User enters payment amount and date
- User confirms payment
- System updates loan
- System recalculates remaining balance
- System returns updated loan
6.4. Delete Loan
- User selects loan to delete
- User confirms deletion
- System deletes loan
- System returns success confirmation
7. Exceptional Conditions
| Condition | Behavior |
|---|---|
| Loan name already exists | Return 400 with error message |
| Loan ID not found | Return 404 Not Found |
| Principal cannot be negative | Return 400 with error message |
| Interest rate invalid | Return 400 with error message |
| Payment amount exceeds balance | Return 400 with error message |
8. Open/Closed Questions
- Should loans support refinancing?
- Should loans support balloon payments?
- Should loans support payment skipping?
- Should loans support multiple interest rate types (fixed, variable)?
9. Acceptance Criteria
- User can create multiple loans
- User can view all loans
- User can update loan details
- User can delete loans
- Loan amortization is calculated correctly
- Payment history is accurate
- Prepayments reduce balance correctly
- Rate changes are handled correctly
- Loans are scoped to user
- Loan calculations are accurate