From: ivan Date: Wed, 3 Sep 2008 01:46:43 +0000 (+0000) Subject: add back ability to post a check/cash refund. be more explicit about it instead... X-Git-Tag: root_of_webpay_support~396 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=46a7257273fdae101658c8a1ee74f654ca0876b5 add back ability to post a check/cash refund. be more explicit about it instead of just being a checkbox when posting a credit. RT#3812 --- diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm index 4e6eaafe2..262b134d1 100644 --- a/FS/FS/AccessRight.pm +++ b/FS/FS/AccessRight.pm @@ -161,8 +161,8 @@ tie my %rights, 'Tie::IxHash', 'Apply payment', #NEWNEW { rightname=>'Unapply payment', desc=>'Enable "unapplication" of unclosed payments from specific invoices.' }, #aka. unapplypayments 'Process payment', - 'Refund payment', - + { rightname=>'Refund payment', desc=>'Enable refund of existing customer payments.' }, + { rightname=>'Delete payment', desc=>'Enable deletion of unclosed payments. Be very careful! Only delete payments that were data-entry errors, not adjustments.' }, #aka. deletepayments Optionally specify one or more comma-separated email addresses to be notified when a payment is deleted. ], @@ -175,6 +175,8 @@ tie my %rights, 'Tie::IxHash', 'Apply credit', #NEWNEW { rightname=>'Unapply credit', desc=>'Enable "unapplication" of unclosed credits.' }, #aka unapplycredits { rightname=>'Delete credit', desc=>'Enable deletion of unclosed credits. Be very careful! Only delete credits that were data-entry errors, not adjustments.' }, #aka. deletecredits Optionally specify one or more comma-separated email addresses to be notified when a credit is deleted. + { rightname=>'Post refund', desc=>'Enable posting of check and cash refunds.' }, +# { rightname=>'Process refund', desc=>'Enable processing of generic credit card/ACH refunds (i.e. not associated with a specific prior payment).' }, 'Delete refund', #NEW 'Add on-the-fly credit reason', #NEW ], diff --git a/FS/FS/payby.pm b/FS/FS/payby.pm index 349d266a3..b54e5d938 100644 --- a/FS/FS/payby.pm +++ b/FS/FS/payby.pm @@ -74,6 +74,7 @@ tie %hash, 'Tie::IxHash', 'BILL' => { tinyname => 'billing', shortname => 'Billing', + payname => 'Check', longname => 'Billing', }, 'PREP' => { @@ -140,6 +141,14 @@ sub shortname { $hash{$payby}->{shortname}; } +sub payname { + my( $self, $payby ) = @_; + #$hash{$payby}->{payname} || $hash{$payby}->{shortname}; + exists($hash{$payby}->{payname}) + ? $hash{$payby}->{payname} + : $hash{$payby}->{shortname}; +} + sub longname { my( $self, $payby ) = @_; $hash{$payby}->{longname}; diff --git a/httemplate/edit/cust_pay.cgi b/httemplate/edit/cust_pay.cgi index 92abb7be8..3c2877498 100755 --- a/httemplate/edit/cust_pay.cgi +++ b/httemplate/edit/cust_pay.cgi @@ -4,24 +4,22 @@ <% include("/elements/header.html", $title, '') %> % } -<% include('/elements/error.html') %> - - - - - +<% include('/elements/init_calendar.html') %> -
- - +<% include('/elements/error.html') %> % unless ( $link eq 'popup' ) { <% small_custview($custnum, $conf->config('countrydefault')) %> % } + + + +

+ Payment <% ntable("#cccccc", 2) %> @@ -45,7 +43,7 @@ Payment Amount <% $money_char %> - by <% $payby{$payby} %> + by <% FS::payby->payname($payby) %> % if ( $payby eq 'BILL' ) { @@ -76,31 +74,24 @@ Payment - -
- - -<%once> +% if ( $link eq 'popup' ) { + + +% } else { + <% include('/elements/footer.html') %> +% } -my $conf = new FS::Conf; +<%init> -my %payby = ( - 'BILL' => 'Check', - 'CASH' => 'Cash', - 'WEST' => 'Western Union', - 'MCRD' => 'Manual credit card', -); +my $conf = new FS::Conf; my $money_char = $conf->config('money_char') || '$'; - -<%init> - die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Post payment'); @@ -132,7 +123,7 @@ if ( $cgi->param('error') ) { my $paybatch = "webui-$_date-$$-". rand() * 2**32; -my $title = 'Post '. $payby{$payby}. ' payment'; +my $title = 'Post '. FS::payby->payname($payby). ' payment'; $title .= " against Invoice #$linknum" if $link eq 'invnum'; my $custnum; @@ -143,5 +134,5 @@ if ( $link eq 'invnum' ) { } elsif ( $link eq 'custnum' ) { $custnum = $linknum; } - + diff --git a/httemplate/edit/cust_refund.cgi b/httemplate/edit/cust_refund.cgi index 3333f5d8c..94c0993d7 100755 --- a/httemplate/edit/cust_refund.cgi +++ b/httemplate/edit/cust_refund.cgi @@ -1,34 +1,37 @@ -<% include('/elements/header.html', 'Refund '. ucfirst(lc($payby)). ' payment', '') %> +% if ( $link eq 'popup' ) { + <% include('/elements/header-popup.html', $title ) %> +% } else { + <% include("/elements/header.html", $title, '') %> +% } <% include('/elements/error.html') %> -<% small_custview($custnum, $conf->config('countrydefault')) %> +% unless ( $link eq 'popup' ) { + <% small_custview($custnum, $conf->config('countrydefault')) %> +% }
+ - +
+ % if ( $cust_pay ) { % % #false laziness w/FS/FS/cust_pay.pm -% my $payby = $cust_pay->payby; +% my $payby = FS::payby->payname($cust_pay->payby); % my $paymask = $cust_pay->paymask; % my $paydate = $cust_pay->paydate; % if ( $cgi->param('error') ) { % $paydate = $cgi->param('exp_year'). '-'. $cgi->param('exp_month'). '-01'; % $paydate = '' unless ($paydate =~ /^\d{2,4}-\d{1,2}-01$'/); % } -% $payby =~ s/^BILL$/Check/ if $paymask; -% $payby =~ s/^CHEK$/Electronic check/; -% -% -
Payment <% ntable("#cccccc", 2) %> @@ -42,7 +45,7 @@ - Method<% ucfirst(lc($payby)) %> # <% $paymask %> + Method<% $payby %> # <% $paymask %> % unless ( $paydate ) { # possibly other reasons: i.e. card has since expired @@ -89,15 +92,27 @@ <% ntable("#cccccc", 2) %> - Date<% time2str("%D",$_date) %> + Date + <% time2str("%D",$_date) %> - Amount$ + Amount + $ by <% FS::payby->payname($payby) %> +% if ( $payby eq 'BILL' ) { + + Check # + + +% } else { + +% } + - Reason + Reason + @@ -106,7 +121,12 @@
-<% include('/elements/footer.html') %> +% if ( $link eq 'popup' ) { + + +% } else { + <% include('/elements/footer.html') %> +% } <%init> @@ -117,7 +137,9 @@ my $conf = new FS::Conf; my $custnum = $cgi->param('custnum'); my $refund = $cgi->param('refund'); my $payby = $cgi->param('payby'); +my $payinfo = $cgi->param('payinfo'); my $reason = $cgi->param('reason'); +my $link = $cgi->param('popup') ? 'popup' : ''; my( $paynum, $cust_pay ) = ( '', '' ); if ( $cgi->param('paynum') =~ /^(\d+)$/ ) { @@ -138,4 +160,6 @@ my $_date = time; my $p1 = popurl(1); +my $title = 'Refund '. FS::payby->payname($payby). ' payment'; + diff --git a/httemplate/edit/process/cust_refund.cgi b/httemplate/edit/process/cust_refund.cgi index 1a7a394b3..5749e5346 100755 --- a/httemplate/edit/process/cust_refund.cgi +++ b/httemplate/edit/process/cust_refund.cgi @@ -2,18 +2,32 @@ % $cgi->param('error', $error); <% $cgi->redirect(popurl(2). "cust_refund.cgi?". $cgi->query_string ) %> %} else { +% +% if ( $link eq 'popup' ) { +% +<% header('Refund entered') %> + + + +% } else { <% $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum") %> +% } %} <%init> die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Refund payment'); + unless $FS::CurrentUser::CurrentUser->access_right('Refund payment') + || $FS::CurrentUser::CurrentUser->access_right('Post refund'); $cgi->param('custnum') =~ /^(\d*)$/ or die "Illegal custnum!"; my $custnum = $1; my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) or die "unknown custnum $custnum"; +my $link = $cgi->param('popup') ? 'popup' : ''; + my $error = ''; if ( $cgi->param('payby') =~ /^(CARD|CHEK)$/ ) { my %options = (); @@ -31,13 +45,12 @@ if ( $cgi->param('payby') =~ /^(CARD|CHEK)$/ ) { 'reason' => $reason, %options ); } else { - die 'unimplemented'; - #my $new = new FS::cust_refund ( { - # map { - # $_, scalar($cgi->param($_)); - # } ( fields('cust_refund'), 'paynum' ) - #} ); - #$error = $new->insert; + my $new = new FS::cust_refund ( { + map { + $_, scalar($cgi->param($_)); + } fields('cust_refund') #huh? , 'paynum' ) + } ); + $error = $new->insert; } diff --git a/httemplate/elements/init_calendar.html b/httemplate/elements/init_calendar.html new file mode 100644 index 000000000..04b013596 --- /dev/null +++ b/httemplate/elements/init_calendar.html @@ -0,0 +1,5 @@ + + +% foreach (qw( _stripped -en -setup )) { + +% } diff --git a/httemplate/view/cust_main/payment_history/refund.html b/httemplate/view/cust_main/payment_history/refund.html index 5f9bca339..797882103 100644 --- a/httemplate/view/cust_main/payment_history/refund.html +++ b/httemplate/view/cust_main/payment_history/refund.html @@ -14,6 +14,7 @@ my $payinfo = $payby eq 'CARD' : $cust_refund->payinfo; $payby =~ s/^BILL$/Check #/ if $payinfo; +$payby =~ s/^BILL$/Check/; $payby =~ s/^CHEK$/Electronic check /; $payby =~ s/^(CARD|COMP)$/$1 /; diff --git a/httemplate/view/cust_refund.html b/httemplate/view/cust_refund.html index 40f6ab630..557e0ab24 100644 --- a/httemplate/view/cust_refund.html +++ b/httemplate/view/cust_refund.html @@ -60,7 +60,7 @@ Refund method - <% $cust_refund->payby_name %> #<% $cust_refund->paymask %> + <% $cust_refund->payby_name %><% $cust_refund->paymask ? ' #'.$cust_refund->paymask : '' %> % if ( $cust_refund->payby =~ /^(CARD|CHEK|LECB)$/ && $cust_refund->paybatch ) {