Add FVSCHEDULE financial function#73
Conversation
Implements FVSCHEDULE with schedule parsing and validation, wires it into function dispatch and static analysis, and adds dedicated tests and docs. Includes a parser fallback so FVSCHEDULE formulas parse without locale data.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| result *= 1.0 + rate; | ||
| } | ||
| if result.is_infinite() { | ||
| return CalcResult::new_error(Error::DIV, cell, "Division by 0".to_string()); |
There was a problem hiding this comment.
Wrong error type for infinite result in FVSCHEDULE
Low Severity
The fn_fvschedule function returns Error::DIV with message "Division by 0" when result.is_infinite(), but FVSCHEDULE only performs multiplication operations. An infinite result from multiplication is an overflow, not division by zero. Other functions in the codebase (such as in bessel.rs and complex.rs) correctly use Error::NUM for infinite/NaN results from non-division operations.
| kind: Function::Fvschedule, | ||
| args, | ||
| }; | ||
| } |
There was a problem hiding this comment.
Hardcoded FVSCHEDULE bypasses locale data pattern
Low Severity
FVSCHEDULE has a hardcoded parser fallback that bypasses the standard language.functions.lookup() pattern used by all other functions. This check also redundantly calls name.trim_start_matches("_xlfn.") which was already called on line 783. The proper fix would be to add fvschedule to the language data structure in base/src/language/mod.rs.


Summary
FVSCHEDULEwith schedule parsing and validationFVSCHEDULEparses without locale dataTest plan
cargo test --package ironcalc_base fvscheduleNote
Medium Risk
Adds a new financial function and wires it through parsing, static analysis, and function dispatch, which can affect formula interpretation and evaluation in edge cases. Logic is straightforward and covered by targeted tests, keeping overall risk moderate.
Overview
Implements Excel-compatible
FVSCHEDULE(principal, schedule)end-to-end: evaluation compoundsprincipalacross a vector/range of rates with validation (rate > -1) and error handling for invalid/overflow results.Wires
FVSCHEDULEinto the engine’s function enum/dispatch and static analysis (expects a scalar + vector), and adds a parser fallback so_xlfn.FVSCHEDULEis recognized even without locale/language function metadata.Adds unit tests for computation, argument-count errors, non-numeric schedule handling, and rate edge cases, and updates docs to mark
FVSCHEDULEas available with a stub documentation page.Written by Cursor Bugbot for commit aa964af. Configure here.