Docs
Servidor MCPHerramientas disponibles

Crear CFDI desde recibos

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

Herramienta MCPcreate_cfdi_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,          "type": "array",          "items": {            "$ref": "#/definitions/__schema0"          },          "description": "One or more open receipt documentRefs from search_documents"        },        "customer": {          "oneOf": [            {              "type": "object",              "properties": {                "kind": {                  "type": "string",                  "const": "existing"                },                "customerId": {                  "type": "string",                  "minLength": 1                }              },              "required": [                "kind",                "customerId"              ],              "additionalProperties": false            },            {              "type": "object",              "properties": {                "kind": {                  "type": "string",                  "const": "public_general"                }              },              "required": [                "kind"              ],              "additionalProperties": false            }          ]        },        "cfdiUse": {          "type": "string",          "enum": [            "G01",            "D06",            "I07",            "I06",            "I01",            "I05",            "D09",            "G02",            "D04",            "I04",            "I03",            "D08",            "G03",            "D03",            "D02",            "D01",            "D05",            "I02",            "CN01",            "I08",            "CP01",            "D10",            "D07",            "S01"          ],          "description": "Active SAT CFDI-use code.",          "x-exac-sat-catalog": "cfdi-uses"        },        "acknowledgeReconciliationDifference": {          "description": "Required only after reviewing a reported fiscal difference",          "allOf": [            {              "$ref": "#/definitions/__schema1"            }          ]        },        "reconciliationNote": {          "type": "string",          "minLength": 1        },        "paymentScheduleReplacement": {          "description": "Required when batching credit receipts that already have operational payment schedules. Replaces them with one acknowledged invoice schedule.",          "allOf": [            {              "$ref": "#/definitions/__schema2"            }          ]        },        "remediation": {          "type": "object",          "properties": {            "customerFiscalIdentity": {              "$ref": "#/definitions/__schema3"            },            "receiptItems": {              "$ref": "#/definitions/__schema4"            }          },          "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,  "definitions": {    "__schema0": {      "type": "string",      "pattern": "^sales_receipt:.*"    },    "__schema1": {      "type": "boolean"    },    "__schema2": {      "type": "object",      "properties": {        "acknowledged": {          "type": "boolean",          "const": true        },        "settlementTerms": {          "type": "object",          "properties": {            "installmentCount": {              "type": "integer",              "minimum": 1,              "maximum": 60            },            "firstDue": {              "oneOf": [                {                  "type": "object",                  "properties": {                    "kind": {                      "type": "string",                      "const": "transaction_date"                    }                  },                  "required": [                    "kind"                  ],                  "additionalProperties": false                },                {                  "type": "object",                  "properties": {                    "kind": {                      "type": "string",                      "const": "months_after_transaction"                    },                    "months": {                      "type": "integer",                      "minimum": 1,                      "maximum": 60                    }                  },                  "required": [                    "kind",                    "months"                  ],                  "additionalProperties": false                },                {                  "type": "object",                  "properties": {                    "kind": {                      "type": "string",                      "const": "fixed_date"                    },                    "date": {                      "type": "string"                    }                  },                  "required": [                    "kind",                    "date"                  ],                  "additionalProperties": false                }              ]            },            "recurrence": {              "oneOf": [                {                  "type": "object",                  "properties": {                    "kind": {                      "type": "string",                      "const": "anchor_day"                    }                  },                  "required": [                    "kind"                  ],                  "additionalProperties": false                },                {                  "type": "object",                  "properties": {                    "kind": {                      "type": "string",                      "const": "day_of_month"                    },                    "day": {                      "type": "integer",                      "minimum": 1,                      "maximum": 31                    }                  },                  "required": [                    "kind",                    "day"                  ],                  "additionalProperties": false                },                {                  "type": "object",                  "properties": {                    "kind": {                      "type": "string",                      "const": "last_day"                    }                  },                  "required": [                    "kind"                  ],                  "additionalProperties": false                }              ]            }          },          "required": [            "installmentCount",            "firstDue",            "recurrence"          ],          "additionalProperties": false        },        "reason": {          "type": "string",          "minLength": 3,          "maxLength": 500        }      },      "required": [        "acknowledged",        "settlementTerms",        "reason"      ],      "additionalProperties": false    },    "__schema3": {      "type": "object",      "properties": {        "rfc": {          "type": "string",          "minLength": 1        },        "taxSystem": {          "type": "string",          "enum": [            "601",            "603",            "605",            "606",            "607",            "608",            "610",            "611",            "612",            "614",            "615",            "616",            "620",            "621",            "622",            "623",            "624",            "625",            "626"          ],          "description": "Active SAT tax-system code.",          "x-exac-sat-catalog": "tax-systems"        },        "postalCode": {          "type": "string",          "minLength": 1        }      },      "additionalProperties": false    },    "__schema4": {      "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      }    }  }}

Esquema de salida

JSON Schema
{  "type": "object",  "properties": {    "data": {      "type": "object",      "properties": {        "cfdi": {          "type": "object",          "properties": {            "documentRef": {              "type": "string",              "pattern": "^cfdi:.+$"            },            "kind": {              "type": "string",              "enum": [                "income",                "credit_note",                "transfer",                "payroll",                "payment_complement"              ]            },            "status": {              "type": "string",              "const": "draft"            }          },          "required": [            "documentRef",            "kind",            "status"          ],          "additionalProperties": false        },        "salesReceiptRefs": {          "type": "array",          "items": {            "type": "string",            "pattern": "^sales_receipt:.+$"          }        },        "reconciliationDifference": {          "type": "number"        }      },      "required": [        "cfdi",        "salesReceiptRefs"      ],      "additionalProperties": false    },    "error": {      "$schema": "http://json-schema.org/draft-07/schema#",      "type": "object",      "properties": {        "code": {          "type": "string",          "enum": [            "validation_error",            "unauthenticated",            "forbidden",            "not_found",            "method_not_allowed",            "conflict",            "idempotency_conflict",            "operation_in_progress",            "recovery_required",            "rate_limited",            "provider_unavailable",            "internal"          ]        },        "message": {          "type": "string"        },        "details": {          "type": "object",          "properties": {            "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            }          },          "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