projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
minor cleanup
[freeside.git]
/
FS
/
FS
/
part_event
/
Action
/
pkg_referral_credit.pm
diff --git
a/FS/FS/part_event/Action/pkg_referral_credit.pm
b/FS/FS/part_event/Action/pkg_referral_credit.pm
index
da872e7
..
a85a3a1
100644
(file)
--- a/
FS/FS/part_event/Action/pkg_referral_credit.pm
+++ b/
FS/FS/part_event/Action/pkg_referral_credit.pm
@@
-1,7
+1,8
@@
package FS::part_event::Action::pkg_referral_credit;
use strict;
package FS::part_event::Action::pkg_referral_credit;
use strict;
-use base qw( FS::part_event::Action );
+use base qw( FS::part_event::Action::Mixin::credit_flat
+ FS::part_event::Action );
sub description { 'Credit the referring customer a specific amount'; }
sub description { 'Credit the referring customer a specific amount'; }
@@
-9,21
+10,8
@@
sub eventtable_hashref {
{ 'cust_pkg' => 1 };
}
{ 'cust_pkg' => 1 };
}
-sub option_fields {
- (
- 'reasonnum' => { 'label' => 'Credit reason',
- 'type' => 'select-reason',
- 'reason_class' => 'R',
- },
- 'amount' => { 'label' => 'Credit amount',
- 'type' => 'money',
- },
- );
-
-}
-
sub do_action {
sub do_action {
- my( $self, $cust_pkg ) = @_;
+ my( $self, $cust_pkg
, $cust_event
) = @_;
my $cust_main = $self->cust_main($cust_pkg);
my $cust_main = $self->cust_main($cust_pkg);
@@
-35,16
+23,18
@@
sub do_action {
return 'Referring customer is cancelled'
if $referring_cust_main->status eq 'cancelled';
return 'Referring customer is cancelled'
if $referring_cust_main->status eq 'cancelled';
- my $amount = $self->_calc_credit($cust_pkg);
- return '' unless $amount > 0;
+ my $warning = '';
+ my $amount = $self->_calc_credit($cust_pkg, $referring_cust_main, \$warning);
+ return $warning unless $amount > 0;
my $reasonnum = $self->option('reasonnum');
my $error = $referring_cust_main->credit(
$amount,
\$reasonnum,
my $reasonnum = $self->option('reasonnum');
my $error = $referring_cust_main->credit(
$amount,
\$reasonnum,
- 'addlinfo' =>
- 'for customer #'. $cust_main->display_custnum. ': '.$cust_main->name,
+ 'eventnum' => $cust_event->eventnum,
+ 'addlinfo' => 'for customer #'. $cust_main->display_custnum.
+ ': '.$cust_main->name,
);
die "Error crediting customer ". $cust_main->referral_custnum.
" for referral: $error"
);
die "Error crediting customer ". $cust_main->referral_custnum.
" for referral: $error"
@@
-52,10
+42,4
@@
sub do_action {
}
}
-sub _calc_credit {
- my( $self, $cust_pkg ) = @_;
-
- $self->option('amount');
-}
-
1;
1;