[freeside-commits] freeside/FS/FS Setup.pm,1.7,1.8
Ivan,,,
ivan at wavetail.420.am
Fri Dec 15 00:37:17 PST 2006
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv21266/FS/FS
Modified Files:
Setup.pm
Log Message:
add a quick tool for adding states to old databases
Index: Setup.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Setup.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Setup.pm 7 Dec 2006 15:24:59 -0000 1.7
+++ Setup.pm 15 Dec 2006 08:37:15 -0000 1.8
@@ -61,30 +61,11 @@
sub populate_locales {
use Locale::Country;
- use Locale::SubCountry;
use FS::cust_main_county;
#cust_main_county
foreach my $country ( sort map uc($_), all_country_codes ) {
-
- my $subcountry = eval { new Locale::SubCountry($country) };
- my @states = $subcountry ? $subcountry->all_codes : undef;
-
- if ( !scalar(@states) || ( scalar(@states)==1 && !defined($states[0]) ) ) {
-
- _add_locale( 'country'=>$country );
-
- } else {
-
- if ( $states[0] =~ /^(\d+|\w)$/ ) {
- @states = map $subcountry->full_name($_), @states
- }
-
- foreach my $state ( @states ) {
- _add_locale( 'country'=>$country, 'state'=>$state);
- }
-
- }
+ _add_country($country);
}
}
@@ -111,6 +92,33 @@
}
+sub _add_country {
+
+ use Locale::SubCountry;
+
+ my( $country ) = shift;
+
+ my $subcountry = eval { new Locale::SubCountry($country) };
+ my @states = $subcountry ? $subcountry->all_codes : undef;
+
+ if ( !scalar(@states) || ( scalar(@states)==1 && !defined($states[0]) ) ) {
+
+ _add_locale( 'country'=>$country );
+
+ } else {
+
+ if ( $states[0] =~ /^(\d+|\w)$/ ) {
+ @states = map $subcountry->full_name($_), @states
+ }
+
+ foreach my $state ( @states ) {
+ _add_locale( 'country'=>$country, 'state'=>$state);
+ }
+
+ }
+
+}
+
sub _add_locale {
my $cust_main_county = new FS::cust_main_county( { 'tax'=>0, @_ });
my $error = $cust_main_county->insert;
More information about the freeside-commits
mailing list