[freeside-commits] freeside/FS/FS/part_event/Action pkg_employee_credit_pkg.pm, NONE, 1.1.2.2 pkg_referral_credit.pm, 1.1, 1.1.4.1 pkg_referral_credit_pkg.pm, 1.2, 1.2.2.1 pkg_agent_credit.pm, NONE, 1.1.2.2 pkg_agent_credit_pkg.pm, NONE, 1.1.2.2
Ivan,,,
ivan at wavetail.420.am
Mon Mar 29 19:53:14 PDT 2010
Update of /home/cvs/cvsroot/freeside/FS/FS/part_event/Action
In directory wavetail.420.am:/tmp/cvs-serv27618/FS/FS/part_event/Action
Modified Files:
Tag: FREESIDE_1_9_BRANCH
pkg_referral_credit.pm pkg_referral_credit_pkg.pm
Added Files:
Tag: FREESIDE_1_9_BRANCH
pkg_employee_credit_pkg.pm pkg_agent_credit.pm
pkg_agent_credit_pkg.pm
Log Message:
employee (otaker / access_user) commissioning, RT#6991
--- NEW FILE: pkg_agent_credit.pm ---
package FS::part_event::Action::pkg_agent_credit;
use strict;
use base qw( FS::part_event::Action::pkg_referral_credit );
sub description { 'Credit the agent a specific amount'; }
#a little false laziness w/pkg_referral_credit
sub do_action {
my( $self, $cust_pkg ) = @_;
my $cust_main = $self->cust_main($cust_pkg);
my $agent = $cust_main->agent;
return "No customer record for agent ". $agent->agent
unless $agent->agent_custnum;
my $agent_cust_main = $agent->agent_cust_main;
#? or return "No customer record for agent ". $agent->agent;
my $amount = $self->_calc_credit($cust_pkg);
return '' unless $amount > 0;
my $reasonnum = $self->option('reasonnum');
my $error = $agent_cust_main->credit(
$amount,
\$reasonnum,
'addlinfo' =>
'for customer #'. $cust_main->display_custnum. ': '.$cust_main->name,
);
die "Error crediting customer ". $agent_cust_main->custnum.
" for agent commission: $error"
if $error;
}
1;
Index: pkg_referral_credit_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_event/Action/pkg_referral_credit_pkg.pm,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -w -d -r1.2 -r1.2.2.1
--- pkg_referral_credit_pkg.pm 19 Aug 2009 21:27:16 -0000 1.2
+++ pkg_referral_credit_pkg.pm 30 Mar 2010 02:53:12 -0000 1.2.2.1
@@ -1,58 +1,9 @@
package FS::part_event::Action::pkg_referral_credit_pkg;
use strict;
-use base qw( FS::part_event::Action::pkg_referral_credit );
+use base qw( FS::part_event::Action::Mixin::credit_pkg
+ FS::part_event::Action::pkg_referral_credit );
sub description { 'Credit the referring customer an amount based on the referred package'; }
-#sub eventtable_hashref {
-# { 'cust_pkg' => 1 };
-#}
-
-sub option_fields {
- (
- 'reasonnum' => { 'label' => 'Credit reason',
- 'type' => 'select-reason',
- 'reason_class' => 'R',
- },
- 'percent' => { 'label' => 'Percent',
- 'type' => 'input-percentage',
- 'default' => '100',
- },
- 'what' => { 'label' => 'Of',
- 'type' => 'select',
- #also add some way to specify in the package def, no?
- 'options' => [ qw( base_recur_permonth ) ],
- 'labels' => { 'base_recur_permonth' => 'Base monthly fee', },
- },
- );
-
-}
-
-sub _calc_referral_credit {
- my( $self, $cust_pkg ) = @_;
-
- my $cust_main = $self->cust_main($cust_pkg);
-
- my $part_pkg = $cust_pkg->part_pkg;
-
- my $what = $self->option('what');
-
- #false laziness w/Condition/cust_payments_pkg.pm
- if ( $what eq 'base_recur_permonth' ) { #huh. yuck.
- if ( $part_pkg->freq !~ /^\d+$/ ) {
- die 'WARNING: Not crediting customer '. $cust_main->referral_custnum.
- ' for package '. $cust_pkg->pkgnum.
- ' ( customer '. $cust_pkg->custnum. ')'.
- ' - Referral credits not (yet) available for '.
- ' packages with '. $part_pkg->freq_pretty. ' frequency';
- }
- }
-
- my $percent = $self->option('percent');
-
- sprintf('%.2f', $part_pkg->$what($cust_pkg) * $percent / 100 );
-
-}
-
1;
Index: pkg_referral_credit.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_event/Action/pkg_referral_credit.pm,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -w -d -r1.1 -r1.1.4.1
--- pkg_referral_credit.pm 22 Nov 2008 22:17:27 -0000 1.1
+++ pkg_referral_credit.pm 30 Mar 2010 02:53:12 -0000 1.1.4.1
@@ -22,7 +22,6 @@
}
-#a little false laziness w/pkg_referral_credit_pkg
sub do_action {
my( $self, $cust_pkg ) = @_;
@@ -36,7 +35,9 @@
return 'Referring customer is cancelled'
if $referring_cust_main->status eq 'cancelled';
- my $amount = $self->_calc_referral_credit($cust_pkg);
+ my $amount = $self->_calc_credit($cust_pkg);
+ return '' unless $amount > 0;
+
my $reasonnum = $self->option('reasonnum');
my $error = $referring_cust_main->credit(
@@ -51,7 +52,7 @@
}
-sub _calc_referral_credit {
+sub _calc_credit {
my( $self, $cust_pkg ) = @_;
$self->option('amount');
--- NEW FILE: pkg_agent_credit_pkg.pm ---
package FS::part_event::Action::pkg_agent_credit_pkg;
use strict;
use base qw( FS::part_event::Action::Mixin::credit_pkg
FS::part_event::Action::pkg_agent_credit );
sub description { 'Credit the agent an amount based on the referred package'; }
1;
--- NEW FILE: pkg_employee_credit_pkg.pm ---
package FS::part_event::Action::pkg_employee_credit_pkg;
use strict;
use base qw( FS::part_event::Action::Mixin::credit_pkg
FS::part_event::Action::pkg_employee_credit );
sub description { 'Credit the ordering employee an amount based on the referred package'; }
1;
More information about the freeside-commits
mailing list