Merge pull request #37127 from ruthra-kumar/better_date_filters_in_get_outstanding_invoices

refactor: better date filters in `Get Outstanding Invoices` dialog
This commit is contained in:
ruthra kumar 2023-09-18 13:20:32 +05:30 committed by GitHub
commit 5acbf3f262
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1588,6 +1588,14 @@ def get_outstanding_reference_documents(args, validate=False):
fieldname, args.get(date_fields[0]), args.get(date_fields[1])
)
posting_and_due_date.append(ple[fieldname][args.get(date_fields[0]) : args.get(date_fields[1])])
elif args.get(date_fields[0]):
# if only from date is supplied
condition += " and {0} >= '{1}'".format(fieldname, args.get(date_fields[0]))
posting_and_due_date.append(ple[fieldname].gte(args.get(date_fields[0])))
elif args.get(date_fields[1]):
# if only to date is supplied
condition += " and {0} <= '{1}'".format(fieldname, args.get(date_fields[1]))
posting_and_due_date.append(ple[fieldname].lte(args.get(date_fields[1])))
if args.get("company"):
condition += " and company = {0}".format(frappe.db.escape(args.get("company")))