Skip to content

Commit

Permalink
refactor: add substring logic in ar/ap report
Browse files Browse the repository at this point in the history
  • Loading branch information
ruthra-kumar committed Nov 20, 2023
1 parent 97090ff commit a9bf906
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import frappe
from frappe import _, qb, scrub
from frappe.query_builder import Criterion
from frappe.query_builder.functions import Date, Sum
from frappe.query_builder.functions import Date, Substring, Sum
from frappe.utils import cint, cstr, flt, getdate, nowdate

from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
Expand Down Expand Up @@ -764,7 +764,12 @@ def get_ple_entries(self):
)

if self.filters.get("show_remarks"):
query = query.select(ple.remarks)
if remarks_length := frappe.db.get_single_value(
"Accounts Settings", "receivable_payable_remarks_length"
):
query = query.select(Substring(ple.remarks, 1, remarks_length).as_("remarks"))
else:
query = query.select(ple.remarks)

if self.filters.get("group_by_party"):
query = query.orderby(self.ple.party, self.ple.posting_date)
Expand Down

0 comments on commit a9bf906

Please sign in to comment.