Sales Analysis

There are several ways to analyse sales history. If a quick analysis is required there is some flexibility in the sales graph script that allows a pictorial representation of the sales against budget. It depends of course the level to which sales budgets are recorded as to whether the comparison against budgets will show anything useful. If a report of the actual numbers is required EdgeERP has a sales report writer that allows sales reports to be created - the resulting report templates can be re-run or modified. These reports can output either a pdf or a csv file for reading into most spreadsheet applications.

From the main menu under Accounts Receivable Reports and Inquiries options, "Sales Analysis Reports". A list of all previously defined sales reports shows with links to:

Also from the bottom of this page it is possible to make up new reports to show most combinations of sales data. A seperate table of sales data is maintained by the system to enable these reports to be run as quickly as possible.

A sales analysis report is made up of:

Sales Analysis Report Headers

The first step in creating a report is to enter the report header information. This includes:

Each grouping consists of a selection of one of:

The report groups on each level in sequence eg. A report with Group By 1 set to Product Code and Group By 2 set to Sales Area, would show the product code, then the areas underneath the product code where the item has been sold. Most often the more logical sequence might be to show the sales area as Group By 1 and the Product Code under the Group By 2 so that the sales of the product codes for each area appear together.

Each Group By section requires a range to be specified. All criteria specified must refer to the coding as specified in the setup section of the relevant Grouping. Eg Sales Areas criteria must be entered as the area code - not the area description. The criteria from should be less than the criteria to otherwise the report will have no output.

Sales Analysis Report Columns

Having created a header for the report the columns can then be defined. Columns for existing reports can be modified at any time. From the main Sales Analysis Reports page - (Accounts Revceivable tab - Sales Analysis Reports) - there is a link on each report to "Define Columns". From this link the columns for the report selected are shown, together with a form to allow input of new columns. The following input is required for each column defined:

If the column is defined as being a calculation the range of periods are not required, neither is the selection of the type of data to show and the budget or actual. Changing the Calculation field to yes then hitting the enter information button, show the fields required for a calculation:

Hitting the Enter Information button adds the column to the report definition. It should then show in the list of defined columns and a blank form for entering a new column definition. If a column is no longer required the list of column definitions shown has a link that allows it to be deleted.

The column number itself is a link to modify the definition of the column. The definition shows in the input form for alternation as necessary.

Clicking the link to maintain report headers shows the list of defined reports for modification or running. To run the report simply click on the Make PDF Report link.

These sales analysis reports have to look at a lot of information (and the reports are generated dynamically) as a result, they can take a minute or so to run on large databases. However, the design of the data has been done very carefully to ensure that reports generate dramatically faster than many such analysis engines.

Automating Sales Reports

Having created reports it is possible to email sales reports to defined recipients. A script called MailSalesReport.php is a template for doing this. There are no links to this script and no security level is set up for it. All that is required is to save this script to another file named anything with an extension of .php under the same directory as the other scripts.

This script will need to be edited with the email addresses of the people to receive the report and the reportID - the system generated report number to be run. The lines to edit are:

/*The Sales report to send */
$ReportID = 4;

/*The people to receive the emailed report */
$Recipients = array('"Root" ','"some one else" ');

The lines surrounded by /* and */ are comments.

Once edited to the ReportID or choice and the Recipients all entered the file should be saved.

To schedule the report to run an entry in crontab under a linux installation that would send the report at 0:0 each week day (assuming wget is installed in /usr/bin/wget and that the web server is on the same machine and the new script is called DailySalesReport.php) would be:
# Scheduled email of a daily sales report

0 0 * * 2-5 root /usr/bin/wget http://localhost/EdgeERP/DailySalesReport.php

since the page has no output - it would be pointless running it in a web browser although it would initiate another email to the defined recipients.

A similar template script is available called MailSalesReport_csv.php that mails the comma separated values file for a ReportID to the Recipients defined in the script in just the same way as MailSalesReport.php script above.

A more elegant solution to automatic emailing of sales analysis reports is available using the report_runner.php script this script can be run from a shell or directly from cron and takes command line parameters. This has the advantage instead of hardcoding a number or scripts this script can be run with the paratmers below:
-r reportnumber (the number of the EdgeERP report)
-n reportname (the name you want to give the report)
-e emailaddress[;emailaddress;emailaddres...] (who you want to send it to)
[-t reporttext ] (some words you want to send with the report-optional)
[ -H edgeerpHOME] (the home directory for EdgeERP - or edit the php file)