This commit is contained in:
CHIEFSOFT\ameye
2025-03-16 17:49:03 -04:00
parent f4a51d8b89
commit 139decf1d1
2 changed files with 83 additions and 2 deletions
+48 -1
View File
@@ -124,4 +124,51 @@ ALTER TABLE ONLY loans
{"cid": "1", "description": "Product Loan 01" , "active" : 0 },
{"cid": "2", "description": "Product Loan 02" , "active" : 0 },
{"cid": "3", "description": "First Advance" , "active" : 1 },
{"cid": "3", "description": "First Advance" , "active" : 1 },
CREATE TABLE trx_raw (
id SERIAL,
AccountID VARCHAR(15) NOT NULL,
trx_start_date timestamp,
trx_end_date timestamp,
amount float DEFAULT 0.0,
D1 VARCHAR(3),
D2 VARCHAR(3),
D3 VARCHAR(3),
Description VARCHAR(75),
D4 VARCHAR(12)
);
ALTER TABLE ONLY trx_raw
ADD CONSTRAINT trx_raw_id_key UNIQUE (id);
CREATE TABLE trx_raw (
AccountID VARCHAR(15) NOT NULL,
trx_start_date VARCHAR(15),
trx_end_date VARCHAR(15),
amount float DEFAULT 0.0,
D1 VARCHAR(3),
D2 VARCHAR(3),
D3 VARCHAR(3),
Description VARCHAR(75),
D4 VARCHAR(12)
);
CREATE TABLE accounts (
id SERIAL,
AccountID VARCHAR(15) UNIQUE NOT NULL
);
ALTER TABLE ONLY accounts
ADD CONSTRAINT accounts_id_key UNIQUE (id);
1738039011 |15-03-2018|15-03-2018| 3000|T|CI|D|ATM WD @ 000000000001447 ACCESS NNEWI NG |1738039
1738039011 |16-03-2018|16-03-2018| 2000|T|CI|D|ATM WD @ 000000000011446 Nnewi Nnewi NG |1738039
1738039011 |19-03-2018|19-03-2018| 1065|T|CI|D|ATM WD @ NNEWI 05 NNEWI NNEWI ANNG |1738039
1738039011 |20-03-2018|20-03-2018| 1065|T|CI|D|ATM WD @ 000000000001447 ACCESS NNEWI NG |1738039
1778212012 |22-03-2018|22-03-2018| 8000|T|CI|D|240447189 ATM WD @ 10503184/ENG LA SATELITE |1778212
1778212012 |19-03-2018|19-03-2018| 260000|T|CI|D|Online : kola |1778212
1778212012 |19-03-2018|19-03-2018| 52.5|T|BI|D|TRANSACTION CHARGE-Online : kola |1778212
1778212012 |16-03-2018|16-03-2018| 270000|T|CI|C|TRF B/O CHIBUZO BEATRICE UGOCHUKWU
+35 -1
View File
@@ -144,7 +144,7 @@ def salary_demousers():
dList = []
SELECT_DEMO_ENTRY = f"SELECT id,uid, bvn AS CustomerID, mobile AS AccountID, name,offers,salary_account,current_loans,mobile,bvn, email, pin, added::text, balance, updated::text AS updated FROM demo_bank_accounts ORDER BY id ASC"
SELECT_DEMO_ENTRY = f"SELECT id,uid, bvn AS CustomerID, mobile AS AccountID, name,offers,salary_account,current_loans,mobile,bvn, email, pin, added::text, balance, updated::text AS updated FROM demo_bank_accounts ORDER BY id DESC LIMIT 1500"
# print(SELECT_DEMO_ENTRY)
with connection:
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
@@ -639,6 +639,9 @@ def repay_loans():
@app.route('/simulation/generator')
def generate_activities():
# insert_random_users()
generate_simulation_salary()
generate_simulation_transaction()
@@ -647,6 +650,37 @@ def generate_activities():
return []
def insert_random_users():
SQL_ACC = "SELECT accountid AS account_no FROM trx_raw GROUP BY accountid"
with connection:
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
cursor.execute(SQL_ACC)
select_demoS = cursor.fetchall()
loan_data = json.dumps( [dict(ix) for ix in select_demoS] )
accounts_result = json.loads( loan_data)
SQL_INSERT = "INSERT INTO demo_bank_accounts (name, salary_account, mobile, bvn, email, pin) VALUES(%s,%s,%s,%s,%s,%s)"
# Iterate through the JSON array
for item in accounts_result:
accountNo = item["account_no"]
new_data = (
names.get_full_name() ,
random.randint(0, 1),
'811-'+str( random.randint(100, 999) )+'-'+str( random.randint(1000, 9999) ) ,
accountNo,
'demo+'+ names.get_first_name() +'@chiefsoft.net',
random.randint(1100, 9999)
)
print(new_data)
with connection:
try:
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
cursor.execute(SQL_INSERT, new_data)
except Exception as e:
print(0)
def generate_simulation_salary():
pass