Documentation >
MAC-PAC Technical Library >
Distribution >
Order Processing >
Programs >
Sales Order Print - Purpose >
Sales Order Print - Calculations
Sales Order Print - Calculations
OP520E
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 record (category 049) is retrieved from the Reference file (REFERP).
3. The following arrays are loaded from the corresponding category on the Reference file:
· Foreign Currency (category 003).
· VAT/GST Tax (category 308).
· Order Types (category 401).
· Sales Order Hold Codes (category 402).
· Order Status Codes (category 403).
· Option Print Codes (category Y33).
· VAT/GST types (category 024)
4. The specific printer location is retrieved from category C16 on the Reference file.
5. The Warehouse Description Array is loaded from the Warehouse Description file (IC170M).
B. Mainline
1. If in batch, the logical Sales Order Print Request file (OP500AL1) is read sequentially. A Sales Order and/or Sales Order Register detail line is generated for each header record as described below. If Async, the request file (OP515AP) is read and the SO is processed, information is retrieved from OP100L41 based on document format code, printed doc, EDI or both are generated.
2. EDI processing verification is performed on the sales order if:
a. An EDI doc has been requested.
b. A reprint of the sales order to be transmitted via EDI is requested (which is performed through the Sales Order Maintenance conversation).
If either of the above conditions are met, the sales order is flagged for EDI processing provided the customer is a valid EDI customer as defined on the customer master file (network ID is not blank).
3. If sales order printing has been requested, the sales order header record is formatted. Decodes for the header are retrieved from the Reference file. The Sales Order Counter is incremented by one. The sales order header information is printed, and if the sales order is flagged for EDI processing, the EDI Sales Order Header file (OP520AP1) is formatted. Also, the EDI Acknowledgment Sent Counter is incremented by one if the sales order is flagged for EDI processing.
4. Each line record associated with the sales order header is retrieved and processed. No line records will exist if the order is to be printed only on the Sales Order Register.
a. The Customer Line Discount Amount is calculated:
Customer line discount amount is retrieved from the Sales Order Line Discount Detail file (OP100M6).
b. The Total line discount amount is calculated: sum of all of the discount detail records for the line (on OP100M6), the line order Qty.
c. In a VAT/GST environment, the VAT/GST Rate for the line is retrieved from the VAT/GST array.
If the customer is subject to VAT surcharge in a VAT environment, the VAT surcharge rate is also retrieved from the VAT array.
d. If VAT/GST is included, the amount subject to VAT/GST is determined as follows, depending on whether the VAT/GST method is net, gross, or recalculate.
For net;
amount subject to VAT/GST =
|
extended price
1 + (VAT/GST rate * discount rate)
|
For net with surcharge applied;
amount subject to VAT/GST =
|
extended price
1 + ((VAT/GST rate + surcharge)* discount rate))
|
For gross or recalculation:
amount subject to VAT/GST =
|
extended price
1 + VAT/GST rate
|
For gross or recalculation with surcharge applied:
amount subject to VAT/GST =
|
extended price
1 + (VAT/GST rate + surcharge rate)
|
e. If the line is a gift and VAT is not calculated for gifts, the VAT amount is ignored. If in a GST environment, PST calculation is performed. See the GST/PST Calculation in this manual for details.
Surcharge amounts are calculated if in a VAT environment and the Bill-to customer is subject to VAT surcharge. All calculations for VAT also take into account any existing surcharge codes.
f. The Extended Price of the line is added to the Total Amount for the Sales Order.
g. If the Apply Discount Code is Y, the Extended Price of the line is also added to the Amount Subject to Cash Discount Accumulator.
h. If a printed SO is requested, sales order line information is printed on the Sales Order. If the sales order is flagged for EDI processing, the sales order line information is written to the EDI Sales Order Detail file (OP520AP2).
i. If printed, the Sales Order Line Counter is incremented by one. The EDI Acknowledgment Line Counter is incremented by one if the order is flagged for EDI processing.
5. All comment records associated with the header or lines, including extended comment records, are printed on the Sales Order if the Print Code designates that the comment is to be printed on the Sales Order. No comment records will exist if the order is to be printed only on the Sales Order Register.
6. Lots associated with a line are printed for lot-assignable items. If a line item is a configured item, then depending on the Print Configuration Code flag retrieved from Reference File category 412, the Configuration Code and Expanded Configuration Code will appear on the report.
7. If a line item is a configured item, and sales order options exist, then depending on the print code retrieved from Reference File category Y33, sales order options and values will appear on the report.
8. 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 will appear on the report.
9. At the completion of a SO the following processing is performed for the previous sales order if the previous sales order was printed on the Sales Order report.
a. Tax/PST processing is performed:
(1) If the home/export flag indicates home processing (H) in a VAT/GST environment, the VAT/surcharge/GST Amount is calculated.
(2) If the home/export flag indicates export processing (E) or is blank in a VAT/GST environment, the Tax Amount is set to zero.
(3) If a non-VAT/GST environment, the Tax Amount is retrieved from the Sales Order Header Print file (OP500AP1).
b. The payment terms information for the order is retrieved from the Payment Terms Reference File category 323. The Cash Discount Amount is calculated:
Amount Subject to Cash Discount Accumulator times Cash Discount.
c. The Total Sales Amount of the order is added to the Tax Amount, giving the Total Amount. The Cash Discount is then subtracted from the Total Amount, giving the Net Amount.
d. The total discount amount for the Sales Order is calculated by summing up the total line discount for every line on the order. The Sales Order Total Discount amount is printed on the Sales Order. This is an extended amount.
e. Order totals are rolled into the Sales Order Register warehouse accumulators. Sales order totals are printed on the Sales Order.
f. 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.
10. The detail line for the warehouse is printed on the Sales Order Register (OP520B) if the order has not been printed on the register, and the Sales Order Register print has been requested.
11. When a warehouse break occurs:
a. The Sales Order Register warehouse accumulators are rolled into the Sales Order Register company accumulators.
b. The Gross Margin Percent for the warehouse is calculated:
(Sales Amount minus Cost of Sales) divided by Sales Amount.
c. The warehouse accumulators are set to zero.
12. When a company break occurs:
a. The Gross Margin Percent for the company is calculated, using the above formula.
b. The totals line for the company is printed on the Sales Order Register.
c. The Sales Order Print Control Summary (OP520C) for the company is printed.
d. The Sales Order Register company accumulators are set to zero.
13. When all sales orders have been processed in batch, the program ends. When an order is completed in Async, the next record is read from OP515AP and the SO is processed. This file is read periodically and orders are processed as requests are read. When the cancel record is read from OP515AP (written when the monitor is canceled), the program ends.