From cccd0b7cd38a88c131e19981be38434f87abe194 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 21 Oct 2005 15:21:37 +0000 Subject: add CASH and WEST payment types (payments only, not cust_main.payby) --- httemplate/edit/cust_main.cgi | 5 ++- httemplate/edit/cust_main/billing.html | 54 ++++++++++++++++++++++++- httemplate/edit/cust_pay.cgi | 46 ++++++++++++--------- httemplate/edit/process/cust_main.cgi | 3 ++ httemplate/search/cust_pay.cgi | 43 ++++++++++++++++++-- httemplate/search/report_cust_pay.html | 6 ++- httemplate/view/cust_bill.cgi | 40 +++++++++++++++++- httemplate/view/cust_main/payment_history.html | 56 +++++++++++++++++++++++--- 8 files changed, 219 insertions(+), 34 deletions(-) (limited to 'httemplate') diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index bfd396881..e10c85f01 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -35,6 +35,7 @@ if ( $cgi->param('error') ) { $popnum = $cgi->param('popnum'); @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') ); $same = $cgi->param('same'); + $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid'); } elsif ( $cgi->keywords ) { #editing my( $query ) = $cgi->keywords; $query =~ /^(\d+)$/; @@ -261,7 +262,8 @@ function bottomfixup(what) { 'payinfo', 'payinfo1', 'payinfo2', 'payname', 'exp_month', 'exp_year', 'paycvv', 'paystart_month', 'paystart_year', 'payissue', - 'payip' + 'payip', + 'paid' ); var billing_bottomvars = new Array( @@ -340,6 +342,7 @@ function copyelement(from, to) { 'payname', 'exp_month', 'exp_year', 'paycvv', 'paystart_month', 'paystart_year', 'payissue', 'payip', + 'paid', 'tax', 'invoicing_list', 'invoicing_list_POST', 'invoicing_list_FAX' diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html index 17b1b0cc9..caac3a956 100644 --- a/httemplate/edit/cust_main/billing.html +++ b/httemplate/edit/cust_main/billing.html @@ -4,6 +4,11 @@ my( $cust_main ) = @_; my $conf = new FS::Conf; my $payby_default = $conf->config('payby-default'); +my @payby = $conf->config('payby'); +#@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP )) +@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP )) + unless grep /\w/, @payby; + if ( $payby_default eq 'HIDE' ) { $cust_main->payby('BILL') unless $cust_main->payby; @@ -294,15 +299,60 @@ if ( $payby_default eq 'HIDE' ) { '', + 'CASH' => + + ''. + + qq!!. + qq!!. + + ''. + ''. + ''. + ''. + ''. + ''. + + '
${r}Amount
 
 
 
 
 
 
', + + 'WEST' => + + ''. + + qq!!. + qq!!. + + ''. + ''. + ''. + ''. + ''. + ''. + + '
${r}Amount
 
 
 
 
 
 
', + ); - tie my %options, 'Tie::IxHash', + + my %allopt = ( 'CARD' => 'Credit card', 'CHEK' => 'Electronic check', 'LECB' => 'Phone bill billing', 'BILL' => 'Billing', + 'CASH' => 'Cash', # initial payment, then billing', + 'WEST' => 'Western Union', # initial payment, then billing', 'COMP' => 'Complimentary', - ; + ); + if ( $cust_main->custnum ) { #don't offer CASH and WEST initial payment types + # when editing customer + delete $allopt{$_} for qw(CASH WEST); + } + + tie my %options, 'Tie::IxHash', + map { $_ => $allopt{$_} } + grep { exists $allopt{$_} } + @payby; + my %payby2option = ( ( map { $_ => $_ } keys %options ), 'DCRD' => 'CARD', diff --git a/httemplate/edit/cust_pay.cgi b/httemplate/edit/cust_pay.cgi index c0a679b03..b2f3f55ff 100755 --- a/httemplate/edit/cust_pay.cgi +++ b/httemplate/edit/cust_pay.cgi @@ -1,8 +1,13 @@ - <% my $conf = new FS::Conf; +my %payby = ( + 'BILL' => 'Check', + 'CASH' => 'Cash', + 'WEST' => 'Western Union', +); + my($link, $linknum, $paid, $payby, $payinfo, $quickpay, $_date); if ( $cgi->param('error') ) { $link = $cgi->param('link'); @@ -12,31 +17,29 @@ if ( $cgi->param('error') ) { $payinfo = $cgi->param('payinfo'); $quickpay = $cgi->param('quickpay'); $_date = $cgi->param('_date') ? str2time($cgi->param('_date')) : time; -} elsif ($cgi->keywords) { - my($query) = $cgi->keywords; - $query =~ /^(\d+)$/; - $link = 'invnum'; - $linknum = $1; - $paid = ''; - $payby = 'BILL'; - $payinfo = ""; - $quickpay = ''; - $_date = time; -} elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) { +} elsif ( $cgi->param('custnum') =~ /^(\d+)$/ ) { $link = 'custnum'; $linknum = $1; $paid = ''; - $payby = 'BILL'; + $payby = $cgi->param('payby') || 'BILL'; $payinfo = ''; $quickpay = $cgi->param('quickpay'); $_date = time; +} elsif ( $cgi->param('invnum') =~ /^(\d+)$/ ) { + $link = 'invnum'; + $linknum = $1; + $paid = ''; + $payby = $cgi->param('payby') || 'BILL'; + $payinfo = ""; + $quickpay = ''; + $_date = time; } else { die "illegal query ". $cgi->keywords; } my $paybatch = "webui-$_date-$$-". rand() * 2**32; -my $title = 'Post payment'; +my $title = 'Post '. $payby{$payby}. ' payment'; $title .= " against Invoice #$linknum" if $link eq 'invnum'; %> @@ -97,13 +100,18 @@ Payment Amount <%= $money_char %> - - - - Check # - + by <%= $payby{$payby} %> +<% if ( $payby eq 'BILL' ) { %> + + + Check # + + + +<% } %> + <% if ( $link eq 'custnum' ) { %> Auto-apply
to invoices diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi index 85dbb9775..d77aa2fdd 100755 --- a/httemplate/edit/process/cust_main.cgi +++ b/httemplate/edit/process/cust_main.cgi @@ -55,6 +55,9 @@ if ( defined($cgi->param('same')) && $cgi->param('same') eq "Y" ) { ); } +$new->setfield('paid', $cgi->param('paid') ) + if $cgi->param('paid'); + #perhaps this stuff should go to cust_main.pm my $cust_pkg = ''; my $svc_acct = ''; diff --git a/httemplate/search/cust_pay.cgi b/httemplate/search/cust_pay.cgi index 89da7426a..2106a649a 100755 --- a/httemplate/search/cust_pay.cgi +++ b/httemplate/search/cust_pay.cgi @@ -16,14 +16,27 @@ } if ( $cgi->param('payby') ) { - $cgi->param('payby') =~ /^(CARD|CHEK|BILL)(-(VisaMC|Amex|Discover))?$/ - or die "illegal payby ". $cgi->param('payby'); + $cgi->param('payby') =~ + /^(CARD|CHEK|BILL|PREP|CASH|WEST)(-(VisaMC|Amex|Discover|Maestro))?$/ + or die "illegal payby ". $cgi->param('payby'); push @search, "cust_pay.payby = '$1'"; if ( $3 ) { if ( $3 eq 'VisaMC' ) { #avoid posix regexes for portability push @search, - " ( substring(cust_pay.payinfo from 1 for 1) = '4' ". + " ( ( substring(cust_pay.payinfo from 1 for 1) = '4' ". + " AND substring(cust_pay.payinfo from 1 for 4) != '4936' ". + " AND substring(cust_pay.payinfo from 1 for 6) ". + " NOT SIMILAR TO '49030[2-9]' ". + " AND substring(cust_pay.payinfo from 1 for 6) ". + " NOT SIMILAR TO '49033[5-9]' ". + " AND substring(cust_pay.payinfo from 1 for 6) ". + " NOT SIMILAR TO '49110[1-2]' ". + " AND substring(cust_pay.payinfo from 1 for 6) ". + " NOT SIMILAR TO '49117[4-9]' ". + " AND substring(cust_pay.payinfo from 1 for 6) ". + " NOT SIMILAR TO '49118[1-2]' ". + " )". " OR substring(cust_pay.payinfo from 1 for 2) = '51' ". " OR substring(cust_pay.payinfo from 1 for 2) = '52' ". " OR substring(cust_pay.payinfo from 1 for 2) = '53' ". @@ -38,7 +51,25 @@ " ) "; } elsif ( $3 eq 'Discover' ) { push @search, - " substring(cust_pay.payinfo from 1 for 4 ) = '6011' "; + " substring(cust_pay.payinfo from 1 for 4 ) = '6011' ". + " OR substring(cust_pay.payinfo from 1 for 3 ) = '650' "; + } elsif ( $3 eq 'Maestro' ) { + push @search, + " ( substring(cust_pay.payinfo from 1 for 2 ) = '63' ". + ' OR substring(cust_pay.payinfo from 1 for 2 ) = '67' ". + ' OR substring(cust_pay.payinfo from 1 for 6 ) = '564182' ". + " OR substring(cust_pay.payinfo from 1 for 4 ) = '4936' ". + " OR substring(cust_pay.payinfo from 1 for 6 ) ". + " SIMILAR TO '49030[2-9]' ". + " OR substring(cust_pay.payinfo from 1 for 6 ) ". + " SIMILAR TO '49033[5-9]' ". + " OR substring(cust_pay.payinfo from 1 for 6 ) ". + " SIMILAR TO '49110[1-2]' ". + " OR substring(cust_pay.payinfo from 1 for 6 ) ". + " SIMILAR TO '49117[4-9]' ". + " OR substring(cust_pay.payinfo from 1 for 6 ) ". + " SIMILAR TO '49118[1-2]' ". + " ) "; } else { die "unknown card type $3"; } @@ -134,6 +165,10 @@ 'Check #'. $cust_pay->payinfo; } elsif ( $cust_pay->payby eq 'PREP' ) { 'Prepaid card #'. $cust_pay->payinfo; + } elsif ( $cust_pay->payby eq 'CASH' ) { + 'Cash '. $cust_pay->payinfo; + } elsif ( $cust_pay->payby eq 'WEST' ) { + 'Western Union'; #. $cust_pay->payinfo; } else { $cust_pay->payby. ' '. $cust_pay->payinfo; } diff --git a/httemplate/search/report_cust_pay.html b/httemplate/search/report_cust_pay.html index 8b9e27302..18501d5b5 100644 --- a/httemplate/search/report_cust_pay.html +++ b/httemplate/search/report_cust_pay.html @@ -19,8 +19,12 @@ + - + + + + diff --git a/httemplate/view/cust_bill.cgi b/httemplate/view/cust_bill.cgi index d149cf172..8dcbd3a35 100755 --- a/httemplate/view/cust_bill.cgi +++ b/httemplate/view/cust_bill.cgi @@ -8,6 +8,12 @@ my $invnum = $3; my $conf = new FS::Conf; +my @payby = $conf->config('payby'); +#@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP )) +@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP )) + unless grep /\w/, @payby; +my %payby = map { $_=>1 } @payby; + my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); die "Invoice #$invnum not found!" unless $cust_bill; my $custnum = $cust_bill->getfield('custnum'); @@ -22,8 +28,38 @@ my $link = $templatename ? "$templatename-$invnum" : $invnum; "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", )) %> -<% if ( $cust_bill->owed > 0 ) { %> - Enter payments (check/cash) against this invoice | +<% if ( $cust_bill->owed > 0 + && ( $payby{'BILL'} || $payby{'CASH'} || $payby{'WEST'} ) + ) + { + my $s = 0; +%> + + Post + + <% if ( $payby{'BILL'} ) { %> + + <%= $s++ ? ' | ' : '' %> + check + + <% } %> + + <% if ( $payby{'CASH'} ) { %> + + <%= $s++ ? ' | ' : '' %> + cash + + <% } %> + + <% if ( $payby{'WEST'} ) { %> + + <%= $s++ ? ' | ' : '' %> + Western Union + + <% } %> + + payment against this invoice
+ <% } %> Re-print this invoice diff --git a/httemplate/view/cust_main/payment_history.html b/httemplate/view/cust_main/payment_history.html index 6c475c5f2..e58b6248e 100644 --- a/httemplate/view/cust_main/payment_history.html +++ b/httemplate/view/cust_main/payment_history.html @@ -1,13 +1,56 @@ <% my( $cust_main ) = @_; - my $conf = new FS::Conf; my $custnum = $cust_main->custnum; + + my $conf = new FS::Conf; + + my @payby = $conf->config('payby'); + #@payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH WEST COMP )) + @payby = (qw( CARD DCRD CHEK DCHK LECB BILL CASH COMP )) + unless grep /\w/, @payby; + my %payby = map { $_=>1 } @payby; + + my $s = 0; + %>

Payment History
-Post cash/check payment -| Process credit card payment -| Process electronic check (ACH) payment + +<% if ( $payby{'BILL'} ) { %> + + <%= $s++ ? ' | ' : '' %> + Post check payment + +<% } %> + +<% if ( $payby{'CASH'} ) { %> + + <%= $s++ ? ' | ' : '' %> + Post cash payment + +<% } %> + +<% if ( $payby{'WEST'} ) { %> + + <%= $s++ ? ' | ' : '' %> + Post Western Union payment + +<% } %> + +<% if ( $payby{'CARD'} || $payby{'DCRD'} ) { %> + + <%= $s++ ? ' | ' : '' %> + Process credit card payment + +<% } %> + +<% if ( $payby{'CHEK'} || $payby{'DCHK'} ) { %> + + <%= $s++ ? ' | ' : '' %> + Process electronic check (ACH) payment + +<% } %> +
Post credit
@@ -51,8 +94,11 @@ foreach my $cust_pay ($cust_main->cust_pay) { $payby =~ s/^BILL$/Check #/ if $payinfo; $payby =~ s/^CHEK$/Electronic check /; $payby =~ s/^PREP$/Prepaid card /; + $payby =~ s/^CARD$/Credit card #/; + $payby =~ s/^COMP$/Complimentary by /; + $payby =~ s/^CASH$/Cash/; + $payby =~ s/^WEST$/Western Union/; $payby =~ s/^BILL$//; - $payby =~ s/^(CARD|COMP)$/$1 /; my $info = $payby ? " ($payby$payinfo)" : ''; my( $pre, $post, $desc, $apply, $ext ) = ( '', '', '', '', '' ); -- cgit v1.2.1