diff options
author | Ivan Kohler <ivan@freeside.biz> | 2014-02-05 22:41:22 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2014-02-05 22:41:22 -0800 |
commit | 9b3e40ffd129991d4567a3439eb2060c64cfa885 (patch) | |
tree | 1b56c6f4b9ab3d0f2356b3c22c97ac060e960323 | |
parent | e1e55ec2b39c6db45e4501165f42616eb2454459 (diff) | |
parent | 145b39e411aacaf495e0c33ff78a7e87b3f18e72 (diff) |
Merge branch 'master' of git.freeside.biz:/home/git/freeside
-rw-r--r-- | FS/FS/Conf.pm | 7 | ||||
-rw-r--r-- | FS/FS/TemplateItem_Mixin.pm | 2 | ||||
-rw-r--r-- | FS/FS/Template_Mixin.pm | 32 | ||||
-rw-r--r-- | FS/FS/cust_main_Mixin.pm | 44 | ||||
-rw-r--r-- | FS/FS/part_pkg/voip_cdr.pm | 8 | ||||
-rw-r--r-- | httemplate/elements/select-terms.html | 3 |
6 files changed, 75 insertions, 21 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 415b90a78..d8c29f364 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1531,8 +1531,11 @@ and customer address. Include units.', 'section' => 'invoicing', 'description' => 'Optional default invoice term, used to calculate a due date printed on invoices.', 'type' => 'select', - 'select_enum' => [ '', 'Payable upon receipt', 'Net 0', 'Net 3', 'Net 9', 'Net 10', 'Net 15', 'Net 18', 'Net 20', 'Net 21', 'Net 30', 'Net 45', 'Net 60', 'Net 90' ], - }, + 'select_enum' => [ + '', 'Payable upon receipt', 'Net 0', 'Net 3', 'Net 9', 'Net 10', + 'Net 15', 'Net 18', 'Net 20', 'Net 21', 'Net 25', 'Net 30', 'Net 45', + 'Net 60', 'Net 90' + ], }, { 'key' => 'invoice_show_prior_due_date', diff --git a/FS/FS/TemplateItem_Mixin.pm b/FS/FS/TemplateItem_Mixin.pm index 66ccfb55d..569d98c2f 100644 --- a/FS/FS/TemplateItem_Mixin.pm +++ b/FS/FS/TemplateItem_Mixin.pm @@ -48,7 +48,7 @@ sub part_pkg { } -=item desc +=item desc LOCALE Returns a description for this line item. For typical line items, this is the I<pkg> field of the corresponding B<FS::part_pkg> object (see L<FS::part_pkg>). diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index 00151ae26..c4c2d7fb0 100644 --- a/FS/FS/Template_Mixin.pm +++ b/FS/FS/Template_Mixin.pm @@ -936,7 +936,7 @@ sub print_generic { my $detail = { ref => $line_item->{'pkgnum'}, pkgpart => $line_item->{'pkgpart'}, - quantity => 1, + #quantity => 1, # not really correct section => $previous_section, # which might be $default_section description => &$escape_function($line_item->{'description'}), ext_description => [ map { &$escape_function($_) } @@ -2576,7 +2576,8 @@ sub _items_cust_bill_pkg { my $is_summary = $display->summary; my $description = $desc; - if ( $type eq 'U' and ($is_summary or $cust_bill_pkg->hidden) ) { + if ( $type eq 'U' and defined($r) ) { + # don't just show the same description as the recur line $description = $self->mt('Usage charges'); } @@ -2596,10 +2597,19 @@ sub _items_cust_bill_pkg { push @dates, $prev->sdate if $prev; push @dates, undef if !$prev; + # show service labels, unless... + # the package is set not to display them unless ( $part_pkg->hide_svc_detail + # or this is a tax-like line item || $cust_bill_pkg->itemdesc + # or this is a hidden (bundled) line item || $cust_bill_pkg->hidden + # or this is a usage summary line || $is_summary && $type && $type eq 'U' + # or this is a usage line and there's a recurring line + # for the package in the same section (which will + # have service labels already) + || ($type eq 'U' and defined($r)) ) { @@ -2647,7 +2657,7 @@ sub _items_cust_bill_pkg { } } #if svc_acct-usage_seconds - } + } # if we are showing service labels unless ( $is_summary ) { warn "$me _items_cust_bill_pkg adding details\n" @@ -2673,15 +2683,15 @@ sub _items_cust_bill_pkg { $amount = $cust_bill_pkg->usage; } - my $unit_amount = - ( $cust_bill_pkg->unitrecur > 0 ) ? $cust_bill_pkg->unitrecur - : $amount; - if ( !$type || $type eq 'R' ) { warn "$me _items_cust_bill_pkg adding recur\n" if $DEBUG > 1; + my $unit_amount = + ( $cust_bill_pkg->unitrecur > 0 ) ? $cust_bill_pkg->unitrecur + : $amount; + if ( $cust_bill_pkg->hidden ) { $r->{amount} += $amount; $r->{unit_amount} += $unit_amount; @@ -2712,7 +2722,6 @@ sub _items_cust_bill_pkg { # line for the bundle, add this package's total amount and # usage details to it $u->{amount} += $amount; - $u->{unit_amount} += $unit_amount, push @{ $u->{ext_description} }, @d; } elsif ( $amount ) { # create a new usage line @@ -2722,8 +2731,6 @@ sub _items_cust_bill_pkg { pkgnum => $cust_bill_pkg->pkgnum, amount => $amount, recur_show_zero => $cust_bill_pkg->recur_show_zero, - unit_amount => $unit_amount, - quantity => $cust_bill_pkg->quantity, %item_dates, ext_description => \@d, }; @@ -2764,8 +2771,11 @@ sub _items_cust_bill_pkg { foreach ( $s, $r, ($opt{skip_usage} ? () : $u ) ) { if ( $_ ) { $_->{amount} = sprintf( "%.2f", $_->{amount} ), + if exists($_->{amount}); $_->{amount} =~ s/^\-0\.00$/0.00/; - $_->{unit_amount} = sprintf( "%.2f", $_->{unit_amount} ), + $_->{unit_amount} = sprintf('%.2f', $_->{unit_amount}) + if exists($_->{unit_amount}); + push @b, { %$_ } if $_->{amount} != 0 || $discount_show_always diff --git a/FS/FS/cust_main_Mixin.pm b/FS/FS/cust_main_Mixin.pm index 92dea2840..769b049db 100644 --- a/FS/FS/cust_main_Mixin.pm +++ b/FS/FS/cust_main_Mixin.pm @@ -7,6 +7,7 @@ use FS::UID qw(dbh); use FS::cust_main; use FS::Record qw( qsearch qsearchs ); use FS::Misc qw( send_email generate_email ); +use HTML::Entities; $DEBUG = 0; $me = '[FS::cust_main_Mixin]'; @@ -582,16 +583,31 @@ sub mt { return $lh->maketext(@_); } -=item time2str_local FORMAT, TIME +=item time2str_local FORMAT, TIME[, ESCAPE] Localizes a date (see L<Date::Language>) for the customer's locale. +FORMAT can be a L<Date::Format> string, or one of these special words: + +- "short": the value of the "date_format" config setting for the customer's + locale, defaulting to "%x". +- "rdate": the same as "short" except that the default has a four-digit year. +- "long": the value of the "date_format_long" config setting for the + customer's locale, defaulting to "%b %o, %Y". + +ESCAPE, if specified, is one of "latex" or "html", and will escape non-ASCII +characters and convert spaces to nonbreaking spaces. + =cut sub time2str_local { # renamed so that we don't have to change every single reference to # time2str everywhere my $self = shift; + my ($format, $time, $escape) = @_; + return '' unless $time > 0; # work around time2str's traditional stupidity + + $self->{_date_format} ||= {}; if (!exists($self->{_dh})) { my $cust_main = $self->cust_main; my $locale = $cust_main->locale if $cust_main; @@ -601,7 +617,31 @@ sub time2str_local { Date::Language->new(); # fall back to English $self->{_dh} = $dh; } - $self->{_dh}->time2str(@_); + + if ($format eq 'short') { + $format = $self->{_date_format}->{short} + ||= $self->conf->config('date_format') || '%x'; + } elsif ($format eq 'rdate') { + $format = $self->{_date_format}->{rdate} + ||= $self->conf->config('date_format') || '%m/%d/%Y'; + } elsif ($format eq 'long') { + $format = $self->{_date_format}->{long} + ||= $self->conf->config('date_format_long') || '%b %o, %Y'; + } + + # actually render the date + my $string = $self->{_dh}->time2str($format, $time); + + if ($escape) { + if ($escape eq 'html') { + $string = encode_entities($string); + $string =~ s/ +/ /g; + } elsif ($escape eq 'latex') { # just do nbsp's here + $string =~ s/ +/~/g; + } + } + + $string; } =back diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm index 229d4f66c..3a210baa8 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -453,10 +453,10 @@ sub calc_usage { } my %options = ( - 'disable_src' => $self->option('disable_src'), - 'default_prefix' => $self->option('default_prefix'), - 'cdrtypenum' => $self->option('use_cdrtypenum'), - 'calltypenum' => $self->option('use_calltypenum'), + 'disable_src' => $self->option('disable_src',1), + 'default_prefix' => $self->option('default_prefix',1), + 'cdrtypenum' => $self->option('use_cdrtypenum',1), + 'calltypenum' => $self->option('use_calltypenum',1), 'status' => '', 'for_update' => 1, ); # $last_bill, $$sdate ) diff --git a/httemplate/elements/select-terms.html b/httemplate/elements/select-terms.html index a66aa29ae..57a83f053 100644 --- a/httemplate/elements/select-terms.html +++ b/httemplate/elements/select-terms.html @@ -33,7 +33,8 @@ my $empty_label = my $empty_value = $opt{'empty_value'} || ''; my @terms = ( emt('Payable upon receipt'), - ( map "Net $_", 0, 3, 9, 10, 15, 18, 20, 30, 45, 60, 90 ), + ( map "Net $_", + 0, 3, 9, 10, 15, 18, 20, 21, 25, 30, 45, 60, 90 ), ); my @pre_options = $opt{pre_options} ? @{ $opt{pre_options} } : (); |