From 46d437e2efd906ca1f7960b5fe96c0289795019e Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 27 Feb 2013 18:55:37 +0530 Subject: [PATCH] fix in get previous fiscal year for leave allocation --- hr/doctype/leave_allocation/leave_allocation.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hr/doctype/leave_allocation/leave_allocation.py b/hr/doctype/leave_allocation/leave_allocation.py index 870a040a27..d2d940f6c9 100755 --- a/hr/doctype/leave_allocation/leave_allocation.py +++ b/hr/doctype/leave_allocation/leave_allocation.py @@ -103,8 +103,10 @@ class DocType: def get_carry_forwarded_leaves(self): if self.doc.carry_forward: self.allow_carry_forward() - prev_fiscal_year = sql("""select name from `tabFiscal Year` - where name < %s order by name desc limit 1""", self.doc.fiscal_year) + prev_fiscal_year = webnotes.conn.sql("""select name from `tabFiscal Year` + where year_start_date = (select date_add(year_start_date, interval -1 year) + from `tabFiscal Year` where name=%s) + order by name desc limit 1""", self.doc.fiscal_year) prev_fiscal_year = prev_fiscal_year and prev_fiscal_year[0][0] or '' prev_bal = 0 if prev_fiscal_year and cint(self.doc.carry_forward) == 1: