From a53dc991aa0c04c5b9a5d06256100af5e93943e1 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 Mar 2009 10:34:30 +0000 Subject: apply byte values from prepaid cards as well as time value, RT#4995 --- httemplate/misc/process/recharge_svc.html | 103 +++++++++++++++--------------- 1 file changed, 51 insertions(+), 52 deletions(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/process/recharge_svc.html b/httemplate/misc/process/recharge_svc.html index 147b9533a..8c4d13e63 100755 --- a/httemplate/misc/process/recharge_svc.html +++ b/httemplate/misc/process/recharge_svc.html @@ -1,62 +1,13 @@ -%unless ($error) { -% -% my ($amount, $seconds, $up, $down, $total) = (0, 0, 0, 0, 0); -% #should probably use payby.pm but whatever -% if ($payby eq 'PREP') { -% $error = $cust_main->get_prepay($prepaid, \$amount, \$seconds, \$up, \$down, \$total) -% || $svc_acct->increment_seconds($seconds) -% || $svc_acct->increment_upbytes($up) -% || $svc_acct->increment_downbytes($down) -% || $svc_acct->increment_totalbytes($total) -% || $cust_main->insert_cust_pay_prepay( $amount, $prepaid ); -% } elsif ( $payby =~ /^(CARD|DCRD|CHEK|DCHK|LECB|BILL|COMP)$/ ) { -% my $part_pkg = $svc_acct->cust_svc->cust_pkg->part_pkg; -% $amount = $part_pkg->option('recharge_amount', 1); -% my %rhash = map { $_ =~ /^recharge_(.*)$/; $1, $part_pkg->option($_) } -% grep { $part_pkg->option($_, 1) } -% qw ( recharge_seconds recharge_upbytes recharge_downbytes -% recharge_totalbytes ); -% -% my $description = "Recharge"; -% $description .= " $rhash{seconds}s" if $rhash{seconds}; -% $description .= " $rhash{upbytes} up" if $rhash{upbytes}; -% $description .= " $rhash{downbytes} down" if $rhash{downbytes}; -% $description .= " $rhash{totalbytes} total" if $rhash{totalbytes}; -% -% $error = $cust_main->charge($amount, "Recharge " . $svc_acct->label, -% $description, $part_pkg->taxclass); -% -% if ($part_pkg->option('recharge_reset', 1)) { -% $error ||= $svc_acct->set_usage(\%rhash); -% }else{ -% $error ||= $svc_acct->recharge(\%rhash); -% } -% -% my $old_balance = $cust_main->balance; -% $error ||= $cust_main->bill; -% $error ||= $cust_main->apply_payments_and_credits; -% my $bill_error = $cust_main->collect('realtime' => 1) unless $error; -% $error ||= "Failed to collect - $bill_error" -% if $cust_main->balance > $old_balance && $cust_main->balance > 0 -% && $payby ne 'BILL'; -% -% } else { -% $error = "fatal error - unknown payby: $payby"; -% } -%} -% %if ($error) { % $cgi->param('error', $error); -% $dbh->rollback if $oldAutoCommit; -% print $cgi->redirect(popurl(2). "recharge_svc.html?". $cgi->query_string ); -%} -%$dbh->commit or die $dbh->errstr if $oldAutoCommit; -% +<% cgi->redirect(popurl(2). "recharge_svc.html?". $cgi->query_string ) %> +%} else { <% header("Package recharged") %> +%} <%init> my $conf = new FS::Conf; @@ -89,4 +40,52 @@ my $oldAutoCommit = $FS::UID::AutoCommit; local $FS::UID::AutoCommit = 0; my $dbh = dbh; +unless ($error) { + + #should probably use payby.pm but whatever + if ($payby eq 'PREP') { + $error = $cust_main->recharge_prepay( $prepaid ); + } elsif ( $payby =~ /^(CARD|DCRD|CHEK|DCHK|LECB|BILL|COMP)$/ ) { + my $part_pkg = $svc_acct->cust_svc->cust_pkg->part_pkg; + $amount = $part_pkg->option('recharge_amount', 1); + my %rhash = map { $_ =~ /^recharge_(.*)$/; $1, $part_pkg->option($_) } + grep { $part_pkg->option($_, 1) } + qw ( recharge_seconds recharge_upbytes recharge_downbytes + recharge_totalbytes ); + + my $description = "Recharge"; + $description .= " $rhash{seconds}s" if $rhash{seconds}; + $description .= " $rhash{upbytes} up" if $rhash{upbytes}; + $description .= " $rhash{downbytes} down" if $rhash{downbytes}; + $description .= " $rhash{totalbytes} total" if $rhash{totalbytes}; + + $error = $cust_main->charge($amount, "Recharge " . $svc_acct->label, + $description, $part_pkg->taxclass); + + if ($part_pkg->option('recharge_reset', 1)) { + $error ||= $svc_acct->set_usage(\%rhash); + }else{ + $error ||= $svc_acct->recharge(\%rhash); + } + + my $old_balance = $cust_main->balance; + $error ||= $cust_main->bill; + $error ||= $cust_main->apply_payments_and_credits; + my $bill_error = $cust_main->collect('realtime' => 1) unless $error; + $error ||= "Failed to collect - $bill_error" + if $cust_main->balance > $old_balance && $cust_main->balance > 0 + && $payby ne 'BILL'; + + } else { + $error = "fatal error - unknown payby: $payby"; + } + +} + +if ($error) { + $dbh->rollback if $oldAutoCommit; +} else { + $dbh->commit or die $dbh->errstr if $oldAutoCommit; +} + -- cgit v1.2.1 From 26119738eaf2b519d91c855c23986f873303887f Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 16 Mar 2009 07:14:29 +0000 Subject: allow country selection on credit card entry, RT#4997 --- httemplate/misc/payment.cgi | 59 ++++++++----------------------------- httemplate/misc/process/payment.cgi | 2 +- 2 files changed, 14 insertions(+), 47 deletions(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi index 004700488..45aeacad4 100644 --- a/httemplate/misc/payment.cgi +++ b/httemplate/misc/payment.cgi @@ -12,7 +12,7 @@ <% ntable('#cccccc') %> - Payment amount + Payment amount - - + - +% if ( $fee ) { + + + +% } + + % if ( $payby eq 'CARD' ) { % % my( $payinfo, $paycvv, $month, $year ) = ( '', '', '', '' ); @@ -237,16 +287,29 @@ my $balance = $cust_main->balance; my $payinfo = ''; -#false laziness w/selfservice make_payment.html shortcut for one-country my $conf = new FS::Conf; + +my $money_char = $conf->config('money_char') || '$'; + +#false laziness w/selfservice make_payment.html shortcut for one-country my %states = map { $_->state => 1 } qsearch('cust_main_county', { 'country' => $conf->config('countrydefault') || 'US' } ); my @states = sort { $a cmp $b } keys %states; -my $payunique = "webui-payment-". time. "-$$-". rand() * 2**32; +my $fee = ''; +my $fee_pkg = ''; +if ( $conf->config('manual_process-pkgpart') ) { + $fee_pkg = + qsearchs('part_pkg', { pkgpart=>$conf->config('manual_process-pkgpart') } ); - + #well ->unit_setup or ->calc_setup both call for a $cust_pkg + # (though ->unit_setup doesn't use it...) + $fee = $fee_pkg->option('setup_fee') + if $fee_pkg; #in case.. better than dying with a perl traceback +} +my $payunique = "webui-payment-". time. "-$$-". rand() * 2**32; + diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi index ea0c7946d..d41bc0f14 100644 --- a/httemplate/misc/process/payment.cgi +++ b/httemplate/misc/process/payment.cgi @@ -32,6 +32,11 @@ $cgi->param('amount') =~ /^\s*(\d*(\.\d\d)?)\s*$/ my $amount = $1; errorpage("amount <= 0") unless $amount > 0; +if ( $cgi->param('fee') =~ /^\s*(\d*(\.\d\d)?)\s*$/ ) { + my $fee = $1; + $amount = sprintf('%.2f', $amount + $fee); +} + $cgi->param('year') =~ /^(\d+)$/ or errorpage("illegal year ". $cgi->param('year')); my $year = $1; @@ -143,6 +148,15 @@ if ( $cgi->param('batch') ) { ); errorpage($error) if $error; + #no error, so order the fee package if applicable... + if ( $cgi->param('fee_pkgpart') =~ /^(\d+)$/ ) { + my $error = $cust_main->order_pkg( + 'cust_pkg' => new FS::cust_pkg { 'pkgpart' => $1 } + ); + errorpage("payment processed successfully, but error ordering fee: $error") + if $error; + } + $cust_main->apply_payments; } -- cgit v1.2.1 From c33e009d50f9af054a5a0195eca5df31c4fb9539 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 29 Sep 2009 22:08:39 +0000 Subject: should fix newsletter sending error when you select a single payby only --- httemplate/misc/email-customers.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/email-customers.html b/httemplate/misc/email-customers.html index 0d3d622c3..f644db9e9 100644 --- a/httemplate/misc/email-customers.html +++ b/httemplate/misc/email-customers.html @@ -126,7 +126,7 @@ die "access denied" my %search = $cgi->Vars; delete $search{$_} for qw( magic from subject html_body text_body ); $search{$_} = [ split(/\0/, $search{$_}) ] - foreach grep $search{$_} =~ /\0/, keys %search; + foreach grep { $_ eq 'payby' || $search{$_} =~ /\0/ } keys %search; my $title = 'Bulk send customer notices'; -- cgit v1.2.1 From 3a02e398ce013116c6ee97fc18472a6f40e0798d Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 4 Oct 2009 02:09:14 +0000 Subject: delete invoices, RT#4048 --- httemplate/misc/delete-cust_bill.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 httemplate/misc/delete-cust_bill.html (limited to 'httemplate/misc') diff --git a/httemplate/misc/delete-cust_bill.html b/httemplate/misc/delete-cust_bill.html new file mode 100644 index 000000000..3a642b0e9 --- /dev/null +++ b/httemplate/misc/delete-cust_bill.html @@ -0,0 +1,21 @@ +% if ( $error ) { +% errorpage($error); +% } else { +<% $cgi->redirect($p. "view/cust_main.cgi?". $custnum) %> +% } +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Delete invoices'); + +#untaint invnum +my($query) = $cgi->keywords; +$query =~ /^(\d+)$/ || die "Illegal crednum"; +my $invnum = $1; + +my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); +my $custnum = $cust_bill->custnum; + +my $error = $cust_bill->delete; + + -- cgit v1.2.1 From 0c2679eee18b3b073bc91657fcf85c5dd2e5efc0 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 5 Oct 2009 02:16:46 +0000 Subject: add manual_process-display config to subtract fee from amount instead of adding, RT#5889 --- httemplate/misc/payment.cgi | 27 ++++++++++++++++++++------- httemplate/misc/process/payment.cgi | 13 ++++++++++--- 2 files changed, 30 insertions(+), 10 deletions(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi index 472763b2d..d35e73f14 100644 --- a/httemplate/misc/payment.cgi +++ b/httemplate/misc/payment.cgi @@ -10,8 +10,6 @@ % #include( '/elements/table.html', '#cccccc' ) -% my $amount = $balance > 0 ? sprintf("%.2f", $balance) : ''; - <% ntable('#cccccc') %> @@ -32,14 +30,14 @@
$"> @@ -24,11 +24,6 @@ % % my( $payinfo, $paycvv, $month, $year ) = ( '', '', '', '' ); % my $payname = $cust_main->first. ' '. $cust_main->getfield('last'); -% my $address1 = $cust_main->address1; -% my $address2 = $cust_main->address2; -% my $city = $cust_main->city; -% my $state = $cust_main->state; -% my $zip = $cust_main->zip; % if ( $cust_main->payby =~ /^(CARD|DCRD)$/ ) { % $payinfo = $cust_main->paymask; % $paycvv = $cust_main->paycvv; @@ -37,13 +32,13 @@ % }
Card number + Card number - + - + - + - - - - - - - - - + <% include( '/elements/location.html', + 'object' => $cust_main, #XXX errors??? + 'no_asterisks' => 1, + 'address1_label' => 'Card billing address', + ) + %> + % } elsif ( $payby eq 'CHEK' ) { % % my( $payinfo1, $payinfo2, $payname, $ss, $paytype, $paystate, diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi index 2baca1e39..ea0c7946d 100644 --- a/httemplate/misc/process/payment.cgi +++ b/httemplate/misc/process/payment.cgi @@ -44,7 +44,7 @@ $cgi->param('payby') =~ /^(CARD|CHEK)$/ or errorpage("illegal payby ". $cgi->param('payby')); my $payby = $1; my %payby2fields = ( - 'CARD' => [ qw( address1 address2 city state zip ) ], + 'CARD' => [ qw( address1 address2 city county state zip country ) ], 'CHEK' => [ qw( ss paytype paystate stateid stateid_state ) ], ); my %type = ( 'CARD' => 'credit card', -- cgit v1.2.1 From 1613980c5c93d0bdf8699d44ff22ecf828abf122 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 22 Mar 2009 02:47:36 +0000 Subject: fix usps address standardization when the zip returned has no zip+4, RT#4882 --- httemplate/misc/xmlhttp-cust_main-address_standardize.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/xmlhttp-cust_main-address_standardize.html b/httemplate/misc/xmlhttp-cust_main-address_standardize.html index 72fa4a464..3b9e142f5 100644 --- a/httemplate/misc/xmlhttp-cust_main-address_standardize.html +++ b/httemplate/misc/xmlhttp-cust_main-address_standardize.html @@ -50,6 +50,9 @@ if ( $sub eq 'address_standardize' ) { unless ( $verifier->is_error ) { + my $zip = $hash->{Zip5}; + $zip .= '-'. $hash->{Zip4} if $hash->{Zip4} =~ /\d/; + $return = { %$return, "new_$pre".'company' => $hash->{FirmName}, @@ -57,7 +60,7 @@ if ( $sub eq 'address_standardize' ) { "new_$pre".'address2' => $hash->{Address1}, "new_$pre".'city' => $hash->{City}, "new_$pre".'state' => $hash->{State}, - "new_$pre".'zip' => $hash->{Zip5}. '-'. $hash->{Zip4}, + "new_$pre".'zip' => $zip, }; my @fields = (qw( company address1 address2 city state zip )); #hmm -- cgit v1.2.1 From 42682206b4ba30de01c82743042f5fb9d48a93ed Mon Sep 17 00:00:00 2001 From: jeff Date: Mon, 23 Mar 2009 23:33:04 +0000 Subject: more DTRT with usage on service transfer between packages and recharges RT #2884, #5040 + #4995 fallout --- httemplate/misc/process/recharge_svc.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/process/recharge_svc.html b/httemplate/misc/process/recharge_svc.html index 8c4d13e63..5f68bf151 100755 --- a/httemplate/misc/process/recharge_svc.html +++ b/httemplate/misc/process/recharge_svc.html @@ -1,6 +1,6 @@ %if ($error) { % $cgi->param('error', $error); -<% cgi->redirect(popurl(2). "recharge_svc.html?". $cgi->query_string ) %> +<% $cgi->redirect(popurl(2). "recharge_svc.html?". $cgi->query_string ) %> %} else { <% header("Package recharged") %> + + + + % if ( $conf->exists('pkg_referral') ) { <% include('/elements/tr-select-part_referral.html', 'curr_value' => scalar( $cgi->param('refnum') ), #get rid of empty_label first# || $cust_main->refnum, @@ -68,4 +101,8 @@ my $cust_main = qsearchs({ my $pkgpart = scalar($cgi->param('pkgpart')); +my $format = "%m/%d/%Y %T %z (%Z)"; #false laziness w/REAL_cust_pkg.cgi? +my $start_date = $cust_main->next_bill_date; +$start_date = $start_date ? time2str($format, $start_date) : ''; + -- cgit v1.2.1 From d1014a727cefa5d9813153594541f62ec15fc8b9 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 12 Aug 2009 02:36:25 +0000 Subject: fix multiple pkgpart search, RT#5924 --- httemplate/misc/bulk_change_pkg.cgi | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/bulk_change_pkg.cgi b/httemplate/misc/bulk_change_pkg.cgi index 3bb677581..7f47a84cf 100755 --- a/httemplate/misc/bulk_change_pkg.cgi +++ b/httemplate/misc/bulk_change_pkg.cgi @@ -7,17 +7,23 @@
- -% for my $param (qw(agentnum magic status classnum pkgpart)) { - +%# some false laziness w/search/cust_pkg.cgi + + +% for my $param (qw(agentnum magic status classnum custom censustract)) { + % } % +% foreach my $pkgpart ($cgi->param('pkgpart')) { + +% } +% % foreach my $field (qw( setup last_bill bill adjourn susp expire cancel )) { % - "> - "> - "> - "> + "> + "> + "> + "> % } <% ntable('#cccccc') %> -- cgit v1.2.1 From 1e34f4a5d142bd58f5918219db0931e81ad0418e Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 20 Aug 2009 09:47:05 +0000 Subject: email statements, RT#4860 --- httemplate/misc/email-statement.cgi | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 httemplate/misc/email-statement.cgi (limited to 'httemplate/misc') diff --git a/httemplate/misc/email-statement.cgi b/httemplate/misc/email-statement.cgi new file mode 100755 index 000000000..67f654d64 --- /dev/null +++ b/httemplate/misc/email-statement.cgi @@ -0,0 +1,19 @@ +<% $cgi->redirect("${p}view/cust_main.cgi?$custnum") %> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Resend invoices'); + +#untaint statementnum +my($query) = $cgi->keywords; +$query =~ /^((.+)-)?(\d+)$/; +my $template = $2 || 'statement'; #XXX configure... via event?? eh.. +my $statementnum = $3; +my $cust_statement = qsearchs('cust_statement',{'statementnum'=>$statementnum}); +die "Can't find statement!\n" unless $cust_statement; + +$cust_statement->email($template); + +my $custnum = $cust_statement->getfield('custnum'); + + -- cgit v1.2.1 From ccdc300b0e5183fba812e6fb1d74e957ea3e2b44 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 22 Aug 2009 00:31:04 +0000 Subject: mason style --- httemplate/misc/states.cgi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/states.cgi b/httemplate/misc/states.cgi index cf2b46ee2..02b7be4af 100644 --- a/httemplate/misc/states.cgi +++ b/httemplate/misc/states.cgi @@ -1,7 +1,7 @@ -% -% -% my $country = $cgi->param('arg'); -% my @output = states_hash($country); -% -% [ <% join(', ', map { qq("$_") } @output) %> ] +<%init> + +my $country = $cgi->param('arg'); +my @output = states_hash($country); + + -- cgit v1.2.1 From 9ecb64360568b205334ae23e1051249cb56491b6 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 14 Sep 2009 23:52:01 +0000 Subject: ping tool, RT#5845 --- httemplate/misc/ping.html | 102 ++++++++++++++++++++++++++++++++++++++ httemplate/misc/xmlhttp-ping.html | 20 ++++++++ 2 files changed, 122 insertions(+) create mode 100644 httemplate/misc/ping.html create mode 100644 httemplate/misc/xmlhttp-ping.html (limited to 'httemplate/misc') diff --git a/httemplate/misc/ping.html b/httemplate/misc/ping.html new file mode 100644 index 000000000..4f0360e8b --- /dev/null +++ b/httemplate/misc/ping.html @@ -0,0 +1,102 @@ +<% include('/elements/header-popup.html', "Ping $ip" ) %> + +<% include('/elements/xmlhttp.html', + 'url' => $p. 'misc/xmlhttp-ping.html', + 'subs' => [ 'ping' ], + ) +%> + +%# + + +<%ntable("#cccccc", 2)%> + +
+ + + + + + + + + + + + + + + + +
Exp.Exp.
CVV2CVV2 (help)
Exact name on cardExact name on card
Card billing address - -
Address line 2 - -
City - - - - - - - - -
- - State - - Zip - -
-
StatusChecking...
Packet loss
Latency
Packets
+ +
+
+ +
+ + + +<%init> + +my($query) = $cgi->keywords; +$query =~ /^([\d\.]+)$/ or die 'Illegal IP'; +my $ip = $1; + + diff --git a/httemplate/misc/xmlhttp-ping.html b/httemplate/misc/xmlhttp-ping.html new file mode 100644 index 000000000..e99303207 --- /dev/null +++ b/httemplate/misc/xmlhttp-ping.html @@ -0,0 +1,20 @@ +<% objToJson($return) %> +<%init> + +my $conf = new FS::Conf; + +my $sub = $cgi->param('sub'); + +die "$sub not supported" unless $sub eq 'ping'; + +my $ip = $cgi->param('arg'); + +my $ping = new Net::Ping('external', 5); +$ping->hires(1); +#my $a=time; warn "pinging\n"; +my ($ret, $duration, $ip2) = $ping->ping($ip); +#warn "done pinging (". int(time-$a). "s)\n"; + +my $return = [ $ret, $duration ]; + + -- cgit v1.2.1 From 25b0525eb1f0d018b893a7bdc96b92a8f446020f Mon Sep 17 00:00:00 2001 From: mark Date: Fri, 25 Sep 2009 02:30:21 +0000 Subject: Batch payment refactoring --- httemplate/misc/download-batch.cgi | 200 +------------------------------------ 1 file changed, 5 insertions(+), 195 deletions(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/download-batch.cgi b/httemplate/misc/download-batch.cgi index 57905daf9..01bf5d25f 100644 --- a/httemplate/misc/download-batch.cgi +++ b/httemplate/misc/download-batch.cgi @@ -1,146 +1,9 @@ -%if ($format eq "BoM") { -% -% my($origid,$datacenter,$typecode,$shortname,$longname,$mybank,$myacct) = -% $conf->config("batchconfig-$format"); -% -<% sprintf( "A%10s%04u%06u%05u%54s\n",$origid,$pay_batch->batchnum,$jdate,$datacenter,""). - sprintf( "XD%03u%06u%-15s%-30s%09u%-12s \n",$typecode,$jdate,$shortname,$longname,$mybank,$myacct ) - %> -% -%}elsif ($format eq "PAP"){ -% -% my($origid,$datacenter,$typecode,$shortname,$longname,$mybank,$myacct) = -% $conf->config("batchconfig-$format"); -% -<% sprintf( "H%10sD%3s%06u%-15s%09u%-12s%04u%19s\n",$origid,$typecode,$cdate,$shortname,$mybank,$myacct,$pay_batch->batchnum,"") %> -% -% -%}elsif ($format eq "csv-td_canada_trust-merchant_pc_batch"){ -%# 1; -%}elsif ($format eq "csv-chase_canada-E-xactBatch"){ -% -% my($origid) = $conf->config("batchconfig-$format"); -<% sprintf( '$$E-xactBatchFileV1.0$$%s:%03u$$%s',$sdate,$pay_batch->batchnum, $origid) - %> -% -%}elsif ($format eq "ach-spiritone"){ -%# 1; -%}else{ -% die "Unknown format for batch in batchconfig. \n"; -%} -% -% -%for my $cust_pay_batch ( sort { $a->paybatchnum <=> $b->paybatchnum } -% qsearch('cust_pay_batch', -% {'batchnum'=>$pay_batch->batchnum} ) -%) { -% -% $cust_pay_batch->exp =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/; -% my( $mon, $y ) = ( $2, $1 ); -% if ( $conf->exists('batch-increment_expiration') ) { -% my( $curmon, $curyear ) = (localtime(time))[4,5]; -% $curmon++; $curyear-=100; -% $y++ while $y < $curyear || ( $y == $curyear && $mon < $curmon ); -% } -% $mon = "0$mon" if $mon =~ /^\d$/; -% $y = "0$y" if $y =~ /^\d$/; -% my $exp = "$mon$y"; -% -% if ( $first_download ) { -% my $balance = $cust_pay_batch->cust_main->balance; -% if ( $balance <= 0 ) { -% my $error = $cust_pay_batch->delete; -% if ( $error ) { -% $dbh->rollback or die $dbh->errstr if $oldAutoCommit; -% die $error; -% } -% next; -% } elsif ( $balance < $cust_pay_batch->amount ) { -% $cust_pay_batch->amount($balance); -% my $error = $cust_pay_batch->replace; -% if ( $error ) { -% $dbh->rollback or die $dbh->errstr if $oldAutoCommit; -% die $error; -% } -% #} elsif ( $balance > $cust_pay_batch->amount ) { -% } -% } -% -% $batchcount++; -% $batchtotal += $cust_pay_batch->amount; -% -% if ($format eq "BoM") { -% -% my( $account, $aba ) = split( '@', $cust_pay_batch->payinfo ); -% -<% sprintf( "D%010.0f%09u%-12s%-29s%-19s\n",$cust_pay_batch->amount*100,$aba,$account,$cust_pay_batch->payname,$cust_pay_batch->paybatchnum) %> -% -% -% } elsif ($format eq "PAP"){ -% -% my( $account, $aba ) = split( '@', $cust_pay_batch->payinfo ); -% -<% sprintf( "D%-23s%06u%-19s%09u%-12s%010.0f\n",$cust_pay_batch->payname,$cdate,$cust_pay_batch->paybatchnum,$aba,$account,$cust_pay_batch->amount*100) %> -% -% -% } elsif ($format eq "csv-td_canada_trust-merchant_pc_batch") { -% -% -,,,,<% $cust_pay_batch->payinfo %>,<% $exp %>,<% $cust_pay_batch->amount %>,<% $cust_pay_batch->paybatchnum %> -% -% -% } elsif ($format eq "csv-chase_canada-E-xactBatch"){ -% -% my $payname=$cust_pay_batch->payname; $payname =~ tr/",/ /; #payinfo too? :P -<% $cust_pay_batch->paybatchnum %>,<% $cust_pay_batch->custnum %>,<% $cust_pay_batch->invnum %>,"<% $payname %>",00,<% $cust_pay_batch->payinfo %>,<% $cust_pay_batch->amount %>,<% $exp %>,, -% -% -% }elsif ($format eq "ach-spiritone"){ -% -% my( $account, $aba ) = split( '@', $cust_pay_batch->payinfo ); -% my $payname=$cust_pay_batch->first. " ". $cust_pay_batch->last; -% $payname =~ tr/",/ /; #payinfo too? -% my $batchline = qq!"$payname","!.$cust_pay_batch->paybatchnum. -% qq!","$aba","$account","27","!.$cust_pay_batch->amount. -% qq!","27","0.00"!; -% push @batchlines, $batchline; -<% $batchline %> -% -% } else { -% die "I'm already dead, but you did not know that.\n"; -% } -% -%} -% -%if ($format eq "BoM") { -% -% -<% sprintf( "YD%08u%014.0f%56s\n",$batchcount,$batchtotal*100,"" ). - sprintf( "Z%014u%05u%014u%05u%41s\n",$batchtotal*100,$batchcount,"0","0","" ) %> -% -% -%} elsif ($format eq "PAP"){ -% -% -<% sprintf( "T%08u%014.0f%57s\n",$batchcount,$batchtotal*100,"" ) %> -% -% -%} elsif ($format eq "csv-td_canada_trust-merchant_pc_batch"){ -% #1; -%} elsif ($format eq "csv-chase_canada-E-xactBatch"){ -% #1; -%} elsif ($format eq "ach-spiritone"){ -% #1; -%} else { -% die "I'm already dead (again), but you did not know that.\n"; -%} -% -<%init> +<% $pay_batch->export_batch($format) %> -my $conf=new FS::Conf; +<%init> #http_header('Content-Type' => 'text/comma-separated-values' ); #IE chokes -http_header('Content-Type' => 'text/plain' ); +http_header('Content-Type' => 'text/plain' ); # not necessarily correct... my $batchnum; if ( $cgi->param('batchnum') =~ /^(\d+)$/ ) { @@ -152,62 +15,9 @@ if ( $cgi->param('batchnum') =~ /^(\d+)$/ ) { my $format; if ( $cgi->param('format') =~ /^([\w\- ]+)$/ ) { $format = $1; -} else { - $format = $conf->config('batch-default_format'); -} - -my $autopost; -if ( $format eq 'ach-spiritone' ) { - $autopost = 1; -}else{ - $autopost = 0; -} - -my $oldAutoCommit = $FS::UID::AutoCommit; -local $FS::UID::AutoCommit = 0; -my $dbh = dbh; - -my $pay_batch = qsearchs('pay_batch', {'batchnum'=>$batchnum, 'status'=>'O'} ); -my $first_download = 1; -unless ($pay_batch) { - $pay_batch = qsearchs('pay_batch', {'batchnum'=>$batchnum, 'status'=>'I'} ) - if $FS::CurrentUser::CurrentUser->access_right('Reprocess batches'); - $first_download = 0; } -die "No pending batch. \n" unless $pay_batch; -my $error = $pay_batch->set_status('I'); -die "error updating batch status: $error\n" if $error; +my $pay_batch = qsearchs('pay_batch', { batchnum => $batchnum } ); +die "Batch not found: '$batchnum'" if !$pay_batch; -my $batchtotal=0; -my $batchcount=0; - -my (@date)=localtime($pay_batch->download); -my $jdate = sprintf("%03d", $date[5] % 100).sprintf("%03d", $date[7] + 1); -my $cdate = sprintf("%02d", $date[3]).sprintf("%02d", $date[4] + 1). - sprintf("%02d", $date[5] % 100); -my $sdate = sprintf("%02d", $date[5] % 100).'/'.sprintf("%02d", $date[4] + 1). - '/'.sprintf("%02d", $date[3]); - -my @batchlines = (); -<%cleanup> -if ($autopost) { - my $dir = $FS::UID::conf_dir. "/cache.". $FS::UID::datasrc; - my $fh = new File::Temp( - TEMPLATE => 'paybatch.'. $batchnum .'.XXXXXXXX', - DIR => $dir, - ) or die "can't open temp file: $!\n"; - - print $fh map{ "$_\n" } @batchlines; - seek $fh, 0, 0; - - $error = $pay_batch->import_results( 'filehandle' => $fh, - 'format' => $format, - ); - die $error if $error; -} - -$dbh->commit or die $dbh->errstr if $oldAutoCommit; - - -- cgit v1.2.1 From 8800e519dc0e4b8eee4ab2cddc74d52c205bc536 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 25 Sep 2009 12:29:16 +0000 Subject: processing fee on credit card recharges, RT#5889 --- httemplate/misc/payment.cgi | 73 ++++++++++++++++++++++++++++++++++--- httemplate/misc/process/payment.cgi | 14 +++++++ 2 files changed, 82 insertions(+), 5 deletions(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi index 45aeacad4..472763b2d 100644 --- a/httemplate/misc/payment.cgi +++ b/httemplate/misc/payment.cgi @@ -10,16 +10,66 @@ % #include( '/elements/table.html', '#cccccc' ) +% my $amount = $balance > 0 ? sprintf("%.2f", $balance) : ''; + <% ntable('#cccccc') %>
Payment amount +
- $"> + <% $money_char %> + +% if ( $fee ) { + + + + + <% $money_char . $fee %> + + <% $fee_pkg->pkg |h %> + = + + <% length($amount) ? $money_char. sprintf('%.2f', $amount + $fee ) : '' %> TOTAL + +% }
Payment amount % if ( $fee ) { - - + + + <% $fee_op %> <% $money_char . $fee %> <% $fee_pkg->pkg |h %> = - <% length($amount) ? $money_char. sprintf('%.2f', $amount + $fee ) : '' %> TOTAL + <% length($amount) ? $money_char. sprintf('%.2f', ($fee_display eq 'add') ? $amount + $fee : $amount - $fee ) : '' %> <% $fee_display eq 'add' ? 'TOTAL' : 'AVAILABLE' %> % }
@@ -55,13 +53,13 @@ var total = ''; if ( what.value.length ) { - total = parseFloat(what.value) + <% $fee %>; + total = parseFloat(what.value) <% $fee_op %> <% $fee %>; /* total = Math.round(total*100)/100; */ total = '<% $money_char %>' + total.toFixed(2); } var total_cell = document.getElementById('ajax_total_cell'); - total_cell.innerHTML = '' + total + ' TOTAL'; + total_cell.innerHTML = '' + total + ' <% $fee_display eq 'add' ? 'TOTAL' : 'AVAILABLE' %>'; } @@ -300,7 +298,13 @@ my @states = sort { $a cmp $b } keys %states; my $fee = ''; my $fee_pkg = ''; +my $fee_display = ''; +my $fee_op = ''; if ( $conf->config('manual_process-pkgpart') ) { + + $fee_display = $conf->config('manual_process-display') || 'add'; + $fee_op = $fee_display eq 'add' ? '+' : '-'; + $fee_pkg = qsearchs('part_pkg', { pkgpart=>$conf->config('manual_process-pkgpart') } ); @@ -308,6 +312,15 @@ if ( $conf->config('manual_process-pkgpart') ) { # (though ->unit_setup doesn't use it...) $fee = $fee_pkg->option('setup_fee') if $fee_pkg; #in case.. better than dying with a perl traceback + +} + +my $amount = ''; +if ( $balance > 0 ) { + $amount = $balance; + $amount += $fee + if $fee && $fee_display eq 'subtract'; + $amount = sprintf("%.2f", $amount); } my $payunique = "webui-payment-". time. "-$$-". rand() * 2**32; diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi index d41bc0f14..1e9501df8 100644 --- a/httemplate/misc/process/payment.cgi +++ b/httemplate/misc/process/payment.cgi @@ -150,11 +150,18 @@ if ( $cgi->param('batch') ) { #no error, so order the fee package if applicable... if ( $cgi->param('fee_pkgpart') =~ /^(\d+)$/ ) { - my $error = $cust_main->order_pkg( - 'cust_pkg' => new FS::cust_pkg { 'pkgpart' => $1 } - ); + + my $cust_pkg = new FS::cust_pkg { 'pkgpart' => $1 }; + + my $error = $cust_main->order_pkg( 'cust_pkg' => $cust_pkg ); errorpage("payment processed successfully, but error ordering fee: $error") if $error; + + #and generate an invoice for it now too + $error = $cust_main->bill( 'pkg_list' => [ $cust_pkg ] ); + errorpage("payment processed and fee ordered sucessfully, but error billing fee: $error") + if $error; + } $cust_main->apply_payments; -- cgit v1.2.1 From 357b4e26965895666685590d59f72de331fecb08 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 5 Oct 2009 02:36:03 +0000 Subject: add manual_process-skip_first option, RT#5889 --- httemplate/misc/payment.cgi | 2 ++ 1 file changed, 2 insertions(+) (limited to 'httemplate/misc') diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi index d35e73f14..ada925c55 100644 --- a/httemplate/misc/payment.cgi +++ b/httemplate/misc/payment.cgi @@ -302,6 +302,8 @@ my $fee_display = ''; my $fee_op = ''; if ( $conf->config('manual_process-pkgpart') ) { + last if $conf->exists('manual_process-skip_first') && ! $cust_main->cust_pay; + $fee_display = $conf->config('manual_process-display') || 'add'; $fee_op = $fee_display eq 'add' ? '+' : '-'; -- cgit v1.2.1 From 331e3441a2eb49396ed3234da33022ce25244974 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 5 Oct 2009 02:40:28 +0000 Subject: add manual_process-skip_first option, RT#5889 --- httemplate/misc/payment.cgi | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi index ada925c55..8d7baa5da 100644 --- a/httemplate/misc/payment.cgi +++ b/httemplate/misc/payment.cgi @@ -300,9 +300,10 @@ my $fee = ''; my $fee_pkg = ''; my $fee_display = ''; my $fee_op = ''; -if ( $conf->config('manual_process-pkgpart') ) { - - last if $conf->exists('manual_process-skip_first') && ! $cust_main->cust_pay; +if ( $conf->config('manual_process-pkgpart') + and ! $conf->exists('manual_process-skip_first') || $cust_main->cust_pay + ) +{ $fee_display = $conf->config('manual_process-display') || 'add'; $fee_op = $fee_display eq 'add' ? '+' : '-'; -- cgit v1.2.1 From 2caddb16574bf73c3687b959656b7ee2f851937f Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 5 Oct 2009 18:17:55 +0000 Subject: oops, handle old cust_main.pm properly (should we be bothering?) :/ RT#5889 --- httemplate/misc/payment.cgi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'httemplate/misc') diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi index 8d7baa5da..813b560bd 100644 --- a/httemplate/misc/payment.cgi +++ b/httemplate/misc/payment.cgi @@ -300,8 +300,12 @@ my $fee = ''; my $fee_pkg = ''; my $fee_display = ''; my $fee_op = ''; +my $num_payments = scalar($cust_main->cust_pay); +#handle old cust_main.pm (remove...) +$num_payments = scalar( @{ [ $cust_main->cust_pay ] } ) + unless defined $num_payments; if ( $conf->config('manual_process-pkgpart') - and ! $conf->exists('manual_process-skip_first') || $cust_main->cust_pay + and ! $conf->exists('manual_process-skip_first') || $num_payments ) { -- cgit v1.2.1 From 06187016fd78ba41fb82846b9e8d461405f316b6 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 7 Oct 2009 23:44:26 +0000 Subject: naming follow-up notices from the event rather than creting a slew of separate templates, RT#5217 --- httemplate/misc/email-statement.cgi | 19 ------------------- httemplate/misc/send-invoice.cgi | 30 ++++++++++++++++++++++++++++++ httemplate/misc/send-statement.cgi | 28 ++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 19 deletions(-) delete mode 100755 httemplate/misc/email-statement.cgi create mode 100644 httemplate/misc/send-invoice.cgi create mode 100755 httemplate/misc/send-statement.cgi (limited to 'httemplate/misc') diff --git a/httemplate/misc/email-statement.cgi b/httemplate/misc/email-statement.cgi deleted file mode 100755 index 67f654d64..000000000 --- a/httemplate/misc/email-statement.cgi +++ /dev/null @@ -1,19 +0,0 @@ -<% $cgi->redirect("${p}view/cust_main.cgi?$custnum") %> -<%init> - -die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Resend invoices'); - -#untaint statementnum -my($query) = $cgi->keywords; -$query =~ /^((.+)-)?(\d+)$/; -my $template = $2 || 'statement'; #XXX configure... via event?? eh.. -my $statementnum = $3; -my $cust_statement = qsearchs('cust_statement',{'statementnum'=>$statementnum}); -die "Can't find statement!\n" unless $cust_statement; - -$cust_statement->email($template); - -my $custnum = $cust_statement->getfield('custnum'); - - diff --git a/httemplate/misc/send-invoice.cgi b/httemplate/misc/send-invoice.cgi new file mode 100644 index 000000000..32dfe276d --- /dev/null +++ b/httemplate/misc/send-invoice.cgi @@ -0,0 +1,30 @@ +<% $cgi->redirect("${p}view/cust_main.cgi?$custnum") %> +<%once> + +my %method = ( map { $_=>1 } qw( email print fax_invoice ) ); + + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Resend invoices'); + +my $invnum = $cgi->param('invnum'); +my $template = $cgi->param('template'); +my $notice_name = $cgi->param('notice_name') if $cgi->param('notice_name'); +my $method = $cgi->param('method'); + +$method .= '_invoice' if $method eq 'fax'; #! + +die "unknown method $method" unless $method{$method}; + +my $cust_bill = qsearchs('cust_bill',{'invnum'=>$invnum}); +die "Can't find invoice!\n" unless $cust_bill; + +$cust_bill->$method({ 'template' => $template, + 'notice_name' => $notice_name, + }); + +my $custnum = $cust_bill->getfield('custnum'); + + diff --git a/httemplate/misc/send-statement.cgi b/httemplate/misc/send-statement.cgi new file mode 100755 index 000000000..e363fbd09 --- /dev/null +++ b/httemplate/misc/send-statement.cgi @@ -0,0 +1,28 @@ +<% $cgi->redirect("${p}view/cust_main.cgi?$custnum") %> +<%once> + +my %method = map { $_=>1 } qw( email print fax_invoice ); + + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Resend invoices'); + +my $statementnum = $cgi->param('statementnum'); +my $template = $cgi->param('template') || 'statement'; #XXX configure... via event?? eh.. +my $notice_name = $cgi->param('notice_name') if $cgi->param('notice_name'); +my $method = $cgi->param('method'); + +$method .= '_invoice' if $method eq 'fax'; #! + +die "unknown method $method" unless $method{$method}; + +my $cust_statement = qsearchs('cust_statement',{'statementnum'=>$statementnum}); +die "Can't find statement!\n" unless $cust_statement; + +$cust_statement->$method({ 'template' => $template }); + +my $custnum = $cust_statement->getfield('custnum'); + + -- cgit v1.2.1