From 4e33311d0fd7167148faec7564db8acc07239054 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Fri, 11 Feb 2022 13:06:15 +0100 Subject: [PATCH] Anzahlungsrechnung: Beim Zahlungseingang auf das Steuertransfer-Konto buchen MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit DATEV benötigt das wirkliche Brutto-Automatik-Konto, um die MwSt zu buchen --- SL/DB/Helper/Payment.pm | 42 +++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/SL/DB/Helper/Payment.pm b/SL/DB/Helper/Payment.pm index 386d284e4..8d0174d9b 100644 --- a/SL/DB/Helper/Payment.pm +++ b/SL/DB/Helper/Payment.pm @@ -312,26 +312,44 @@ sub pay_invoice { ($netamount, $taxamount) = Form->calculate_tax($arap_amount, $tax->rate, 1, $roundplaces); # for debugging database set my $fullmatch = $netamount == $entry->{amount} ? '::netamount total true' : ''; + my $transfer_chart = $tax->taxkey == 2 ? SL::DB::Chart->new(id => $::instance_conf->get_advance_payment_taxable_7_id)->load + : $tax->taxkey == 3 ? SL::DB::Chart->new(id => $::instance_conf->get_advance_payment_taxable_19_id)->load + : undef; + die "No Transfer Chart for Advance Payment" unless ref $transfer_chart eq 'SL::DB::Chart'; + + my $arap_full_booking= SL::DB::AccTransaction->new(trans_id => $self->id, + chart_id => $clearing_chart->id, + chart_link => $clearing_chart->link, + amount => $arap_amount * -1, # full amount + transdate => $transdate_obj, + source => 'Automatic Tax Booking for Payment in Advance' . $fullmatch, + taxkey => 0, + tax_id => SL::DB::Manager::Tax->find_by(taxkey => 0)->id); + $arap_full_booking->save; + push @new_acc_ids, $arap_full_booking->acc_trans_id; + + my $arap_tax_booking= SL::DB::AccTransaction->new(trans_id => $self->id, + chart_id => $transfer_chart->id, + chart_link => $transfer_chart->link, + amount => _round($netamount), # full amount + transdate => $transdate_obj, + source => 'Automatic Tax Booking for Payment in Advance' . $fullmatch, + taxkey => $tax->taxkey, + tax_id => $tax->id); + $arap_tax_booking->save; + push @new_acc_ids, $arap_tax_booking->acc_trans_id; + my $tax_booking= SL::DB::AccTransaction->new(trans_id => $self->id, chart_id => $tax->chart_id, chart_link => $tax->chart->link, amount => _round($taxamount), transdate => $transdate_obj, source => 'Automatic Tax Booking for Payment in Advance' . $fullmatch, - taxkey => $tax->taxkey, - tax_id => $tax->id); - $tax_booking->save; - push @new_acc_ids, $tax_booking->acc_trans_id; - my $arap_tax_booking= SL::DB::AccTransaction->new(trans_id => $self->id, - chart_id => $clearing_chart->id, - chart_link => $clearing_chart->link, - amount => _round($taxamount * -1), - transdate => $transdate_obj, - source => 'Automatic Tax Booking for Payment in Advance' . $fullmatch, taxkey => 0, tax_id => SL::DB::Manager::Tax->find_by(taxkey => 0)->id); - $arap_tax_booking->save; - push @new_acc_ids, $arap_tax_booking->acc_trans_id; + + $tax_booking->save; + push @new_acc_ids, $tax_booking->acc_trans_id; } } $fx_gain_loss_amount *= -1 if $self->is_sales; -- 2.20.1