fix(report): Purchase YGB VAT report only lists documents with YGB

Replace the purchase_type/agricultural_goods gate with a YGB-presence
filter: a Purchase Invoice is included only when at least one of its YGB
fields (ygb / line_code) is filled.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ali 2026-06-25 09:19:10 +00:00
parent 2d743f2878
commit beec3f4416
1 changed files with 10 additions and 3 deletions

View File

@ -63,12 +63,19 @@ def get_columns(filters=None):
def get_data(filters=None): def get_data(filters=None):
"""Get report data — one row per qualifying Purchase Invoice. """Get report data — one row per qualifying Purchase Invoice.
A document qualifies when it is submitted and at least one of the A document qualifies when it is submitted and carries YGB data, i.e. at
purchase_type / agricultural_goods flags is set. Items are not filtered. least one of the ygb / line_code fields is filled. Items are not filtered.
""" """
filters = filters or {} filters = filters or {}
conditions = "pi.docstatus = 1 AND (pi.agricultural_goods = 1 OR pi.purchase_type = 1)" # Only documents that actually carry YGB data: at least one of the YGB
# fields (ygb / line_code) is filled.
conditions = (
"pi.docstatus = 1 AND ("
"(pi.ygb IS NOT NULL AND pi.ygb != 0) "
"OR (pi.line_code IS NOT NULL AND pi.line_code != '')"
")"
)
params = {} params = {}
if filters.get("company"): if filters.get("company"):