def save(self, *args, **kwargs): if not self.code: self.code = str(self.company.id) + '-' + str(self.get_code(10000, 99999)) if self.used_by: self.date = today() super(Pin, self).save(*args, **kwargs)
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
def save(self, *args, **kwargs): if not self.code: self.code = str(self.company.id) + '-' + str( self.get_code(10000, 99999)) if self.used_by: self.date = today() super(Pin, self).save(*args, **kwargs)