[report] fix via error report
This commit is contained in:
parent
2437d4cce2
commit
b4c4351513
@ -29,7 +29,7 @@ frappe.query_reports["Payment Period Based On Invoice Date"] = {
|
||||
options: "Account",
|
||||
get_query: function() {
|
||||
return {
|
||||
query: "erpnext.controllers.queries.get_account_list",
|
||||
query: "erpnext.controllers.queries.get_account_list",
|
||||
filters: {
|
||||
"report_type": "Balance Sheet",
|
||||
company: frappe.query_report.filters_by_name.company.get_value()
|
||||
@ -42,7 +42,8 @@ frappe.query_reports["Payment Period Based On Invoice Date"] = {
|
||||
label: __("Company"),
|
||||
fieldtype: "Link",
|
||||
options: "Company",
|
||||
reqd: 1,
|
||||
default: frappe.defaults.get_user_default("company")
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,9 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import msgprint, _
|
||||
from frappe import _
|
||||
from erpnext.accounts.report.accounts_receivable.accounts_receivable import get_ageing_data
|
||||
from frappe.utils import flt
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
@ -19,16 +20,16 @@ def execute(filters=None):
|
||||
for d in entries:
|
||||
if d.against_voucher:
|
||||
against_date = d.against_voucher and invoice_posting_date_map[d.against_voucher] or ""
|
||||
outstanding_amount = d.debit or -1*d.credit
|
||||
outstanding_amount = flt(d.debit) or -1 * flt(d.credit)
|
||||
else:
|
||||
against_date = d.against_invoice and invoice_posting_date_map[d.against_invoice] or ""
|
||||
outstanding_amount = d.credit or -1*d.debit
|
||||
outstanding_amount = flt(d.credit) or -1 * flt(d.debit)
|
||||
|
||||
row = [d.name, d.account, d.posting_date, d.against_voucher or d.against_invoice,
|
||||
against_date, d.debit, d.credit, d.cheque_no, d.cheque_date, d.remark]
|
||||
|
||||
if d.against_voucher or d.against_invoice:
|
||||
row += get_ageing_data(d.posting_date, against_date, outstanding_amount)
|
||||
row += get_ageing_data(30, 60, 90, d.posting_date, against_date, outstanding_amount)
|
||||
else:
|
||||
row += ["", "", "", "", ""]
|
||||
|
||||
@ -46,40 +47,40 @@ def get_columns():
|
||||
|
||||
def get_conditions(filters):
|
||||
conditions = ""
|
||||
party_accounts = []
|
||||
party = None
|
||||
|
||||
if filters.get("account"):
|
||||
party_accounts = [filters["account"]]
|
||||
party = filters["account"]
|
||||
else:
|
||||
cond = filters.get("company") and (" and company = '%s'" %
|
||||
filters["company"].replace("'", "\'")) or ""
|
||||
conditions += " and company = '%s'" % frappe.db.escape(filters["company"])
|
||||
|
||||
if filters.get("payment_type") == "Incoming":
|
||||
cond += " and master_type = 'Customer'"
|
||||
else:
|
||||
cond += " and master_type = 'Supplier'"
|
||||
account_type = "Receivable" if filters.get("payment_type") == "Incoming" else "Payable"
|
||||
|
||||
party_accounts = frappe.db.sql_list("""select name from `tabAccount`
|
||||
where ifnull(master_name, '')!='' and docstatus < 2 %s""" % cond)
|
||||
conditions += """ and account in
|
||||
(select name from tabAccount
|
||||
where account_type = '{0}'
|
||||
and company='{1}')""".format(account_type, frappe.db.escape(filters["company"]))
|
||||
|
||||
if party_accounts:
|
||||
conditions += " and jvd.account in (%s)" % (", ".join(['%s']*len(party_accounts)))
|
||||
if party:
|
||||
conditions += " and jvd.party = '%s'" % frappe.db.escape(party)
|
||||
else:
|
||||
msgprint(_("No Customer or Supplier Accounts found"), raise_exception=1)
|
||||
conditions += " and ifnull(jvd.party, '') != ''"
|
||||
|
||||
if filters.get("from_date"): conditions += " and jv.posting_date >= '%s'" % filters["from_date"]
|
||||
if filters.get("to_date"): conditions += " and jv.posting_date <= '%s'" % filters["to_date"]
|
||||
if filters.get("from_date"):
|
||||
conditions += " and jv.posting_date >= '%s'" % filters["from_date"]
|
||||
if filters.get("to_date"):
|
||||
conditions += " and jv.posting_date <= '%s'" % filters["to_date"]
|
||||
|
||||
return conditions, party_accounts
|
||||
return conditions
|
||||
|
||||
def get_entries(filters):
|
||||
conditions, party_accounts = get_conditions(filters)
|
||||
conditions = get_conditions(filters)
|
||||
entries = frappe.db.sql("""select jv.name, jvd.account, jv.posting_date,
|
||||
jvd.against_voucher, jvd.against_invoice, jvd.debit, jvd.credit,
|
||||
jv.cheque_no, jv.cheque_date, jv.remark
|
||||
from `tabJournal Entry Account` jvd, `tabJournal Entry` jv
|
||||
where jvd.parent = jv.name and jv.docstatus=1 %s order by jv.name DESC""" %
|
||||
(conditions), tuple(party_accounts), as_dict=1)
|
||||
conditions, as_dict=1, debug=1)
|
||||
|
||||
return entries
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user