'Get balance for pl accounts'

def get_pl_balances(self):

    return frappe.db.sql(u"\n DCTB  DCTB  DCTB select\n DCTB  DCTB  DCTB  DCTB t1.account,    t1.cost_center,    t2.account_currency,\n DCTB  DCTB  DCTB  DCTB sum(t1.debit_in_account_currency)    -    sum(t1.credit_in_account_currency)    as    balance_in_account_currency,\n DCTB  DCTB  DCTB  DCTB sum(t1.debit)    -    sum(t1.credit)    as    balance_in_company_currency\n DCTB  DCTB  DCTB from    `tabGL    Entry`    t1,    `tabAccount`    t2\n DCTB  DCTB  DCTB where    t1.account    =    t2.name    and    t2.report_type    =    'Profit    and    Loss'\n DCTB  DCTB  DCTB and    t2.docstatus    <    2    and    t2.company    =    %s\n DCTB  DCTB  DCTB and    t1.posting_date    between    %s    and    %s\n DCTB  DCTB  DCTB group    by    t1.account,    t1.cost_center\n DCTB  DCTB ", (self.company, self.get(u'year_start_date'), self.posting_date), as_dict=1)
