From beec3f44163bb24e37709b3009f4577b21817eea Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Thu, 25 Jun 2026 09:19:10 +0000 Subject: [PATCH] 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) --- .../purchase_ygb_vat_report.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/taxes_az/taxes_az/report/purchase_ygb_vat_report/purchase_ygb_vat_report.py b/taxes_az/taxes_az/report/purchase_ygb_vat_report/purchase_ygb_vat_report.py index 99bd6da..7195f09 100644 --- a/taxes_az/taxes_az/report/purchase_ygb_vat_report/purchase_ygb_vat_report.py +++ b/taxes_az/taxes_az/report/purchase_ygb_vat_report/purchase_ygb_vat_report.py @@ -63,12 +63,19 @@ def get_columns(filters=None): def get_data(filters=None): """Get report data — one row per qualifying Purchase Invoice. - A document qualifies when it is submitted and at least one of the - purchase_type / agricultural_goods flags is set. Items are not filtered. + A document qualifies when it is submitted and carries YGB data, i.e. at + least one of the ygb / line_code fields is filled. Items are not filtered. """ 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 = {} if filters.get("company"):