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',
13 'inherit_fields' => [ 'global_Mixin' ],
15 'comission_amount' => { 'name' => 'Commission amount per month (per active package)',
18 'comission_depth' => { 'name' => 'Number of layers',
21 'reason_type' => { 'name' => 'Reason type for commission credits',
23 'select_table' => 'reason_type',
24 'select_hash' => { 'class' => 'R' },
25 'select_key' => 'typenum',
26 'select_label' => 'type',
29 'fieldorder' => [ 'comission_depth', 'comission_amount', 'reason_type' ],
30 #'setup' => 'what.setup_fee.value',
31 #'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 + \';\'',
37 my $str = $self->SUPER::price_info;
38 my $com = $self->option('comission_amount');
39 $str .= ", $com commission" if $com;
44 my($self, $cust_pkg ) = @_;
46 my $amount = $self->option('comission_amount');
47 my $num_active = scalar(
48 $cust_pkg->cust_main->referral_cust_pkg( $self->option('comission_depth') )
51 my $commission = sprintf('%.2f', $amount*$num_active);
53 if ( $commission > 0 ) {
56 $cust_pkg->cust_main->credit( $commission, "commission",
57 'reason_type'=>$self->option('reason_type'),
63 $self->option('recur_fee');
66 sub can_discount { 0; }