[freeside-commits] branch master updated. 3e5de9ecd12870fdd96d40198dc7490140b6000f

Mark Wells mark at 420.am
Thu Apr 4 16:25:09 PDT 2013


The branch, master has been updated
       via  3e5de9ecd12870fdd96d40198dc7490140b6000f (commit)
       via  72980e7f1077ba3fc8573a095fa77e505f101a82 (commit)
       via  b76f78eed096a15249722731a2823613bf87331e (commit)
      from  4eec6f5915c280d818ade87c0e6ce286c5d61c37 (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 3e5de9ecd12870fdd96d40198dc7490140b6000f
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Apr 4 16:23:41 2013 -0700

    keep package discounts during location change, #22364

diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index fe83f00..b2cb413 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -1775,11 +1775,10 @@ sub change {
   }
 
   # whether to override pkgpart checking on the new package
-  my $allow_pkgpart = 1;
+  my $same_pkgpart = 1;
   if ( $opt->{'pkgpart'} and ( $opt->{'pkgpart'} != $self->pkgpart ) ) {
-    $allow_pkgpart = 0;
+    $same_pkgpart = 0;
   }
-      
 
   my $unused_credit = 0;
   my $keep_dates = $opt->{'keep_dates'};
@@ -1820,7 +1819,7 @@ sub change {
     %hash,
   };
   $error = $cust_pkg->insert( 'change' => 1,
-                              'allow_pkgpart' => $allow_pkgpart );
+                              'allow_pkgpart' => $same_pkgpart );
   if ($error) {
     $dbh->rollback if $oldAutoCommit;
     return $error;
@@ -1878,6 +1877,23 @@ sub change {
     }
   }
 
+  # transfer discounts, if we're not changing pkgpart
+  if ( $same_pkgpart ) {
+    foreach my $old_discount ($self->cust_pkg_discount_active) {
+      # don't remove the old discount, we may still need to bill that package.
+      my $new_discount = new FS::cust_pkg_discount {
+        'pkgnum'      => $cust_pkg->pkgnum,
+        'discountnum' => $old_discount->discountnum,
+        'months_used' => $old_discount->months_used,
+      };
+      $error = $new_discount->insert;
+      if ( $error ) {
+        $dbh->rollback if $oldAutoCommit;
+        return "Error transferring discounts: $error";
+      }
+    }
+  }
+
   # Order any supplemental packages.
   my $part_pkg = $cust_pkg->part_pkg;
   my @old_supp_pkgs = $self->supplemental_pkgs;
@@ -1912,7 +1928,7 @@ sub change {
         $new->set($_, $old->get($_));
       }
     }
-    $error = $new->insert( allow_pkgpart => $allow_pkgpart );
+    $error = $new->insert( allow_pkgpart => $same_pkgpart );
     # transfer services
     if ( $old ) {
       $error ||= $old->transfer($new);

commit 72980e7f1077ba3fc8573a095fa77e505f101a82
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Apr 4 15:46:25 2013 -0700

    allow location change when the package definition has been disabled, #22365, #940

diff --git a/FS/FS/cust_main/Packages.pm b/FS/FS/cust_main/Packages.pm
index a3809f6..29e3bec 100644
--- a/FS/FS/cust_main/Packages.pm
+++ b/FS/FS/cust_main/Packages.pm
@@ -87,7 +87,7 @@ sub order_pkg {
     if exists($opt->{'depend_jobnum'}) && $opt->{'depend_jobnum'};
 
   my %insert_params = map { $opt->{$_} ? ( $_ => $opt->{$_} ) : () }
-                          qw( ticket_subject ticket_queue );
+                          qw( ticket_subject ticket_queue allow_pkgpart );
 
   local $SIG{HUP} = 'IGNORE';
   local $SIG{INT} = 'IGNORE';
@@ -173,6 +173,7 @@ sub order_pkg {
         'refnum'        => $cust_pkg->refnum,
         'discountnum'   => $cust_pkg->discountnum,
         'waive_setup'   => $cust_pkg->waive_setup,
+        'allow_pkgpart' => $opt->{'allow_pkgpart'},
     });
     $error = $self->order_pkg('cust_pkg' => $pkg);
     if ( $error ) {
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index ab479dd..fe83f00 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -267,6 +267,12 @@ a ticket will be added to this customer with this subject
 
 an optional queue name for ticket additions
 
+=item allow_pkgpart
+
+Don't check the legality of the package definition.  This should be used
+when performing a package change that doesn't change the pkgpart (i.e. 
+a location change).
+
 =back
 
 =cut
@@ -274,7 +280,8 @@ an optional queue name for ticket additions
 sub insert {
   my( $self, %options ) = @_;
 
-  my $error = $self->check_pkgpart;
+  my $error;
+  $error = $self->check_pkgpart unless $options{'allow_pkgpart'};
   return $error if $error;
 
   my $part_pkg = $self->part_pkg;
@@ -613,7 +620,6 @@ sub check {
     $self->ut_numbern('pkgnum')
     || $self->ut_foreign_key('custnum', 'cust_main', 'custnum')
     || $self->ut_numbern('pkgpart')
-    || $self->check_pkgpart
     || $self->ut_foreign_keyn('locationnum', 'cust_location', 'locationnum')
     || $self->ut_numbern('start_date')
     || $self->ut_numbern('setup')
@@ -654,14 +660,19 @@ sub check {
 
 =item check_pkgpart
 
+Check the pkgpart to make sure it's allowed with the reg_code and/or
+promo_code of the package (if present) and with the customer's agent.
+Called from C<insert>, unless we are doing a package change that doesn't
+affect pkgpart.
+
 =cut
 
 sub check_pkgpart {
   my $self = shift;
 
-  my $error = $self->ut_numbern('pkgpart');
-  return $error if $error;
+  # my $error = $self->ut_numbern('pkgpart'); # already done
 
+  my $error;
   if ( $self->reg_code ) {
 
     unless ( grep { $self->pkgpart == $_->pkgpart }
@@ -981,6 +992,7 @@ sub uncancel {
 
   my $error = $cust_pkg->insert(
     'change' => 1, #supresses any referral credit to a referring customer
+    'allow_pkgpart' => 1, # allow this even if the package def is disabled
   );
   if ($error) {
     $dbh->rollback if $oldAutoCommit;
@@ -1762,6 +1774,13 @@ sub change {
 
   }
 
+  # whether to override pkgpart checking on the new package
+  my $allow_pkgpart = 1;
+  if ( $opt->{'pkgpart'} and ( $opt->{'pkgpart'} != $self->pkgpart ) ) {
+    $allow_pkgpart = 0;
+  }
+      
+
   my $unused_credit = 0;
   my $keep_dates = $opt->{'keep_dates'};
   # Special case.  If the pkgpart is changing, and the customer is
@@ -1800,7 +1819,8 @@ sub change {
     locationnum  => ( $opt->{'locationnum'}                        ),
     %hash,
   };
-  $error = $cust_pkg->insert( 'change' => 1 );
+  $error = $cust_pkg->insert( 'change' => 1,
+                              'allow_pkgpart' => $allow_pkgpart );
   if ($error) {
     $dbh->rollback if $oldAutoCommit;
     return $error;
@@ -1885,14 +1905,14 @@ sub change {
         contract_end  => $cust_pkg->contract_end,
         refnum        => $cust_pkg->refnum,
         discountnum   => $cust_pkg->discountnum,
-        waive_setup   => $cust_pkg->waive_setup
+        waive_setup   => $cust_pkg->waive_setup,
     });
     if ( $old and $opt->{'keep_dates'} ) {
       foreach (qw(setup bill last_bill)) {
         $new->set($_, $old->get($_));
       }
     }
-    $error = $new->insert;
+    $error = $new->insert( allow_pkgpart => $allow_pkgpart );
     # transfer services
     if ( $old ) {
       $error ||= $old->transfer($new);

commit b76f78eed096a15249722731a2823613bf87331e
Author: Mark Wells <mark at freeside.biz>
Date:   Wed Apr 3 17:18:31 2013 -0700

    make cust_pay upgrade more tolerant about payment gateways

diff --git a/FS/FS/payinfo_transaction_Mixin.pm b/FS/FS/payinfo_transaction_Mixin.pm
index 093891e..50659ac 100644
--- a/FS/FS/payinfo_transaction_Mixin.pm
+++ b/FS/FS/payinfo_transaction_Mixin.pm
@@ -73,10 +73,7 @@ sub _parse_paybatch {
     my $payment_gateway =
       qsearchs('payment_gateway', { 'gatewaynum' => $gatewaynum } );
 
-    die "payment gateway $gatewaynum not found" #?
-      unless $payment_gateway;
-
-    $processor = $payment_gateway->gateway_module;
+    $processor = $payment_gateway->gateway_module if $payment_gateway;
 
   }
 

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

Summary of changes:
 FS/FS/cust_main/Packages.pm        |    3 +-
 FS/FS/cust_pkg.pm                  |   50 +++++++++++++++++++++++++++++++-----
 FS/FS/payinfo_transaction_Mixin.pm |    5 +---
 3 files changed, 46 insertions(+), 12 deletions(-)




More information about the freeside-commits mailing list