coati-payroll 0.0.11__py3-none-any.whl → 0.0.13__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.
Potentially problematic release.
This version of coati-payroll might be problematic. Click here for more details.
- coati_payroll/__init__.py +7 -17
- coati_payroll/app.py +2 -13
- coati_payroll/audit_helpers.py +2 -13
- coati_payroll/auth.py +2 -13
- coati_payroll/cli.py +17 -14
- coati_payroll/config.py +2 -13
- coati_payroll/demo_data.py +2 -13
- coati_payroll/enums.py +2 -13
- coati_payroll/forms.py +7 -13
- coati_payroll/formula_engine/__init__.py +14 -13
- coati_payroll/formula_engine/ast/__init__.py +16 -1
- coati_payroll/formula_engine/ast/ast_visitor.py +15 -17
- coati_payroll/formula_engine/ast/expression_evaluator.py +12 -14
- coati_payroll/formula_engine/ast/safe_operators.py +16 -15
- coati_payroll/formula_engine/ast/type_converter.py +17 -17
- coati_payroll/formula_engine/data_sources.py +3 -13
- coati_payroll/formula_engine/engine.py +12 -13
- coati_payroll/formula_engine/exceptions.py +13 -13
- coati_payroll/formula_engine/execution/__init__.py +15 -13
- coati_payroll/formula_engine/execution/execution_context.py +12 -13
- coati_payroll/formula_engine/execution/step_executor.py +12 -14
- coati_payroll/formula_engine/execution/variable_store.py +13 -13
- coati_payroll/formula_engine/novelty_codes.py +3 -13
- coati_payroll/formula_engine/results/__init__.py +14 -13
- coati_payroll/formula_engine/results/execution_result.py +47 -35
- coati_payroll/formula_engine/steps/__init__.py +14 -14
- coati_payroll/formula_engine/steps/assignment_step.py +12 -13
- coati_payroll/formula_engine/steps/base_step.py +13 -13
- coati_payroll/formula_engine/steps/calculation_step.py +12 -13
- coati_payroll/formula_engine/steps/conditional_step.py +12 -13
- coati_payroll/formula_engine/steps/step_factory.py +11 -13
- coati_payroll/formula_engine/steps/tax_lookup_step.py +12 -13
- coati_payroll/formula_engine/tables/__init__.py +14 -13
- coati_payroll/formula_engine/tables/bracket_calculator.py +12 -13
- coati_payroll/formula_engine/tables/table_lookup.py +12 -14
- coati_payroll/formula_engine/tables/tax_table.py +13 -13
- coati_payroll/formula_engine/validation/__init__.py +14 -13
- coati_payroll/formula_engine/validation/schema_validator.py +12 -14
- coati_payroll/formula_engine/validation/security_validator.py +12 -13
- coati_payroll/formula_engine/validation/tax_table_validator.py +12 -13
- coati_payroll/formula_engine_examples.py +2 -13
- coati_payroll/i18n.py +2 -13
- coati_payroll/initial_data.py +2 -13
- coati_payroll/interes_engine.py +2 -13
- coati_payroll/liquidacion_engine/__init__.py +2 -13
- coati_payroll/liquidacion_engine/engine.py +2 -13
- coati_payroll/locale_config.py +2 -13
- coati_payroll/migrations/20260125_032900_initial_migration.py +2 -14
- coati_payroll/migrations/__init__.py +2 -13
- coati_payroll/model.py +83 -82
- coati_payroll/nomina_engine/__init__.py +2 -13
- coati_payroll/nomina_engine/calculators/__init__.py +2 -13
- coati_payroll/nomina_engine/calculators/benefit_calculator.py +2 -13
- coati_payroll/nomina_engine/calculators/concept_calculator.py +2 -1
- coati_payroll/nomina_engine/calculators/deduction_calculator.py +2 -13
- coati_payroll/nomina_engine/calculators/exchange_rate_calculator.py +2 -13
- coati_payroll/nomina_engine/calculators/perception_calculator.py +2 -13
- coati_payroll/nomina_engine/calculators/salary_calculator.py +2 -13
- coati_payroll/nomina_engine/domain/__init__.py +2 -13
- coati_payroll/nomina_engine/domain/calculation_items.py +2 -13
- coati_payroll/nomina_engine/domain/employee_calculation.py +2 -13
- coati_payroll/nomina_engine/domain/payroll_context.py +2 -13
- coati_payroll/nomina_engine/engine.py +2 -13
- coati_payroll/nomina_engine/processors/__init__.py +2 -13
- coati_payroll/nomina_engine/processors/accounting_processor.py +2 -13
- coati_payroll/nomina_engine/processors/accumulation_processor.py +2 -13
- coati_payroll/nomina_engine/processors/loan_processor.py +2 -13
- coati_payroll/nomina_engine/processors/novelty_processor.py +2 -13
- coati_payroll/nomina_engine/processors/vacation_processor.py +2 -13
- coati_payroll/nomina_engine/repositories/__init__.py +2 -13
- coati_payroll/nomina_engine/repositories/acumulado_repository.py +2 -13
- coati_payroll/nomina_engine/repositories/base_repository.py +2 -13
- coati_payroll/nomina_engine/repositories/config_repository.py +2 -13
- coati_payroll/nomina_engine/repositories/employee_repository.py +2 -13
- coati_payroll/nomina_engine/repositories/exchange_rate_repository.py +2 -13
- coati_payroll/nomina_engine/repositories/novelty_repository.py +2 -13
- coati_payroll/nomina_engine/repositories/planilla_repository.py +2 -13
- coati_payroll/nomina_engine/results/__init__.py +2 -13
- coati_payroll/nomina_engine/results/error_result.py +2 -13
- coati_payroll/nomina_engine/results/payroll_result.py +2 -13
- coati_payroll/nomina_engine/results/validation_result.py +2 -13
- coati_payroll/nomina_engine/services/__init__.py +2 -13
- coati_payroll/nomina_engine/services/accounting_voucher_service.py +2 -13
- coati_payroll/nomina_engine/services/employee_processing_service.py +2 -13
- coati_payroll/nomina_engine/services/payroll_execution_service.py +2 -13
- coati_payroll/nomina_engine/validators/__init__.py +2 -13
- coati_payroll/nomina_engine/validators/base_validator.py +2 -13
- coati_payroll/nomina_engine/validators/currency_validator.py +2 -13
- coati_payroll/nomina_engine/validators/employee_validator.py +2 -13
- coati_payroll/nomina_engine/validators/period_validator.py +2 -13
- coati_payroll/nomina_engine/validators/planilla_validator.py +2 -13
- coati_payroll/queue/__init__.py +2 -13
- coati_payroll/queue/driver.py +2 -13
- coati_payroll/queue/drivers/__init__.py +2 -13
- coati_payroll/queue/drivers/dramatiq_driver.py +9 -16
- coati_payroll/queue/drivers/huey_driver.py +2 -13
- coati_payroll/queue/drivers/noop_driver.py +2 -13
- coati_payroll/queue/selector.py +2 -13
- coati_payroll/queue/tasks.py +13 -20
- coati_payroll/rate_limiting.py +2 -13
- coati_payroll/rbac.py +12 -19
- coati_payroll/report_engine.py +2 -13
- coati_payroll/report_export.py +2 -13
- coati_payroll/schema_validator.py +2 -13
- coati_payroll/security.py +2 -13
- coati_payroll/static/schema_editor.js +862 -0
- coati_payroll/static/styles.css +5 -0
- coati_payroll/system_reports.py +2 -13
- coati_payroll/templates/auth/login.html +5 -0
- coati_payroll/templates/base.html +5 -1
- coati_payroll/templates/index.html +5 -0
- coati_payroll/templates/macros.html +5 -0
- coati_payroll/templates/modules/calculation_rule/form.html +5 -0
- coati_payroll/templates/modules/calculation_rule/index.html +5 -0
- coati_payroll/templates/modules/calculation_rule/schema_editor.html +292 -974
- coati_payroll/templates/modules/carga_inicial_prestacion/form.html +5 -0
- coati_payroll/templates/modules/carga_inicial_prestacion/index.html +5 -0
- coati_payroll/templates/modules/carga_inicial_prestacion/reporte.html +5 -0
- coati_payroll/templates/modules/config_calculos/index.html +5 -0
- coati_payroll/templates/modules/configuracion/index.html +24 -27
- coati_payroll/templates/modules/currency/form.html +5 -0
- coati_payroll/templates/modules/currency/index.html +5 -0
- coati_payroll/templates/modules/custom_field/form.html +5 -0
- coati_payroll/templates/modules/custom_field/index.html +5 -0
- coati_payroll/templates/modules/deduccion/form.html +5 -0
- coati_payroll/templates/modules/deduccion/index.html +5 -0
- coati_payroll/templates/modules/employee/form.html +5 -0
- coati_payroll/templates/modules/employee/index.html +5 -0
- coati_payroll/templates/modules/empresa/form.html +5 -0
- coati_payroll/templates/modules/empresa/index.html +5 -0
- coati_payroll/templates/modules/exchange_rate/form.html +5 -0
- coati_payroll/templates/modules/exchange_rate/import.html +5 -0
- coati_payroll/templates/modules/exchange_rate/index.html +5 -0
- coati_payroll/templates/modules/liquidacion/index.html +5 -0
- coati_payroll/templates/modules/liquidacion/nueva.html +5 -0
- coati_payroll/templates/modules/liquidacion/ver.html +5 -0
- coati_payroll/templates/modules/payroll_concepts/audit_log.html +5 -0
- coati_payroll/templates/modules/percepcion/form.html +5 -0
- coati_payroll/templates/modules/percepcion/index.html +5 -0
- coati_payroll/templates/modules/planilla/config.html +5 -0
- coati_payroll/templates/modules/planilla/config_deducciones.html +5 -0
- coati_payroll/templates/modules/planilla/config_empleados.html +5 -0
- coati_payroll/templates/modules/planilla/config_percepciones.html +5 -0
- coati_payroll/templates/modules/planilla/config_prestaciones.html +5 -0
- coati_payroll/templates/modules/planilla/config_reglas.html +5 -0
- coati_payroll/templates/modules/planilla/ejecutar_nomina.html +5 -0
- coati_payroll/templates/modules/planilla/form.html +5 -0
- coati_payroll/templates/modules/planilla/index.html +5 -0
- coati_payroll/templates/modules/planilla/listar_nominas.html +5 -0
- coati_payroll/templates/modules/planilla/log_nomina.html +5 -0
- coati_payroll/templates/modules/planilla/novedades/form.html +5 -0
- coati_payroll/templates/modules/planilla/novedades/index.html +5 -0
- coati_payroll/templates/modules/planilla/ver_nomina.html +5 -0
- coati_payroll/templates/modules/planilla/ver_nomina_empleado.html +5 -0
- coati_payroll/templates/modules/plugins/index.html +5 -0
- coati_payroll/templates/modules/prestacion/form.html +5 -0
- coati_payroll/templates/modules/prestacion/index.html +5 -0
- coati_payroll/templates/modules/prestacion_management/dashboard.html +5 -0
- coati_payroll/templates/modules/prestacion_management/initial_balance_bulk.html +5 -0
- coati_payroll/templates/modules/prestamo/approve.html +5 -0
- coati_payroll/templates/modules/prestamo/condonacion.html +5 -0
- coati_payroll/templates/modules/prestamo/detail.html +5 -0
- coati_payroll/templates/modules/prestamo/form.html +5 -0
- coati_payroll/templates/modules/prestamo/index.html +5 -0
- coati_payroll/templates/modules/prestamo/pago_extraordinario.html +5 -0
- coati_payroll/templates/modules/prestamo/tabla_pago_pdf.html +5 -0
- coati_payroll/templates/modules/report/admin_index.html +5 -0
- coati_payroll/templates/modules/report/detail.html +5 -0
- coati_payroll/templates/modules/report/execute.html +5 -0
- coati_payroll/templates/modules/report/index.html +5 -0
- coati_payroll/templates/modules/report/permissions.html +5 -0
- coati_payroll/templates/modules/settings/index.html +5 -0
- coati_payroll/templates/modules/shared/concept_form.html +19 -12
- coati_payroll/templates/modules/shared/concept_index.html +39 -27
- coati_payroll/templates/modules/tipo_planilla/form.html +5 -0
- coati_payroll/templates/modules/tipo_planilla/index.html +5 -0
- coati_payroll/templates/modules/user/form.html +5 -0
- coati_payroll/templates/modules/user/index.html +5 -0
- coati_payroll/templates/modules/user/profile.html +5 -0
- coati_payroll/templates/modules/vacation/account_detail.html +5 -0
- coati_payroll/templates/modules/vacation/account_form.html +5 -0
- coati_payroll/templates/modules/vacation/account_index.html +5 -0
- coati_payroll/templates/modules/vacation/dashboard.html +5 -0
- coati_payroll/templates/modules/vacation/initial_balance_bulk.html +5 -0
- coati_payroll/templates/modules/vacation/initial_balance_form.html +5 -0
- coati_payroll/templates/modules/vacation/leave_request_detail.html +5 -0
- coati_payroll/templates/modules/vacation/leave_request_form.html +5 -0
- coati_payroll/templates/modules/vacation/leave_request_index.html +5 -0
- coati_payroll/templates/modules/vacation/policy_detail.html +5 -0
- coati_payroll/templates/modules/vacation/policy_form.html +5 -0
- coati_payroll/templates/modules/vacation/policy_index.html +5 -0
- coati_payroll/templates/modules/vacation/register_taken_form.html +5 -0
- coati_payroll/translations/en/LC_MESSAGES/messages.mo +0 -0
- coati_payroll/translations/en/LC_MESSAGES/messages.po +2963 -3561
- coati_payroll/vacation_service.py +2 -13
- coati_payroll/version.py +3 -14
- coati_payroll/vistas/__init__.py +2 -13
- coati_payroll/vistas/calculation_rule.py +14 -24
- coati_payroll/vistas/carga_inicial_prestacion.py +2 -13
- coati_payroll/vistas/config_calculos.py +2 -13
- coati_payroll/vistas/configuracion.py +29 -39
- coati_payroll/vistas/constants.py +2 -13
- coati_payroll/vistas/currency.py +2 -13
- coati_payroll/vistas/custom_field.py +2 -13
- coati_payroll/vistas/employee.py +2 -13
- coati_payroll/vistas/empresa.py +2 -13
- coati_payroll/vistas/exchange_rate.py +2 -13
- coati_payroll/vistas/liquidacion.py +2 -13
- coati_payroll/vistas/payroll_concepts.py +2 -13
- coati_payroll/vistas/planilla/__init__.py +2 -13
- coati_payroll/vistas/planilla/association_routes.py +8 -17
- coati_payroll/vistas/planilla/config_routes.py +2 -13
- coati_payroll/vistas/planilla/export_routes.py +28 -35
- coati_payroll/vistas/planilla/helpers/__init__.py +2 -13
- coati_payroll/vistas/planilla/helpers/association_helpers.py +2 -13
- coati_payroll/vistas/planilla/helpers/excel_helpers.py +2 -13
- coati_payroll/vistas/planilla/helpers/form_helpers.py +2 -13
- coati_payroll/vistas/planilla/nomina_routes.py +2 -13
- coati_payroll/vistas/planilla/novedad_routes.py +2 -13
- coati_payroll/vistas/planilla/routes.py +2 -13
- coati_payroll/vistas/planilla/services/__init__.py +2 -13
- coati_payroll/vistas/planilla/services/export_service.py +4 -15
- coati_payroll/vistas/planilla/services/nomina_service.py +2 -13
- coati_payroll/vistas/planilla/services/novedad_service.py +3 -16
- coati_payroll/vistas/planilla/services/planilla_service.py +2 -13
- coati_payroll/vistas/planilla/validators/__init__.py +2 -13
- coati_payroll/vistas/planilla/validators/planilla_validators.py +2 -13
- coati_payroll/vistas/prestacion.py +2 -13
- coati_payroll/vistas/prestamo.py +2 -13
- coati_payroll/vistas/report.py +2 -13
- coati_payroll/vistas/settings.py +2 -13
- coati_payroll/vistas/tipo_planilla.py +2 -13
- coati_payroll/vistas/user.py +2 -13
- coati_payroll/vistas/vacation.py +15 -13
- coati_payroll/wsgi_server.py +37 -0
- {coati_payroll-0.0.11.dist-info → coati_payroll-0.0.13.dist-info}/METADATA +11 -4
- coati_payroll-0.0.13.dist-info/RECORD +248 -0
- coati_payroll/translations/es/LC_MESSAGES/messages.mo +0 -0
- coati_payroll/translations/es/LC_MESSAGES/messages.po +0 -7374
- coati_payroll-0.0.11.dist-info/RECORD +0 -248
- {coati_payroll-0.0.11.dist-info → coati_payroll-0.0.13.dist-info}/LICENSE +0 -0
- {coati_payroll-0.0.11.dist-info → coati_payroll-0.0.13.dist-info}/WHEEL +0 -0
- {coati_payroll-0.0.11.dist-info → coati_payroll-0.0.13.dist-info}/entry_points.txt +0 -0
- {coati_payroll-0.0.11.dist-info → coati_payroll-0.0.13.dist-info}/top_level.txt +0 -0
coati_payroll/__init__.py
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: 2025 - 2026 BMO Soluciones, S.A.
|
|
14
3
|
"""
|
|
15
4
|
Coati Payroll
|
|
16
5
|
=============
|
|
@@ -224,8 +213,9 @@ def create_app(config) -> Flask:
|
|
|
224
213
|
app.config["PERMANENT_SESSION_LIFETIME"] = timedelta(hours=24) # Session timeout
|
|
225
214
|
|
|
226
215
|
# Configure Flask-Babel
|
|
227
|
-
app.config["BABEL_DEFAULT_LOCALE"] = "
|
|
228
|
-
app.config["BABEL_TRANSLATION_DIRECTORIES"] = "translations"
|
|
216
|
+
app.config["BABEL_DEFAULT_LOCALE"] = "es"
|
|
217
|
+
app.config["BABEL_TRANSLATION_DIRECTORIES"] = join(dirname(__file__), "translations")
|
|
218
|
+
app.config["BABEL_SUPPORTED_LOCALES"] = ["es", "en"]
|
|
229
219
|
babel.init_app(app, locale_selector=get_locale)
|
|
230
220
|
|
|
231
221
|
session_manager.init_app(app)
|
|
@@ -366,10 +356,10 @@ def ensure_database_initialized(app: Flask | None = None) -> None:
|
|
|
366
356
|
_db.create_all()
|
|
367
357
|
log.trace("ensure_database_initialized: create_all() completed")
|
|
368
358
|
except Exception as exc:
|
|
369
|
-
from sqlalchemy.exc import OperationalError
|
|
359
|
+
from sqlalchemy.exc import OperationalError, ProgrammingError
|
|
370
360
|
|
|
371
361
|
msg = str(exc).lower()
|
|
372
|
-
if isinstance(exc, OperationalError) and "already exists" in msg:
|
|
362
|
+
if isinstance(exc, (OperationalError, ProgrammingError)) and "already exists" in msg:
|
|
373
363
|
log.trace("ensure_database_initialized: create_all skipped existing objects")
|
|
374
364
|
else:
|
|
375
365
|
log.trace(f"ensure_database_initialized: create_all() raised: {exc}")
|
coati_payroll/app.py
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: 2025 - 2026 BMO Soluciones, S.A.
|
|
14
3
|
"""App module."""
|
|
15
4
|
|
|
16
5
|
from __future__ import annotations
|
coati_payroll/audit_helpers.py
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: 2025 - 2026 BMO Soluciones, S.A.
|
|
14
3
|
"""Helper functions for audit and governance of payroll concepts."""
|
|
15
4
|
|
|
16
5
|
from __future__ import annotations
|
coati_payroll/auth.py
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: 2025 - 2026 BMO Soluciones, S.A.
|
|
14
3
|
"""Auth module."""
|
|
15
4
|
|
|
16
5
|
from __future__ import annotations
|
coati_payroll/cli.py
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: 2025 - 2026 BMO Soluciones, S.A.
|
|
14
3
|
"""Command line interface for Coati Payroll system administration."""
|
|
15
4
|
|
|
16
5
|
from __future__ import annotations
|
|
@@ -43,10 +32,12 @@ from coati_payroll.model import db, Usuario, PluginRegistry
|
|
|
43
32
|
from coati_payroll.auth import proteger_passwd
|
|
44
33
|
from coati_payroll.log import log
|
|
45
34
|
from coati_payroll.plugin_manager import discover_installed_plugins, load_plugin_module, sync_plugin_registry
|
|
35
|
+
from coati_payroll.wsgi_server import serve as wsgi_server
|
|
46
36
|
|
|
47
37
|
|
|
48
38
|
# Global context to store CLI options
|
|
49
39
|
class CLIContext:
|
|
40
|
+
|
|
50
41
|
def __init__(self):
|
|
51
42
|
self.environment = None
|
|
52
43
|
self.json_output = False
|
|
@@ -69,6 +60,7 @@ def output_result(ctx, message, data=None, success=True):
|
|
|
69
60
|
|
|
70
61
|
|
|
71
62
|
class PluginsCommand(click.Group):
|
|
63
|
+
|
|
72
64
|
def list_commands(self, cli_ctx):
|
|
73
65
|
try:
|
|
74
66
|
return [p.plugin_id for p in discover_installed_plugins()]
|
|
@@ -76,6 +68,7 @@ class PluginsCommand(click.Group):
|
|
|
76
68
|
return []
|
|
77
69
|
|
|
78
70
|
def get_command(self, cli_ctx, name):
|
|
71
|
+
|
|
79
72
|
def _load_module_or_fail():
|
|
80
73
|
try:
|
|
81
74
|
return load_plugin_module(name)
|
|
@@ -326,7 +319,6 @@ class PluginsCommand(click.Group):
|
|
|
326
319
|
|
|
327
320
|
plugins = PluginsCommand(name="plugins", help="Gestión de plugins instalados")
|
|
328
321
|
|
|
329
|
-
|
|
330
322
|
# ============================================================================
|
|
331
323
|
# SYSTEM COMMANDS
|
|
332
324
|
# ============================================================================
|
|
@@ -548,6 +540,17 @@ def _database_status():
|
|
|
548
540
|
return {"tables": len(tables), "table_names": tables[:10], "record_counts": counts}
|
|
549
541
|
|
|
550
542
|
|
|
543
|
+
@click.command()
|
|
544
|
+
@with_appcontext
|
|
545
|
+
@pass_context
|
|
546
|
+
def serve():
|
|
547
|
+
"""Run the application server."""
|
|
548
|
+
try:
|
|
549
|
+
wsgi_server(app=current_app)
|
|
550
|
+
except Exception as e:
|
|
551
|
+
click.echo(f"Failed to start server: {e}", err=True)
|
|
552
|
+
|
|
553
|
+
|
|
551
554
|
@click.group()
|
|
552
555
|
def database():
|
|
553
556
|
"""Database management commands."""
|
coati_payroll/config.py
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: 2025 - 2026 BMO Soluciones, S.A.
|
|
14
3
|
"""Base configuration for the payroll module."""
|
|
15
4
|
|
|
16
5
|
from __future__ import annotations
|
coati_payroll/demo_data.py
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: 2025 - 2026 BMO Soluciones, S.A.
|
|
14
3
|
"""Demo data loading for manual testing.
|
|
15
4
|
|
|
16
5
|
This module provides comprehensive sample data to facilitate manual testing
|
coati_payroll/enums.py
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: 2025 - 2026 BMO Soluciones, S.A.
|
|
14
3
|
"""Enumerations for type safety using Python 3.11+ StrEnum.
|
|
15
4
|
|
|
16
5
|
This module defines string-based enums using Python 3.11's StrEnum class,
|
coati_payroll/forms.py
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: 2025 - 2026 BMO Soluciones, S.A.
|
|
14
3
|
|
|
15
4
|
"""Forms module.
|
|
16
5
|
|
|
@@ -1767,3 +1756,8 @@ class VacationInitialBalanceForm(FlaskForm):
|
|
|
1767
1756
|
)
|
|
1768
1757
|
|
|
1769
1758
|
submit = SubmitField(_("Cargar Saldo Inicial"))
|
|
1759
|
+
|
|
1760
|
+
|
|
1761
|
+
class ConfiguracionIdiomaForm(FlaskForm):
|
|
1762
|
+
idioma = SelectField("Idioma", validators=[DataRequired()])
|
|
1763
|
+
submit = SubmitField("Guardar Cambios")
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: 2025 - 2026 BMO Soluciones, S.A.
|
|
14
3
|
"""Formula engine package.
|
|
15
4
|
|
|
16
5
|
This package contains the refactored formula engine with modular architecture:
|
|
@@ -21,6 +10,17 @@ This package contains the refactored formula engine with modular architecture:
|
|
|
21
10
|
|
|
22
11
|
from __future__ import annotations
|
|
23
12
|
|
|
13
|
+
# <-------------------------------------------------------------------------> #
|
|
14
|
+
# Standard library
|
|
15
|
+
# <-------------------------------------------------------------------------> #
|
|
16
|
+
|
|
17
|
+
# <-------------------------------------------------------------------------> #
|
|
18
|
+
# Standard library
|
|
19
|
+
# <-------------------------------------------------------------------------> #
|
|
20
|
+
|
|
21
|
+
# <-------------------------------------------------------------------------> #
|
|
22
|
+
# Local modules
|
|
23
|
+
# <-------------------------------------------------------------------------> #
|
|
24
24
|
# Import from formula_engine_examples
|
|
25
25
|
# EXAMPLE_PROGRESSIVE_TAX_SCHEMA is the new generic name
|
|
26
26
|
# EXAMPLE_IR_NICARAGUA_SCHEMA is kept for backward compatibility (deprecated)
|
|
@@ -51,6 +51,7 @@ from .ast import (
|
|
|
51
51
|
from .data_sources import AVAILABLE_DATA_SOURCES
|
|
52
52
|
from .novelty_codes import NOVELTY_CODES
|
|
53
53
|
|
|
54
|
+
# <==================[ Expose all varaibles and constants ]===================>
|
|
54
55
|
__all__ = [
|
|
55
56
|
# Main engine
|
|
56
57
|
"FormulaEngine",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SPDX-FileCopyrightText: 2025 - 2026 BMO Soluciones, S.A.
|
|
2
|
+
# Copyright 2025 - 2026 BMO Soluciones, S.A.
|
|
2
3
|
#
|
|
3
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
5
|
# you may not use this file except in compliance with the License.
|
|
@@ -70,6 +71,19 @@ Security Notes:
|
|
|
70
71
|
- Regular security audits are recommended
|
|
71
72
|
"""
|
|
72
73
|
|
|
74
|
+
# <-------------------------------------------------------------------------> #
|
|
75
|
+
# Standard library
|
|
76
|
+
# <-------------------------------------------------------------------------> #
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# <-------------------------------------------------------------------------> #
|
|
80
|
+
# Third party packages
|
|
81
|
+
# <-------------------------------------------------------------------------> #
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
# <-------------------------------------------------------------------------> #
|
|
85
|
+
# Local modules
|
|
86
|
+
# <-------------------------------------------------------------------------> #
|
|
73
87
|
from .ast_visitor import ASTVisitor, SafeASTVisitor
|
|
74
88
|
from .expression_evaluator import ExpressionEvaluator
|
|
75
89
|
from .safe_operators import (
|
|
@@ -90,6 +104,7 @@ from .type_converter import (
|
|
|
90
104
|
MIN_DECIMAL_VALUE,
|
|
91
105
|
)
|
|
92
106
|
|
|
107
|
+
# <==================[ Expose all varaibles and constants ]===================>
|
|
93
108
|
__all__ = [
|
|
94
109
|
"ASTVisitor",
|
|
95
110
|
"SafeASTVisitor",
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: 2025 - 2026 BMO Soluciones, S.A.
|
|
14
3
|
"""AST Visitor pattern for safe expression evaluation.
|
|
15
4
|
|
|
16
5
|
This module implements a secure AST visitor that evaluates mathematical expressions
|
|
@@ -30,11 +19,20 @@ and each type has an explicit, auditable handler method.
|
|
|
30
19
|
|
|
31
20
|
from __future__ import annotations
|
|
32
21
|
|
|
22
|
+
# <-------------------------------------------------------------------------> #
|
|
23
|
+
# Standard library
|
|
24
|
+
# <-------------------------------------------------------------------------> #
|
|
25
|
+
import ast
|
|
33
26
|
from abc import ABC, abstractmethod
|
|
34
27
|
from decimal import Decimal
|
|
35
28
|
|
|
36
|
-
|
|
29
|
+
# <-------------------------------------------------------------------------> #
|
|
30
|
+
# Third party packages
|
|
31
|
+
# <-------------------------------------------------------------------------> #
|
|
37
32
|
|
|
33
|
+
# <-------------------------------------------------------------------------> #
|
|
34
|
+
# Local modules
|
|
35
|
+
# <-------------------------------------------------------------------------> #
|
|
38
36
|
from ..exceptions import CalculationError
|
|
39
37
|
from .safe_operators import SAFE_FUNCTIONS, SAFE_OPERATORS
|
|
40
38
|
from .type_converter import to_decimal
|
|
@@ -151,7 +149,7 @@ class SafeASTVisitor(ASTVisitor):
|
|
|
151
149
|
"""
|
|
152
150
|
if node.id not in self.variables:
|
|
153
151
|
raise CalculationError(
|
|
154
|
-
f"Undefined variable: '{node.id}'.
|
|
152
|
+
f"Undefined variable: '{node.id}'. Available variables: {', '.join(sorted(self.variables.keys()))}"
|
|
155
153
|
)
|
|
156
154
|
return self.variables[node.id]
|
|
157
155
|
|
|
@@ -174,7 +172,7 @@ class SafeASTVisitor(ASTVisitor):
|
|
|
174
172
|
op_func = SAFE_OPERATORS.get(op_type)
|
|
175
173
|
if not op_func:
|
|
176
174
|
raise CalculationError(
|
|
177
|
-
f"Operator '{op_type.__name__}' is not allowed.
|
|
175
|
+
f"Operator '{op_type.__name__}' is not allowed. Allowed operators: +, -, *, /, //, %, **"
|
|
178
176
|
)
|
|
179
177
|
|
|
180
178
|
if op_type in (ast.Div, ast.FloorDiv, ast.Mod) and right == 0:
|
|
@@ -226,7 +224,7 @@ class SafeASTVisitor(ASTVisitor):
|
|
|
226
224
|
"""
|
|
227
225
|
if not isinstance(node.func, ast.Name):
|
|
228
226
|
raise CalculationError(
|
|
229
|
-
"Only direct named function calls are allowed.
|
|
227
|
+
"Only direct named function calls are allowed. Attribute access and lambda functions are prohibited."
|
|
230
228
|
)
|
|
231
229
|
|
|
232
230
|
func_name = node.func.id
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: 2025 - 2026 BMO Soluciones, S.A.
|
|
14
3
|
"""Expression evaluator using AST visitor pattern.
|
|
15
4
|
|
|
16
5
|
This module provides secure evaluation of mathematical expressions from JSON rules.
|
|
@@ -40,13 +29,22 @@ Example Unsafe Expression (rejected):
|
|
|
40
29
|
|
|
41
30
|
from __future__ import annotations
|
|
42
31
|
|
|
32
|
+
# <-------------------------------------------------------------------------> #
|
|
33
|
+
# Standard library
|
|
34
|
+
# <-------------------------------------------------------------------------> #
|
|
43
35
|
import ast
|
|
44
36
|
from decimal import Decimal
|
|
45
37
|
from typing import Callable
|
|
46
38
|
|
|
39
|
+
# <-------------------------------------------------------------------------> #
|
|
40
|
+
# Third party packages
|
|
41
|
+
# <-------------------------------------------------------------------------> #
|
|
42
|
+
|
|
43
|
+
# <-------------------------------------------------------------------------> #
|
|
44
|
+
# Local modules
|
|
45
|
+
# <-------------------------------------------------------------------------> #
|
|
47
46
|
from coati_payroll.i18n import _
|
|
48
47
|
from coati_payroll.log import TRACE_LEVEL_NUM, is_trace_enabled, log
|
|
49
|
-
|
|
50
48
|
from ..exceptions import CalculationError
|
|
51
49
|
from .ast_visitor import SafeASTVisitor
|
|
52
50
|
from .safe_operators import ALLOWED_AST_TYPES, MAX_EXPRESSION_LENGTH, MAX_AST_DEPTH
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: 2025 - 2026 BMO Soluciones, S.A.
|
|
14
3
|
"""Safe operators and functions for expression evaluation.
|
|
15
4
|
|
|
16
5
|
This module defines the ONLY operators and functions allowed in formula expressions.
|
|
@@ -40,10 +29,22 @@ Prohibited Operations:
|
|
|
40
29
|
|
|
41
30
|
from __future__ import annotations
|
|
42
31
|
|
|
32
|
+
# <-------------------------------------------------------------------------> #
|
|
33
|
+
# Standard library
|
|
34
|
+
# <-------------------------------------------------------------------------> #
|
|
43
35
|
import ast
|
|
44
36
|
import operator
|
|
45
37
|
from typing import Any, Callable
|
|
46
38
|
|
|
39
|
+
# <-------------------------------------------------------------------------> #
|
|
40
|
+
# Third party packages
|
|
41
|
+
# <-------------------------------------------------------------------------> #
|
|
42
|
+
|
|
43
|
+
# <-------------------------------------------------------------------------> #
|
|
44
|
+
# Local modules
|
|
45
|
+
# <-------------------------------------------------------------------------> #
|
|
46
|
+
|
|
47
|
+
# <-------------------- Constantes Locales --------------------> #
|
|
47
48
|
MAX_EXPRESSION_LENGTH = 1000
|
|
48
49
|
MAX_AST_DEPTH = 50
|
|
49
50
|
MAX_FUNCTION_ARGS = 20
|
|
@@ -61,12 +62,12 @@ def validate_safe_function_call(func_name: str, args: list[Any]) -> None:
|
|
|
61
62
|
"""
|
|
62
63
|
if func_name not in SAFE_FUNCTIONS:
|
|
63
64
|
raise ValueError(
|
|
64
|
-
f"Function '{func_name}' is not in the whitelist.
|
|
65
|
+
f"Function '{func_name}' is not in the whitelist. Allowed functions: {', '.join(SAFE_FUNCTIONS.keys())}"
|
|
65
66
|
)
|
|
66
67
|
|
|
67
68
|
if len(args) > MAX_FUNCTION_ARGS:
|
|
68
69
|
raise ValueError(
|
|
69
|
-
f"Too many arguments ({len(args)}) for function '{func_name}'.
|
|
70
|
+
f"Too many arguments ({len(args)}) for function '{func_name}'. Maximum allowed: {MAX_FUNCTION_ARGS}"
|
|
70
71
|
)
|
|
71
72
|
|
|
72
73
|
if func_name == "round" and len(args) > 2:
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: 2025 - 2026 BMO Soluciones, S.A.
|
|
14
3
|
"""Type conversion utilities for formula engine.
|
|
15
4
|
|
|
16
5
|
This module provides safe type conversion functions that maintain financial
|
|
@@ -36,12 +25,23 @@ Security Considerations:
|
|
|
36
25
|
|
|
37
26
|
from __future__ import annotations
|
|
38
27
|
|
|
28
|
+
# <-------------------------------------------------------------------------> #
|
|
29
|
+
# Standard library
|
|
30
|
+
# <-------------------------------------------------------------------------> #
|
|
31
|
+
import math
|
|
39
32
|
from decimal import Decimal, InvalidOperation
|
|
40
33
|
from typing import Any
|
|
41
|
-
import math
|
|
42
34
|
|
|
35
|
+
# <-------------------------------------------------------------------------> #
|
|
36
|
+
# Third party packages
|
|
37
|
+
# <-------------------------------------------------------------------------> #
|
|
38
|
+
|
|
39
|
+
# <-------------------------------------------------------------------------> #
|
|
40
|
+
# Local modules
|
|
41
|
+
# <-------------------------------------------------------------------------> #
|
|
43
42
|
from ..exceptions import ValidationError
|
|
44
43
|
|
|
44
|
+
# <-------------------- Constantes Locales --------------------> #
|
|
45
45
|
MAX_DECIMAL_DIGITS = 28
|
|
46
46
|
MAX_DECIMAL_VALUE = Decimal("9" * MAX_DECIMAL_DIGITS)
|
|
47
47
|
MIN_DECIMAL_VALUE = -MAX_DECIMAL_VALUE
|
|
@@ -98,7 +98,7 @@ def to_decimal(value: Any) -> Decimal:
|
|
|
98
98
|
)
|
|
99
99
|
if math.isinf(value):
|
|
100
100
|
raise ValidationError(
|
|
101
|
-
"Cannot convert infinity to Decimal.
|
|
101
|
+
"Cannot convert infinity to Decimal. Check for division by zero or overflow in input calculations."
|
|
102
102
|
)
|
|
103
103
|
|
|
104
104
|
try:
|
|
@@ -127,10 +127,10 @@ def _validate_decimal_range(value: Decimal) -> None:
|
|
|
127
127
|
ValidationError: If value is outside acceptable range
|
|
128
128
|
"""
|
|
129
129
|
if value.is_nan():
|
|
130
|
-
raise ValidationError("Decimal value is NaN (Not a Number).
|
|
130
|
+
raise ValidationError("Decimal value is NaN (Not a Number). This indicates an invalid calculation result.")
|
|
131
131
|
|
|
132
132
|
if value.is_infinite():
|
|
133
|
-
raise ValidationError("Decimal value is infinite.
|
|
133
|
+
raise ValidationError("Decimal value is infinite. This indicates an overflow or division by zero.")
|
|
134
134
|
|
|
135
135
|
if value > MAX_DECIMAL_VALUE or value < MIN_DECIMAL_VALUE:
|
|
136
136
|
raise ValidationError(
|
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: 2025 - 2026 BMO Soluciones, S.A.
|
|
14
3
|
"""Available data sources for formula engine calculations.
|
|
15
4
|
|
|
16
5
|
This module defines all available data sources that can be accessed
|
|
17
6
|
when creating calculation rules in the formula engine.
|
|
18
7
|
"""
|
|
19
8
|
|
|
9
|
+
# ................................ CONTANTES ................................ #
|
|
20
10
|
AVAILABLE_DATA_SOURCES = {
|
|
21
11
|
"empleado": {
|
|
22
12
|
"label": "Empleado",
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# SPDX-FileCopyrightText: 2025 - 2026 BMO Soluciones, S.A.
|
|
14
3
|
"""Main formula engine facade."""
|
|
15
4
|
|
|
16
5
|
from __future__ import annotations
|
|
17
6
|
|
|
7
|
+
# <-------------------------------------------------------------------------> #
|
|
8
|
+
# Standard library
|
|
9
|
+
# <-------------------------------------------------------------------------> #
|
|
18
10
|
from decimal import Decimal
|
|
19
11
|
from typing import Any
|
|
20
12
|
|
|
13
|
+
# <-------------------------------------------------------------------------> #
|
|
14
|
+
# Third party packages
|
|
15
|
+
# <-------------------------------------------------------------------------> #
|
|
16
|
+
|
|
17
|
+
# <-------------------------------------------------------------------------> #
|
|
18
|
+
# Local modules
|
|
19
|
+
# <-------------------------------------------------------------------------> #
|
|
21
20
|
from coati_payroll.i18n import _
|
|
22
21
|
from coati_payroll.log import TRACE_LEVEL_NUM, is_trace_enabled, log
|
|
23
22
|
|