Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a complete database schema for a banking system. The schema defines core banking entities and their relationships, along with automated procedures for transaction management and interest calculations.
Key Changes:
- Database schema with 11 tables covering branches, employees, customers, accounts, and transactions
- Three stored procedures for transaction processing, fixed deposit validation, and automated interest crediting
- Automated reference number generation for transactions via trigger function
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| prefix := 'TXN'; | ||
| END IF; | ||
|
|
||
| NEW.ref_no := prefix || '-' || TO_CHAR(NEW.timestamp, 'YYYYMMDD') || '-' || LPAD(NEXTVAL('txn_ref_no')::TEXT, 5, '0'); |
There was a problem hiding this comment.
The trigger function references 'ref_no' but the transactions table defines the column as 'ref_number' (line 95). This will cause a runtime error when the trigger executes.
| NEW.ref_no := prefix || '-' || TO_CHAR(NEW.timestamp, 'YYYYMMDD') || '-' || LPAD(NEXTVAL('txn_ref_no')::TEXT, 5, '0'); | |
| NEW.ref_number := prefix || '-' || TO_CHAR(NEW.timestamp, 'YYYYMMDD') || '-' || LPAD(NEXTVAL('txn_ref_no')::TEXT, 5, '0'); |
| 'Interest', | ||
| rec.principal_amount + (interest_amount * CAST(SPLIT_PART(rec.months, ' ', 1) AS INTEGER)), | ||
| 'FD Maturity Payout', | ||
| new_balance |
There was a problem hiding this comment.
The variable 'new_balance' is used as an OUT parameter but is not declared in the procedure. This will cause a compilation error.
| 'Interest', | ||
| interest_amount * duration_months, | ||
| 'FD Interest Payout', | ||
| new_balance |
There was a problem hiding this comment.
The variable 'new_balance' is used as an OUT parameter but is not declared in the procedure. This will cause a compilation error.
| INSERT INTO transactions(holder_id, amount, type, description) | ||
| VALUES (current_holder_id, p_amount, p_type, p_description); |
There was a problem hiding this comment.
The INSERT statement omits the 'timestamp' column, which should be included or have a DEFAULT value defined. Without it, the trigger function 'assign_ref_no()' will fail when trying to access NEW.timestamp at line 184.
| INSERT INTO transactions(holder_id, amount, type, description) | |
| VALUES (current_holder_id, p_amount, p_type, p_description); | |
| INSERT INTO transactions(holder_id, amount, type, description, timestamp) | |
| VALUES (current_holder_id, p_amount, p_type, p_description, CURRENT_TIMESTAMP); |
| IF p_type = 'Deposit' THEN | ||
| new_balance := current_balance + p_amount; | ||
| ELSIF p_type = 'Withdrawal' THEN | ||
| IF current_balance > p_amount THEN |
There was a problem hiding this comment.
The withdrawal validation allows withdrawal when balance equals amount, but doesn't account for minimum balance requirements defined in savingsaccount_plans. This could allow accounts to fall below their required min_balance.
No description provided.