commit
7ed4e080a2
@ -210,7 +210,7 @@ def get_gl_entries(company, from_date, to_date, root_lft, root_rgt, ignore_closi
|
|||||||
if from_date:
|
if from_date:
|
||||||
additional_conditions.append("and posting_date >= %(from_date)s")
|
additional_conditions.append("and posting_date >= %(from_date)s")
|
||||||
|
|
||||||
gl_entries = frappe.db.sql("""select posting_date, account, debit, credit from `tabGL Entry`
|
gl_entries = frappe.db.sql("""select posting_date, account, debit, credit, is_opening from `tabGL Entry`
|
||||||
where company=%(company)s
|
where company=%(company)s
|
||||||
{additional_conditions}
|
{additional_conditions}
|
||||||
and posting_date <= %(to_date)s
|
and posting_date <= %(to_date)s
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import flt, getdate
|
from frappe.utils import flt, getdate, cstr
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
@ -155,7 +155,7 @@ def get_accountwise_gle(filters, gl_entries, gle_map):
|
|||||||
for gle in gl_entries:
|
for gle in gl_entries:
|
||||||
amount = flt(gle.debit, 3) - flt(gle.credit, 3)
|
amount = flt(gle.debit, 3) - flt(gle.credit, 3)
|
||||||
if (filters.get("account") or filters.get("party") or filters.get("group_by_account")) \
|
if (filters.get("account") or filters.get("party") or filters.get("group_by_account")) \
|
||||||
and gle.posting_date < from_date:
|
and (gle.posting_date < from_date or cstr(gle.is_opening) == "Yes"):
|
||||||
gle_map[gle.account].opening += amount
|
gle_map[gle.account].opening += amount
|
||||||
if filters.get("account") or filters.get("party"):
|
if filters.get("account") or filters.get("party"):
|
||||||
opening += amount
|
opening += amount
|
||||||
|
@ -90,7 +90,7 @@ def get_rootwise_opening_balances(filters, report_type):
|
|||||||
where
|
where
|
||||||
company=%(company)s
|
company=%(company)s
|
||||||
{additional_conditions}
|
{additional_conditions}
|
||||||
and posting_date < %(from_date)s
|
and (posting_date < %(from_date)s or ifnull(is_opening, 'No') = 'Yes')
|
||||||
and account in (select name from `tabAccount` where report_type=%(report_type)s)
|
and account in (select name from `tabAccount` where report_type=%(report_type)s)
|
||||||
group by account""".format(additional_conditions=additional_conditions),
|
group by account""".format(additional_conditions=additional_conditions),
|
||||||
{
|
{
|
||||||
@ -128,16 +128,21 @@ def calculate_values(accounts, gl_entries_by_account, opening_balances, filters)
|
|||||||
for d in accounts:
|
for d in accounts:
|
||||||
d.update(init.copy())
|
d.update(init.copy())
|
||||||
|
|
||||||
|
# add opening
|
||||||
|
d["opening_debit"] = opening_balances.get(d.name, {}).get("opening_debit", 0)
|
||||||
|
d["opening_credit"] = opening_balances.get(d.name, {}).get("opening_credit", 0)
|
||||||
|
|
||||||
for entry in gl_entries_by_account.get(d.name, []):
|
for entry in gl_entries_by_account.get(d.name, []):
|
||||||
|
if entry.is_opening == "Yes" and d.root_type in ("Asset", "Liability", "Equity"):
|
||||||
|
d["opening_debit"] += flt(entry.debit)
|
||||||
|
d["opening_credit"] += flt(entry.credit)
|
||||||
|
else:
|
||||||
d["debit"] += flt(entry.debit)
|
d["debit"] += flt(entry.debit)
|
||||||
d["credit"] += flt(entry.credit)
|
d["credit"] += flt(entry.credit)
|
||||||
|
|
||||||
total_row["debit"] += d["debit"]
|
total_row["debit"] += d["debit"]
|
||||||
total_row["credit"] += d["credit"]
|
total_row["credit"] += d["credit"]
|
||||||
|
|
||||||
# add opening
|
|
||||||
d["opening_debit"] = opening_balances.get(d.name, {}).get("opening_debit", 0)
|
|
||||||
d["opening_credit"] = opening_balances.get(d.name, {}).get("opening_credit", 0)
|
|
||||||
|
|
||||||
return total_row
|
return total_row
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ class NamingSeries(Document):
|
|||||||
except frappe.DoesNotExistError:
|
except frappe.DoesNotExistError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if options:
|
||||||
prefixes = prefixes + "\n" + options
|
prefixes = prefixes + "\n" + options
|
||||||
|
|
||||||
prefixes.replace("\n\n", "\n")
|
prefixes.replace("\n\n", "\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user