fix calcualtion

This commit is contained in:
admin.suherdy 2025-11-21 17:10:14 +07:00
parent 4012e6f4c9
commit 9b5deb2f87
3 changed files with 158 additions and 12 deletions

145
.gitignore vendored Normal file
View File

@ -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

View File

@ -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)

View File

@ -34,7 +34,8 @@
widget="monetary"
options="{'currency_field': 'currency_id'}"
string="Residual Amount"
readonly="1"/>
readonly="1"
invisible="1"/>
</field>
</field>
</record>