fix: Prevent validation from running during stats command

- Remove validation logic from calculate_tax_yearly_average()
- Add _auto_download_missing_monthly_data() for silent auto-download
- Fix duplicate validation code in CLI that caused unintended execution
- Separate validation from calculation: --stats only calculates, --validate only validates
- Maintain auto-download functionality for missing data in calculations
- Ensure stats command shows only calculation results without validation output

Root Cause: Validation code was embedded in tax calculation function and duplicated in CLI
Solution: Extract validation from calculation, keep auto-download separate
Result: --stats shows clean output, --validate provides full analysis

Testing:  Stats command clean,  Validation command works,  No type errors
This commit is contained in:
kdusek
2026-01-12 23:29:13 +01:00
parent 7ce88e6e4a
commit 8be7f745b1
2 changed files with 31 additions and 55 deletions

View File

@@ -556,36 +556,6 @@ def main():
print(
f"'Jednotný kurz' pro daňové účely podle metodiky ČNB pro {currency_code} za rok {year} nebyl nalezen."
)
debug_print("HIT: Validation condition")
print("VALIDATION: Condition matched!")
# Validation command
base_threshold = args.change_threshold
adaptive = not args.no_adaptive
if args.currency:
# Validate specific currency
debug_print(f"Validuji data pro měnu {args.currency}...")
results = data_validator.validate_currency_data(
args.currency, args.year, base_threshold, adaptive
)
if args.json:
output_json(results)
else:
text_output = data_validator.format_validation_text(results)
print(text_output)
else:
# Validate all currencies
debug_print("Validuji data pro všechny měny...")
results = data_validator.validate_all_currencies(
args.year, base_threshold, adaptive
)
if args.json:
output_json(results)
else:
text_output = data_validator.format_validation_text(results)
print(text_output)
elif args.currency and not args.get_rate:
# Pokud je zadána měna, ale není zadán --get-rate, vytiskneme poslední dostupný kurz
# Toto musí být až po --stats, jinak by se --stats nikdy nevykonalo