Revision c4fb78fe
Von Sven Schöling vor mehr als 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); |
... | ... | |
1664 | 1665 |
# link records |
1665 | 1666 |
if ($::form->{converted_from_oe_id}) { |
1666 | 1667 |
my @converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id}; |
1667 |
foreach my $converted_from_oe_id (@converted_from_oe_ids) { |
|
1668 |
my $src = SL::DB::Order->new(id => $converted_from_oe_id)->load; |
|
1669 |
$src->update_attributes(closed => 1) if $src->type =~ /_quotation$/ && $self->order->is_type(PURCHASE_DELIVERY_ORDER_TYPE); |
|
1670 |
$src->link_to_record($self->order); |
|
1671 |
} |
|
1672 |
if (scalar @{ $::form->{converted_from_orderitems_ids} || [] }) { |
|
1673 |
my $idx = 0; |
|
1674 |
foreach (@{ $self->order->items_sorted }) { |
|
1675 |
my $from_id = $::form->{converted_from_orderitems_ids}->[$idx]; |
|
1676 |
next if !$from_id; |
|
1677 |
SL::DB::RecordLink->new(from_table => 'orderitems', |
|
1678 |
from_id => $from_id, |
|
1679 |
to_table => 'orderitems', |
|
1680 |
to_id => $_->id |
|
1681 |
)->save; |
|
1682 |
$idx++; |
|
1683 |
} |
|
1684 |
} |
|
1668 |
set_record_link_conversions( |
|
1669 |
$self->order, |
|
1670 |
'SL::DB::Order' => \@converted_from_oe_ids, |
|
1671 |
'SL::DB::OrderItem' => $::form->{converted_from_orderitems_ids}, |
|
1672 |
); |
|
1685 | 1673 |
} |
1686 | 1674 |
if ($::form->{converted_from_reclamation_id}) { |
1687 | 1675 |
my @converted_from_reclamation_ids = split ' ', $::form->{converted_from_reclamation_id}; |
1688 |
foreach my $converted_from_reclamation_id (@converted_from_reclamation_ids) { |
|
1689 |
my $src = SL::DB::Reclamation->new(id => $converted_from_reclamation_id)->load; |
|
1690 |
if(!$::instance_conf->get_shipped_qty_require_stock_out || $self->order->delivered) { |
|
1691 |
$src->update_attributes(delivered => 1); |
|
1692 |
} |
|
1693 |
$src->link_to_record($self->order); |
|
1694 |
} |
|
1695 |
if (scalar @{ $::form->{converted_from_reclamation_items_ids} || [] }) { |
|
1696 |
my $idx = 0; |
|
1697 |
foreach (@{ $self->order->items_sorted }) { |
|
1698 |
my $from_id = $::form->{converted_from_reclamation_items_ids}->[$idx]; |
|
1699 |
next if !$from_id; |
|
1700 |
SL::DB::RecordLink->new(from_table => 'reclamation_items', |
|
1701 |
from_id => $from_id, |
|
1702 |
to_table => 'orderitems', |
|
1703 |
to_id => $_->id |
|
1704 |
)->save; |
|
1705 |
$idx++; |
|
1706 |
} |
|
1707 |
} |
|
1676 |
set_record_link_conversions( |
|
1677 |
$self->order, |
|
1678 |
'SL::DB::Reclamation' => \@converted_from_reclamation_ids, |
|
1679 |
'SL::DB::ReclamationItem' => $::form->{converted_from_reclamation_items_ids}, |
|
1680 |
); |
|
1708 | 1681 |
} |
1709 | 1682 |
|
1710 | 1683 |
$self->save_history('SAVED'); |
SL/Controller/Order.pm | ||
---|---|---|
32 | 32 |
use SL::DB::Shipto; |
33 | 33 |
use SL::DB::Translation; |
34 | 34 |
use SL::DB::ValidityToken; |
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); |
... | ... | |
2196 | 2197 |
# link records |
2197 | 2198 |
if ($::form->{converted_from_oe_id}) { |
2198 | 2199 |
my @converted_from_oe_ids = split ' ', $::form->{converted_from_oe_id}; |
2199 |
|
|
2200 |
foreach my $converted_from_oe_id (@converted_from_oe_ids) { |
|
2201 |
my $src = SL::DB::Order->new(id => $converted_from_oe_id)->load; |
|
2202 |
$src->update_attributes(closed => 1) if $src->type =~ /_quotation$/; |
|
2203 |
$src->link_to_record($self->order); |
|
2204 |
} |
|
2205 |
if (scalar @{ $::form->{converted_from_orderitems_ids} || [] }) { |
|
2206 |
my $idx = 0; |
|
2207 |
foreach (@{ $self->order->items_sorted }) { |
|
2208 |
my $from_id = $::form->{converted_from_orderitems_ids}->[$idx]; |
|
2209 |
next if !$from_id; |
|
2210 |
SL::DB::RecordLink->new(from_table => 'orderitems', |
|
2211 |
from_id => $from_id, |
|
2212 |
to_table => 'orderitems', |
|
2213 |
to_id => $_->id |
|
2214 |
)->save; |
|
2215 |
$idx++; |
|
2216 |
} |
|
2217 |
} |
|
2200 |
set_record_link_conversions( |
|
2201 |
$self->order, |
|
2202 |
'SL::DB::Order' => \@converted_from_oe_ids, |
|
2203 |
'SL::DB::OrderItem' => $::form->{converted_from_orderitems_ids}, |
|
2204 |
); |
|
2218 | 2205 |
|
2219 | 2206 |
$self->link_requirement_specs_linking_to_created_from_objects(@converted_from_oe_ids); |
2220 | 2207 |
} |
2221 | 2208 |
if ($::form->{converted_from_reclamation_id}) { |
2222 | 2209 |
my @converted_from_reclamation_ids = split ' ', $::form->{converted_from_reclamation_id}; |
2223 |
|
|
2224 |
foreach my $converted_from_reclamation_id (@converted_from_reclamation_ids) { |
|
2225 |
my $src = SL::DB::Reclamation->new(id => $converted_from_reclamation_id)->load; |
|
2226 |
$src->link_to_record($self->order); |
|
2227 |
} |
|
2228 |
if (scalar @{ $::form->{converted_from_reclamation_items_ids} || [] }) { |
|
2229 |
my $idx = 0; |
|
2230 |
foreach (@{ $self->order->items_sorted }) { |
|
2231 |
my $from_id = $::form->{converted_from_reclamation_items_ids}->[$idx]; |
|
2232 |
next if !$from_id; |
|
2233 |
SL::DB::RecordLink->new(from_table => 'reclamation_items', |
|
2234 |
from_id => $from_id, |
|
2235 |
to_table => 'orderitems', |
|
2236 |
to_id => $_->id |
|
2237 |
)->save; |
|
2238 |
$idx++; |
|
2239 |
} |
|
2240 |
} |
|
2210 |
set_record_links_conversions( |
|
2211 |
$self->order, |
|
2212 |
'SL::DB::Reclamation' => \@converted_from_reclamation_ids, |
|
2213 |
'SL::DB::ReclamationItem' => $::form->{converted_from_reclamation_items_ids}, |
|
2214 |
); |
|
2241 | 2215 |
} |
2242 | 2216 |
|
2243 | 2217 |
$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; |
... | ... | |
1707 | 1708 |
|
1708 | 1709 |
my $reclamation = $self->reclamation; |
1709 | 1710 |
|
1710 |
$reclamation->{converted_from_record_id} = delete $::form->{converted_from_record_id};
|
|
1711 |
$reclamation->{converted_from_record_type_ref} = delete $::form->{converted_from_record_type_ref};
|
|
1711 |
$reclamation->{RECORD_ID()} = delete $::form->{converted_from_record_id};
|
|
1712 |
$reclamation->{RECORD_TYPE_REF()} = delete $::form->{converted_from_record_type_ref};
|
|
1712 | 1713 |
|
1713 | 1714 |
my $from_record_item_ids = delete $::form->{converted_from_record_item_ids} ; |
1714 | 1715 |
my $from_record_item_type_refs = delete $::form->{converted_from_record_item_type_refs} ; |
... | ... | |
1716 | 1717 |
if (scalar @{ $from_record_item_ids || [] }) { |
1717 | 1718 |
for my $idx (0 .. $#{ $reclamation->items_sorted }) { |
1718 | 1719 |
my $reclamation_item = $reclamation->items_sorted->[$idx]; |
1719 |
$reclamation_item->{converted_from_record_item_id} = $from_record_item_ids->[$idx];
|
|
1720 |
$reclamation_item->{converted_from_record_item_type_ref} = $from_record_item_type_refs->[$idx];
|
|
1720 |
$reclamation_item->{RECORD_ITEM_ID()} = $from_record_item_ids->[$idx];
|
|
1721 |
$reclamation_item->{RECORD_ITEM_TYPE_REF()} = $from_record_item_type_refs->[$idx];
|
|
1721 | 1722 |
} |
1722 | 1723 |
} |
1723 | 1724 |
} |
Auch abrufbar als: Unified diff
RecordLink: conversions nicht mehr manuell in Controllern machen
stattdessen per Helper setzen lassen