taxincluded => { type => 'boolean' },
taxincluded_checked => { type => 'boolean' },
taxnumber => { type => 'text' },
- taxzone_id => { type => 'integer', default => '0', not_null => 1 },
+ taxzone_id => { type => 'integer', not_null => 1 },
terms => { type => 'integer', default => '0' },
user_password => { type => 'text' },
username => { type => 'text' },
class => 'SL::DB::PaymentTerm',
key_columns => { payment_id => 'id' },
},
+
+ taxzone => {
+ class => 'SL::DB::TaxZone',
+ key_columns => { taxzone_id => 'id' },
+ },
);
1;
street => { type => 'text' },
taxincluded => { type => 'boolean' },
taxnumber => { type => 'text' },
- taxzone_id => { type => 'integer', default => '0', not_null => 1 },
+ taxzone_id => { type => 'integer', not_null => 1 },
terms => { type => 'integer', default => '0' },
user_password => { type => 'text' },
username => { type => 'text' },
class => 'SL::DB::PaymentTerm',
key_columns => { payment_id => 'id' },
},
+
+ taxzone => {
+ class => 'SL::DB::TaxZone',
+ key_columns => { taxzone_id => 'id' },
+ },
);
1;
$query = qq|DELETE FROM tax_zones WHERE id=0|;
$self->db_query($query);
- #Adapt other tables to the new id:
+ #Adapt ar/ap and customer/vendor tables to the new taxzone_id
$query = qq|UPDATE ar SET taxzone_id=$id WHERE taxzone_id=0|;
$self->db_query($query);
$query = qq|UPDATE ap SET taxzone_id=$id WHERE taxzone_id=0|;
$self->db_query($query);
+
+ $query = qq|UPDATE customer SET taxzone_id=$id WHERE taxzone_id=0|;
+ $self->db_query($query);
+
+ $query = qq|UPDATE vendor SET taxzone_id=$id WHERE taxzone_id=0|;
+ $self->db_query($query);
}
+ # Remove default 0 for taxzone_id
+ $query = qq|ALTER TABLE customer ALTER COLUMN taxzone_id DROP default|;
+ $self->db_query($query);
+
+ $query = qq|ALTER TABLE vendor ALTER COLUMN taxzone_id DROP default|;
+ $self->db_query($query);
+
#Set Constraints:
$query = qq|ALTER TABLE ar ADD FOREIGN KEY (taxzone_id) REFERENCES tax_zones (id)|;
$self->db_query($query);
$query = qq|ALTER TABLE ap ADD FOREIGN KEY (taxzone_id) REFERENCES tax_zones (id)|;
$self->db_query($query);
+ $query = qq|ALTER TABLE customer ADD FOREIGN KEY (taxzone_id) REFERENCES tax_zones (id)|;
+ $self->db_query($query);
+
+ $query = qq|ALTER TABLE vendor ADD FOREIGN KEY (taxzone_id) REFERENCES tax_zones (id)|;
+ $self->db_query($query);
+
$sth->finish;
return 1;