I am trying to create a report for Sales Rep Profitability accessing Peachtree 2014 data files for a strategic purchasing agent firm using the integrated Crystal Reports 2008 SP1. Sales order(s) have directly related purchase order(s)and both record types are in the JrnlHdr table. A code in JrnlHdr.JrnlKey_Journal, 11 for sales orders and 10 for purchase orders distinguishes the record type. Sales and purchase order number coding relate the sale to the cost as follows:
Sales Order number: Syear-xxxxQ Where S is constant, year is 4 digit, - is constant, xxxx sequential number for order, Q is for sequential numbering of sub-sales orders emitted pertaining to order Syear-xxxx and starts with A ending in Z
Purchase Order number: As Sales Order number substituting the S with a P (Pyear-xxxxQ) and Q is for sequential numbering of sub-purchase orders emitted pertaining to order Pyear-xxxx and starts with A ending in Z
So for example, the total for Sales Order number S2013-5678 is the sum of S2013-5678A to S2013-5678Z (number of sub-sales orders varies, but each sub-sales order is an actual record in the JrnlHdr table), and the total related cost is the total for Purchase Order number P2013-5678A to P2013-5678Z (number of sub-purchase orders varies, but each sub-purchase order is an actual record in the JrnlHdr table). Please note that there is no record in JrnlHdr for main sales and purchase order number Syear-xxxx and Pyear-xxxx, only the sub-order records.
The report should be grouped by the JrnlHdr.EmpRecordNumber and have a line for each main sales order as:
(Main Sales Order Number) (Total Sales order Amount) (Main Purchase Order Number) (Total Purchase Order Amount)
How is the record selection and consolidation (various sub-orders for the one main order) done for both the sales order and purchase order, since both are in the same table, and there is no 1 to 1 relation between sales sub-orders and purchase sub-orders?