{
   "$schema": "https://json-schema.org/draft/2020-12/schema",
   "$id": "https://api.thebigalice.com/schema/customs/simple_customs_declaration/v1.1/schema.json",
   "$defs": {
      "iso31661_alpha_2": {
         "type": "string",
         "description": "The country code must be represented in *ISO 3166-1 alpha-2*.",
         "maxLength": 2,
         "examples": [
            "IT"
         ]
      },
      "person_or_company": {
         "type": "object",
         "description": "Person or Company",
         "additionalProperties": false,
         "required": [
            "name",
            "address",
            "city",
            "country"
         ],
         "examples": [
            {
               "eori": "IT00852040112",
               "name": "Laghezza S.p.A.",
               "address": "Via San Bartolomeo, 103",
               "city": "La Spezia",
               "postal_code": "19125",
               "province": "SP",
               "country": "IT"
            }
         ],
         "properties": {
            "eori": {
               "type": "string",
               "title": "Only EU, The EORI of the person or the company.",
               "examples": [
                  "IT00852040112"
               ]
            },
            "name": {
               "type": "string",
               "title": "The name of the person or the company.",
               "examples": [
                  "Laghezza S.p.A."
               ]
            },
            "address": {
               "type": "string",
               "title": "The address of the person or the company.",
               "examples": [
                  "Via San Bartolomeo, 103"
               ]
            },
            "city": {
               "type": "string",
               "title": "The city of the person or the company.",
               "examples": [
                  "La Spezia"
               ]
            },
            "postal_code": {
               "type": "string",
               "title": "The postal code of the person or the company.",
               "examples": [
                  "19125"
               ]
            },
            "province": {
               "type": "string",
               "title": "The province of the person or the company.",
               "examples": [
                  "SP"
               ]
            },
            "country": {
               "type": "string",
               "title": "The country code of the person or the company."
            }
         }
      },
      "declaration_type": {
         "type": "object",
         "description": "Refer to *Box 1* of *Commission Delegated Regulation (EU) 2016/341*.",
         "additionalProperties": false,
         "examples": [
            {
               "first_subdivision": "EX",
               "second_subdivision": "A"
            }
         ],
         "properties": {
            "first_subdivision": {
               "type": "string",
               "title": "The first subdivision.",
               "description": "In the first subdivision, enter the relevant Union code from Appendix D1.",
               "examples": [
                  "EX",
                  "IM"
               ]
            },
            "second_subdivision": {
               "type": "string",
               "title": "The second subdivision.",
               "description": "In the second subdivision, enter the type of declaration using the relevant Union code from Appendix D1.",
               "examples": [
                  "A"
               ]
            },
            "third_subdivision": {
               "type": "string",
               "title": "The third subdivision.",
               "description": "In the third subdivision, enter the relevant Union code from Appendix D1.",
               "examples": [
                  "T1",
                  "T2"
               ]
            }
         }
      },
      "amount": {
         "type": "object",
         "description": "Amount with currency",
         "additionalProperties": false,
         "required": [
            "amount",
            "currency"
         ],
         "examples": [
            {
               "amount": 11.20,
               "currency": "USD"
            }
         ],
         "properties": {
            "amount": {
               "type": "number",
               "minimum": 0,
               "title": "The amount.",
               "examples": [
                  11.20
               ]
            },
            "currency": {
               "type": "string",
               "maxLength": 3,
               "title": "The currency of amount.",
               "examples": [
                  "USD"
               ]
            }
         }
      },
      "declaration_item": {
         "type": "object",
         "description": "The declaration item.",
         "additionalProperties": false,
         "required": [
            "number"
         ],
         "examples": [
            {
               "number": 1,
               "taxes": [
                  {
                     "code": "A00",
                     "base": 1000,
                     "rate": 0.01,
                     "amount": {
                        "amount": 10,
                        "currency": "EUR"
                     },
                     "payment_method": "E"
                  },
                  {
                     "code": "B00",
                     "base": 1010,
                     "rate": 0.22,
                     "amount": {
                        "amount": 222.2,
                        "currency": "EUR"
                     },
                     "payment_method": "G"
                  }
               ],
               "a93": {
                  "number": "000037",
                  "year": 2024,
                  "customs_office": "IT137100",
                  "deferred_payment_account": "14221Q"
               },
               "release": {
                  "control_circuit_outcome": "CA",
                  "release_code": "IF4R14",
                  "release_date": "2024-01-03"
               }
            }
         ],
         "properties": {
            "number": {
               "type": "integer",
               "minimum": 1,
               "title": "The number of the item.",
               "examples": [
                  1,
                  2,
                  3
               ]
            },
            "taxes": {
               "type": "array",
               "minItems": 0,
               "title": "Taxes of the item.",
               "items": {
                  "$ref": "#/$defs/declaration_item_tax",
                  "title": "Item Tax."
               }
            },
            "a93": {
               "title": "A93 of the item.",
               "$ref": "#/$defs/declaration_a93"
            },
            "release": {
               "title": "Release information of the item.",
               "$ref": "#/$defs/declaration_release"
            }
         }
      },
      "declaration_item_tax": {
         "type": "object",
         "description": "The item tax information.",
         "additionalProperties": false,
         "required": [
            "code",
            "base",
            "rate",
            "amount",
            "payment_method"
         ],
         "examples": [
             {
               "code": "A00",
               "base": 1000.00,
               "rate": 0.01,
               "amount": {
                  "amount": 10,
                  "currency": "EUR"
               },
               "payment_method": "E"
            }
         ],
         "properties": {
            "code": {
               "type": "string",
               "title": "The code of the tax.",
               "examples": [
                  "A00",
                  "B00"
               ]
            },
            "base": {
              "type": "number",
               "minimum": 0,
               "title": "The base of the tax calculation.",
               "examples": [
                  1000.00
               ]
            },
            "rate":  {
               "type": "number",
               "minimum": 0,
               "title": "The rate of the tax calculation.",
               "examples": [
                  0.01
               ]
            },
            "amount": {
               "title": "The amount of the tax.",
               "description": "Amount with currency",
               "$ref": "#/$defs/amount"
            },
            "payment_method": {
               "type": "string",
               "title": "The payment method of the tax.",
               "examples": [
                  "E",
                  "G"
               ]
            }
         }
      },
      "declaration_a93": {
         "type": "object",
         "description": "A93 information.",
         "additionalProperties": false,
         "required": [
            "number",
            "year",
            "customs_office",
            "deferred_payment_account"
         ],
         "examples": [
            {
               "number": "000037",
               "year": 2024,
               "customs_office": "IT137100",
               "deferred_payment_account": "14221Q",
               "payments": [
                  {
                     "amount": {
                        "amount": 665.70,
                        "currency": "EUR"
                     },
                     "expiration_date": "2024-03-08",
                     "payment_method": "E",
                     "description": "duty"
                  },
                  {
                     "amount": {
                        "amount": 3886.41,
                        "currency": "EUR"
                     },
                     "expiration_date": "2024-03-08",
                     "payment_method": "G",
                     "description": "vat_and_other_taxes"
                  }
               ]
            }
         ],
         "properties": {
            "number": {
               "type": "string",
               "title": "The number of A93.",
               "examples": [
                  "000037"
               ]
            },
            "year": {
               "type": "integer",
               "title": "The year of A93.",
               "examples": [
                     1970
                  ]
            },
            "customs_office": {
               "type": "string",
               "title": "The customs office of A93.",
               "examples": [
                  "IT137100"
               ]
            },
            "deferred_payment_account": {
               "type": "string",
               "title": "The deferred payment account of A93.",
               "examples": [
                  "14221Q"
               ]
            },
            "payments": {
               "type": "array",
               "title": "List of A93 payments.",
               "items": {
                  "minItems": 1,
                  "$ref": "#/$defs/declaration_a93_payment"
               }
            }
         }
      },
      "declaration_a93_payment": {
         "type": "object",
         "title": "Payment of the A93.",
         "additionalProperties": false,
         "required": [
            "amount",
            "expiration_date",
            "payment_method"
         ],
         "examples": [
            {
               "amount": {
                  "amount": 665.70,
                  "currency": "EUR"
               },
               "expiration_date": "2024-03-08",
               "payment_method": "E",
               "description": "duty"
            }
         ],
         "properties": {
            "amount": {
               "title": "The amount of payment.",
               "$ref": "#/$defs/amount"
            },
            "expiration_date": {
               "type": "string",
               "format": "date",
               "title": "The expiration date of the payment.",
               "description": "The expiration date must be represented in *ISO 8601*.",
               "examples": [
                  "1970-01-01"
               ]
            },
            "payment_method": {
               "type": "string",
               "title": "The method of the payment.",
               "examples": [
                  "E",
                  "G"
               ]
            },
            "description": {
               "type": "string",
               "title": "The description of the payment.",
               "examples": [
                  "duty",
                  "vat_and_other_taxes"
               ]
            }
         }
      },
      "declaration_ivisto": {
         "type": "object",
         "description": "IVISTO information.",
         "additionalProperties": false,
         "required": [
            "exit_date",
            "exit_customs_office"
         ],
         "examples": [
             {
                "exit_date": "1970-01-01" ,
                "exit_customs_office": "IT137100"
             }
         ],
         "properties": {
            "exit_date": {
               "type": "string",
               "format": "date",
               "title": "The exit date of the declaration.",
               "description": "The exit date must be represented in *ISO 8601*.",
               "examples": [
                  "1970-01-01"
               ]
            },
            "exit_customs_office": {
               "type": "string",
               "title": "The exit customs office of the declaration.",
               "examples": [
                  "IT137100"
               ]
            }
         }
      },
      "declaration_release": {
         "type": "object",
         "description": "Release information.",
         "additionalProperties": false,
         "required": [
            "control_circuit_outcome"
         ],
         "examples": [
            {
               "control_circuit_outcome": "CA",
               "release_code": "IL2U14",
               "release_date": "1970-01-01"
            },
            {
               "control_circuit_outcome": "VM"
            }
         ],
         "properties": {
            "control_circuit_outcome": {
               "type": "string",
               "title": "The control circuit outcome.",
               "examples": [
                  "CA",
                  "VM",
                  "CD",
                  "CS"
               ]
            },
            "release_code": {
               "type": "string",
               "title": "The release code of the item.",
               "examples": [
                  "IL6UO6",
                  "IF4R14"
               ]
            },
            "release_date": {
               "type": "string",
               "format": "date",
               "title": "The release date of the item.",
               "description": "The release date must be represented in *ISO 8601*.",
               "examples": [
                  "1970-01-01"
               ]
            }
         }
      },
      "attachment": {
         "type": "object",
         "description": "Attachment.",
         "additionalProperties": false,
         "required": [
            "filename",
            "binary",
            "content_type"
         ],
         "examples": [
            {
               "filename": "test.pdf",
               "binary": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYlWNgAAIAAAUAAdafFs0AAAAASUVORK5CYII=",
               "content_type": "application/pdf",
               "category": "INVOICE",
               "year": 2023,
               "identification_number": "FATT/2023/123"
            }
         ],
         "properties": {
            "filename": {
               "type": "string",
               "title": "The filename of the attachment",
               "examples": [
                  "test.pdf"
               ]
            },
            "binary": {
               "type": "string",
               "title": "The binary of the attachment",
               "contentEncoding": "base64",
               "examples": [
                  "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYlWNgAAIAAAUAAdafFs0AAAAASUVORK5CYII="
               ]
            },
            "content_type": {
               "type": "string",
               "title": "The content_type of the attachment",
               "enum": [
                  "application/pdf"
               ],
               "examples": [
                  "application/pdf"
               ]
            },
            "category": {
               "type": "string",
               "title": "The category of the attachment",
               "enum": [
                  "DAU",
                  "DAE",
                  "DAT",
                  "COPIA-CORTESIA",
                  "PROSPETTO-SVINCOLO",
                  "PROSPETTO-SINTESI",
                  "PROSPETTO-CONTABILE"
               ],
               "examples": [
                  "PROSPETTO-SINTESI",
                  "DAE"
               ]
            },
            "year": {
               "type": "integer",
               "title": "The year of the attachment",
               "minimum": 0,
               "examples": [
                  1983,
                  2023
               ]
            },
            "identification_number": {
               "type": "string",
               "title": "The identification number of the attachment",
               "examples": [
                  "FATT/2023/123"
               ]
            }
         }
      }
   },
   "type": "object",
   "title": "Simple Customs Declaration",
   "description": "Simple representation of customs declaration.",
   "additionalProperties": false,
   "required": [
      "schema_id",
      "customer_code",
      "customer_shipment_reference",
      "declaration_type",
      "mrn",
      "registration_date",
      "customs_office",
      "total_amount",
      "consignee",
      "consignor"
   ],
   "examples": [
      {
         "schema_id": "https://api.thebigalice.com/schema/customs/simple_customs_declaration/v1.1/schema.json",
         "customer_code": "ACME",
         "customer_shipment_reference": "2023/121/A"
      }
   ],
   "properties": {
      "schema_id": {
         "type": "string",
         "title": "The Id of the JSON schema",
         "examples": [
            "https://api.thebigalice.com/schema/customs/simple_customs_declaration/v1.1/schema.json"
         ]
      },
      "customer_code": {
         "type": "string",
         "title": "The customer code.",
         "examples": [
            "ACME"
         ]
      },
      "customer_shipment_reference": {
         "type": "string",
         "title": "The customer reference of the shipment.",
         "examples": [
            "121212/A"
         ]
      },
      "mrn": {
         "type": "string",
         "title": "The Movement Reference Number of the declaration.",
         "examples": [
            "12ITQXT121234345E0"
         ]
      },
      "regime": {
         "type": "string",
         "title": "The regime of the declaration.",
         "examples": [
            "4000"
         ]
      },
      "declaration_type": {
         "title": "The declaration type.",
         "description": "Refer to *Box 1* of *Commission Delegated Regulation (EU) 2016/341*.",
         "$ref": "#/$defs/declaration_type"
      },
      "registration_date": {
         "type": "string",
         "format": "date",
         "title": "The declaration registration date.",
         "description": "The registration date must be represented in *ISO 8601*.",
         "examples": [
            "1970-01-01"
         ]
      },
      "customs_office": {
         "type": "string",
         "title": "The declaration customs office.",
         "examples": [
            "IT279100"
         ]
      },
      "total_amount": {
         "title": "The declaration total amount.",
         "description": "Refer to *Box 22* of *Commission Delegated Regulation (EU) 2016/341*.",
         "$ref": "#/$defs/amount"
      },
      "consignee": {
         "title": "The consignee.",
         "description": "Refer to *Box 8* of *Commission Delegated Regulation (EU) 2016/341*.",
         "$ref": "#/$defs/person_or_company"
      },
      "consignor": {
         "title": "The consignor/exporter.",
         "description": "Refer to *Box 2* of *Commission Delegated Regulation (EU) 2016/341*.",
         "$ref": "#/$defs/person_or_company"
      },
      "status": {
         "type": "string",
         "title": "The status of declaration.",
         "enum": [
            "RELEASED",
            "PARTIALLY RELEASED",
            "NOT RELEASED"
         ],
         "examples": [
            "RELEASED"
         ]
      },
      "items": {
         "type": "array",
         "minItems": 0,
         "title": "The items of the declaration.",
         "items": {
            "$ref": "#/$defs/declaration_item",
            "title": "The item of the declaration."
         }
      },
      "a93": {
         "title": "List of A93.",
         "description": "Any A93 related to declaration.",
         "type": "array",
         "minItems": 0,
         "items": {
            "$ref": "#/$defs/declaration_a93",
            "title": "The A93 information."
         }
      },
      "ivisto": {
         "title": "List of IVISTO information.",
         "description": "Any IVISTO information related to declaration.",
         "type": "array",
         "minItems": 0,
         "items": {
            "$ref": "#/$defs/declaration_ivisto",
            "title": "The IVISTO information."
         }
      },
      "release": {
         "title": "List of release information.",
         "description": "Any release information related to declaration.",
         "type": "array",
         "minItems": 0,
         "items": {
            "$ref": "#/$defs/declaration_release",
            "title": "The release information."
         }
      },
      "attachments": {
         "title": "List of Attachments.",
         "description": "Any Attachment related to declaration.",
         "type": "array",
         "minItems": 0,
         "items": {
            "$ref": "#/$defs/attachment",
            "title": "The attachment."
         }
      }
   }
}