OPS435: Assignment #2
Create a Bash shell script to help users record and track payments to vendor accounts.
Monday April 12, 2010 @ 11:59:59 p.m.
OVERVIEW / REQUIREMENTS:
You have been approached by the "payments section" of the purchasing department to write a portable Bash shell script called makePayments.bash to simplify making payments to their vendors. Vendors are companies that we have purchased goods and services from and may owe them money.
One section of the purchasing department records purchases made from vendors on account. We don't worry about this, it is done by someone else, but we need to use this purchases file. We can assume that purchases from vendors have already been included in a file that contains the following fields:
Your shell script will only accept two arguments: an existing file pathname (purchases file), and the payments file (does not have to exist). If your shell script is issued with any other number of arguments than 2, then the shell script will display a USAGE stderr message, and exit the shell script with a false value.
If the shell script contains two arugments with the first argument as a valid file pathname, then the user will be presented with a menu to
The menu should only accept valid numbers for the menu, and display a message into indicate that the select is not valid (but NOT exit the script). Below are descriptions how each menu item should function.
If the user presses <ctrl><c> at any time during the program, the screen will clear and indicate that the program has been aborted, temporary files have been removed, and prompt the the user to press the ENTER key to exit the program...
MAKE A VENDOR PAYMENT:
When this menu item is selected, the screen clear and the user will be prompted for a vendor number. Only valid vendor numbers consist of an UPPERCASE letter followed by three numbers. If the user enters an invalid vendor number, or the vendor number does NOT exist in the purchases file, then the user will be prompted repeatly. Upon entry of an valid and existing vendor number, then all of the purchases (on separate lines) will be displayed showing a line number, the invoice number, and the amount of purchase.
The user is then prompted to type in the invoice number, and amount of payment. You can assume the user can make only one payment at a time, and you are not reqruired to error-check for negative payments. If you are required to make multiple payments, then the user must select another vendor payment from the main menu.
When the payment is completed, the system will indicate that the payment has been recorded, the payment will be added to the bottom of the payments file, and your script will pause for the user to press <ENTER> to return to the main menu.
DISPLAY VENDOR PURCHASES:
When this menu item is selected, the screen is cleared, and the purchases datebase file is read to display the vendor's full name, and the total purchase amount owed (note: there could be more than one purchase transacations from the same vendor). Refer to the HINT and TIPS section to see how to determine the total amount owed to vendors.
DISPLAY PAYMENTS TO VENDORS:
When this menu item is selected, the screen is cleared, and the payments database file is read to display the vendor's full name, and the total payments made to the vendor (note: there could be more than one payment made to the same vendor). Refer to the HINT and TIPS section to see how to determine the total amount owed to vendors.
When this menu item is selected, the screen is cleared, and the script informs the user that the application has exited. The program should terminate with a true exit status.
[ run1.txt ] Incorrect number of arguments
[ run2.txt ] Invalid purchases database filename
[ run3.txt ] User presses <ctrl><c>
[ run4.txt ] Invalid Vendor Number, Non-Existent Vendor, and Valid Payments
[ run5.txt ] Additional Payment Transcations
HINTS / SUGGESTIONS / ADDITIONAL REQUIREMENTS:
ASSIGNMENT SUBMISSION INSTRUCTIONS:
You MUST run the program below to submit your assignment (no exceptions). The following table displays which command to run to submit your assignment #2 (when available).
Shell scripts are to be submitted from your Matrix account from the submission scripts displayed above – no exceptions.
If you do not submit your shell script on time, there will be a 10% penalty.
Late assignments will carry a penalty of 10% per day. Since assignment is submitted electronically: weekends count!.
If your script is not functional when tested, or produces too many incorrect answers, it will receive a mark of zero and must be resubmitted with in 7 days. Once resubmitted, such assignments can receive a maximum of 55%.
Every assignment will be checked for
plagiarism. If any copying is discovered, both students will
receive a mark of 0
and a "Dishonesty Report" will be entered in both student's files.
Good Luck :)