1 package FS::part_pkg::flat_comission;
4 use vars qw(@ISA %info);
5 #use FS::Record qw(qsearch qsearchs);
6 use FS::part_pkg::flat;
8 @ISA = qw(FS::part_pkg::flat);
11 'name' => 'Flat rate with recurring commission per (any) active package',
12 'shortname' => 'Commission per (any) active package',
14 'setup_fee' => { 'name' => 'Setup fee for this package',
17 'recur_fee' => { 'name' => 'Recurring fee for this package',
20 'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
21 ' of service at cancellation',
24 'comission_amount' => { 'name' => 'Commission amount per month (per active package)',
27 'comission_depth' => { 'name' => 'Number of layers',
30 'reason_type' => { 'name' => 'Reason type for commission credits',
32 'select_table' => 'reason_type',
33 'select_hash' => { 'class' => 'R' },
34 'select_key' => 'typenum',
35 'select_label' => 'type',
38 'fieldorder' => [ 'setup_fee', 'recur_fee', 'unused_credit', 'comission_depth', 'comission_amount', 'reason_type' ],
39 #'setup' => 'what.setup_fee.value',
40 #'recur' => '\'my $error = $cust_pkg->cust_main->credit( \' + what.comission_amount.value + \' * scalar($cust_pkg->cust_main->referral_cust_pkg(\' + what.comission_depth.value+ \')), "commission" ); die $error if $error; \' + what.recur_fee.value + \';\'',
45 my($self, $cust_pkg ) = @_;
47 my $amount = $self->option('comission_amount');
48 my $num_active = scalar(
49 $cust_pkg->cust_main->referral_cust_pkg( $self->option('comission_depth') )
52 my $commission = sprintf('%.2f', $amount*$num_active);
54 if ( $commission > 0 ) {
57 $cust_pkg->cust_main->credit( $commission, "commission",
58 'reason_type'=>$self->option('reason_type'),
64 $self->option('recur_fee');