1 package FS::part_pkg::flat_comission_cust;
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 active customer',
12 'shortname' => 'Commission per active customer',
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 customer)',
27 'comission_depth' => { 'name' => 'Number of layers',
30 'reason_type' => { 'name' => 'Reason type for commission credits',
31 'type' => 'select_table',
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_main_ncancelled(\' + 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_main_ncancelled(
50 $self->option('comission_depth')
54 if ( $amount && $num_active ) {
56 $cust_pkg->cust_main->credit( $amount*$num_active, "commission",
57 'reason_type'=>$self->option('reason_type'),
62 $self->option('recur_fee');