def _convert_date(self, name, value, explicit_type=True): try: dt = convert_date(value, result_format='datetime') if dt.hour or dt.minute or dt.second or dt.microsecond: raise ValueError return dt.date() except ValueError: return self._handle_error(name, value, 'date', explicit_type)
def _expiry(self, expiry: str) -> int: try: expiry_cleaned = str(expiry) expiry_cleaned = expiry_cleaned.split(".")[0] expiry_cleaned = expiry_cleaned.split(",")[0] expiry_cleaned = expiry_cleaned.replace(" ", "") return int(expiry_cleaned) except ValueError: return int(convert_date(expiry, result_format="epoch"))
def __init__(self, **kwargs): random_year = random.randint(1971, 2100) random_month = format(random.randint(1, 12), '02') bill_period = "{}-{}".format(random_year, random_month) self.bill_period = kwargs.get('bill_period', bill_period) issue_date = int( convert_date("{}-10".format(self.bill_period), result_format='epoch')) due_date = int( convert_date("{}-20".format(self.bill_period), result_format='epoch')) due_date = int( get_current_date(increment='15 days', result_format='epoch', exclude_millis='yes')) self.date_from = int( get_current_date(increment='-15 days', result_format='epoch', exclude_millis='yes')) self.date_to = int( get_current_date(increment='15 days', result_format='epoch', exclude_millis='yes')) self.last_calc_date = self.date_from - 86400 self.accumulated_es_bill_id = kwargs.get('accumulated_es_bill_id', None) self.amount = kwargs.get('amount', 499) self.balance = kwargs.get('balance', "499.0") self.previous_balance = kwargs.get('previous_balance', 0) self.previous_paid_amount = kwargs.get('previous_paid_amount', 0) self.adjustment_amount = kwargs.get('adjustment_amount', 0) self.bill_status = kwargs.get('bill_status', 1) self.discarded_es_bill_id = kwargs.get('discarded_es_bill_id', None) self.unissued_invoice_amount = kwargs.get('unissued_invoice_amount', 0) self.issue_date = kwargs.get('issue_date', issue_date) self.due_date = kwargs.get('due_date', due_date) self.taxable_amount = kwargs.get( 'taxable_amount', float(self.balance) - float(self.adjustment_amount)) self.tran_no = 178552762
def add_cookie(self, name, value, path=None, domain=None, secure=None, expiry=None): """Adds a cookie to your current session. "name" and "value" are required, "path", "domain", "secure" and "expiry" are optional. Expiry supports the same formats as the DateTime library. """ new_cookie = {'name': name, 'value': value} if is_truthy(path): new_cookie['path'] = path if is_truthy(domain): new_cookie['domain'] = domain # Secure should be True or False if is_truthy(secure): new_cookie['secure'] = secure if is_truthy(expiry): expiry_datetime = int(convert_date(expiry, result_format='epoch')) new_cookie['expiry'] = expiry_datetime self.browser.add_cookie(new_cookie)
def _convert(self, value, explicit_type=True): dt = convert_date(value, result_format='datetime') if dt.hour or dt.minute or dt.second or dt.microsecond: raise ValueError("Value is datetime, not date.") return dt.date()
def _convert(self, value, explicit_type=True): return convert_date(value, result_format='datetime')
def _expiry(self, expiry: str) -> int: try: return int(expiry) except ValueError: return int(convert_date(expiry, result_format="epoch"))
def _expiry(self, expiry): try: return int(expiry) except ValueError: return int(convert_date(expiry, result_format='epoch'))
def _expiry(self, expiry): try: return int(expiry) except (ValueError, TypeError): return int(convert_date(expiry, result_format="epoch"))
def _convert_datetime(self, name, value, explicit_type=True): try: return convert_date(value, result_format='datetime') except ValueError: return self._handle_error(name, value, 'datetime', explicit_type)