[freeside-commits] branch FREESIDE_3_BRANCH updated. 75592b7f37bcc6ec8141de80d3642c6f61671bc4

Ivan ivan at 420.am
Tue Jul 23 12:19:39 PDT 2013


The branch, FREESIDE_3_BRANCH has been updated
       via  75592b7f37bcc6ec8141de80d3642c6f61671bc4 (commit)
       via  9d25ecf983c1ca92d9ca0137b678ded22455691d (commit)
       via  ad1bcd1a8eea6d21bd5c380a53698ffe17f9678f (commit)
      from  d2b79b490c5a685991ca87ec6f953a7d18782c1d (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 75592b7f37bcc6ec8141de80d3642c6f61671bc4
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Jul 23 12:19:38 2013 -0700

    add "Package Age Younger" condition, RT#23171

diff --git a/FS/FS/part_event/Condition/pkg_age_Common.pm b/FS/FS/part_event/Condition/pkg_age_Common.pm
new file mode 100644
index 0000000..0f3b9ef
--- /dev/null
+++ b/FS/FS/part_event/Condition/pkg_age_Common.pm
@@ -0,0 +1,68 @@
+package FS::part_event::Condition::pkg_age_Common;
+use base qw( FS::part_event::Condition );
+
+use strict;
+use Tie::IxHash;
+
+tie our %dates, 'Tie::IxHash',
+  '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 eventtable_hashref {
+    { 'cust_main' => 0,
+      'cust_bill' => 0,
+      'cust_pkg'  => 1,
+    };
+}
+
+#something like this
+sub option_fields {
+  my $class = shift;
+  (
+    'age'  =>  { 'label'   => $class->pkg_age_label,
+                 'type'    => 'freq',
+               },
+    'field' => { 'label'   => 'Compare date',
+                 'type'    => 'select',
+                 'options' => [ keys %dates ],
+                 'labels'  => \%dates,
+               },
+  );
+}
+
+sub condition {
+  my( $self, $cust_pkg, %opt ) = @_;
+
+  my $age = $self->option_age_from('age', $opt{'time'} );
+
+  my $pkg_date = $cust_pkg->get( $self->option('field') );
+
+  $pkg_date && $self->pkg_age_compare( $pkg_date, $age );
+
+}
+
+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');
+  my $op    = $class->pkg_age_operator;
+
+  #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 .= ' END )';
+  return $sql;
+}
+
+1;
+
diff --git a/FS/FS/part_event/Condition/pkg_age_before.pm b/FS/FS/part_event/Condition/pkg_age_before.pm
new file mode 100644
index 0000000..c778265
--- /dev/null
+++ b/FS/FS/part_event/Condition/pkg_age_before.pm
@@ -0,0 +1,18 @@
+package FS::part_event::Condition::pkg_age_before;
+use base qw( FS::part_event::Condition::pkg_age_Common );
+
+use strict;
+
+sub description { 'Package Age Younger'; }
+
+sub pkg_age_operator { '>'; }
+
+sub pkg_age_label { 'Package date age younger than'; }
+
+sub pkg_age_compare {
+  my( $pkg_date, $age ) = @_;
+  $pkg_date > $age;
+}
+
+1;
+
diff --git a/FS/FS/part_event_condition.pm b/FS/FS/part_event_condition.pm
index 32f19a3..d550680 100644
--- a/FS/FS/part_event_condition.pm
+++ b/FS/FS/part_event_condition.pm
@@ -185,6 +185,10 @@ foreach my $INC ( @INC ) {
     };
     my $mod = $1;
     my $fullmod = "FS::part_event::Condition::$mod";
+    if ( $fullmod =~ /_(Mixin|Common)$/ ) {
+      #warn "skipping $1 class $fullmod\n";
+      next;
+    }
     eval "use $fullmod;";
     if ( $@ ) {
       die "error using $fullmod (skipping): $@\n" if $@;

commit 9d25ecf983c1ca92d9ca0137b678ded22455691d
Merge: ad1bcd1 d2b79b4
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Jul 23 12:19:25 2013 -0700

    Merge branch 'FREESIDE_3_BRANCH' of git.freeside.biz:/home/git/freeside into FREESIDE_3_BRANCH


commit ad1bcd1a8eea6d21bd5c380a53698ffe17f9678f
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Jul 22 20:13:12 2013 -0700

    3.1

diff --git a/httemplate/docs/about.html b/httemplate/docs/about.html
index c2ba4e4..43b6a3d 100644
--- a/httemplate/docs/about.html
+++ b/httemplate/docs/about.html
@@ -56,7 +56,7 @@ GNU <b>Affero</b> General Public License.<BR>
 
 % unless ( $agentnum ) {
   <CENTER>
-  <FONT SIZE="-3">"I can't figure out ... if it's an end or the beginning" - R. Hunter</FONT>
+  <FONT SIZE="-3">"His job is to shed light, and not to master" - R. Hunter</FONT>
   </CENTER>
 % }
 

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

Summary of changes:
 FS/FS/part_event/Condition/pkg_age_Common.pm |   68 ++++++++++++++++++++++++++
 FS/FS/part_event/Condition/pkg_age_before.pm |   18 +++++++
 FS/FS/part_event_condition.pm                |    4 ++
 httemplate/docs/about.html                   |    2 +-
 4 files changed, 91 insertions(+), 1 deletions(-)
 create mode 100644 FS/FS/part_event/Condition/pkg_age_Common.pm
 create mode 100644 FS/FS/part_event/Condition/pkg_age_before.pm




More information about the freeside-commits mailing list