[freeside-commits] branch FREESIDE_3_BRANCH updated. 3d7fbe317c6a3e4b130533ff0465ba8b4323204c
Mark Wells
mark at 420.am
Mon Dec 12 17:33:34 PST 2016
The branch, FREESIDE_3_BRANCH has been updated
via 3d7fbe317c6a3e4b130533ff0465ba8b4323204c (commit)
from d16d6fd5dea52c5b48abe6a3ccf44fd69645a875 (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 3d7fbe317c6a3e4b130533ff0465ba8b4323204c
Author: Mark Wells <mark at freeside.biz>
Date: Mon Dec 12 17:09:47 2016 -0800
prevent package defs from being cloned unnecessarily, #73687
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index a166d40..b2e6400 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -2973,7 +2973,7 @@ sub modify_charge {
$pkg_opt_modified = 1;
}
}
- $pkg_opt_modified = 1 if (scalar(@old_additional) - 1) != $i;
+ $pkg_opt_modified = 1 if scalar(@old_additional) != $i;
$pkg_opt{'additional_count'} = $i if $i > 0;
my $old_classnum;
@@ -3126,8 +3126,6 @@ sub modify_charge {
'';
}
-
-
use Storable 'thaw';
use MIME::Base64;
use Data::Dumper;
diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm
index 498daf6..5f7c831 100644
--- a/FS/FS/part_pkg.pm
+++ b/FS/FS/part_pkg.pm
@@ -355,11 +355,11 @@ can be set to a hashref of svcparts and flag values ('Y' or '') to set the
to a hashref of svcparts and flag values ('Y' or '') to set the field
in those records.
-If I<primary_svc> is set to the svcpart of the primary service, the appropriate
-FS::pkg_svc record will be updated.
+If I<primary_svc> is set to the svcpart of the primary service, the
+appropriate FS::pkg_svc record will be updated.
-If I<options> is set to a hashref, the appropriate FS::part_pkg_option records
-will be replaced.
+If I<options> is set to a hashref, the appropriate FS::part_pkg_option
+records will be replaced.
=cut
@@ -1985,6 +1985,55 @@ sub queueable_upgrade {
FS::upgrade_journal->set_done($upgrade);
}
+ # remove custom flag from one-time charge packages that were accidentally
+ # flagged as custom
+ $search = FS::Cursor->new({
+ 'table' => 'part_pkg',
+ 'hashref' => { 'freq' => '0',
+ 'custom' => 'Y',
+ 'family_pkgpart' => { op => '!=', value => '' },
+ },
+ 'addl_from' => ' JOIN
+ (select pkgpart from cust_pkg group by pkgpart having count(*) = 1)
+ AS singular_pkg USING (pkgpart)',
+ });
+ my @fields = grep { $_ ne 'pkgpart'
+ and $_ ne 'custom'
+ and $_ ne 'disabled' } FS::part_pkg->fields;
+ PKGPART: while (my $part_pkg = $search->fetch) {
+ # can't merge the package back into its parent (too late for that)
+ # but we can remove the custom flag if it's not actually customized,
+ # i.e. nothing has been changed.
+
+ my $family_pkgpart = $part_pkg->family_pkgpart;
+ next PKGPART if $family_pkgpart == $part_pkg->pkgpart;
+ my $parent_pkg = FS::part_pkg->by_key($family_pkgpart);
+ foreach my $field (@fields) {
+ if ($part_pkg->get($field) ne $parent_pkg->get($field)) {
+ next PKGPART;
+ }
+ }
+ # options have to be identical too
+ # but links, FCC options, discount plans, and usage packages can't be
+ # changed through the "modify charge" UI, so skip them
+ my %newopt = $part_pkg->options;
+ my %oldopt = $parent_pkg->options;
+ OPTION: foreach my $option (keys %newopt) {
+ if (delete $newopt{$option} ne delete $oldopt{$option}) {
+ next PKGPART;
+ }
+ }
+ if (keys(%newopt) or keys(%oldopt)) {
+ next PKGPART;
+ }
+ # okay, now replace it
+ warn "Removing custom flag from part_pkg#".$part_pkg->pkgpart."\n";
+ $part_pkg->set('custom', '');
+ my $error = $part_pkg->replace;
+ die $error if $error;
+ } # $search->fetch
+
+ return;
}
=item curuser_pkgs_sql
-----------------------------------------------------------------------
Summary of changes:
FS/FS/cust_pkg.pm | 4 +---
FS/FS/part_pkg.pm | 57 +++++++++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 54 insertions(+), 7 deletions(-)
More information about the freeside-commits
mailing list