[freeside-commits] branch master updated. 8a537c7d535a26aec3b5ae38eddc7a813a42a270
Mark Wells
mark at 420.am
Thu Feb 14 17:06:12 PST 2013
The branch, master has been updated
via 8a537c7d535a26aec3b5ae38eddc7a813a42a270 (commit)
from e55892bdf6dc95710a19876087690a9664421215 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 8a537c7d535a26aec3b5ae38eddc7a813a42a270
Author: Mark Wells <mark at freeside.biz>
Date: Thu Feb 14 17:04:42 2013 -0800
don't create duplicate locations when ship and bill addresses are the same, #940
diff --git a/FS/FS/cust_main/Location.pm b/FS/FS/cust_main/Location.pm
index ba3513b..bd0af53 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);
-----------------------------------------------------------------------
Summary of changes:
FS/FS/cust_main/Location.pm | 30 ++++++++++++++++++++++--------
1 files changed, 22 insertions(+), 8 deletions(-)
More information about the freeside-commits
mailing list