Updated packages. Added new session type
This commit is contained in:
@@ -19,8 +19,15 @@ import string
|
||||
import random
|
||||
|
||||
|
||||
def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
|
||||
return ''.join(random.choice(chars) for _ in range(size))
|
||||
def generate_random_number_string(length):
|
||||
# Ensure the length is at least 1
|
||||
if length < 1:
|
||||
raise ValueError("Length must be at least 1")
|
||||
|
||||
# Generate a random number with the specified length
|
||||
random_number = ''.join(random.choices(string.digits, k=length))
|
||||
|
||||
return random_number
|
||||
|
||||
|
||||
|
||||
@@ -143,24 +150,31 @@ def create_customer():
|
||||
.query(Admin_Company)
|
||||
.filter(Admin_Company.id == 1)
|
||||
.first())
|
||||
last_customer = (db.session
|
||||
.query(Customer_Customer)
|
||||
.order_by(Customer_Customer.id.desc())
|
||||
.first())
|
||||
|
||||
get_company = (db.session
|
||||
.query(Admin_Company)
|
||||
.filter(Admin_Company.id == 1)
|
||||
.first())
|
||||
|
||||
|
||||
random_string = generate_random_number_string(6)
|
||||
|
||||
made_account_number = str(get_company.account_prefix) + '-' + str(random_string)
|
||||
see_if_exists = (db.session.query(Customer_Customer).filter(Customer_Customer.account_number == made_account_number).first())
|
||||
|
||||
new_customer_id = last_customer.id + 1
|
||||
if len(str(new_customer_id)) == 2:
|
||||
new_customer_id = '000' + str(new_customer_id)
|
||||
if len(str(new_customer_id)) == 3:
|
||||
new_customer_id = '00' + str(new_customer_id)
|
||||
if len(str(new_customer_id)) == 4:
|
||||
new_customer_id = '0' + str(new_customer_id)
|
||||
if see_if_exists is not None:
|
||||
|
||||
starter_digits = str(get_company.account_prefix) + '-' + str(new_customer_id)
|
||||
random_string = generate_random_number_string(10)
|
||||
|
||||
made_account_number = str(get_company.account_prefix) + '-' + str(random_string)
|
||||
see_if_exists = (db.session.query(Customer_Customer).filter(Customer_Customer.account_number == made_account_number).first())
|
||||
|
||||
made_account_number = starter_digits
|
||||
if see_if_exists is not None:
|
||||
|
||||
random_string = generate_random_number_string(10)
|
||||
|
||||
made_account_number = str(get_company.account_prefix) + '-' + str(random_string)
|
||||
see_if_exists = (db.session.query(Customer_Customer).filter(Customer_Customer.account_number == made_account_number).first())
|
||||
|
||||
response_customer_last_name = request.json["customer_last_name"]
|
||||
response_customer_first_name = request.json["customer_first_name"]
|
||||
|
||||
Reference in New Issue
Block a user