From 9a2a4c7fc2a1541fae45e6d8516f5050ace06061 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Tue, 22 Mar 2022 09:15:20 +0100 Subject: [PATCH] Kosmetik, Toten Code identifizieren, Alphabetische Reihenfolge Module --- SL/DB/GLTransaction.pm | 4 ++-- SL/DB/Helper/Payment.pm | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/SL/DB/GLTransaction.pm b/SL/DB/GLTransaction.pm index 50b29c0ff..a235bd9db 100644 --- a/SL/DB/GLTransaction.pm +++ b/SL/DB/GLTransaction.pm @@ -113,7 +113,7 @@ sub add_chart_booking { require SL::DB::Chart; die "add_chart_booking needs a transdate" unless $self->transdate; die "add_chart_booking needs taxincluded" unless defined $self->taxincluded; - die "chart missing" unless $params{chart} && ref($params{chart}) eq 'SL::DB::Chart'; + die "chart missing" unless $params{chart} && ref($params{chart}) eq 'SL::DB::Chart'; die t8('Booking needs at least one debit and one credit booking!') unless $params{debit} or $params{credit}; # must exist and not be 0 die t8('Cannot have a value in both Debit and Credit!') @@ -212,7 +212,7 @@ sub validate { my $sum = sum map { $_->amount } @{ $self->transactions }; # compare rounded amount to 0, to get around floating point problems, e.g. # $sum = -2.77555756156289e-17 - push @errors, t8('Out of balance transaction!') unless $::form->round_amount($sum,5) == 0; + push @errors, t8('Out of balance transaction!') . $sum unless $::form->round_amount($sum,5) == 0; }; } else { push @errors, t8('Empty transaction!'); diff --git a/SL/DB/Helper/Payment.pm b/SL/DB/Helper/Payment.pm index 28a981768..05de16377 100644 --- a/SL/DB/Helper/Payment.pm +++ b/SL/DB/Helper/Payment.pm @@ -10,14 +10,16 @@ our %EXPORT_TAGS = ( ); require SL::DB::Chart; + +use Carp; use Data::Dumper; use DateTime; -use SL::DATEV qw(:CONSTANTS); -use SL::Locale::String qw(t8); use List::Util qw(sum); + +use SL::DATEV qw(:CONSTANTS); use SL::DB::Exchangerate; use SL::DB::Currency; -use Carp; +use SL::Locale::String qw(t8); # # Public functions not exported by default @@ -259,7 +261,7 @@ sub pay_invoice { $reference_amount -= abs($amount); $paid_amount += -1 * $amount * $exchangerate; $skonto_amount_check -= $skonto_booking->{'skonto_amount'}; - }; + } if ( $params{payment_type} eq 'difference_as_skonto' ) { die "difference_as_skonto calculated incorrectly, sum of calculated payments doesn't add up to open amount $total_open_amount, reference_amount = $reference_amount\n" unless _round($reference_amount) == 0; } @@ -895,6 +897,8 @@ sub get_payment_suggestions { push(@{$self->{payment_select_options}} , { payment_type => 'with_skonto_pt', display => t8('with skonto acc. to pt') , selected => 1 }); } else { if ( ( $self->valid_skonto_amount($self->open_amount) || $self->valid_skonto_amount($open_amount) ) and not $params{sepa} ) { + # Will never be reached + die "This case is as dead as the dead cat. Go to start, don't pick 2,000 \$"; $self->{invoice_amount_suggestion} = $open_amount; # only suggest difference_as_skonto if open_amount exactly matches skonto_amount # AND we aren't in SEPA mode -- 2.20.1