from pyspark.sql.types import *

xero_bronze = StructType([
    StructField("type", StringType(), True),
    StructField("contact", StructType([
        StructField("contact_id", StringType(), True),
        StructField("merged_to_contact_id", StringType(), True),
        StructField("contact_number", StringType(), True),
        StructField("account_number", StringType(), True),
        StructField("contact_status", StringType(), True),
        StructField("name", StringType(), True),
        StructField("first_name", StringType(), True),
        StructField("last_name", StringType(), True),
        StructField("company_number", StringType(), True),
        StructField("email_address", StringType(), True),
        StructField("contact_persons", ArrayType(StringType()), True),
        StructField("bank_account_details", StringType(), True),
        StructField("tax_number", StringType(), True),
        StructField("accounts_receivable_tax_type", StringType(), True),
        StructField("accounts_payable_tax_type", StringType(), True),
        StructField("addresses", ArrayType(StringType()), True),
        StructField("phones", ArrayType(StringType()), True),
        StructField("is_supplier", BooleanType(), True),
        StructField("is_customer", BooleanType(), True),
        StructField("sales_default_line_amount_type", StringType(), True),
        StructField("purchases_default_line_amount_type", StringType(), True),
        StructField("default_currency", StringType(), True),
        StructField("xero_network_key", StringType(), True),
        StructField("sales_default_account_code", StringType(), True),
        StructField("purchases_default_account_code", StringType(), True),
        StructField("sales_tracking_categories", StringType(), True),
        StructField("purchases_tracking_categories", StringType(), True),
        StructField("tracking_category_name", StringType(), True),
        StructField("tracking_category_option", StringType(), True),
        StructField("payment_terms", StringType(), True),
        StructField("updated_date_utc", StringType(), True),
        StructField("contact_groups", ArrayType(StringType()), True),
        StructField("website", StringType(), True),
        StructField("branding_theme", StringType(), True),
        StructField("batch_payments", StringType(), True),
        StructField("discount", StringType(), True),
        StructField("balances", StringType(), True),
        StructField("attachments", StringType(), True),
        StructField("has_attachments", BooleanType(), True),
        StructField("validation_errors", StringType(), True),
        StructField("has_validation_errors", BooleanType(), True),
        StructField("status_attribute_string", StringType(), True)
    ]), True),
    StructField("line_items", ArrayType(StructType([
        StructField("line_item_id", StringType(), True),
        StructField("description", StringType(), True),
        StructField("quantity", DecimalType(10, 4), True),
        StructField("unit_amount", DecimalType(10, 2), True),
        StructField("item_code", StringType(), True),
        StructField("account_code", StringType(), True),
        StructField("account_id", StringType(), True),
        StructField("tax_type", StringType(), True),
        StructField("tax_amount", DecimalType(10, 2), True),
        StructField("item", StringType(), True),
        StructField("line_amount", DecimalType(10, 2), True),
        StructField("tracking", ArrayType(StructType([
            StructField("tracking_category_id", StringType(), True),
            StructField("tracking_option_id", StringType(), True),
            StructField("name", StringType(), True),
            StructField("option", StringType(), True)
        ])), True),
        StructField("discount_rate", DecimalType(5, 2), True),
        StructField("discount_amount", DecimalType(10, 2), True),
        StructField("repeating_invoice_id", StringType(), True),
        StructField("taxability", StringType(), True),
        StructField("sales_tax_code_id", StringType(), True),
        StructField("tax_breakdown", StringType(), True)
    ])), True),
    StructField("date", DateType(), True),
    StructField("due_date", DateType(), True),
    StructField("line_amount_types", StringType(), True),
    StructField("invoice_number", StringType(), True),
    StructField("reference", StringType(), True),
    StructField("branding_theme_id", StringType(), True),
    StructField("url", StringType(), True),
    StructField("currency_code", StringType(), True),
    StructField("currency_rate", DecimalType(12, 10), True),
    StructField("status", StringType(), True),
    StructField("sent_to_contact", BooleanType(), True),
    StructField("expected_payment_date", StringType(), True),
    StructField("planned_payment_date", StringType(), True),
    StructField("cis_deduction", DecimalType(5, 2), True),
    StructField("cis_rate", DecimalType(5, 2), True),
    StructField("sub_total", DecimalType(10, 2), True),
    StructField("total_tax", DecimalType(10, 2), True),
    StructField("total", DecimalType(10, 2), True),
    StructField("total_discount", DecimalType(10, 2), True),
    StructField("invoice_id", StringType(), True),
    StructField("repeating_invoice_id", StringType(), True),
    StructField("has_attachments", BooleanType(), True),
    StructField("is_discounted", BooleanType(), True),
    StructField("payments", ArrayType(StructType([
        StructField("invoice", StringType(), True),
        StructField("credit_note", StringType(), True),
        StructField("prepayment", StringType(), True),
        StructField("overpayment", StringType(), True),
        StructField("invoice_number", StringType(), True),
        StructField("credit_note_number", StringType(), True),
        StructField("batch_payment", StringType(), True),
        StructField("account", StringType(), True),
        StructField("code", StringType(), True),
        StructField("date", DateType(), True),
        StructField("currency_rate", DecimalType(12, 10), True),
        StructField("amount", DecimalType(10, 2), True),
        StructField("bank_amount", DecimalType(10, 2), True),
        StructField("reference", StringType(), True),
        StructField("is_reconciled", BooleanType(), True),
        StructField("status", StringType(), True),
        StructField("payment_type", StringType(), True),
        StructField("updated_date_utc", StringType(), True),
        StructField("payment_id", StringType(), True),
        StructField("batch_payment_id", StringType(), True),
        StructField("bank_account_number", StringType(), True),
        StructField("particulars", StringType(), True),
        StructField("details", StringType(), True),
        StructField("has_account", BooleanType(), True),
        StructField("has_validation_errors", BooleanType(), True),
        StructField("status_attribute_string", StringType(), True),
        StructField("validation_errors", StringType(), True),
        StructField("warnings", StringType(), True)
    ])), True),
    StructField("prepayments", ArrayType(StringType()), True),
    StructField("overpayments", ArrayType(StringType()), True),
    StructField("amount_due", DecimalType(10, 2), True),
    StructField("amount_paid", DecimalType(10, 2), True),
    StructField("fully_paid_on_date", DateType(), True),
    StructField("amount_credited", DecimalType(10, 2), True),
    StructField("updated_date_utc", TimestampType(), True),
    StructField("credit_notes", ArrayType(StringType()), True),
    StructField("attachments", StringType(), True),
    StructField("has_errors", BooleanType(), True),
    StructField("status_attribute_string", StringType(), True),
    StructField("validation_errors", StringType(), True),
    StructField("warnings", StringType(), True),
    StructField("invoice_addresses", ArrayType(StringType()), True)
])