[freeside-commits] branch FREESIDE_3_BRANCH updated. 68d8ad238bcb54677492f26faadf920d559038d0

Mark Wells mark at 420.am
Wed May 14 13:03:36 PDT 2014


The branch, FREESIDE_3_BRANCH has been updated
       via  68d8ad238bcb54677492f26faadf920d559038d0 (commit)
      from  97105665715dd56465db126082919a319c71c2e2 (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 68d8ad238bcb54677492f26faadf920d559038d0
Author: Mark Wells <mark at freeside.biz>
Date:   Wed May 14 13:02:08 2014 -0700

    also allow "original setup date" in pkg_age condition, #25528

diff --git a/FS/FS/part_event/Condition/pkg_age.pm b/FS/FS/part_event/Condition/pkg_age.pm
index de58970..f2cfe6d 100644
--- a/FS/FS/part_event/Condition/pkg_age.pm
+++ b/FS/FS/part_event/Condition/pkg_age.pm
@@ -1,67 +1,18 @@
 package FS::part_event::Condition::pkg_age;
+use base qw( FS::part_event::Condition::pkg_age_Common );
 
 use strict;
-use base qw( FS::part_event::Condition );
-use FS::Record qw( qsearch );
 
-sub description {
-  'Package Age';
-}
-
-sub eventtable_hashref {
-    { 'cust_main' => 0,
-      'cust_bill' => 0,
-      'cust_pkg'  => 1,
-    };
-}
-
-#something like this
-sub option_fields {
-  (
-    'age'  =>  { 'label'   => 'Package date age',
-                 'type'    => 'freq',
-               },
-    'field' => { 'label'   => 'Compare date',
-                 'type'    => 'select',
-                 'options' => [qw(
-                   setup last_bill bill adjourn susp expire cancel contract_end
-                 )],
-                 'labels'  => {
-                   'setup'        => 'Setup date',
-                   'last_bill'    => 'Last bill date',
-                   'bill'         => 'Next bill date',
-                   'adjourn'      => 'Adjournment date',
-                   'susp'         => 'Suspension date',
-                   'expire'       => 'Expiration date',
-                   'cancel'       => 'Cancellation date',
-                   'contract_end' => 'Contract end date',
-                 },
-               },
-  );
-}
+sub description { 'Package Age'; }
 
-sub condition {
-  my( $self, $cust_pkg, %opt ) = @_;
+sub pkg_age_operator { '<='; }
 
-  my $age = $self->option_age_from('age', $opt{'time'} );
-
-  my $pkg_date = $cust_pkg->get( $self->option('field') );
-
-  $pkg_date && $pkg_date <= $age;
-
-}
+sub pkg_age_label { 'Package date older than'; }
 
-sub condition_sql {
-  my( $class, $table, %opt ) = @_;
-  my $age   = $class->condition_sql_option_age_from('age', $opt{'time'});
-  my $field = $class->condition_sql_option('field');
-#amazingly, this is actually faster 
-  my $sql = '( CASE';
-  foreach( qw(setup last_bill bill adjourn susp expire cancel contract_end) ) {
-    $sql .= " WHEN $field = '$_' THEN (cust_pkg.$_ IS NOT NULL AND cust_pkg.$_ <= $age)";
-  }
-  $sql .= ' END )';
-  return $sql;
+sub pkg_age_compare {
+  my( $self, $pkg_date, $age ) = @_;
+  
+  $pkg_date <= $age;
 }
 
 1;

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/part_event/Condition/pkg_age.pm |   65 ++++-----------------------------
 1 files changed, 8 insertions(+), 57 deletions(-)




More information about the freeside-commits mailing list