[freeside-commits] freeside/FS/FS part_pkg_taxclass.pm, 1.1, 1.2 Upgrade.pm, 1.4, 1.5
Ivan,,,
ivan at wavetail.420.am
Tue Feb 19 17:19:47 PST 2008
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv20437/FS/FS
Modified Files:
part_pkg_taxclass.pm Upgrade.pm
Log Message:
update the tax class editor to enable taxclass adding, RT#2929
Index: part_pkg_taxclass.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg_taxclass.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- part_pkg_taxclass.pm 19 Feb 2008 09:15:14 -0000 1.1
+++ part_pkg_taxclass.pm 20 Feb 2008 01:19:45 -0000 1.2
@@ -2,6 +2,7 @@
use strict;
use vars qw( @ISA );
+use FS::UID qw(dbh);
use FS::Record qw( qsearch qsearchs );
@ISA = qw(FS::Record);
@@ -100,8 +101,7 @@
my $self = shift;
my $error =
- $self->ut_numbern('serial')
- || $self->ut_number('taxclassnum')
+ $self->ut_numbern('taxclassnum')
|| $self->ut_text('taxclass')
;
return $error if $error;
@@ -111,6 +111,38 @@
=back
+=cut
+
+# _upgrade_data
+#
+# Used by FS::Upgrade to migrate to a new database.
+
+sub _upgrade_data { # class method
+ my ($class, %opts) = @_;
+
+ my $sth = dbh->prepare('
+ SELECT DISTINCT taxclass
+ FROM cust_main_county
+ LEFT JOIN part_pkg_taxclass USING ( taxclass )
+ WHERE taxclassnum IS NULL
+ AND taxclass IS NOT NULL
+ ') or die dbh->errstr;
+ $sth->execute or die $sth->errstr;
+ my %taxclass = map { $_->[0] => 1 } @{$sth->fetchall_arrayref};
+ my @taxclass = grep $_, keys %taxclass;
+
+ foreach my $taxclass ( @taxclass ) {
+
+ my $part_pkg_taxclass = new FS::part_pkg_taxclass ( {
+ 'taxclass' => $taxclass,
+ } );
+ my $error = $part_pkg_taxclass->insert;
+ die $error if $error;
+
+ }
+
+}
+
=head1 BUGS
Other tables (cust_main_county, part_pkg, agent_payment_gateway) have a text
Index: Upgrade.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Upgrade.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Upgrade.pm 14 Feb 2008 03:52:36 -0000 1.4
+++ Upgrade.pm 20 Feb 2008 01:19:45 -0000 1.5
@@ -49,8 +49,12 @@
eval "use $class;";
die $@ if $@;
- $class->_upgrade_data(%opt)
- if $class->can('_upgrade_data');
+ if ( $class->can('_upgrade_data') ) {
+ $class->_upgrade_data(%opt);
+ } else {
+ warn "WARNING: asked for upgrade of $table,".
+ " but FS::$table has no _upgrade_data method\n";
+ }
# my @records = @{ $data->{$table} };
#
@@ -88,6 +92,10 @@
#populate cust_pay.otaker
'cust_pay' => [],
+
+ #populate part_pkg_taxclass for starters
+ 'part_pkg_taxclass' => [],
+
;
\%hash;
More information about the freeside-commits
mailing list