summaryrefslogtreecommitdiff
path: root/httemplate/misc
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/misc')
-rw-r--r--httemplate/misc/batch-cust_pay.html31
-rwxr-xr-xhttemplate/misc/change_pkg.cgi13
-rw-r--r--httemplate/misc/delete-cust_bill.html21
-rw-r--r--httemplate/misc/delete-cust_pkg_discount.html2
-rw-r--r--httemplate/misc/email-customer-statement.html92
-rw-r--r--httemplate/misc/email-customers.html138
-rw-r--r--httemplate/misc/payment.cgi4
-rw-r--r--httemplate/misc/process/batch-cust_pay.cgi1
-rw-r--r--httemplate/misc/process/email-customer-statement.html9
-rw-r--r--httemplate/misc/process/nms-add_iface.html2
-rw-r--r--httemplate/misc/xmlhttp-cust_bill_pkg-calculate_taxes.html116
11 files changed, 262 insertions, 167 deletions
diff --git a/httemplate/misc/batch-cust_pay.html b/httemplate/misc/batch-cust_pay.html
index fb3ec04f3..9f2540cc7 100644
--- a/httemplate/misc/batch-cust_pay.html
+++ b/httemplate/misc/batch-cust_pay.html
@@ -26,15 +26,15 @@ function warnUnload() {
}
window.onbeforeunload = warnUnload;
-function add_row_callback(rownum, prefix, values) {
+function add_row_callback(rownum, values) {
if (values) {
- custnum_update_callback(rownum, prefix);
+ custnum_update_callback(rownum);
} else {
document.getElementById('enable_app'+rownum).disabled = true;
}
}
-function delete_row_callback(rownum, prefix) {
+function delete_row_callback(rownum) {
var i = 0;
var delbutton = document.getElementById('delete'+rownum+'.'+i);
var delrows = [];
@@ -49,7 +49,7 @@ function delete_row_callback(rownum, prefix) {
}
}
-function custnum_update_callback(rownum, prefix) {
+function custnum_update_callback(rownum) {
var custnum = document.getElementById('custnum'+rownum).value;
// if there is a custnum and more than one open invoice, enable
// (and check) the box
@@ -58,17 +58,17 @@ function custnum_update_callback(rownum, prefix) {
enable_app_checkbox.disabled = show_applications;
% if ( $use_discounts ) {
- select_discount_term(rownum, prefix);
+ select_discount_term(rownum);
% }
}
-function invnum_update_callback(rownum, prefix) {
- custnum_update_callback(rownum, prefix);
+function invnum_update_callback(rownum) {
+ custnum_update_callback(rownum);
}
-function select_discount_term(row, prefix) {
- var custnum_obj = document.getElementById('custnum'+prefix+row);
- var select_obj = document.getElementById('discount_term'+prefix+row);
+function select_discount_term(row) {
+ var custnum_obj = document.getElementById('custnum'+row);
+ var select_obj = document.getElementById('discount_term'+row);
var value = '';
if (select_obj.type == 'hidden') {
@@ -436,6 +436,7 @@ my @footer_align = ( 'r', 'r' );
my @onchange = ( '', '' );;
my $use_discounts = '';
+# Not entirely sure this works anymore...
if ( FS::Record->scalar_sql('SELECT COUNT(*) FROM part_pkg_discount') ) {
#push @header, 'Discount';
push @header, '';
@@ -460,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/change_pkg.cgi b/httemplate/misc/change_pkg.cgi
index 1b4a94e81..e74747e82 100755
--- a/httemplate/misc/change_pkg.cgi
+++ b/httemplate/misc/change_pkg.cgi
@@ -28,6 +28,14 @@
'curr_value' => $cust_pkg->quantity
&>
+% if ($use_contract_end) {
+ <& /elements/tr-input-date-field.html, {
+ 'name' => 'contract_end',
+ 'value' => ($cgi->param('contract_end') || $cust_pkg->get('contract_end')),
+ 'label' => '<B>Contract End</B>',
+ } &>
+% }
+
</TABLE>
<BR>
@@ -124,6 +132,8 @@ my $part_pkg = $cust_pkg->part_pkg;
my $title = "Change Package";
+my $use_contract_end = $cust_pkg->get('contract_end') ? 1 : 0;
+
# if there's already a package change ordered, preload it
if ( $cust_pkg->change_to_pkgnum ) {
my $change_to = FS::cust_pkg->by_key($cust_pkg->change_to_pkgnum);
@@ -131,6 +141,9 @@ if ( $cust_pkg->change_to_pkgnum ) {
foreach(qw( start_date pkgpart locationnum quantity )) {
$cgi->param($_, $change_to->get($_));
}
+ if ($use_contract_end) {
+ $cgi->param('contract_end', $change_to->get('contract_end'));
+ }
$title = "Edit Scheduled Package Change";
}
</%init>
diff --git a/httemplate/misc/delete-cust_bill.html b/httemplate/misc/delete-cust_bill.html
deleted file mode 100644
index 3a642b0e9..000000000
--- a/httemplate/misc/delete-cust_bill.html
+++ /dev/null
@@ -1,21 +0,0 @@
-% 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;
-
-</%init>
diff --git a/httemplate/misc/delete-cust_pkg_discount.html b/httemplate/misc/delete-cust_pkg_discount.html
index 0bdaa13b3..58a99ca67 100644
--- a/httemplate/misc/delete-cust_pkg_discount.html
+++ b/httemplate/misc/delete-cust_pkg_discount.html
@@ -13,7 +13,7 @@ my $curuser = $FS::CurrentUser::CurrentUser;
#XXX ACL to remove discounts
#die "access denied"
-# unless $curuser->access_right('Delete invoices');
+# unless $curuser->access_right('Delete discounts');
#untaint pkgdiscountnum
my($query) = $cgi->keywords;
diff --git a/httemplate/misc/email-customer-statement.html b/httemplate/misc/email-customer-statement.html
new file mode 100644
index 000000000..20430f5b1
--- /dev/null
+++ b/httemplate/misc/email-customer-statement.html
@@ -0,0 +1,92 @@
+<& email-customers.html,
+ 'form_action' => 'email-customer-statement.html',
+ 'title' => 'Send statement to customer',
+ 'no_search_fields' => [ 'start_date', 'end_date' ],
+ 'alternate_form' => $alternate_form,
+ 'post_search_hook' => $post_search_hook,
+ 'acl' => $acl,
+ 'process_url' => 'process/email-customer-statement.html',
+&>
+<%init>
+
+my $acl = 'Resend invoices';
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right($acl);
+
+my $alternate_form = sub {
+ # this could maaaybe be a separate element, for cleanliness
+ # but it's really only for use by this page, and it's not overly complicated
+ my $noinit = 0;
+ return join("\n",
+ '<TABLE BORDER="0">',
+ (
+ map {
+ my $label = ucfirst($_);
+ $label =~ s/_/ /;
+ include('/elements/tr-input-date-field.html',{
+ 'name' => $_,
+ 'value' => $cgi->param($_) || '',
+ 'label' => $label,
+ 'noinit' => $noinit++
+ });
+ }
+ qw( start_date end_date )
+ ),
+ '</TABLE>',
+ '<INPUT TYPE="hidden" NAME="action" VALUE="preview">',
+ '<INPUT TYPE="submit" VALUE="Preview notice">',
+ );
+};
+
+my $post_search_hook = sub {
+ my %opt = @_;
+ return unless $cgi->param('action') eq 'preview';
+ my $cust_main = qsearchs('cust_main',$opt{'search'})
+ or die "Could not find customer";
+
+ # so that the statement indicates the latest date
+ my $date_format = $opt{'conf'}->config('date_format') || '%m/%d/%Y';
+ $cgi->param('end_date', time2str($date_format, time))
+ unless $cgi->param('end_date');
+
+ # set from/subject/html_body based on date range
+
+ $cgi->param('from',
+ $opt{'conf'}->config('invoice_from')
+ );
+
+ # shortcut for common text
+ my $summary_text = $cust_main->name_short .
+ ($cgi->param('start_date') ? ' from ' : '') .
+ $cgi->param('start_date') .
+ ($cgi->param('end_date') ? ' through ' : '') .
+ $cgi->param('end_date');
+
+ $cgi->param('subject',
+ $opt{'conf'}->config('company_name') .
+ ' statement for ' .
+ $summary_text
+ );
+
+ $cgi->param('html_body',
+ '<P>' .
+ $opt{'conf'}->config('company_name') .
+ ' statement of charges and payments for ' .
+ $summary_text .
+ "</P>" .
+ include('/elements/customer-statement.html',
+ 'history' => [
+ $cust_main->payment_history(
+ map {
+ $_ => parse_datetime(scalar($cgi->param($_)))
+ }
+ qw( start_date end_date ),
+ ),
+ ],
+ )
+ );
+};
+
+</%init>
+
diff --git a/httemplate/misc/email-customers.html b/httemplate/misc/email-customers.html
index 83e86158f..47e6a5b48 100644
--- a/httemplate/misc/email-customers.html
+++ b/httemplate/misc/email-customers.html
@@ -1,11 +1,42 @@
+<%doc>
+
+Allows emailing one or more customers, based on a search for customers. Search can
+be specified either through cust_main fields as cgi params, or through a base64 encoded
+frozen hash in the 'search' cgi param. Form allows selecting an existing msg_template,
+or creating a custom message, and shows a preview of the message before sending.
+If linked to as a popup, include the cgi parameter 'popup' for proper header handling.
+
+This may also be used as an element in other pages, enabling you to provide an
+alternate initial form while using this for search freezing/thawing and
+preview/send actions, with the following options:
+
+acl - the access right to use (defaults to 'Bulk send customer notices')
+
+form_action - the URL to submit the form to
+
+process_url - the URL for starting the JSRPC process
+
+title - the title of the page
+
+no_search_fields - arrayref of additional fields that are not search parameters
+
+alternate_form - subroutine that returns alternate html for the initial form,
+replaces msgnum/from/subject/html_body/action inputs and submit button,
+not used if an action is specified
+
+post_search_hook - sub hook for additional processing after search has been processed from cgi,
+gets passed options 'conf' and 'search' (a reference to the unfrozen %search hash),
+should be used to set msgnum or from/subject/html_body cgi params
+
+</%doc>
% if ($popup) {
-<% include('/elements/header-popup.html', $title) %>
+<& /elements/header-popup.html, $title &>
% } else {
-<% include('/elements/header.html', $title) %>
+<& /elements/header.html, $title &>
% }
-<FORM NAME="OneTrueForm" ACTION="email-customers.html" METHOD="POST">
+<FORM NAME="OneTrueForm" ACTION="<% $form_action %>" METHOD="GET">
<INPUT TYPE="hidden" NAME="table" VALUE="<% $table %>">
%# Mixing search params with from address, subject, etc. required special-case
%# handling of those, risked name conflicts, and caused massive problems with
@@ -19,13 +50,12 @@
<FONT SIZE="+2">Sending notice</FONT>
- <% include('/elements/progress-init.html',
+ <& /elements/progress-init.html,
'OneTrueForm',
[ qw( search table from subject html_body text_body msgnum ) ],
- 'process/email-customers.html',
+ $process_url,
$pdest,
- )
- %>
+ &>
% } elsif ( $cgi->param('action') eq 'preview' ) {
@@ -35,34 +65,32 @@
% if ( $cgi->param('action') ) {
- <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
- <INPUT TYPE="hidden" NAME="msgnum" VALUE="<% $cgi->param('msgnum') %>">
+ <TABLE CLASS="fsinnerbox">
+ <INPUT TYPE="hidden" NAME="msgnum" VALUE="<% scalar($cgi->param('msgnum')) %>">
% if ( $msg_template ) {
- <% include('/elements/tr-fixed.html',
+ <& /elements/tr-fixed.html,
'label' => 'Template:',
'value' => $msg_template->msgname,
- )
- %>
+ &>
% }
- <% include('/elements/tr-fixed.html',
+ <& /elements/tr-fixed.html,
'field' => 'from',
'label' => 'From:',
- 'value' => scalar( $from ),
- )
- %>
+ 'value' => $from,
+ &>
- <% include('/elements/tr-fixed.html',
+ <& /elements/tr-fixed.html,
'field' => 'subject',
'label' => 'Subject:',
- 'value' => scalar( $subject ),
- )
- %>
+ 'value' => $subject,
+ &>
<INPUT TYPE="hidden" NAME="html_body" VALUE="<% $html_body |h %>">
+ <TR><TD COLSPAN=2>&nbsp;</TD></TR>
<TR>
- <TD ALIGN="right" VALIGN="top">Message (HTML display): </TD>
+ <TH ALIGN="right" VALIGN="top">Message (HTML display): </TD>
<TD CLASS="background" ALIGN="left"><% $html_body %></TD>
</TR>
@@ -72,16 +100,34 @@
% )
% );
<INPUT TYPE="hidden" NAME="text_body" VALUE="<% $text_body |h %>">
+ <TR><TD COLSPAN=2>&nbsp;</TD></TR>
<TR>
- <TD ALIGN="right" VALIGN="top">Message (Text display): </TD>
- <TD CLASS="background" STYLE="background-color:white" ALIGN="left"><PRE><% $text_body %></PRE></TD>
+ <TH ALIGN="right" VALIGN="top">Message (Text display): </TD>
+ <TD CLASS="background" ALIGN="left">
+ <a href="javascript:void(0)" ID="email-message-text-view" style="color:#666666" onclick="showtext()">(view)</a>
+ <a href="javascript:void(0)" ID="email-message-text-hide" style="color:#666666; display: none;" onclick="hidetext()">(hide)</a>
+ <PRE id="email-message-text" style="display: none;"><% $text_body %></PRE>
+ </TD>
</TR>
</TABLE>
-% if ( $cgi->param('action') eq 'preview' ) {
+% if ( $cgi->param('action') eq 'preview' ) {
<SCRIPT>
+
+ function showtext() {
+ $('#email-message-text-view').css('display','none');
+ $('#email-message-text-hide').css('display','');
+ $('#email-message-text').slideDown();
+ }
+
+ function hidetext() {
+ $('#email-message-text-view').css('display','');
+ $('#email-message-text-hide').css('display','none');
+ $('#email-message-text').slideUp();
+ }
+
function areyousure(href) {
return confirm("Send this notice to <% ($num_cust > 1) ? "$num_cust customers" : '1 customer' %> ?");
}
@@ -93,6 +139,10 @@
% }
+% } elsif ($opt{'alternate_form'}) {
+
+<% &{$opt{'alternate_form'}}() %>
+
% } else {
<SCRIPT TYPE="text/javascript">
@@ -121,12 +171,11 @@ Template:
'size' => 20,
&>&gt;</TD>
- <% include('/elements/tr-input-text.html',
+ <& /elements/tr-input-text.html,
'field' => 'subject',
'label' => 'Subject:',
'size' => 50,
- )
- %>
+ &>
<TR>
<TD ALIGN="right" VALIGN="top" STYLE="padding-top:3px">Message: </TD>
@@ -144,7 +193,7 @@ Template:
<INPUT TYPE="hidden" NAME="action" VALUE="preview">
<INPUT TYPE="submit" VALUE="Preview notice">
-% }
+% } #end not action or alternate form
</FORM>
@@ -154,14 +203,24 @@ Template:
</SCRIPT>
% }
-<% include('/elements/footer.html') %>
+<& /elements/footer.html &>
<%init>
+my %opt = @_;
+
+$opt{'acl'} ||= 'Bulk send customer notices';
+
die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Bulk send customer notices');
+ unless $FS::CurrentUser::CurrentUser->access_right($opt{'acl'});
my $conf = FS::Conf->new;
+my @no_search_fields = qw( action table from subject html_body text_body popup url );
+
+my $form_action = $opt{'form_action'} || 'email-customers.html';
+my $process_url = $opt{'process_url'} || 'process/email-customers.html';
+my $title = $opt{'title'} || 'Send customer notices';
+push( @no_search_fields, @{$opt{'no_search_fields'}} ) if $opt{'no_search_fields'};
my $table = $cgi->param('table') or die "'table' required";
my $agent_virt_agentnum = $cgi->param('agent_virt_agentnum') || '';
@@ -173,19 +232,22 @@ $pdest->{'url'} = $cgi->param('url') if $url;
my %search;
if ( $cgi->param('search') ) {
- %search = %{ thaw(decode_base64($cgi->param('search'))) };
+ %search = %{ thaw(decode_base64( $cgi->param('search') )) };
}
else {
%search = $cgi->Vars;
- delete $search{$_} for qw( action table from subject html_body text_body popup url );
+ delete $search{$_} for @no_search_fields;
# FS::$table->search is expected to know which parameters might be
# multi-valued, and to accept scalar values for them also. No good
# solution to this since CGI can't tell whether a parameter _might_
# have had multiple values, only whether it does.
@search{keys %search} = map { /\0/ ? [ split /\0/, $_ ] : $_ } values %search;
-}
+}
-my $title = 'Send customer notices';
+&{$opt{'post_search_hook'}}(
+ 'conf' => $conf,
+ 'search' => \%search,
+) if $opt{'post_search_hook'};
my $num_cust;
my $from = '';
@@ -203,6 +265,7 @@ my $html_body = $cgi->param('html_body') || '';
my $msg_template = '';
if ( $cgi->param('action') eq 'preview' ) {
+
my $sql_query = "FS::$table"->search(\%search);
my $count_query = delete($sql_query->{'count_query'});
my $count_sth = dbh->prepare($count_query)
@@ -214,17 +277,18 @@ if ( $cgi->param('action') eq 'preview' ) {
if ( $cgi->param('msgnum') ) {
$msg_template = qsearchs('msg_template',
- { msgnum => $cgi->param('msgnum') } )
+ { msgnum => scalar($cgi->param('msgnum')) } )
or die "template not found: ".$cgi->param('msgnum');
$sql_query->{'extra_sql'} .= ' LIMIT 1';
$sql_query->{'select'} = "$table.*";
$sql_query->{'order_by'} = '';
my $object = qsearchs($sql_query);
my $cust = $object->cust_main;
- my %message = $msg_template->prepare(
+ my %msgopts = (
'cust_main' => $cust,
- 'object' => $object
+ 'object' => $object,
);
+ my %message = $msg_template->prepare(%msgopts);
($from, $subject, $html_body) = @message{'from', 'subject', 'html_body'};
}
}
diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi
index 4860aed83..f4f0b56dd 100644
--- a/httemplate/misc/payment.cgi
+++ b/httemplate/misc/payment.cgi
@@ -1,5 +1,7 @@
<& /elements/header.html, mt("Process [_1] payment",$type{$payby}) &>
<& /elements/small_custview.html, $cust_main, '', '', popurl(2) . "view/cust_main.cgi" &>
+<BR>
+
<FORM NAME="OneTrueForm" ACTION="process/payment.cgi" METHOD="POST" onSubmit="document.OneTrueForm.process.disabled=true">
<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $custnum %>">
<INPUT TYPE="hidden" NAME="payby" VALUE="<% $payby %>">
@@ -8,7 +10,7 @@
<& /elements/init_overlib.html &>
-<% ntable('#cccccc') %>
+<TABLE class="fsinnerbox">
<& /elements/tr-amount_fee.html,
'amount' => $amount,
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/misc/process/email-customer-statement.html b/httemplate/misc/process/email-customer-statement.html
new file mode 100644
index 000000000..40a8a702a
--- /dev/null
+++ b/httemplate/misc/process/email-customer-statement.html
@@ -0,0 +1,9 @@
+<% $server->process %>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Resend invoices');
+
+my $server = new FS::UI::Web::JSRPC 'FS::cust_main_Mixin::process_email_search_result', $cgi;
+
+</%init>
diff --git a/httemplate/misc/process/nms-add_iface.html b/httemplate/misc/process/nms-add_iface.html
index d21b3792a..79e685686 100644
--- a/httemplate/misc/process/nms-add_iface.html
+++ b/httemplate/misc/process/nms-add_iface.html
@@ -1,4 +1,4 @@
-<& /elements/header-popup.html, 'Interface added') &>
+<& /elements/header-popup.html, 'Interface added' &>
<SCRIPT TYPE="text/javascript">
window.top.location.reload();
</SCRIPT>
diff --git a/httemplate/misc/xmlhttp-cust_bill_pkg-calculate_taxes.html b/httemplate/misc/xmlhttp-cust_bill_pkg-calculate_taxes.html
index 4558682bd..8f417765b 100644
--- a/httemplate/misc/xmlhttp-cust_bill_pkg-calculate_taxes.html
+++ b/httemplate/misc/xmlhttp-cust_bill_pkg-calculate_taxes.html
@@ -4,7 +4,7 @@
my $curuser = $FS::CurrentUser::CurrentUser;
die "access denied" unless $curuser->access_right('Credit line items');
-my $DEBUG = 0;
+my $DEBUG = 1;
my $conf = new FS::Conf;
@@ -12,107 +12,31 @@ my $sub = $cgi->param('sub');
my $return = {};
-if ( $sub eq 'calculate_taxes' ) {
+die "unknown sub '$sub'" if $sub ne 'calculate_taxes';
- {
+my %arg = $cgi->param('arg');
+warn join('', map "$_: $arg{$_}\n", keys %arg )
+ if $DEBUG;
- my %arg = $cgi->param('arg');
- $return = \%arg;
- warn join('', map "$_: $arg{$_}\n", keys %arg )
- if $DEBUG;
+#some false laziness w/cust_credit::credit_lineitems
- #some false laziness w/cust_credit::credit_lineitems
+my $cust_main = qsearchs({
+ 'table' => 'cust_main',
+ 'hashref' => { 'custnum' => $arg{custnum} },
+ 'extra_sql' => ' AND '. $curuser->agentnums_sql,
+}) or die 'unknown customer';
- my $cust_main = qsearchs({
- 'table' => 'cust_main',
- 'hashref' => { 'custnum' => $arg{custnum} },
- 'extra_sql' => ' AND '. $curuser->agentnums_sql,
- }) or die 'unknown customer';
+$arg{billpkgnums} = [ split(',', $arg{billpkgnums}) ];
+$arg{setuprecurs} = [ split(',', $arg{setuprecurs}) ];
+$arg{amounts} = [ split(',', $arg{amounts}) ];
- my @billpkgnums = split(',', $arg{billpkgnums});
- my @setuprecurs = split(',', $arg{setuprecurs});
- my @amounts = split(',', $arg{amounts});
+my %results = FS::cust_credit->calculate_tax_adjustment(%arg);
- my @cust_bill_pkg = ();
- my $taxlisthash = {};
- while ( @billpkgnums ) {
- my $billpkgnum = shift @billpkgnums;
- my $setuprecur = shift @setuprecurs;
- my $amount = shift @amounts;
+$return = {
+ %arg,
+ %results
+};
- my $cust_bill_pkg = qsearchs({
- 'table' => 'cust_bill_pkg',
- 'hashref' => { 'billpkgnum' => $billpkgnum },
- 'addl_from' => 'LEFT JOIN cust_bill USING (invnum)',
- 'extra_sql' => 'AND custnum = '. $cust_main->custnum,
- }) or die "unknown billpkgnum $billpkgnum";
-
- #shouldn't be passed# next if $cust_bill_pkg->pkgnum == 0;
-
- if ( $setuprecur eq 'setup' ) {
- $cust_bill_pkg->setup($amount);
- $cust_bill_pkg->recur(0);
- $cust_bill_pkg->unitrecur(0);
- $cust_bill_pkg->type('');
- } else {
- $cust_bill_pkg->recur($amount);
- $cust_bill_pkg->setup(0);
- $cust_bill_pkg->unitsetup(0);
- }
-
- push @cust_bill_pkg, $cust_bill_pkg;
-
- $cust_main->_handle_taxes( $taxlisthash, $cust_bill_pkg );
- }
-
- if ( @cust_bill_pkg ) {
-
- my $listref_or_error =
- $cust_main->calculate_taxes( \@cust_bill_pkg, $taxlisthash, $cust_bill_pkg[0]->cust_bill->_date );
-
- unless ( ref( $listref_or_error ) ) {
- $return->{error} = $listref_or_error;
- last;
- }
-
- my @taxlines = ();
- my $taxtotal = 0;
- $return->{taxlines} = \@taxlines;
- foreach my $taxline ( @$listref_or_error ) {
- my $amount = $taxline->setup;
- my $desc = $taxline->desc;
- foreach my $location (
- @{$taxline->get('cust_bill_pkg_tax_location')},
- @{$taxline->get('cust_bill_pkg_tax_rate_location')} )
- {
- my $taxlocnum = $location->locationnum || '';
- my $taxratelocnum = $location->taxratelocationnum || '';
- $location->cust_bill_pkg_desc($taxline->desc); #ugh @ that kludge
- $taxtotal += $location->amount;
- push @taxlines,
- #[ $location->desc, $taxline->setup, $taxlocnum, $taxratelocnum ];
- [ $location->desc, $location->amount, $taxlocnum, $taxratelocnum ];
- $amount -= $location->amount;
- }
- if ($amount > 0) {
- $taxtotal += $amount;
- push @taxlines,
- [ $taxline->itemdesc. ' (default)', sprintf('%.2f', $amount), '', '' ];
- }
- }
-
- $return->{taxlines} = \@taxlines;
- $return->{taxtotal} = sprintf('%.2f', $taxtotal);
-
- } else {
-
- $return->{taxlines} = [];
- $return->{taxtotal} = '0.00';
-
- }
-
- }
-
-}
+warn Dumper $return if $DEBUG;
</%init>