From 3fa2bc364fc6810b7ce8a02d27e7062ff850ee9d Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 12 Dec 2009 23:54:14 +0000 Subject: [PATCH] better reporting for tax credits, RT#4729 --- FS/FS/cust_credit_bill_pkg.pm | 14 +++++++-- httemplate/search/cust_bill_pkg.cgi | 2 ++ httemplate/search/cust_credit_bill_pkg.html | 44 +++++++++++++---------------- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/FS/FS/cust_credit_bill_pkg.pm b/FS/FS/cust_credit_bill_pkg.pm index 787b4f251..8b01cd21a 100644 --- a/FS/FS/cust_credit_bill_pkg.pm +++ b/FS/FS/cust_credit_bill_pkg.pm @@ -2,9 +2,14 @@ package FS::cust_credit_bill_pkg; use strict; use vars qw( @ISA ); -use FS::Record qw( qsearch qsearchs ); +use FS::Record qw( qsearchs ); # qsearch ); +use FS::cust_main_Mixin; +use FS::cust_credit_bill; +use FS::cust_bill_pkg; +use FS::cust_bill_pkg_tax_location; +use FS::cust_bill_pkg_tax_rate_location; -@ISA = qw(FS::Record); +@ISA = qw( FS::cust_main_Mixin FS::Record ); =head1 NAME @@ -130,6 +135,11 @@ sub check { $self->SUPER::check; } +sub cust_credit_bill { + my $self = shift; + qsearchs('cust_credit_bill', { 'creditbillnum' => $self->creditbillnum } ); +} + =back =head1 BUGS diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi index 063b5f4b6..4cc90a44c 100644 --- a/httemplate/search/cust_bill_pkg.cgi +++ b/httemplate/search/cust_bill_pkg.cgi @@ -74,6 +74,8 @@ %> <%init> +#LOTS of false laziness below w/cust_credit_bill_pkg.cgi + die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Financial reports'); diff --git a/httemplate/search/cust_credit_bill_pkg.html b/httemplate/search/cust_credit_bill_pkg.html index a1d456123..52e0ac6fe 100644 --- a/httemplate/search/cust_credit_bill_pkg.html +++ b/httemplate/search/cust_credit_bill_pkg.html @@ -8,41 +8,32 @@ #'#', 'Amount', - # credit date, By, Reason, - # line item, invoice + #credit + 'Date', + 'By', + 'Reason', + + # line item 'Description', - 'Setup charge', - ( $use_usage eq 'usage' - ? 'Usage charge' - : 'Recurring charge' - ), + + #invoice 'Invoice', 'Date', FS::UI::Web::cust_header(), ], 'fields' => [ #'creditbillpkgnum', - 'amount', + sub { sprintf($money_char.'%.2f', shift->amount ) }, + + sub { time2str('%b %d %Y', shift->get('cust_credit_date') ) }, + 'otaker', + sub { shift->cust_credit_bill->cust_credit->reason }, sub { $_[0]->pkgnum > 0 ? $_[0]->get('pkg') # possibly use override.pkg : $_[0]->get('itemdesc') # but i think this correct }, - #strikethrough or "N/A ($amount)" or something these when - # they're not applicable to pkg_tax search - sub { sprintf($money_char.'%.2f', shift->setup ) }, - sub { my $row = shift; - my $value = 0; - if ( $use_usage eq 'recurring' ) { - $value = $row->recur - $row->usage; - } elsif ( $use_usage eq 'usage' ) { - $value = $row->usage; - } else { - $value = $row->recur; - } - sprintf($money_char.'%.2f', $value ); - }, 'invnum', sub { time2str('%b %d %Y', shift->_date ) }, \&FS::UI::Web::cust_fields, @@ -52,13 +43,14 @@ '', '', '', + '', $ilink, $ilink, ( map { $_ ne 'Cust. Status' ? $clink : '' } FS::UI::Web::cust_header() ), ], - 'align' => 'rlrrrc'.FS::UI::Web::cust_aligns(), + 'align' => 'rrlllrr'.FS::UI::Web::cust_aligns(), 'color' => [ '', '', @@ -66,6 +58,7 @@ '', '', '', + '', FS::UI::Web::cust_colors(), ], 'style' => [ @@ -75,6 +68,7 @@ '', '', '', + '', FS::UI::Web::cust_styles(), ], ) @@ -495,8 +489,10 @@ my $join_credit = ' LEFT JOIN cust_credit_bill USING ( creditbillnum ) $where"; #} -my @select = ( 'cust_credit_bill_pkg.amount', +my @select = ( 'cust_credit_bill_pkg.*', 'cust_bill_pkg.*', + 'cust_credit.otaker', + 'cust_credit._date AS cust_credit_date', 'cust_bill._date', ); push @select, 'part_pkg.pkg' unless $cgi->param('istax'); -- 2.11.0