[freeside-commits] branch FREESIDE_2_3_BRANCH updated. 9528cfd540bd5bcf8ee581458d7b0e407cf12b8b

Ivan ivan at 420.am
Tue Feb 26 01:22:04 PST 2013


The branch, FREESIDE_2_3_BRANCH has been updated
       via  9528cfd540bd5bcf8ee581458d7b0e407cf12b8b (commit)
      from  d0174a54dff1c4ef602737379b3eccbed2c03578 (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 9528cfd540bd5bcf8ee581458d7b0e407cf12b8b
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Feb 26 01:22:00 2013 -0800

    add event action to increment the referring customer's pacakge's next bill date, RT#20143

diff --git a/FS/FS/part_event/Action/referral_pkg_billdate.pm b/FS/FS/part_event/Action/referral_pkg_billdate.pm
new file mode 100644
index 0000000..40d94e2
--- /dev/null
+++ b/FS/FS/part_event/Action/referral_pkg_billdate.pm
@@ -0,0 +1,55 @@
+package FS::part_event::Action::referral_pkg_billdate;
+
+use strict;
+use base qw( FS::part_event::Action );
+
+sub description { "Increment the referring customer's package's next bill date"; }
+
+#sub eventtable_hashref {
+#}
+
+sub option_fields {
+  (
+    'if_pkgpart' => { 'label'    => 'Only packages',
+                      'type'     => 'select-part_pkg',
+                      'multiple' => 1,
+                    },
+    'increment'  => { 'label'    => 'Increment by',
+                      'type'     => 'freq',
+                      'value'    => '1m',
+                    },
+  );
+}
+
+sub do_action {
+  my( $self, $cust_object, $cust_event ) = @_;
+
+  my $cust_main = $self->cust_main($cust_object);
+
+  return 'No referring customer' unless $cust_main->referral_custnum;
+
+  my $referring_cust_main = $cust_main->referring_cust_main;
+  #return 'Referring customer is cancelled'
+  #  if $referring_cust_main->status eq 'cancelled';
+
+  my %if_pkgpart = map { $_=>1 } split(/\s*,\s*/, $self->option('if_pkgpart') );
+  my @cust_pkg = grep $if_pkgpart{ $_->pkgpart },
+                      $referring_cust_main->billing_pkgs;
+  return 'No qualifying billing package definition' unless @cust_pkg;
+
+  my $cust_pkg = $cust_pkg[0]; #only one
+
+  my $bill = $cust_pkg->bill || $cust_pkg->setup || time;
+
+  $cust_pkg->bill(
+    $cust_pkg->part_pkg->add_freq( $bill, $self->option('increment') )
+  );
+
+  my $error = $cust_pkg->replace;
+  die "Error incrementing next bill date: $error" if $error;
+
+  '';
+
+}
+
+1;

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

Summary of changes:
 FS/FS/part_event/Action/referral_pkg_billdate.pm |   55 ++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)
 create mode 100644 FS/FS/part_event/Action/referral_pkg_billdate.pm




More information about the freeside-commits mailing list