{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/upgrowth-dz/json-schema/upgrowth-dz-export-repatriation-deadline-schema.json",
  "title": "ExportRepatriationDeadline",
  "x-generated": "2026-11-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/upgrowth-dz-openapi.yml#/components/schemas/ExportRepatriationDeadline",
  "type": "object",
  "required": [
    "inputs",
    "refused",
    "export_credit_insurance_required",
    "legal_basis"
  ],
  "properties": {
    "inputs": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "description": "goods or services."
        },
        "start_date": {
          "type": "string",
          "description": "YYYY-MM-DD."
        },
        "payment_term_days": {
          "type": [
            "integer",
            "null"
          ],
          "description": "The term sent, null when none was."
        },
        "payment_date": {
          "type": [
            "string",
            "null"
          ],
          "description": "The payment date sent, null when none was."
        }
      }
    },
    "kind": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "name": {
          "type": "string",
          "description": "In the language of the request."
        },
        "start_label": {
          "type": "string",
          "description": "What the start date is: the shipment or the completion date."
        }
      }
    },
    "rule_days": {
      "type": "object",
      "properties": {
        "base": {
          "type": "integer",
          "description": "120."
        },
        "maximum": {
          "type": "integer",
          "description": "180."
        }
      }
    },
    "refused": {
      "type": "boolean",
      "description": "True when the payment term is above 180 days."
    },
    "refusal": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "code": {
              "type": "string"
            },
            "maximum_days": {
              "type": "integer"
            },
            "message": {
              "type": "string"
            }
          }
        },
        {
          "type": "null"
        }
      ],
      "description": "Why the term is refused, null otherwise."
    },
    "days_used": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Days counted from the start date: 120, or the term from 121 to 180; null when refused."
    },
    "last_repatriation_date": {
      "type": [
        "string",
        "null"
      ],
      "description": "The last day to repatriate, YYYY-MM-DD; null when refused."
    },
    "export_credit_insurance_required": {
      "type": "boolean",
      "description": "True when the term is above 120 days (and up to 180)."
    },
    "export_credit_insurance_note": {
      "type": [
        "string",
        "null"
      ],
      "description": "What the insurance requires, null when it is not required."
    },
    "payment": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "date": {
              "type": "string"
            },
            "repatriation_day": {
              "type": "string",
              "description": "The same day: the receipts are repatriated when the client pays."
            },
            "same_day_rule": {
              "type": "string"
            },
            "days_from_start": {
              "type": "integer"
            },
            "days_to_deadline": {
              "type": [
                "integer",
                "null"
              ],
              "description": "Negative when the payment is after the deadline."
            },
            "before_deadline": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "on_deadline": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "after_deadline": {
              "type": [
                "boolean",
                "null"
              ]
            }
          }
        },
        {
          "type": "null"
        }
      ],
      "description": "Present when payment_date is sent."
    },
    "reminders": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "legal_basis": {
      "type": "object",
      "properties": {
        "act": {
          "type": "object",
          "additionalProperties": true
        },
        "article": {
          "type": "string"
        },
        "journal_officiel": {
          "type": "object",
          "properties": {
            "year": {
              "type": "integer"
            },
            "issue": {
              "type": "integer"
            },
            "page": {
              "type": "integer"
            }
          }
        },
        "links": {
          "type": "object",
          "properties": {
            "issue_url": {
              "type": "string",
              "format": "uri"
            },
            "act_url": {
              "type": "string",
              "format": "uri"
            }
          }
        },
        "text": {
          "type": "string",
          "description": "The basis in words, in the language of the request."
        }
      }
    },
    "limitations": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  }
}