X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fis.pl;h=58d4c4f9172b8fee3fd9a680373d7dfb0b0c3061;hb=c2f911bdbad03f7b81e0121e4e866bb96586168c;hp=9c6cd67a5fc7d4531a1a73249f9478736bb1ef76;hpb=dc39f671740dc3ab2292c604e8605dd69fb33eac;p=kivitendo-erp.git diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index 9c6cd67a5..58d4c4f91 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -90,6 +90,8 @@ sub edit { $main::auth->assert('invoice_edit'); + $form->{taxincluded_changed_by_user} = 1; + # show history button $form->{javascript} = qq||; #/show hhistory button @@ -312,7 +314,7 @@ sub form_header { $TMPL_VAR{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all(query => [ or => [ id => $::form->{employee_id}, deleted => 0 ] ]); $TMPL_VAR{ALL_SALESMEN} = SL::DB::Manager::Employee->get_all(query => [ or => [ id => $::form->{salesman_id}, deleted => 0 ] ]); $TMPL_VAR{ALL_SHIPTO} = SL::DB::Manager::Shipto->get_all(query => [ - or => [ trans_id => $::form->{"$::form->{vc}_id"} * 1, shipto_id => $::form->{shipto_id} * 1 ] + or => [ trans_id => $::form->{"$::form->{vc}_id"} * 1, and => [ shipto_id => $::form->{shipto_id} * 1, trans_id => undef ] ] ]); $TMPL_VAR{ALL_CONTACTS} = SL::DB::Manager::Contact->get_all(query => [ or => [ @@ -405,6 +407,14 @@ sub form_footer { my ($tax, $subtotal); $form->{taxaccounts_array} = [ split / /, $form->{taxaccounts} ]; + my $paymet_id = $::form->{payment_id}; + IS->get_customer(\%myconfig, \%$form) if $form->{type} =~ /sales_(order|quotation)/; + $::form->{payment_id} = $paymet_id; + + if ( $form->{vc} eq 'customer' && !$form->{taxincluded_changed_by_user} ) { + $form->{taxincluded} = defined($form->{taxincluded_checked}) ? $form->{taxincluded_checked} : $myconfig{taxincluded_checked}; + } + foreach my $item (@{ $form->{taxaccounts_array} }) { if ($form->{"${item}_base"}) { if ($form->{taxincluded}) { @@ -509,6 +519,9 @@ sub update { for my $i (1 .. $form->{paidaccounts}) { next unless $form->{"paid_$i"}; map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate); + if (!$form->{"forex_$i"}) { #read exchangerate from input field (not hidden) + $form->{exchangerate} = $form->{"exchangerate_$i"}; + } $form->{"forex_$i"} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'); $form->{"exchangerate_$i"} = $form->{"forex_$i"} if $form->{"forex_$i"}; } @@ -576,7 +589,7 @@ sub update { $form->{creditremaining} -= $amount; - map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces) } qw(sellprice listprice lastcost); + map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces) } qw(sellprice lastcost); $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}); @@ -729,7 +742,7 @@ sub post { ($form->{AR_paid}) = split /--/, $form->{AR_paid}; $form->{storno} ||= 0; - $form->{label} = $locale->text('Invoice'); + $form->{label} = $form->{type} eq 'credit_note' ? $locale->text('Credit Note') : $locale->text('Invoice'); $form->{id} = 0 if $form->{postasnew}; @@ -748,7 +761,7 @@ sub post { remove_draft() if $form->{remove_draft}; if(!exists $form->{addition}) { - $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; + $form->{snumbers} = 'invnumber' .'_'. $form->{invnumber}; # ($form->{type} eq 'credit_note' ? 'cnnumber' : 'invnumber') .'_'. $form->{invnumber}; $form->{addition} = $form->{print_and_post} ? "PRINTED AND POSTED" : $form->{storno} ? "STORNO" : "POSTED"; @@ -822,7 +835,7 @@ sub storno { $form->error($locale->text("Invoice has already been storno'd!")); } - map({ my $key = $_; delete($form->{$key}) unless (grep({ $key eq $_ } qw(id login password stylesheet type))); } keys(%{ $form })); + map({ my $key = $_; delete($form->{$key}) unless (grep({ $key eq $_ } qw(id login password type))); } keys(%{ $form })); invoice_links(); prepare_invoice(); @@ -872,8 +885,6 @@ sub delete { $form->header; print qq| - -
|; @@ -938,6 +949,12 @@ sub credit_note { # map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } # qw(creditlimit creditremaining); + for my $i (1 .. $form->{rowcount}) { + for (qw(listprice)) { + $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"}; + } + } + my $currency = $form->{currency}; &invoice_links; @@ -979,7 +996,7 @@ sub yes { if (IS->delete_invoice(\%myconfig, \%$form)) { # saving the history if(!exists $form->{addition}) { - $form->{snumbers} = qq|invnumber_| . $form->{invnumber}; + $form->{snumbers} = 'invnumber' .'_'. $form->{invnumber}; # ($form->{type} eq 'credit_note' ? 'cnnumber' : 'invnumber') .'_'. $form->{invnumber}; $form->{addition} = "DELETED"; $form->save_history; }