catalogmx 0.3.0__py3-none-any.whl → 0.4.0__py3-none-any.whl
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.
- catalogmx/__init__.py +133 -19
- catalogmx/calculators/__init__.py +113 -0
- catalogmx/calculators/costo_trabajador.py +213 -0
- catalogmx/calculators/impuestos.py +920 -0
- catalogmx/calculators/imss.py +370 -0
- catalogmx/calculators/isr.py +290 -0
- catalogmx/calculators/resico.py +154 -0
- catalogmx/catalogs/banxico/__init__.py +29 -3
- catalogmx/catalogs/banxico/cetes_sqlite.py +279 -0
- catalogmx/catalogs/banxico/inflacion_sqlite.py +302 -0
- catalogmx/catalogs/banxico/salarios_minimos_sqlite.py +295 -0
- catalogmx/catalogs/banxico/tiie_sqlite.py +279 -0
- catalogmx/catalogs/banxico/tipo_cambio_usd_sqlite.py +255 -0
- catalogmx/catalogs/banxico/udis_sqlite.py +332 -0
- catalogmx/catalogs/cnbv/__init__.py +9 -0
- catalogmx/catalogs/cnbv/sectores.py +173 -0
- catalogmx/catalogs/conapo/__init__.py +15 -0
- catalogmx/catalogs/conapo/sistema_urbano_nacional.py +50 -0
- catalogmx/catalogs/conapo/zonas_metropolitanas.py +230 -0
- catalogmx/catalogs/ift/__init__.py +1 -1
- catalogmx/catalogs/ift/codigos_lada.py +517 -313
- catalogmx/catalogs/inegi/__init__.py +17 -0
- catalogmx/catalogs/inegi/scian.py +127 -0
- catalogmx/catalogs/mexico/__init__.py +2 -0
- catalogmx/catalogs/mexico/giros_mercantiles.py +119 -0
- catalogmx/catalogs/sat/carta_porte/material_peligroso.py +5 -1
- catalogmx/catalogs/sat/cfdi_4/clave_prod_serv.py +78 -0
- catalogmx/catalogs/sat/cfdi_4/tasa_o_cuota.py +2 -1
- catalogmx/catalogs/sepomex/__init__.py +2 -1
- catalogmx/catalogs/sepomex/codigos_postales.py +30 -2
- catalogmx/catalogs/sepomex/codigos_postales_completo.py +261 -0
- catalogmx/cli.py +12 -9
- catalogmx/data/__init__.py +10 -0
- catalogmx/data/mexico_dynamic.sqlite3 +0 -0
- catalogmx/data/updater.py +362 -0
- catalogmx/generators/__init__.py +20 -0
- catalogmx/generators/identity.py +582 -0
- catalogmx/helpers.py +177 -3
- catalogmx/utils/__init__.py +29 -0
- catalogmx/utils/clabe_utils.py +417 -0
- catalogmx/utils/text.py +7 -1
- catalogmx/validators/clabe.py +52 -2
- catalogmx/validators/nss.py +32 -27
- catalogmx/validators/rfc.py +185 -52
- catalogmx-0.4.0.dist-info/METADATA +905 -0
- {catalogmx-0.3.0.dist-info → catalogmx-0.4.0.dist-info}/RECORD +51 -25
- {catalogmx-0.3.0.dist-info → catalogmx-0.4.0.dist-info}/WHEEL +1 -1
- catalogmx/catalogs/banxico/udis.py +0 -279
- catalogmx-0.3.0.dist-info/METADATA +0 -644
- {catalogmx-0.3.0.dist-info → catalogmx-0.4.0.dist-info}/entry_points.txt +0 -0
- {catalogmx-0.3.0.dist-info → catalogmx-0.4.0.dist-info}/licenses/AUTHORS.rst +0 -0
- {catalogmx-0.3.0.dist-info → catalogmx-0.4.0.dist-info}/licenses/LICENSE +0 -0
- {catalogmx-0.3.0.dist-info → catalogmx-0.4.0.dist-info}/top_level.txt +0 -0
catalogmx/__init__.py
CHANGED
|
@@ -1,56 +1,170 @@
|
|
|
1
|
+
"""
|
|
2
|
+
catalogmx - Mexican Data Validation and Catalog Library
|
|
3
|
+
|
|
4
|
+
A comprehensive library for validating Mexican identifiers (RFC, CURP, CLABE, NSS),
|
|
5
|
+
accessing official catalogs (SAT, Banxico, INEGI, SEPOMEX, IFT, CNBV), and
|
|
6
|
+
calculating taxes and payroll (ISR, RESICO, IMSS, IVA, Costo del Trabajador).
|
|
7
|
+
|
|
8
|
+
Usage:
|
|
9
|
+
# Validators - Simple helper functions
|
|
10
|
+
from catalogmx import is_valid_rfc, is_valid_curp, is_valid_clabe, is_valid_nss
|
|
11
|
+
|
|
12
|
+
is_valid_rfc('PEGJ900515KL8') # True
|
|
13
|
+
is_valid_curp('PEGJ900515HJCRRN05') # True
|
|
14
|
+
is_valid_clabe('002010077777777771') # True
|
|
15
|
+
is_valid_nss('12345678903') # True
|
|
16
|
+
|
|
17
|
+
# Generators
|
|
18
|
+
from catalogmx import generate_rfc_persona_fisica, generate_curp, generate_clabe
|
|
19
|
+
|
|
20
|
+
rfc = generate_rfc_persona_fisica(
|
|
21
|
+
nombre='Juan',
|
|
22
|
+
apellido_paterno='Pérez',
|
|
23
|
+
apellido_materno='García',
|
|
24
|
+
fecha_nacimiento='1990-05-15'
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
clabe = generate_clabe(
|
|
28
|
+
bank_code='002', # Banamex
|
|
29
|
+
branch_code='010', # Branch
|
|
30
|
+
account_number='07777777777'
|
|
31
|
+
) # Returns: '002010077777777771'
|
|
32
|
+
|
|
33
|
+
# Calculators
|
|
34
|
+
from catalogmx.calculators import calculate_isr, calculate_resico
|
|
35
|
+
from catalogmx.calculators import calcular_cuotas_obrero_patronales
|
|
36
|
+
from catalogmx.calculators import IVACalculator, calcular_costo_total
|
|
37
|
+
|
|
38
|
+
# Catalogs
|
|
39
|
+
from catalogmx.catalogs.sat.cfdi_4 import FormaPago, MetodoPago, UsoCFDI
|
|
40
|
+
from catalogmx.catalogs.banxico import Banks
|
|
41
|
+
from catalogmx.catalogs.inegi import States, Municipios
|
|
42
|
+
from catalogmx.catalogs.sepomex import CodigosPostales
|
|
43
|
+
"""
|
|
44
|
+
|
|
1
45
|
__version__ = "0.3.0"
|
|
2
46
|
|
|
3
|
-
#
|
|
4
|
-
# Modern
|
|
5
|
-
|
|
47
|
+
# =============================================================================
|
|
48
|
+
# Modern Helper Functions (recommended API)
|
|
49
|
+
# =============================================================================
|
|
50
|
+
from catalogmx.helpers import (
|
|
51
|
+
# RFC helpers
|
|
6
52
|
detect_rfc_type,
|
|
53
|
+
# CLABE helpers
|
|
54
|
+
generate_clabe,
|
|
55
|
+
generate_clabe_random,
|
|
7
56
|
# CURP helpers
|
|
8
57
|
generate_curp,
|
|
9
|
-
# RFC helpers
|
|
10
58
|
generate_rfc_persona_fisica,
|
|
11
59
|
generate_rfc_persona_moral,
|
|
60
|
+
get_clabe_info,
|
|
12
61
|
get_curp_info,
|
|
62
|
+
# NSS helpers
|
|
63
|
+
get_nss_info,
|
|
64
|
+
# Utility
|
|
65
|
+
get_project_root,
|
|
66
|
+
is_valid_clabe,
|
|
13
67
|
is_valid_curp,
|
|
68
|
+
is_valid_nss,
|
|
14
69
|
is_valid_rfc,
|
|
70
|
+
validate_clabe,
|
|
15
71
|
validate_curp,
|
|
72
|
+
validate_nss,
|
|
16
73
|
validate_rfc,
|
|
17
74
|
)
|
|
18
75
|
|
|
19
|
-
#
|
|
20
|
-
|
|
76
|
+
# =============================================================================
|
|
77
|
+
# Validator Classes (for advanced usage)
|
|
78
|
+
# =============================================================================
|
|
79
|
+
from catalogmx.validators.clabe import (
|
|
80
|
+
CLABECheckDigitError,
|
|
81
|
+
CLABEException,
|
|
82
|
+
CLABELengthError,
|
|
83
|
+
CLABEStructureError,
|
|
84
|
+
CLABEValidator,
|
|
85
|
+
)
|
|
86
|
+
from catalogmx.validators.curp import (
|
|
21
87
|
CURPException,
|
|
22
88
|
CURPGenerator,
|
|
23
89
|
CURPLengthError,
|
|
24
90
|
CURPStructureError,
|
|
25
91
|
CURPValidator,
|
|
26
92
|
)
|
|
27
|
-
from .validators.
|
|
93
|
+
from catalogmx.validators.nss import (
|
|
94
|
+
NSSCheckDigitError,
|
|
95
|
+
NSSException,
|
|
96
|
+
NSSLengthError,
|
|
97
|
+
NSSStructureError,
|
|
98
|
+
NSSValidator,
|
|
99
|
+
)
|
|
100
|
+
from catalogmx.validators.rfc import (
|
|
28
101
|
RFCGenerator,
|
|
29
102
|
RFCGeneratorFisicas,
|
|
30
103
|
RFCGeneratorMorales,
|
|
31
104
|
RFCValidator,
|
|
32
105
|
)
|
|
33
106
|
|
|
107
|
+
# =============================================================================
|
|
108
|
+
# Generators (identity generation with Faker - optional dependency)
|
|
109
|
+
# =============================================================================
|
|
110
|
+
# Note: Requires faker package - install with: pip install catalogmx[generators]
|
|
111
|
+
# from catalogmx.generators import generate_identity, generate_persona_fisica, generate_persona_moral
|
|
112
|
+
|
|
113
|
+
# =============================================================================
|
|
114
|
+
# Submodules (import as needed)
|
|
115
|
+
# =============================================================================
|
|
116
|
+
# Catalogs: from catalogmx import catalogs
|
|
117
|
+
# Calculators: from catalogmx import calculators
|
|
118
|
+
# Validators: from catalogmx import validators
|
|
119
|
+
# Generators: from catalogmx.generators import generate_identity
|
|
120
|
+
|
|
34
121
|
__all__ = [
|
|
35
|
-
#
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
"RFCGeneratorFisicas",
|
|
39
|
-
"RFCGeneratorMorales",
|
|
40
|
-
# CURP Classes (legacy/advanced usage)
|
|
41
|
-
"CURPValidator",
|
|
42
|
-
"CURPGenerator",
|
|
43
|
-
"CURPException",
|
|
44
|
-
"CURPLengthError",
|
|
45
|
-
"CURPStructureError",
|
|
46
|
-
# Modern helper functions (recommended)
|
|
122
|
+
# Version
|
|
123
|
+
"__version__",
|
|
124
|
+
# RFC Helper Functions
|
|
47
125
|
"generate_rfc_persona_fisica",
|
|
48
126
|
"generate_rfc_persona_moral",
|
|
49
127
|
"validate_rfc",
|
|
50
128
|
"detect_rfc_type",
|
|
51
129
|
"is_valid_rfc",
|
|
130
|
+
# RFC Classes
|
|
131
|
+
"RFCValidator",
|
|
132
|
+
"RFCGenerator",
|
|
133
|
+
"RFCGeneratorFisicas",
|
|
134
|
+
"RFCGeneratorMorales",
|
|
135
|
+
# CURP Helper Functions
|
|
52
136
|
"generate_curp",
|
|
53
137
|
"validate_curp",
|
|
54
138
|
"get_curp_info",
|
|
55
139
|
"is_valid_curp",
|
|
140
|
+
# CURP Classes
|
|
141
|
+
"CURPValidator",
|
|
142
|
+
"CURPGenerator",
|
|
143
|
+
"CURPException",
|
|
144
|
+
"CURPLengthError",
|
|
145
|
+
"CURPStructureError",
|
|
146
|
+
# CLABE Helper Functions
|
|
147
|
+
"generate_clabe",
|
|
148
|
+
"generate_clabe_random",
|
|
149
|
+
"validate_clabe",
|
|
150
|
+
"get_clabe_info",
|
|
151
|
+
"is_valid_clabe",
|
|
152
|
+
# CLABE Classes
|
|
153
|
+
"CLABEValidator",
|
|
154
|
+
"CLABEException",
|
|
155
|
+
"CLABELengthError",
|
|
156
|
+
"CLABEStructureError",
|
|
157
|
+
"CLABECheckDigitError",
|
|
158
|
+
# NSS Helper Functions
|
|
159
|
+
"validate_nss",
|
|
160
|
+
"get_nss_info",
|
|
161
|
+
"is_valid_nss",
|
|
162
|
+
# NSS Classes
|
|
163
|
+
"NSSValidator",
|
|
164
|
+
"NSSException",
|
|
165
|
+
"NSSLengthError",
|
|
166
|
+
"NSSStructureError",
|
|
167
|
+
"NSSCheckDigitError",
|
|
168
|
+
# Utility
|
|
169
|
+
"get_project_root",
|
|
56
170
|
]
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Calculators for Mexican taxes and payroll
|
|
3
|
+
|
|
4
|
+
Available calculators:
|
|
5
|
+
- ISR (Impuesto Sobre la Renta) - Income Tax
|
|
6
|
+
- RESICO (Régimen Simplificado de Confianza) - Simplified Trust Regime
|
|
7
|
+
- IMSS (Instituto Mexicano del Seguro Social) - Social Security Contributions
|
|
8
|
+
- IVA (Impuesto al Valor Agregado) - Value Added Tax
|
|
9
|
+
- IEPS (Impuesto Especial sobre Producción y Servicios) - Special Production and Services Tax
|
|
10
|
+
- Retenciones (Withholdings) - ISR and IVA withholdings
|
|
11
|
+
- Impuestos Locales (Local Taxes) - State and municipal taxes
|
|
12
|
+
- Costo Trabajador (Worker Cost) - Total cost of employing a worker
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from catalogmx.calculators.costo_trabajador import (
|
|
16
|
+
CostoTotalResult,
|
|
17
|
+
calcular_costo_total,
|
|
18
|
+
obtener_dias_vacaciones,
|
|
19
|
+
)
|
|
20
|
+
from catalogmx.calculators.impuestos import (
|
|
21
|
+
IEPSCalculationResult,
|
|
22
|
+
IEPSCalculator,
|
|
23
|
+
IEPSCategoria,
|
|
24
|
+
IEPSTasa,
|
|
25
|
+
ImpuestoEstatal,
|
|
26
|
+
ImpuestosLocalesCalculator,
|
|
27
|
+
IVACalculationResult,
|
|
28
|
+
IVACalculator,
|
|
29
|
+
IVATasa,
|
|
30
|
+
RetencionCalculationResult,
|
|
31
|
+
RetencionCalculator,
|
|
32
|
+
RetencionISR,
|
|
33
|
+
RetencionIVA,
|
|
34
|
+
)
|
|
35
|
+
from catalogmx.calculators.imss import (
|
|
36
|
+
ClaseRiesgo,
|
|
37
|
+
CuotasIMSSResult,
|
|
38
|
+
IMSSYear,
|
|
39
|
+
Modalidad10Result,
|
|
40
|
+
Modalidad40Result,
|
|
41
|
+
UMAInfo,
|
|
42
|
+
ZonaSalario,
|
|
43
|
+
calcular_cuotas_obrero_patronales,
|
|
44
|
+
calcular_modalidad_10,
|
|
45
|
+
calcular_modalidad_40,
|
|
46
|
+
get_salario_minimo,
|
|
47
|
+
get_uma,
|
|
48
|
+
)
|
|
49
|
+
from catalogmx.calculators.isr import (
|
|
50
|
+
ISRCalculationResult,
|
|
51
|
+
ISRPeriod,
|
|
52
|
+
ISRYear,
|
|
53
|
+
calculate_isr,
|
|
54
|
+
calculate_subsidy,
|
|
55
|
+
get_isr_brackets,
|
|
56
|
+
)
|
|
57
|
+
from catalogmx.calculators.resico import (
|
|
58
|
+
RESICOCalculationResult,
|
|
59
|
+
RESICOPeriod,
|
|
60
|
+
RESICOYear,
|
|
61
|
+
calculate_resico,
|
|
62
|
+
get_resico_brackets,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
__all__ = [
|
|
66
|
+
# ISR
|
|
67
|
+
"calculate_isr",
|
|
68
|
+
"get_isr_brackets",
|
|
69
|
+
"calculate_subsidy",
|
|
70
|
+
"ISRYear",
|
|
71
|
+
"ISRPeriod",
|
|
72
|
+
"ISRCalculationResult",
|
|
73
|
+
# RESICO
|
|
74
|
+
"calculate_resico",
|
|
75
|
+
"get_resico_brackets",
|
|
76
|
+
"RESICOYear",
|
|
77
|
+
"RESICOPeriod",
|
|
78
|
+
"RESICOCalculationResult",
|
|
79
|
+
# IMSS
|
|
80
|
+
"calcular_cuotas_obrero_patronales",
|
|
81
|
+
"calcular_modalidad_40",
|
|
82
|
+
"calcular_modalidad_10",
|
|
83
|
+
"get_uma",
|
|
84
|
+
"get_salario_minimo",
|
|
85
|
+
"IMSSYear",
|
|
86
|
+
"ZonaSalario",
|
|
87
|
+
"ClaseRiesgo",
|
|
88
|
+
"CuotasIMSSResult",
|
|
89
|
+
"Modalidad40Result",
|
|
90
|
+
"Modalidad10Result",
|
|
91
|
+
"UMAInfo",
|
|
92
|
+
# IVA
|
|
93
|
+
"IVACalculator",
|
|
94
|
+
"IVACalculationResult",
|
|
95
|
+
"IVATasa",
|
|
96
|
+
# IEPS
|
|
97
|
+
"IEPSCalculator",
|
|
98
|
+
"IEPSCalculationResult",
|
|
99
|
+
"IEPSCategoria",
|
|
100
|
+
"IEPSTasa",
|
|
101
|
+
# Retenciones
|
|
102
|
+
"RetencionCalculator",
|
|
103
|
+
"RetencionCalculationResult",
|
|
104
|
+
"RetencionISR",
|
|
105
|
+
"RetencionIVA",
|
|
106
|
+
# Impuestos Locales
|
|
107
|
+
"ImpuestosLocalesCalculator",
|
|
108
|
+
"ImpuestoEstatal",
|
|
109
|
+
# Costo Trabajador
|
|
110
|
+
"calcular_costo_total",
|
|
111
|
+
"obtener_dias_vacaciones",
|
|
112
|
+
"CostoTotalResult",
|
|
113
|
+
]
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Costo Total del Trabajador Calculator for Mexico
|
|
3
|
+
Calculates the true cost of hiring an employee in Mexico including all contributions and reserves
|
|
4
|
+
|
|
5
|
+
Official sources:
|
|
6
|
+
- Ley Federal del Trabajo (LFT)
|
|
7
|
+
- IMSS contribution tables
|
|
8
|
+
- Infonavit contributions
|
|
9
|
+
- State payroll tax laws
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from typing import TypedDict
|
|
13
|
+
|
|
14
|
+
from catalogmx.calculators.impuestos import ImpuestosLocalesCalculator
|
|
15
|
+
from catalogmx.calculators.imss import IMSSYear, calcular_cuotas_obrero_patronales
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class CostoTotalResult(TypedDict):
|
|
19
|
+
"""Total worker cost calculation result"""
|
|
20
|
+
|
|
21
|
+
salario_bruto_mensual: float
|
|
22
|
+
cuotas_imss_patronales: float
|
|
23
|
+
infonavit: float
|
|
24
|
+
impuesto_nomina: float
|
|
25
|
+
reserva_aguinaldo: float
|
|
26
|
+
reserva_prima_vacacional: float
|
|
27
|
+
reserva_vacaciones: float
|
|
28
|
+
ptu_estimado: float
|
|
29
|
+
costo_total_mensual: float
|
|
30
|
+
costo_total_anual: float
|
|
31
|
+
factor_costo: float
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# Vacation days according to LFT 2023 (Article 76)
|
|
35
|
+
DIAS_VACACIONES_POR_ANTIGUEDAD = {
|
|
36
|
+
1: 12,
|
|
37
|
+
2: 14,
|
|
38
|
+
3: 16,
|
|
39
|
+
4: 18,
|
|
40
|
+
5: 20,
|
|
41
|
+
6: 22,
|
|
42
|
+
7: 22,
|
|
43
|
+
8: 22,
|
|
44
|
+
9: 22,
|
|
45
|
+
10: 22,
|
|
46
|
+
11: 24,
|
|
47
|
+
12: 24,
|
|
48
|
+
13: 24,
|
|
49
|
+
14: 24,
|
|
50
|
+
15: 24,
|
|
51
|
+
16: 26,
|
|
52
|
+
17: 26,
|
|
53
|
+
18: 26,
|
|
54
|
+
19: 26,
|
|
55
|
+
20: 26,
|
|
56
|
+
21: 28,
|
|
57
|
+
22: 28,
|
|
58
|
+
23: 28,
|
|
59
|
+
24: 28,
|
|
60
|
+
25: 28,
|
|
61
|
+
26: 30,
|
|
62
|
+
27: 30,
|
|
63
|
+
28: 30,
|
|
64
|
+
29: 30,
|
|
65
|
+
30: 30,
|
|
66
|
+
31: 32,
|
|
67
|
+
32: 32,
|
|
68
|
+
33: 32,
|
|
69
|
+
34: 32,
|
|
70
|
+
35: 32,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def obtener_dias_vacaciones(antiguedad_anos: int) -> int:
|
|
75
|
+
"""
|
|
76
|
+
Get vacation days based on seniority according to LFT 2023
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
antiguedad_anos: Years of seniority (1-35+)
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
Number of vacation days
|
|
83
|
+
|
|
84
|
+
Examples:
|
|
85
|
+
>>> obtener_dias_vacaciones(1)
|
|
86
|
+
12
|
|
87
|
+
>>> obtener_dias_vacaciones(5)
|
|
88
|
+
20
|
|
89
|
+
>>> obtener_dias_vacaciones(40)
|
|
90
|
+
32
|
|
91
|
+
"""
|
|
92
|
+
if antiguedad_anos <= 0:
|
|
93
|
+
return 12
|
|
94
|
+
elif antiguedad_anos <= 35:
|
|
95
|
+
return DIAS_VACACIONES_POR_ANTIGUEDAD.get(antiguedad_anos, 32)
|
|
96
|
+
else:
|
|
97
|
+
return 32
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def calcular_costo_total(
|
|
101
|
+
salario_mensual_bruto: float,
|
|
102
|
+
cve_estado: str = "09",
|
|
103
|
+
antiguedad_anos: int = 1,
|
|
104
|
+
dias_aguinaldo: int = 15,
|
|
105
|
+
incluir_ptu: bool = False,
|
|
106
|
+
porcentaje_ptu: float = 10.0,
|
|
107
|
+
year: IMSSYear = 2026,
|
|
108
|
+
) -> CostoTotalResult:
|
|
109
|
+
"""
|
|
110
|
+
Calculate the total cost of employing a worker in Mexico
|
|
111
|
+
|
|
112
|
+
This calculator helps employers understand the true cost of hiring someone
|
|
113
|
+
by including all mandatory contributions, taxes, and labor law reserves.
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
salario_mensual_bruto: Monthly gross salary (base pay)
|
|
117
|
+
cve_estado: State code for payroll tax calculation (default: "09" CDMX)
|
|
118
|
+
antiguedad_anos: Years of seniority (affects vacation days, default: 1)
|
|
119
|
+
dias_aguinaldo: Aguinaldo days (minimum 15, default: 15)
|
|
120
|
+
incluir_ptu: Include PTU (profit sharing) reserve (default: False)
|
|
121
|
+
porcentaje_ptu: PTU percentage if included (default: 10.0%)
|
|
122
|
+
year: Year for IMSS calculations (default: 2026)
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
Complete breakdown of employer costs including:
|
|
126
|
+
- IMSS employer contributions
|
|
127
|
+
- Infonavit (5% of SBC)
|
|
128
|
+
- Payroll tax (varies by state)
|
|
129
|
+
- Aguinaldo reserve
|
|
130
|
+
- Vacation bonus reserve
|
|
131
|
+
- Vacation pay reserve
|
|
132
|
+
- Optional PTU reserve
|
|
133
|
+
|
|
134
|
+
Examples:
|
|
135
|
+
>>> # Calculate cost for $15,000/month employee in CDMX
|
|
136
|
+
>>> result = calcular_costo_total(15000, "09", 1)
|
|
137
|
+
>>> print(f"Total monthly cost: ${result['costo_total_mensual']:.2f}")
|
|
138
|
+
Total monthly cost: $18750.00
|
|
139
|
+
|
|
140
|
+
>>> # Calculate with PTU included
|
|
141
|
+
>>> result = calcular_costo_total(20000, "09", 3, incluir_ptu=True)
|
|
142
|
+
>>> print(f"Factor: {result['factor_costo']:.2f}x")
|
|
143
|
+
Factor: 1.35x
|
|
144
|
+
"""
|
|
145
|
+
# 1. Calculate daily wage (assuming 30-day month for calculation purposes)
|
|
146
|
+
salario_diario = salario_mensual_bruto / 30.0
|
|
147
|
+
|
|
148
|
+
# 2. Calculate IMSS employer contributions
|
|
149
|
+
cuotas_imss = calcular_cuotas_obrero_patronales(
|
|
150
|
+
salario_diario=salario_diario, dias=30, year=year
|
|
151
|
+
)
|
|
152
|
+
cuotas_imss_patronales = cuotas_imss["total_patron"]
|
|
153
|
+
|
|
154
|
+
# 3. Calculate Infonavit (5% of SBC)
|
|
155
|
+
salario_base_cotizacion = cuotas_imss["salario_base_cotizacion"]
|
|
156
|
+
infonavit = salario_base_cotizacion * 0.05
|
|
157
|
+
|
|
158
|
+
# 4. Calculate payroll tax (varies by state, typically 2-3%)
|
|
159
|
+
impuesto_nomina = ImpuestosLocalesCalculator.calcular_impuesto_nomina(
|
|
160
|
+
total_percepciones=salario_mensual_bruto, cve_estado=cve_estado
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
# 5. Calculate monthly reserves
|
|
164
|
+
|
|
165
|
+
# Aguinaldo: dias_aguinaldo / 12 months
|
|
166
|
+
reserva_aguinaldo = (salario_diario * dias_aguinaldo) / 12.0
|
|
167
|
+
|
|
168
|
+
# Vacation days based on seniority (LFT 2023)
|
|
169
|
+
dias_vacaciones = obtener_dias_vacaciones(antiguedad_anos)
|
|
170
|
+
|
|
171
|
+
# Vacation reserve: vacation days / 12 months
|
|
172
|
+
reserva_vacaciones = (salario_diario * dias_vacaciones) / 12.0
|
|
173
|
+
|
|
174
|
+
# Vacation bonus (prima vacacional): 25% of vacation days value
|
|
175
|
+
reserva_prima_vacacional = reserva_vacaciones * 0.25
|
|
176
|
+
|
|
177
|
+
# 6. Optional PTU reserve
|
|
178
|
+
ptu_estimado = 0.0
|
|
179
|
+
if incluir_ptu:
|
|
180
|
+
# PTU is typically calculated on annual salary
|
|
181
|
+
# We estimate monthly reserve as (annual_salary * ptu_percentage) / 12
|
|
182
|
+
ptu_estimado = (salario_mensual_bruto * 12 * (porcentaje_ptu / 100)) / 12.0
|
|
183
|
+
|
|
184
|
+
# 7. Calculate totals
|
|
185
|
+
costo_total_mensual = (
|
|
186
|
+
salario_mensual_bruto
|
|
187
|
+
+ cuotas_imss_patronales
|
|
188
|
+
+ infonavit
|
|
189
|
+
+ impuesto_nomina
|
|
190
|
+
+ reserva_aguinaldo
|
|
191
|
+
+ reserva_prima_vacacional
|
|
192
|
+
+ reserva_vacaciones
|
|
193
|
+
+ ptu_estimado
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
costo_total_anual = costo_total_mensual * 12
|
|
197
|
+
|
|
198
|
+
# Factor: how much the real cost is compared to base salary
|
|
199
|
+
factor_costo = costo_total_mensual / salario_mensual_bruto
|
|
200
|
+
|
|
201
|
+
return CostoTotalResult(
|
|
202
|
+
salario_bruto_mensual=salario_mensual_bruto,
|
|
203
|
+
cuotas_imss_patronales=cuotas_imss_patronales,
|
|
204
|
+
infonavit=infonavit,
|
|
205
|
+
impuesto_nomina=impuesto_nomina,
|
|
206
|
+
reserva_aguinaldo=reserva_aguinaldo,
|
|
207
|
+
reserva_prima_vacacional=reserva_prima_vacacional,
|
|
208
|
+
reserva_vacaciones=reserva_vacaciones,
|
|
209
|
+
ptu_estimado=ptu_estimado,
|
|
210
|
+
costo_total_mensual=costo_total_mensual,
|
|
211
|
+
costo_total_anual=costo_total_anual,
|
|
212
|
+
factor_costo=factor_costo,
|
|
213
|
+
)
|