[freeside-commits] branch FREESIDE_4_BRANCH updated. 04fb5a4901bec15d10867a39324b24c71d528cdd

Ivan ivan at 420.am
Sat Feb 18 14:21:06 PST 2017


The branch, FREESIDE_4_BRANCH has been updated
       via  04fb5a4901bec15d10867a39324b24c71d528cdd (commit)
      from  863ef1994806855a881130638fa6e70a3ee65e5c (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 04fb5a4901bec15d10867a39324b24c71d528cdd
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sat Feb 18 14:21:05 2017 -0800

    fix 4.x upgrades when an invoice with a discount was deleted instead of voided, RT#74611

diff --git a/FS/FS/cust_bill_pkg_discount.pm b/FS/FS/cust_bill_pkg_discount.pm
index 616657a..2a638a9 100644
--- a/FS/FS/cust_bill_pkg_discount.pm
+++ b/FS/FS/cust_bill_pkg_discount.pm
@@ -2,6 +2,7 @@ package FS::cust_bill_pkg_discount;
 use base qw( FS::cust_main_Mixin FS::Record );
 
 use strict;
+use FS::Record qw( dbh );
 
 =head1 NAME
 
@@ -185,6 +186,19 @@ sub description {
   return $desc;
 }
 
+sub _upgrade_schema {
+  my ($class, %opts) = @_;
+
+  my $sql = '
+    DELETE FROM cust_bill_pkg_discount WHERE NOT EXISTS
+      ( SELECT 1 FROM cust_bill_pkg WHERE cust_bill_pkg.billpkgnum = cust_bill_pkg_discount.billpkgnum )
+  ';
+
+  my $sth = dbh->prepare($sql) or die dbh->errstr;
+  $sth->execute or die $sth->errstr;
+  '';
+}
+
 =back
 
 =head1 BUGS

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

Summary of changes:
 FS/FS/cust_bill_pkg_discount.pm |   14 ++++++++++++++
 1 file changed, 14 insertions(+)




More information about the freeside-commits mailing list