Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 35183016

Von Tamino Steinert vor etwa 1 Jahr hinzugefügt

DB::Order: Persistenter Record-Type

Unterschiede anzeigen:

SL/DB/MetaSetup/Order.pm
26 26
  expected_billing_date   => { type => 'date' },
27 27
  globalproject_id        => { type => 'integer' },
28 28
  id                      => { type => 'integer', not_null => 1, sequence => 'id' },
29
  intake                  => { type => 'boolean', default => 'false', not_null => 1 },
30 29
  intnotes                => { type => 'text' },
31 30
  itime                   => { type => 'timestamp', default => 'now()' },
32 31
  language_id             => { type => 'integer' },
......
41 40
  payment_id              => { type => 'integer' },
42 41
  proforma                => { type => 'boolean', default => 'false' },
43 42
  quonumber               => { type => 'text' },
44
  quotation               => { type => 'boolean', default => 'false' },
43
  record_type             => { type => 'enum', check_in => [ 'request_quotation', 'sales_quotation', 'purchase_quotation_intake', 'purchase_order', 'sales_order_intake', 'sales_order' ], db_type => 'order_types', not_null => 1 },
45 44
  reqdate                 => { type => 'date' },
46 45
  salesman_id             => { type => 'integer' },
47 46
  shippingpoint           => { type => 'text' },
sql/Pg-upgrade2/order_type.sql
1
-- @tag: order_type
2
-- @description: Persistente Typen in Aufträgen
3
-- @depends: release_3_7_0 oe_sales_order_intake_type
4

  
5
CREATE TYPE order_types AS ENUM (
6
  'request_quotation',
7
  'sales_quotation',
8
  'purchase_quotation_intake',
9
  'purchase_order',
10
  'sales_order_intake',
11
  'sales_order'
12
);
13

  
14
ALTER TABLE oe ADD COLUMN record_type order_types;
15

  
16
UPDATE oe SET record_type = 'sales_order'
17
  WHERE customer_id IS NOT NULL and (quotation = FALSE or quotation is null) and intake = FALSE;
18
UPDATE oe SET record_type = 'purchase_order'
19
  WHERE vendor_id   IS NOT NULL and (quotation = FALSE or quotation is null) and intake = FALSE;
20

  
21
UPDATE oe SET record_type = 'sales_quotation'
22
  WHERE customer_id IS NOT NULL and quotation = TRUE and intake = FALSE;
23
UPDATE oe SET record_type = 'request_quotation'
24
  WHERE vendor_id   IS NOT NULL and quotation = TRUE and intake = FALSE;
25

  
26
UPDATE oe SET record_type = 'sales_order_intake'
27
  WHERE customer_id IS NOT NULL and (quotation = FALSE or quotation is null) and intake = TRUE;
28
UPDATE oe SET record_type = 'purchase_quotation_intake'
29
  WHERE vendor_id   IS NOT NULL and quotation = TRUE and intake = TRUE;
30

  
31

  
32
ALTER TABLE oe ALTER COLUMN record_type SET NOT NULL;
33

  
34
ALTER TABLE oe DROP COLUMN quotation;
35
ALTER TABLE oe DROP COLUMN intake;

Auch abrufbar als: Unified diff