From 688a2aefca15f7cff4f578eedc8e7185a84c5cdc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Fri, 10 Dec 2021 16:12:51 +0100 Subject: [PATCH] =?utf8?q?Anzahlungs-Rg.:=20Steuer=20der=20Anzahlungs-Rgs.?= =?utf8?q?=20nicht=20auf=20das=20Forderungskto=20buchen=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit … und Betrag der Anzahlungs-Rgs. mit Steuerschlüssel 0 buchen --- SL/IS.pm | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/SL/IS.pm b/SL/IS.pm index e5ba049b5..c667c0f2a 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -1082,6 +1082,7 @@ SQL } } + my $iap_amounts; if ($form->{type} eq 'final_invoice') { my $invoices_for_advance_payment = $self->_get_invoices_for_advance_payment($form->{convert_from_ar_ids} || $form->{id}); if (scalar @$invoices_for_advance_payment > 0) { @@ -1110,15 +1111,24 @@ SQL } # VAT for invoices for advance payment is booked on payment of these. So do not book this VAT for final invoice. - # Collect VAT of invoices for advance payment. + # And book the amount of the invoices for advance payment with taxkey 0 (see below). + # Collect amounts and VAT of invoices for advance payment. + # Set sellprices to fxsellprices for items, because # the PriceTaxCalculator sets fxsellprice from sellprice before calculating. $_->sellprice($_->fxsellprice) for @{$invoice_for_advance_payment->items}; my %pat = $invoice_for_advance_payment->calculate_prices_and_taxes; foreach my $tax_chart_id (keys %{ $pat{taxes_by_chart_id} }) { - my $tax_accno = SL::DB::Chart->new(id => $tax_chart_id)->load->accno; - $form->{amount}{ $form->{id} }{$tax_accno} -= $pat{taxes_by_chart_id}->{$tax_chart_id}; + my $tax_accno = SL::DB::Chart->load_cached($tax_chart_id)->accno; + $form->{amount}{ $form->{id} }{$tax_accno} -= $pat{taxes_by_chart_id}->{$tax_chart_id}; + $form->{amount}{ $form->{id} }{$form->{AR}} += $pat{taxes_by_chart_id}->{$tax_chart_id}; + } + + foreach my $amount_chart_id (keys %{ $pat{amounts} }) { + my $amount_accno = SL::DB::Chart->load_cached($amount_chart_id)->accno; + $iap_amounts->{$amount_accno} += $pat{amounts}->{$amount_chart_id}->{amount}; + $form->{amount}{ $form->{id} }{$amount_accno} -= $pat{amounts}->{$amount_chart_id}->{amount}; } } } @@ -1237,6 +1247,17 @@ SQL } } + # Book the amount of the invoices for advance payment with taxkey 0 (see below). + if ($form->{type} eq 'final_invoice' && $iap_amounts) { + foreach my $accno (keys %$iap_amounts) { + $query = + qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, tax_id, taxkey, project_id, chart_link) + VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, (SELECT id FROM tax WHERE taxkey=0), 0, ?, (SELECT link FROM chart WHERE accno = ?))|; + @values = (conv_i($form->{id}), $accno, $iap_amounts->{$accno}, conv_date($form->{invdate}), conv_i($project_id), $accno); + do_query($form, $dbh, $query, @values); + } + } + # deduct payment differences from diff for my $i (1 .. $form->{paidaccounts}) { if ($form->{"paid_$i"} != 0) { -- 2.20.1