From 9b5deb2f871ce4115d7d034a33cf7a07a05acfd4 Mon Sep 17 00:00:00 2001 From: "admin.suherdy" Date: Fri, 21 Nov 2025 17:10:14 +0700 Subject: [PATCH] fix calcualtion --- .gitignore | 145 ++++++++++++++++++++++++++++++++ models/account_payment.py | 22 ++--- views/account_payment_views.xml | 3 +- 3 files changed, 158 insertions(+), 12 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..78d815c --- /dev/null +++ b/.gitignore @@ -0,0 +1,145 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# IDE +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db diff --git a/models/account_payment.py b/models/account_payment.py index f354c9e..fc3169f 100644 --- a/models/account_payment.py +++ b/models/account_payment.py @@ -45,8 +45,8 @@ class AccountPayment(models.Model): # For debugging - let's try multiple approaches: # Approach 1: All lines residual - approach1_residual = total_residual - approach1_residual_currency = total_residual_currency + #approach1_residual = total_residual + #approach1_residual_currency = total_residual_currency # Approach 2: Only reconcilable account lines reconcilable_lines = all_lines.filtered(lambda line: line.account_id.reconcile) @@ -61,26 +61,26 @@ class AccountPayment(models.Model): # For now, let's use the approach that gives us the largest non-zero value # This will help us identify which approach works candidates = [ - abs(approach1_residual), + #abs(approach1_residual), abs(approach2_residual), abs(approach3_residual), - abs(approach1_residual_currency), + #abs(approach1_residual_currency), abs(approach2_residual_currency), abs(approach3_residual_currency) ] max_value = max(candidates) if candidates else 0.0 - if abs(approach1_residual) == max_value: - pay.payment_residual = abs(approach1_residual) - pay.payment_residual_currency = abs(approach1_residual_currency) - elif abs(approach2_residual) == max_value: + #if abs(approach1_residual) == max_value: + # pay.payment_residual = abs(approach1_residual) + # pay.payment_residual_currency = abs(approach1_residual_currency) + if abs(approach2_residual) == max_value: pay.payment_residual = abs(approach2_residual) pay.payment_residual_currency = abs(approach2_residual_currency) elif abs(approach3_residual) == max_value: pay.payment_residual = abs(approach3_residual) pay.payment_residual_currency = abs(approach3_residual_currency) - else: + #else: # Fallback to currency residuals - pay.payment_residual = abs(approach1_residual_currency) - pay.payment_residual_currency = abs(approach1_residual_currency) + #pay.payment_residual = abs(approach1_residual_currency) + #pay.payment_residual_currency = abs(approach1_residual_currency) diff --git a/views/account_payment_views.xml b/views/account_payment_views.xml index fa1250b..ea939ec 100644 --- a/views/account_payment_views.xml +++ b/views/account_payment_views.xml @@ -34,7 +34,8 @@ widget="monetary" options="{'currency_field': 'currency_id'}" string="Residual Amount" - readonly="1"/> + readonly="1" + invisible="1"/>