Saltar a contenido

Create payment complement draft


title: Create a payment complement draft

Build a draft payment complement (comprobante type P, Pagos 2.0) that records payments received for one or more PPD invoices, without writing the document by hand. Arguments: fecha (the complement's own Fecha, YYYY-MM-DDTHH:MM:SS, required: the server never picks the clock) and pagos, an array of {fecha_pago, forma_de_pago (SAT c_FormaPago key, never 99), num_operacion (optional), documentos: [{invoice_id (the id of a signed PPD invoice of yours), imp_pagado (decimal string)}]}. The server takes Receptor from the paid invoices (they must share one receptor), numbers each installment from its ledger and computes the balances and taxes; the result is the stored draft in the get_invoice shape, an ordinary draft that update_invoice_draft replaces and sign_invoice stamps. Validation problems (an invoice that is a draft, canceled, PUE or unknown, an amount above the balance, ...) answer invalid_argument with the per-field errors. Returns a needs_csd status instead of a draft if the issuer has no CSD.

Alcance (scope): invoices:write · Características: —

Parámetros

Parámetro Tipo Obligatorio Descripción
fecha string Sí YYYY-MM-DDTHH:MM:SS
pagos array de object Sí
issuer string Sí Id of the issuer the call acts for, from list_issuers.

Esquema de entrada (JSON Schema)

{
  "type": "object",
  "properties": {
    "fecha": {
      "type": "string",
      "description": "YYYY-MM-DDTHH:MM:SS"
    },
    "pagos": {
      "type": "array",
      "minItems": 1,
      "maxItems": 10,
      "items": {
        "type": "object",
        "properties": {
          "fecha_pago": {
            "type": "string",
            "description": "YYYY-MM-DDTHH:MM:SS"
          },
          "forma_de_pago": {
            "type": "string",
            "description": "SAT c_FormaPago key of the payment, not 99"
          },
          "num_operacion": {
            "type": "string",
            "maxLength": 100
          },
          "documentos": {
            "type": "array",
            "minItems": 1,
            "maxItems": 20,
            "items": {
              "type": "object",
              "properties": {
                "invoice_id": {
                  "type": "string"
                },
                "imp_pagado": {
                  "type": "string",
                  "description": "Decimal string, e.g. '500.00'"
                }
              },
              "required": [
                "invoice_id",
                "imp_pagado"
              ]
            }
          }
        },
        "required": [
          "fecha_pago",
          "forma_de_pago",
          "documentos"
        ]
      }
    },
    "issuer": {
      "type": "string",
      "format": "uuid",
      "description": "Id of the issuer the call acts for, from list_issuers."
    }
  },
  "required": [
    "fecha",
    "pagos",
    "issuer"
  ]
}