Revision b632cee8
Von Moritz Bunkus vor fast 12 Jahren hinzugefügt
SL/DB/DeliveryOrderItem.pm | ||
---|---|---|
12 | 12 |
); |
13 | 13 |
|
14 | 14 |
__PACKAGE__->meta->make_manager_class; |
15 |
__PACKAGE__->meta->add_relationship( |
|
16 |
unit_obj => { |
|
17 |
type => 'one to one', |
|
18 |
class => 'SL::DB::Unit', |
|
19 |
column_map => { unit => 'name' }, |
|
20 |
}, |
|
21 |
); |
|
15 | 22 |
|
16 | 23 |
__PACKAGE__->meta->initialize; |
17 | 24 |
|
... | ... | |
19 | 26 |
|
20 | 27 |
sub part { |
21 | 28 |
# canonial alias for parts. |
22 |
return shift->parts;
|
|
29 |
goto &parts;
|
|
23 | 30 |
} |
24 | 31 |
|
25 | 32 |
1; |
SL/DB/InvoiceItem.pm | ||
---|---|---|
12 | 12 |
); |
13 | 13 |
|
14 | 14 |
__PACKAGE__->meta->add_relationship( |
15 |
part => { |
|
16 |
type => 'one to one', |
|
17 |
class => 'SL::DB::Part', |
|
18 |
column_map => { parts_id => 'id' }, |
|
19 |
}, |
|
20 |
price_factor_obj => { |
|
21 |
type => 'one to one', |
|
22 |
class => 'SL::DB::PriceFactor', |
|
23 |
column_map => { price_factor_id => 'id' }, |
|
24 |
}, |
|
25 | 15 |
unit_obj => { |
26 | 16 |
type => 'one to one', |
27 | 17 |
class => 'SL::DB::Unit', |
... | ... | |
34 | 24 |
|
35 | 25 |
__PACKAGE__->meta->initialize; |
36 | 26 |
|
27 |
sub part { |
|
28 |
# canonial alias for parts. |
|
29 |
goto &parts; |
|
30 |
} |
|
31 |
|
|
37 | 32 |
1; |
SL/DB/MetaSetup/DeliveryOrderItem.pm | ||
---|---|---|
55 | 55 |
key_columns => { price_factor_id => 'id' }, |
56 | 56 |
}, |
57 | 57 |
|
58 |
pricegroup => { |
|
59 |
class => 'SL::DB::Pricegroup', |
|
60 |
key_columns => { pricegroup_id => 'id' }, |
|
61 |
}, |
|
62 |
|
|
58 | 63 |
project => { |
59 | 64 |
class => 'SL::DB::Project', |
60 | 65 |
key_columns => { project_id => 'id' }, |
SL/DB/MetaSetup/InvoiceItem.pm | ||
---|---|---|
50 | 50 |
class => 'SL::DB::Part', |
51 | 51 |
key_columns => { parts_id => 'id' }, |
52 | 52 |
}, |
53 |
|
|
54 |
price_factor_obj => { |
|
55 |
class => 'SL::DB::PriceFactor', |
|
56 |
key_columns => { price_factor_id => 'id' }, |
|
57 |
}, |
|
58 |
|
|
59 |
pricegroup => { |
|
60 |
class => 'SL::DB::Pricegroup', |
|
61 |
key_columns => { pricegroup_id => 'id' }, |
|
62 |
}, |
|
63 |
|
|
64 |
project => { |
|
65 |
class => 'SL::DB::Project', |
|
66 |
key_columns => { project_id => 'id' }, |
|
67 |
}, |
|
53 | 68 |
], |
54 | 69 |
); |
55 | 70 |
|
SL/DB/MetaSetup/OrderItem.pm | ||
---|---|---|
48 | 48 |
class => 'SL::DB::Part', |
49 | 49 |
key_columns => { parts_id => 'id' }, |
50 | 50 |
}, |
51 |
|
|
52 |
price_factor_obj => { |
|
53 |
class => 'SL::DB::PriceFactor', |
|
54 |
key_columns => { price_factor_id => 'id' }, |
|
55 |
}, |
|
56 |
|
|
57 |
pricegroup => { |
|
58 |
class => 'SL::DB::Pricegroup', |
|
59 |
key_columns => { pricegroup_id => 'id' }, |
|
60 |
}, |
|
61 |
|
|
62 |
project => { |
|
63 |
class => 'SL::DB::Project', |
|
64 |
key_columns => { project_id => 'id' }, |
|
65 |
}, |
|
66 |
|
|
67 |
trans => { |
|
68 |
class => 'SL::DB::Order', |
|
69 |
key_columns => { trans_id => 'id' }, |
|
70 |
}, |
|
51 | 71 |
], |
52 | 72 |
); |
53 | 73 |
|
SL/DB/OrderItem.pm | ||
---|---|---|
16 | 16 |
); |
17 | 17 |
|
18 | 18 |
__PACKAGE__->meta->add_relationship( |
19 |
part => { |
|
20 |
type => 'one to one', |
|
21 |
class => 'SL::DB::Part', |
|
22 |
column_map => { parts_id => 'id' }, |
|
23 |
}, |
|
24 |
price_factor_obj => { |
|
25 |
type => 'one to one', |
|
26 |
class => 'SL::DB::PriceFactor', |
|
27 |
column_map => { price_factor_id => 'id' }, |
|
28 |
}, |
|
29 | 19 |
unit_obj => { |
30 | 20 |
type => 'one to one', |
31 | 21 |
class => 'SL::DB::Unit', |
32 | 22 |
column_map => { unit => 'name' }, |
33 | 23 |
}, |
34 |
order => { |
|
35 |
type => 'one to one', |
|
36 |
class => 'SL::DB::Order', |
|
37 |
column_map => { trans_id => 'id' }, |
|
38 |
}, |
|
39 | 24 |
); |
40 | 25 |
|
41 | 26 |
__PACKAGE__->meta->initialize; |
... | ... | |
54 | 39 |
return sum(map { AM->convert_unit($_->unit => $self->unit) * $_->qty } @doi); |
55 | 40 |
} |
56 | 41 |
|
42 |
sub part { |
|
43 |
# canonial alias for parts. |
|
44 |
goto &parts; |
|
45 |
} |
|
46 |
|
|
47 |
sub order { |
|
48 |
# canonial alias for trans. |
|
49 |
goto &trans; |
|
50 |
} |
|
51 |
|
|
57 | 52 |
1; |
SL/DO.pm | ||
---|---|---|
293 | 293 |
do_statement($form, $h_item_id, $q_item_id); |
294 | 294 |
my ($item_id) = $h_item_id->fetchrow_array(); |
295 | 295 |
|
296 |
# Get pricegroup_id and save it. Unfortunately the interface |
|
297 |
# also uses ID "0" for signalling that none is selected, but "0" |
|
298 |
# must not be stored in the database. Therefore we cannot simply |
|
299 |
# use conv_i(). |
|
300 |
my $pricegroup_id = $form->{"pricegroup_id_$i"} * 1; |
|
301 |
$pricegroup_id = undef if !$pricegroup_id; |
|
302 |
|
|
296 | 303 |
# save detail record in delivery_order_items table |
297 | 304 |
@values = (conv_i($item_id), conv_i($form->{id}), conv_i($form->{"id_$i"}), |
298 | 305 |
$form->{"description_$i"}, $form->{"longdescription_$i"}, |
... | ... | |
305 | 312 |
$form->{"lastcost_$i"}, |
306 | 313 |
conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"price_factor_id_$i"}), |
307 | 314 |
conv_i($form->{"marge_price_factor_$i"}), |
308 |
conv_i($form->{"pricegroup_id_$i"}));
|
|
315 |
$pricegroup_id);
|
|
309 | 316 |
do_statement($form, $h_item, $q_item, @values); |
310 | 317 |
|
311 | 318 |
my $stock_info = DO->unpack_stock_information('packed' => $form->{"stock_${in_out}_$i"}); |
SL/IS.pm | ||
---|---|---|
707 | 707 |
} |
708 | 708 |
} |
709 | 709 |
|
710 |
# get pricegroup_id and save it |
|
710 |
# Get pricegroup_id and save it. Unfortunately the interface |
|
711 |
# also uses ID "0" for signalling that none is selected, but "0" |
|
712 |
# must not be stored in the database. Therefore we cannot simply |
|
713 |
# use conv_i(). |
|
711 | 714 |
($null, my $pricegroup_id) = split(/--/, $form->{"sellprice_pg_$i"}); |
712 | 715 |
$pricegroup_id *= 1; |
716 |
$pricegroup_id = undef if !$pricegroup_id; |
|
713 | 717 |
|
714 | 718 |
my ($invoice_id) = selectfirst_array_query($form, $dbh, qq|SELECT nextval('invoiceid')|); |
715 | 719 |
|
... | ... | |
729 | 733 |
$form->{"sellprice_$i"}, $fxsellprice, |
730 | 734 |
$form->{"discount_$i"}, $allocated, 'f', |
731 | 735 |
$form->{"unit_$i"}, conv_date($form->{"reqdate_$i"}), conv_i($form->{"project_id_$i"}), |
732 |
$form->{"serialnumber_$i"}, conv_i($pricegroup_id),
|
|
736 |
$form->{"serialnumber_$i"}, $pricegroup_id,
|
|
733 | 737 |
$form->{"ordnumber_$i"}, conv_date($form->{"transdate_$i"}), |
734 | 738 |
$form->{"cusordnumber_$i"}, $baseqty, $form->{"subtotal_$i"} ? 't' : 'f', |
735 | 739 |
$form->{"marge_percent_$i"}, $form->{"marge_absolut_$i"}, |
SL/OE.pm | ||
---|---|---|
419 | 419 |
|
420 | 420 |
$reqdate = ($form->{"reqdate_$i"}) ? $form->{"reqdate_$i"} : undef; |
421 | 421 |
|
422 |
# get pricegroup_id and save ist |
|
422 |
# Get pricegroup_id and save it. Unfortunately the interface |
|
423 |
# also uses ID "0" for signalling that none is selected, but "0" |
|
424 |
# must not be stored in the database. Therefore we cannot simply |
|
425 |
# use conv_i(). |
|
423 | 426 |
($null, my $pricegroup_id) = split(/--/, $form->{"sellprice_pg_$i"}); |
424 | 427 |
$pricegroup_id *= 1; |
428 |
$pricegroup_id = undef if !$pricegroup_id; |
|
425 | 429 |
|
426 | 430 |
# save detail record in orderitems table |
427 | 431 |
my $orderitems_id = $form->{"orderitems_id_$i"}; |
... | ... | |
441 | 445 |
$form->{"qty_$i"}, $baseqty, |
442 | 446 |
$fxsellprice, $form->{"discount_$i"}, |
443 | 447 |
$form->{"unit_$i"}, conv_date($reqdate), conv_i($form->{"project_id_$i"}), |
444 |
$form->{"serialnumber_$i"}, $form->{"ship_$i"}, conv_i($pricegroup_id),
|
|
448 |
$form->{"serialnumber_$i"}, $form->{"ship_$i"}, $pricegroup_id,
|
|
445 | 449 |
$form->{"ordnumber_$i"}, conv_date($form->{"transdate_$i"}), |
446 | 450 |
$form->{"cusordnumber_$i"}, $form->{"subtotal_$i"} ? 't' : 'f', |
447 | 451 |
$form->{"marge_percent_$i"}, $form->{"marge_absolut_$i"}, |
sql/Pg-upgrade2/orderitems_delivery_order_items_invoice_foreign_keys.sql | ||
---|---|---|
1 |
-- @tag: orderitems_delivery_order_items_invoice_foreign_keys |
|
2 |
-- @description: Fremdschlüssel für Tabellen oderitems, delivery_order_items, invoice |
|
3 |
-- @depends: release_3_0_0 |
|
4 |
-- @charset: utf-8 |
|
5 |
UPDATE orderitems SET pricegroup_id = NULL WHERE pricegroup_id = 0; |
|
6 |
UPDATE delivery_order_items SET pricegroup_id = NULL WHERE pricegroup_id = 0; |
|
7 |
UPDATE invoice SET pricegroup_id = NULL WHERE pricegroup_id = 0; |
|
8 |
|
|
9 |
UPDATE orderitems SET project_id = NULL WHERE project_id NOT IN (SELECT id FROM project); |
|
10 |
UPDATE delivery_order_items SET project_id = NULL WHERE project_id NOT IN (SELECT id FROM project); |
|
11 |
UPDATE invoice SET project_id = NULL WHERE project_id NOT IN (SELECT id FROM project); |
|
12 |
|
|
13 |
ALTER TABLE orderitems ADD FOREIGN KEY (trans_id) REFERENCES oe (id); |
|
14 |
ALTER TABLE orderitems ADD FOREIGN KEY (project_id) REFERENCES project (id); |
|
15 |
ALTER TABLE orderitems ADD FOREIGN KEY (pricegroup_id) REFERENCES pricegroup (id); |
|
16 |
ALTER TABLE orderitems ADD FOREIGN KEY (price_factor_id) REFERENCES price_factors (id); |
|
17 |
|
|
18 |
ALTER TABLE delivery_order_items ADD FOREIGN KEY (pricegroup_id) REFERENCES pricegroup (id); |
|
19 |
|
|
20 |
ALTER TABLE invoice ADD FOREIGN KEY (project_id) REFERENCES project (id); |
|
21 |
ALTER TABLE invoice ADD FOREIGN KEY (pricegroup_id) REFERENCES pricegroup (id); |
|
22 |
ALTER TABLE invoice ADD FOREIGN KEY (price_factor_id) REFERENCES price_factors (id); |
Auch abrufbar als: Unified diff
InvoiceItem, OrderItem, DeliveryOrderItem: diverse Fremdschlüssel eingeführt