Documentation >
MAC-PAC Technical Library >
Distribution >
Order Processing >
Programs >
Invoice, Debit/Credit Memo, and Cash Sales Print - Purpose >
Invoice, Debit/Credit Memo, and Cash Sales Print - Calculations
Invoice, Debit/Credit Memo, and Cash Sales Print - Calculations
OP540E
A. Housekeeping
1. See the Common Processing Routines - Housekeeping section of this manual for a general discussion of this subroutine. Processing specific to this program is described below.
2. The date format (category 049), the document type codes (category 328), and the Order Processing system defaults (category 412) records are retrieved from the Reference file. If the latter two are not found, the program aborts.
3. The following arrays are loaded:
a. The document/form type codes record (category 422) is retrieved from the Reference file. This information, which is used to change the form type when a control break occurs, is loaded into the Form Type Code Array (CFC) and the Form Type Name Array (CFT).
b. All Company/Warehouse combinations are retrieved from the Warehouse Description file. These are used to load the Company/Warehouse Array (CWA) and the VAT Array (VRG).
c. Language codes are retrieved from the Reference File (category D92). These codes are used to translate memos and invoices into other languages. The information is loaded into array LC.
d. Currency codes are retrieved from the Reference File (category D89). These codes are landed into the currency codes array (RCU) and are used to determine the decimal precision used for the currency.
4. The Order Processing control parameters record (category 424) is retrieved from the Reference file to determine which documents have been requested.
5. The specific printer location is retrieved from category C16 on the Reference file. The printer location defaults to QPRINT if blank on reference file record.
6. The print code (category Y33) is retrieved to determine if sales order options are to be printed.
B. Mainline
1. The Input Parameter (INPPAR) determines whether immediate or off-line processing is performed. If the Input Parameter contains I, immediate processing is performed. Otherwise, off-line processing is performed.
2. Immediate processing is initiated at the beginning of the day through a control language program.
a. When first started, the control language program reads the Open Item Print Request file (OP535AP) sequentially.
(1) If an end-of-file condition exists, the control language program waits for a record to be added to the file before continuing.
(2) To end the control language program, an end-of-file record is added to the Open Item Print Request file. This causes the Program Status of the print program to be set to end (END).
b. If a document is to be printed immediately, three conditions must be met:
(1) The document print flag on the open item header record must be N (document not yet printed) or Y (EDI invoice has been requested and not yet transmitted) decided based on customer default - customer name and address file is checked to determine if it is valid.
(2) The open item header record must not have a status of closed (C).
(3) If a Cash Sales Document was requested, the Order Processing system defaults record (category 412) must indicate that these documents are to be printed.
c. The header for the requested document is formatted and printed. In case of no charge line items having a part message code associated, Reference File category M10 (OP Document Detail Options) is checked for determining if the line has to be printed. Information is retrieved from the logical Open Item file (AROPENL7), the Reference file, the information arrays, and the company/location master file (CF280M) if the company/location has changed. If the invoice is to be transmitted via EDI, the EDI Invoice Header file (OP540AP1) is formatted.
d. The line items for the requested document are formatted and printed. Information is retrieved from the Open Item files, the Reference file, and the information arrays. If the invoice is to be transmitted via EDI, the EDI Invoice Detail file (OP540AP2) is formatted.
e. The comments for the requested document are retrieved from the logical Open Item file, and are printed if the Print Code designates that the comment is to be printed on the document. If the invoice is to be transmitted via EDI, the OP540PA3 and OP540AP4 are formatted.
f. The option and option value from the Sales Order Options file (EC200M) are printed if the Expert Configurator module is installed.
g. If a line item is a configured item and price detail information exists, then depending on the print code retrieved from Reference File category Y33, price detail information is printed on the report.
h. The lots, quantities, and lot comments are printed from the Invoice Lot Master file.
i. For a consolidated invoice, a page break is placed after every sales order number or transfer order number. The saved field is updated with the new sales order number/transfer order number and a new header is printed on the form.
j. When all records for a specific document have been processed, the following calculations are performed:
(1) Total Sales is the accumulated Extended Amount from all line items.
(2) The total discount amount for the open item is the extended discount amount that was given to the open item. It is printed on each open item.
(3) Tax Amount is calculated:
(a) If the home/export flag indicates home processing (H) in a VAT environment or if in a GST environment, the Tax Amount is accumulated from the VAT arrays. VAT surcharge amount will also be calculated if necessary.
(b) If VAT/GST is included and the VAT/GST amount exceeds the maximum included limit, then the VAT/GST amount is printed as a separate line on the document.
(c) If the home/export flag indicates export processing (E) in a VAT environment, the Tax Amount is set to zero.
(d) In a non-VAT environment, the Tax Amount is calculated. In a GST environment, the PST amount is calculated.
(4) If an invoice has installment payments, an installment detail line for each installment will be printed. The installment information, installment due date and the installment amount.
(5) Total Amount = Total Sales plus Tax Amount.
(6) Cash Discount = Amount Subject to Discount times Discount Percent.
(7) Net Amount = Total Amount minus Cash Discount.
k. The open item header record is updated to indicate that the requested document was printed (and, if relevant, that an EDI invoice was sent), and to indicate the date and time of printing. The print request record is then deleted.
l. When the Company or Location changes, the saved fields are updated with the new Company/Location and a new header is printed on the form.
m. If an installation has more that one form type for a document, this program must be modified to accept the additional form types. Output specifications for these additional form types must also be added. The default (or standard) form type is 1.
3. Off-line processing is driven off of the logical Open Item Header file (AROPENL8). This file is a view of all open item header records whose print flag contains N (document not yet printed) or Y (EDI decided from customer). A specific document will not be printed unless the printing of that document type has been requested.
a. The logical Open Item Header file is read sequentially until the end of the file is reached.
b. The first time through, the Company and Location fields are saved. The Company and Location of each header record is compared against the saved values. When a break occurs in either field:
(1) The Control report (OP540E) is printed, giving control totals of the number of documents, number of lines, and net amount of each of the document types that was printed for the previous company/location.
(2) The corresponding counters and accumulators are reset to zero.
c. The header for the requested document is formatted and printed as in step 2c. The appropriate document counter is incremented by one.
d. The line items for the requested document are formatted and printed as in step 2d. The appropriate line counter is incremented by the number of lines processed.
e. The comments for the requested document are retrieved and printed as in step 2e.
f. The lots for the line are retrieved and printed as in step 2h.
g. When all records for a specific document have been processed, the totals are calculated as in step 2i. The Net Amount is added to the appropriate accumulator for the document type.
h. The open item header record is updated to indicate that the requested document was printed (and, if relevant, that an EDI invoice was sent), and to indicate the time of printing.
i. If an installation has more than one form type for a document, this program must be modified to accept the additional form types. Output specifications for these additional form types must also be added. The default (or standard) form type is 1.
4. Before printing the document, the customer master file is checked for a language code. If the customer has a valid language code the document will print in this secondary language.