[fix] [setup_wizard] fiscal year fix for setup wizard

This commit is contained in:
Akhilesh Darjee
2013-11-25 19:51:18 +05:30
parent 8991ad719c
commit ec0da0b177
16 changed files with 140 additions and 95 deletions

View File

@@ -35,15 +35,15 @@ class DocType:
webnotes.conn.set_default(key, self.doc.fields.get(keydict[key], ''))
# update year start date and year end date from fiscal_year
ysd = webnotes.conn.sql("""select year_start_date from `tabFiscal Year`
where name=%s""", self.doc.current_fiscal_year)
ysd = ysd and ysd[0][0] or ''
from webnotes.utils import get_first_day, get_last_day
if ysd:
year_start_end_date = webnotes.conn.sql("""select year_start_date, year_end_date
from `tabFiscal Year` where name=%s""", self.doc.current_fiscal_year)
ysd = year_start_end_date[0][0] or ''
yed = year_start_end_date[0][1] or ''
if ysd and yed:
webnotes.conn.set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
webnotes.conn.set_default('year_end_date', \
get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d'))
webnotes.conn.set_default('year_end_date', yed.strftime('%Y-%m-%d'))
# enable default currency
if self.doc.default_currency:

View File

@@ -88,9 +88,10 @@ wn.pages['setup-wizard'].onload = function(wrapper) {
placeholder: 'e.g. "My Company LLC"'},
{fieldname:'company_abbr', label: wn._('Company Abbreviation'), fieldtype:'Data',
placeholder:'e.g. "MC"',reqd:1},
{fieldname:'fy_start', label:'Financial Year Start Date', fieldtype:'Select',
description:'Your financial year begins on', reqd:1,
options: ['', '1st Jan', '1st Apr', '1st Jul', '1st Oct'] },
{fieldname:'fy_start_date', label:'Financial Year Start Date', fieldtype:'Date',
description:'Your financial year begins on', reqd:1},
{fieldname:'fy_end_date', label:'Financial Year End Date', fieldtype:'Date',
description:'Your financial year ends on', reqd:1},
{fieldname:'company_tagline', label: wn._('What does it do?'), fieldtype:'Data',
placeholder:'e.g. "Build tools for builders"', reqd:1},
],

View File

@@ -72,18 +72,12 @@ def update_profile_name(args):
add_all_roles_to(args.get("name"))
def create_fiscal_year_and_company(args):
curr_fiscal_year, fy_start_date, fy_abbr = get_fy_details(args.get('fy_start'), True)
curr_fiscal_year = get_fy_details(args.get('fy_start_date'), args.get('fy_end_date'))
webnotes.bean([{
"doctype":"Fiscal Year",
'year': curr_fiscal_year,
'year_start_date': fy_start_date
}]).insert()
curr_fiscal_year, fy_start_date, fy_abbr = get_fy_details(args.get('fy_start'))
webnotes.bean([{
"doctype":"Fiscal Year",
'year': curr_fiscal_year,
'year_start_date': fy_start_date,
'year_start_date': args.get('fy_start_date'),
'year_end_date': args.get('fy_end_date'),
}]).insert()
@@ -196,25 +190,13 @@ def create_email_digest():
edigest.insert()
def get_fy_details(fy_start, last_year=False):
st = {'1st Jan':'01-01','1st Apr':'04-01','1st Jul':'07-01', '1st Oct': '10-01'}
if cint(getdate(nowdate()).month) < cint((st[fy_start].split('-'))[0]):
curr_year = getdate(nowdate()).year - 1
def get_fy_details(fy_start_date, fy_end_date):
start_year = getdate(fy_start_date).year
if start_year == getdate(fy_end_date).year:
fy = cstr(start_year)
else:
curr_year = getdate(nowdate()).year
if last_year:
curr_year = curr_year - 1
stdt = cstr(curr_year)+'-'+cstr(st[fy_start])
if(fy_start == '1st Jan'):
fy = cstr(curr_year)
abbr = cstr(fy)[-2:]
else:
fy = cstr(curr_year) + '-' + cstr(curr_year+1)
abbr = cstr(curr_year)[-2:] + '-' + cstr(curr_year+1)[-2:]
return fy, stdt, abbr
fy = cstr(start_year) + '-' + cstr(start_year + 1)
return fy
def create_taxes(args):
for i in xrange(1,6):