OPS435: Assignment #2

HAND-IN REQUIREMENTS:

General Description

Create a graphical Bash shell script to view purchases, to contact vendors, as well as to make payments against outstanding purchase balances.

Due Date

Wednesday August 10, 2011 @ 11:59:59 p.m.

OVERVIEW / GENERAL REQUIREMENTS:

You have been approached by the "purchasing department" to write a portable Bash shell script called makePayments.bash to use graphical method of viewing purchasing information, and making payments against outstanding vendor balances. Vendors are companies that we have purchased goods and services from and may owe them money. In order to make the shell script graphical, you need to study how to use the Zenity command. Refer to the HINTS / TIPS section below to learn how to use the Zenity command.

The purchasing department already has an employee that records vendor purchases into a purhchases file, so we don't have to worry about recording vendor purchases. What we need to do is create a graphical program that reads the purchases file to generate reports, and record payments towards outstanding vendor balances. You can assume that if there are multiple purchases for the same vendor, the outstanding balance grows for that one vendor record.

The layout for the purchases file will always consist of the same format: a four-field, colon-separated database file containing the following field sequence:

Your shell script will only accept one argument: a valid 4 field, colon-separated purchases database file pathname. This filename could be ANY filename, as long as it is a valid database.

If your shell script is issued without exactly one argument, then the shell script will display a graphical USAGE error message, and exit the shell script with a false value. If the file is not valid (i.e. doesn't exists), or is not a four-field database (separated by colon), then the shell script will display a graphical error message, and exit the shell script with a false value. Since the error messages are graphical, you are NOT required to redirect stdout as stderr.

If the shell script is issued correctly, then the following graphical menu will appear. This menu will continue to loop until the user selects "Exit".
In the menu, the user clicks on a button, and then clicks OK or presses ENTER.

This is a fairly fool-proof system, and no error-checking is involved.

Please view the picture on the right-side for reference.

Menu for user to make selections
Diagram of Main Menu for Making Selections

DETAILED REQUIREMENTS:



DISPLAY PURCHASES:

When this menu item is selected, the purchases database file is read in order to graphically display the vendor's full name, and the outstanding balance.

Also, a grand total of the outstanding balance will be displayed at the bottom, along with a message that a copy of this file is contained in the file pathname ~/purchaseReport.txt.

NOTE: The report should be properly aligned for the ~/purchaseReport.txt file, but does NOT have to be aligned for the graphical display. There is an ongoing issue with how the Zenity command handles whitespace characters generated from the printf command.

Sample Report for Displaying Purchases
Sample Report for Displaying Purchases. Click to Enlarge."
Sample Hard-copy Report Saved for Displaying Purchases
Sample Hard-copy Report Saved as a file
(not related to graphical display report on left-side).
Click to Enlarge.

MAKE A PAYMENT:

When this menu item is selected, the user will be prompted for a full vendor name. The user MUST enter a vendor name that matches (including case sensitivity and exact full vendor name), otherwise, another dialog box will indicate "no matches", and request that the user re-enter a vendor name.

Prompt for Full Vendor Name
Dialog box prompting for full Vendor Name.
Re-prompt for Vendor Name if no match
Dialog box prompting to re-enter Vendor Name if no match.
Prompt for payment against outstanding balance
Dialog box requesting amount of payment against outstanding balance.
If there is a vendor name match, then the vendor name and outstanding vendor balance will be displayed, and the user can enter a payment against that outstanding balance. You can assume that your program only works with dollars (i.e. no decimal places), therefore your shell script will only accept valid integers; otherwise, the user will have to re-enter the payment. Also, if the payment is greater than the outstanding balance, your program will indicate that the "payment exceeds the outstanding balance", and that the user must re-enter the payment amount. An example of this is shown in the YouTube SAMPLE RUNS.

If the partial payment was successful, then the vendor record's balance is updated in the database file.

If a complete payment has been made against the outstanding balance, then the vendor record is to be removed from the purchases database file.

NOTE: Please refer to the HINTS / TIPS for help and suggestions...



CONTACT VENDOR:

When this menu item is selected, a graphical report is displayed containing the date of last purchase, the vendor name and the outstanding balance (if over $500).
In this case, we can immediately phone the vendor and talk to them to and arrange a method of payment before they get too upset...


View the diagram on the right-side for reference.

EXIT:

When this menu item is selected, the program removes any temporary files, and then terminates with a true exit status.



Sample Report for Contacting Vendors
Sample Report for contacting vendors with
outstanding balances over $500.
Click to Enlarge."

SAMPLE DATABASE:

[ purchases.dat ] Exact Database used in YouTube SAMPLE RUNS. Copy and paste to a file called: purchases.dat



SAMPLE RUNS:

[ Video ] YouTube Video (with commentary) of running this shell script under different senerios. You can pause and replay this video at anytime.
You can set the resolution to 720p and set to "full screen mode" to see the video in more detail...

NOTE: Ignore part of YouTube commentary about "CONTACT VENDOR" report should have phone # instead of date. The report is correct, and shows first column as date of last purchase (instead of phone #).



HINTS / TIPS (and other ASSUMPTIONS):

  • You can assume that you don't have to error-check empty database files, but your shell script should verify that the file exists, and that the file is a four-field, colon-separated database file.

  • You are required to use at least one user-defined function in your shell script.

  • You MUST use zenity for this assignment. You can use read and echo, for practice, but then change-over to use the Zenity command. If you submit your assignment without using the Zenity command, you will immediately lose 20% of your mark.

    Here is a link how to use the Zenity command: [ html]

  • You MUST use the awk utility to generate the Display Purchases and Contact Vendor reports. Use the printf command within awk to make your purchase amounts align properly.

  • Make certain to remove ALL temporary files upon exit. You are NOT required to trap any signals in this assignment.

  • It is recommended to use temporary files when matching valid vendor names to display the invoice and purchase amount information. You can then use command substitution to help store vendor information into variables. In order to update a record, you will need to use a temporary file. You need to somehow remove the record that payment is made to, and build a new record with updated information, and append to the bottom of the file. You will not be able to complete the assignment without using the awk and sed commands, so learn how to use them!

ASSIGNMENT SUBMISSION INSTRUCTIONS:

You MUST follow the complete set of instructions by clicking the submission link below and follow those submission instructions.

Assignment #2 Submission Instructions: [ html ]


GRADING

  1. Shell scripts are to be submitted from your Matrix account from the submission scripts displayed above – no exceptions.

  2. You are expected to complete this assignment by yourself. There is no groupwork allowed for this assignment!

  3. Late assignments will carry a penalty of 10% per day. Since assignment is submitted electronically: weekends count!.

  4. If your script is not functional when tested, or produces too many incorrect answers, you will receive an e-mail to resubmit your assignment, and lose 20% of your mark (after other deductions are noted after remarking).

  5. 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 :)