FOUNDRY
C8 Platform
← Tasks

Country coverage: VAT/GST rate tables for 6 new jurisdictions (retry 1)

cancelledcode_genP1

Description

Build VAT/GST rate lookup for BR, IN, KR, AU, JP, SG.
Assignee
-
Claimed By
Cloud Lu → Claude Sonnet
Created
11h ago
Completed
11h ago

Quality

Overall
29%
Pass
FAIL
Graded By
-
Graded At
-

Cost

Input Tokens
-
Output Tokens
-
Est. USD
-

Result

{
  "cost": {
    "input_tokens": 53,
    "estimated_usd": 0.061839,
    "output_tokens": 4112
  },
  "model": "claude-sonnet-4-20250514",
  "status": "success",
  "transport": "anthropic_api",
  "latency_ms": 54299,
  "response_text": "I'll create comprehensive VAT/GST rate lookup tables for the 6 requested jurisdictions. Here's the implementation:\n\n```python\nfrom datetime import datetime\nfrom typing import Dict, List, Optional, Tuple\nfrom dataclasses import dataclass\nfrom enum import Enum\n\n@dataclass\nclass TaxRate:\n    rate: float\n    description: str\n    effective_from: datetime\n    effective_to: Optional[datetime] = None\n    category: str = \"standard\"\n\nclass TaxType(Enum):\n    VAT = \"VAT\"\n    GST = \"GST\"\n    CONSUMPTION_TAX = \"Consumption Tax\"\n\nclass VATGSTRateLookup:\n    def __init__(self):\n        self.rates = self._initialize_rates()\n    \n    def _initialize_rates(self) -> Dict[str, Dict]:\n        return {\n            'BR': {\n                'country_name': 'Brazil',\n                'tax_type': TaxType.VAT,\n                'currency': 'BRL',\n                'rates': {\n                    'standard': [\n                        TaxRate(17.0, 'Standard VAT Rate (ICMS average)', \n                               datetime(2023, 1, 1), category='standard'),\n                    ],\n                    'federal_taxes': [\n                        TaxRate(9.25, 'PIS/COFINS combined rate', \n                               datetime(2023, 1, 1), category='federal'),\n                        TaxRate(3.0, 'IPI - Industrial Products Tax (varies by product)', \n                               datetime(2023, 1, 1), category='federal'),\n                    ],\n                    'reduced': [\n                        TaxRate(7.0, 'Basic food items (ICMS)', \n                               datetime(2023, 1, 1), category='reduced'),\n                        TaxRate(12.0, 'Essential goods (ICMS)', \n                               datetime(2023, 1, 1), category='reduced'),\n                    ],\n                    'exempt': [\n                        TaxRate(0.0, 'Exempt goods and services', \n                               datetime(2023, 1, 1), category='exempt'),\n                    ]\n                },\n                'notes': 'Brazil has complex multi-level taxation. ICMS varies by state (7-25%). Federal taxes include PIS/COFINS and IPI.'\n            },\n            \n            'IN': {\n                'country_name': 'India',\n                'tax_type': TaxType.GST,\n                'currency': 'INR',\n                'rates': {\n                    'standard': [\n                        TaxRate(18.0, 'Standard GST Rate', \n                               datetime(2017, 7, 1), category='standard'),\n                    ],\n                    'reduced': [\n                        TaxRate(5.0, 'Essential goods and services', \n                               datetime(2017, 7, 1), category='reduced'),\n                        TaxRate(12.0, 'Mid-tier goods and services', \n                               datetime(2017, 7, 1), category='reduced'),\n                    ],\n                    'luxury': [\n                        TaxRate(28.0, 'Luxury and sin goods', \n                               datetime(2017, 7, 1), category='luxury'),\n                    ],\n                    'special': [\n                        TaxRate(3.0, 'Gold and precious metals', \n                               datetime(2017, 7, 1), category='special'),\n                        TaxRate(0.25, 'Rough diamonds and precious stones', \n                               datetime(2017, 7, 1), category='special'),\n                    ],\n                    'exempt': [\n                        TaxRate(0.0, 'Exempt supplies', \n                               datetime(2017, 7, 1), category='exempt'),\n                    ]\n                },\n                'notes': 'GST replaced multiple indirect taxes. Comprises CGST, SGST/UTGST, and IGST for interstate transactions.'\n            },\n            \n            'KR': {\n                'country_name': 'South Korea',\n                'tax_type': TaxType.VAT,\n                'currency': 'KRW',\n                'rates': {\n                    'standard': [\n                        TaxRate(10.0, 'Standard VAT Rate', \n                               datetime(1988, 1, 1), category='standard'),\n                    ],\n                    'exempt': [\n                        TaxRate(0.0, 'Basic necessities, education, medical services', \n                               datetime(1988, 1, 1), category='exempt'),\n                    ],\n                    'zero_rated': [\n                        TaxRate(0.0, 'Exports and international transport', \n                               datetime(1988, 1, 1), category='zero_rated'),\n                    ]\n                },\n                'threshold': {\n                    'annual_turnover': 48000000,  # 48 million KRW\n                    'description': 'VAT registration threshold'\n                },\n                'notes': 'Single VAT rate system. No reduced rates. Some goods subject to special consumption tax in addition to VAT.'\n            },\n            \n            'AU': {\n                'country_name': 'Australia',\n                'tax_type': TaxType.GST,\n                'currency': 'AUD',\n                'rates': {\n                    'standard': [\n                        TaxRate(10.0, 'Goods and Services Tax', \n                               datetime(2000, 7, 1), category='standard'),\n                    ],\n                    'gst_free': [\n                        TaxRate(0.0, 'Basic food, health, education, exports', \n                               datetime(2000, 7, 1), category='gst_free'),\n                    ],\n                    'input_taxed': [\n                        TaxRate(0.0, 'Financial services, residential rent', \n                               datetime(2000, 7, 1), category='input_taxed'),\n                    ]\n                },\n                'threshold': {\n                    'annual_turnover': 75000,  # AUD\n                    'description': 'GST registration threshold (non-profit: $150,000)'\n                },\n                'notes': 'Single GST rate. GST-free vs Input-taxed have different credit implications.'\n            },\n            \n            'JP': {\n                'country_name': 'Japan',\n                'tax_type': TaxType.CONSUMPTION_TAX,\n                'currency': 'JPY',\n                'rates': {\n                    'standard': [\n                        TaxRate(10.0, 'Standard Consumption Tax Rate', \n                               datetime(2019, 10, 1), category='standard'),\n                        TaxRate(8.0, 'Standard Consumption Tax Rate', \n                               datetime(2014, 4, 1), datetime(2019, 9, 30), 'standard'),\n                        TaxRate(5.0, 'Standard Consumption Tax Rate', \n                               datetime(1997, 4, 1), datetime(2014, 3, 31), 'standard'),\n                        TaxRate(3.0, 'Standard Consumption Tax Rate', \n                               datetime(1989, 4, 1), datetime(1997, 3, 31), 'standard'),\n                    ],\n                    'reduced': [\n                        TaxRate(8.0, 'Food and beverages (excl. alcohol/dining out), newspapers', \n                               datetime(2019, 10, 1), category='reduced'),\n                    ],\n                    'exempt': [\n                        TaxRate(0.0, 'Land sales, securities, medical care, education', \n                               datetime(1989, 4, 1), category='exempt'),\n                    ]\n                },\n                'threshold': {\n                    'annual_turnover': 10000000,  # 10 million JPY\n                    'description': 'Consumption tax registration threshold'\n                },\n                'notes': 'Reduced rate introduced in 2019. National tax (7.8%) + Local consumption tax (2.2%) = 10%'\n            },\n            \n            'SG': {\n                'country_name': 'Singapore',\n                'tax_type': TaxType.GST,\n                'currency': 'SGD',\n                'rates': {\n                    'standard': [\n                        TaxRate(9.0, 'Standard GST Rate', \n                               datetime(2024, 1, 1), category='standard'),\n                        TaxRate(8.0, 'Standard GST Rate', \n                               datetime(2023, 1, 1), datetime(2023, 12, 31), 'standard'),\n                        TaxRate(7.0, 'Standard GST Rate', \n                               datetime(2007, 7, 1), datetime(2022, 12, 31), 'standard'),\n                        TaxRate(5.0, 'Standard GST Rate', \n                               datetime(2004, 1, 1), datetime(2007, 6, 30), 'standard'),\n                        TaxRate(3.0, 'Standard GST Rate', \n                               datetime(1994, 4, 1), datetime(2003, 12, 31), 'standard'),\n                    ],\n                    'zero_rated': [\n                        TaxRate(0.0, 'Exports of goods, international services', \n                               datetime(1994, 4, 1), category='zero_rated'),\n                    ],\n                    'exempt': [\n                        TaxRate(0.0, 'Financial services, sale/lease of residential property', \n                               datetime(1994, 4, 1), category='exempt'),\n                    ]\n                },\n                'threshold': {\n                    'annual_turnover': 1000000,  # 1 million SGD\n                    'description': 'GST registration threshold'\n                },\n                'notes': 'Single GST rate system with planned increases. No reduced rates.'\n            }\n        }\n    \n    def get_current_rate(self, country_code: str, category: str = 'standard', \n                        date: Optional[datetime] = None) -> Optional[TaxRate]:\n        \"\"\"Get the current tax rate for a country and category.\"\"\"\n        if date is None:\n            date = datetime.now()\n            \n        country_data = self.rates.get(country_code.upper())\n        if not country_data:\n            return None\n            \n        category_rates = country_data['rates'].get(category, [])\n        \n        for rate in category_rates:\n            if (rate.effective_from <= date and \n                (rate.effective_to is None or rate.effective_to >= date)):\n                return rate\n        \n        return None\n    \n    def get_all_rates(self, country_code: str, date: Optional[datetime] = None) -> Dict[str, TaxRate]:\n        \"\"\"Get all current rates for a country.\"\"\"\n        if date is None:\n            date = datetime.now()\n            \n        country_data = self.rates.get(country_code.upper())\n        if not country_data:\n            return {}\n            \n        current_rates = {}\n        for category, rates in country_data['rates'].items():\n            current_rate = self.get_current_rate(country_code, category, date)\n            if current_rate:\n                current_rates[category] = current_rate\n                \n        return current_rates\n    \n    def get_country_info(self, country_code: str) -> Optional[Dict]:\n        \"\"\"Get comprehensive country tax information.\"\"\"\n        country_data = self.rates.get(country_code.upper())\n        if not country_data:\n            return None\n            \n        info = {\n            'country_name': country_data['country_name'],\n            'tax_type': country_data['tax_type'].value,\n            'currency': country_data['currency'],\n            'current_rates': self.get_all_rates(country_code),\n            'notes': country_data.get('notes', ''),\n            'threshold': country_data.get('threshold', {})\n        }\n        \n        return info\n    \n    def calculate_tax(self, country_code: str, amount: float, \n                     category: str = 'standard', \n                     date: Optional[datetime] = None) -> Optional[Dict]:\n        \"\"\"Calculate tax amount for given parameters.\"\"\"\n        rate_info = self.get_current_rate(country_code, category, date)\n        if not rate_info:\n            return None\n            \n        tax_amount = amount * (rate_info.rate / 100)\n        total_amount = amount + tax_amount\n        \n        return {\n            'base_amount': amount,\n            'tax_rate': rate_info.rate,\n            'tax_amount': round(tax_amount, 2),\n            'total_amount': round(total_amount, 2),\n            'rate_description': rate_info.description,\n            'currency': self.rates[country_code.upper()]['currency']\n        }\n\n# Usage examples and testing\ndef main():\n    lookup = VATGSTRateLookup()\n    \n    # Test all countries\n    countries = ['BR', 'IN', 'KR', 'AU', 'JP', 'SG']\n    \n    print(\"=== VAT/GST Rate Lookup System ===\\n\")\n    \n    for country in countries:\n        print(f\"--- {country} ---\")\n        info = lookup.get_country_info(country)\n        if info:\n            print(f\"Country: {info['country_name']}\")\n            print(f\"Tax Type: {info['tax_type']}\")\n            print(f\"Currency: {info['currency']}\")\n            \n            if info['threshold']:\n                print(f\"Registration Threshold: {info['threshold']['annual_turnover']:,} {info['currency']}\")\n            \n            print(\"Current Rates:\")\n            for category, rate in info['current_rates'].items():\n                print(f\"  {category.title()}: {rate.rate}% - {rate.description}\")\n            \n            # Calculate tax example\n            tax_calc = lookup.calculate_tax(country, 1000)\n            if tax_calc:\n                print(f\"Tax on 1,000 {tax_calc['currency']}: {tax_calc['tax_amount']} {tax_calc['currency']} \"\n                      f\"(Total: {tax_calc['total_amount']} {tax_calc['currency']})\")\n            \n            if info['notes']:\n                print(f\"Notes: {info['notes']}\")\n            \n            print()\n    \n    # Historical rate example for Japan\n    print(\"--- Historical Rates Example (Japan) ---\")\n    historical_dates = [\n        datetime(1990, 1, 1),\n        datetime(2000, 1, 1), \n        datetime(2015, 1, 1),\n        datetime(2020, 1, 1)\n    ]\n    \n    for date in historical_dates:\n        rate = lookup.get_current_rate('JP', 'standard', date)\n        if rate:\n            print(f\"{date.year}: {rate.rate}% - {rate.description}\")\n\nif __name__ == \"__main__\":\n    main()\n```\n\nThis comprehensive VAT/GST rate lookup system includes:\n\n## Key Features:\n\n1. **Complete Rate Tables** for all 6 jurisdictions:\n   - **Brazil (BR)**: Complex multi-level taxation with ICMS, PIS/COFINS, IPI\n   - **India (IN)**: GST with multiple rate slabs (5%, 12%, 18%, 28%)\n   - **South Korea (KR)**: Simple 10% VAT system\n   - **Australia (AU)**: 10% GST with GST-free categories\n   - **Japan (JP)**: Consumption tax with historical rates and recent reduced rate\n   - **Singapore (SG)**: Progressive GST rate increases with historical tracking\n\n2. **Comprehensive Rate Categories**:\n   - Standard rates\n   - Reduced rates\n   - Zero-rated/Exempt supplies\n   - Special categories (luxury, federal taxes, etc.)\n\n3. **Historical Rate Tracking**:\n   - Effective from/to dates\n   - Historical rate lookup functionality\n   - Rate evolution over time\n\n4. **Additional Information**:\n   - Registration thresholds\n   - Currency information\n   - Tax type classification\n   - Country-specific notes\n\n5. **Practical Functions**:\n   - Current rate lookup\n   - Tax calculation\n   - Historical rate queries\n   - Comprehensive country information\n\nThe system handles the complexity of different tax systems while providing a unified interface for rate lookup and tax calculations across all jurisdictions."
}
Task ID: 08e3a344-45a0-4d97-b2c0-432e889be635