summaryrefslogtreecommitdiff
path: root/FS/FS/cust_main/Location.pm
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-02-17 14:21:53 -0800
committerIvan Kohler <ivan@freeside.biz>2013-02-17 14:21:53 -0800
commitc13c6407510f6fd1783ce0fbd97800afa27c30b5 (patch)
tree2aa89f3303f46f08bc82f109eae4b9cc313db676 /FS/FS/cust_main/Location.pm
parent4e619bb76046bc35f0d7d29ae743b629f2a34030 (diff)
parent8b590098fbd78765f97d44f5500a967b4afdbbe1 (diff)
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'FS/FS/cust_main/Location.pm')
-rw-r--r--FS/FS/cust_main/Location.pm30
1 files changed, 22 insertions, 8 deletions
diff --git a/FS/FS/cust_main/Location.pm b/FS/FS/cust_main/Location.pm
index ba3513b2f..bd0af5348 100644
--- a/FS/FS/cust_main/Location.pm
+++ b/FS/FS/cust_main/Location.pm
@@ -167,15 +167,29 @@ sub _upgrade_data {
$cust_main->set(bill_locationnum => $bill_location->locationnum);
if ( $cust_main->get('ship_address1') ) {
- my $ship_location = FS::cust_location->new(
- {
- custnum => $custnum,
- map { $_ => $cust_main->get("ship_$_") } location_fields()
+ # detect duplicates
+ my $same = 1;
+ my $ship_location;
+ foreach (location_fields()) {
+ if ( length($cust_main->get("ship_$_")) and
+ $cust_main->get($_) ne $cust_main->get("ship_$_") ) {
+ $same = 0;
}
- );
- $error = $ship_location->insert;
- die "error migrating service address for customer $custnum: $error"
- if $error;
+ }
+
+ if ( $same ) {
+ $ship_location = $bill_location;
+ } else {
+ $ship_location = FS::cust_location->new(
+ {
+ custnum => $custnum,
+ map { $_ => $cust_main->get("ship_$_") } location_fields()
+ }
+ );
+ $error = $ship_location->insert;
+ die "error migrating service address for customer $custnum: $error"
+ if $error;
+ }
$cust_main->set(ship_locationnum => $ship_location->locationnum);