Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
34d1559
fix: build item ageing from the v16 FIFO slots class
av-dev2 Aug 26, 2026
32c7659
fix: drop the hard coded item group and brand defaults
av-dev2 Aug 26, 2026
89bfe79
fix: stop forcing an index that v16 no longer creates
av-dev2 Aug 26, 2026
495f086
fix: qualify the ambiguous item_code column
av-dev2 Aug 26, 2026
d733c39
fix: keep entries without a party and accept account lists
av-dev2 Aug 26, 2026
d58a9e7
fix: guard the account filter setup on load
av-dev2 Aug 26, 2026
b1dd483
fix: guard the ageing filter setup on load
av-dev2 Aug 26, 2026
9927090
fix: require a company before querying receivable accounts
av-dev2 Aug 26, 2026
4402f61
fix: make company a required filter
av-dev2 Aug 26, 2026
3876f03
fix: read filters as a mapping rather than an int
av-dev2 Aug 26, 2026
68f175d
fix: default the fiscal year filter
av-dev2 Aug 26, 2026
8e30ea2
fix: default the group by filter to invoice
av-dev2 Aug 26, 2026
9eb88f8
fix: return early without totals and read credit notes per row
av-dev2 Aug 26, 2026
9773872
fix: accept a numeric docstatus filter
av-dev2 Aug 26, 2026
99a726c
fix: accept a numeric docstatus filter
av-dev2 Aug 26, 2026
856b37f
fix: accept a numeric docstatus filter
av-dev2 Aug 26, 2026
d6dcacc
fix: accept a numeric docstatus filter
av-dev2 Aug 26, 2026
eb8b738
fix: accept a numeric docstatus filter
av-dev2 Aug 26, 2026
1ffa6e1
fix: read the payroll cheque fields from custom fields
av-dev2 Aug 26, 2026
2107710
feat: add the date filters the bank report query needs
av-dev2 Aug 26, 2026
8b835e3
feat: add payroll entry cheque fields for the bank report
av-dev2 Aug 26, 2026
b1ea98c
fix: join custom fields on dt instead of parent
av-dev2 Aug 26, 2026
e4afd3e
fix: select only invoice fields the report may read
av-dev2 Aug 26, 2026
701e533
feat: add the date filters the withholding query needs
av-dev2 Aug 26, 2026
f52356f
chore: remove the misspelled excise duty filter script
av-dev2 Aug 26, 2026
cdcc47d
feat: add filters that load for the excise duty report
av-dev2 Aug 26, 2026
56dee34
fix: default the excise duty detailed report dates
av-dev2 Aug 26, 2026
fe56578
fix: explain that the report needs the lending app
av-dev2 Aug 26, 2026
f386024
fix: explain that the report needs its source doctype
av-dev2 Aug 26, 2026
2152697
fix: explain that the report needs the is_marked field
av-dev2 Aug 26, 2026
1ed41aa
fix: read the quotation party from party_name
av-dev2 Aug 26, 2026
30afcac
fix: query shipment tracking from the Order Track doctype
av-dev2 Aug 26, 2026
59a30e5
fix: point shipment tracking at the Order Track doctype
av-dev2 Aug 26, 2026
4a85bad
fix: filter shipment tracking by Order Track orders
av-dev2 Aug 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@ frappe.query_reports["Accounts Receivable Multi Currency"] = {
}
}

erpnext.utils.add_dimensions('Accounts Receivable', 9);
erpnext.utils.add_dimensions('Accounts Receivable Multi Currency', 9);
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ frappe.query_reports["Accounts Receivable Summary Multi Currency"] = {
"label": __("Company"),
"fieldtype": "Link",
"options": "Company",
"default": frappe.defaults.get_user_default("Company")
"default": frappe.defaults.get_user_default("Company"),
"reqd": 1
},
{
"fieldname":"ageing_based_on",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,12 +638,18 @@ def prepare_conditions(self, party_type):
where supplier_group=%s)""")
values.append(self.filters.get("supplier_group"))

if not self.filters.get("company"):
frappe.throw(_("{0} is mandatory").format(_("Company")))

accounts = [
d.name
for d in frappe.get_all(
"Account", filters={"account_type": account_type, "company": self.filters.company}
)
]
if not accounts:
frappe.throw(_("No {0} account found for {1}").format(_(account_type), self.filters.company))

conditions.append("account in ({})".format(",".join(["%s"] * len(accounts))))
values += accounts

Expand Down
22 changes: 22 additions & 0 deletions csf_tz/csf_tz/report/bank_report/bank_report.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2016, Aakvatech and contributors
// For license information, please see license.txt
/* eslint-disable */

frappe.query_reports["Bank Report"] = {
"filters": [
{
"fieldname": "from_date",
"label": __("From Date"),
"fieldtype": "Date",
"default": frappe.datetime.month_start(),
"reqd": 1,
},
{
"fieldname": "to_date",
"label": __("To Date"),
"fieldtype": "Date",
"default": frappe.datetime.month_end(),
"reqd": 1,
},
]
};
4 changes: 2 additions & 2 deletions csf_tz/csf_tz/report/bank_report/bank_report.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"filters": [],
"idx": 0,
"is_standard": "Yes",
"modified": "2023-12-20 18:01:54.064621",
"modified": "2026-08-25 07:35:01.417396",
"modified_by": "Administrator",
"module": "CSF TZ",
"name": "Bank Report",
"owner": "Administrator",
"prepared_report": 0,
"query": "SELECT\tdate_format(ss.start_date, '%%M %%Y') AS \"Month::140\",\n\t\tss.employee\t\tAS \"Employee ID::120\", \n\t\tss.employee_name\tAS \"Employee Name::200\", \n\t\tss.bank_account_no\tAS \"Account No.::120\", \n\t\temp.bank_code\t\tAS \"Bank Code.::120\", \n\t\tss.net_pay\t\tAS \"Net Pay:Currency:120\",\n\t\tconcat(cmp.abbr, '/', date_format(ss.start_date, '%%M %%Y/%%d')) AS \"Payroll Entry::140\",\n\t\tpe.cheque_number\tAS \"Cheque No.::120\", \n\t\tpe.cheque_date\t\tAS \"Cheque Date::120\", \n\t\tss.company\t\tAS \"Company::120\",\n\t\tb.bank AS \"Bank Name::120\",\n\t\tb.branch_code AS \"Branch::120\",\n\t\tadr.address_line1 AS \"Address1::120\",\n\t\tadr.city AS \"City::120\",\n\t\tadr.country AS \"Country::120\"\nFROM \t`tabSalary Slip` ss\n\tLEFT JOIN `tabEmployee` emp ON ss.employee = emp.name\n\tLEFT JOIN `tabPayroll Entry` pe ON ss.payroll_entry = pe.name\n\tLEFT OUTER JOIN `tabCompany` cmp ON ss.company = cmp.name \n\tLEFT JOIN `tabBank Account` b ON pe.bank_account_for_transfer = b.name\n\tLEFT JOIN `tabAddress` adr ON pe.bank_account_for_transfer = adr.address_title\nWHERE\temp.salary_mode = 'Bank'\nAND \tss.start_date >= %(from_date)s\nAND \tss.end_date <= %(to_date)s",
"query": "SELECT\tdate_format(ss.start_date, '%%M %%Y') AS \"Month::140\",\n\t\tss.employee\t\tAS \"Employee ID::120\", \n\t\tss.employee_name\tAS \"Employee Name::200\", \n\t\tss.bank_account_no\tAS \"Account No.::120\", \n\t\temp.bank_code\t\tAS \"Bank Code.::120\", \n\t\tss.net_pay\t\tAS \"Net Pay:Currency:120\",\n\t\tconcat(cmp.abbr, '/', date_format(ss.start_date, '%%M %%Y/%%d')) AS \"Payroll Entry::140\",\n\t\tpe.cheque_number\tAS \"Cheque No.::120\", \n\t\tpe.cheque_date\t\tAS \"Cheque Date::120\", \n\t\tss.company\t\tAS \"Company::120\",\n\t\tb.bank AS \"Bank Name::120\",\n\t\tb.branch_code AS \"Branch::120\",\n\t\tadr.address_line1 AS \"Address1::120\",\n\t\tadr.city AS \"City::120\",\n\t\tadr.country AS \"Country::120\"\nFROM \t`tabSalary Slip` ss\n\tLEFT JOIN `tabEmployee` emp ON ss.employee = emp.name\n\tLEFT JOIN `tabPayroll Entry` pe ON ss.payroll_entry = pe.name\n\tLEFT OUTER JOIN `tabCompany` cmp ON ss.company = cmp.name \n\tLEFT JOIN `tabBank Account` b ON pe.bank_account = b.name\n\tLEFT JOIN `tabAddress` adr ON pe.bank_account = adr.address_title\nWHERE\temp.salary_mode = 'Bank'\nAND \tss.start_date >= %(from_date)s\nAND \tss.end_date <= %(to_date)s",
"ref_doctype": "Salary Slip",
"report_name": "Bank Report",
"report_type": "Query Report",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import frappe
from erpnext import get_company_currency
from frappe import _, msgprint
from frappe.utils import cstr, flt, getdate
from frappe.utils import cint, cstr, flt, getdate
from frappe.utils.nestedset import get_descendants_of


Expand Down Expand Up @@ -245,7 +245,9 @@ def get_cur_conditions(filters, company_currency):
doc_status = {"Draft": 0, "Submitted": 1, "Cancelled": 2}

if filters.get("docstatus"):
conditions += "docstatus = {}".format(doc_status[filters.get("docstatus")])
conditions += "docstatus = {}".format(
doc_status.get(filters.get("docstatus"), cint(filters.get("docstatus")))
)

if filters.get("from_date"):
conditions += " and start_date >= %(from_date)s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ frappe.query_reports["Excise Duty Detailed Report"] = {
"fieldname": "from_date",
"fieldtype": "Date",
"label": "From Date",
"mandatory": 1,
"wildcard_filter": 0
"reqd": 1,
"default": frappe.datetime.month_start()
},
{
"fieldname": "to_date",
"fieldtype": "Date",
"label": "To Date",
"mandatory": 1,
"wildcard_filter": 0
"reqd": 1,
"default": frappe.datetime.get_today()
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ frappe.query_reports["Excise Duty Report"] = {
"fieldname": "from_date",
"fieldtype": "Date",
"label": "From Date",
"mandatory": 1,
"wildcard_filter": 0
"reqd": 1,
"default": frappe.datetime.month_start()
},
{
"fieldname": "to_date",
"fieldtype": "Date",
"label": "To Date",
"mandatory": 1,
"wildcard_filter": 0
"reqd": 1,
"default": frappe.datetime.get_today()
}
]
}
52 changes: 31 additions & 21 deletions csf_tz/csf_tz/report/general_ledger_pro/general_ledger_pro.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
get_dimension_with_children,
)
from erpnext.accounts.report.financial_statements import get_cost_centers_with_children
from erpnext.accounts.report.general_ledger.general_ledger import get_accounts_with_children
from erpnext.accounts.report.utils import convert_to_presentation_currency, get_currency
from erpnext.accounts.utils import get_account_currency
from frappe import _, _dict
Expand Down Expand Up @@ -45,6 +46,16 @@ def execute(filters=None):
return columns, res


def parse_account_filter(account):
"""The desk sends a JSON list; older callers send a single account name."""
if isinstance(account, str):
try:
account = frappe.parse_json(account)
except Exception:
return [account]
return account if isinstance(account, list) else [account]


def validate_filters(filters, account_details):
if not filters.get("company"):
frappe.throw(_("{0} is mandatory").format(_("Company")))
Expand All @@ -54,15 +65,16 @@ def validate_filters(filters, account_details):
_("{0} and {1} are mandatory").format(frappe.bold(_("From Date")), frappe.bold(_("To Date")))
)

if filters.get("account") and not account_details.get(filters.account):
frappe.throw(_("Account {0} does not exists").format(filters.account))
if filters.get("account"):
filters.account = parse_account_filter(filters.get("account"))
for account in filters.account:
if not account_details.get(account):
frappe.throw(_("Account {0} does not exists").format(account))

if (
filters.get("account")
and filters.get("group_by") == _("Group by Account")
and account_details[filters.account].is_group == 0
):
frappe.throw(_("Can not filter based on Account, if grouped by Account"))
if filters.get("account") and filters.get("group_by") == _("Group by Account"):
for account in filters.account:
if account_details[account].is_group == 0:
frappe.throw(_("Can not filter based on Account, if grouped by Account"))

if filters.get("voucher_no") and filters.get("group_by") in [_("Group by Voucher")]:
frappe.throw(_("Can not filter based on Voucher No, if grouped by Voucher"))
Expand Down Expand Up @@ -95,7 +107,8 @@ def set_account_currency(filters):
account_currency = None

if filters.get("account"):
account_currency = get_account_currency(filters.account)
currencies = {get_account_currency(account) for account in filters.account}
account_currency = currencies.pop() if len(currencies) == 1 else None
elif filters.get("party"):
gle_currency = frappe.db.get_value(
"GL Entry",
Expand Down Expand Up @@ -191,13 +204,13 @@ def get_gl_entries(filters, accounting_dimensions):
gl_entries_all_except_students = frappe.db.sql(
f"""
select
gle.name as gl_entry, posting_date, account, party_type, party,
`tabGL Entry`.name as gl_entry, posting_date, account, party_type, party,
voucher_type, voucher_no, {dimension_fields}
cost_center, project,
against_voucher_type, against_voucher, account_currency,
remarks, against, is_opening, gle.creation {select_fields}
from `tabGL Entry` as gle
where party != 'Student' and company=%(company)s {get_conditions(filters)}
remarks, against, is_opening, `tabGL Entry`.creation {select_fields}
from `tabGL Entry`
where ifnull(party, '') != 'Student' and company=%(company)s {get_conditions(filters)}
{distributed_cost_center_query}
{order_by_statement}
""",
Expand All @@ -214,7 +227,7 @@ def get_gl_entries(filters, accounting_dimensions):
gl_entries = (gl_entries_all_except_students or []) + (gl_entries_students or [])

if filters.get("presentation_currency"):
return convert_to_presentation_currency(gl_entries, currency_map, filters.get("company"))
return convert_to_presentation_currency(gl_entries, currency_map, filters)
else:
return gl_entries

Expand All @@ -226,11 +239,11 @@ def get_student_gl_entries(
return frappe.db.sql(
f"""
select
gle.name as gl_entry, posting_date, account, party_type, CONCAT(std.first_name, " ", IFNULL(std.middle_name, ''), " ", IFNULL(std.last_name, '')) as party,
`tabGL Entry`.name as gl_entry, posting_date, account, party_type, CONCAT(std.first_name, " ", IFNULL(std.middle_name, ''), " ", IFNULL(std.last_name, '')) as party,
voucher_type, voucher_no, {dimension_fields}
cost_center, project,
against_voucher_type, against_voucher, account_currency,
remarks, against, is_opening, gle.creation {select_fields}
remarks, against, is_opening, `tabGL Entry`.creation {select_fields}
from `tabGL Entry` AS gle
INNER JOIN `tabStudent` AS std ON gle.party = std.name
where gle.party_type = 'Student' and company=%(company)s {get_conditions(filters)}
Expand All @@ -245,11 +258,8 @@ def get_student_gl_entries(
def get_conditions(filters):
conditions = []
if filters.get("account"):
lft, rgt = frappe.db.get_value("Account", filters["account"], ["lft", "rgt"])
conditions.append(
f"""account in (select name from tabAccount
where lft>={lft} and rgt<={rgt} and docstatus<2)"""
)
filters.account = get_accounts_with_children(filters.account)
conditions.append("account in %(account)s")

if filters.get("cost_center"):
filters.cost_center = get_cost_centers_with_children(filters.cost_center)
Expand Down
1 change: 1 addition & 0 deletions csf_tz/csf_tz/report/gross_profit_pro/gross_profit_pro.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
def execute(filters=None):
if not filters:
filters = frappe._dict()
filters.group_by = filters.get("group_by") or "Invoice"
filters.currency = frappe.get_cached_value("Company", filters.company, "default_currency")

gross_profit_data = GrossProfitGenerator(filters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@


def execute(filters=None):
if not frappe.db.exists("DocType", "Loan Repayment"):
frappe.throw(_("The Lending app is not installed on this site"))

loans = []
data = []
columns = get_columns(filters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,4 @@ frappe.query_reports["Multi-Currency Ledger"] = {
]
}

erpnext.dimension_filters.forEach((dimension) => {
frappe.query_reports["Multi-Currency Ledger"].filters.splice(15, 0 ,{
"fieldname": dimension["fieldname"],
"label": __(dimension["label"]),
"fieldtype": "Link",
"options": dimension["document_type"]
});
});
erpnext.utils.add_dimensions("Multi-Currency Ledger", 15);
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def execute(filters=None):
sales_label = {"details": "Sales - Sales Returns"}
totals = {}
generate_sales_returns(filters, data, totals, sales_label)
if not totals:
return columns, data
data[0]["std_sales"] = fmt_money(float(totals["total_std_sales"]), 2, data[1]["invoice_currency"])
data[0]["vat"] = fmt_money(float(totals["vat"]), 2, data[1]["invoice_currency"])
data[0]["ex_amount"] = fmt_money(float(totals["ex_amount"]), 2, data[1]["invoice_currency"])
Expand All @@ -34,10 +36,9 @@ def generate_credit_note(data, totals, credit_note_label):
if data[i]["details"] != "Credit Note - Sales Returns":
credit_notes = frappe.get_list(
"Sales Invoice",
filters={"is_return": 1, "return_against": "ACC-SINV-2019-07382", "docstatus": 1},
filters={"is_return": 1, "return_against": data[i]["details"], "docstatus": 1},
fields=["*"],
)
print(credit_notes)
for ii in credit_notes:
if i == 1:
data.append(credit_note_label)
Expand Down Expand Up @@ -79,11 +80,16 @@ def generate_credit_note(data, totals, credit_note_label):


def generate_sales_returns(filters, data, totals, sales_label):
efd_z_report_invoices = frappe.get_list(
"EFD Z Report Invoice", filters={"parent": filters.get("efd_report")}, fields=["*"]
efd_z_report_invoices = frappe.get_all(
"EFD Z Report Invoice",
filters={"parent": filters.get("efd_report"), "parenttype": "EFD Z Report"},
fields=["invoice_number"],
parent_doctype="EFD Z Report",
order_by="idx",
)
for idx, i in enumerate(efd_z_report_invoices):
sales_invoice = frappe.get_doc("Sales Invoice", i.invoice_number).__dict__
i.invoice_currency = sales_invoice["currency"]
if idx == 0:
data.append(sales_label)
totals["total_std_sales"] = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
],
"idx": 0,
"is_standard": "Yes",
"modified": "2021-08-21 21:42:36.003335",
"modified": "2026-08-25 07:35:01.417396",
"modified_by": "Administrator",
"module": "CSF TZ",
"name": "Parent Child Relationship",
"owner": "Administrator",
"prepared_report": 0,
"query": "SELECT CONCAT_WS('-', dt.module, dt.name) as name, GROUP_CONCAT(df.options) as imports\nFROM `tabDocType` dt\nINNER JOIN `tabDocField` df ON dt.name = df.parent\nWHERE df.options IS NOT NULL\n AND df.fieldtype = \"Link\"\n AND dt.is_submittable = %(is_submittable)s\n AND dt.istable = %(is_table)s\n AND dt.module = %(module)s\nGROUP BY dt.module, dt.name\nUNION ALL\nSELECT CONCAT_WS('-', dt.module, dt.name) as name, GROUP_CONCAT(df.options) as imports\nFROM `tabDocType` dt\nINNER JOIN `tabCustom Field` df ON dt.name = df.parent\nWHERE df.options IS NOT NULL\n AND df.fieldtype = \"Link\"\n AND dt.is_submittable = %(is_submittable)s\n AND dt.istable = %(is_table)s\n AND dt.module = %(module)s\nGROUP BY dt.module, dt.name",
"query": "SELECT CONCAT_WS('-', dt.module, dt.name) as name, GROUP_CONCAT(df.options) as imports\nFROM `tabDocType` dt\nINNER JOIN `tabDocField` df ON dt.name = df.parent\nWHERE df.options IS NOT NULL\n AND df.fieldtype = \"Link\"\n AND dt.is_submittable = %(is_submittable)s\n AND dt.istable = %(is_table)s\n AND dt.module = %(module)s\nGROUP BY dt.module, dt.name\nUNION ALL\nSELECT CONCAT_WS('-', dt.module, dt.name) as name, GROUP_CONCAT(df.options) as imports\nFROM `tabDocType` dt\nINNER JOIN `tabCustom Field` df ON dt.name = df.dt\nWHERE df.options IS NOT NULL\n AND df.fieldtype = \"Link\"\n AND dt.is_submittable = %(is_submittable)s\n AND dt.istable = %(is_table)s\n AND dt.module = %(module)s\nGROUP BY dt.module, dt.name",
"ref_doctype": "DocType",
"report_name": "Parent Child Relationship",
"report_type": "Query Report",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import erpnext
import frappe
from frappe import _
from frappe.utils import flt
from frappe.utils import cint, flt
from frappe.utils.nestedset import get_descendants_of


Expand Down Expand Up @@ -386,7 +386,9 @@ def get_salary_slips(filters):
query = frappe.qb.from_(salary_slip).select(salary_slip.star)

if filters.get("docstatus"):
query = query.where(salary_slip.docstatus == doc_status[filters.get("docstatus")])
query = query.where(
salary_slip.docstatus == doc_status.get(filters.get("docstatus"), cint(filters.get("docstatus")))
)

if filters.get("from_date"):
query = query.where(salary_slip.start_date >= filters.get("from_date"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import erpnext
import frappe
from frappe import _
from frappe.utils import flt
from frappe.utils import cint, flt
from frappe.utils.nestedset import get_descendants_of


Expand Down Expand Up @@ -187,7 +187,9 @@ def get_conditions(filters, company_currency):
doc_status = {"Draft": 0, "Submitted": 1, "Cancelled": 2}

if filters.get("docstatus"):
conditions += "docstatus = {}".format(doc_status[filters.get("docstatus")])
conditions += "docstatus = {}".format(
doc_status.get(filters.get("docstatus"), cint(filters.get("docstatus")))
)

if filters.get("from_date"):
conditions += " and start_date >= %(from_date)s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import erpnext
import frappe
from frappe import _
from frappe.utils import cint
from frappe.utils.nestedset import get_descendants_of


Expand Down Expand Up @@ -143,7 +144,9 @@ def get_conditions(filters, company_currency):
doc_status = {"Draft": 0, "Submitted": 1, "Cancelled": 2}

if filters.get("docstatus"):
conditions += "docstatus = {}".format(doc_status[filters.get("docstatus")])
conditions += "docstatus = {}".format(
doc_status.get(filters.get("docstatus"), cint(filters.get("docstatus")))
)

if filters.get("from_date"):
conditions += " and start_date >= %(from_date)s"
Expand Down
Loading
Loading