summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/browse/reason.html16
-rw-r--r--httemplate/edit/process/quotation_pkg_detail.html5
-rw-r--r--httemplate/edit/quotation_pkg_detail.html29
-rw-r--r--httemplate/edit/reason.html6
-rwxr-xr-xhttemplate/elements/tr-select-reason.html7
-rw-r--r--httemplate/misc/xmlhttp-cust_bill_pkg-calculate_taxes.html116
6 files changed, 73 insertions, 106 deletions
diff --git a/httemplate/browse/reason.html b/httemplate/browse/reason.html
index bdbcf3704..7f62ada84 100644
--- a/httemplate/browse/reason.html
+++ b/httemplate/browse/reason.html
@@ -65,11 +65,8 @@ my @links = (
my $align = 'rll';
-if ( $class eq 'S' ) {
- push @header,
- 'Credit unused service',
- 'Suspension fee',
- ;
+if ( $class eq 'S' or $class eq 'C' ) {
+ push @header, 'Credit unused service';
push @fields,
sub {
my $reason = shift;
@@ -78,7 +75,12 @@ if ( $class eq 'S' ) {
} else {
return '<SPAN STYLE="background-color:#ff0000">NO</SPAN>';
}
- },
+ };
+ $align .= 'c';
+}
+if ( $class eq 'S' ) {
+ push @header, 'Suspension fee';
+ push @fields,
sub {
my $reason = shift;
my $feepart = $reason->feepart;
@@ -107,7 +109,7 @@ if ( $class eq 'S' ) {
$text .= '</FONT>';
}
;
- $align .= 'cl';
+ $align .= 'l';
}
# reason merge handling
diff --git a/httemplate/edit/process/quotation_pkg_detail.html b/httemplate/edit/process/quotation_pkg_detail.html
index 2fc420280..9e4ac3222 100644
--- a/httemplate/edit/process/quotation_pkg_detail.html
+++ b/httemplate/edit/process/quotation_pkg_detail.html
@@ -40,6 +40,9 @@ for ( my $row = 0; exists($param->{"detail$row"}); $row++ ) {
if $param->{"detail$row"} =~ /\S/;
}
-my $error = $quotation_pkg->set_details(@details);
+my $error = $quotation_pkg->set_details(
+ details => \@details,
+ copy_on_order => scalar($cgi->param('copy_on_order')) ? 'Y' : ''
+ );
</%init>
diff --git a/httemplate/edit/quotation_pkg_detail.html b/httemplate/edit/quotation_pkg_detail.html
index 80a904420..ae09b9c6a 100644
--- a/httemplate/edit/quotation_pkg_detail.html
+++ b/httemplate/edit/quotation_pkg_detail.html
@@ -21,6 +21,20 @@
<TD BGCOLOR="#ffffff"><% $part_pkg->comment |h %></TD>
</TR>
+ <TR>
+ <TD></TD>
+ <TD>
+ <SELECT NAME="copy_on_order">
+ <OPTION VALUE=""<% $copy_on_order ? '' : ' SELECTED' %>>
+ <% emt('Details will only appear on quotation') %>
+ </OPTION>
+ <OPTION VALUE="Y"<% $copy_on_order ? ' SELECTED' : '' %>>
+ <% emt('Copy details to invoice when placing order') %>
+ </OPTION>
+ </SELECT>
+ </TD>
+ </TR>
+
% my $row = 0;
% for ( @details ) {
@@ -111,6 +125,21 @@ my $part_pkg = $quotation_pkg->part_pkg;
my @details = $quotation_pkg->details;
+my $copy_on_order = 0;
+if (@details) {
+
+ # currently, they should either all have this flag, or none
+ # but just in case, erring on the side of not copying to invoice
+ # unless every existing detail has copy_on_order
+ # (anyway, user has to submit change, this is just for autofill)
+
+ my @quotation_pkg_detail = $quotation_pkg->quotation_pkg_detail;
+ my @copy_on_order = grep { $_->copy_on_order } @quotation_pkg_detail;
+ $copy_on_order = 1 if @copy_on_order;
+ my @no_copy_on_order = grep { !$_->copy_on_order } @quotation_pkg_detail;
+ $copy_on_order = 0 if @no_copy_on_order;
+}
+
my $title = ( scalar(@details) ? 'Edit ' : 'Add ' ). 'Quotation Details';
</%init>
diff --git a/httemplate/edit/reason.html b/httemplate/edit/reason.html
index 30168d551..331db4439 100644
--- a/httemplate/edit/reason.html
+++ b/httemplate/edit/reason.html
@@ -65,12 +65,14 @@ my @fields = (
},
);
-if ( $class eq 'S' ) {
+if ( $class eq 'S' or $class eq 'C' ) {
push @fields,
{ 'field' => 'unused_credit',
'type' => 'checkbox',
'value' => 'Y',
- },
+ };
+}
+if ( $class eq 'S' ) {
{ 'type' => 'tablebreak-tr-title' },
{ 'field' => 'feepart',
'type' => 'select-table',
diff --git a/httemplate/elements/tr-select-reason.html b/httemplate/elements/tr-select-reason.html
index 47acd854b..3b9bb2299 100755
--- a/httemplate/elements/tr-select-reason.html
+++ b/httemplate/elements/tr-select-reason.html
@@ -120,6 +120,13 @@ Example:
&>
% } # scalar(@types)
+% if ( $class eq 'C' ) {
+ <& tr-checkbox.html,
+ label => 'Credit the unused portion of service when canceling',
+ field => $id.'_new_unused_credit',
+ value => 'Y'
+ &>
+% }
% if ( $class eq 'S' ) {
<& tr-checkbox.html,
label => 'Credit the unused portion of service when suspending',
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>