projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix problems using inventory for UID (and other fields controlled by check in svc_acc...
[freeside.git]
/
FS
/
FS
/
cust_bill.pm
diff --git
a/FS/FS/cust_bill.pm
b/FS/FS/cust_bill.pm
index
861bb4c
..
a0885f1
100644
(file)
--- a/
FS/FS/cust_bill.pm
+++ b/
FS/FS/cust_bill.pm
@@
-96,6
+96,18
@@
L<Time::Local> and L<Date::Parse> for conversion functions.
=item charged - amount of this invoice
=item charged - amount of this invoice
+=item invoice_terms - optional terms override for this specific invoice
+
+=back
+
+Customer info at invoice generation time
+
+=over 4
+
+=item previous_balance
+
+=item billing_balance
+
=back
Deprecated
=back
Deprecated
@@
-2355,8
+2367,8
@@
sub print_generic {
# my( $cr_total, @cr_cust_credit ) = $self->cust_credit; #credits
#my $balance_due = $self->owed + $pr_total - $cr_total;
my $balance_due = $self->owed + $pr_total;
# my( $cr_total, @cr_cust_credit ) = $self->cust_credit; #credits
#my $balance_due = $self->owed + $pr_total - $cr_total;
my $balance_due = $self->owed + $pr_total;
- $invoice_data{'true_previous_balance'} = sprintf("%.2f",
$self->previous_balance
);
- $invoice_data{'balance_adjustments'} = sprintf("%.2f",
$self->previous_balance - $self->billing_balance
);
+ $invoice_data{'true_previous_balance'} = sprintf("%.2f",
($self->previous_balance || 0)
);
+ $invoice_data{'balance_adjustments'} = sprintf("%.2f",
($self->previous_balance || 0) - ($self->billing_balance || 0)
);
$invoice_data{'previous_balance'} = sprintf("%.2f", $pr_total);
$invoice_data{'balance'} = sprintf("%.2f", $balance_due);
$invoice_data{'previous_balance'} = sprintf("%.2f", $pr_total);
$invoice_data{'balance'} = sprintf("%.2f", $balance_due);
@@
-2989,10
+3001,10
@@
sub _translate_old_latex_format {
$line_item_line =~ s/\$(\w+)/'. \$_tr_line->{$1}. '/g;
push @template, " \$OUT .= '$line_item_line';";
}
$line_item_line =~ s/\$(\w+)/'. \$_tr_line->{$1}. '/g;
push @template, " \$OUT .= '$line_item_line';";
}
-
+
push @template, '}',
'--@]';
push @template, '}',
'--@]';
-
+ #' doh, gvim
} elsif ( $line =~ /^%%TotalDetails\s*$/ ) {
push @template, '[@--',
} elsif ( $line =~ /^%%TotalDetails\s*$/ ) {
push @template, '[@--',
@@
-3026,11
+3038,12
@@
sub _translate_old_latex_format {
sub terms {
my $self = shift;
sub terms {
my $self = shift;
- #check for an invoice- specific override (eventually)
+ #check for an invoice-specific override
+ return $self->invoice_terms if $self->invoice_terms;
#check for a customer- specific override
#check for a customer- specific override
- return $self->cust_main->invoice_terms
-
if $self->
cust_main->invoice_terms;
+ my $cust_main = $self->cust_main;
+
return $cust_main->invoice_terms if $
cust_main->invoice_terms;
#use configured default
$conf->config('invoice_default_terms') || '';
#use configured default
$conf->config('invoice_default_terms') || '';
@@
-3095,70
+3108,72
@@
sub _date_pretty {
time2str('%x', $self->_date);
}
time2str('%x', $self->_date);
}
+use vars qw(%pkg_category_cache);
sub _items_sections {
my $self = shift;
my $late = shift;
my $summarypage = shift;
my $escape = shift;
sub _items_sections {
my $self = shift;
my $late = shift;
my $summarypage = shift;
my $escape = shift;
- my %s = ();
- my %l = ();
+ my %s
ubtotal
= ();
+ my %l
ate_subtotal
= ();
my %not_tax = ();
foreach my $cust_bill_pkg ( $self->cust_bill_pkg )
{
my %not_tax = ();
foreach my $cust_bill_pkg ( $self->cust_bill_pkg )
{
-
my $usage = $cust_bill_pkg->usage;
foreach my $display ($cust_bill_pkg->cust_bill_pkg_display) {
next if ( $display->summary && $summarypage );
my $usage = $cust_bill_pkg->usage;
foreach my $display ($cust_bill_pkg->cust_bill_pkg_display) {
next if ( $display->summary && $summarypage );
- my $
desc
= $display->section;
- my $type = $display->type;
+ my $
section
= $display->section;
+ my $type
= $display->type;
- if ( $cust_bill_pkg->pkgnum > 0 ) {
- $not_tax{$desc} = 1;
- }
+ $not_tax{$section} = 1
+ unless $cust_bill_pkg->pkgnum == 0;
if ( $display->post_total && !$summarypage ) {
if (! $type || $type eq 'S') {
if ( $display->post_total && !$summarypage ) {
if (! $type || $type eq 'S') {
- $l
{$desc
} += $cust_bill_pkg->setup
- if
( $cust_bill_pkg->setup != 0 )
;
+ $l
ate_subtotal{$section
} += $cust_bill_pkg->setup
+ if
$cust_bill_pkg->setup != 0
;
}
if (! $type) {
}
if (! $type) {
- $l
{$desc
} += $cust_bill_pkg->recur
- if
( $cust_bill_pkg->recur != 0 )
;
+ $l
ate_subtotal{$section
} += $cust_bill_pkg->recur
+ if
$cust_bill_pkg->recur != 0
;
}
if ($type && $type eq 'R') {
}
if ($type && $type eq 'R') {
- $l
{$desc
} += $cust_bill_pkg->recur - $usage
- if
( $cust_bill_pkg->recur != 0 )
;
+ $l
ate_subtotal{$section
} += $cust_bill_pkg->recur - $usage
+ if
$cust_bill_pkg->recur != 0
;
}
if ($type && $type eq 'U') {
}
if ($type && $type eq 'U') {
- $l
{$desc
} += $usage;
+ $l
ate_subtotal{$section
} += $usage;
}
} else {
}
} else {
+
+ next if $cust_bill_pkg->pkgnum == 0 && ! $section;
+
if (! $type || $type eq 'S') {
if (! $type || $type eq 'S') {
- $s
{$desc
} += $cust_bill_pkg->setup
- if
( $cust_bill_pkg->setup != 0 )
;
+ $s
ubtotal{$section
} += $cust_bill_pkg->setup
+ if
$cust_bill_pkg->setup != 0
;
}
if (! $type) {
}
if (! $type) {
- $s
{$desc
} += $cust_bill_pkg->recur
- if
( $cust_bill_pkg->recur != 0 )
;
+ $s
ubtotal{$section
} += $cust_bill_pkg->recur
+ if
$cust_bill_pkg->recur != 0
;
}
if ($type && $type eq 'R') {
}
if ($type && $type eq 'R') {
- $s
{$desc
} += $cust_bill_pkg->recur - $usage
- if
( $cust_bill_pkg->recur != 0 )
;
+ $s
ubtotal{$section
} += $cust_bill_pkg->recur - $usage
+ if
$cust_bill_pkg->recur != 0
;
}
if ($type && $type eq 'U') {
}
if ($type && $type eq 'U') {
- $s
{$desc
} += $usage;
+ $s
ubtotal{$section
} += $usage;
}
}
}
}
@@
-3167,28
+3182,42
@@
sub _items_sections {
}
}
- my %cache = map { $_->categoryname => $_ }
- qsearch( 'pkg_category', {disabled => 'Y'} );
- $cache{$_->categoryname} = $_
- foreach qsearch( 'pkg_category', {disabled => ''} );
+ %pkg_category_cache = ();
push @$late, map { { 'description' => &{$escape}($_),
push @$late, map { { 'description' => &{$escape}($_),
- 'subtotal' => $l{$_},
+ 'subtotal' => $l
ate_subtotal
{$_},
'post_total' => 1,
} }
'post_total' => 1,
} }
- sort { $cache{$a}->weight <=> $cache{$b}->weight } keys %l;
+ sort _categorysort keys %late_subtotal;
+
+ my @sections;
+ if ( $summarypage ) {
+ @sections = grep { exists($subtotal{$_}) || ! _pkg_category{$_}->disabled }
+ keys %pkg_category_cache;
+ } else {
+ @sections = keys %subtotal;
+ }
map { { 'description' => &{$escape}($_),
map { { 'description' => &{$escape}($_),
- 'subtotal' => $s{$_},
+ 'subtotal' => $s
ubtotal
{$_},
'summarized' => $not_tax{$_} ? '' : 'Y',
'tax_section' => $not_tax{$_} ? '' : 'Y',
'summarized' => $not_tax{$_} ? '' : 'Y',
'tax_section' => $not_tax{$_} ? '' : 'Y',
- } }
- sort { $cache{$a}->weight <=> $cache{$b}->weight }
- ( $summarypage
- ? ( grep { exists($s{$_}) || !$cache{$_}->disabled } keys %cache )
- : ( keys %s )
- );
+ }
+ }
+ sort _categorysort @sections;
+
+}
+
+#helper subs for above
+
+sub _categorysort {
+ _pkg_category($a)->weight <=> _pkg_category($b)->weight;
+}
+sub _pkg_category {
+ my $categoryname = shift;
+ $pkg_category_cache{$categoryname} ||=
+ qsearchs( 'pkg_category', { 'categoryname' => $categoryname } );
}
sub _items {
}
sub _items {