X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIS.pm;h=e9bd54d4793d9d73d68016347525e3617649168e;hb=0e9f6f033ae78206cfa0fd56e310dd79327f99f4;hp=6018634dd8c3a0d01e83876619c4d089e1c79ae9;hpb=aa63ebae1c0a758ec438c594acb328b1f0e5e001;p=kivitendo-erp.git diff --git a/SL/IS.pm b/SL/IS.pm index 6018634dd..e9bd54d47 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -52,10 +52,12 @@ use SL::IC; use SL::IO; use SL::TransNumber; use SL::DB::Default; +use SL::DB::Draft; use SL::DB::Tax; use SL::DB::TaxZone; use SL::TransNumber; use SL::DB; +use SL::Presenter::Part qw(type_abbreviation classification_abbreviation); use Data::Dumper; use strict; @@ -433,7 +435,7 @@ sub invoice_details { } my $tax_rate = $taxrate * 100; push(@{ $form->{TEMPLATE_ARRAYS}->{tax_rate} }, qq|$tax_rate|); - if ($form->{"assembly_$i"}) { + if ($form->{"part_type_$i"} eq 'assembly') { $sameitem = ""; # get parts and push them onto the stack @@ -663,6 +665,13 @@ sub customer_details { 'trans_id' => $form->{customer_id}); map { $form->{"vc_cvar_$_->{name}"} = $_->{value} } @{ $custom_variables }; + if ($form->{cp_id}) { + $custom_variables = CVar->get_custom_variables(dbh => $dbh, + module => 'Contacts', + trans_id => $form->{cp_id}); + $form->{"cp_cvar_$_->{name}"} = $_->{value} for @{ $custom_variables }; + } + $form->{cp_greeting} = GenericTranslations->get('dbh' => $dbh, 'translation_type' => 'greetings::' . ($form->{cp_gender} eq 'f' ? 'female' : 'male'), 'language_id' => $language_id, @@ -857,9 +866,9 @@ sub _post_invoice { next if $payments_only; - if ($form->{"inventory_accno_$i"} || $form->{"assembly_$i"}) { + if ($form->{"inventory_accno_$i"} || $form->{"part_type_$i"} eq 'assembly') { - if ($form->{"assembly_$i"}) { + if ($form->{"part_type_$i"} eq 'assembly') { # record assembly item as allocated &process_assembly($dbh, $myconfig, $form, $position, $form->{"id_$i"}, $baseqty); @@ -1402,19 +1411,19 @@ SQL do_query($form, $dbh, $query, @orphaned_ids); } + if ($form->{draft_id}) { + SL::DB::Manager::Draft->delete_all(where => [ id => delete($form->{draft_id}) ]); + } + # safety check datev export if ($::instance_conf->get_datev_check_on_sales_invoice) { - my $transdate = $::form->{invdate} ? DateTime->from_lxoffice($::form->{invdate}) : undef; - $transdate ||= DateTime->today; my $datev = SL::DATEV->new( - exporttype => DATEV_ET_BUCHUNGEN, - format => DATEV_FORMAT_KNE, dbh => $dbh, trans_id => $form->{id}, ); - $datev->export; + $datev->generate_datev_data; if ($datev->errors) { die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; @@ -2129,6 +2138,11 @@ sub get_customer { my $payment_id; # get customer + my $where = ''; + if ($cid) { + $where .= 'AND c.id = ?'; + push @values, $cid; + } $query = qq|SELECT c.id AS customer_id, c.name AS customer, c.discount as customer_discount, c.creditlimit, @@ -2140,8 +2154,7 @@ sub get_customer { FROM customer c LEFT JOIN business b ON (b.id = c.business_id) LEFT JOIN currencies cu ON (c.currency_id=cu.id) - WHERE c.id = ?|; - push @values, $cid; + WHERE 1 = 1 $where|; $ref = selectfirst_hashref_query($form, $dbh, $query, @values); delete $ref->{salesman_id} if !$ref->{salesman_id}; @@ -2341,8 +2354,8 @@ sub retrieve_item { push @{ $ref->{matches} ||= [] }, $::locale->text('EAN') . ': ' . $ref->{ean}; } - $ref->{type_and_classific} = $::request->presenter->type_abbreviation($ref->{part_type}). - $::request->presenter->classification_abbreviation($ref->{classification_id}); + $ref->{type_and_classific} = type_abbreviation($ref->{part_type}) . + classification_abbreviation($ref->{classification_id}); if (! $ref->{used_for_sale} ) { $has_wrong_pclass = PCLASS_NOTFORSALE ; next; @@ -2424,7 +2437,6 @@ sub retrieve_item { } $ref->{onhand} *= 1; - push @{ $form->{item_list} }, $ref; } $sth->finish;