[freeside-commits] freeside/FS/FS cust_main.pm, 1.574, 1.575 prospect_main.pm, 1.4, 1.5
Ivan,,,
ivan at wavetail.420.am
Sun Mar 27 15:46:40 PDT 2011
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv28613/FS/FS
Modified Files:
cust_main.pm prospect_main.pm
Log Message:
better prospect -> customer conversion, RT#7111
Index: prospect_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/prospect_main.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -d -r1.4 -r1.5
--- prospect_main.pm 21 Mar 2011 00:55:12 -0000 1.4
+++ prospect_main.pm 27 Mar 2011 22:46:37 -0000 1.5
@@ -8,6 +8,7 @@
use FS::agent;
use FS::cust_location;
use FS::contact;
+use FS::qual;
$DEBUG = 0;
@@ -221,7 +222,7 @@
my $contact = ($self->contact)[0]; #first contact? good enough for now
return $contact->line if $contact;
- $self->prospectnum;
+ 'Prospect #'. $self->prospectnum;
}
=item contact
@@ -246,6 +247,18 @@
qsearch( 'cust_location', { 'prospectnum' => $self->prospectnum } );
}
+=item qual
+
+Returns the qualifications (see L<FS::qual>) associated with this prospect.
+
+=cut
+
+sub qual {
+ my $self = shift;
+ qsearch( 'qual', { 'prospectnum' => $self->prospectnum } );
+}
+
+
=item search HASHREF
(Class method)
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.574
retrieving revision 1.575
diff -u -w -d -r1.574 -r1.575
--- cust_main.pm 20 Jan 2011 23:05:57 -0000 1.574
+++ cust_main.pm 27 Mar 2011 22:46:36 -0000 1.575
@@ -67,6 +67,7 @@
use FS::banned_pay;
use FS::cust_main_note;
use FS::cust_attachment;
+use FS::contact;
# 1 is mostly method/subroutine entry and options
# 2 traces progress of some operations
@@ -368,7 +369,8 @@
$cust_main->insert( {}, [ $email, 'POST' ] );
-Currently available options are: I<depend_jobnum>, I<noexport> and I<tax_exemption>.
+Currently available options are: I<depend_jobnum>, I<noexport>,
+I<tax_exemption> and I<prospectnum>.
If I<depend_jobnum> is set, all provisioning jobs will have a dependancy
on the supplied jobnum (they will not run until the specific job completes).
@@ -382,6 +384,8 @@
The I<tax_exemption> option can be set to an arrayref of tax names.
FS::cust_main_exemption records will be created and inserted.
+If I<prospectnum> is set, moves contacts and locations from that prospect.
+
=cut
sub insert {
@@ -480,16 +484,41 @@
}
}
- if ( $invoicing_list ) {
- $error = $self->check_invoicing_list( $invoicing_list );
+ my $prospectnum = delete $options{'prospectnum'};
+ if ( $prospectnum ) {
+
+ warn " moving contacts and locations from prospect $prospectnum\n"
+ if $DEBUG > 1;
+
+ my $prospect_main =
+ qsearchs('prospect_main', { 'prospectnum' => $prospectnum } );
+ unless ( $prospect_main ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "Unknown prospectnum $prospectnum";
+ }
+ $prospect_main->custnum($self->custnum);
+ $prospect_main->disabled('Y');
+ my $error = $prospect_main->replace;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+
+ my @contact = $prospect_main->contact;
+ my @cust_location = $prospect_main->cust_location;
+ my @qual = $prospect_main->qual;
+
+ foreach my $r ( @contact, @cust_location, @qual ) {
+ $r->prospectnum('');
+ $r->custnum($self->custnum);
+ my $error = $r->replace;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
- #return "checking invoicing_list (transaction rolled back): $error";
return $error;
}
- $self->invoicing_list( $invoicing_list );
}
+ }
warn " setting cust_main_exemption\n"
if $DEBUG > 1;
@@ -2033,6 +2062,18 @@
qsearch('cust_location', { 'custnum' => $self->custnum } );
}
+=item cust_contact
+
+Returns all contacts (see L<FS::contact>) for this customer.
+
+=cut
+
+#already used :/ sub contact {
+sub cust_contact {
+ my $self = shift;
+ qsearch('contact', { 'custnum' => $self->custnum } );
+}
+
=item unsuspend
Unsuspends all unflagged suspended packages (see L</unflagged_suspended_pkgs>
More information about the freeside-commits
mailing list