[freeside-commits] branch FREESIDE_3_BRANCH updated. 2a4d10f557968a85fe10076294a8402938082d03
Jonathan Prykop
jonathan at 420.am
Tue Feb 10 21:26:05 PST 2015
The branch, FREESIDE_3_BRANCH has been updated
via 2a4d10f557968a85fe10076294a8402938082d03 (commit)
from 8b307b13a808f9174f781e6300b08a95bdca5dfa (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 2a4d10f557968a85fe10076294a8402938082d03
Author: Jonathan Prykop <jonathan at freeside.biz>
Date: Tue Feb 3 14:32:19 2015 -0600
RT#27886: Referral customers and billing events
diff --git a/FS/FS/part_event/Condition/has_referral_custnum.pm b/FS/FS/part_event/Condition/has_referral_custnum.pm
index c505794..f8a2b82 100644
--- a/FS/FS/part_event/Condition/has_referral_custnum.pm
+++ b/FS/FS/part_event/Condition/has_referral_custnum.pm
@@ -31,19 +31,22 @@ sub condition {
my($self, $object, %opt) = @_;
my $cust_main = $self->cust_main($object);
+ return 0 unless $cust_main; #sanity check
+ return 0 unless $cust_main->referral_custnum;
+
+ my $referring_cust_main = $cust_main->referral_custnum_cust_main;
+ return 0 unless $referring_cust_main; #sanity check;
+
+ #referring customer must sign up before referred customer
+ return 0 unless $cust_main->signupdate > $referring_cust_main->signupdate;
if ( $self->option('active') ) {
- return 0 unless $cust_main->referral_custnum;
#check for no cust_main for referral_custnum? (deleted?)
- return 0 unless $cust_main->referral_custnum_cust_main->status eq 'active';
- } else {
- return 0 unless $cust_main->referral_custnum; # ? 1 : 0;
+ return 0 unless $referring_cust_main->status eq 'active';
}
return 1 unless $self->option('check_bal');
- my $referring_cust_main = $cust_main->referral_custnum_cust_main;
-
#false laziness w/ balance_age_under
my $under = $self->option('balance');
$under = 0 unless length($under);
diff --git a/FS/FS/part_event/Condition/has_referral_pkgpart.pm b/FS/FS/part_event/Condition/has_referral_pkgpart.pm
index 60ba7cc..7062f6c 100644
--- a/FS/FS/part_event/Condition/has_referral_pkgpart.pm
+++ b/FS/FS/part_event/Condition/has_referral_pkgpart.pm
@@ -1,6 +1,7 @@
package FS::part_event::Condition::has_referral_pkgpart;
use base qw( FS::part_event::Condition );
+use FS::part_event::Condition::has_referral_custnum;
#maybe i should be incorporated in has_referral_custnum
use strict;
@@ -19,10 +20,10 @@ sub option_fields {
sub condition {
my($self, $object, %opt) = @_;
+ return 0 unless FS::part_event::Condition::has_referral_custnum::condition($self, $object, %opt);
+
my $cust_main = $self->cust_main($object);
- return 0 unless $cust_main->referral_custnum;
-
my $if_pkgpart = $self->option('if_pkgpart') || {};
grep $if_pkgpart->{ $_->pkgpart },
$cust_main->referral_custnum_cust_main->ncancelled_pkgs;
-----------------------------------------------------------------------
Summary of changes:
FS/FS/part_event/Condition/has_referral_custnum.pm | 15 +++++++++------
FS/FS/part_event/Condition/has_referral_pkgpart.pm | 5 +++--
2 files changed, 12 insertions(+), 8 deletions(-)
More information about the freeside-commits
mailing list