Introduction
Each time a book is borrowed, the Pascal Memorial Library pays the author a small sum of money as royalty. Because the sum owed for each "borrowing" is very small, royalties are only paid once every quarter. Royalties are paid to authors through their agents. Only one cheque per quarter is sent to each agent but to allow him to pay his authors the correct amount, a breakdown of the royalties owed to each author is included with the cheque.
A report is required which;
- Shows the amount to be sent to each agent.
- Shows the breakdown of the agent payment into author payments.
- Shows the breakdown of each author payment into royalty payments per book.
The report must be printed in agent name sequence. The sequence of authors within each agent and of books within each author does not matter. The print specification for the report is on the last page.
Files
All the data required to produce the Royalty Payment Report is contained in two indexed files.
The indexed file Books.dat has the following record description;-
|
Field |
KeyType |
Type |
Length |
Value |
Book-Number |
Primary |
9 |
7 |
1-9999999 |
Book-Name |
- |
X |
25 |
- |
Author-Number |
Alt with Duplicates |
9 |
7 |
1-9999999 |
Royalty-Rate |
- |
9 |
3 |
0.001-0.999 |
Quarter-Borrowings |
- |
9 |
3 |
0-999 |
The indexed file Author.dat has the following record description;-
|
Field |
KeyType |
Type |
Length |
Value |
Author-Number |
Primary |
9 |
7 |
1-9999999 |
Author-Name |
- |
X |
25 |
- |
Agent-Name |
Alt with Duplicates |
X |
25 |
- |
Processing
Some fields required in the report do not appear in either of the indexed files and must be calculated. The following describes these fields and how to calculate them;
Book-Royalty contains the royalty to be paid for a book for the quarter. It is obtained by multiplying Quarter-Borrowings by Royalty-Rate. It is a numeric field with up to three places before the decimal point and two places after.
Quarter-Author-Borrows contains the sum of Quarter-Borrowings for all of an authors books on loan in the library. It is a numeric field up to four digits long.
Author-Royalties is the sum of an author's Book-Royaltys. It is a numeric field with up to four places before the decimal point and two after.
Agent-Payment is the sum of an agent's Author-Royalties. It is a numeric field with up to six places before the decimal point and two after it.
In addition to producing the report the program must perform a small update on the Quarter-Borrowings field of the Books file. When all the calculations involving the Quarter-Borrowings field have been done, it must be set to zero so that the borrowings for the new quarter may be accumulated.
Print Specification
| Line 2-5 | Headings; to be printed at the top of the report only. | ||||||||||
| Line 7 |
|
||||||||||
| Lines 8-13 | Same as line 7 but the agent and author names have been suppressed. | ||||||||||
| Lines 15-16 |
Printed when all the book details for an author have been printed. Quarter Borrowings contains the accumulated quarter borrowings for an author. It is a numeric field with zero suppression and comma insertion. Royalties is the accumulated Book-Royaltys for an author. It is a numeric field with a floating dollar sign, decimal point and comma insertion. |
||||||||||
| Line27 | Printed when all the author details for an agent have been printed. Agent-Payment contains the accumulated royalties to be paid to an agent's authors. This field is numeric with a floating dollar sign, decimal point and comma insertion. |
Notes: There is no need to allow for page breaks.
