Beispiel #1
0
 def get_fy(self, dt=None):
     # returns bs year for nepali fy system, ad for another
     dt = dt or today()
     calendar = get_calendar()
     if type(dt) == str or type(dt) == unicode:
         dt = tuple_from_string(dt)
     if self.use_nepali_fy_system:
         if calendar == 'ad':
             dt = ad2bs(dt)
         if type(dt) == tuple:
             dt = string_from_tuple(dt)
         month = int(dt.split('-')[1])
         year = int(dt.split('-')[0])
         if month < 4:
             year -= 1
     else:
         if type(dt) == tuple:
             dt = date_from_tuple(dt)
         if calendar == 'bs':
             dt = date_from_tuple(bs2ad(dt))
         if dt.month < self.fy_start_month:
             return dt.year - 1
         if dt.month > self.fy_start_month:
             return dt.year
         if dt.month == self.fy_start_month:
             if dt.day < self.fy_start_day:
                 return dt.year - 1
             return dt.year
     return year
Beispiel #2
0
 def get_fy(self, dt=None):
     # returns bs year for nepali fy system, ad for another
     dt = dt or today()
     calendar = get_calendar()
     if type(dt) == str or type(dt) == unicode:
         dt = tuple_from_string(dt)
     if self.use_nepali_fy_system:
         if calendar == 'ad':
             dt = ad2bs(dt)
         if type(dt) == tuple:
             dt = string_from_tuple(dt)
         month = int(dt.split('-')[1])
         year = int(dt.split('-')[0])
         if month < 4:
             year -= 1
     else:
         if type(dt) == tuple:
             dt = date_from_tuple(dt)
         if calendar == 'bs':
             dt = date_from_tuple(bs2ad(dt))
         if dt.month < self.fy_start_month:
             return dt.year - 1
         if dt.month > self.fy_start_month:
             return dt.year
         if dt.month == self.fy_start_month:
             if dt.day < self.fy_start_day:
                 return dt.year - 1
             return dt.year
     return year
Beispiel #3
0
 def get_fy_end(self, dt=None, year=None):
     calendar = get_calendar()
     year = year or self.get_fy(dt)
     if self.use_nepali_fy_system:
         # get fy end in bs
         fiscal_year_end = str(int(year) + 1) + '-03-' + str(bs[int(year) + 1][2])
         tuple_value = tuple_from_string(fiscal_year_end)
         if calendar == 'ad':
             tuple_value = bs2ad(tuple_value)
     else:
         # get fy end in ad
         fiscal_year_end = date(int(year) + 1, self.fy_start_month, self.fy_start_day) - timedelta(days=1)
         tuple_value = tuple_from_date(fiscal_year_end)
         if calendar == 'bs':
             tuple_value = ad2bs(tuple_value)
     return tuple_value
Beispiel #4
0
 def get_fy_start(self, dt=None, year=None):
     calendar = get_calendar()
     year = year or self.get_fy(dt)
     if self.use_nepali_fy_system:
         # get fy start in bs
         fiscal_year_start = str(year) + '-04-01'
         tuple_value = tuple_from_string(fiscal_year_start)
         if calendar == 'ad':
             tuple_value = bs2ad(tuple_value)
     else:
         # get fy start in ad
         fiscal_year_start = str(year) + '-' + str(self.fy_start_month) + '-' + str(self.fy_start_day)
         tuple_value = tuple_from_string(fiscal_year_start)
         if calendar == 'bs':
             tuple_value = ad2bs(tuple_value)
     return tuple_value
Beispiel #5
0
 def get_fy_start(self, dt=None, year=None):
     calendar = get_calendar()
     year = year or self.get_fy(dt)
     if self.use_nepali_fy_system:
         # get fy start in bs
         fiscal_year_start = str(year) + '-04-01'
         tuple_value = tuple_from_string(fiscal_year_start)
         if calendar == 'ad':
             tuple_value = bs2ad(tuple_value)
     else:
         # get fy start in ad
         fiscal_year_start = str(year) + '-' + str(
             self.fy_start_month) + '-' + str(self.fy_start_day)
         tuple_value = tuple_from_string(fiscal_year_start)
         if calendar == 'bs':
             tuple_value = ad2bs(tuple_value)
     return tuple_value
Beispiel #6
0
 def get_fy_end(self, dt=None, year=None):
     calendar = get_calendar()
     year = year or self.get_fy(dt)
     if self.use_nepali_fy_system:
         # get fy end in bs
         fiscal_year_end = str(int(year) + 1) + '-03-' + str(
             bs[int(year) + 1][2])
         tuple_value = tuple_from_string(fiscal_year_end)
         if calendar == 'ad':
             tuple_value = bs2ad(tuple_value)
     else:
         # get fy end in ad
         fiscal_year_end = date(
             int(year) + 1, self.fy_start_month,
             self.fy_start_day) - timedelta(days=1)
         tuple_value = tuple_from_date(fiscal_year_end)
         if calendar == 'bs':
             tuple_value = ad2bs(tuple_value)
     return tuple_value