Difference between revisions of "Freeside:3:Documentation:Developer/FS/Report/Table/Monthly"

From Freeside
Jump to: navigation, search
m (Edit via perl MediaWiki framework (1.13))
 
m (Edit via perl MediaWiki framework (1.13))
 
(2 intermediate revisions by the same user not shown)
Line 14: Line 14:
 
     #opt
 
     #opt
 
     'agentnum'    => 54
 
     'agentnum'    => 54
 +
    'refnum'      => 54
 +
    'cust_classnum' => [ 1,2,4 ],
 
     'params'      => [ [ 'paramsfor', 'item_one' ], [ 'item', 'two' ] ], # ...
 
     'params'      => [ [ 'paramsfor', 'item_one' ], [ 'item', 'two' ] ], # ...
 
     'remove_empty' => 1, #collapse empty rows, default 0
 
     'remove_empty' => 1, #collapse empty rows, default 0
Line 21: Line 23:
 
   my $data = $report->data;
 
   my $data = $report->data;
 
</code>
 
</code>
==METHODS==
+
==PARAMETERS==
; data
+
===TIME PERIOD===
:Returns a hashref of data (!! describe)
+
<tt>start_month</tt>, <tt>start_year</tt>, <tt>end_month</tt>, and <tt>end_year</tt> specify the date range to be included in the report. The start and end months are included. Each month's values are summed from midnight on the first of the month to 23:59:59 on the last day of the month.
 +
 
 +
===REPORT ITEMS===
 +
; items&#58; An arrayref of observables to calculate for each month. See [[Freeside:3:Documentation:Developer/FS/Report/Table|FS::Report::Table]] for a list of observables and their parameters.; params&#58; An arrayref, parallel to <tt>items</tt>, of arrayrefs of parameters (in paired name/value form) to be passed to the observables.; cross_params&#58; Cross-product parameters. This must be an arrayref of arrayrefs of parameters (paired name/value form). This creates an additional "axis" (orthogonal to the time and <tt>items</tt> axes) in which the item is calculated once with each set of parameters in <tt>cross_params</tt>. These parameters are merged with those in <tt>params</tt>. Instead of being nested two levels, <tt>data</tt> will be nested three levels, with the third level corresponding to this arrayref.
 +
===FILTERING===
 +
; agentnum&#58; Limit to customers with this agent.; refnum&#58; Limit to customers with this advertising source.; cust_classnum&#58; Limit to customers with this classnum; can be an arrayref.; remove_empty&#58; Set this to a true value to hide rows that contain only zeroes. The <tt>indices</tt> array in the returned data will list the item indices that are actually present in the output so that you know what they are. Ignored if <tt>cross_params</tt> is in effect.
 +
===PASS-THROUGH===
 +
<tt>item_labels</tt>, <tt>colors</tt>, and <tt>links</tt> may be specified as arrayrefs parallel to <tt>items</tt>. Those values will be returned in <tt>data</tt>, with any hidden rows (due to <tt>remove_empty</tt>) filtered out, which is the only reason to do this. Now that we have <tt>indices</tt> it's probably better to use that.
 +
 
 +
; PROCESSING; normalize&#58; Set this to an item index to have all other items expressed as a percentage of that one. That item will then be omitted from the output. If the normalization item is zero in some period, all the values in that period will be undef.
 +
==RETURNED DATA==
 +
The <tt>data</tt> method runs the report and returns a hashref of the following:
 +
 
 +
; label
 +
:Month labels, in MM/YYYY format.
 +
; speriod, eperiod
 +
:Absolute start and end times of each month, in unix time format.
 +
; items
 +
:The values passed in as <tt>items</tt>, with any suppressed rows deleted.
 +
; indices
 +
:The indices of items in the input <tt>items</tt> list that appear in the result set. Useful for figuring out what they are when <tt>remove_empty</tt> has deleted some items.
 +
; item_labels, colors, links - see PASS-THROUGH above; data
 +
:The actual results. An arrayref corresponding to <tt>label</tt> (the time axis), containing arrayrefs corresponding to <tt>items</tt>, containing either numbers or, if <tt>cross_params</tt> is given, arrayrefs corresponding to <tt>cross_params</tt>.
  
 
==BUGS==
 
==BUGS==
Documentation.
+
==SEE ALSO==
 +
==POD ERRORS==
 +
Hey! '''The above document had some coding errors, which are explained below:'''
  
==SEE ALSO==
+
; Around line 91&#58;
 +
:'=item' outside of any '=over'
 +
; Around line 98&#58;
 +
:You forgot a '=back' before '=head1'
 +
; Around line 302&#58;
 +
:=back without =over

Latest revision as of 10:48, 21 July 2015

NAME

FS::Report::Table::Monthly - Tables of report data, indexed monthly

SYNOPSIS

 use FS::Report::Table::Monthly;

 my $report = new FS::Report::Table::Monthly (
   'items' => [ 'invoiced', 'netsales', 'credits', 'receipts', ],
   'start_month' => 4,
   'start_year'  => 2000,
   'end_month'   => 4,
   'end_year'    => 2020,
   #opt
   'agentnum'    => 54
   'refnum'      => 54
   'cust_classnum' => [ 1,2,4 ],
   'params'      => [ [ 'paramsfor', 'item_one' ], [ 'item', 'two' ] ], # ...
   'remove_empty' => 1, #collapse empty rows, default 0
   'item_labels' => [ ], #useful with remove_empty
 );

 my $data = $report->data;

PARAMETERS

TIME PERIOD

start_month, start_year, end_month, and end_year specify the date range to be included in the report. The start and end months are included. Each month's values are summed from midnight on the first of the month to 23:59:59 on the last day of the month.

REPORT ITEMS

items: An arrayref of observables to calculate for each month. See FS::Report::Table for a list of observables and their parameters.; params: An arrayref, parallel to items, of arrayrefs of parameters (in paired name/value form) to be passed to the observables.; cross_params: Cross-product parameters. This must be an arrayref of arrayrefs of parameters (paired name/value form). This creates an additional "axis" (orthogonal to the time and items axes) in which the item is calculated once with each set of parameters in cross_params. These parameters are merged with those in params. Instead of being nested two levels, data will be nested three levels, with the third level corresponding to this arrayref.

FILTERING

agentnum: Limit to customers with this agent.; refnum: Limit to customers with this advertising source.; cust_classnum: Limit to customers with this classnum; can be an arrayref.; remove_empty: Set this to a true value to hide rows that contain only zeroes. The indices array in the returned data will list the item indices that are actually present in the output so that you know what they are. Ignored if cross_params is in effect.

PASS-THROUGH

item_labels, colors, and links may be specified as arrayrefs parallel to items. Those values will be returned in data, with any hidden rows (due to remove_empty) filtered out, which is the only reason to do this. Now that we have indices it's probably better to use that.

PROCESSING; normalize: Set this to an item index to have all other items expressed as a percentage of that one. That item will then be omitted from the output. If the normalization item is zero in some period, all the values in that period will be undef.

RETURNED DATA

The data method runs the report and returns a hashref of the following:

label
Month labels, in MM/YYYY format.
speriod, eperiod
Absolute start and end times of each month, in unix time format.
items
The values passed in as items, with any suppressed rows deleted.
indices
The indices of items in the input items list that appear in the result set. Useful for figuring out what they are when remove_empty has deleted some items.
item_labels, colors, links - see PASS-THROUGH above; data
The actual results. An arrayref corresponding to label (the time axis), containing arrayrefs corresponding to items, containing either numbers or, if cross_params is given, arrayrefs corresponding to cross_params.

BUGS

SEE ALSO

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 91:
'=item' outside of any '=over'
Around line 98:
You forgot a '=back' before '=head1'
Around line 302:
=back without =over