Skip to content

January 1 2025, Slovakia VAT rate 20% -> 23% !#76

Open
dgtlmoon wants to merge 1 commit into
iconfinder:masterfrom
dgtlmoon:slovakia-23
Open

January 1 2025, Slovakia VAT rate 20% -> 23% !#76
dgtlmoon wants to merge 1 commit into
iconfinder:masterfrom
dgtlmoon:slovakia-23

Conversation

@dgtlmoon
Copy link
Copy Markdown

@dgtlmoon dgtlmoon commented Feb 10, 2025

@dgtlmoon dgtlmoon changed the title Slovakia 20% -> 23% Slovakia VAT rate 20% -> 23% Feb 10, 2025
@dgtlmoon dgtlmoon changed the title Slovakia VAT rate 20% -> 23% January 1 2025, Slovakia VAT rate 20% -> 23% ! Feb 10, 2025
@JasterTDC JasterTDC self-assigned this Feb 10, 2025
@dgtlmoon
Copy link
Copy Markdown
Author

https://github.com/airgproducts/eurovat and then call .update() is a far better way todo this

You should replace the vat_rate actual info with a call to this library instead, its going to make it a lot nicer for everyone

e
import eurovat
from eurovat.registry import VatRuleRegistry


def update_vat_data_if_needed(max_age_hours=24, verbose=True):
    """
    Update VAT data if cache doesn't exist or is older than max_age_hours.

    Args:
        max_age_hours: Maximum age of cache in hours before updating (default: 24)
        verbose: Print status messages (default: True)

    Returns:
        bool: True if update was performed, False if cache was fresh
    """
    registry = VatRuleRegistry()

    # Check if cache file exists
    if not os.path.exists(registry.cache.filename):
        if verbose:
            print(f'VAT cache file does not exist, updating from EU database...')
        registry.update()
        if verbose:
            print(f'✓ VAT data updated successfully')
        return True

    # Check cache age
    cache_age_seconds = time.time() - registry.cache_last_update
    cache_age_hours = cache_age_seconds / 3600

    if cache_age_hours > max_age_hours:
        if verbose:
            last_update = datetime.fromtimestamp(registry.cache_last_update)
            print(f'VAT cache is {cache_age_hours:.1f} hours old (last updated: {last_update})')
            print(f'Threshold: {max_age_hours} hours. Updating from EU database...')
        registry.update()
        if verbose:
            print(f'✓ VAT data updated successfully')
        return True
    else:
        if verbose:
            last_update = datetime.fromtimestamp(registry.cache_last_update)
            print(f'VAT cache is fresh ({cache_age_hours:.1f} hours old, last updated: {last_update})')
        return False


def get_vat_rate_with_auto_update(country_code, max_cache_age_hours=24):
    """
    Get VAT rate for a country, automatically updating cache if needed.

    Args:
        country_code: ISO 3166-1 alpha-2 country code (e.g., 'EE', 'CZ')
        max_cache_age_hours: Maximum cache age before auto-update (default: 24)

    Returns:
        VatRate object with rate, reduced flag, description, etc.
    """
    update_vat_data_if_needed(max_age_hours=max_cache_age_hours, verbose=False)
    return eurovat.get_vat_rate(country_code)


@carltongibson
Copy link
Copy Markdown

@dgtlmoon Please stop spamming every issue. Yes, we get it. You have an alternative package. 📦

@dgtlmoon
Copy link
Copy Markdown
Author

@carltongibson if you have time to reply to my comments, maybe you will consider just releasing a new version? since the last update of this package is a few "VAT Changes" behind already see #75

@carltongibson
Copy link
Copy Markdown

I;m not a maintainer here. I'm a user that as to read your noise.

Stop spamming!

@dgtlmoon
Copy link
Copy Markdown
Author

@carltongibson YOU stop spamming :)

@carltongibson
Copy link
Copy Markdown

You've left identical comments on something like 20 issues. Dude. Seriously.

@dgtlmoon
Copy link
Copy Markdown
Author

@carltongibson "something like " or like, like? like.. i mean like like like... i think it was 2-3 and they were slightly different comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants