X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_credit_bill_pkg.html;h=63d70c27e06498ad18eb2b8c927d1ca694fbac91;hb=a80507837e7edee6e06206fdda466a9cf7391566;hp=a57a5ae1ab74c8e036d8f2635946ea245c4de7e9;hpb=f2e7b5d30a04b6f050e0a82afd8b95c81730bc0c;p=freeside.git diff --git a/httemplate/search/cust_credit_bill_pkg.html b/httemplate/search/cust_credit_bill_pkg.html index a57a5ae1a..63d70c27e 100644 --- a/httemplate/search/cust_credit_bill_pkg.html +++ b/httemplate/search/cust_credit_bill_pkg.html @@ -1,4 +1,4 @@ -<% include( 'elements/search.html', +<& elements/search.html, 'title' => 'Credit application detail', #to line item 'name_singular' => 'credit application', 'query' => $query, @@ -16,6 +16,8 @@ # line item 'Description', + 'Location', + @post_desc_header, #invoice 'Invoice', @@ -34,6 +36,8 @@ ? $_[0]->get('pkg') # possibly use override.pkg : $_[0]->get('itemdesc') # but i think this correct }, + $location_sub, + @post_desc, 'invnum', sub { time2str('%b %d %Y', shift->_date ) }, \&FS::UI::Web::cust_fields, @@ -44,6 +48,8 @@ '', #'otaker', '', #reason '', #line item description + '', #location + @post_desc_null, 'invnum', '_date', #cust fields @@ -54,13 +60,18 @@ '', '', '', + '', + @post_desc_null, $ilink, $ilink, ( map { $_ ne 'Cust. Status' ? $clink : '' } FS::UI::Web::cust_header() ), ], - 'align' => 'rrlllrr'.FS::UI::Web::cust_aligns(), + 'align' => 'rrllll'. + $post_desc_align. + 'rr'. + FS::UI::Web::cust_aligns(), 'color' => [ '', '', @@ -68,6 +79,8 @@ '', '', '', + @post_desc_null, + '', '', FS::UI::Web::cust_colors(), ], @@ -78,14 +91,17 @@ '', '', '', + @post_desc_null, + '', '', FS::UI::Web::cust_styles(), ], - ) -%> + +&> <%init> #LOTS of false laziness below w/cust_bill_pkg.cgi +# and a little w/cust_credit.html die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Financial reports'); @@ -98,10 +114,23 @@ my $agentnums_sql = my @where = ( $agentnums_sql ); +if ( $cgi->param('usernum') =~ /^(\d+)$/ ) { + push @where, "cust_credit.usernum = $1"; +} + my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); push @where, "cust_bill._date >= $beginning", "cust_bill._date <= $ending"; +my($cr_begin, $cr_end) = FS::UI::Web::parse_beginning_ending($cgi, 'credit'); +push @where, "cust_credit._date >= $cr_begin", + "cust_credit._date <= $cr_end"; + +#credit amount? seems more what is expected than the applied amount +my @lt_gt = FS::UI::Web::parse_lt_gt($cgi, 'amount' ); +s/amount/cust_credit.amount/g foreach (@lt_gt); +push @where, @lt_gt; + if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) { push @where, "cust_main.agentnum = $1"; } @@ -354,8 +383,8 @@ my $count_query = "SELECT COUNT(DISTINCT creditbillpkgnum), SUM(cust_credit_bill_pkg.amount)"; my $join_cust = - ' JOIN cust_bill ON ( cust_bill_pkg.invnum = cust_bill.invnum ) - LEFT JOIN cust_main ON ( cust_bill.custnum = cust_main.custnum ) '; + ' JOIN cust_bill ON ( cust_bill_pkg.invnum = cust_bill.invnum )'. + FS::UI::Web::join_cust_main('cust_bill', 'cust_pkg'); my $join_pkg; @@ -400,10 +429,9 @@ if ( $cgi->param('nottax') ) { s/cust_pkg\.locationnum/cust_bill_pkg_tax_location.locationnum/g for @where; } -} else { +} else { - #die? - warn "neiether nottax nor istax parameters specified"; + #warn "neither nottax nor istax parameters specified"; #same as before? $join_pkg = ' LEFT JOIN cust_pkg USING ( pkgnum ) LEFT JOIN part_pkg USING ( pkgpart ) '; @@ -432,6 +460,18 @@ push @select, 'part_pkg.pkg' unless $cgi->param('istax'); push @select, 'cust_main.custnum', FS::UI::Web::cust_sql_fields(); +my @post_desc_header = (); +my @post_desc = (); +my @post_desc_null = (); +my $post_desc_align = ''; +if ( $conf->exists('enable_taxclasses') && ! $cgi->param('istax') ) { + push @post_desc_header, 'Tax class'; + push @post_desc, 'taxclass'; + push @post_desc_null, ''; + $post_desc_align .= 'l'; + push @select, 'part_pkg.taxclass'; # or should this use override? +} + my $query = { 'table' => 'cust_credit_bill_pkg', 'addl_from' => "$join_cust_bill_pkg @@ -450,4 +490,57 @@ my $clink = [ "${p}view/cust_main.cgi?", 'custnum' ]; my $conf = new FS::Conf; my $money_char = $conf->config('money_char') || '$'; +my $tax_pkg_address = $conf->exists('tax-pkg_address'); +my $tax_ship_address = $conf->exists('tax-ship_address'); + +my $location_sub = sub { + #my $cust_credit_bill_pkg = shift; + my $self = shift; + my $tax_Xlocation = $self->cust_bill_pkg_tax_Xlocation; + if ( defined($tax_Xlocation) && $tax_Xlocation ) { + + if ( ref($tax_Xlocation) eq 'FS::cust_bill_pkg_tax_location' ) { + + if ( $tax_Xlocation->taxtype eq 'FS::cust_main_county' ) { + my $cust_main_county = $tax_Xlocation->cust_main_county; + if ( $cust_main_county ) { + $cust_main_county->label; + } else { + ''; #cust_main_county record is gone... history? yuck. + } + } else { + '(CCH tax_rate)'; #XXX FS::tax_rate.. vendor taxes not yet handled here + } + + } elsif ( ref($tax_Xlocation) eq 'FS::cust_bill_pkg_tax_rate_location' ) { + '(CCH)'; #XXX vendor taxes not yet handled here + } else { + 'unknown tax_Xlocation '. ref($tax_Xlocation); + } + + } else { + + my $cust_bill_pkg = $self->cust_bill_pkg; + if ( $cust_bill_pkg->pkgnum > 0 ) { + my $cust_pkg = $cust_bill_pkg->cust_pkg; + if ( $tax_pkg_address && (my $cust_location = $cust_pkg->cust_location) ){ + $cust_location->county_state_country; + } else { + my $cust_main = $cust_pkg->cust_main; + if ( $tax_ship_address && $cust_main->has_ship_address ) { + $cust_main->county_state_country('ship_'); + } else { + $cust_main->county_state_country; + } + } + + } else { + #tax? we shouldn't have wound up here then... + ''; #return customer ship or bill address? (depending on tax-ship_address) + } + + } + +}; +