X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fquotation.pm;h=c61e001c6a84efa9442b8ead5b43cae38e37d29b;hb=c22d84e565ab16db142395dce2e8621624eff140;hp=db8b0fcb38ed05be5e01cbbd001d6d72e6a75bfc;hpb=8b70832328eb02dc9253dab7b436c6479b588162;p=freeside.git diff --git a/FS/FS/quotation.pm b/FS/FS/quotation.pm index db8b0fcb3..c61e001c6 100644 --- a/FS/FS/quotation.pm +++ b/FS/FS/quotation.pm @@ -138,6 +138,9 @@ sub check { $self->usernum($FS::CurrentUser::CurrentUser->usernum) unless $self->usernum; + return 'confidence must be an integer between 1 and 100' + if length($self->confidence) && (($self->confidence < 1) || ($self->confidence > 100)); + return 'prospectnum or custnum must be specified' if ! $self->prospectnum && ! $self->custnum; @@ -277,8 +280,8 @@ sub _items_sections { 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; @@ -347,7 +350,7 @@ sub _items_sections { 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. @@ -359,10 +362,13 @@ packages as real packages for the customer. If there is an error, returns an error message, otherwise, returns the newly-created FS::cust_main object. +Accepts the same params as L. + =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 @@ -379,7 +385,7 @@ sub convert_cust_main { $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; @@ -391,7 +397,7 @@ sub convert_cust_main { } -=item order [ HASHREF ] +=item order [ HASHREF ] [ PARAMS ] This method is for use with quotations which are already associated with a customer. @@ -403,11 +409,16 @@ If HASHREF is passed, it will be filled with a hash mapping the C of each quoted package to the C 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'; @@ -458,10 +469,11 @@ sub order { } } - 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) { @@ -470,6 +482,13 @@ sub order { } $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 } @@ -1050,7 +1069,11 @@ sub _items_pkg { $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);