summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-09-16 06:38:09 -0700
committerIvan Kohler <ivan@freeside.biz>2014-09-16 06:38:09 -0700
commita1c723188509e9e251b233672e68327bb4ad42e7 (patch)
treeb18fc05298bda50aa3fdff8b70cb97138a5104db /FS
parentf1885b7eb233b3853f0e8baba781846f55bf64ae (diff)
convert prospects to customers via quotations, RT#20688
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Schema.pm6
-rw-r--r--FS/FS/cust_main.pm26
2 files changed, 21 insertions, 11 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 02fcf8e..1de3709 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -1811,10 +1811,11 @@ sub tables_hashref {
'add_date', @date_type, '', '',
'disabled', 'char', 'NULL', 1, '', '',
'custnum', 'int', 'NULL', '', '', '',
+ 'refnum', 'int', 'NULL', '', '', '',
],
'primary_key' => 'prospectnum',
'unique' => [],
- 'index' => [ [ 'company' ], [ 'agentnum' ], [ 'disabled' ] ],
+ 'index' => [ ['company'], ['agentnum'], ['disabled'], ['refnum'] ],
'foreign_keys' => [
{ columns => [ 'agentnum' ],
table => 'agent',
@@ -1822,6 +1823,9 @@ sub tables_hashref {
{ columns => [ 'custnum' ],
table => 'cust_main',
},
+ { columns => [ 'refnum' ],
+ table => 'part_referral',
+ },
],
},
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index cbf95f5..9b893ea 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -414,14 +414,9 @@ sub insert {
# insert locations
foreach my $l (qw(bill_location ship_location)) {
- my $loc = delete $self->hashref->{$l};
- # XXX if we're moving a prospect's locations, do that here
- if ( !$loc ) {
- #return "$l not set";
- #location-less customer records are now permitted
- next;
- }
-
+
+ my $loc = delete $self->hashref->{$l} or next;
+
if ( !$loc->locationnum ) {
# warn the location that we're going to insert it with no custnum
$loc->set(custnum_pending => 1);
@@ -433,8 +428,19 @@ sub insert {
my $label = $l eq 'ship_location' ? 'service' : 'billing';
return "$error (in $label location)";
}
- }
- elsif ( ($loc->custnum || 0) > 0 or $loc->prospectnum ) {
+
+ } elsif ( $loc->prospectnum ) {
+
+ $loc->prospectnum('');
+ $loc->set(custnum_pending => 1);
+ my $error = $loc->replace;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ my $label = $l eq 'ship_location' ? 'service' : 'billing';
+ return "$error (moving $label location)";
+ }
+
+ } elsif ( ($loc->custnum || 0) > 0 ) {
# then it somehow belongs to another customer--shouldn't happen
$dbh->rollback if $oldAutoCommit;
return "$l belongs to customer ".$loc->custnum;