debt_optimizer.core package

class debt_optimizer.core.Config(config_path=None)[source]

Bases: object

Configuration manager for debt optimizer.

Parameters:

config_path (Path | None)

DEFAULT_CONFIG_PATHS = [PosixPath('/home/docs/.debt_optimizer'), PosixPath('debt_optimizer.yaml'), PosixPath('debt_optimizer.yml')]
DEFAULT_VALUES = {'auto_backup': True, 'bank_account_name': 'PECU Checking', 'compare_strategies': False, 'emergency_fund': 1000.0, 'extra_payment': 0.0, 'fuzzy_match_threshold': 80, 'input_file': 'default.xlsx', 'optimization_goal': 'minimize_interest', 'output_file': 'debt_analysis.xlsx', 'quicken_db_path': '/home/docs/Documents/Bryan.quicken/data', 'simple_report': False}
__init__(config_path=None)[source]

Initialize configuration.

Parameters:

config_path (Optional[Path]) – Path to config file. If None, searches default locations.

as_dict()[source]

Get configuration as dictionary.

Return type:

Dict[str, Any]

Returns:

Dictionary of all configuration values

classmethod create_default_config(path)[source]

Create a new configuration file with default values.

Parameters:

path (Path) – Path where to create the config file

Return type:

Config

Returns:

New Config instance

get(key, default=None)[source]

Get configuration value.

Parameters:
  • key (str) – Configuration key

  • default (Any) – Default value if key not found

Return type:

Any

Returns:

Configuration value or default

load_from_file(path)[source]

Load configuration from YAML file.

Parameters:

path (Path) – Path to YAML config file

Raises:
Return type:

None

save_to_file(path=None)[source]

Save current configuration to YAML file.

Parameters:

path (Optional[Path]) – Path to save config. If None, uses current config_path.

Raises:
Return type:

None

set(key, value)[source]

Set configuration value.

Parameters:
  • key (str) – Configuration key

  • value (Any) – Configuration value

Return type:

None

update(values)[source]

Update multiple configuration values.

Parameters:

values (Dict[str, Any]) – Dictionary of configuration values

Return type:

None

validate()[source]

Validate configuration values.

Return type:

Tuple[bool, List[str]]

Returns:

Tuple of (is_valid, list_of_errors)

class debt_optimizer.core.BalanceUpdater(db_path, fuzzy_threshold=80, bank_account_name='PECU Checking', auto_backup=True)[source]

Bases: object

Updates Excel workbook balances from Quicken database.

Parameters:
  • db_path (Path)

  • fuzzy_threshold (int)

  • bank_account_name (str)

  • auto_backup (bool)

__init__(db_path, fuzzy_threshold=80, bank_account_name='PECU Checking', auto_backup=True)[source]

Initialize balance updater.

Parameters:
  • db_path (Path) – Path to Quicken SQLite database

  • fuzzy_threshold (int) – Minimum score for fuzzy matches (0-100)

  • bank_account_name (str) – Name of checking account to use for bank balance

  • auto_backup (bool) – Whether to create backup before updating

backup_excel(xlsx_path)[source]

Create timestamped backup of Excel file.

Parameters:

xlsx_path (Path) – Path to Excel file

Return type:

Path

Returns:

Path to backup file

connect_db()[source]

Connect to Quicken database in read-only mode.

Return type:

Connection

Returns:

SQLite connection

load_quicken_balances()[source]

Load account balances from Quicken database.

Calculates balance as Quicken register shows it: - Prioritizes register balance (sum of all transactions dated today or earlier) - Falls back to ZONLINEBANKINGLEDGERBALANCEAMOUNT if no transactions exist - Includes ALL transactions (reconciled, cleared, and uncleared) dated today or earlier - Excludes only future-dated transactions

This matches Quicken’s register balance which includes all transaction statuses dated on or before today. Uses Apple Cocoa timestamp format (seconds since 2001-01-01).

Returns:

E501

Return type:

Tuple of (accounts_by_name, credit_card_names, checking_names, savings_names) # noqa

update_debts_sheet(ws, accounts_by_name, credit_card_names)[source]

Update debt balances in Debts sheet.

Parameters:
  • ws – openpyxl worksheet

  • accounts_by_name (Dict[str, Dict]) – Dictionary of account data by name

  • credit_card_names (List[str]) – List of credit card account names

Return type:

List[Dict]

Returns:

List of update records

update_settings_sheet(ws, accounts_by_name, checking_names)[source]

Update current bank balance in Settings sheet.

Parameters:
  • ws – openpyxl worksheet

  • accounts_by_name (Dict[str, Dict]) – Dictionary of account data by name

  • checking_names (List[str]) – List of checking account names

Return type:

Optional[Dict]

Returns:

Update record or None if not updated

update_workbook(xlsx_path, interactive=True)[source]

Update Excel workbook with balances from Quicken database.

Parameters:
  • xlsx_path (Path) – Path to Excel workbook

  • interactive (bool) – Whether to prompt for fuzzy matches

Return type:

Dict[str, Any]

Returns:

Dictionary with update summary

Raises:
exception debt_optimizer.core.BalanceUpdaterError[source]

Bases: Exception

Base exception for balance updater errors.

Submodules