{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/luckpanda-app/json-schema/luckpanda-app-record-payment-receipt-schema.json",
  "title": "RecordPaymentReceipt",
  "x-generated": "2026-10-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/luckpanda-app-openapi.yaml#/components/schemas/RecordPaymentReceipt",
  "allOf": [
    {
      "$ref": "#/$defs/CommandBase"
    },
    {
      "type": "object",
      "required": [
        "kind",
        "party_id",
        "currency",
        "received_on",
        "lines"
      ],
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "receipt",
            "advance"
          ]
        },
        "party_id": {
          "$ref": "#/$defs/Uuid"
        },
        "currency": {
          "$ref": "#/$defs/Currency"
        },
        "received_on": {
          "$ref": "#/$defs/Date"
        },
        "lines": {
          "type": "array",
          "minItems": 1,
          "maxItems": 20,
          "items": {
            "type": "object",
            "required": [
              "amount_minor"
            ],
            "properties": {
              "amount_minor": {
                "type": "integer",
                "minimum": 0
              },
              "fee_minor": {
                "type": "integer",
                "minimum": 0
              },
              "withholding_minor": {
                "type": "integer",
                "minimum": 0
              },
              "payment_account_id": {
                "$ref": "#/$defs/Uuid"
              },
              "method": {
                "type": "string",
                "enum": [
                  "bank_transfer",
                  "upi",
                  "cash",
                  "cheque",
                  "demand_draft",
                  "card",
                  "wallet",
                  "gateway",
                  "other"
                ]
              },
              "reference": {
                "type": "string",
                "maxLength": 200
              }
            }
          }
        },
        "allocations": {
          "type": "array",
          "maxItems": 50,
          "items": {
            "type": "object",
            "required": [
              "document_id",
              "amount_minor"
            ],
            "properties": {
              "document_id": {
                "$ref": "#/$defs/Uuid"
              },
              "amount_minor": {
                "type": "integer",
                "minimum": 1
              },
              "withholding_minor": {
                "type": "integer",
                "minimum": 0
              },
              "document_revision_no": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        },
        "confirm_overpayment": {
          "type": "boolean",
          "default": false
        },
        "fx_rate_to_base": {
          "type": "string"
        },
        "notes": {
          "type": "string",
          "maxLength": 1000
        }
      }
    }
  ],
  "$defs": {
    "CommandBase": {
      "type": "object",
      "required": [
        "idempotency_key",
        "correlation_id"
      ],
      "properties": {
        "idempotency_key": {
          "$ref": "#/$defs/IdempotencyKey"
        },
        "correlation_id": {
          "$ref": "#/$defs/Uuid"
        },
        "dry_run": {
          "type": "boolean",
          "default": false
        },
        "proposal_only": {
          "type": "boolean",
          "default": false,
          "description": "Make it a proposal for a person to accept instead of acting."
        },
        "approval_request_id": {
          "$ref": "#/$defs/Uuid"
        }
      }
    },
    "Currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
    },
    "Date": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "IdempotencyKey": {
      "type": "string",
      "minLength": 16,
      "maxLength": 128,
      "pattern": "^[A-Za-z0-9._:-]+$"
    },
    "Uuid": {
      "type": "string",
      "format": "uuid"
    }
  }
}