use FS::cust_svc;
use FS::part_pkg;
use FS::cust_main;
+use FS::type_pkgs;
# need to 'use' these instead of 'require' in sub { cancel, suspend, unsuspend,
# setup }
Adds this billing item to the database ("Orders" the item). If there is an
error, returns the error, otherwise returns false.
+sub insert {
+ my $self = shift;
+
+ # custnum might not have have been defined in sub check (for one-shot new
+ # customers), so check it here instead
+
+ my $error = $self->ut_number('custnum');
+ return $error if $error
+
+ return "Unknown customer"
+ unless qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
+
+ $self->SUPER::insert;
+
+}
+
=item delete
Currently unimplemented. You don't want to delete billing items, because there
my $error =
$self->ut_numbern('pkgnum')
- || $self->ut_number('custnum')
+ || $self->ut_numbern('custnum')
|| $self->ut_number('pkgpart')
|| $self->ut_numbern('setup')
|| $self->ut_numbern('bill')
;
return $error if $error;
- return "Unknown customer"
- unless qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
+ if ( $self->custnum ) {
+ return "Unknown customer"
+ unless qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
+ }
return "Unknown pkgpart"
unless qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } );
sub order {
my($custnum,$pkgparts,$remove_pkgnums)=@_;
- my(%part_pkg);
# generate %part_pkg
# $part_pkg{$pkgpart} is true iff $custnum may purchase $pkgpart
- my($cust_main)=qsearchs('cust_main',{'custnum'=>$custnum});
- my($agent)=qsearchs('agent',{'agentnum'=> $cust_main->agentnum });
-
- my($type_pkgs);
- foreach $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) {
- my($pkgpart)=$type_pkgs->pkgpart;
- $part_pkg{$pkgpart}++;
- }
#
+ my($cust_main)=qsearchs('cust_main',{'custnum'=>$custnum});
+ my($agent)=qsearchs('agent',{'agentnum'=> $cust_main->agentnum });
+ my %part_pkg = %{ $agent->pkgpart_hashref };
my(%svcnum);
# generate %svcnum
=head1 VERSION
-$Id: cust_pkg.pm,v 1.7 1999-02-09 09:55:06 ivan Exp $
+$Id: cust_pkg.pm,v 1.10 1999-07-20 10:37:05 ivan Exp $
=head1 BUGS
pod ivan@sisd.com 98-sep-21
$Log: cust_pkg.pm,v $
-Revision 1.7 1999-02-09 09:55:06 ivan
+Revision 1.10 1999-07-20 10:37:05 ivan
+cleaned up the new one-screen signup bits in htdocs/edit/cust_main.cgi to
+prepare for a signup server
+
+Revision 1.9 1999/03/29 01:11:51 ivan
+use FS::type_pkgs
+
+Revision 1.8 1999/03/25 13:48:14 ivan
+allow empty custnum in sub check (but call that an error in sub insert),
+for one-screen new customer entry
+
+Revision 1.7 1999/02/09 09:55:06 ivan
invoices show line items for each service in a package (see the label method
of FS::cust_svc)