Revision 6c3afa9b
Von Bernd Bleßmann vor etwa 3 Jahren hinzugefügt
SL/DB/Order.pm | ||
---|---|---|
240 | 240 |
require SL::DB::Invoice; |
241 | 241 |
$invoice = SL::DB::Invoice->new_from($self)->post(%params) || die; |
242 | 242 |
$self->link_to_record($invoice); |
243 |
# TODO extend link_to_record for items, otherwise long-term no d.r.y. |
|
244 |
foreach my $item (@{ $invoice->items }) { |
|
245 |
foreach (qw(orderitems)) { |
|
246 |
if ($item->{"converted_from_${_}_id"}) { |
|
247 |
die unless $item->{id}; |
|
248 |
RecordLinks->create_links('mode' => 'ids', |
|
249 |
'from_table' => $_, |
|
250 |
'from_ids' => $item->{"converted_from_${_}_id"}, |
|
251 |
'to_table' => 'invoice', |
|
252 |
'to_id' => $item->{id}, |
|
253 |
) || die; |
|
254 |
delete $item->{"converted_from_${_}_id"}; |
|
255 |
} |
|
256 |
} |
|
257 |
} |
|
243 | 258 |
$self->update_attributes(closed => 1); |
244 | 259 |
1; |
245 | 260 |
})) { |
Auch abrufbar als: Unified diff
S:D:Order: convert_to_invoice: items verlinken