summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-11-18 11:41:35 -0800
committerIvan Kohler <ivan@freeside.biz>2014-11-18 11:41:35 -0800
commit707368aa7db1cecdd05b74c8531249a1e1370823 (patch)
tree83193ff53d64fbfb607f8a87b49ba838986b12f6 /FS
parent6bead8d6f196872b9863aa902341697b43a5b067 (diff)
parent5ed43cea286d5fab10db1cfdc4fa80b99b203ab9 (diff)
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/ClientAPI/MyAccount.pm212
-rw-r--r--FS/FS/Template_Mixin.pm114
-rw-r--r--FS/FS/cdr/cx3.pm9
-rw-r--r--FS/FS/cust_main/Billing.pm4
-rw-r--r--FS/FS/part_export/phone_shellcommands.pm2
-rw-r--r--FS/FS/part_pkg/discount_Mixin.pm49
6 files changed, 236 insertions, 154 deletions
diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index ec114ff09..61082bd9e 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -1716,6 +1716,9 @@ sub list_svcs {
my($context, $session, $custnum) = _custoragent_session_custnum($p);
return { 'error' => $session } if $context eq 'error';
+ my $conf = new FS::Conf;
+
+ my $hide_usage = $conf->exists('selfservice_hide-usage') ? 1 : 0;
my $search = { 'custnum' => $custnum };
$search->{'agentnum'} = $session->{'agentnum'} if $context eq 'agent';
my $cust_main = qsearchs('cust_main', $search )
@@ -1729,7 +1732,6 @@ sub list_svcs {
my @cust_svc = ();
my @cust_pkg_usage = ();
- #foreach my $cust_pkg ( $cust_main->ncancelled_pkgs ) {
foreach my $cust_pkg ( $p->{'ncancelled'}
? $cust_main->ncancelled_pkgs
: $cust_main->unsuspended_pkgs ) {
@@ -1740,14 +1742,16 @@ sub list_svcs {
@cust_svc = grep { $_->part_svc->selfservice_access ne 'hidden' } @cust_svc;
my %usage_pools;
- foreach (@cust_pkg_usage) {
- my $part = $_->part_pkg_usage;
- my $tag = $part->description . ($part->shared ? 1 : 0);
- my $row = $usage_pools{$tag}
- ||= [ $part->description, 0, 0, $part->shared ? 1 : 0 ];
- $row->[1] += sprintf('%.1f', $_->minutes); # minutes remaining
- $row->[2] += $part->minutes; # minutes total
- }
+ if (!$hide_usage) {
+ foreach (@cust_pkg_usage) {
+ my $part = $_->part_pkg_usage;
+ my $tag = $part->description . ($part->shared ? 1 : 0);
+ my $row = $usage_pools{$tag}
+ ||= [ $part->description, 0, 0, $part->shared ? 1 : 0 ];
+ $row->[1] += sprintf('%.1f', $_->minutes); # minutes remaining
+ $row->[2] += $part->minutes; # minutes total
+ }
+ } # otherwise just leave them empty
if ( $p->{'svcdb'} ) {
my $svcdb = ref($p->{'svcdb'}) eq 'HASH'
@@ -1761,108 +1765,110 @@ sub list_svcs {
#@svc_x = sort { $a->domain cmp $b->domain || $a->username cmp $b->username }
# @svc_x;
- my $conf = new FS::Conf;
+ my @svcs; # stuff to return to the client
+ foreach my $cust_svc (@cust_svc) {
+ my $svc_x = $cust_svc->svc_x;
+ my($label, $value) = $cust_svc->label;
+ my $part_svc = $cust_svc->part_svc;
+ my $svcdb = $part_svc->svcdb;
+ my $cust_pkg = $cust_svc->cust_pkg;
+ my $part_pkg = $cust_pkg->part_pkg;
- {
+ my %hash = (
+ 'svcnum' => $cust_svc->svcnum,
+ 'display_svcnum' => $cust_svc->display_svcnum,
+ 'svcdb' => $svcdb,
+ 'label' => $label,
+ 'value' => $value,
+ 'pkg_label' => $cust_pkg->pkg_locale,
+ 'pkg_status' => $cust_pkg->status,
+ 'readonly' => ($part_svc->selfservice_access eq 'readonly'),
+ );
+
+ # would it make sense to put this in a svc_* method?
+
+ if ( $svcdb eq 'svc_acct' ) {
+ foreach (qw(username email finger seconds)) {
+ $hash{$_} = $svc_x->$_;
+ }
+
+ if (!$hide_usage) {
+ %hash = (
+ %hash,
+ 'upbytes' => display_bytecount($svc_x->upbytes),
+ 'downbytes' => display_bytecount($svc_x->downbytes),
+ 'totalbytes' => display_bytecount($svc_x->totalbytes),
+
+ 'recharge_amount' => $part_pkg->option('recharge_amount',1),
+ 'recharge_seconds' => $part_pkg->option('recharge_seconds',1),
+ 'recharge_upbytes' =>
+ display_bytecount($part_pkg->option('recharge_upbytes',1)),
+ 'recharge_downbytes' =>
+ display_bytecount($part_pkg->option('recharge_downbytes',1)),
+ 'recharge_totalbytes' =>
+ display_bytecount($part_pkg->option('recharge_totalbytes',1)),
+ # more...
+ );
+ }
+
+ } elsif ( $svcdb eq 'svc_dsl' ) {
+
+ $hash{'phonenum'} = $svc_x->phonenum;
+ if ( $svc_x->first || $svc_x->get('last') || $svc_x->company ) {
+ $hash{'name'} = $svc_x->first. ' '. $svc_x->get('last');
+ $hash{'name'} = $svc_x->company. ' ('. $hash{'name'}. ')'
+ if $svc_x->company;
+ } else {
+ $hash{'name'} = $cust_main->name;
+ }
+ # no usage to hide here
+
+ } elsif ( $svcdb eq 'svc_phone' ) {
+ if (!$hide_usage) {
+ # could potentially show lots of things...
+ $hash{'outbound'} = 1;
+ $hash{'inbound'} = 0;
+ if ( $part_pkg->plan eq 'voip_inbound' ) {
+ $hash{'outbound'} = 0;
+ $hash{'inbound'} = 1;
+ } elsif ( $part_pkg->option('selfservice_inbound_format')
+ or $conf->config('selfservice-default_inbound_cdr_format')
+ ) {
+ $hash{'inbound'} = 1;
+ }
+ foreach (qw(inbound outbound)) {
+ # hmm...we can't filter by status here, because there might
+ # not be cdr_terminations at all. have to go by date.
+ # find all since the last bill date.
+ # XXX cdr types? we are going to need them.
+ if ( $hash{$_} ) {
+ my $sum_cdr = $svc_x->sum_cdrs(
+ 'inbound' => ( $_ eq 'inbound' ? 1 : 0 ),
+ 'begin' => ($cust_pkg->last_bill || 0),
+ 'nonzero' => 1,
+ 'disable_charged_party' => 1,
+ );
+ $hash{$_} = $sum_cdr->hashref;
+ }
+ }
+ } # not hiding usage
+ } # svcdb
+
+ push @svcs, \%hash;
+ } # foreach $cust_svc
+
+ return {
'svcnum' => $session->{'svcnum'},
'custnum' => $custnum,
'date_format' => $conf->config('date_format') || '%m/%d/%Y',
'view_usage_nodomain' => $conf->exists('selfservice-view_usage_nodomain'),
- 'svcs' => [
- map {
- my $svc_x = $_->svc_x;
- my($label, $value) = $_->label;
- my $part_svc = $_->part_svc;
- my $svcdb = $part_svc->svcdb;
- my $cust_pkg = $_->cust_pkg;
- my $part_pkg = $cust_pkg->part_pkg;
-
- my %hash = (
- 'svcnum' => $_->svcnum,
- 'display_svcnum' => $_->display_svcnum,
- 'svcdb' => $svcdb,
- 'label' => $label,
- 'value' => $value,
- 'pkg_label' => $cust_pkg->pkg_locale,
- 'pkg_status' => $cust_pkg->status,
- 'readonly' => ($part_svc->selfservice_access eq 'readonly'),
- );
-
- if ( $svcdb eq 'svc_acct' ) {
- %hash = (
- %hash,
- 'username' => $svc_x->username,
- 'email' => $svc_x->email,
- 'finger' => $svc_x->finger,
- 'seconds' => $svc_x->seconds,
- 'upbytes' => display_bytecount($svc_x->upbytes),
- 'downbytes' => display_bytecount($svc_x->downbytes),
- 'totalbytes' => display_bytecount($svc_x->totalbytes),
-
- 'recharge_amount' => $part_pkg->option('recharge_amount',1),
- 'recharge_seconds' => $part_pkg->option('recharge_seconds',1),
- 'recharge_upbytes' =>
- display_bytecount($part_pkg->option('recharge_upbytes',1)),
- 'recharge_downbytes' =>
- display_bytecount($part_pkg->option('recharge_downbytes',1)),
- 'recharge_totalbytes' =>
- display_bytecount($part_pkg->option('recharge_totalbytes',1)),
- # more...
- );
-
- } elsif ( $svcdb eq 'svc_dsl' ) {
- $hash{'phonenum'} = $svc_x->phonenum;
- if ( $svc_x->first || $svc_x->get('last') || $svc_x->company ) {
- $hash{'name'} = $svc_x->first. ' '. $svc_x->get('last');
- $hash{'name'} = $svc_x->company. ' ('. $hash{'name'}. ')'
- if $svc_x->company;
- } else {
- $hash{'name'} = $cust_main->name;
- }
- } elsif ( $svcdb eq 'svc_phone' ) {
- # could potentially show lots of things...
- $hash{'outbound'} = 1;
- $hash{'inbound'} = 0;
- if ( $part_pkg->plan eq 'voip_inbound' ) {
- $hash{'outbound'} = 0;
- $hash{'inbound'} = 1;
- } elsif ( $part_pkg->option('selfservice_inbound_format')
- or $conf->config('selfservice-default_inbound_cdr_format')
- ) {
- $hash{'inbound'} = 1;
- }
- foreach (qw(inbound outbound)) {
- # hmm...we can't filter by status here, because there might
- # not be cdr_terminations at all. have to go by date.
- # find all since the last bill date.
- # XXX cdr types? we are going to need them.
- if ( $hash{$_} ) {
- my $sum_cdr = $svc_x->sum_cdrs(
- 'inbound' => ( $_ eq 'inbound' ? 1 : 0 ),
- 'begin' => ($cust_pkg->last_bill || 0),
- 'nonzero' => 1,
- 'disable_charged_party' => 1,
- );
- $hash{$_} = $sum_cdr->hashref;
- }
- }
- }
-
- # elsif ( $svcdb eq 'svc_phone' || $svcdb eq 'svc_port' ) {
- # %hash = (
- # %hash,
- # );
- #}
-
- \%hash;
- }
- @cust_svc
- ],
+ 'svcs' => \@svcs,
'usage_pools' => [
map { $usage_pools{$_} }
sort { $a cmp $b }
keys %usage_pools
],
+ 'hide_usage' => $hide_usage,
};
}
@@ -2144,6 +2150,10 @@ sub _usage_details {
my($callback, $p, %opt) = @_;
my $conf = FS::Conf->new;
+ if ( $conf->exists('selfservice_hide-usage') ) {
+ return { 'error' => 'Viewing usage is not allowed.' };
+ }
+
my($context, $session, $custnum) = _custoragent_session_custnum($p);
return { 'error' => $session } if $context eq 'error';
diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index f70ac3ce2..0928ee52f 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -344,13 +344,13 @@ sub print_generic {
my @invoice_template = map "$_\n", $conf->config($templatefile)
or die "cannot load config data $templatefile";
- my $old_latex = '';
if ( $format eq 'latex' && grep { /^%%Detail/ } @invoice_template ) {
#change this to a die when the old code is removed
- warn "old-style invoice template $templatefile; ".
+ # it's been almost ten years, changing it to a die.
+ die "old-style invoice template $templatefile; ".
"patch with conf/invoice_latex.diff or use new conf/invoice_latex*\n";
- $old_latex = 'true';
- @invoice_template = _translate_old_latex_format(@invoice_template);
+ #$old_latex = 'true';
+ #@invoice_template = _translate_old_latex_format(@invoice_template);
}
warn "$me print_generic creating T:T object\n"
@@ -880,6 +880,7 @@ sub print_generic {
);
my $money_char = $money_chars{$format};
+ # extremely dubious
my %other_money_chars = ( 'latex' => '\dollar ',#XXX should be a config too
'html' => $conf->config('money_char') || '$',
'template' => '',
@@ -1091,8 +1092,7 @@ sub print_generic {
ext_description => [ map { &$escape_function($_) }
@{ $line_item->{'ext_description'} || [] }
],
- amount => ( $old_latex ? '' : $money_char).
- $line_item->{'amount'},
+ amount => $money_char . $line_item->{'amount'},
product_code => $line_item->{'pkgpart'} || 'N/A',
};
@@ -1178,8 +1178,9 @@ sub print_generic {
$line_item->{'product_code'} = $line_item->{'pkgpart'} || 'N/A'; # mt()?
$line_item->{'section'} = $section;
$line_item->{'description'} = &$escape_function($line_item->{'description'});
- if (!$old_latex) { # dubious; templates should provide this
- $line_item->{'amount'} = $money_char.$line_item->{'amount'};
+ $line_item->{'amount'} = $money_char.$line_item->{'amount'};
+
+ if ( length($line_item->{'unit_amount'}) ) {
$line_item->{'unit_amount'} = $money_char.$line_item->{'unit_amount'};
}
$line_item->{'ext_description'} ||= [];
@@ -1226,13 +1227,12 @@ sub print_generic {
if ( $multisection ) {
- my $money = $old_latex ? '' : $money_char;
push @detail_items, {
ext_description => [],
ref => '',
quantity => '',
description => $description,
- amount => $money. $amount,
+ amount => $money_char. $amount,
product_code => '',
section => $tax_section,
};
@@ -1360,13 +1360,12 @@ sub print_generic {
$total->{'total_amount'} = $minus.$other_money_char.$credit->{'amount'};
$adjusttotal += $credit->{'amount'};
if ( $multisection ) {
- my $money = $old_latex ? '' : $money_char;
push @detail_items, {
ext_description => [],
ref => '',
quantity => '',
description => &$escape_function($credit->{'description'}),
- amount => $money. $credit->{'amount'},
+ amount => $money_char . $credit->{'amount'},
product_code => '',
section => $adjust_section,
};
@@ -1395,13 +1394,12 @@ sub print_generic {
$total->{'total_amount'} = $minus.$other_money_char.$payment->{'amount'};
$adjusttotal += $payment->{'amount'};
if ( $multisection ) {
- my $money = $old_latex ? '' : $money_char;
push @detail_items, {
ext_description => [],
ref => '',
quantity => '',
description => &$escape_function($payment->{'description'}),
- amount => $money. $payment->{'amount'},
+ amount => $money_char . $payment->{'amount'},
product_code => '',
section => $adjust_section,
};
@@ -2635,16 +2633,21 @@ sub _items_cust_bill_pkg {
my $cust_main = $self->cust_main;#for per-agent cust_bill-line_item-ate_style
# and location labels
- my @b = ();
- my ($s, $r, $u) = ( undef, undef, undef );
+ my @b = (); # accumulator for the line item hashes that we'll return
+ my ($s, $r, $u, $d) = ( undef, undef, undef );
+ # the 'current' line item hashes for setup, recur, usage, discount
foreach my $cust_bill_pkg ( @$cust_bill_pkgs )
{
-
- foreach ( $s, $r, ($opt{skip_usage} ? () : $u ) ) {
+ # if the current line item is waiting to go out, and the one we're about
+ # to start is not bundled, then push out the current one and start a new
+ # one.
+ foreach ( $s, $r, ($opt{skip_usage} ? () : $u ) , $d ) {
if ( $_ && !$cust_bill_pkg->hidden ) {
- $_->{amount} = sprintf( "%.2f", $_->{amount} ),
+ $_->{amount} = sprintf( "%.2f", $_->{amount} );
$_->{amount} =~ s/^\-0\.00$/0.00/;
- $_->{unit_amount} = sprintf( "%.2f", $_->{unit_amount} ),
+ if (exists($_->{unit_amount})) {
+ $_->{unit_amount} = sprintf( "%.2f", $_->{unit_amount} );
+ }
push @b, { %$_ }
if $_->{amount} != 0
|| $discount_show_always
@@ -2715,6 +2718,7 @@ sub _items_cust_bill_pkg {
# quotation_pkgs are never fees, so don't worry about the case where
# part_pkg is undefined
+ # and I guess they're never bundled either?
if ( $cust_bill_pkg->setup != 0 ) {
my $description = $desc;
$description .= ' Setup'
@@ -2739,7 +2743,8 @@ sub _items_cust_bill_pkg {
};
}
- } elsif ( $cust_bill_pkg->pkgnum > 0 ) { # and it's not a quotation_pkg
+ } elsif ( $cust_bill_pkg->pkgnum > 0 ) {
+ # a "normal" package line item (not a quotation, not a fee, not a tax)
warn "$me _items_cust_bill_pkg cust_bill_pkg is non-tax\n"
if $DEBUG > 1;
@@ -3018,6 +3023,66 @@ sub _items_cust_bill_pkg {
} # recurring or usage with recurring charge
+ # decide whether to show active discounts here
+ if (
+ # case 1: we are showing a single line for the package
+ ( !$type )
+ # case 2: we are showing a setup line for a package that has
+ # no base recurring fee
+ or ( $type eq 'S' and $cust_bill_pkg->unitrecur == 0 )
+ # case 3: we are showing a recur line for a package that has
+ # a base recurring fee
+ or ( $type eq 'R' and $cust_bill_pkg->unitrecur > 0 )
+ ) {
+
+ my @discounts = $cust_bill_pkg->cust_bill_pkg_discount;
+ # special case: if there are old "discount details" on this line
+ # item, don't show discount line items
+ if ( FS::cust_bill_pkg_detail->count(
+ "detail LIKE 'Includes discount%' AND billpkgnum = " .
+ $cust_bill_pkg->billpkgnum
+ ) > 0 ) {
+ @discounts = ();
+ }
+ if( @discounts ) {
+ warn "$me _items_cust_bill_pkg including discounts for ".
+ $cust_bill_pkg->billpkgnum."\n"
+ if $DEBUG;
+ my $discount_amount = sum( map {$_->amount} @discounts );
+ my $orig_amount = $cust_bill_pkg->setup + $cust_bill_pkg->recur
+ + $discount_amount;
+ # if multiple discounts apply to the same package, how to display
+ # them? ext_description lines, apparently
+ if ( $d and $cust_bill_pkg->hidden ) {
+ $d->{amount} += $discount_amount;
+ $d->{orig_amount} += $orig_amount;
+ } else {
+ my @ext;
+ # make a placeholder for the original price, if necessary
+ # (if unit prices are enabled, it won't be necessary)
+ push @ext, '' if !$conf->exists('invoice-unitprice');
+ $d = {
+ _is_discount => 1,
+ description => $self->mt('Discount included'),
+ amount => $discount_amount,
+ orig_amount => $orig_amount,
+ ext_description => \@ext,
+ };
+ foreach my $cust_bill_pkg_discount (@discounts) {
+ my $def = $cust_bill_pkg_discount->cust_pkg_discount->discount;
+ push @ext, &{$escape_function}( $def->description );
+ }
+ }
+
+ # update the placeholder to show the original price in the
+ # first ext_description line
+ if ( !$conf->exists('invoice-unitprice') ) {
+ $d->{ext_description}->[0] =
+ sprintf('Original price: %.2f', $d->{orig_amount});
+ }
+ } # if there are any discounts
+ } # if this is an appropriate place to show discounts
+
} else { # taxes and fees
warn "$me _items_cust_bill_pkg cust_bill_pkg is tax\n"
@@ -3039,13 +3104,14 @@ sub _items_cust_bill_pkg {
}
- foreach ( $s, $r, ($opt{skip_usage} ? () : $u ) ) {
+ foreach ( $s, $r, ($opt{skip_usage} ? () : $u, $d ) ) {
if ( $_ ) {
$_->{amount} = sprintf( "%.2f", $_->{amount} ),
if exists($_->{amount});
$_->{amount} =~ s/^\-0\.00$/0.00/;
- $_->{unit_amount} = sprintf('%.2f', $_->{unit_amount})
- if exists($_->{unit_amount});
+ if (exists($_->{unit_amount})) {
+ $_->{unit_amount} = sprintf( "%.2f", $_->{unit_amount} );
+ }
push @b, { %$_ }
if $_->{amount} != 0
diff --git a/FS/FS/cdr/cx3.pm b/FS/FS/cdr/cx3.pm
index bc511d966..e5b5f0350 100644
--- a/FS/FS/cdr/cx3.pm
+++ b/FS/FS/cdr/cx3.pm
@@ -16,18 +16,17 @@ use Date::Parse;
sub {
my ($cdr, $data, $conf, $param) = @_;
- $param->{skiprow} = 1 if $data ne 'CallDetail 0'; # skip non-detail records
+ $param->{skiprow} = 1 unless $data =~ 'CallDetail'; # skip non-detail records
}, # record type
- 'uniqueid', # unique id
- skip(1), # unknown
+ skip(2), # unknown, callid ( not unique )
'src', # source
'dst', # destination
sub { my ($cdr, $calldate, $param) = @_;
- if ($calldate =~ /^(\d{4})-(\d{2})-(\d{2})\s*(\d{2}):(\d{2}):(\d{2})$/){
+ if ($calldate =~ /^(\d{2})\/(\d{2})\/(\d{4})\s*(\d{2}):(\d{2}):(\d{2})$/){
$cdr->set('calldate', $calldate);
- my $tmp_date = "$2/$3/$1 $4:$5:$6";
+ my $tmp_date = "$2/$1/$3 $4:$5:$6";
$tmp_date = str2time($tmp_date);
$cdr->set('startdate', $tmp_date);
diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm
index f65d495cf..9e2082fc3 100644
--- a/FS/FS/cust_main/Billing.pm
+++ b/FS/FS/cust_main/Billing.pm
@@ -946,7 +946,9 @@ sub _make_lines {
my $setup = 0;
my $unitsetup = 0;
my @setup_discounts = ();
- my %setup_param = ( 'discounts' => \@setup_discounts );
+ my %setup_param = ( 'discounts' => \@setup_discounts,
+ 'real_pkgpart' => $params{real_pkgpart}
+ );
my $setup_billed_currency = '';
my $setup_billed_amount = 0;
# Conditions for setting setup date and charging the setup fee:
diff --git a/FS/FS/part_export/phone_shellcommands.pm b/FS/FS/part_export/phone_shellcommands.pm
index 593b14e47..71445bf27 100644
--- a/FS/FS/part_export/phone_shellcommands.pm
+++ b/FS/FS/part_export/phone_shellcommands.pm
@@ -53,6 +53,7 @@ old_ for replace operations):
<LI><code>$cust_name</code> - Customer name (quoted for the shell)
<LI><code>$pkgnum</code> - Internal package number
<LI><code>$custnum</code> - Internal customer number
+ <LI><code>$phone_name</code> - Phone name (quoted for the shell)
<LI><code>$mac_addr</code> - MAC address (Device MAC address insert and delete commands only)
<LI><code>$devicename</code> - Device type (Device type insert and delete commands only)
</UL>
@@ -115,6 +116,7 @@ sub _export_command {
my $cust_name = $cust_pkg ? $cust_pkg->cust_main->name : '';
$cust_name = shell_quote $cust_name;
my $sip_password = shell_quote $svc_phone->sip_password;
+ my $phone_name = shell_quote $svc_phone->phone_name;
#done setting variables for the command
$self->shellcommands_queue( $svc_phone->svcnum,
diff --git a/FS/FS/part_pkg/discount_Mixin.pm b/FS/FS/part_pkg/discount_Mixin.pm
index be0200c77..31802758c 100644
--- a/FS/FS/part_pkg/discount_Mixin.pm
+++ b/FS/FS/part_pkg/discount_Mixin.pm
@@ -32,7 +32,7 @@ sub calc_recur {
Takes all the arguments of calc_recur. Calculates and returns the amount
by which to reduce the recurring fee; also increments months used on the
-discount and generates an invoice detail describing it.
+discount.
=cut
@@ -162,31 +162,34 @@ sub calc_discount {
'months' => $months,
};
push @{ $param->{'discounts'} }, $cust_bill_pkg_discount;
+ $tot_discount += $amount;
#add details on discount to invoice
- my $money_char = $conf->config('money_char') || '$';
- $months = sprintf('%.2f', $months) if $months =~ /\./;
-
- my $d = 'Includes ';
- my $format;
-
- if ( $months eq '1' ) {
- $d .= "discount of $money_char$amount";
- $d .= " each" if $cust_pkg->quantity > 1;
- $format = 'Undiscounted amount: %s%.2f';
- } else {
- $d .= 'setup ' if defined $param->{'setup_charge'};
- $d .= 'discount of '. $discount->description_short;
- $d .= " for $months months"
- unless defined $param->{'setup_charge'};
- $d .= ": $money_char$amount" if $discount->percent;
- $format = 'Undiscounted monthly amount: %s%.2f';
- }
+ # no longer! this is now done during rendering based on the existence
+ # of the cust_bill_pkg_discount record
+ #
+ #my $money_char = $conf->config('money_char') || '$';
+ #$months = sprintf('%.2f', $months) if $months =~ /\./;
+
+ #my $d = 'Includes ';
+ #my $format;
+
+ #if ( $months eq '1' ) {
+ # $d .= "discount of $money_char$amount";
+ # $d .= " each" if $cust_pkg->quantity > 1;
+ # $format = 'Undiscounted amount: %s%.2f';
+ #} else {
+ # $d .= 'setup ' if defined $param->{'setup_charge'};
+ # $d .= 'discount of '. $discount->description_short;
+ # $d .= " for $months months"
+ # unless defined $param->{'setup_charge'};
+ # $d .= ": $money_char$amount" if $discount->percent;
+ # $format = 'Undiscounted monthly amount: %s%.2f';
+ #}
+
+ #push @$details, $d;
+ #push @$details, sprintf( $format, $money_char, $br );
- push @$details, $d;
- push @$details, sprintf( $format, $money_char, $br );
-
- $tot_discount += $amount;
}
sprintf('%.2f', $tot_discount);