X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIS.pm;h=7522bd24843678d2b25417d9a755b95b4d3c46a8;hb=be42a45043cab936e86e91aa895c6fc25bab079f;hp=a64765388e1058e113f81f85b2b6c6a31a90b5c4;hpb=fd8bde53d5f22fe6923a904682dc25f2b3af8a3d;p=kivitendo-erp.git diff --git a/SL/IS.pm b/SL/IS.pm index a64765388..7522bd248 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -373,23 +373,11 @@ sub invoice_details { $sth->finish; } - my $cvars; - if (! $form->{"invoice_id_$i"}) { - # get values for CVars from master data for new items - $cvars = CVar->get_custom_variables(dbh => $dbh, - module => 'IC', - trans_id => $form->{"id_$i"}, - ); - } else { - # get values for CVars from custom_variables for existing items - $cvars = CVar->get_custom_variables(dbh => $dbh, - module => 'IC', - sub_module => 'invoice', - trans_id => $form->{"invoice_id_$i"}, - ); - } - # map only non-editable CVars to form (editable ones are already there) - map { $form->{"ic_cvar_$_->{name}_$i"} = $_->{value} unless $_->{flag_editable} } @{ $cvars }; + CVar->get_non_editable_ic_cvars(form => $form, + dbh => $dbh, + row => $i, + sub_module => 'invoice', + may_converted_from => ['delivery_order_items', 'orderitems', 'invoice']); push @{ $form->{TEMPLATE_ARRAYS}->{"ic_cvar_$_->{name}"} }, CVar->format_to_template(CVar->parse($form->{"ic_cvar_$_->{name}_$i"}, $_), $_) @@ -767,7 +755,12 @@ sub post_invoice { $pricegroup_id *= 1; $pricegroup_id = undef if !$pricegroup_id; - my $cvars; + CVar->get_non_editable_ic_cvars(form => $form, + dbh => $dbh, + row => $i, + sub_module => 'invoice', + may_converted_from => ['delivery_order_items', 'orderitems', 'invoice']); + if (!$form->{"invoice_id_$i"}) { # there is no persistent id, therefore create one with all necessary constraints my $q_invoice_id = qq|SELECT nextval('invoiceid')|; @@ -778,22 +771,7 @@ sub post_invoice { do_query($form, $dbh, $q_create_invoice_id, conv_i($form->{"invoice_id_$i"}), conv_i($form->{id}), conv_i($position), conv_i($form->{"id_$i"})); $h_invoice_id->finish(); - - # get values for CVars from master data for new items - $cvars = CVar->get_custom_variables(dbh => $dbh, - module => 'IC', - trans_id => $form->{"id_$i"}, - ); - } else { - # get values for CVars from custom_variables for existing items - $cvars = CVar->get_custom_variables(dbh => $dbh, - module => 'IC', - sub_module => 'invoice', - trans_id => $form->{"invoice_id_$i"}, - ); } - # map only non-editable CVars to form (editable ones are already there) - map { $form->{"ic_cvar_$_->{name}_$i"} = $_->{value} unless $_->{flag_editable} } @{ $cvars }; # save detail record in invoice table $query = <