X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FHelper%2FPayment.pm;h=64d6a639cbdeb0aeaaf5aaa1933c08e0fc2446c0;hb=8d05386958d82c45b50062268bb549a08051486f;hp=5b3a138b531f7d0977ef1c2633fda7720559fe7f;hpb=587100bda49b111367428750b51614e25be4d4d3;p=kivitendo-erp.git diff --git a/SL/DB/Helper/Payment.pm b/SL/DB/Helper/Payment.pm index 5b3a138b5..64d6a639c 100644 --- a/SL/DB/Helper/Payment.pm +++ b/SL/DB/Helper/Payment.pm @@ -119,7 +119,7 @@ sub pay_invoice { my $fx_gain_loss_amount = 0; # for fx_gain and fx_loss my $db = $self->db; - $db->do_transaction(sub { + $db->with_transaction(sub { my $new_acc_trans; # all three payment type create 1 AR/AP booking (the paid part) @@ -278,36 +278,38 @@ sub pay_invoice { # than adding them to the transaction relation array. $self->forget_related('transactions'); - my $datev_check = 0; - if ( $is_sales ) { - if ( ( $self->invoice && $::instance_conf->get_datev_check_on_sales_invoice ) || - ( !$self->invoice && $::instance_conf->get_datev_check_on_ar_transaction )) { - $datev_check = 1; - }; - } else { - if ( ( $self->invoice && $::instance_conf->get_datev_check_on_purchase_invoice ) || - ( !$self->invoice && $::instance_conf->get_datev_check_on_ap_transaction )) { - $datev_check = 1; - }; - }; + my $datev_check = 0; + if ( $is_sales ) { + if ( ( $self->invoice && $::instance_conf->get_datev_check_on_sales_invoice ) || + ( !$self->invoice && $::instance_conf->get_datev_check_on_ar_transaction )) { + $datev_check = 1; + } + } else { + if ( ( $self->invoice && $::instance_conf->get_datev_check_on_purchase_invoice ) || + ( !$self->invoice && $::instance_conf->get_datev_check_on_ap_transaction )) { + $datev_check = 1; + } + } - if ( $datev_check ) { + if ( $datev_check ) { - my $datev = SL::DATEV->new( - exporttype => DATEV_ET_BUCHUNGEN, - format => DATEV_FORMAT_KNE, - dbh => $db->dbh, - trans_id => $self->{id}, - ); + my $datev = SL::DATEV->new( + exporttype => DATEV_ET_BUCHUNGEN, + format => DATEV_FORMAT_KNE, + dbh => $db->dbh, + trans_id => $self->{id}, + ); - $datev->clean_temporary_directories; - $datev->export; + $datev->clean_temporary_directories; + $datev->export; - if ($datev->errors) { - # this exception should be caught by do_transaction, which handles the rollback - die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; + if ($datev->errors) { + # this exception should be caught by with_transaction, which handles the rollback + die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors; + } } - }; + + 1; }) || die t8('error while paying invoice #1 : ', $self->invnumber) . $db->error . "\n"; @@ -385,7 +387,7 @@ sub open_amount { # if the difference is 0.01 Cent this may end up as 0.009999999999998 # numerically, so round this value when checking for cent threshold >= 0.01 - return $self->amount - $self->paid; + return ($self->amount // 0) - ($self->paid // 0); }; sub open_percent {