summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/Conf.pm7
-rw-r--r--FS/FS/Template_Mixin.pm23
-rw-r--r--FS/FS/cust_bill.pm9
-rw-r--r--httemplate/edit/elements/edit.html6
-rw-r--r--httemplate/elements/tr-amount_fee.html4
-rw-r--r--httemplate/elements/tr-select-invoice.html43
-rw-r--r--httemplate/elements/tr-select-payment_options.html94
-rw-r--r--httemplate/misc/payment.cgi14
8 files changed, 166 insertions, 34 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 59f9b69fc..9b891879b 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -2753,13 +2753,6 @@ and customer address. Include units.',
},
{
- 'key' => 'manual_process-single_invoice_amount',
- 'section' => 'payments',
- 'description' => 'When entering manual credit card and ACH payments, amount will not autofill if the customer has more than one open invoice',
- 'type' => 'checkbox',
- },
-
- {
'key' => 'manual_process-pkgpart',
'section' => 'payments',
'description' => 'Package to add to each manual credit card and ACH payment entered by employees from the backend. WARNING: Although recently permitted to US merchants in general, specific consumer protection laws may prohibit or restrict this practice in California, Colorado, Connecticut, Florda, Kansas, Maine, Massachusetts, New York, Oklahome, and Texas. Surcharging is also generally prohibited in most countries outside the US, AU and UK.',
diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm
index 7d92d21af..b9f3e9274 100644
--- a/FS/FS/Template_Mixin.pm
+++ b/FS/FS/Template_Mixin.pm
@@ -1955,6 +1955,23 @@ sub due_date2str {
$self->due_date ? $self->time2str_local(shift, $self->due_date) : '';
}
+=item invoice_pay_by_msg
+
+ displays the invoice_pay_by_msg or default Please pay by [_1] if empty.
+
+=cut
+
+sub invoice_pay_by_msg {
+ my $self = shift;
+ my $msg = '';
+ my $please_pay_by =
+ $self->conf->config('invoice_pay_by_msg', $self->agentnum)
+ || 'Please pay by [_1]';
+ $msg .= ' - ' . $self->mt($please_pay_by, $self->due_date2str('short')) . ' ';
+
+ $msg;
+}
+
=item balance_due_msg
=cut
@@ -1969,11 +1986,7 @@ sub balance_due_msg {
# _items_total) and not here
# (yes, or if invoice_sections is enabled; this is just for compatibility)
if ( $self->due_date ) {
- my $please_pay_by =
- $self->conf->config('invoice_pay_by_msg', $self->agentnum)
- || 'Please pay by [_1]';
- $msg .= ' - ' . $self->mt($please_pay_by, $self->due_date2str('short')).
- ' '
+ $msg .= $self->invoice_pay_by_msg
unless $self->conf->config_bool('invoice_omit_due_date',$self->agentnum);
} elsif ( $self->terms ) {
$msg .= ' - '. $self->mt($self->terms);
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 5ae4f3686..8b94dcc87 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -3450,17 +3450,12 @@ sub _items_total {
$total_descr = $self->mt('Total Charges');
}
- if ( $conf->exists('invoice_show_prior_due_date') ) {
+ if ( $conf->exists('invoice_show_prior_due_date') && !$conf->exists('invoice_omit_due_date') ) {
# then the due date should be shown with Total New Charges,
# and should NOT be shown with the Balance Due message.
if ( $self->due_date ) {
- $total_descr = join(' ',
- $total_descr,
- '-',
- $self->mt('Please pay by'),
- $self->due_date2str('short')
- );
+ $total_descr .= $self->invoice_pay_by_msg;
} elsif ( $self->terms ) {
$total_descr = join(' ',
$total_descr,
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 2f82f9c99..8ba703a2f 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -872,7 +872,9 @@ my $pkey = dbdef->table($table)->primary_key; #? $opt{'primary_key'} ||
my $fields = $opt{'fields'}
#|| [ grep { $_ ne $pkey } dbdef->table($table)->columns ];
|| [ grep { $_ ne $pkey } fields($table) ];
-#my @actualfields = map { ref($_) ? $_->{'field'} : $_ } @$fields;
+my @actualfields = map { ref($_) ? $_->{'field'} : $_ } @$fields;
+
+push @actualfields, $pkey;
my $js_form_validate = {};
@@ -915,7 +917,7 @@ if ( $opt{'embed'} ) {
$mode = 'error';
$object = $class->new( {
- map { $_ => scalar($cgi->param($_)) } fields($table)
+ map { $_ => scalar($cgi->param($_)) } @actualfields
});
&{$opt{'error_callback'}}( $cgi, $object, $fields, \%opt )
diff --git a/httemplate/elements/tr-amount_fee.html b/httemplate/elements/tr-amount_fee.html
index 12488521a..9c13f5952 100644
--- a/httemplate/elements/tr-amount_fee.html
+++ b/httemplate/elements/tr-amount_fee.html
@@ -1,4 +1,4 @@
- <TR>
+ <TR ID="payment_amount_row" <% $opt{'row_style'} %>>
<TH ALIGN="right"><% mt('Payment amount') |h %></TH>
<TD COLSPAN=7>
<TABLE><TR><TD BGCOLOR="#ffffff">
@@ -15,7 +15,7 @@
onKeyPress = "amount_changed(this)"
% }
>
- </TD><TD BGCOLOR="#cccccc">
+ </TD><TD BGCOLOR="<% length($fee) ? '#cccccc' : '#ffffff' %>">
% if ( $fee ) {
<INPUT TYPE="hidden" NAME="fee_pkgpart" VALUE="<% $fee_pkg->pkgpart %>">
<INPUT TYPE="hidden" NAME="fee" VALUE="<% $fee_display eq 'add' ? $fee : '' %>">
diff --git a/httemplate/elements/tr-select-invoice.html b/httemplate/elements/tr-select-invoice.html
new file mode 100644
index 000000000..3728d348d
--- /dev/null
+++ b/httemplate/elements/tr-select-invoice.html
@@ -0,0 +1,43 @@
+<%doc>
+
+Example:
+
+ include( '/elements/tr-select-invoice.html',
+
+ #opt - most get used in /elements/tr-amount-fee
+ 'custnum' => 4, # customer number,
+ 'prefix' => 'pre', # prefix to fields and row ID's
+ )
+
+</%doc>
+
+ <TR ID="invoice_row" STYLE="display:none;">
+ <TH ALIGN="right"><% mt('Open invoices') |h %></TH>
+ <TD COLSPAN=7>
+ <SELECT
+ ID = "<% $opt{prefix} %>invoice"
+ NAME = "<% $opt{prefix} %>invoice"
+ onChange = "<% $opt{prefix} %>invoice_select_changed(this)"
+ >
+ <OPTION VALUE="select">Select an invoice to pay</OPTION>
+% foreach my $record (@records) {
+% my $read_date = time2str("%b %o, %Y", $record->_date);
+ <OPTION VALUE="<% $record->charged %>"><% $record->invnum %> (<% $read_date %>) - <% $record->charged %></OPTION>
+% }
+
+ </SELECT>
+ </TD>
+ </TR>
+
+<%init>
+
+my %opt = @_;
+
+my @records = qsearch( {
+ 'select' => '*',
+ 'table' => 'cust_bill',
+ 'hashref' => { 'custnum' => $opt{custnum} },
+ 'order_by' => 'ORDER BY _date',
+});
+
+</%init>
diff --git a/httemplate/elements/tr-select-payment_options.html b/httemplate/elements/tr-select-payment_options.html
new file mode 100644
index 000000000..2304c22d0
--- /dev/null
+++ b/httemplate/elements/tr-select-payment_options.html
@@ -0,0 +1,94 @@
+<%doc>
+
+Example:
+
+ include( '/elements/tr-select-payment_options.html',
+
+ #opt - most get used in /elements/tr-amount-fee
+ 'custnum' => 4, # customer number needed for selecting invoices
+ 'prefix' => 'pre', # prefix to fields and row ID's
+ 'amount' => 1, # payment amount
+ 'process-pkgpart' => scalar($conf->config('manual_process-pkgpart', $cust_main->agentnum)),
+ 'process-display' => scalar($conf->config('manual_process-display')),
+ 'process-skip_first' => $conf->exists('manual_process-skip_first'),
+ 'num_payments' => scalar($cust_main->cust_pay),
+ 'surcharge_percentage' =>
+ ( $payby eq 'CARD'
+ ? scalar($conf->config('credit-card-surcharge-percentage', $cust_main->agentnum))
+ : 0
+ ),
+ )
+
+</%doc>
+
+ <TR STYLE="display:block">
+ <TH ALIGN="right"><% mt('Payment options') |h %></TH>
+ <TD COLSPAN=7>
+ <SELECT
+ ID = "<% $opt{prefix} %>payment_option"
+ NAME = "<% $opt{prefix} %>payment_option"
+ onChange = "<% $opt{prefix} %>payment_option_changed(this)"
+ <% $opt{disabled} %>
+ >
+ <OPTION VALUE="select">Select payment option</OPTION>
+ <OPTION VALUE="<% $opt{amount} %>">Pay full balance</OPTION>
+ <OPTION VALUE="invoice">Pay specific invoice</OPTION>
+ <OPTION VALUE="">Pay specific amount</OPTION>
+ </SELECT>
+ </TD>
+ </TR>
+
+ <& /elements/tr-select-invoice.html,
+ 'custnum' => $opt{custnum},
+ 'prefix' => $opt{prefix},
+ &>
+
+ <& /elements/tr-amount_fee.html,
+ 'row_style' => 'STYLE="display:none;"',
+ %opt
+ &>
+
+ <SCRIPT TYPE="text/javascript">
+
+ function <% $opt{prefix} %>payment_option_changed(what) {
+
+ if ( what.value == 'select' ) {
+ document.getElementById('payment_amount_row').style.display = 'none';
+ document.getElementById('invoice_row').style.display = 'none';
+ document.getElementById('<% $opt{prefix} %>invoice').value = 'select';
+ document.getElementById('amount').value = '';
+ }
+ else if ( what.value == 'invoice' ) {
+ document.getElementById('payment_amount_row').style.display = 'none';
+ document.getElementById('invoice_row').style.display = 'block';
+ document.getElementById('amount').value = '';
+ }
+ else {
+ document.getElementById('payment_amount_row').style.display = 'block';
+ document.getElementById('invoice_row').style.display = 'none';
+ document.getElementById('<% $opt{prefix} %>invoice').value = 'select';
+ document.getElementById('amount').value = what.value;
+ }
+
+ }
+
+ function <% $opt{prefix} %>invoice_select_changed(what) {
+
+ if ( what.value == 'select' ) {
+ document.getElementById('payment_amount_row').style.display = 'none';
+ document.getElementById('amount').value = '';
+ }
+ else {
+ document.getElementById('payment_amount_row').style.display = 'block';
+ document.getElementById('amount').value = what.value;
+ }
+
+ }
+
+</SCRIPT>
+
+<%init>
+
+my %opt = @_;
+
+</%init> \ No newline at end of file
diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi
index 35f57e8d6..5bfa29d70 100644
--- a/httemplate/misc/payment.cgi
+++ b/httemplate/misc/payment.cgi
@@ -12,8 +12,9 @@
<TABLE class="fsinnerbox">
- <& /elements/tr-amount_fee.html,
- 'amount' => $amount,
+ <& /elements/tr-select-payment_options.html,
+ 'custnum' => $cust_main->custnum,
+ 'amount' => $balance,
'process-pkgpart' =>
scalar($conf->config('manual_process-pkgpart', $cust_main->agentnum)),
'process-display' => scalar($conf->config('manual_process-display')),
@@ -356,15 +357,6 @@ my %states = map { $_->state => 1 }
} );
my @states = sort { $a cmp $b } keys %states;
-my $amount = '';
-if ( $balance > 0 ) {
- # when configured to do so, amount will only auto-fill with balance
- # if balance represents a single invoice
- $amount = $balance
- unless $conf->exists('manual_process-single_invoice_amount')
- && ($cust_main->open_cust_bill != 1);
-}
-
my $payunique = "webui-payment-". time. "-$$-". rand() * 2**32;
</%init>