[freeside-commits] freeside/FS/FS cust_main.pm,1.240,1.241
Ivan,,,
ivan at wavetail.420.am
Mon Aug 21 10:45:33 PDT 2006
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv31721
Modified Files:
cust_main.pm
Log Message:
search for existing advertising sources before adding a new one
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.240
retrieving revision 1.241
diff -u -d -r1.240 -r1.241
--- cust_main.pm 18 Aug 2006 12:18:19 -0000 1.240
+++ cust_main.pm 21 Aug 2006 17:45:31 -0000 1.241
@@ -4466,16 +4466,21 @@
if ( $field eq 'refnum' && $columns[0] !~ /^\s*(\d+)\s*$/ ) {
my $referral = $columns[0];
- my $part_referral = new FS::part_referral {
- 'referral' => $referral,
- 'agentnum' => $agentnum,
- };
+ my %hash = ( 'referral' => $referral,
+ 'agentnum' => $agentnum,
+ );
- my $error = $part_referral->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "can't auto-insert advertising source: $referral: $error";
+ my $part_referral = qsearchs('part_referral', \%hash )
+ || new FS::part_referral \%hash;
+
+ unless ( $part_referral->refnum ) {
+ my $error = $part_referral->insert;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "can't auto-insert advertising source: $referral: $error";
+ }
}
+
$columns[0] = $part_referral->refnum;
}
More information about the freeside-commits
mailing list