'count_query' => $count_query,
'count_addl' => [ $money_char. '%.2f total', ],
'header' => [
- '#',
+ #'#',
'Description',
'Setup charge',
( $use_usage eq 'usage'
FS::UI::Web::cust_header(),
],
'fields' => [
- 'billpkgnum',
+ #'billpkgnum',
sub { $_[0]->pkgnum > 0
? $_[0]->get('pkg') # possibly use override.pkg
: $_[0]->get('itemdesc') # but i think this correct
\&FS::UI::Web::cust_fields,
],
'links' => [
- '',
+ #'',
'',
'',
'',
FS::UI::Web::cust_header()
),
],
- 'align' => 'rlrrrc'.FS::UI::Web::cust_aligns(),
+ #'align' => 'rlrrrc'.FS::UI::Web::cust_aligns(),
+ 'align' => 'lrrrc'.FS::UI::Web::cust_aligns(),
'color' => [
- '',
+ #'',
'',
'',
'',
FS::UI::Web::cust_colors(),
],
'style' => [
- '',
+ #'',
'',
'',
'',
%>
<%init>
+#LOTS of false laziness below w/cust_credit_bill_pkg.cgi
+
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
}
+my @loc_param = qw( city county state country );
+
if ( $cgi->param('out') ) {
my ( $loc_sql, @param ) = FS::cust_pkg->location_sql( 'ornull' => 1 );
";
#not linked to by anything, but useful for debugging "out of taxable region"
- if ( grep $cgi->param($_), qw( county state country ) ) {
+ if ( grep $cgi->param($_), @loc_param ) {
- my %ph = map { $_ => dbh->quote( $cgi->param($_) ) }
- qw( county state country );
+ my %ph = map { $_ => dbh->quote( scalar($cgi->param($_)) ) } @loc_param;
my ( $loc_sql, @param ) = FS::cust_pkg->location_sql;
while ( $loc_sql =~ /\?/ ) { #easier to do our own substitution
my %ph = ( 'county' => dbh->quote($_),
map { $_ => dbh->quote( $cgi->param($_) ) }
- qw( state country )
+ qw( city state country )
);
my ( $loc_sql, @param ) = FS::cust_pkg->location_sql;
} else {
- my %ph = map { $_ => dbh->quote( $cgi->param($_) ) }
- qw( county state country );
+ my %ph = map { $_ => dbh->quote( scalar($cgi->param($_)) ) } @loc_param;
my ( $loc_sql, @param ) = FS::cust_pkg->location_sql;
while ( $loc_sql =~ /\?/ ) { #easier to do our own substitution
);
my %ph = map { ( $pn{$_} => dbh->quote( $cgi->param($_) || '' ) ) }
- qw( county state city locationtaxid );
+ qw( city county state locationtaxid );
push @where,
join( ' AND ', map { "( $_ = $ph{$_} OR $ph{$_} = '' AND $_ IS NULL)" }
}
-my $where = ' WHERE '. join(' AND ', @where);
-
my $join_cust = ' JOIN cust_bill USING ( invnum )
LEFT JOIN cust_main USING ( custnum ) ';
$join_pkg .= ' LEFT JOIN cust_bill_pkg_tax_location USING ( billpkgnum )
LEFT JOIN cust_location USING ( locationnum ) ';
- #quelle kludge, false laziness w/report_tax.cgi
- $where =~ s/cust_pkg\.locationnum/cust_bill_pkg_tax_location.locationnum/g;
- } elsif ( scalar( grep( /locationtaxid/, $cgi->param ) ) ) {
+ #quelle kludge, somewhat false laziness w/report_tax.cgi
+ s/cust_pkg\.locationnum/cust_bill_pkg_tax_location.locationnum/g for @where;
+ } elsif ( scalar( grep( /locationtaxid/, $cgi->param ) ) ||
+ $cgi->param('iscredit') eq 'rate') {
$join_pkg .=
' LEFT JOIN cust_bill_pkg_tax_rate_location USING ( billpkgnum ) '.
' LEFT JOIN tax_rate_location USING ( taxratelocationnum ) ';
}
+ if ( $cgi->param('iscredit') ) {
+ $join_pkg .= ' JOIN cust_credit_bill_pkg USING ( billpkgnum';
+ if ( $conf->exists('tax-pkg_address') ) {
+ $join_pkg .= ', billpkgtaxlocationnum )';
+ push @where, "billpkgtaxratelocationnum IS NULL";
+ } elsif ( $cgi->param('iscredit') eq 'rate' ) {
+ $join_pkg .= ', billpkgtaxratelocationnum )';
+ } else {
+ $join_pkg .= ' )';
+ push @where, "billpkgtaxratelocationnum IS NULL";
+ }
+ }
+
} else {
#die?
}
+my $where = ' WHERE '. join(' AND ', @where);
+
if ($use_usage) {
$count_query .=
" FROM (SELECT cust_bill_pkg.setup, cust_bill_pkg.recur,
} else {
$count_query .= " FROM cust_bill_pkg $join_cust $join_pkg $where";
}
-warn "count_query is $count_query\n";
my @select = (
'cust_bill_pkg.*',