def picking_date_bs(self): """:return the Nepalidate""" if self.date: date_str = str(self.date) format_str = '%Y-%m-%d %H:%M:%S' # The format datetime_obj = datetime.strptime(date_str, format_str) self.date_bs = samwat.from_ad(datetime_obj.date())
def mydate3(self): """:return the Nepalidate""" if self.date: date_str = str(self.date) format_str = '%Y-%m-%d' # The format datetime_obj = datetime.strptime(date_str, format_str) self.nep_jv_date = samwat.from_ad(datetime_obj.date())
def mydate4(self): if self.date_due: """:return the Nepalidate""" date_str2 = str(self.date_due) format_str = '%Y-%m-%d' # The format datetime_obj2 = datetime.strptime(date_str2, format_str) self.nep_due_date = samwat.from_ad(datetime_obj2.date())
def get_request_data(self, market, commodity, category): data = { 'csrf_appcore': self.token, 'market': market['id'], 'category': category['id'], 'commodity': commodity['id'], 'date_from': '2001-01-01', 'date_to': str(samwat.from_ad(date.today())) } return data
def sendBS(request): bs_date = samwat.from_ad(date.today()) return {'bs_date': bs_date}
def get_BS(dateAD): bs_date = samwat.from_ad(dateAD.date()) return bs_date
def calculate(vehicle_registration_type, vehicle, cubic_centimeter_capacity, valid_upto): dates = list((valid_upto.split('-'))) small_vehicle = ['CAR', 'JEEP', 'VAN', 'MICRO-BUS'] power_vehicle = [ 'DOZER', 'EXCAVATOR', 'LOADER', 'ROLLER', 'TIPPER', 'CRANE', 'MINI-TIPPER', 'TRACTOR', 'POWER-TILLER', 'MINI-TRUCK', 'MINI-BUS', 'BUS', 'TRUCK' ] vehicle = vehicle.upper() tax = int() if (int(dates[2]) == 2076): year = '_' + '2075' else: year = '_' + dates[2] if vehicle_registration_type == 'private': database_link = sqlite3.connect('private.db') elif vehicle_registration_type == 'public': database_link = sqlite3.connect('public.db') if vehicle == 'MOTORCYCLE': cursor = database_link.execute('SELECT CC_BEG, CC_END, ' + year + ' FROM MOTORCYCLE') for row in cursor: if cubic_centimeter_capacity >= row[ 0] and cubic_centimeter_capacity <= row[1]: tax = row[2] elif vehicle in small_vehicle: cursor = database_link.execute('SELECT CC_BEG, CC_END, ' + year + ' FROM SMALL_VEH') for row in cursor: if (row[0] <= cubic_centimeter_capacity and row[1] >= cubic_centimeter_capacity): tax = row[2] elif vehicle in power_vehicle: cursor = database_link.execute('SELECT TYPE, ' + year + ' FROM POWER_VEH') for row in cursor: if row[0] == vehicle: tax = row[1] temp = valid_upto valid_upto = samwat(int(dates[2]), int(dates[1]), int(dates[0])) current_date = samwat.from_ad(date.today()) validity = valid_upto + timedelta(days=365) validity = validity.as_tuple() validity = str(validity[2]) + '-' + str(validity[1]) + '-' + str( validity[0]) number_of_days_left = current_date - valid_upto number_of_days_left = number_of_days_left.days if number_of_days_left <= 0: return 0, temp penalty_free_date = valid_upto.as_tuple() if (penalty_free_date[1] + 3 > 12): penalty_free_date = samwat(penalty_free_date[0] + 1, 1, 1) penalty_free_date = penalty_free_date - timedelta(days=1) else: penalty_free_date = samwat(penalty_free_date[0], penalty_free_date[1] + 3, penalty_free_date[2]) if (penalty_free_date >= current_date): return tax, validity days_exceeded = current_date - penalty_free_date days_exceeded = days_exceeded.days if days_exceeded <= 30: tax = tax + (0.05 * tax) elif days_exceeded <= 45: tax = tax + (0.1 * tax) else: current_date = current_date.as_tuple() if current_date[0] == int(dates[2]): tax = tax + (0.2 * tax) else: tax = tax + (0.32 * tax) return tax, validity
def test_from_ad(self): self.assertEqual(samwat.from_ad(self.ad_date), self.bs_date)