{
  "$defs": {
    "Advance": {
      "description": "Advance represents a single payment that has been made already, such as a deposit on an intent to purchase, or as credit from a previous invoice which was later corrected or cancelled.",
      "properties": {
        "amount": {
          "$ref": "https://gobl.org/draft-0/num/amount",
          "description": "How much was paid.",
          "title": "Amount"
        },
        "card": {
          "$ref": "#/$defs/Card",
          "description": "Details of the payment that was made via a credit or debit card.",
          "title": "Card"
        },
        "credit_transfer": {
          "$ref": "#/$defs/CreditTransfer",
          "description": "Details about how the payment was made by credit (bank) transfer.",
          "title": "Credit Transfer"
        },
        "currency": {
          "$ref": "https://gobl.org/draft-0/currency/code",
          "description": "If different from the parent document's base currency.",
          "title": "Currency"
        },
        "date": {
          "$ref": "https://gobl.org/draft-0/cal/date",
          "description": "When the advance was made.",
          "title": "Date"
        },
        "description": {
          "description": "Details about the advance.",
          "title": "Description",
          "type": "string"
        },
        "grant": {
          "description": "If this \"advance\" payment has come from a public grant or subsidy, set this to true.",
          "title": "Grant",
          "type": "boolean"
        },
        "key": {
          "$ref": "https://gobl.org/draft-0/cbc/key",
          "anyOf": [
            {
              "const": "any",
              "description": "Any method available, no preference.",
              "title": "Any"
            },
            {
              "const": "card",
              "description": "Payment card.",
              "title": "Card"
            },
            {
              "const": "credit-transfer",
              "description": "Sender initiated bank or wire transfer.",
              "title": "Credit Transfer"
            },
            {
              "const": "debit-transfer",
              "description": "Receiver initiated bank or wire transfer.",
              "title": "Debit Transfer"
            },
            {
              "const": "cash",
              "description": "Cash in hand.",
              "title": "Cash"
            },
            {
              "const": "cheque",
              "description": "Cheque from bank.",
              "title": "Cheque"
            },
            {
              "const": "bank-draft",
              "description": "Bankers Draft or Bank Cheque.",
              "title": "Draft"
            },
            {
              "const": "direct-debit",
              "description": "Direct debit from the customers bank account.",
              "title": "Direct Debit"
            },
            {
              "const": "online",
              "description": "Online or web payment.",
              "title": "Online"
            },
            {
              "const": "promissory-note",
              "description": "Promissory note contract.",
              "title": "Promissory Note"
            },
            {
              "const": "netting",
              "description": "Intercompany clearing or clearing between partners.",
              "title": "Netting"
            },
            {
              "const": "other",
              "description": "Other or mutually defined means of payment.",
              "title": "Other"
            },
            {
              "pattern": "^(?:[a-z]|[a-z0-9][a-z0-9-+]*[a-z0-9])$",
              "title": "Regime Specific Key"
            }
          ],
          "description": "The payment means used to make the advance.",
          "title": "Key"
        },
        "meta": {
          "$ref": "https://gobl.org/draft-0/cbc/meta",
          "description": "Additional details useful for the parties involved.",
          "title": "Meta"
        },
        "percent": {
          "$ref": "https://gobl.org/draft-0/num/percentage",
          "description": "How much as a percentage of the total with tax was paid",
          "title": "Percent"
        },
        "ref": {
          "description": "ID or reference for the advance.",
          "title": "Reference",
          "type": "string"
        },
        "uuid": {
          "description": "Universally Unique Identifier.",
          "format": "uuid",
          "title": "UUID",
          "type": "string"
        }
      },
      "required": [
        "description",
        "amount"
      ],
      "type": "object"
    },
    "Card": {
      "description": "Card contains simplified card holder data as a reference for the customer.",
      "properties": {
        "holder": {
          "description": "Name of the person whom the card belongs to.",
          "title": "Holder Name",
          "type": "string"
        },
        "last4": {
          "description": "Last 4 digits of the card's Primary Account Number (PAN).",
          "title": "Last 4",
          "type": "string"
        }
      },
      "required": [
        "last4",
        "holder"
      ],
      "type": "object"
    },
    "CreditTransfer": {
      "description": "CreditTransfer contains fields that can be used for making payments via a bank transfer or wire.",
      "properties": {
        "bic": {
          "description": "Bank Identifier Code used for international transfers.",
          "title": "BIC",
          "type": "string"
        },
        "branch": {
          "$ref": "https://gobl.org/draft-0/org/address",
          "description": "Bank office branch address, not normally required.",
          "title": "Branch"
        },
        "iban": {
          "description": "International Bank Account Number",
          "title": "IBAN",
          "type": "string"
        },
        "name": {
          "description": "Name of the bank.",
          "title": "Name",
          "type": "string"
        },
        "number": {
          "description": "Account number, if IBAN not available.",
          "title": "Number",
          "type": "string"
        }
      },
      "type": "object"
    }
  },
  "$id": "https://gobl.org/draft-0/pay/advance",
  "$ref": "#/$defs/Advance",
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}