my $part_pkg = $pkg->part_pkg;
my $recur_freq = $part_pkg->freq;
- $show{$recur_freq} = 1 if $pkg->unitrecur > 0;
- $show{0} = 1 if $pkg->unitsetup > 0;
+ $show{$recur_freq} = 1 if $pkg->unitrecur > 0 or $pkg->recur_show_zero;
+ $show{0} = 1 if $pkg->unitsetup > 0 or $pkg->setup_show_zero;
($subtotals{0} ||= 0) += $pkg->setup + $pkg->setup_tax;
($subtotals{$recur_freq} ||= 0) += $pkg->recur + $pkg->recur_tax;
sub enable_previous { 0 }
-=item convert_cust_main
+=item convert_cust_main [ PARAMS ]
If this quotation already belongs to a customer, then returns that customer, as
an FS::cust_main object.
If there is an error, returns an error message, otherwise, returns the
newly-created FS::cust_main object.
+Accepts the same params as L</order>.
+
=cut
sub convert_cust_main {
my $self = shift;
+ my $params = shift || {};
my $cust_main = $self->cust_main;
return $cust_main if $cust_main; #already converted, don't again
$self->prospectnum('');
$self->custnum( $cust_main->custnum );
- my $error = $self->replace || $self->order;
+ my $error = $self->replace || $self->order(undef,$params);
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;
}
-=item order [ HASHREF ]
+=item order [ HASHREF ] [ PARAMS ]
This method is for use with quotations which are already associated with a customer.
C<quotationpkgnum> of each quoted package to the C<pkgnum> of the package
as ordered.
+If PARAMS hashref is passed, the following params are accepted:
+
+onhold - if true, suspends newly ordered packages
+
=cut
sub order {
my $self = shift;
my $pkgnum_map = shift || {};
+ my $params = shift || {};
my $details_map = {};
tie my %all_cust_pkg, 'Tie::RefHash';
}
}
- foreach my $quotationpkgnum (keys %$pkgnum_map) {
- # convert the objects to just pkgnums
- my $cust_pkg = $pkgnum_map->{$quotationpkgnum};
- $pkgnum_map->{$quotationpkgnum} = $cust_pkg->pkgnum;
+ if ($$params{'onhold'}) {
+ foreach my $quotationpkgnum (keys %$pkgnum_map) {
+ last if $error;
+ $error = $pkgnum_map->{$quotationpkgnum}->suspend();
+ }
}
if ($error) {
}
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
+
+ foreach my $quotationpkgnum (keys %$pkgnum_map) {
+ # convert the objects to just pkgnums
+ my $cust_pkg = $pkgnum_map->{$quotationpkgnum};
+ $pkgnum_map->{$quotationpkgnum} = $cust_pkg->pkgnum;
+ }
+
''; #no error
}
$quotation_pkg->get('unit'.$setuprecur));
$this_item->{'amount'} = sprintf('%.2f', $this_item->{'unit_amount'}
* $quotation_pkg->quantity);
- next if $this_item->{'amount'} == 0;
+ next if $this_item->{'amount'} == 0 and !(
+ $setuprecur eq 'setup'
+ ? $quotation_pkg->setup_show_zero
+ : $quotation_pkg->recur_show_zero
+ );
if ( $preref ) {
$this_item->{'preref_html'} = &$preref($quotation_pkg);