diff --git a/SQL/salaryloan.sql b/SQL/salaryloan.sql index caa36c9..8bc4aca 100644 --- a/SQL/salaryloan.sql +++ b/SQL/salaryloan.sql @@ -81,13 +81,32 @@ CREATE TABLE loan_apply ( loan VARCHAR(25) NOT NULL, bvn VARCHAR(12) NOT NULL, amount INT DEFAULT 0, - added timestamp without time zone DEFAULT now() + added timestamp without time zone DEFAULT now(), + verified timestamp ); ALTER TABLE ONLY loan_apply ADD CONSTRAINT loan_apply_id_key UNIQUE (id); +CREATE TABLE loans ( + id SERIAL, + uid uuid DEFAULT uuid_generate_v4(), + bvn VARCHAR(12) NOT NULL, + loan VARCHAR(25) REFERENCES loan_offers (loan), + approved_amount INT DEFAULT 0, + initial_deduction INT DEFAULT 0, + days_duration INT DEFAULT 0, + added timestamp without time zone DEFAULT now(), + due_date timestamp +); +ALTER TABLE ONLY loans + ADD CONSTRAINT loans_id_key UNIQUE (id); + + +--- ALTER TABLE loan_apply ADD verified timestamp; + + {"cid": "425611f2-c692-4404-b93d-76ca7a5ce00", "description": "100,000 Naira for 30 Days" , "active" : 1 }, {"cid": "425611f2-c692-4404-b93d-76ca7a5ce01", "description": "300,000 Naira for 60 Days" , "active" : 1 }, {"cid": "425611f2-c692-4404-b93d-76ca7a5ce02", "description": "900,000 Naira for 90 Days" , "active" : 1 }, diff --git a/app/app.py b/app/app.py index efd9c5a..776a426 100644 --- a/app/app.py +++ b/app/app.py @@ -352,6 +352,11 @@ def salary_verifloan2(): account_found = count = len( account ) print("10000-a") if account_found == 1 : + UPDATE_APPLICATION = "UPDATE loan_apply SET verified = now() WHERE uid::text = '" + loan_application_id + "' " + with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor: + cursor.execute(UPDATE_APPLICATION) + + loan_create(bvn,loan_application_id) return { "status": "1", "message" : "Loan Verified", @@ -361,7 +366,7 @@ def salary_verifloan2(): return { "status": "-1", "data": None, - "message" : "Invalid Loan", + "message" : "Invalid Loan or PIN", "error": "1" }, 404 @@ -376,6 +381,8 @@ def salary_verifloan2(): "data": None }, 500 +def loan_create(bvn,loan_application_id): + pass def products(): product_data = [