[freeside-commits] branch master updated. 2a7f90bbc8958c0674bb470ecd8e4bed00e6a8c4

Ivan ivan at 420.am
Thu Apr 26 17:35:23 PDT 2012


The branch, master has been updated
       via  2a7f90bbc8958c0674bb470ecd8e4bed00e6a8c4 (commit)
       via  4f94568dd0bc4c857441ec531e2c936fefa78635 (commit)
       via  015f3c7ad959f6e07531e121c68f6a2e2ab794cc (commit)
      from  6ff1c755b054201c38b0a2a7b6161325af5c0bcf (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 2a7f90bbc8958c0674bb470ecd8e4bed00e6a8c4
Merge: 4f94568 6ff1c75
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Apr 26 17:35:14 2012 -0700

    Merge branch 'master' of git.freeside.biz:/home/git/freeside


commit 4f94568dd0bc4c857441ec531e2c936fefa78635
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Apr 26 17:35:02 2012 -0700

    add "Don't run this event more than once per customer in the specified interval" condition, RT#17386

diff --git a/FS/FS/part_event/Condition/once_percust_every.pm b/FS/FS/part_event/Condition/once_percust_every.pm
new file mode 100644
index 0000000..6903b87
--- /dev/null
+++ b/FS/FS/part_event/Condition/once_percust_every.pm
@@ -0,0 +1,58 @@
+package FS::part_event::Condition::once_every;
+
+use strict;
+use FS::Record qw( qsearch );
+use FS::part_event;
+use FS::cust_event;
+
+use base qw( FS::part_event::Condition );
+
+sub description { "Don't run this event more than once per customer in the specified interval"; }
+
+sub eventtable_hashref {
+    { 'cust_main' => 0,
+      'cust_bill' => 1,
+      'cust_pkg'  => 1,
+    };
+}
+
+# Runs the event at most "once every X", per customer.
+
+sub option_fields {
+  (
+    'run_delay'  => { label=>'Interval', type=>'freq', value=>'1m', },
+  );
+}
+
+sub condition {
+  my($self, $object, %opt) = @_;
+
+  my $obj_pkey = $object->primary_key;
+  my $obj_table = $object->table;
+  my $custnum = $object->custnum;
+
+  my @where = (
+    "tablenum IN ( SELECT $obj_pkey FROM $obj_table WHERE custnum = $custnum )"
+  );
+  if ( $opt{'cust_event'}->eventnum =~ /^(\d+)$/ ) {
+    push @where, " eventnum != $1 ";
+  }
+  my $extra_sql = ' AND '. join(' AND ', @where);
+ 
+  my $max_date = $self->option_age_from('run_delay', $opt{'time'});
+ 
+  my @existing = qsearch( {
+    'table'     => 'cust_event',
+    'hashref'   => {
+                     'eventpart' => $self->eventpart,
+                     'status'    => { op=>'!=', value=>'failed'  },
+                     '_date'     => { op=>'>',  value=>$max_date },
+                   },
+    'extra_sql' => $extra_sql,
+  } );
+
+  ! scalar(@existing);
+
+}
+
+1;

commit 015f3c7ad959f6e07531e121c68f6a2e2ab794cc
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Apr 26 17:34:42 2012 -0700

    doc

diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm
index ef30809..eca291a 100644
--- a/FS/FS/cust_pay.pm
+++ b/FS/FS/cust_pay.pm
@@ -87,7 +87,7 @@ order taker (see L<FS::access_user>)
 
 =item payby
 
-Payment Type (See L<FS::payinfo_Mixin> for valid payby values)
+Payment Type (See L<FS::payinfo_Mixin> for valid values)
 
 =item payinfo
 

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

Summary of changes:
 FS/FS/cust_pay.pm                                  |    2 +-
 .../{once_percust.pm => once_percust_every.pm}     |   37 +++++++------------
 2 files changed, 15 insertions(+), 24 deletions(-)
 copy FS/FS/part_event/Condition/{once_percust.pm => once_percust_every.pm} (60%)




More information about the freeside-commits mailing list