Revision 3c92067f
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'); |
Auch abrufbar als: Unified diff
RecordLink: conversions nicht mehr manuell in Controllern machen
stattdessen per Helper setzen lassen