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"):