fiscalapi 4.0.2__tar.gz → 4.0.12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/PKG-INFO +337 -336
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/README.md +302 -302
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/fiscalapi/__init__.py +88 -88
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/fiscalapi/models/common_models.py +67 -67
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/fiscalapi/models/fiscalapi_models.py +323 -323
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/fiscalapi/services/base_service.py +217 -217
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/fiscalapi/services/catalog_service.py +19 -19
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/fiscalapi/services/fiscalapi_client.py +17 -17
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/fiscalapi/services/invoice_service.py +65 -65
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/fiscalapi/services/people_service.py +32 -32
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/fiscalapi/services/product_service.py +31 -31
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/fiscalapi/services/tax_file_servive.py +40 -40
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/fiscalapi.egg-info/PKG-INFO +337 -336
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/fiscalapi.egg-info/requires.txt +1 -0
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/setup.cfg +4 -4
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/setup.py +53 -52
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/LICENSE.txt +0 -0
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/fiscalapi/models/__init__.py +0 -0
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/fiscalapi/services/__init__.py +0 -0
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/fiscalapi.egg-info/SOURCES.txt +0 -0
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/fiscalapi.egg-info/dependency_links.txt +0 -0
- {fiscalapi-4.0.2 → fiscalapi-4.0.12}/fiscalapi.egg-info/top_level.txt +0 -0
|
@@ -1,336 +1,337 @@
|
|
|
1
|
-
Metadata-Version: 2.2
|
|
2
|
-
Name: fiscalapi
|
|
3
|
-
Version: 4.0.
|
|
4
|
-
Summary: Genera facturas CFDI válidas ante el SAT consumiendo el API de https://www.fiscalapi.com
|
|
5
|
-
Home-page: https://www.fiscalapi.com
|
|
6
|
-
Author: Fiscalapi
|
|
7
|
-
Author-email: contacto@fiscalapi.com
|
|
8
|
-
License: MPL-2.0
|
|
9
|
-
Keywords: factura,cfdi,facturacion,mexico,sat,fiscalapi
|
|
10
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
-
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
14
|
-
Classifier: Topic :: Office/Business :: Financial
|
|
15
|
-
Requires-Python: >=3.7
|
|
16
|
-
Description-Content-Type: text/markdown
|
|
17
|
-
License-File: LICENSE.txt
|
|
18
|
-
Requires-Dist: pydantic>=2.0.0
|
|
19
|
-
Requires-Dist: requests>=2.0.0
|
|
20
|
-
Requires-Dist: urllib3>=1.0.0
|
|
21
|
-
Requires-Dist: certifi>=2023.0.0
|
|
22
|
-
|
|
23
|
-
Dynamic: author
|
|
24
|
-
Dynamic:
|
|
25
|
-
Dynamic:
|
|
26
|
-
Dynamic: description
|
|
27
|
-
Dynamic:
|
|
28
|
-
Dynamic:
|
|
29
|
-
Dynamic:
|
|
30
|
-
Dynamic:
|
|
31
|
-
Dynamic: requires-
|
|
32
|
-
Dynamic:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
[](https://badge.fury.io/py/fiscalapi)
|
|
38
|
+
[](https://github.com/FiscalAPI/fiscalapi-python/blob/main/LICENSE.txt)
|
|
39
|
+
|
|
40
|
+
**SDK oficial de FiscalAPI para Python**, la API de facturación CFDI y otros servicios fiscales en México. Simplifica la integración con los servicios de facturación electrónica, eliminando las complejidades del SAT y facilitando la generación de facturas, notas de crédito, complementos de pago, nómina, carta porte, y más. ¡Facturar sin dolor ahora es posible!
|
|
41
|
+
|
|
42
|
+
## 🚀 Características
|
|
43
|
+
|
|
44
|
+
- Soporte completo para **CFDI 4.0**
|
|
45
|
+
- Compatible con Python 3.7+
|
|
46
|
+
- Dos modos de operación: **Por valores** o **Por referencias**
|
|
47
|
+
- Manejo simplificado de errores
|
|
48
|
+
- Búsqueda en catálogos del SAT
|
|
49
|
+
- Documentación completa y ejemplos prácticos
|
|
50
|
+
|
|
51
|
+
## 📦 Instalación
|
|
52
|
+
|
|
53
|
+
**pip**:
|
|
54
|
+
```bash
|
|
55
|
+
pip install fiscalapi
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**poetry**:
|
|
59
|
+
```bash
|
|
60
|
+
poetry add fiscalapi
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## ⚙️ Configuración
|
|
64
|
+
|
|
65
|
+
### Configuración Básica
|
|
66
|
+
|
|
67
|
+
1. **Crea un objeto de configuración** con [tus credenciales](https://docs.fiscalapi.com/credentials-info):
|
|
68
|
+
```python
|
|
69
|
+
from fiscalapi.models.common_models import FiscalApiSettings
|
|
70
|
+
|
|
71
|
+
settings = FiscalApiSettings(
|
|
72
|
+
api_url="https://test.fiscalapi.com", # https://live.fiscalapi.com (producción)
|
|
73
|
+
api_key="<API_KEY>",
|
|
74
|
+
tenant="<TENANT_KEY>"
|
|
75
|
+
)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
2. **Crea la instancia del cliente**:
|
|
79
|
+
```python
|
|
80
|
+
from fiscalapi.services.fiscalapi_client import FiscalApiClient
|
|
81
|
+
|
|
82
|
+
client = FiscalApiClient(settings=settings)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## 🔄 Modos de Operación
|
|
86
|
+
|
|
87
|
+
FiscalAPI admite dos [modos de operación](https://docs.fiscalapi.com/modes-of-operation):
|
|
88
|
+
|
|
89
|
+
- **Por Referencias**: Envía solo IDs de objetos previamente creados en el dashboard de FiscalAPI.
|
|
90
|
+
Ideal para integraciones ligeras.
|
|
91
|
+
|
|
92
|
+
- **Por Valores**: Envía todos los campos requeridos en cada petición, con mayor control sobre los datos.
|
|
93
|
+
No se requiere configuración previa en el dashboard.
|
|
94
|
+
|
|
95
|
+
## 📝 Ejemplos de Uso
|
|
96
|
+
|
|
97
|
+
### 1. Crear una Persona (Emisor o Receptor)
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from fiscalapi.models.fiscalapi_models import Person
|
|
101
|
+
|
|
102
|
+
person = Person(
|
|
103
|
+
legal_name="Empresa Python SA de CV",
|
|
104
|
+
email="mail7@gmail.com",
|
|
105
|
+
password="TestPassword1234!"
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
api_response = client.people.create(person)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 2. Subir Certificados CSD
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
from fiscalapi.models.fiscalapi_models import TaxFile
|
|
115
|
+
|
|
116
|
+
# Subir certificado (CER)
|
|
117
|
+
certificado_csd = TaxFile(
|
|
118
|
+
person_id="3f3478b4-60fd-459e-8bfc-f8239fc96257",
|
|
119
|
+
tin="FUNK671228PH6",
|
|
120
|
+
base64_file="MIIFgDCCA2igAwIBAgIUMzAwMDEwMDAwMDA1MDAwMDM0NDYwDQYJKo...",
|
|
121
|
+
file_type=0, # 0 para certificado, 1 para llave privada
|
|
122
|
+
password="12345678a"
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
# Subir llave privada (KEY)
|
|
126
|
+
clave_privada_csd = TaxFile(
|
|
127
|
+
person_id="3f3478b4-60fd-459e-8bfc-f8239fc96257",
|
|
128
|
+
tin="FUNK671228PH6",
|
|
129
|
+
base64_file="MIIFDjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQIAg...",
|
|
130
|
+
file_type=1,
|
|
131
|
+
password="12345678a"
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
api_response_cer = client.tax_files.create(certificado_csd)
|
|
135
|
+
api_response_key = client.tax_files.create(clave_privada_csd)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 3. Crear un Producto o Servicio
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
from fiscalapi.models.fiscalapi_models import Product
|
|
142
|
+
|
|
143
|
+
product = Product(
|
|
144
|
+
description="Producto python sin impuestos",
|
|
145
|
+
unit_price=Decimal("100.00")
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
api_response = client.products.create(product)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### 4. Actualizar Impuestos de un Producto
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
from fiscalapi.models.fiscalapi_models import Product, ProductTax
|
|
155
|
+
|
|
156
|
+
product = Product(
|
|
157
|
+
id="f4bf4df3-5a91-4a30-b137-52cb517d13c4",
|
|
158
|
+
description="Producto python sin impuestos",
|
|
159
|
+
unit_price=Decimal("100.00"),
|
|
160
|
+
product_taxes=[
|
|
161
|
+
ProductTax(
|
|
162
|
+
rate=Decimal("0.160000"),
|
|
163
|
+
taxId="002",
|
|
164
|
+
taxFlagId="T",
|
|
165
|
+
taxTypeId="Tasa"
|
|
166
|
+
),
|
|
167
|
+
ProductTax(
|
|
168
|
+
rate=Decimal("0.106667"),
|
|
169
|
+
taxId="002",
|
|
170
|
+
taxFlagId="R",
|
|
171
|
+
taxTypeId="Tasa"
|
|
172
|
+
),
|
|
173
|
+
ProductTax(
|
|
174
|
+
rate=Decimal("0.100000"),
|
|
175
|
+
taxId="001",
|
|
176
|
+
taxFlagId="R",
|
|
177
|
+
taxTypeId="Tasa"
|
|
178
|
+
)
|
|
179
|
+
]
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
api_response = client.products.update(product)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### 5. Crear una Factura de Ingreso (Por Referencias)
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
from datetime import datetime
|
|
189
|
+
from decimal import Decimal
|
|
190
|
+
from fiscalapi.models.fiscalapi_models import Invoice, InvoiceIssuer, InvoiceItem, InvoiceRecipient
|
|
191
|
+
|
|
192
|
+
invoice = Invoice(
|
|
193
|
+
version_code="4.0",
|
|
194
|
+
series="F",
|
|
195
|
+
date=datetime.now().strftime("%Y-%m-%dT%H:%M:%S"),
|
|
196
|
+
payment_form_code="01",
|
|
197
|
+
payment_conditions="Contado",
|
|
198
|
+
currency_code="MXN",
|
|
199
|
+
type_code="I",
|
|
200
|
+
expedition_zip_code="42501",
|
|
201
|
+
payment_method_code="PUE",
|
|
202
|
+
exchange_rate=1,
|
|
203
|
+
export_code="01",
|
|
204
|
+
issuer=InvoiceIssuer(
|
|
205
|
+
id="3f3478b4-60fd-459e-8bfc-f8239fc96257"
|
|
206
|
+
),
|
|
207
|
+
recipient=InvoiceRecipient(
|
|
208
|
+
id="96b46762-d246-4a67-a562-510a25dbafa9"
|
|
209
|
+
),
|
|
210
|
+
items=[
|
|
211
|
+
InvoiceItem(
|
|
212
|
+
id="114a4be5-fb65-40b2-a762-ff0c55c6ebfa",
|
|
213
|
+
quantity=Decimal("1.5"),
|
|
214
|
+
discount=Decimal("255.85")
|
|
215
|
+
)
|
|
216
|
+
]
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
api_response = client.invoices.create(invoice)
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### 6. Crear la Misma Factura de Ingreso (Por Valores)
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
from fiscalapi.models.fiscalapi_models import Invoice, InvoiceIssuer, InvoiceItem, InvoiceRecipient, ItemTax, TaxCredential
|
|
226
|
+
|
|
227
|
+
invoice = Invoice(
|
|
228
|
+
version_code="4.0",
|
|
229
|
+
series="F",
|
|
230
|
+
date=datetime.now().strftime("%Y-%m-%dT%H:%M:%S"),
|
|
231
|
+
payment_form_code="01",
|
|
232
|
+
currency_code="MXN",
|
|
233
|
+
type_code="I",
|
|
234
|
+
expedition_zip_code="42501",
|
|
235
|
+
payment_method_code="PUE",
|
|
236
|
+
exchange_rate=1,
|
|
237
|
+
export_code="01",
|
|
238
|
+
issuer=InvoiceIssuer(
|
|
239
|
+
tin="FUNK671228PH6",
|
|
240
|
+
legal_name="KARLA FUENTE NOLASCO",
|
|
241
|
+
tax_regime_code="621",
|
|
242
|
+
tax_credentials=[
|
|
243
|
+
TaxCredential(
|
|
244
|
+
base64_file="MIIFgDCCA2igAwIBAgIUMzAwMDEwMDAwMDA1MDAwMDM0NDYwDQYJKo...",
|
|
245
|
+
file_type=0,
|
|
246
|
+
password="12345678a"
|
|
247
|
+
),
|
|
248
|
+
TaxCredential(
|
|
249
|
+
base64_file="MIIFDjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQIAg...",
|
|
250
|
+
file_type=1,
|
|
251
|
+
password="12345678a"
|
|
252
|
+
)
|
|
253
|
+
]
|
|
254
|
+
),
|
|
255
|
+
recipient=InvoiceRecipient(
|
|
256
|
+
tin="EKU9003173C9",
|
|
257
|
+
legal_name="ESCUELA KEMPER URGATE",
|
|
258
|
+
zip_code="42501",
|
|
259
|
+
tax_regime_code="601",
|
|
260
|
+
cfdi_use_code="G01",
|
|
261
|
+
email="mail@domain.com"
|
|
262
|
+
),
|
|
263
|
+
items=[
|
|
264
|
+
InvoiceItem(
|
|
265
|
+
item_code="84111506",
|
|
266
|
+
quantity=Decimal("9.5"),
|
|
267
|
+
unit_of_measurement_code="E48",
|
|
268
|
+
description="Invoicing software as a service",
|
|
269
|
+
unit_price=Decimal("3587.75"),
|
|
270
|
+
tax_object_code="02",
|
|
271
|
+
item_sku="7506022301697",
|
|
272
|
+
discount=Decimal("255.85"),
|
|
273
|
+
item_taxes=[
|
|
274
|
+
ItemTax(
|
|
275
|
+
tax_code="002",
|
|
276
|
+
tax_type_code="Tasa",
|
|
277
|
+
tax_rate=Decimal("0.160000"),
|
|
278
|
+
tax_flag_code="T"
|
|
279
|
+
)
|
|
280
|
+
]
|
|
281
|
+
)
|
|
282
|
+
]
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
api_response = client.invoices.create(invoice)
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### 7. Búsqueda en Catálogos del SAT
|
|
289
|
+
|
|
290
|
+
```python
|
|
291
|
+
# Buscar registros que contengan 'inter' en el catalogo 'SatUnitMeasurements' (página 1, tamaño página 10)
|
|
292
|
+
api_response = client.catalogs.search_catalog("SatUnitMeasurements", "inter", 1, 10)
|
|
293
|
+
|
|
294
|
+
if api_response.succeeded:
|
|
295
|
+
for item in api_response.data.items:
|
|
296
|
+
print(f"Unidad: {item.description}")
|
|
297
|
+
else:
|
|
298
|
+
print(api_response.message)
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
## 📋 Operaciones Principales
|
|
302
|
+
|
|
303
|
+
- **Facturas (CFDI)**
|
|
304
|
+
Crear facturas de ingreso, notas de crédito, complementos de pago, cancelaciones, generación de PDF/XML.
|
|
305
|
+
- **Personas (Clientes/Emisores)**
|
|
306
|
+
Alta y administración de personas, gestión de certificados (CSD).
|
|
307
|
+
- **Productos y Servicios**
|
|
308
|
+
Administración de catálogos de productos, búsqueda en catálogos SAT.
|
|
309
|
+
|
|
310
|
+
## 🤝 Contribuir
|
|
311
|
+
|
|
312
|
+
1. Haz un fork del repositorio.
|
|
313
|
+
2. Crea una rama para tu feature: `git checkout -b feature/AmazingFeature`
|
|
314
|
+
3. Realiza commits de tus cambios: `git commit -m 'Add some AmazingFeature'`
|
|
315
|
+
4. Sube tu rama: `git push origin feature/AmazingFeature`
|
|
316
|
+
5. Abre un Pull Request en GitHub.
|
|
317
|
+
|
|
318
|
+
## 🐛 Reportar Problemas
|
|
319
|
+
|
|
320
|
+
1. Asegúrate de usar la última versión del SDK.
|
|
321
|
+
2. Verifica si el problema ya fue reportado.
|
|
322
|
+
3. Proporciona un ejemplo mínimo reproducible.
|
|
323
|
+
4. Incluye los mensajes de error completos.
|
|
324
|
+
|
|
325
|
+
## 📄 Licencia
|
|
326
|
+
|
|
327
|
+
Este proyecto está licenciado bajo la Licencia **MPL**. Consulta el archivo [LICENSE](LICENSE.txt) para más detalles.
|
|
328
|
+
|
|
329
|
+
## 🔗 Enlaces Útiles
|
|
330
|
+
|
|
331
|
+
- [Documentación Oficial](https://docs.fiscalapi.com)
|
|
332
|
+
- [Portal de FiscalAPI](https://fiscalapi.com)
|
|
333
|
+
- [Ejemplos en Python](https://github.com/FiscalAPI/fiscalapi-samples-python)
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
Desarrollado con ❤️ por [Fiscalapi](https://www.fiscalapi.com)
|