def create_account_balances(self): # get periods period_list = self.get_period_list() cnt = 0 # get accounts al = sql("select name from tabAccount") for a in al: # check if sql("select count(*) from `tabAccount Balance` where fiscal_year=%s and account=%s", (self.doc.name, a[0]))[0][0] < 13: for p in period_list: # check if missing if not sql("select name from `tabAccount Balance` where period=%s and account=%s and fiscal_year=%s", (p[0], a[0], self.doc.name)): d = Document('Account Balance') d.account = a[0] d.period = p[0] d.start_date = p[1].strftime('%Y-%m-%d') d.end_date = p[2].strftime('%Y-%m-%d') d.fiscal_year = p[3] d.debit = 0 d.credit = 0 d.opening = 0 d.balance = 0 d.save(1) cnt += 1 if cnt % 100 == 0: sql("commit") sql("start transaction") return cnt
def create_account_balances(self): # get periods period_list = self.get_period_list() cnt = 0 # get accounts al = sql("select name from tabAccount") for a in al: # check if sql( "select count(*) from `tabAccount Balance` where fiscal_year=%s and account=%s", (self.doc.name, a[0]))[0][0] < 13: for p in period_list: # check if missing if not sql( "select name from `tabAccount Balance` where period=%s and account=%s and fiscal_year=%s", (p[0], a[0], self.doc.name)): d = Document('Account Balance') d.account = a[0] d.period = p[0] d.start_date = p[1].strftime('%Y-%m-%d') d.end_date = p[2].strftime('%Y-%m-%d') d.fiscal_year = p[3] d.debit = 0 d.credit = 0 d.opening = 0 d.balance = 0 d.save(1) cnt += 1 if cnt % 100 == 0: sql("commit") sql("start transaction") return cnt
def create_new_balances(self, det): # check if sql( "select count(t1.name) from `tabAccount Balance` t1, tabAccount t2 where t1.fiscal_year=%s and t2.lft <= %s and t2.rgt >= %s and t2.name = t1.account", (self.doc.fiscal_year, det[0][0], det[0][1] ))[0][0] < 13 * (cint(det[0][1]) - cint(det[0][0]) + 1) / 2: period_list = self.get_period_list() accounts = sql( "select name from tabAccount where lft <= %s and rgt >= %s" % (det[0][0], det[0][1])) for p in period_list: for a in accounts: # check if missing if not sql( "select name from `tabAccount Balance` where period=%s and account=%s and fiscal_year=%s", (p[0], a[0], self.doc.fiscal_year)): d = Document('Account Balance') d.account = a[0] d.period = p[0] d.start_date = p[1].strftime('%Y-%m-%d') d.end_date = p[2].strftime('%Y-%m-%d') d.fiscal_year = self.doc.fiscal_year d.debit = 0 d.credit = 0 d.opening = 0 d.balance = 0 d.save(1)
def set_year_balance(self): p = sql("select name, start_date, end_date, fiscal_year from `tabPeriod` where docstatus != 2 and period_type in ('Month', 'Year')") for d in p: if not sql("select name from `tabAccount Balance` where account=%s and period=%s", (self.doc.name, d[0])): ac = Document('Account Balance') ac.account = self.doc.name ac.period = d[0] ac.start_date = d[1].strftime('%Y-%m-%d') ac.end_date = d[2].strftime('%Y-%m-%d') ac.fiscal_year = d[3] ac.opening = 0 ac.debit = 0 ac.credit = 0 ac.balance = 0 ac.save(1)
def create_new_balances(self, det): # check if sql("select count(t1.name) from `tabAccount Balance` t1, tabAccount t2 where t1.fiscal_year=%s and t2.lft <= %s and t2.rgt >= %s and t2.name = t1.account", (self.doc.fiscal_year, det[0][0], det[0][1]))[0][0] < 13*(cint(det[0][1]) - cint(det[0][0]) +1)/2: period_list = self.get_period_list() accounts = sql("select name from tabAccount where lft <= %s and rgt >= %s" % (det[0][0], det[0][1])) for p in period_list: for a in accounts: # check if missing if not sql("select name from `tabAccount Balance` where period=%s and account=%s and fiscal_year=%s", (p[0], a[0], self.doc.fiscal_year)): d = Document('Account Balance') d.account = a[0] d.period = p[0] d.start_date = p[1].strftime('%Y-%m-%d') d.end_date = p[2].strftime('%Y-%m-%d') d.fiscal_year = self.doc.fiscal_year d.debit = 0 d.credit = 0 d.opening = 0 d.balance = 0 d.save(1)