name_postfix => "_$i",
dbh => $dbh);
# link order items with doi
- if ($form->{"converted_from_order_orderitems_id_$i"}) {
+ if ($form->{"converted_from_orderitems_id_$i"}) {
RecordLinks->create_links('dbh' => $dbh,
'mode' => 'ids',
'from_table' => 'orderitems',
- 'from_ids' => $form->{"converted_from_order_orderitems_id_$i"},
+ 'from_ids' => $form->{"converted_from_orderitems_id_$i"},
'to_table' => 'delivery_order_items',
'to_id' => $form->{"delivery_order_items_id_$i"},
);
- delete $form->{"converted_from_order_orderitems_id_$i"};
+ delete $form->{"converted_from_orderitems_id_$i"};
}
}
name_prefix => 'ic_',
name_postfix => "_$i",
dbh => $dbh);
+ # link oe items with invoice
+ if ($form->{"converted_from_orderitems_id_$i"}) {
+ RecordLinks->create_links('dbh' => $dbh,
+ 'mode' => 'ids',
+ 'from_table' => 'orderitems',
+ 'from_ids' => $form->{"converted_from_orderitems_id_$i"},
+ 'to_table' => 'invoice',
+ 'to_id' => $form->{"invoice_id_$i"},
+ );
+ delete $form->{"converted_from_orderitems_id_$i"};
+ }
+ # link doi items with invoice
+ if ($form->{"converted_from_delivery_order_items_id_$i"}) {
+ RecordLinks->create_links('dbh' => $dbh,
+ 'mode' => 'ids',
+ 'from_table' => 'delivery_order_items',
+ 'from_ids' => $form->{"converted_from_delivery_order_items_id_$i"},
+ 'to_table' => 'invoice',
+ 'to_id' => $form->{"invoice_id_$i"},
+ );
+ delete $form->{"converted_from_delivery_order_items_id_$i"};
+ }
}
$h_item_unit->finish();
name_postfix => "_$i",
dbh => $dbh);
}
+ # link oe items with invoice
+ if ($form->{"converted_from_orderitems_id_$i"}) {
+ RecordLinks->create_links('dbh' => $dbh,
+ 'mode' => 'ids',
+ 'from_table' => 'orderitems',
+ 'from_ids' => $form->{"converted_from_orderitems_id_$i"},
+ 'to_table' => 'invoice',
+ 'to_id' => $form->{"invoice_id_$i"},
+ );
+ delete $form->{"converted_from_orderitems_id_$i"};
+ }
+ # link doi items with invoice
+ if ($form->{"converted_from_delivery_order_items_id_$i"}) {
+ RecordLinks->create_links('dbh' => $dbh,
+ 'mode' => 'ids',
+ 'from_table' => 'delivery_order_items',
+ 'from_ids' => $form->{"converted_from_delivery_order_items_id_$i"},
+ 'to_table' => 'invoice',
+ 'to_id' => $form->{"invoice_id_$i"},
+ );
+ delete $form->{"converted_from_delivery_order_items_id_$i"};
+ }
}
# total payments, don't move we need it here
}
map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"} } qw(ship qty sellprice listprice lastcost basefactor);
$form->{"donumber_$i"} = $form->{donumber};
+ $form->{"converted_from_delivery_order_items_id_$i"} = delete $form->{"delivery_order_items_id_$i"};
}
$form->{type} = "invoice";
$ref->{reqdate} ||= $ref->{dord_transdate}; # copy transdates into each invoice row
map { $form->{"${_}_$form->{rowcount}"} = $ref->{$_} } keys %{ $ref };
map { $form->{"${_}_$form->{rowcount}"} = $form->format_amount(\%myconfig, $ref->{$_}) } qw(qty sellprice lastcost);
+ $form->{"converted_from_delivery_order_items_id_$form->{rowcount}"} = delete $form->{"delivery_order_items_id_$form->{rowcount}"};
if ($vc_discount){ # falls wir einen Lieferanten/Kundenrabatt haben
# und keinen anderen discount wert an $i ...
push @hidden_vars, qw(orderitems_id converted_from_quotation_orderitems_id);
}
if ($is_invoice) {
- push @hidden_vars, qw(invoice_id converted_from_quotation_orderitems_id converted_from_order_orderitems_id
- converted_from_delivery_order_items_id);
+ push @hidden_vars, qw(invoice_id converted_from_orderitems_id converted_from_delivery_order_items_id);
}
if ($::form->{type} =~ /credit_note/) {
push @hidden_vars, qw(invoice_id converted_from_invoice_id);
map { $form->{"${_}_${i}"} = $form->format_amount(\%myconfig, $form->{"${_}_${i}"}) } qw(sellprice discount lastcost);
push @hidden_vars, grep { defined $form->{"${_}_${i}"} } qw(sellprice discount not_discountable price_factor_id lastcost);
push @hidden_vars, "stock_${stock_in_out}_sum_qty", "stock_${stock_in_out}";
- push @hidden_vars, qw(delivery_order_items_id converted_from_order_orderitems_id);
+ push @hidden_vars, qw(delivery_order_items_id converted_from_orderitems_id);
}
my @HIDDENS = map { value => $_}, (
stock_out stock_in has_sernumber reqdate orderitems_id
active_price_source active_discount_source delivery_order_items_id
invoice_id converted_from_quotation_orderitems_id
- converted_from_order_orderitems_id converted_from_delivery_order_items_id);
+ converted_from_orderitems_id converted_from_delivery_order_items_id);
my $ic_cvar_configs = CVar->get_configs(module => 'IC');
push @flds, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs };
for (qw(ship qty sellprice listprice basefactor)) {
$form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"};
}
+ $form->{"converted_from_orderitems_id_$i"} = delete $form->{"orderitems_id_$i"};
}
my ($buysell, $orddate, $exchangerate);
# bo creates the id, reset it
map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued);
- delete $form->{"orderitems_id_$_"} for 1 .. $form->{"rowcount"};
$form->{ $form->{vc} } =~ s/--.*//g;
$form->{type} = "invoice";
for my $i (1 .. $form->{rowcount}) {
map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice listprice lastcost basefactor discount);
- $form->{"converted_from_order_orderitems_id_$i"} = $form->{"orderitems_id_$i"};
- delete $form->{"orderitems_id_$i"}; # even if they don't exist in form. cvars checks them before display_row
+ $form->{"converted_from_orderitems_id_$i"} = delete $form->{"orderitems_id_$i"};
}
my %old_values = map { $_ => $form->{$_} } qw(customer_id oldcustomer customer vendor_id oldvendor vendor shipto_id);