Docs
Servidor MCPHerramientas disponibles

Crear factura desde recibos

Crea un borrador CFDI a partir de recibos de venta compatibles.

Herramienta MCPcreate_invoice_draft_from_sales_receipts

Propósito

Crea un borrador CFDI a partir de recibos de venta compatibles.

Usar cuando
Uno o más recibos están listos para facturarse juntos.
No usar cuando
No comparten cliente, moneda, pago y momento de pago.
Permisos requeridos
invoices:manage + receipts:read
Efectos secundarios
Efecto externo
Idempotencia
Idempotente

Esquema de entrada

JSON Schema
{  "type": "object",  "properties": {    "idempotencyKey": {      "type": "string",      "minLength": 1,      "maxLength": 200,      "description": "Unique retry key for this exact operation. Reuse it only when retrying the same request."    },    "input": {      "type": "object",      "properties": {        "salesReceiptRefs": {          "minItems": 1,          "maxItems": 100,          "type": "array",          "items": {            "type": "string",            "pattern": "^sales_receipt:.*"          },          "description": "One or more open receipt documentRefs from search_documents"        },        "customer": {          "oneOf": [            {              "type": "object",              "properties": {                "kind": {                  "const": "existing"                },                "customerId": {                  "type": "string",                  "minLength": 1                }              },              "required": [                "kind",                "customerId"              ],              "additionalProperties": false            },            {              "type": "object",              "properties": {                "kind": {                  "const": "public_general"                }              },              "required": [                "kind"              ],              "additionalProperties": false            }          ]        },        "cfdiUse": {          "enum": [            "CN01",            "CP01",            "D01",            "D02",            "D03",            "D04",            "D05",            "D06",            "D07",            "D08",            "D09",            "D10",            "G01",            "G02",            "G03",            "I01",            "I02",            "I03",            "I04",            "I05",            "I06",            "I07",            "I08",            "S01"          ],          "description": "Known SAT CFDI-use code.",          "x-exac-sat-catalog": "cfdi-uses"        },        "acknowledgeReconciliationDifference": {          "description": "Required only after reviewing a reported fiscal difference",          "allOf": [            {              "type": "boolean"            }          ]        },        "reconciliationNote": {          "type": "string",          "minLength": 1        },        "remediation": {          "type": "object",          "properties": {            "customerFiscalIdentity": {              "type": "object",              "properties": {                "rfc": {                  "type": "string",                  "minLength": 1                },                "taxSystem": {                  "enum": [                    "601",                    "603",                    "605",                    "606",                    "607",                    "608",                    "610",                    "611",                    "612",                    "614",                    "615",                    "616",                    "620",                    "621",                    "622",                    "623",                    "624",                    "625",                    "626"                  ],                  "description": "Known SAT tax-system code.",                  "x-exac-sat-catalog": "tax-systems"                },                "postalCode": {                  "type": "string",                  "minLength": 1                }              },              "additionalProperties": false            },            "receiptItems": {              "type": "array",              "items": {                "type": "object",                "properties": {                  "salesReceiptRef": {                    "type": "string",                    "pattern": "^sales_receipt:.*"                  },                  "items": {                    "type": "array",                    "items": {                      "type": "object",                      "properties": {                        "index": {                          "type": "integer",                          "minimum": 0,                          "maximum": 9007199254740991                        },                        "satProductCode": {                          "type": "string",                          "minLength": 1                        },                        "satUnitCode": {                          "type": "string",                          "minLength": 1                        },                        "saveToProduct": {                          "type": "boolean"                        }                      },                      "required": [                        "index",                        "satProductCode",                        "satUnitCode"                      ],                      "additionalProperties": false                    }                  }                },                "required": [                  "salesReceiptRef",                  "items"                ],                "additionalProperties": false              }            }          },          "additionalProperties": false,          "description": "Supply only when validation reports missing customer or item fiscal identity. Use the receipt reference and zero-based item index reported in details.issues."        }      },      "required": [        "salesReceiptRefs",        "customer",        "cfdiUse"      ],      "additionalProperties": false    }  },  "required": [    "idempotencyKey",    "input"  ],  "$schema": "http://json-schema.org/draft-07/schema#",  "additionalProperties": false}

Esquema de salida

JSON Schema
{  "type": "object",  "properties": {    "data": {      "type": "object",      "properties": {        "invoice": {          "type": "object",          "properties": {            "simulated": {              "allOf": [                {                  "type": "boolean",                  "const": true                }              ]            },            "documentRef": {              "type": "string",              "pattern": "^invoice:.+$"            },            "kind": {              "enum": [                "income",                "credit_note",                "transfer",                "payroll",                "payment_complement"              ]            },            "status": {              "const": "draft"            }          },          "required": [            "documentRef",            "kind",            "status"          ],          "additionalProperties": false        },        "salesReceiptRefs": {          "type": "array",          "items": {            "type": "string",            "pattern": "^sales_receipt:.+$"          }        },        "reconciliationDifference": {          "type": "number"        }      },      "required": [        "invoice",        "salesReceiptRefs"      ],      "additionalProperties": false    },    "error": {      "$schema": "http://json-schema.org/draft-07/schema#",      "type": "object",      "properties": {        "code": {          "enum": [            "validation_error",            "unauthenticated",            "forbidden",            "payment_required",            "not_found",            "method_not_allowed",            "conflict",            "idempotency_conflict",            "operation_in_progress",            "recovery_required",            "migration_required",            "rate_limited",            "provider_unavailable",            "internal"          ]        },        "message": {          "type": "string"        },        "details": {          "type": "object",          "properties": {            "document": {              "type": "object",              "properties": {                "documentRef": {                  "type": "string",                  "pattern": "^(invoice|withholding|sales_receipt|declaration|tax_compliance_opinion|sales_receipt_refund):.+$"                },                "editable": {                  "type": "boolean"                }              },              "required": [                "documentRef",                "editable"              ],              "additionalProperties": false            },            "issues": {              "type": "array",              "items": {                "type": "object",                "properties": {                  "path": {                    "type": "array",                    "items": {                      "anyOf": [                        {                          "type": "string"                        },                        {                          "type": "number"                        }                      ]                    }                  },                  "message": {                    "type": "string"                  },                  "code": {                    "type": "string"                  }                },                "required": [                  "path",                  "message"                ],                "additionalProperties": false              }            },            "retryable": {              "type": "boolean"            },            "retryAfterSeconds": {              "type": "integer",              "exclusiveMinimum": 0,              "maximum": 9007199254740991            },            "reason": {              "type": "string"            },            "balanceMinor": {              "type": "integer",              "minimum": 0,              "maximum": 9007199254740991            },            "topUpUrl": {              "type": "string"            }          },          "additionalProperties": false        }      },      "required": [        "code",        "message"      ],      "additionalProperties": false    }  },  "$schema": "http://json-schema.org/draft-07/schema#",  "additionalProperties": false,  "oneOf": [    {      "required": [        "data"      ]    },    {      "required": [        "error"      ]    }  ]}

Flujo relacionado

Consulta los flujos canónicos en la introducción

Herramientas relacionadas