diff options
| author | jeff <jeff> | 2008-04-01 00:54:44 +0000 |
|---|---|---|
| committer | jeff <jeff> | 2008-04-01 00:54:44 +0000 |
| commit | 4104f4e3d1b387296b16b4a035b4b7f42e0c5977 (patch) | |
| tree | fcb03d2c518cc91df33059675764d548fedc9e7a /httemplate/misc | |
| parent | 12eb930abf31078c68dbf7eb94865faa1c59fc9e (diff) | |
checkpoint of new tax rating system
Diffstat (limited to 'httemplate/misc')
| -rwxr-xr-x | httemplate/misc/process/recharge_svc.new | 85 | ||||
| -rw-r--r-- | httemplate/misc/process/tax-import.cgi | 58 | ||||
| -rw-r--r-- | httemplate/misc/tax-import.cgi | 91 |
3 files changed, 234 insertions, 0 deletions
diff --git a/httemplate/misc/process/recharge_svc.new b/httemplate/misc/process/recharge_svc.new new file mode 100755 index 000000000..bc916e5da --- /dev/null +++ b/httemplate/misc/process/recharge_svc.new @@ -0,0 +1,85 @@ +% +% +%#untaint svcnum +%my $svcnum = $cgi->param('svcnum'); +%$svcnum =~ /^(\d+)$/ || die "Illegal svcnum"; +%$svcnum = $1; +% +%#untaint prepaid +%my $prepaid = $cgi->param('prepaid'); +%$prepaid =~ /^(\w*)$/; +%$prepaid = $1; + +%#untaint payby +%my $payby = $cgi->param('payby'); +%$payby =~ /^([A-Z]*)$/; +%$payby = $1; +% +%my $error = ''; +%my $svc_acct = qsearchs( 'svc_acct', {'svcnum'=>$svcnum} ); +%$error = "Can't recharge service $svcnum. " unless $svc_acct; +% +%my $cust_main = $svc_acct->cust_svc->cust_pkg->cust_main; +% +%my $oldAutoCommit = $FS::UID::AutoCommit; +%local $FS::UID::AutoCommit = 0; +%my $dbh = dbh; +% +% +%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($_, 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); +% +% $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; +% +<% header("Package recharged") %> + <SCRIPT TYPE="text/javascript"> + window.top.location.reload(); + </SCRIPT> + </BODY></HTML> +<%init> +my $conf = new FS::Conf; +</%init> diff --git a/httemplate/misc/process/tax-import.cgi b/httemplate/misc/process/tax-import.cgi new file mode 100644 index 000000000..77fba61f5 --- /dev/null +++ b/httemplate/misc/process/tax-import.cgi @@ -0,0 +1,58 @@ +% if ( $error ) { +% warn $error; +% errorpage($error); +% } else { + <% include('/elements/header.html','Import successful') %> + <% include('/elements/footer.html') %> +% } +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Import'); + +my $cfh = $cgi->upload('codefile'); +my $zfh = $cgi->upload('plus4file'); +my $tfh = $cgi->upload('txmatrix'); +my $dfh = $cgi->upload('detail'); +#warn $cgi; +#warn $fh; + +my $oldAutoCommit = $FS::UID::AutoCommit; +local $FS::UID::AutoCommit = 0; +my $dbh = dbh; + +my $error = defined($cfh) + ? FS::tax_class::batch_import( { + filehandle => $cfh, + 'format' => scalar($cgi->param('format')), + } ) + : 'No code file'; + +$error ||= defined($zfh) + ? FS::cust_tax_location::batch_import( { + filehandle => $zfh, + 'format' => scalar($cgi->param('format')), + } ) + : 'No plus4 file'; + +$error ||= defined($tfh) + ? FS::part_pkg_taxrate::batch_import( { + filehandle => $tfh, + 'format' => scalar($cgi->param('format')), + } ) + : 'No tax matrix file'; + +$error ||= defined($dfh) + ? FS::tax_rate::batch_import( { + filehandle => $dfh, + 'format' => scalar($cgi->param('format')), + } ) + : 'No tax detail file'; + +if ($error) { + $dbh->rollback or die $dbh->errstr if $oldAutoCommit; +}else{ + $dbh->commit or die $dbh->errstr if $oldAutoCommit; +} + +</%init> diff --git a/httemplate/misc/tax-import.cgi b/httemplate/misc/tax-import.cgi new file mode 100644 index 000000000..1f60dbe00 --- /dev/null +++ b/httemplate/misc/tax-import.cgi @@ -0,0 +1,91 @@ +<% include("/elements/header.html",'Batch Tax Rate Import') %> + +Import a CSV file set containing tax rate records. +<BR><BR> + +<FORM ACTION="process/tax-import.cgi" METHOD="post" ENCTYPE="multipart/form-data"> + +<% &ntable("#cccccc", 2) %> + +<TR> + <TH ALIGN="right">Format</TH> + <TD> + <SELECT NAME="format"> + <OPTION VALUE="cch">CCH +<!-- <OPTION VALUE="extended" SELECTED>Extended + <OPTION VALUE="extended-plus_company">Extended plus company --> + </SELECT> + </TD> +</TR> + +<TR> + <TH ALIGN="right">code CSV filename</TH> + <TD><INPUT TYPE="file" NAME="codefile"></TD> +</TR> + +<TR> + <TH ALIGN="right">plus4 CSV filename</TH> + <TD><INPUT TYPE="file" NAME="plus4file"></TD> +</TR> + +<TR> + <TH ALIGN="right">txmatrix CSV filename</TH> + <TD><INPUT TYPE="file" NAME="txmatrix"></TD> +</TR> + +<TR> + <TH ALIGN="right">detail CSV filename</TH> + <TD><INPUT TYPE="file" NAME="detail"></TD> +</TR> + + +<TR><TD COLSPAN=2 ALIGN="center" STYLE="padding-top:6px"><INPUT TYPE="submit" VALUE="Import CSV files"></TD></TR> + +</TABLE> + +</FORM> + +<BR> + +<!-- Simple file format is CSV, with the following field order: <i>cust_pkg.setup, dayphone, first, last, address1, address2, city, state, zip, comments</i> +<BR><BR> --> + +<%$req%> Required fields +<BR><BR> + +Field information: + +<ul> + + <li><i>refnum</i>: Advertising source number - where a customer heard about your service. Configuration -> Miscellaneous -> View/Edit advertising sources. This field has special treatment upon import: If a string is passed instead +of an integer, the string is searched for and if necessary auto-created in the +advertising source table. + + <li><i>payinfo</i>: Credit card number, or leave this, <i>paycvv</i> and <i>paydate</i> blank for email/paper invoicing. + + <li><i>paycvv</i>: CVV2 number (three digits on the back of the credit card) + + <li><i>paydate</i>: Credit card expiration date, MM/YYYY or MM/YY (M/YY and M/YYYY are also accepted). + + <li><i>invoicing_list</i>: Email address for invoices, or POST for postal invoices. + + <li><i>pkgpart</i>: Package definition. Configuration -> Provisioning, services and packages -> View/Edit package definitions + + <li><i>username</i> and <i>_password</i> are required if <i>pkgpart</i> is specified. +</ul> + +<BR> + +<% include('/elements/footer.html') %> + +<%once> + +my $req = qq!<font color="#ff0000">*</font>!; + +</%once> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Import'); + +</%init> |
