[freeside-commits] branch FREESIDE_4_BRANCH updated. 3671ac4f46054ab39aded867ec3e5d2732bdb6c3
Ivan Kohler
ivan at freeside.biz
Wed Feb 27 21:17:08 PST 2019
The branch, FREESIDE_4_BRANCH has been updated
via 3671ac4f46054ab39aded867ec3e5d2732bdb6c3 (commit)
from c0fe809ef451d5d862dd1c8aea1b15ccf34863ba (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 3671ac4f46054ab39aded867ec3e5d2732bdb6c3
Author: Ivan Kohler <ivan at freeside.biz>
Date: Wed Feb 27 21:17:06 2019 -0800
add classnum exclusion and setup/recur fee multiplication, RT#82943
diff --git a/bin/part_pkg-bulk_change b/bin/part_pkg-bulk_change
index 24cf18915..176965baf 100755
--- a/bin/part_pkg-bulk_change
+++ b/bin/part_pkg-bulk_change
@@ -1,14 +1,14 @@
#!/usr/bin/perl
use strict;
-use vars qw( $opt_r $opt_m $opt_p $opt_o $opt_v $opt_t $opt_s $opt_S $opt_z $opt_Z );
+use vars qw( $opt_r $opt_m $opt_C $opt_p $opt_o $opt_v $opt_t $opt_s $opt_S $opt_z $opt_Z $opt_e $opt_u );
use Getopt::Std;
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearch qsearchs);
use FS::part_pkg;
use FS::part_pkg_option;
-getopts('rm:p:o:v:t:sSzZ');
+getopts('rm:C:p:o:v:t:sSzZe:u:');
my $user = shift or &usage;
adminsuidsetup $user;
@@ -16,6 +16,7 @@ adminsuidsetup $user;
my %search = ();
$search{'plan'} = $opt_p if $opt_p;
$search{'comment'} = $opt_m if $opt_m;
+$search{'classnum'} = { op=>'NOT IN', value=>"($opt_C)" } if $opt_C;
foreach my $part_pkg ( qsearch('part_pkg',\%search) ) {
next if ! $part_pkg->freq && $opt_r;
@@ -44,6 +45,40 @@ foreach my $part_pkg ( qsearch('part_pkg',\%search) ) {
}
+ if ( $opt_e ) {
+ my %hash = (
+ 'pkgpart' => $part_pkg->pkgpart,
+ 'optionname' => 'setup_fee',
+ );
+
+ my $part_pkg_option = qsearchs('part_pkg_option', \%hash);
+
+ if ( $part_pkg_option ) {
+ $part_pkg_option->optionvalue(
+ sprintf('%.2f', $part_pkg_option->optionvalue * $opt_e)
+ );
+ my $error = $part_pkg_option->replace;
+ die $error if $error;
+ }
+ }
+
+ if ( $opt_u ) {
+ my %hash = (
+ 'pkgpart' => $part_pkg->pkgpart,
+ 'optionname' => 'recur_fee',
+ );
+
+ my $part_pkg_option = qsearchs('part_pkg_option', \%hash);
+
+ if ( $part_pkg_option ) {
+ $part_pkg_option->optionvalue(
+ sprintf('%.2f', $part_pkg_option->optionvalue * $opt_u)
+ );
+ my $error = $part_pkg_option->replace;
+ die $error if $error;
+ }
+ }
+
if ( $opt_t || $opt_s || $opt_S || $opt_z || $opt_Z ) {
$part_pkg->taxclass($opt_t) if $opt_t;
@@ -59,7 +94,7 @@ foreach my $part_pkg ( qsearch('part_pkg',\%search) ) {
}
sub usage {
- die "usage: part_pkg-bulk_change [ -r ] [ -p plan ] [ -m comment ] [ -o option_name -v option_value ] [ -t new_taxclass ] [ -s | -S ] [ -z | -Z ] employee_username\n";
+ die "usage: part_pkg-bulk_change [ -r ] [ -p plan ] [ -m comment ] [ -C classnum,classnum ] [ -o option_name -v option_value ] [ -t new_taxclass ] [ -s | -S ] [ -z | -Z ] [ -e multiplier ] [ -u multiplier ] employee_username\n";
}
=head1 NAME
@@ -68,7 +103,7 @@ cust_main-bulk_change
=head1 SYNOPSIS
- part_pkg-bulk_change [ -r ] [ -p plan ] [ -m comment ] [ -o option_name -v option_value ] [ -t new_taxclass ] [ -s | -S ] [ -z | -Z ] employee_username
+ part_pkg-bulk_change [ -r ] [ -p plan ] [ -m comment ] [ -C classnum,classnum ] [ -o option_name -v option_value ] [ -t new_taxclass ] [ -s | -S ] [ -z | -Z ] [ -e multiplier ] [ -u multiplier ] employee_username
=head1 DESCRIPTION
@@ -82,6 +117,8 @@ Search options:
-m: packages with this comment only
+-C: excluding package classnum or classnums (comma-separated list)
+
Change options:
-o: part_pkg_option optionname
@@ -98,6 +135,10 @@ Change options:
-Z: Turn on "Show zero recurring"
+-e: Multiply setup fee by this value (i.e. 1.05 for a 5% price increase)
+
+-u: Multiply recurring fee by this value (i.e. 1.05 for a 5% price increase)
+
employee_username
=head1 BUGS
-----------------------------------------------------------------------
Summary of changes:
bin/part_pkg-bulk_change | 49 ++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 45 insertions(+), 4 deletions(-)
More information about the freeside-commits
mailing list