Factura
La API de Facturación de Tandia te permite enviar facturas electrónicas.
Enviar una Factura
Para enviar una factura, realiza una solicitud POST a la siguiente URL:
POST /api/invoice
Host: invoice.tandia.io
Content-Type: application/json
Authorization: Bearer token-de-api
Debes proporcionar un cuerpo de solicitud en formato JSON con la información de la factura que deseas enviar. Aquí tienes unos ejemplos:
Factura gravada
{
"number": "FF10-00000029",
"date": "2023-11-01T18:46:00-05:00",
"customer": {
"document_type": "6",
"document_number": "20740021552",
"registration_name": "Jane Doe SAC",
"email": "jdoe@business.com"
},
"company": {
"tax_id": "ruc-registrada-en-api"
},
"currency": "PEN",
"payment_method": "cash",
"tax_total": 36.00,
"sale_value": 200.00,
"subtotal": 236.00,
"total": 236.00,
"taxed_amount": 200.00,
"tax_amounts": [
{
"code": "IGV",
"amount": 36.00
}
],
"items": [
{
"free": false,
"code": "P001",
"unit": "NIU",
"description": "PRODUCTO 1",
"quantity": 2.00,
"unit_value": 100.00,
"unit_price": 118.00,
"tax_total": 36.00,
"sale_value": 200.00,
"subtotal": 200.00,
"taxes": [
{
"code": "IGV",
"amount": 36.00
}
],
"total": 236.00
}
]
}
Factura a crédito
{
"number": "FF41-00020431",
"date": "2023-10-02T18:46:00-05:00",
"customer": {
"document_type": "6",
"document_number": "20740021552",
"registration_name": "Jane Doe SAC",
"email": "jdoe@business.com"
},
"company": {
"tax_id": "ruc-registrada-en-api"
},
"currency": "PEN",
"payment_method": "credit",
"credit_installments": [
{
"currency": "PEN",
"amount": 100.00,
"payment_date": "2023-11-02T18:46:00-05:00"
},
{
"currency": "PEN",
"amount": 100.00,
"payment_date": "2023-12-02T18:46:00-05:00"
}
],
"tax_total": 36.00,
"sale_value": 200.00,
"subtotal": 236.00,
"total": 236.00,
"taxed_amount": 200.00,
"tax_amounts": [
{
"code": "IGV",
"amount": 36.00
}
],
"items": [
{
"free": false,
"code": "P001",
"unit": "NIU",
"description": "Producto 1",
"quantity": 2.00,
"unit_value": 100.00,
"unit_price": 118.00,
"tax_total": 36.00,
"sale_value": 200.00,
"subtotal": 200.00,
"taxes": [
{
"code": "IGV",
"amount": 36.00,
"percentage": 18.00
}
],
"total": 236.00
}
]
}
Factura exonerada
{
"number": "FF71-00003132",
"date": "2023-11-01T18:46:00-05:00",
"customer": {
"document_type": "6",
"document_number": "20740021552",
"registration_name": "Jane Doe SAC",
"email": "jdoe@business.com"
},
"company": {
"tax_id": "ruc-registrada-en-api"
},
"currency": "PEN",
"payment_method": "cash",
"tax_total": 0.00,
"sale_value": 100.00,
"subtotal": 100.00,
"total": 100.00,
"exonerated_amount": 100.00,
"tax_amounts": [
{
"code": "EXO",
"amount": 0.00
}
],
"items": [
{
"free": false,
"code": "P001",
"unit": "KG",
"description": "PRODUCTO 1",
"quantity": 2.00,
"unit_value": 50.00,
"unit_price": 50.00,
"tax_total": 0.00,
"sale_value": 100.00,
"subtotal": 100.00,
"taxes": [
{
"code": "EXO",
"amount": 0.00
}
],
"total": 100.00
}
]
}
Factura gratuita
{
"number": "FF81-00010041",
"date": "2023-11-01T19:51:25-05:00",
"customer": {
"document_type": "6",
"document_number": "20740021552",
"registration_name": "Jane Doe SAC",
"email": "jdoe@business.com"
},
"company": {
"tax_id": "ruc-registrada-en-api"
},
"currency": "PEN",
"payment_method": "cash",
"tax_total": 0.00,
"sale_value": 0.00,
"subtotal": 0.00,
"total": 0.00,
"free_amount": 200.00,
"tax_amounts": [
{
"code": "GRA",
"amount": 36.00
}
],
"legends": [
{
"code": "1002",
"value": "TRANSFERENCIA GRATUITA DE UN BIEN Y/O SERVICIO PRESTADO GRATUITAMENTE"
}
],
"items": [
{
"free": true,
"code": "P001",
"unit": "NIU",
"description": "PRODUCTO 1",
"quantity": 2.00,
"unit_value": 0.00,
"unit_price": 100.00,
"tax_total": 36.00,
"sale_value": 200.00,
"subtotal": 200.00,
"taxes": [
{
"code": "IGV",
"affectation_type": "11",
"amount": 36.00
}
],
"total": 200.00
}
]
}
Factura inafecta
{
"number": "FF91-00032025",
"date": "2023-11-28T18:46:00-05:00",
"customer": {
"document_type": "6",
"document_number": "20740021552",
"registration_name": "Jane Doe SAC",
"email": "jdoe@business.com"
},
"company": {
"tax_id": "ruc-registrada-en-api"
},
"currency": "PEN",
"payment_method": "cash",
"tax_total": 0.00,
"sale_value": 1000.00,
"subtotal": 1000.00,
"total": 1000.00,
"unaffected_amount": 1000.00,
"tax_amounts": [
{
"code": "INA",
"amount": 0
}
],
"items": [
{
"free": false,
"code": "P001",
"unit": "KG",
"description": "PRODUCTO 1",
"quantity": 2.00,
"unit_value": 500.00,
"unit_price": 500.00,
"tax_total": 0.00,
"sale_value": 1000.00,
"subtotal": 1000.00,
"taxes": [
{
"code": "INA",
"amount": 0.00
}
],
"total": 1000.00
}
]
}
Factura ICBPER
{
"number": "FF92-00110013",
"date": "2023-11-02T18:46:00-05:00",
"customer": {
"document_type": "6",
"document_number": "20740021552",
"registration_name": "Jane Doe SAC",
"email": "jdoe@business.com"
},
"company": {
"tax_id": "ruc-registrada-en-api"
},
"currency": "PEN",
"payment_method": "cash",
"tax_total": 36.84,
"sale_value": 200.20,
"subtotal": 237.04,
"round": 0.04,
"total": 237.00,
"taxed_amount": 200.20,
"tax_amounts": [
{
"code": "IGV",
"amount": 36.04
},
{
"code": "ICBPER",
"amount": 0.80
}
],
"items": [
{
"free": false,
"code": "P001",
"unit": "NIU",
"description": "PRODUCTO 1",
"quantity": 2.00,
"unit_value": 100.00,
"unit_price": 118.00,
"tax_total": 36.00,
"sale_value": 200.00,
"subtotal": 200.00,
"taxes": [
{
"code": "IGV",
"amount": 36.00
}
],
"total": 236.00
},
{
"free": false,
"code": "B001",
"unit": "NIU",
"description": "Bolsa de plástico",
"quantity": 4.00,
"unit_value": 0.05,
"unit_price": 0.059,
"tax_total": 0.84,
"sale_value": 0.20,
"subtotal": 0.20,
"taxes": [
{
"code": "IGV",
"amount": 0.04
},
{
"code": "ICBPER",
"amount": 0.80,
"percentage": 0.20
}
],
"total": 1.04
}
]
}
Factura con detracción
{
"number": "FF51-00021129",
"date": "2023-11-02T20:46:00-05:00",
"customer": {
"document_type": "6",
"document_number": "20740021552",
"registration_name": "Jane Doe SAC",
"email": "jdoe@business.com"
},
"company": {
"tax_id": "ruc-registrada-en-api"
},
"currency": "PEN",
"payment_method": "cash",
"tax_total": 144.00,
"sale_value": 800.00,
"subtotal": 944.00,
"total": 944.00,
"taxed_amount": 800.00,
"tax_amounts": [
{
"code": "IGV",
"amount": 144.00
}
],
"detraction": {
"bank_account": "0004-3342343243",
"code": "022",
"payment_code": "003",
"percentage": 4.00,
"amount": 37.76
},
"items": [
{
"free": false,
"code": "S001",
"unit": "ZZ",
"description": "Servicio 1",
"quantity": 4.00,
"unit_value": 200.00,
"unit_price": 236.00,
"tax_total": 144.00,
"subtotal": 800.00,
"sale_value": 800.00,
"total": 944.00,
"taxes": [
{
"code": "IGV",
"amount": 144.00
}
]
}
]
}
Factura con descuentos
{
"number": "FF32-00025631",
"date": "2023-11-02T14:01:00-05:00",
"customer": {
"document_type": "6",
"document_number": "20740021552",
"registration_name": "Jane Doe SAC",
"email": "jdoe@business.com"
},
"company": {
"tax_id": "ruc-registrada-en-api"
},
"currency": "PEN",
"payment_method": "cash",
"tax_total": 3.60,
"sale_value": 20.00,
"subtotal": 23.60,
"total": 16.60,
"taxed_amount": 20.00,
"tax_amounts": [
{
"code": "IGV",
"amount": 3.60
}
],
"discounts" : [
{
"code": "03",
"base_amount": 3.00,
"percentage": 1,
"amount": 3
}
],
"items": [
{
"free": false,
"code": "P001",
"unit": "NIU",
"description": "Producto 001",
"quantity": 10.00,
"unit_value": 2.00,
"unit_price": 1.96,
"tax_total": 3.60,
"sale_value": 20.00,
"subtotal": 20.00,
"total": 19.60,
"taxes": [
{
"code": "IGV",
"amount": 3.60
}
],
"discounts" : [
{
"code": "01",
"base_amount": 20.00,
"percentage": 0.2,
"amount": 4
}
]
}
]
}
Factura compuesta
{
"number": "FF61-00600145",
"date": "2023-11-09T18:46:00-05:00",
"customer": {
"document_type": "6",
"document_number": "20740021552",
"registration_name": "John Doe SAC",
"email": "jdoe@business.com"
},
"company": {
"tax_id": "ruc-registrada-en-api"
},
"currency": "PEN",
"payment_method": "cash",
"tax_total": 36.00,
"sale_value": 500.00,
"subtotal": 536.00,
"total": 536.00,
"taxed_amount": 200.00,
"exonerated_amount": 100.00,
"unaffected_amount": 200.00,
"free_amount": 300.00,
"tax_amounts": [
{
"code": "IGV",
"amount": 36.00
},
{
"code": "EXO",
"amount": 0.00
},
{
"code": "INA",
"amount": 0.00
},
{
"code": "GRA",
"amount": 18.00
}
],
"legends": [
{
"code": "1002",
"value": "TRANSFERENCIA GRATUITA DE UN BIEN Y/O SERVICIO PRESTADO GRATUITAMENTE"
}
],
"items": [
{
"free": false,
"code": "P001",
"unit": "NIU",
"description": "Producto 1",
"quantity": 2.00,
"unit_value": 100.00,
"unit_price": 118.00,
"tax_total": 36.00,
"sale_value": 200.00,
"subtotal": 200.00,
"total": 236.00,
"taxes": [
{
"code": "IGV",
"amount": 36.00
}
]
},
{
"free": false,
"code": "P002",
"unit": "KG",
"description": "PRODUCTO 2",
"quantity": 2.00,
"unit_value": 50.00,
"unit_price": 50.00,
"tax_total": 0.00,
"sale_value": 100.00,
"subtotal": 100.00,
"total": 100.00,
"taxes": [
{
"code": "EXO",
"amount": 0.00
}
]
},
{
"free": false,
"code": "P003",
"unit": "NIU",
"description": "PRODUCTO 3",
"quantity": 2.00,
"unit_value": 100.00,
"unit_price": 100.00,
"tax_total": 0.00,
"sale_value": 200.00,
"subtotal": 200.00,
"total": 200.00,
"taxes": [
{
"code": "INA",
"amount": 0.00
}
]
},
{
"free": true,
"code": "P004",
"unit": "NIU",
"description": "PRODUCTO 4",
"quantity": 1.00,
"unit_value": 0.00,
"unit_price": 100.00,
"tax_total": 18.00,
"sale_value": 100.00,
"subtotal": 100.00,
"total": 0.00,
"taxes": [
{
"code": "IGV",
"affectation_type": "13",
"amount": 18.00
}
]
},
{
"free": true,
"code": "P005",
"unit": "NIU",
"description": "PRODUCTO 5",
"quantity": 2.00,
"unit_value": 0.00,
"unit_price": 100.00,
"tax_total": 0.00,
"sale_value": 200.00,
"subtotal": 200.00,
"total": 0.00,
"taxes": [
{
"code": "INA",
"affectation_type": "32",
"amount": 0.00
}
]
}
]
}
Factura con anticipos
{
"number": "FF20-00000026",
"date": "2023-11-02T14:01:00-05:00",
"customer": {
"document_type": "6",
"document_number": "10740021552",
"registration_name": "Jane Doe"
},
"company": {
"tax_id": "ruc-registrada-en-api"
},
"currency": "PEN",
"payment_method": "cash",
"prepayments": [
{
"document_type": "02",
"document_number": "FF01-00000011",
"total": 100.00
}
],
"discounts": [
{
"code": "04",
"base_amount": 100.00,
"percentage": 1,
"amount": 100.00
}
],
"tax_total": 18.00,
"sale_value": 200.00,
"subtotal": 236.00,
"total": 136.00,
"taxed_amount": 100.00,
"tax_amounts": [
{
"code": "IGV",
"amount": 18.00
}
],
"items": [
{
"free": false,
"code": "P001",
"unit": "NIU",
"description": "Producto 001",
"quantity": 2.00,
"unit_value": 100.00,
"unit_price": 118.00,
"tax_total": 36.00,
"subtotal": 200.00,
"sale_value": 200.00,
"total": 236.00,
"taxes": [
{
"code": "IGV",
"amount": 36.00
}
]
}
]
}
Respuesta
Cuando envías una factura a través de la API de Facturación de Tandia, recibirás una respuesta que contiene información sobre el estado del comprobante. A continuación, se detalla la estructura de la respuesta:
{
"id": "doc_da1e8fe3b8e94c09a93a78e5d1a9f770",
"type": "invoice",
"currency": "PEN",
"external_id": null,
"number": "FF61-00600145",
"date": "2023-11-09T18:46:00-05:00",
"company": {
"tax_id": "20750022128",
"business_name": "Corp Demo S.A.C.",
"trade_name": "Corp Demo",
"email": "user@corp.com",
"phone": "+51 987654321",
"country": "PE",
"address": {
"postal_zone": "15074",
"country": "PE",
"country_subentity": "LIMA",
"city": "LIMA",
"district": "LIMA",
"city_subdivision": null,
"address": "CALLE MANUEL A. FUENTES NRO. 683 INT. 101",
"type_code": null
},
"logo": null
},
"total": 536,
"observation": null,
"status": "created",
"success": false,
"metadata": [],
"failure_code": null,
"failure_message": null,
"document_pdf": null,
"document_file": null,
"qr_code": null,
"result": null,
"logs": []
}
Factura básica
Este es un modelo de solicitud en formato json para una factura básica. La cabecera lleva el campo serie, el cual indica que es de tipo Factura. La numeración se maneja de forma automática en el sistema.
{
"serie": "FF07",
"date": "2024-06-14T11:56:00-05:00",
"customer": {
"documentNumber": "20740021552",
"registrationName": "Jane Doe SAC",
"email": "jdoe@business.com"
},
"company": {
"taxId": "ruc-registrada-en-api"
},
"currency": "PEN",
"items": [
{
"free": false,
"description": "Item 01",
"price": 100.00,
"quantity": 1,
"taxes": ["IGV18"]
},
{
"free": false,
"description": "Item 02",
"price": 50,
"quantity": 1,
"taxes": ["IGV18"]
}
]
}
Detalle de Items
Especificación sobre el contenido en detalle de los ítems para la factura básica.
Atributos
Indicar si un ítem es gratuito o no.
Descripción o concepto del ítem.
Precio total del producto. Nosotros nos encargamos de los cálculos.
Cantidad de productos.
Códigos de los impuestos correspondientes que afectan al ítem. Ejemplo: IGV18, IGV10, ICBPER.
Respuesta
Cuando envías una factura a través de la API de Facturación de Tandia, recibirás una respuesta que contiene información sobre el estado del comprobante. A continuación, se detalla la estructura de la respuesta:
{
"id": "doc_e6725ec6a53f4ada977a6950713a7bd4",
"type": "invoice",
"currency": "PEN",
"external_id": null,
"number": "FF07-10000002",
"date": "2024-05-02T11:23:00-05:00",
"company": {
"tax_id": "20750022128",
"business_name": "Corp Demo S.A.C.",
"trade_name": "Corp Demo",
"email": "user@corp.com",
"phone": "+51 987654321",
"country": "PE",
"address": {
"postal_zone": "15074",
"country": "PE",
"country_subentity": "LIMA",
"city": "LIMA",
"district": "LIMA",
"city_subdivision": null,
"address": "CALLE MANUEL A. FUENTES NRO. 683 INT. 101",
"type_code": null
},
"logo": null
},
"customer": {
"document_type": "6",
"document_number": "20740021552",
"registration_name": "Jane Doe SAC",
"family_name": null,
"email": "jdoe@business.com",
"document_extra": null
},
"total": 150,
"order_reference": null,
"observation": null,
"status": "created",
"success": false,
"metadata": [],
"failure_code": null,
"failure_message": null,
"document_pdf": null,
"document_file": null,
"qr_code": null,
"result": null,
"logs": []
}