Revision 2bb40d4e
Von Sven Schöling vor etwa 1 Jahr hinzugefügt
SL/Controller/DeliveryOrder.pm | ||
---|---|---|
32 | 32 |
use SL::DB::TransferType; |
33 | 33 |
use SL::DB::ValidityToken; |
34 | 34 |
use SL::DB::Warehouse; |
35 |
use SL::DB::Helper::RecordLink qw(set_record_link_conversions); |
|
35 | 36 |
use SL::Model::Record; |
36 | 37 |
|
37 | 38 |
use SL::Helper::CreatePDF qw(:all); |
... | ... | |
1668 | 1669 |
# link records |
1669 | 1670 |
if ($::form->{converted_from_oe_id}) { |
1670 | 1671 |
my @converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id}; |
1671 |
foreach my $converted_from_oe_id (@converted_from_oe_ids) { |
|
1672 |
my $src = SL::DB::Order->new(id => $converted_from_oe_id)->load; |
|
1673 |
$src->update_attributes(closed => 1) if $src->type =~ /_quotation$/ && $self->order->is_type(PURCHASE_DELIVERY_ORDER_TYPE); |
|
1674 |
$src->link_to_record($self->order); |
|
1675 |
} |
|
1676 |
if (scalar @{ $::form->{converted_from_orderitems_ids} || [] }) { |
|
1677 |
my $idx = 0; |
|
1678 |
foreach (@{ $self->order->items_sorted }) { |
|
1679 |
my $from_id = $::form->{converted_from_orderitems_ids}->[$idx]; |
|
1680 |
next if !$from_id; |
|
1681 |
SL::DB::RecordLink->new(from_table => 'orderitems', |
|
1682 |
from_id => $from_id, |
|
1683 |
to_table => 'orderitems', |
|
1684 |
to_id => $_->id |
|
1685 |
)->save; |
|
1686 |
$idx++; |
|
1687 |
} |
|
1688 |
} |
|
1672 |
set_record_link_conversions( |
|
1673 |
$self->order, |
|
1674 |
'SL::DB::Order' => \@converted_from_oe_ids, |
|
1675 |
'SL::DB::OrderItem' => $::form->{converted_from_orderitems_ids}, |
|
1676 |
); |
|
1689 | 1677 |
} |
1690 | 1678 |
if ($::form->{converted_from_reclamation_id}) { |
1691 | 1679 |
my @converted_from_reclamation_ids = split ' ', $::form->{converted_from_reclamation_id}; |
1692 |
foreach my $converted_from_reclamation_id (@converted_from_reclamation_ids) { |
|
1693 |
my $src = SL::DB::Reclamation->new(id => $converted_from_reclamation_id)->load; |
|
1694 |
if(!$::instance_conf->get_shipped_qty_require_stock_out || $self->order->delivered) { |
|
1695 |
$src->update_attributes(delivered => 1); |
|
1696 |
} |
|
1697 |
$src->link_to_record($self->order); |
|
1698 |
} |
|
1699 |
if (scalar @{ $::form->{converted_from_reclamation_items_ids} || [] }) { |
|
1700 |
my $idx = 0; |
|
1701 |
foreach (@{ $self->order->items_sorted }) { |
|
1702 |
my $from_id = $::form->{converted_from_reclamation_items_ids}->[$idx]; |
|
1703 |
next if !$from_id; |
|
1704 |
SL::DB::RecordLink->new(from_table => 'reclamation_items', |
|
1705 |
from_id => $from_id, |
|
1706 |
to_table => 'orderitems', |
|
1707 |
to_id => $_->id |
|
1708 |
)->save; |
|
1709 |
$idx++; |
|
1710 |
} |
|
1711 |
} |
|
1680 |
set_record_link_conversions( |
|
1681 |
$self->order, |
|
1682 |
'SL::DB::Reclamation' => \@converted_from_reclamation_ids, |
|
1683 |
'SL::DB::ReclamationItem' => $::form->{converted_from_reclamation_items_ids}, |
|
1684 |
); |
|
1712 | 1685 |
} |
1713 | 1686 |
|
1714 | 1687 |
$self->save_history('SAVED'); |
SL/Controller/Order.pm | ||
---|---|---|
33 | 33 |
use SL::DB::Shipto; |
34 | 34 |
use SL::DB::Translation; |
35 | 35 |
use SL::DB::ValidityToken; |
36 |
use SL::DB::Helper::RecordLink qw(set_record_link_conversions); |
|
36 | 37 |
use SL::Model::Record; |
37 | 38 |
|
38 | 39 |
use SL::Helper::CreatePDF qw(:all); |
... | ... | |
2222 | 2223 |
# link records |
2223 | 2224 |
if ($::form->{converted_from_oe_id}) { |
2224 | 2225 |
my @converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id}; |
2225 |
|
|
2226 |
foreach my $converted_from_oe_id (@converted_from_oe_ids) { |
|
2227 |
my $src = SL::DB::Order->new(id => $converted_from_oe_id)->load; |
|
2228 |
$src->update_attributes(closed => 1) if $src->type =~ /_quotation$/; |
|
2229 |
$src->update_attributes(closed => 1) if $src->type eq purchase_quotation_intake_type() && $self->type eq purchase_order_type(); |
|
2230 |
$src->link_to_record($self->order); |
|
2231 |
} |
|
2232 |
if (scalar @{ $::form->{converted_from_orderitems_ids} || [] }) { |
|
2233 |
my $idx = 0; |
|
2234 |
foreach (@{ $self->order->items_sorted }) { |
|
2235 |
my $from_id = $::form->{converted_from_orderitems_ids}->[$idx]; |
|
2236 |
next if !$from_id; |
|
2237 |
SL::DB::RecordLink->new(from_table => 'orderitems', |
|
2238 |
from_id => $from_id, |
|
2239 |
to_table => 'orderitems', |
|
2240 |
to_id => $_->id |
|
2241 |
)->save; |
|
2242 |
$idx++; |
|
2243 |
} |
|
2244 |
} |
|
2226 |
set_record_link_conversions( |
|
2227 |
$self->order, |
|
2228 |
'SL::DB::Order' => \@converted_from_oe_ids, |
|
2229 |
'SL::DB::OrderItem' => $::form->{converted_from_orderitems_ids}, |
|
2230 |
); |
|
2245 | 2231 |
|
2246 | 2232 |
$self->link_requirement_specs_linking_to_created_from_objects(@converted_from_oe_ids); |
2247 | 2233 |
} |
2248 | 2234 |
if ($::form->{converted_from_reclamation_id}) { |
2249 | 2235 |
my @converted_from_reclamation_ids = split ' ', $::form->{converted_from_reclamation_id}; |
2250 |
|
|
2251 |
foreach my $converted_from_reclamation_id (@converted_from_reclamation_ids) { |
|
2252 |
my $src = SL::DB::Reclamation->new(id => $converted_from_reclamation_id)->load; |
|
2253 |
$src->link_to_record($self->order); |
|
2254 |
} |
|
2255 |
if (scalar @{ $::form->{converted_from_reclamation_items_ids} || [] }) { |
|
2256 |
my $idx = 0; |
|
2257 |
foreach (@{ $self->order->items_sorted }) { |
|
2258 |
my $from_id = $::form->{converted_from_reclamation_items_ids}->[$idx]; |
|
2259 |
next if !$from_id; |
|
2260 |
SL::DB::RecordLink->new(from_table => 'reclamation_items', |
|
2261 |
from_id => $from_id, |
|
2262 |
to_table => 'orderitems', |
|
2263 |
to_id => $_->id |
|
2264 |
)->save; |
|
2265 |
$idx++; |
|
2266 |
} |
|
2267 |
} |
|
2236 |
set_record_links_conversions( |
|
2237 |
$self->order, |
|
2238 |
'SL::DB::Reclamation' => \@converted_from_reclamation_ids, |
|
2239 |
'SL::DB::ReclamationItem' => $::form->{converted_from_reclamation_items_ids}, |
|
2240 |
); |
|
2268 | 2241 |
} |
2269 | 2242 |
|
2270 | 2243 |
$self->set_project_in_linked_requirement_specs if $self->order->globalproject_id; |
SL/Controller/Reclamation.pm | ||
---|---|---|
26 | 26 |
use SL::DB::Shipto; |
27 | 27 |
use SL::DB::Translation; |
28 | 28 |
use SL::DB::ValidityToken; |
29 |
use SL::DB::Helper::RecordLink qw(RECORD_ID RECORD_TYPE_REF RECORD_ITEM_ID RECORD_ITEM_TYPE_REF); |
|
29 | 30 |
|
30 | 31 |
use SL::Helper::CreatePDF qw(:all); |
31 | 32 |
use SL::Helper::PrintOptions; |
... | ... | |
1713 | 1714 |
|
1714 | 1715 |
my $reclamation = $self->reclamation; |
1715 | 1716 |
|
1716 |
$reclamation->{converted_from_record_id} = delete $::form->{converted_from_record_id};
|
|
1717 |
$reclamation->{converted_from_record_type_ref} = delete $::form->{converted_from_record_type_ref};
|
|
1717 |
$reclamation->{RECORD_ID()} = delete $::form->{converted_from_record_id};
|
|
1718 |
$reclamation->{RECORD_TYPE_REF()} = delete $::form->{converted_from_record_type_ref};
|
|
1718 | 1719 |
|
1719 | 1720 |
my $from_record_item_ids = delete $::form->{converted_from_record_item_ids} ; |
1720 | 1721 |
my $from_record_item_type_refs = delete $::form->{converted_from_record_item_type_refs} ; |
... | ... | |
1722 | 1723 |
if (scalar @{ $from_record_item_ids || [] }) { |
1723 | 1724 |
for my $idx (0 .. $#{ $reclamation->items_sorted }) { |
1724 | 1725 |
my $reclamation_item = $reclamation->items_sorted->[$idx]; |
1725 |
$reclamation_item->{converted_from_record_item_id} = $from_record_item_ids->[$idx];
|
|
1726 |
$reclamation_item->{converted_from_record_item_type_ref} = $from_record_item_type_refs->[$idx];
|
|
1726 |
$reclamation_item->{RECORD_ITEM_ID()} = $from_record_item_ids->[$idx];
|
|
1727 |
$reclamation_item->{RECORD_ITEM_TYPE_REF()} = $from_record_item_type_refs->[$idx];
|
|
1727 | 1728 |
} |
1728 | 1729 |
} |
1729 | 1730 |
} |
Auch abrufbar als: Unified diff
RecordLink: conversions nicht mehr manuell in Controllern machen
stattdessen per Helper setzen lassen