repost balance button removed from period closing voucher

This commit is contained in:
Nabin Hait
2012-07-10 14:24:45 +05:30
parent 0a38e4528b
commit 0aec0e1a63
2 changed files with 130 additions and 199 deletions

View File

@@ -41,8 +41,6 @@ class DocType:
self.year_end_date = '' self.year_end_date = ''
# Validate Account Head
#============================================================
def validate_account_head(self): def validate_account_head(self):
acc_det = sql("select debit_or_credit, is_pl_account, group_or_ledger, company from `tabAccount` where name = '%s'" % (self.doc.closing_account_head)) acc_det = sql("select debit_or_credit, is_pl_account, group_or_ledger, company from `tabAccount` where name = '%s'" % (self.doc.closing_account_head))
@@ -61,8 +59,7 @@ class DocType:
msgprint("Account %s does not belong to Company %s ." % (self.doc.closing_account_head, self.doc.company)) msgprint("Account %s does not belong to Company %s ." % (self.doc.closing_account_head, self.doc.company))
raise Exception raise Exception
# validate posting date
#=============================================================
def validate_posting_date(self): def validate_posting_date(self):
yr = sql("select start_date, end_date from `tabPeriod` where period_name = '%s'" % (self.doc.fiscal_year)) yr = sql("select start_date, end_date from `tabPeriod` where period_name = '%s'" % (self.doc.fiscal_year))
self.year_start_date = yr and yr[0][0] or '' self.year_start_date = yr and yr[0][0] or ''
@@ -79,8 +76,7 @@ class DocType:
msgprint("Another Period Closing Entry: %s has been made after posting date: %s" % (cstr(pce[0][0]), self.doc.posting_date)) msgprint("Another Period Closing Entry: %s has been made after posting date: %s" % (cstr(pce[0][0]), self.doc.posting_date))
raise Exception raise Exception
# Validate closing entry requirement
#==========================================================
def validate_pl_balances(self): def validate_pl_balances(self):
income_bal = sql("select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) from `tabGL Entry` t1, tabAccount t2 where t1.account = t2.name and t1.posting_date between '%s' and '%s' and t2.debit_or_credit = 'Credit' and t2.group_or_ledger = 'Ledger' and ifnull(t2.freeze_account, 'No') = 'No' and t2.is_pl_account = 'Yes' and t2.docstatus < 2 and t2.company = '%s'" % (self.year_start_date, self.doc.posting_date, self.doc.company)) income_bal = sql("select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) from `tabGL Entry` t1, tabAccount t2 where t1.account = t2.name and t1.posting_date between '%s' and '%s' and t2.debit_or_credit = 'Credit' and t2.group_or_ledger = 'Ledger' and ifnull(t2.freeze_account, 'No') = 'No' and t2.is_pl_account = 'Yes' and t2.docstatus < 2 and t2.company = '%s'" % (self.year_start_date, self.doc.posting_date, self.doc.company))
expense_bal = sql("select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) from `tabGL Entry` t1, tabAccount t2 where t1.account = t2.name and t1.posting_date between '%s' and '%s' and t2.debit_or_credit = 'Debit' and t2.group_or_ledger = 'Ledger' and ifnull(t2.freeze_account, 'No') = 'No' and t2.is_pl_account = 'Yes' and t2.docstatus < 2 and t2.company = '%s'" % (self.year_start_date, self.doc.posting_date, self.doc.company)) expense_bal = sql("select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) from `tabGL Entry` t1, tabAccount t2 where t1.account = t2.name and t1.posting_date between '%s' and '%s' and t2.debit_or_credit = 'Debit' and t2.group_or_ledger = 'Ledger' and ifnull(t2.freeze_account, 'No') = 'No' and t2.is_pl_account = 'Yes' and t2.docstatus < 2 and t2.company = '%s'" % (self.year_start_date, self.doc.posting_date, self.doc.company))
@@ -92,15 +88,13 @@ class DocType:
msgprint("Both Income and Expense balances are zero. No Need to make Period Closing Entry.") msgprint("Both Income and Expense balances are zero. No Need to make Period Closing Entry.")
raise Exception raise Exception
# Get account (pl) specific balance
#===========================================================
def get_pl_balances(self, d_or_c): def get_pl_balances(self, d_or_c):
"""Get account (pl) specific balance"""
acc_bal = sql("select t1.account, sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) from `tabGL Entry` t1, `tabAccount` t2 where t1.account = t2.name and t2.group_or_ledger = 'Ledger' and ifnull(t2.freeze_account, 'No') = 'No' and ifnull(t2.is_pl_account, 'No') = 'Yes' and ifnull(is_cancelled, 'No') = 'No' and t2.debit_or_credit = '%s' and t2.docstatus < 2 and t2.company = '%s' and t1.posting_date between '%s' and '%s' group by t1.account " % (d_or_c, self.doc.company, self.year_start_date, self.doc.posting_date)) acc_bal = sql("select t1.account, sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) from `tabGL Entry` t1, `tabAccount` t2 where t1.account = t2.name and t2.group_or_ledger = 'Ledger' and ifnull(t2.freeze_account, 'No') = 'No' and ifnull(t2.is_pl_account, 'No') = 'Yes' and ifnull(is_cancelled, 'No') = 'No' and t2.debit_or_credit = '%s' and t2.docstatus < 2 and t2.company = '%s' and t1.posting_date between '%s' and '%s' group by t1.account " % (d_or_c, self.doc.company, self.year_start_date, self.doc.posting_date))
return acc_bal return acc_bal
# Makes GL Entries
# ==========================================================
def make_gl_entries(self, acc_det): def make_gl_entries(self, acc_det):
for a in acc_det: for a in acc_det:
if flt(a[1]): if flt(a[1]):
@@ -126,8 +120,6 @@ class DocType:
self.save_entry(fdict) self.save_entry(fdict)
# Save GL Entry
# ==========================================================
def save_entry(self, fdict, is_cancel = 'No'): def save_entry(self, fdict, is_cancel = 'No'):
# Create new GL entry object and map values # Create new GL entry object and map values
le = Document('GL Entry') le = Document('GL Entry')
@@ -148,27 +140,7 @@ class DocType:
le_obj.on_update(adv_adj = '', cancel = '') le_obj.on_update(adv_adj = '', cancel = '')
# Reposting Balances
# ==========================================================
def repost_account_balances(self):
# Get Next Fiscal Year
fy = sql("select name, is_fiscal_year_closed from `tabFiscal Year` where name = '%s' and past_year = '%s'" % (self.doc.next_fiscal_year, self.doc.fiscal_year))
if not fy:
msgprint("There is no Fiscal Year with Name " + cstr(self.doc.next_fiscal_year) + " and Past Year " + cstr(self.doc.fiscal_year))
raise Exception
if fy and fy[0][1] == 'Yes':
msgprint("Fiscal Year %s has been closed." % cstr(fy[1]))
raise Exception
# Repost Balances
get_obj('Fiscal Year', fy[0][0]).repost()
# Validation
# ===========================================================
def validate(self): def validate(self):
# validate account head # validate account head
self.validate_account_head() self.validate_account_head()
@@ -179,8 +151,6 @@ class DocType:
self.validate_pl_balances() self.validate_pl_balances()
# On Submit
# ===========================================================
def on_submit(self): def on_submit(self):
# Makes closing entries for Expense Account # Makes closing entries for Expense Account
@@ -197,8 +167,6 @@ class DocType:
self.make_gl_entries([[self.doc.closing_account_head, flt(bal)]]) self.make_gl_entries([[self.doc.closing_account_head, flt(bal)]])
# On Cancel
# =============================================================
def on_cancel(self): def on_cancel(self):
# get all submit entries of current closing entry voucher # get all submit entries of current closing entry voucher
gl_entries = sql("select account, debit, credit from `tabGL Entry` where voucher_type = 'Period Closing Voucher' and voucher_no = '%s' and ifnull(is_cancelled, 'No') = 'No'" % (self.doc.name)) gl_entries = sql("select account, debit, credit from `tabGL Entry` where voucher_type = 'Period Closing Voucher' and voucher_no = '%s' and ifnull(is_cancelled, 'No') = 'No'" % (self.doc.name))

View File

@@ -3,9 +3,9 @@
# These values are common in all dictionaries # These values are common in all dictionaries
{ {
'creation': '2012-04-13 11:56:17', 'creation': '2012-06-11 12:09:52',
'docstatus': 0, 'docstatus': 0,
'modified': '2012-05-31 11:38:17', 'modified': '2012-07-10 14:21:21',
'modified_by': u'Administrator', 'modified_by': u'Administrator',
'owner': u'jai@webnotestech.com' 'owner': u'jai@webnotestech.com'
}, },
@@ -273,42 +273,5 @@
'permlevel': 0, 'permlevel': 0,
'print_hide': 1, 'print_hide': 1,
'search_index': 0 'search_index': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'repost_account_balances',
'fieldtype': u'Section Break',
'label': u'Repost Account Balances',
'oldfieldtype': u'Section Break',
'options': u'Simple',
'permlevel': 0
},
# DocField
{
'allow_on_submit': 1,
'doctype': u'DocField',
'fieldname': u'next_fiscal_year',
'fieldtype': u'Select',
'label': u'Fiscal Year (For Reposting)',
'oldfieldname': u'next_fiscal_year',
'oldfieldtype': u'Select',
'options': u'link:Fiscal Year',
'permlevel': 0
},
# DocField
{
'allow_on_submit': 1,
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'repost',
'fieldtype': u'Button',
'label': u'Repost',
'oldfieldtype': u'Button',
'options': u'repost_account_balances',
'permlevel': 0
} }
] ]