Revision 5a1856a8
Von Jan Büren vor fast 3 Jahren hinzugefügt
SL/AP.pm | ||
---|---|---|
428 | 428 |
sub _reverse_charge { |
429 | 429 |
my ($self, $myconfig, $form) = @_; |
430 | 430 |
|
431 |
# check taxkey settings or return |
|
432 |
my $tax = SL::DB::Manager::Tax->get_first( where => [taxkey => 94 ]); |
|
433 |
return unless ref $tax eq 'SL::DB::Tax'; |
|
434 |
|
|
435 | 431 |
# delete previous bookings, if they exists (repost) |
436 | 432 |
my $ap_gl = SL::DB::Manager::ApGl->get_first(where => [ ap_id => $form->{id} ]); |
437 | 433 |
my $gl_id = ref $ap_gl eq 'SL::DB::ApGl' ? $ap_gl->gl_id : undef; |
... | ... | |
440 | 436 |
SL::DB::Manager::ApGl-> delete_all(where => [ ap_id => $form->{id} ]) if $gl_id; |
441 | 437 |
SL::DB::Manager::RecordLink-> delete_all(where => [ from_table => 'ap', to_table => 'gl', from_id => $form->{id} ]); |
442 | 438 |
|
443 |
# gl booking |
|
444 |
my ($credit, $debit); |
|
445 |
$credit = SL::DB::Manager::Chart->find_by(id => $tax->chart_id); |
|
446 |
$debit = SL::DB::Manager::Chart->find_by(id => $tax->reverse_charge_chart_id); |
|
447 |
|
|
448 |
croak("No such Chart ID" . $tax->chart_id) unless ref $credit eq 'SL::DB::Chart'; |
|
449 |
croak("No such Chart ID" . $tax->reverse_chart_id) unless ref $debit eq 'SL::DB::Chart'; |
|
450 |
|
|
451 | 439 |
my ($i, $current_transaction); |
452 | 440 |
|
453 | 441 |
for $i (1 .. $form->{rowcount}) { |
454 |
next unless $form->{"taxkey_$i"} == 94; |
|
455 | 442 |
|
456 |
my ($tmpnetamount, $tmptaxamount) = $form->calculate_tax($form->{"amount_$i"}, 0.19, $form->{taxincluded}, 2); |
|
443 |
my $tax = SL::DB::Manager::Tax->get_first( where => [id => $form->{"tax_id_$i"}, '!reverse_charge_chart_id' => undef ]); |
|
444 |
next unless ref $tax eq 'SL::DB::Tax'; |
|
445 |
|
|
446 |
# gl booking |
|
447 |
my ($credit, $debit); |
|
448 |
$credit = SL::DB::Manager::Chart->find_by(id => $tax->chart_id); |
|
449 |
$debit = SL::DB::Manager::Chart->find_by(id => $tax->reverse_charge_chart_id); |
|
450 |
|
|
451 |
croak("No such Chart ID" . $tax->chart_id) unless ref $credit eq 'SL::DB::Chart'; |
|
452 |
croak("No such Chart ID" . $tax->reverse_chart_id) unless ref $debit eq 'SL::DB::Chart'; |
|
453 |
|
|
454 |
my ($tmpnetamount, $tmptaxamount) = $form->calculate_tax($form->{"amount_$i"}, $tax->rate, $form->{taxincluded}, 2); |
|
457 | 455 |
$current_transaction = SL::DB::GLTransaction->new( |
458 | 456 |
employee_id => $form->{employee_id}, |
459 | 457 |
transdate => $form->{transdate}, |
... | ... | |
466 | 464 |
chart => $tmptaxamount > 0 ? $debit : $credit, |
467 | 465 |
debit => abs($tmptaxamount), |
468 | 466 |
source => "Reverse Charge for " . $form->{invnumber}, |
467 |
tax_id => 0, |
|
469 | 468 |
)->add_chart_booking( |
470 | 469 |
chart => $tmptaxamount > 0 ? $credit : $debit, |
471 | 470 |
credit => abs($tmptaxamount), |
472 | 471 |
source => "Reverse Charge for " . $form->{invnumber}, |
472 |
tax_id => 0, |
|
473 | 473 |
)->post; |
474 | 474 |
# add a stable link from ap to gl |
475 | 475 |
my %props_gl = ( |
bin/mozilla/ap.pl | ||
---|---|---|
496 | 496 |
$form->{"taxcharts_$i"} = \@taxcharts; |
497 | 497 |
|
498 | 498 |
# reverse charge hack for template, display two taxes |
499 |
if ($taxchart_to_use->taxkey == 94) {
|
|
499 |
if ($taxchart_to_use->reverse_charge_chart_id) {
|
|
500 | 500 |
my $tmpnetamount; |
501 |
($tmpnetamount, $form->{"tax_reverse_$i"}) = $form->calculate_tax($form->parse_amount(\%myconfig, $form->{"amount_$i"}), 0.19, $form->{taxincluded},2); |
|
501 |
($tmpnetamount, $form->{"tax_reverse_$i"}) = $form->calculate_tax($form->parse_amount(\%myconfig, $form->{"amount_$i"}), |
|
502 |
$taxchart_to_use->rate, $form->{taxincluded}, 2 ); |
|
503 |
|
|
502 | 504 |
$form->{"tax_charge_$i"} = $form->{"tax_reverse_$i"} * -1; |
503 | 505 |
$form->{"tax_reverse_$i"} = $form->format_amount(\%myconfig, $form->{"tax_reverse_$i"}, 2); |
504 | 506 |
$form->{"tax_charge_$i"} = $form->format_amount(\%myconfig, $form->{"tax_charge_$i"}, 2); |
... | ... | |
807 | 809 |
$form->error($locale->text('Cannot post transaction for a closed period!')) if ($form->date_closed($form->{"transdate"}, \%myconfig)); |
808 | 810 |
|
809 | 811 |
my $zero_amount_posting = 1; |
810 |
# no taxincluded for 94 |
|
811 |
my $tax = SL::DB::Manager::Tax->get_first( where => [taxkey => 94 ]); |
|
812 |
my $tax_id = ref $tax eq 'SL::DB::Tax' ? $tax->id : undef; |
|
813 | 812 |
for my $i (1 .. $form->{rowcount}) { |
814 |
# no taxincluded for 94 |
|
815 |
if ($tax_id && $form->{"taxchart_$i"} =~ m/^$tax_id--/ && $form->{taxincluded}) { |
|
813 |
|
|
814 |
# no taxincluded for reverse charge |
|
815 |
my ($used_tax_id) = split(/--/, $form->{"taxchart_$i"}); |
|
816 |
my $tax = SL::DB::Manager::Tax->find_by(id => $used_tax_id); |
|
817 |
if ($tax->reverse_charge_chart_id && $form->{taxincluded}) { |
|
816 | 818 |
$form->error($locale->text('Cannot Post AP transaction with tax included!')); |
817 | 819 |
} |
820 |
|
|
818 | 821 |
if ($form->parse_amount(\%myconfig, $form->{"amount_$i"})) { |
819 | 822 |
$zero_amount_posting = 0; |
820 | 823 |
} |
Auch abrufbar als: Unified diff
Kreditorenbeleg prinzipiell um reverse_charge für beliebige Steuerschlüssel erw.
Sobald eine Steuer ein Gegenkonto (reverse_charge_chart_id) besitzt
wird die Steuer immer gespiegelt gebucht. Unabhängig vom Steuersatz
oder Steuerschlüssel.