This repository has been archived by the owner on Jun 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
400 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
CREATE OR REPLACE PROCEDURE make_payment ( | ||
amen_id IN amenity_payment.amenity_id%type, | ||
lease_id IN lease_payment.lease_id%type, | ||
pay_method IN payment_method.id%type, | ||
pay_amt IN amenity_payment.pay_amt%type, | ||
payer IN person.id%type, | ||
memo IN amenity_payment.memo%type, | ||
ret OUT NUMBER | ||
) | ||
IS | ||
BEGIN | ||
IF amen_id <> -1 THEN | ||
INSERT INTO amenity_payment(date_paid, pay_method_id, pay_amt, payer, memo) | ||
VALUES(DEFAULT, pay_method, pay_amt, payer, memo); | ||
ret := 0; | ||
ELSIF lease_id <> -1 THEN | ||
INSERT INTO lease_payment(date_paid, pay_method_id, pay_amt, payer, memo) | ||
VALUES(DEFAULT, pay_method, pay_amt, payer, memo); | ||
ret := 0; | ||
ELSE | ||
ret := 1; | ||
END IF; | ||
END; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
CREATE OR REPLACE PROCEDURE sign_lease ( | ||
personId IN payment_method.person_id%type, | ||
propId IN lease.prop_id%type, | ||
apt IN lease.apt%type, | ||
termLength IN lease.term_length%type, | ||
amt OUT number, | ||
valid OUT number, | ||
success OUT number | ||
) IS | ||
rent_amount lease.rent_amount%type; | ||
lease_id lease.id%type; | ||
BEGIN | ||
-- Ensures that the lease does not exist the same time as another | ||
SELECT COUNT(*) into amt from lease where prop_id = propId and apt=apt and CURRENT_TIMESTAMP <= ADD_MONTHS(start_date, term_length); | ||
-- Ensures that the apartment is a valid apartment | ||
SELECT COUNT(*) into valid from apartment where prop_id = propId and apt = apt; | ||
|
||
IF amt <> 0 THEN | ||
success := -1; | ||
return; | ||
ELSIF valid <> 0 THEN | ||
success := -2; | ||
return; | ||
END IF; | ||
|
||
SELECT RENT into rent_amount from apartment where prop_id = propId and apt = apt; | ||
INSERT INTO lease(prop_id, apt, start_date, term_length, rent_amount) VALUES(propId, apt, CURRENT_TIMESTAMP, termLength, rent_amount); | ||
SELECT MAX(id) into lease_id from lease; | ||
INSERT INTO person_on_lease VALUES(lease_id, personId); | ||
success := 0; | ||
END; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SELECT COUNT(*) FROM renter_info where person_id = ?; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- The prop_id and apt fields should come from the Java program, first ensuring that it is a valid apartment (Lease is still alive), view_lease_to_pay should be run before this. | ||
|
||
-- Selecting prop amenities to pay for | ||
SELECT amenity.id, amenity, cost | ||
FROM | ||
(amenity left outer join amenity_payment on amenity.id = amenity_payment.amenity_id) | ||
join prop_amenity on amenity.prop_amenity_id = prop_amenity.id | ||
WHERE | ||
prop_id = ? and | ||
(TO_CHAR(date_paid, 'YYYYMM') = TO_CHAR(CURRENT_TIMESTAMP, 'YYYYMM') or TO_CHAR(date_paid, 'YYYYMM') is null); | ||
|
||
-- Selecting apt amenities to pay for | ||
SELECT amenity.id, amenity, cost | ||
FROM | ||
(amenity left outer join amenity_payment on amenity.id = amenity_payment.amenity_id) | ||
join apt_amenity on amenity.apt_amenity_id = apt_amenity.id | ||
WHERE | ||
prop_id = ? and apt = ? | ||
(TO_CHAR(date_paid, 'YYYYMM') = TO_CHAR(CURRENT_TIMESTAMP, 'YYYYMM') or TO_CHAR(date_paid, 'YYYYMM') is null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- By Lease ID | ||
select | ||
prop_id, | ||
street_name, | ||
apt, | ||
city, | ||
state, | ||
zipcode, | ||
square_footage, | ||
bed_count, | ||
bath_count, | ||
start_date, | ||
term_length, | ||
rent | ||
from (lease join apartment on lease.prop_id = apartment.prop_id and lease.apt = apartment.apt) join property on lease.prop_id = property.id; | ||
|
||
|
||
-- Get Prop Amenities | ||
select amenity, cost | ||
from prop_amenity | ||
where prop_id = ?; | ||
|
||
|
||
-- Get Apt Amenities | ||
select amenity, cost | ||
from apt_amenity | ||
where prop_id = ? and apt = ?; | ||
|
||
|
||
-- Get Roommates | ||
select first_name, last_name | ||
from person_on_lease join person on person_on_lease.person_id = person.id | ||
where lease_id = ? and person_id <> ?; | ||
|
||
|
||
-- Get Pets | ||
select animal, pet_name | ||
from pet_on_lease join pet on pet_on_lease.pet_id = pet.id | ||
where lease_id = ?; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- Select leases that are still active | ||
SELECT id, prop_id, apt, start_date, term_length, rent_amount | ||
FROM lease left outer join lease_payment on lease.id = lease_payment.lease_id | ||
WHERE id in (SELECT lease_id from person_on_lease where person_id = 8) and | ||
TO_CHAR(ADD_MONTHS(start_date, term_length), 'YYYYMM') >= TO_CHAR(CURRENT_TIMESTAMP, 'YYYYMM') and | ||
(TO_CHAR(date_paid, 'YYYYMM') = TO_CHAR(CURRENT_TIMESTAMP, 'YYYYMM') or TO_CHAR(date_paid, 'YYYYMM') is null); | ||
-- End date of the lease is past today's date | ||
-- Payment has already been made for the month or first payment is due |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- Venmo Given Person ID | ||
select payment_method.id, handle | ||
from payment_method join venmo on venmo_id = venmo.id | ||
where person_id = ?; | ||
|
||
-- ACH Given Person ID | ||
select payment_method.id, bank_name, acct_num, routing_num | ||
from payment_method join ach on ach_id = ach.id | ||
where person_id = ?; | ||
|
||
-- Card Given Person ID | ||
select payment_method.id, first_name, last_name, card_num, exp_date, cvv, pin | ||
from payment_method join pay_card on card_id = pay_card.id | ||
where person_id = ?; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
-- Given Person ID | ||
select | ||
person.id as id, | ||
first_name || ' ' || last_name as name, | ||
ssn, | ||
age, | ||
phone_number, | ||
email, | ||
credit_score, | ||
apt, | ||
lease_id | ||
from | ||
(((person | ||
left outer join renter_info on renter_info.person_id = person.id) | ||
natural left outer join person_on_lease) | ||
left outer join lease on lease_id = lease.id) | ||
natural left outer join apartment | ||
where person.id = ?; | ||
|
||
|
||
-- Given First/Last Name | ||
select | ||
person.id as id, | ||
first_name || ' ' || last_name as name, | ||
ssn, | ||
age, | ||
phone_number, | ||
email, | ||
credit_score, | ||
apt, | ||
lease_id | ||
from | ||
(((person | ||
left outer join renter_info on renter_info.person_id = person.id) | ||
natural left outer join person_on_lease) | ||
left outer join lease on lease_id = lease.id) | ||
natural left outer join apartment | ||
where first_name = ? or last_name = ?; | ||
|
||
|
||
-- Given First Name ONLY | ||
select | ||
person.id as id, | ||
first_name || ' ' || last_name as name, | ||
ssn, | ||
age, | ||
phone_number, | ||
email, | ||
credit_score, | ||
apt, | ||
lease_id | ||
from | ||
(((person | ||
left outer join renter_info on renter_info.person_id = person.id) | ||
natural left outer join person_on_lease) | ||
left outer join lease on lease_id = lease.id) | ||
natural left outer join apartment | ||
where first_name = ?; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.