[freeside-commits] branch FREESIDE_3_BRANCH updated. 472f6aedda5898e6e0ab2b78a492d8e8e5c7cf93
Mark Wells
mark at 420.am
Wed Apr 30 22:35:41 PDT 2014
The branch, FREESIDE_3_BRANCH has been updated
via 472f6aedda5898e6e0ab2b78a492d8e8e5c7cf93 (commit)
from f064b8593fa93cd8c55618c63d6bba4a0c542cbf (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 472f6aedda5898e6e0ab2b78a492d8e8e5c7cf93
Author: Mark Wells <mark at freeside.biz>
Date: Wed Apr 30 22:35:23 2014 -0700
billing event conditions on original package setup date, #25528
diff --git a/FS/FS/part_event/Condition/pkg_age_Common.pm b/FS/FS/part_event/Condition/pkg_age_Common.pm
index 33e49b8..2e0e539 100644
--- a/FS/FS/part_event/Condition/pkg_age_Common.pm
+++ b/FS/FS/part_event/Condition/pkg_age_Common.pm
@@ -13,6 +13,7 @@ tie our %dates, 'Tie::IxHash',
'expire' => 'Expiration date',
'cancel' => 'Cancellation date',
'contract_end' => 'Contract end date',
+ 'orig_setup' => 'Original setup date',
;
sub eventtable_hashref {
@@ -42,7 +43,16 @@ sub condition {
my $age = $self->pkg_age_age( $cust_pkg, %opt );
- my $pkg_date = $cust_pkg->get( $self->option('field') );
+ my $field = $self->option('field');
+ if ( $field =~ /^orig_(\w+)$/ ) {
+ # then find the package's oldest ancestor and compare to that
+ $field = $1;
+ while ($cust_pkg->change_pkgnum) {
+ $cust_pkg = $cust_pkg->old_cust_pkg;
+ }
+ }
+
+ my $pkg_date = $cust_pkg->get( $field );
$pkg_date && $self->pkg_age_compare( $pkg_date, $age );
@@ -64,8 +74,13 @@ sub condition_sql {
#amazingly, this is actually faster
my $sql = '( CASE';
foreach ( keys %dates ) {
- $sql .= " WHEN $field = '$_' THEN ".
- " (cust_pkg.$_ IS NOT NULL AND cust_pkg.$_ $op $age)";
+ $sql .= " WHEN $field = '$_' THEN ";
+ # don't even try to handle orig_setup in here. it's not worth it.
+ if ($_ =~ /^orig_/) {
+ $sql .= 'TRUE';
+ } else {
+ $sql .= " (cust_pkg.$_ IS NOT NULL AND cust_pkg.$_ $op $age)";
+ }
}
$sql .= ' END )';
return $sql;
-----------------------------------------------------------------------
Summary of changes:
FS/FS/part_event/Condition/pkg_age_Common.pm | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
More information about the freeside-commits
mailing list