$form->{defaultcurrency} = $form->get_default_currency($myconfig);
my $defaultcurrency = $form->{defaultcurrency};
- # Seit neuestem wird die department_id schon übergeben UND $form->department nicht mehr
- # korrekt zusammengebaut. Sehr wahrscheinlich beim Umstieg auf T8 kaputt gegangen
- # Ich lass den Code von 2005 erstmal noch stehen ;-) jb 03-2011
- if (!$form->{department_id}){
- ($null, $form->{department_id}) = split(/--/, $form->{department});
- }
-
my $all_units = AM->retrieve_units($myconfig, $form);
if (!$payments_only) {
name_postfix => "_$i",
dbh => $dbh);
}
+ # link previous items with invoice items
+ foreach (qw(delivery_order_items orderitems invoice)) {
+ if ($form->{"converted_from_${_}_id_$i"}) {
+ RecordLinks->create_links('dbh' => $dbh,
+ 'mode' => 'ids',
+ 'from_table' => $_,
+ 'from_ids' => $form->{"converted_from_${_}_id_$i"},
+ 'to_table' => 'invoice',
+ 'to_id' => $form->{"invoice_id_$i"},
+ );
+ delete $form->{"converted_from_${_}_id_$i"};
+ }
+ }
}
# total payments, don't move we need it here
}
# Link this record to the records it was created from.
- RecordLinks->create_links('dbh' => $dbh,
- 'mode' => 'ids',
- 'from_table' => 'oe',
- 'from_ids' => $form->{convert_from_oe_ids},
- 'to_table' => 'ar',
- 'to_id' => $form->{id},
- );
- delete $form->{convert_from_oe_ids};
+ if ($form->{convert_from_oe_ids}) {
+ RecordLinks->create_links('dbh' => $dbh,
+ 'mode' => 'ids',
+ 'from_table' => 'oe',
+ 'from_ids' => $form->{convert_from_oe_ids},
+ 'to_table' => 'ar',
+ 'to_id' => $form->{id},
+ );
+ delete $form->{convert_from_oe_ids};
+ }
my @convert_from_do_ids = map { $_ * 1 } grep { $_ } split m/\s+/, $form->{convert_from_do_ids};