Revision cc872430
Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt
SL/DB/MetaSetup/DeliveryOrder.pm | ||
---|---|---|
shipto_id => { type => 'integer' },
|
||
shipvia => { type => 'text' },
|
||
taxincluded => { type => 'boolean' },
|
||
taxzone_id => { type => 'integer' },
|
||
taxzone_id => { type => 'integer', not_null => 1 },
|
||
terms => { type => 'integer' },
|
||
transaction_description => { type => 'text' },
|
||
transdate => { type => 'date', default => 'now()' },
|
||
... | ... | |
key_columns => { shipto_id => 'shipto_id' },
|
||
},
|
||
|
||
taxzone => {
|
||
class => 'SL::DB::TaxZone',
|
||
key_columns => { taxzone_id => 'id' },
|
||
},
|
||
|
||
vendor => {
|
||
class => 'SL::DB::Vendor',
|
||
key_columns => { vendor_id => 'id' },
|
SL/DB/MetaSetup/Invoice.pm | ||
---|---|---|
storno => { type => 'boolean', default => 'false' },
|
||
storno_id => { type => 'integer' },
|
||
taxincluded => { type => 'boolean' },
|
||
taxzone_id => { type => 'integer' },
|
||
taxzone_id => { type => 'integer', not_null => 1 },
|
||
terms => { type => 'integer', default => '0' },
|
||
transaction_description => { type => 'text' },
|
||
transdate => { type => 'date', default => 'now' },
|
SL/DB/MetaSetup/Order.pm | ||
---|---|---|
shipto_id => { type => 'integer' },
|
||
shipvia => { type => 'text' },
|
||
taxincluded => { type => 'boolean' },
|
||
taxzone_id => { type => 'integer' },
|
||
taxzone_id => { type => 'integer', not_null => 1 },
|
||
transaction_description => { type => 'text' },
|
||
transdate => { type => 'date', default => 'now' },
|
||
vendor_id => { type => 'integer' },
|
||
... | ... | |
key_columns => { shipto_id => 'shipto_id' },
|
||
},
|
||
|
||
taxzone => {
|
||
class => 'SL::DB::TaxZone',
|
||
key_columns => { taxzone_id => 'id' },
|
||
},
|
||
|
||
vendor => {
|
||
class => 'SL::DB::Vendor',
|
||
key_columns => { vendor_id => 'id' },
|
SL/DB/MetaSetup/PurchaseInvoice.pm | ||
---|---|---|
storno => { type => 'boolean', default => 'false' },
|
||
storno_id => { type => 'integer' },
|
||
taxincluded => { type => 'boolean', default => 'false' },
|
||
taxzone_id => { type => 'integer' },
|
||
taxzone_id => { type => 'integer', not_null => 1 },
|
||
transaction_description => { type => 'text' },
|
||
transdate => { type => 'date', default => 'now' },
|
||
type => { type => 'text' },
|
sql/Pg-upgrade2/taxzone_id_in_oe_delivery_orders.sql | ||
---|---|---|
-- @tag: taxzone_id_in_oe_delivery_orders
|
||
-- @description: Werte für Inland in Spalte taxzone_id in Tabellen oe und delivery_orders in Foreign Key zu tax_zones konvertieren; NULL-Werte in ap/ar verhindern; Spalten NOT NULL setzen
|
||
-- @depends: change_taxzone_id_0
|
||
|
||
UPDATE oe SET taxzone_id = (SELECT id FROM tax_zones WHERE description = 'Inland') WHERE (taxzone_id = 0) OR (taxzone_id IS NULL);
|
||
UPDATE delivery_orders SET taxzone_id = (SELECT id FROM tax_zones WHERE description = 'Inland') WHERE (taxzone_id = 0) OR (taxzone_id IS NULL);
|
||
UPDATE ar SET taxzone_id = (SELECT id FROM tax_zones WHERE description = 'Inland') WHERE (taxzone_id = 0) OR (taxzone_id IS NULL);
|
||
UPDATE ap SET taxzone_id = (SELECT id FROM tax_zones WHERE description = 'Inland') WHERE (taxzone_id = 0) OR (taxzone_id IS NULL);
|
||
|
||
ALTER TABLE oe ALTER COLUMN taxzone_id SET NOT NULL;
|
||
ALTER TABLE delivery_orders ALTER COLUMN taxzone_id SET NOT NULL;
|
||
ALTER TABLE ar ALTER COLUMN taxzone_id SET NOT NULL;
|
||
ALTER TABLE ap ALTER COLUMN taxzone_id SET NOT NULL;
|
||
|
||
ALTER TABLE oe ADD CONSTRAINT oe_taxzone_id_fkey FOREIGN KEY (taxzone_id) REFERENCES tax_zones (id);
|
||
ALTER TABLE delivery_orders ADD CONSTRAINT delivery_orders_taxzone_id_fkey FOREIGN KEY (taxzone_id) REFERENCES tax_zones (id);
|
Auch abrufbar als: Unified diff
Bearb. Buchungsgruppen: Spalte taxzone_id in oe/delivery_orders konvertieren
1. Werte 0 und NULL durch neue ID für »Inland« ersetzen (oe,
delivery_orders, ar, ap)
2. Spalte taxzone_id NOT NULL setzen (oe, delivery_orders, ar, ap)
3. Fremdschlüssel auf Tabelle tax_zones setzen (oe, delivery_orders)