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
14 changed files
with
239 additions
and
195 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,37 @@ | ||
create or replace FUNCTION sign_lease_helper ( | ||
propId IN lease.prop_id%type, | ||
aptId IN lease.apt%type, | ||
termLength IN lease.term_length%type | ||
) RETURN number | ||
IS | ||
amt number; | ||
valid number; | ||
rent_amount lease.rent_amount%type; | ||
leaseId number; | ||
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 = aptId 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 = aptId; | ||
|
||
IF amt <> 0 THEN | ||
return -1; | ||
ELSIF valid = 0 THEN | ||
return -2; | ||
END IF; | ||
|
||
SELECT RENT into rent_amount | ||
FROM apartment where prop_id = propId and apt = aptId; | ||
|
||
INSERT INTO lease(prop_id, apt, start_date, term_length, rent_amount) | ||
VALUES(propId, aptId, CURRENT_TIMESTAMP, termLength, rent_amount) RETURNING id into leaseId; | ||
commit; | ||
return leaseId; | ||
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
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
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 |
---|---|---|
@@ -1,11 +1,16 @@ | ||
CREATE OR REPLACE PROCEDURE add_pet ( | ||
create or replace PROCEDURE add_pet ( | ||
animal pet.animal%type, | ||
pet_name pet.pet_name%type, | ||
lease_id lease.id%type | ||
) IS | ||
pet_id pet.id%type; | ||
BEGIN | ||
INSERT INTO pet(animal, pet_name) VALUES(animal, pet_name); | ||
commit; | ||
SELECT MAX(id) into pet_id from pet; | ||
INSERT INTO pet_on_lease(lease_id, pet_id) VALUES(lease_id, pet_id); | ||
commit; | ||
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 |
---|---|---|
@@ -1,10 +1,25 @@ | ||
CREATE OR REPLACE PROCEDURE add_venmo ( | ||
person_id payment_method.person_id%type, | ||
handle venmo.handle%type | ||
) IS | ||
venmo_id payment_method.venmo_id%type; | ||
BEGIN | ||
INSERT INTO venmo(handle) VALUES(handle); | ||
SELECT MAX(id) into venmo_id from venmo; | ||
INSERT INTO payment_method(person_id, card_id, venmo_id, ach_id) VALU ES(person_id, NULL, venmo_id, NULL); | ||
END; | ||
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(amenity_id, date_paid, pay_method_id, pay_amt, payer, memo) | ||
VALUES(amen_id, CURRENT_TIMESTAMP, pay_method, pay_amt, payer, memo); | ||
ret := 0; | ||
ELSIF lease_id <> -1 THEN | ||
INSERT INTO lease_payment(lease_id, date_paid, pay_method_id, pay_amt, payer, memo) | ||
VALUES(lease_id, CURRENT_TIMESTAMP, 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 |
---|---|---|
@@ -1,4 +1,9 @@ | ||
-- Used by NUMA to add apartments for a new property | ||
-- Do last | ||
|
||
CREATE OR REPLACE PROCEDURE | ||
CREATE OR REPLACE PROCEDURE bulk_add ( | ||
propId property.id%type, | ||
maxLetter char, | ||
maxNumber number, | ||
|
||
) |
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 |
---|---|---|
@@ -1,46 +1,27 @@ | ||
CREATE OR REPLACE PROCEDURE sign_lease ( | ||
create or replace PROCEDURE sign_lease ( | ||
personId IN payment_method.person_id%type, | ||
propId IN lease.prop_id%type, | ||
apt IN lease.apt%type, | ||
aptId IN lease.apt%type, | ||
termLength IN lease.term_length%type, | ||
success OUT number | ||
ssn IN renter_info.ssn%type, | ||
success OUT number | ||
) IS | ||
amt number; | ||
valid number; | ||
rent_amount lease.rent_amount%type; | ||
lease_id lease.id%type; | ||
leaseId 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); | ||
leaseId := sign_lease_helper(propId, aptId, termLength); | ||
dbms_output.put_line(leaseId); | ||
|
||
-- 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; | ||
if leaseId > 0 then | ||
INSERT INTO renter_info(person_id, ssn) VALUES(personId, ssn); | ||
commit; | ||
INSERT INTO person_on_lease VALUES(leaseId, personId); | ||
commit; | ||
success := 0; | ||
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; | ||
end if; | ||
|
||
INSERT INTO person_on_lease VALUES(lease_id, personId); | ||
|
||
success := 0; | ||
success := -1; | ||
return; | ||
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
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
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