summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/AccessRight.pm6
-rw-r--r--FS/FS/payby.pm9
-rwxr-xr-xhttemplate/edit/cust_pay.cgi45
-rwxr-xr-xhttemplate/edit/cust_refund.cgi52
-rwxr-xr-xhttemplate/edit/process/cust_refund.cgi29
-rw-r--r--httemplate/elements/init_calendar.html5
-rw-r--r--httemplate/view/cust_main/payment_history/refund.html1
-rw-r--r--httemplate/view/cust_refund.html2
8 files changed, 97 insertions, 52 deletions
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index 4e6eaaf..262b134 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 349d266..b54e5d9 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 92abb7b..3c28774 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') %>
-
-<LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2">
-<SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT>
-<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT>
-<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT>
+<% include('/elements/init_calendar.html') %>
-<FORM ACTION="<% popurl(1) %>process/cust_pay.cgi" METHOD=POST>
-<INPUT TYPE="hidden" NAME="link" VALUE="<% $link %>">
-<INPUT TYPE="hidden" NAME="linknum" VALUE="<% $linknum %>">
+<% include('/elements/error.html') %>
% unless ( $link eq 'popup' ) {
<% small_custview($custnum, $conf->config('countrydefault')) %>
% }
+<FORM NAME="PaymentForm" ACTION="<% popurl(1) %>process/cust_pay.cgi" METHOD=POST onSubmit="document.PaymentForm.submit.disabled=true">
+<INPUT TYPE="hidden" NAME="link" VALUE="<% $link %>">
+<INPUT TYPE="hidden" NAME="linknum" VALUE="<% $linknum %>">
<INPUT TYPE="hidden" NAME="payby" VALUE="<% $payby %>">
+<INPUT TYPE="hidden" NAME="paybatch" VALUE="<% $paybatch %>">
<BR><BR>
+
Payment
<% ntable("#cccccc", 2) %>
@@ -45,7 +43,7 @@ Payment
<TR>
<TD ALIGN="right">Amount</TD>
<TD BGCOLOR="#ffffff" ALIGN="right"><% $money_char %></TD>
- <TD><INPUT TYPE="text" NAME="paid" VALUE="<% $paid %>" SIZE=8 MAXLENGTH=8> by <B><% $payby{$payby} %></B></TD>
+ <TD><INPUT TYPE="text" NAME="paid" VALUE="<% $paid %>" SIZE=8 MAXLENGTH=8> by <B><% FS::payby->payname($payby) %></B></TD>
</TR>
% if ( $payby eq 'BILL' ) {
@@ -76,31 +74,24 @@ Payment
</TABLE>
-<INPUT TYPE="hidden" NAME="paybatch" VALUE="<% $paybatch %>">
-
<BR>
<INPUT TYPE="submit" VALUE="Post payment">
</FORM>
-</BODY>
-</HTML>
-<%once>
+% if ( $link eq 'popup' ) {
+ </BODY>
+ </HTML>
+% } 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') || '$';
-</%once>
-<%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;
}
-</%init>
+</%init>
diff --git a/httemplate/edit/cust_refund.cgi b/httemplate/edit/cust_refund.cgi
index 3333f5d..94c0993 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')) %>
+% }
<FORM NAME="RefundForm" ACTION="<% $p1 %>process/cust_refund.cgi" METHOD=POST onSubmit="document.RefundForm.submit.disabled=true">
+<INPUT TYPE="hidden" NAME="popup" VALUE="<% $link %>">
<INPUT TYPE="hidden" NAME="refundnum" VALUE="">
<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
<INPUT TYPE="hidden" NAME="paynum" VALUE="<% $paynum %>">
<INPUT TYPE="hidden" NAME="_date" VALUE="<% $_date %>">
<INPUT TYPE="hidden" NAME="payby" VALUE="<% $payby %>">
-<INPUT TYPE="hidden" NAME="payinfo" VALUE="">
<INPUT TYPE="hidden" NAME="paybatch" VALUE="">
<INPUT TYPE="hidden" NAME="credited" VALUE="">
+
<BR>
+
% 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/;
-%
-%
-
<BR>Payment
<% ntable("#cccccc", 2) %>
@@ -42,7 +45,7 @@
</TR>
<TR>
- <TD ALIGN="right">Method</TD><TD BGCOLOR="#ffffff"><% ucfirst(lc($payby)) %> # <% $paymask %></TD>
+ <TD ALIGN="right">Method</TD><TD BGCOLOR="#ffffff"><% $payby %> # <% $paymask %></TD>
</TR>
% unless ( $paydate ) { # possibly other reasons: i.e. card has since expired
@@ -89,15 +92,27 @@
<% ntable("#cccccc", 2) %>
<TR>
- <TD ALIGN="right">Date</TD><TD BGCOLOR="#ffffff"><% time2str("%D",$_date) %></TD>
+ <TD ALIGN="right">Date</TD>
+ <TD BGCOLOR="#ffffff"><% time2str("%D",$_date) %></TD>
</TR>
<TR>
- <TD ALIGN="right">Amount</TD><TD BGCOLOR="#ffffff">$<INPUT TYPE="text" NAME="refund" VALUE="<% $refund %>" SIZE=8 MAXLENGTH=8></TD>
+ <TD ALIGN="right">Amount</TD>
+ <TD BGCOLOR="#ffffff">$<INPUT TYPE="text" NAME="refund" VALUE="<% $refund %>" SIZE=8 MAXLENGTH=8> by <B><% FS::payby->payname($payby) %></B></TD>
</TR>
+% if ( $payby eq 'BILL' ) {
+ <TR>
+ <TD ALIGN="right">Check #</TD>
+ <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10></TD>
+ </TR>
+% } else {
+ <INPUT TYPE="hidden" NAME="payinfo" VALUE="">
+% }
+
<TR>
- <TD ALIGN="right">Reason</TD><TD BGCOLOR="#ffffff"><INPUT TYPE="text" NAME="reason" VALUE="<% $reason %>"></TD>
+ <TD ALIGN="right">Reason</TD>
+ <TD BGCOLOR="#ffffff"><INPUT TYPE="text" NAME="reason" VALUE="<% $reason %>"></TD>
</TR>
</TABLE>
@@ -106,7 +121,12 @@
</FORM>
-<% include('/elements/footer.html') %>
+% if ( $link eq 'popup' ) {
+ </BODY>
+ </HTML>
+% } 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';
+
</%init>
diff --git a/httemplate/edit/process/cust_refund.cgi b/httemplate/edit/process/cust_refund.cgi
index 1a7a394..5749e53 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') %>
+ <SCRIPT TYPE="text/javascript">
+ window.top.location.reload();
+ </SCRIPT>
+
+ </BODY></HTML>
+% } 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;
}
</%init>
diff --git a/httemplate/elements/init_calendar.html b/httemplate/elements/init_calendar.html
new file mode 100644
index 0000000..04b0135
--- /dev/null
+++ b/httemplate/elements/init_calendar.html
@@ -0,0 +1,5 @@
+<LINK REL="stylesheet" TYPE="text/css" HREF="<%$fsurl%>elements/calendar-win2k-2.css" TITLE="win2k-2">
+
+% foreach (qw( _stripped -en -setup )) {
+<SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar<%$_%>.js"></SCRIPT>
+% }
diff --git a/httemplate/view/cust_main/payment_history/refund.html b/httemplate/view/cust_main/payment_history/refund.html
index 5f9bca3..7978821 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 40f6ab6..557e0ab 100644
--- a/httemplate/view/cust_refund.html
+++ b/httemplate/view/cust_refund.html
@@ -60,7 +60,7 @@
<TR>
<TD ALIGN="right">Refund method</TD>
- <TD BGCOLOR="#FFFFFF"><B><% $cust_refund->payby_name %> #<% $cust_refund->paymask %></B></TD>
+ <TD BGCOLOR="#FFFFFF"><B><% $cust_refund->payby_name %><% $cust_refund->paymask ? ' #'.$cust_refund->paymask : '' %></B></TD>
</TR>
% if ( $cust_refund->payby =~ /^(CARD|CHEK|LECB)$/ && $cust_refund->paybatch ) {