Skip to main content

FinancialEvent Structure Field Mismatches

This document outlines the mismatches between the FinancialEvent struct as defined in the codebase and how it was referenced in our tests.

Issue Summary

When implementing tests for the financial calculation logic, we encountered compile errors due to field name mismatches in the FinancialEvent struct. The tests were referencing field names that don't match the actual field names in the struct definition.

Field Comparison Table

Incorrect Field (Used in Tests)Correct Field (In Struct Definition)
end_daterecurrence_end_date
milestone_categoryaffected_category
milestone_multipliermilestone_effect

Code Snippets

Current FinancialEvent Structure:

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct FinancialEvent {
pub id: String,
pub name: String,
pub description: String,
pub event_type: EventType,
pub amount: f64,
pub date: NaiveDate,
pub recurrence: RecurrenceType,
pub recurrence_end_date: Option<NaiveDate>,
// New fields for enhanced financial modeling
pub category: Option<String>, // Category tag for expense classification
pub growth_rate: Option<f64>, // Monthly growth rate (decimal: 0.05 = 5%)
pub max_amount: Option<f64>, // Maximum cap for growing expenses
pub is_milestone: bool, // Flag for milestone events
pub milestone_effect: Option<f64>, // Multiplier effect for milestones
pub affected_category: Option<String>, // Category affected by milestone
}

Examples of Test Errors:

error[E0560]: struct `financial_event::FinancialEvent` has no field named `end_date`
--> src/models/financial_scenario.rs:798:13
|
798 | end_date: Some(end_date),
| ^^^^^^^^ `financial_event::FinancialEvent` does not have this field
|
= note: available fields are: `recurrence_end_date`, `milestone_effect`, `affected_category`
error[E0560]: struct `financial_event::FinancialEvent` has no field named `milestone_category`
--> src/models/financial_scenario.rs:803:13
|
803 | milestone_category: None,
| ^^^^^^^^^^^^^^^^^^ `financial_event::FinancialEvent` does not have this field
|
= note: available fields are: `recurrence_end_date`, `milestone_effect`, `affected_category`

Resolution Plan

To fix the issue:

  1. Update all test functions to use the correct field names
  2. Check factory methods like new_milestone to ensure proper field assignment
  3. Update any relevant factory methods if needed
  4. Verify that there are no other field name inconsistencies in the codebase

This will ensure proper test coverage of all FinancialEvent functionality.