summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorivan <ivan>2010-03-30 12:07:48 +0000
committerivan <ivan>2010-03-30 12:07:48 +0000
commit18f1fb3831bd99520f02a5ebe717344f71dc866f (patch)
treec2b2393ef8e829ca638d67855d42263ced091d59 /FS
parent5706781c54820002799ce3a1d2d4893256b9b755 (diff)
employee commission reporting, RT#6991
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/cust_credit.pm2
-rw-r--r--FS/FS/cust_event.pm6
-rw-r--r--FS/FS/cust_main.pm8
-rw-r--r--FS/FS/part_event/Action/pkg_agent_credit.pm7
-rw-r--r--FS/FS/part_event/Action/pkg_employee_credit.pm7
-rw-r--r--FS/FS/part_event/Action/pkg_referral_credit.pm7
6 files changed, 21 insertions, 16 deletions
diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm
index a7de397..b87b0db 100644
--- a/FS/FS/cust_credit.pm
+++ b/FS/FS/cust_credit.pm
@@ -14,6 +14,7 @@ use FS::cust_credit_bill;
use FS::part_pkg;
use FS::reason_type;
use FS::reason;
+use FS::cust_event;
$me = '[ FS::cust_credit ]';
$DEBUG = 0;
@@ -300,6 +301,7 @@ sub check {
|| $self->ut_textn('addlinfo')
|| $self->ut_enum('closed', [ '', 'Y' ])
|| $self->ut_foreign_keyn('pkgnum', 'cust_pkg', 'pkgnum')
+ || $self->ut_foreign_keyn('eventnum', 'cust_event', 'eventnum')
;
return $error if $error;
diff --git a/FS/FS/cust_event.pm b/FS/FS/cust_event.pm
index d2fcfc1..52b5911 100644
--- a/FS/FS/cust_event.pm
+++ b/FS/FS/cust_event.pm
@@ -1,18 +1,16 @@
package FS::cust_event;
use strict;
+use base qw( FS::cust_main_Mixin FS::Record );
use vars qw( @ISA $DEBUG $me );
use Carp qw( croak confess );
use FS::Record qw( qsearch qsearchs dbdef );
-use FS::cust_main_Mixin;
use FS::part_event;
#for cust_X
use FS::cust_main;
use FS::cust_pkg;
use FS::cust_bill;
-@ISA = qw(FS::cust_main_Mixin FS::Record);
-
$DEBUG = 0;
$me = '[FS::cust_event]';
@@ -230,7 +228,7 @@ sub do_event {
my $error;
{
local $SIG{__DIE__}; # don't want Mason __DIE__ handler active
- $error = eval { $part_event->do_action($object); };
+ $error = eval { $part_event->do_action($object, $self); };
}
my $status = '';
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 24eb73a..1d220fe 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -7447,7 +7447,7 @@ sub referral_cust_main_ncancelled {
Like referral_cust_main, except returns a flat list of all unsuspended (and
uncancelled) packages for each customer. The number of items in this list may
-be useful for comission calculations (perhaps after a C<grep { my $pkgpart = $_->pkgpart; grep { $_ == $pkgpart } @commission_worthy_pkgparts> } $cust_main-> ).
+be useful for commission calculations (perhaps after a C<grep { my $pkgpart = $_->pkgpart; grep { $_ == $pkgpart } @commission_worthy_pkgparts> } $cust_main-> ).
=cut
@@ -7509,8 +7509,10 @@ sub credit {
$cust_credit->set('reason', $reason)
}
- $cust_credit->addlinfo( delete $options{'addlinfo'} )
- if exists($options{'addlinfo'});
+ for (qw( addlinfo eventnum )) {
+ $cust_credit->$_( delete $options{$_} )
+ if exists($options{$_});
+ }
$cust_credit->insert(%options);
diff --git a/FS/FS/part_event/Action/pkg_agent_credit.pm b/FS/FS/part_event/Action/pkg_agent_credit.pm
index 2502738..4bcee98 100644
--- a/FS/FS/part_event/Action/pkg_agent_credit.pm
+++ b/FS/FS/part_event/Action/pkg_agent_credit.pm
@@ -7,7 +7,7 @@ sub description { 'Credit the agent a specific amount'; }
#a little false laziness w/pkg_referral_credit
sub do_action {
- my( $self, $cust_pkg ) = @_;
+ my( $self, $cust_pkg, $cust_event ) = @_;
my $cust_main = $self->cust_main($cust_pkg);
@@ -26,8 +26,9 @@ sub do_action {
my $error = $agent_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 ". $agent_cust_main->custnum.
" for agent commission: $error"
diff --git a/FS/FS/part_event/Action/pkg_employee_credit.pm b/FS/FS/part_event/Action/pkg_employee_credit.pm
index 28fd025..64dd8b2 100644
--- a/FS/FS/part_event/Action/pkg_employee_credit.pm
+++ b/FS/FS/part_event/Action/pkg_employee_credit.pm
@@ -7,7 +7,7 @@ sub description { 'Credit the ordering employee a specific amount'; }
#a little false laziness w/pkg_referral_credit
sub do_action {
- my( $self, $cust_pkg ) = @_;
+ my( $self, $cust_pkg, $cust_event ) = @_;
my $cust_main = $self->cust_main($cust_pkg);
@@ -26,8 +26,9 @@ sub do_action {
my $error = $employee_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 ". $employee_cust_main->custnum.
" for employee commission: $error"
diff --git a/FS/FS/part_event/Action/pkg_referral_credit.pm b/FS/FS/part_event/Action/pkg_referral_credit.pm
index da872e7..e7c92d6 100644
--- a/FS/FS/part_event/Action/pkg_referral_credit.pm
+++ b/FS/FS/part_event/Action/pkg_referral_credit.pm
@@ -23,7 +23,7 @@ sub option_fields {
}
sub do_action {
- my( $self, $cust_pkg ) = @_;
+ my( $self, $cust_pkg, $cust_event ) = @_;
my $cust_main = $self->cust_main($cust_pkg);
@@ -43,8 +43,9 @@ sub do_action {
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"