fix display unclosed values for trial/balance/sheet
This commit is contained in:
parent
d97200cb5a
commit
ea3b342dde
@ -14,17 +14,31 @@ def execute(filters=None):
|
||||
liability = get_data(filters.company, "Liability", "Credit", period_list, only_current_fiscal_year=False)
|
||||
equity = get_data(filters.company, "Equity", "Credit", period_list, only_current_fiscal_year=False)
|
||||
|
||||
provisional_profit_loss = get_provisional_profit_loss(asset, liability, equity,
|
||||
provisional_profit_loss,total_credit = get_provisional_profit_loss(asset, liability, equity,
|
||||
period_list, filters.company)
|
||||
|
||||
message = check_opening_balance(asset, liability, equity)
|
||||
message,opening_balance = check_opening_balance(asset, liability, equity)
|
||||
|
||||
data = []
|
||||
data.extend(asset or [])
|
||||
data.extend(liability or [])
|
||||
data.extend(equity or [])
|
||||
if opening_balance and round(opening_balance,2) !=0:
|
||||
unclosed ={
|
||||
"account_name": "'" + _("Unclosed Fiscal Years Profit / Loss (Credit)") + "'",
|
||||
"account": None,
|
||||
"warn_if_negative": True,
|
||||
"currency": frappe.db.get_value("Company", filters.company, "default_currency")
|
||||
}
|
||||
for period in period_list:
|
||||
unclosed[period.key] = opening_balance
|
||||
provisional_profit_loss[period.key] = provisional_profit_loss[period.key] - opening_balance
|
||||
unclosed["total"]=opening_balance
|
||||
data.append(unclosed)
|
||||
|
||||
if provisional_profit_loss:
|
||||
data.append(provisional_profit_loss)
|
||||
data.append(total_credit)
|
||||
|
||||
columns = get_columns(filters.periodicity, period_list, company=filters.company)
|
||||
|
||||
@ -34,14 +48,20 @@ def execute(filters=None):
|
||||
|
||||
def get_provisional_profit_loss(asset, liability, equity, period_list, company):
|
||||
if asset and (liability or equity):
|
||||
total=0
|
||||
total = total_total=0
|
||||
currency = frappe.db.get_value("Company", company, "default_currency")
|
||||
provisional_profit_loss = {
|
||||
"account_name": "'" + _("Provisional Profit / Loss (Credit)") + "'",
|
||||
"account": None,
|
||||
"warn_if_negative": True,
|
||||
"currency": frappe.db.get_value("Company", company, "default_currency")
|
||||
"currency": currency
|
||||
}
|
||||
total_row = {
|
||||
"account_name": "'" + _("Total (Credit)") + "'",
|
||||
"account": None,
|
||||
"warn_if_negative": True,
|
||||
"currency": currency
|
||||
}
|
||||
|
||||
has_value = False
|
||||
|
||||
for period in period_list:
|
||||
@ -52,15 +72,20 @@ def get_provisional_profit_loss(asset, liability, equity, period_list, company):
|
||||
effective_liability += flt(equity[-2].get(period.key))
|
||||
|
||||
provisional_profit_loss[period.key] = flt(asset[-2].get(period.key)) - effective_liability
|
||||
total_row[period.key] = effective_liability + provisional_profit_loss[period.key]
|
||||
|
||||
if provisional_profit_loss[period.key]:
|
||||
has_value = True
|
||||
|
||||
total += flt(provisional_profit_loss[period.key])
|
||||
provisional_profit_loss["total"] = total
|
||||
|
||||
total_total += flt(total_row[period.key])
|
||||
total_row["total"] = total_total
|
||||
|
||||
if has_value:
|
||||
return provisional_profit_loss
|
||||
return provisional_profit_loss, total_row
|
||||
return None,total_row
|
||||
|
||||
def check_opening_balance(asset, liability, equity):
|
||||
# Check if previous year balance sheet closed
|
||||
@ -73,7 +98,8 @@ def check_opening_balance(asset, liability, equity):
|
||||
opening_balance -= flt(equity[0].get("opening_balance", 0))
|
||||
|
||||
if opening_balance:
|
||||
return _("Previous Financial Year is not closed")
|
||||
return _("Previous Financial Year is not closed"),opening_balance
|
||||
return None,None
|
||||
|
||||
def get_chart_data(columns, asset, liability, equity):
|
||||
x_intervals = ['x'] + [d.get("label") for d in columns[2:]]
|
||||
|
@ -87,8 +87,7 @@ def get_opening_balances(filters):
|
||||
|
||||
|
||||
def get_rootwise_opening_balances(filters, report_type):
|
||||
additional_conditions = " and posting_date >= %(year_start_date)s" \
|
||||
if report_type == "Profit and Loss" else ""
|
||||
additional_conditions = ""
|
||||
|
||||
if not flt(filters.with_period_closing_entry):
|
||||
additional_conditions += " and ifnull(voucher_type, '')!='Period Closing Voucher'"
|
||||
|
Loading…
x
Reference in New Issue
Block a user