[freeside-commits] freeside/FS/FS Schema.pm, 1.96, 1.97 cust_bill.pm, 1.220, 1.221 cust_bill_pkg.pm, 1.20, 1.21 cust_main.pm, 1.356, 1.357
Jeff Finucane,420,,
jeff at wavetail.420.am
Fri Aug 8 11:13:06 PDT 2008
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv30634/FS/FS
Modified Files:
Schema.pm cust_bill.pm cust_bill_pkg.pm cust_main.pm
Log Message:
cdrs can be in separate invoice section, after total, summarized inline, with hints for page breaks
Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -d -r1.96 -r1.97
--- Schema.pm 3 Aug 2008 02:15:07 -0000 1.96
+++ Schema.pm 8 Aug 2008 18:13:03 -0000 1.97
@@ -496,9 +496,12 @@
'sdate', @date_type, '', '',
'edate', @date_type, '', '',
'itemdesc', 'varchar', 'NULL', $char_d, '', '',
+ 'section', 'varchar', 'NULL', $char_d, '', '',
'quantity', 'int', 'NULL', '', '', '',
'unitsetup', @money_typen, '', '',
'unitrecur', @money_typen, '', '',
+ 'duplicate', 'char', 'NULL', 1, '', '', # does this need to be in db?
+ 'post_total', 'char', 'NULL', 1, '', '',
],
'primary_key' => 'billpkgnum',
'unique' => [],
Index: cust_bill_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill_pkg.pm,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- cust_bill_pkg.pm 2 Aug 2008 04:20:16 -0000 1.20
+++ cust_bill_pkg.pm 8 Aug 2008 18:13:04 -0000 1.21
@@ -57,6 +57,24 @@
=item itemdesc - Line item description (overrides normal package description)
+=item section - Invoice section (overrides normal package section)
+
+=duplicate - Indicates this item appears elsewhere on the invoice
+ (and should not be retaxed or reincluded in totals)
+
+=post_total - A hint that this item should appear after invoice totals
+
+=cut
+
+sub section {
+ my ( $self, $value ) = @_;
+ if ( defined($value) ) {
+ $self->setfield('section', $value);
+ } else {
+ $self->getfield('section') || $self->part_pkg->categoryname;
+ }
+}
+
=item quantity - If not set, defaults to 1
=item unitsetup - If not set, defaults to setup
@@ -174,6 +192,9 @@
|| $self->ut_numbern('sdate')
|| $self->ut_numbern('edate')
|| $self->ut_textn('itemdesc')
+ || $self->ut_textn('section')
+ || $self->ut_enum('duplicate', [ '', 'Y' ])
+ || $self->ut_enum('post_total', [ '', 'Y' ])
;
return $error if $error;
@@ -382,7 +403,7 @@
sub units {
my $self = shift;
- $self->part_pkg->calc_units($self->cust_pkg);
+ $self->pkgnum ? $self->part_pkg->calc_units($self->cust_pkg) : 0; # 1?
}
=item quantity
@@ -425,6 +446,18 @@
: $self->getfield('unitrecur');
}
+=item separate_cdr
+
+Returns true if this line item represents a cdr line item in its own section.
+
+=cut
+
+# lame, but works for now
+sub separate_cdr {
+ my( $self ) = shift;
+ $self->pkgnum && $self->section ne $self->part_pkg->categoryname;
+}
+
=back
=head1 BUGS
Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.220
retrieving revision 1.221
diff -u -d -r1.220 -r1.221
--- cust_bill.pm 2 Aug 2008 04:20:16 -0000 1.220
+++ cust_bill.pm 8 Aug 2008 18:13:04 -0000 1.221
@@ -1999,9 +1999,11 @@
my $adjust_section = { 'description' => 'Credits, Payments, and Adjustments',
'subtotal' => 0 }; # adjusted below
+ my $unsquelched = $params{unsquelch_cdr} || $cust_main->squelch_cdr ne 'Y';
my $multisection = $conf->exists('invoice_sections', $cust_main->agentnum);
+ my $late_sections = [];
if ( $multisection ) {
- push @sections, $self->_items_sections;
+ push @sections, $self->_items_sections( $late_sections );
}else{
push @sections, { 'description' => '', 'subtotal' => '' };
}
@@ -2040,7 +2042,7 @@
push @buf, ['',''];
}
- foreach my $section (@sections) {
+ foreach my $section (@sections, @$late_sections) {
$section->{'subtotal'} = $other_money_char.
sprintf('%.2f', $section->{'subtotal'})
@@ -2056,8 +2058,8 @@
$options{'section'} = $section if $multisection;
$options{'format'} = $format;
$options{'escape_function'} = $escape_function;
- $options{'format_function'} = sub { () }
- unless $params{unsquelch_cdr} || $cust_main->squelch_cdr ne 'Y';
+ $options{'format_function'} = sub { () } unless $unsquelched;
+ $options{'unsquelched'} = $unsquelched;
foreach my $line_item ( $self->_items_pkg(%options) ) {
my $detail = {
@@ -2278,6 +2280,11 @@
}
}
+ if ( $multisection ) {
+ push @sections, @$late_sections
+ if $unsquelched;
+ }
+
$invoice_lines = 0;
my $wasfunc = 0;
foreach ( grep /invoice_lines\(\d*\)/, @invoice_template ) { #kludgy
@@ -2537,24 +2544,42 @@
sub _items_sections {
my $self = shift;
+ my $late = shift;
my %s = ();
- foreach my $cust_bill_pkg ( $self->cust_bill_pkg ) {
+ my %l = ();
+
+ foreach my $cust_bill_pkg ( $self->cust_bill_pkg )
+ {
if ( $cust_bill_pkg->pkgnum > 0 ) {
- my $desc = $cust_bill_pkg->part_pkg->categoryname;
+ my $desc = $cust_bill_pkg->section;
- $s{$desc} += $cust_bill_pkg->setup
- if ( $cust_bill_pkg->setup != 0 );
+ if ( $cust_bill_pkg->post_total ) {
+ $l{$desc} += $cust_bill_pkg->setup
+ if ( $cust_bill_pkg->setup != 0 );
- $s{$desc} += $cust_bill_pkg->recur
- if ( $cust_bill_pkg->recur != 0 );
+ $l{$desc} += $cust_bill_pkg->recur
+ if ( $cust_bill_pkg->recur != 0 );
+
+ } else {
+ $s{$desc} += $cust_bill_pkg->setup
+ if ( $cust_bill_pkg->setup != 0 );
+
+ $s{$desc} += $cust_bill_pkg->recur
+ if ( $cust_bill_pkg->recur != 0 );
+ }
}
}
+ push @$late, map { { 'description' => $_,
+ 'subtotal' => $l{$_},
+ 'post_total' => 1,
+ } } sort keys %l;
+
map { {'description' => $_, 'subtotal' => $s{$_}} } sort keys %s;
}
@@ -2613,7 +2638,7 @@
my @cust_bill_pkg =
grep { $_->pkgnum &&
( defined($section)
- ? $_->part_pkg->categoryname eq $section->{'description'}
+ ? $_->section eq $section->{'description'}
: 1
)
} $self->cust_bill_pkg;
@@ -2643,9 +2668,13 @@
my $format = $opt{format} || '';
my $escape_function = $opt{escape_function} || sub { shift };
my $format_function = $opt{format_function} || '';
+ my $unsquelched = $opt{unsquelched} || '';
my @b = ();
- foreach my $cust_bill_pkg ( @$cust_bill_pkg ) {
+ foreach my $cust_bill_pkg ( grep { $unsquelched ? 1 : ! $_->separate_cdr }
+ @$cust_bill_pkg
+ )
+ {
my $cust_pkg = $cust_bill_pkg->cust_pkg;
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.356
retrieving revision 1.357
diff -u -d -r1.356 -r1.357
--- cust_main.pm 6 Aug 2008 04:05:54 -0000 1.356
+++ cust_main.pm 8 Aug 2008 18:13:04 -0000 1.357
@@ -2491,18 +2491,20 @@
unless $part_pkg->pkgpart == $real_pkgpart;
push @$appended_cust_bill_pkg, $cust_bill_pkg;
- $$total_setup += $cust_bill_pkg->setup;
- $$total_recur += $cust_bill_pkg->recur;
+ unless ($cust_bill_pkg->duplicate) {
+ $$total_setup += $cust_bill_pkg->setup;
+ $$total_recur += $cust_bill_pkg->recur;
- ###
- # handle taxes
- ###
+ ###
+ # handle taxes
+ ###
- unless ( $self->tax =~ /Y/i || $self->payby eq 'COMP' ) {
+ unless ( $self->tax =~ /Y/i || $self->payby eq 'COMP' ) {
- $self->_handle_taxes($part_pkg, $taxlisthash, $cust_bill_pkg);
+ $self->_handle_taxes($part_pkg, $taxlisthash, $cust_bill_pkg);
- } #unless $self->tax =~ /Y/i || $self->payby eq 'COMP'
+ } #unless $self->tax =~ /Y/i || $self->payby eq 'COMP'
+ }
}
}
More information about the freeside-commits
mailing list