diff options
author | Jonathan Prykop <jonathan@freeside.biz> | 2015-07-13 18:33:52 -0500 |
---|---|---|
committer | Jonathan Prykop <jonathan@freeside.biz> | 2015-07-13 18:33:52 -0500 |
commit | 4b695753d2456060e6a16808120cbb488a19c584 (patch) | |
tree | bdbfb439e5ee7be8e2b84c388589043a05d385bc /httemplate | |
parent | 2ead33f915536127cd148d4e2ca474b9c45c634b (diff) |
RT#31594: Unapplied payment issues
Diffstat (limited to 'httemplate')
-rwxr-xr-x | httemplate/edit/cust_pay.cgi | 10 | ||||
-rw-r--r-- | httemplate/edit/process/cust_pay-no_auto_apply.cgi | 48 | ||||
-rwxr-xr-x | httemplate/edit/process/cust_pay.cgi | 1 | ||||
-rw-r--r-- | httemplate/misc/batch-cust_pay.html | 10 | ||||
-rw-r--r-- | httemplate/misc/process/batch-cust_pay.cgi | 1 | ||||
-rw-r--r-- | httemplate/view/cust_main/payment_history/payment.html | 103 |
6 files changed, 115 insertions, 58 deletions
diff --git a/httemplate/edit/cust_pay.cgi b/httemplate/edit/cust_pay.cgi index 888335fbb..5d74365e7 100755 --- a/httemplate/edit/cust_pay.cgi +++ b/httemplate/edit/cust_pay.cgi @@ -87,15 +87,17 @@ <TD ALIGN="right"><% mt('Auto-apply to invoices') |h %></TD> <TD COLSPAN=2> <SELECT NAME="apply"> - <OPTION VALUE="yes" SELECTED><% mt('yes') |h %> - <OPTION><% mt('no') |h %></SELECT> - </TD> + <OPTION VALUE="yes" SELECTED><% mt('yes') |h %></OPTION> + <OPTION VALUE=""><% mt('not now') |h %></OPTION> + <OPTION VALUE="never"><% mt('never') |h %></OPTION> + </SELECT> + </TD> % } elsif ( $link eq 'invnum' ) { <TD ALIGN="right"><% mt('Apply to') |h %></TD> <TD COLSPAN=2 BGCOLOR="#ffffff">Invoice #<B><% $linknum %></B> only</TD> - <INPUT TYPE="hidden" NAME="apply" VALUE="no"> + <INPUT TYPE="hidden" NAME="apply" VALUE=""> % } </TR> diff --git a/httemplate/edit/process/cust_pay-no_auto_apply.cgi b/httemplate/edit/process/cust_pay-no_auto_apply.cgi new file mode 100644 index 000000000..ccbd2d7b5 --- /dev/null +++ b/httemplate/edit/process/cust_pay-no_auto_apply.cgi @@ -0,0 +1,48 @@ +<%doc> +Quick process for toggling no_auto_apply field in cust_pay. + +Requires paynum and no_auto_apply ('Y' or '') in cgi. + +Requires 'Apply payment' acl. +</%doc> + +% if ($error) { + +<P STYLE="color: #FF0000"><% emt($error) %></P> + +% } else { + +<P STYLE="font-weight: bold;"><% emt($message) %></P> +<P><% emt('Please wait while the page reloads.') %></P> +<SCRIPT TYPE="text/javascript"> +window.top.location.reload(); +</SCRIPT> + +% } + +<%init> +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Apply payment'); + +my $paynum = $cgi->param('paynum'); +my $noauto = $cgi->param('no_auto_apply'); + +my $error = ''; +my $message = ''; +my $cust_pay = qsearchs('cust_pay',{ paynum => $paynum }); +if ($cust_pay) { + if (($noauto eq 'Y') || (defined($noauto) && (length($noauto) == 0))) { + $cust_pay->no_auto_apply($noauto); + $error = $cust_pay->replace; + $message = $noauto ? + q(Payment will not be automatically applied to open invoices, must be applied manually) : + q(Payment will be automatically applied to open invoices the next time this customer's payments are processed); + } else { + $error = 'no_auto_apply not specified'; + } +} else { + $error .= 'Payment could not be found in database'; +} + + +</%init> diff --git a/httemplate/edit/process/cust_pay.cgi b/httemplate/edit/process/cust_pay.cgi index a002fa181..56d3f2ff1 100755 --- a/httemplate/edit/process/cust_pay.cgi +++ b/httemplate/edit/process/cust_pay.cgi @@ -50,6 +50,7 @@ else { my $new = new FS::cust_pay ( { $field => $linknum, _date => $_date, + no_auto_apply => ($cgi->param('apply') eq 'never') ? 'Y' : '', map { $_, scalar($cgi->param($_)); } qw( paid payby payinfo paybatch diff --git a/httemplate/misc/batch-cust_pay.html b/httemplate/misc/batch-cust_pay.html index 3b0ebc112..9f2540cc7 100644 --- a/httemplate/misc/batch-cust_pay.html +++ b/httemplate/misc/batch-cust_pay.html @@ -461,6 +461,16 @@ push @footer, ''; push @footer_align, ''; push @onchange, 'toggle_application_row'; +push @header, 'No Auto Allocate'; +push @fields, 'no_auto_apply'; +push @types, 'checkbox'; +push @align, 'c'; +push @sizes, '0'; +push @colors, ''; +push @footer, ''; +push @footer_align, ''; +push @onchange, ''; + #push @header, 'Error'; push @header, ''; push @fields, 'error'; diff --git a/httemplate/misc/process/batch-cust_pay.cgi b/httemplate/misc/process/batch-cust_pay.cgi index bb4b9733c..ff7886239 100644 --- a/httemplate/misc/process/batch-cust_pay.cgi +++ b/httemplate/misc/process/batch-cust_pay.cgi @@ -40,6 +40,7 @@ foreach my $row ( map /^custnum(\d+)$/, keys %$param ) { 'payinfo' => $param->{"payinfo$row"}, 'discount_term' => $param->{"discount_term$row"}, 'paybatch' => $paybatch, + 'no_auto_apply' => exists($param->{"no_auto_apply$row"}) ? 'Y' : '', } if $param->{"custnum$row"} || $param->{"paid$row"} diff --git a/httemplate/view/cust_main/payment_history/payment.html b/httemplate/view/cust_main/payment_history/payment.html index 4ec9271ef..bf88a6607 100644 --- a/httemplate/view/cust_main/payment_history/payment.html +++ b/httemplate/view/cust_main/payment_history/payment.html @@ -9,6 +9,7 @@ my $date_format = $opt{'date_format'} || '%m/%d/%Y'; my @cust_bill_pay = $cust_pay->cust_bill_pay; my @cust_pay_refund = $cust_pay->cust_pay_refund; +my $unapplied = $cust_pay->unapplied; my ($payby,$payinfo) = translate_payinfo($cust_pay); my $target = "$payby$payinfo"; @@ -50,39 +51,14 @@ if ( scalar(@cust_bill_pay) == 0 $payment = emt("Unapplied Payment by [_1]",$otaker); $payment =~ s/$otaker/<i>$otaker<\/i>/ if $italicize_otaker; $payment = '<B><FONT COLOR="#FF0000">'.$payment.'</FONT></B>'; - if ( $opt{'Apply payment'} ) { - if ( $opt{total_owed} > 0 ) { - $apply = ' ('. - include( '/elements/popup_link.html', - 'label' => emt('apply'), - 'action' => "${p}edit/cust_bill_pay.cgi?". - $cust_pay->paynum, - 'actionlabel' => emt('Apply payment'), - %cust_bill_pay_width, - %cust_bill_pay_height, - ). - ')'; - } - if ( $opt{total_unapplied_refunds} > 0 ) { - $apply.= ' ('. - include( '/elements/popup_link.html', - 'label' => emt('apply to refund'), - 'action' => "${p}edit/cust_pay_refund.cgi?". - $cust_pay->paynum, - 'actionlabel' => emt('Apply payment to refund'), - 'width' => 392, - ). - ')'; - } - } } elsif ( scalar(@cust_bill_pay) == 1 && scalar(@cust_pay_refund) == 0 - && $cust_pay->unapplied == 0 ) { + && $unapplied == 0 ) { #applied to one invoice, the usual situation $desc .= ' '. $cust_bill_pay[0]->applied_to_invoice; } elsif ( scalar(@cust_bill_pay) == 0 && scalar(@cust_pay_refund) == 1 - && $cust_pay->unapplied == 0 ) { + && $unapplied == 0 ) { #applied to one refund $desc .= emt(" refunded on [_1]", time2str($date_format, $cust_pay_refund[0]->_date) ); } else { @@ -101,40 +77,59 @@ if ( scalar(@cust_bill_pay) == 0 die "$app is not a FS::cust_bill_pay or FS::cust_pay_refund"; } } - if ( $cust_pay->unapplied > 0 ) { + if ( $unapplied > 0 ) { $desc .= ' '. '<B><FONT COLOR="#FF0000">'. - emt("[_1][_2] unapplied", $opt{money_char}, $cust_pay->unapplied). + emt("[_1][_2] unapplied", $opt{money_char}, $unapplied). '</FONT></B>'; - if ( $opt{'Apply payment'} ) { - if ( $opt{total_owed} > 0 ) { - $apply = ' ('. - include( '/elements/popup_link.html', - 'label' => emt('apply'), - 'action' => "${p}edit/cust_bill_pay.cgi?". - $cust_pay->paynum, - 'actionlabel' => emt('Apply payment'), - %cust_bill_pay_width, - %cust_bill_pay_height, - ). - ')'; - } - if ( $opt{total_unapplied_refunds} > 0 ) { - $apply.= ' ('. - include( '/elements/popup_link.html', - 'label' => emt('apply to refund'), - 'action' => "${p}edit/cust_pay_refund.cgi?". - $cust_pay->paynum, - 'actionlabel' => emt('Apply payment to refund'), - 'width' => 392, - ). - ')'; - } - } $desc .= '<BR>'; } } +if ($unapplied > 0) { + if ( $opt{'Apply payment'} ) { + if ( $opt{total_owed} > 0 ) { + $apply = ' ('. + include( '/elements/popup_link.html', + 'label' => emt('apply'), + 'action' => "${p}edit/cust_bill_pay.cgi?". + $cust_pay->paynum, + 'actionlabel' => emt('Apply payment'), + %cust_bill_pay_width, + %cust_bill_pay_height, + ). + ')'; + } + if ( $opt{total_unapplied_refunds} > 0 ) { + $apply.= ' ('. + include( '/elements/popup_link.html', + 'label' => emt('apply to refund'), + 'action' => "${p}edit/cust_pay_refund.cgi?". + $cust_pay->paynum, + 'actionlabel' => emt('Apply payment to refund'), + 'width' => 392, + ). + ')'; + } + $apply .= ' (auto‑apply: ' + . ($cust_pay->no_auto_apply ? 'no' : 'yes') + . ' | ' + . include( '/elements/popup_link.html', + 'label' => emt($cust_pay->no_auto_apply ? 'yes' : 'no'), + 'action' => "${p}edit/process/cust_pay-no_auto_apply.cgi?paynum=" + . $cust_pay->paynum + . '&no_auto_apply=' + . ($cust_pay->no_auto_apply ? '' : 'Y'), + 'actionlabel' => emt('Toggle Auto-Apply'), + 'width' => 392, + 'height' => 200, + ) + . ')'; + } else { # end if $opt('Apply payment') + $apply .= ' (no auto-apply)' if $cust_pay->no_auto_apply; + } +} # end if $unapplied > 0 + my $view = ' ('. include('/elements/popup_link.html', 'label' => emt('view receipt'), |