Skip to content

Commit

Permalink
Load batch data before approving
Browse files Browse the repository at this point in the history
Initializes 'batch_class_id' (but not 'batch_class'), so compare the former.

Fixes ledgersmb#8610
  • Loading branch information
ehuelsmann committed Jan 21, 2025
1 parent 61430f8 commit 0e3bd75
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/LedgerSMB/Scripts/vouchers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ sub batch_approve {
for my $count (1 .. $batch->{rowcount_}){
next unless $batch->{'select_' . $count};
$batch->{batch_id} = $batch->{"row_$count"};
$batch->get;
$batch->post;
}
$request->{report_name} = 'batches';
Expand Down
14 changes: 8 additions & 6 deletions old/lib/LedgerSMB/Batch.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ package LedgerSMB::Batch;

use strict;
use warnings;
use base qw(LedgerSMB::PGOld);

use LedgerSMB::Magic qw( BC_PAYMENT BC_PAYMENT_REVERSAL BC_RECEIPT BC_RECEIPT_REVERSAL );
use LedgerSMB::Setting;
use base qw(LedgerSMB::PGOld);

use Log::Any qw($log);

Expand Down Expand Up @@ -255,11 +256,12 @@ Returns the batch C<approved_on> date (being the current database date).
sub post {
my ($self) = @_;

if (not (defined $self->{batch_class}
and ($self->{batch_class} eq 'payment'
or $self->{batch_class} eq 'payment_reversal'
or $self->{batch_class} eq 'receipt'
or $self->{batch_class} eq 'receipt_reversal'))) {
$log->info("Deleting batch $self->{id} of class $self->{batch_class_id}");

Check failure on line 259 in old/lib/LedgerSMB/Batch.pm

View workflow job for this annotation

GitHub Actions / test-remainder (5.36, 15, firefox, 1, 7)

( STDERR ) job 10 Use of uninitialized value in concatenation (.) or string

Check failure on line 259 in old/lib/LedgerSMB/Batch.pm

View workflow job for this annotation

GitHub Actions / test-remainder (5.36, 15, firefox, 1, 7)

( STDERR ) job 10 Use of uninitialized value in concatenation (.) or string

Check failure on line 259 in old/lib/LedgerSMB/Batch.pm

View workflow job for this annotation

GitHub Actions / test-remainder (5.36, 15, firefox, 1, 7)

( STDERR ) job 13 Use of uninitialized value in concatenation (.) or string

Check failure on line 259 in old/lib/LedgerSMB/Batch.pm

View workflow job for this annotation

GitHub Actions / test-remainder (5.36, 15, firefox, 1, 7)

( STDERR ) job 13 Use of uninitialized value in concatenation (.) or string

Check failure on line 259 in old/lib/LedgerSMB/Batch.pm

View workflow job for this annotation

GitHub Actions / test-remainder (5.40, 13, operablink, 1, 7)

( STDERR ) job 10 Use of uninitialized value in concatenation (.) or string

Check failure on line 259 in old/lib/LedgerSMB/Batch.pm

View workflow job for this annotation

GitHub Actions / test-remainder (5.40, 13, operablink, 1, 7)

( STDERR ) job 10 Use of uninitialized value in concatenation (.) or string

Check failure on line 259 in old/lib/LedgerSMB/Batch.pm

View workflow job for this annotation

GitHub Actions / test-remainder (5.40, 13, operablink, 1, 7)

( STDERR ) job 13 Use of uninitialized value in concatenation (.) or string

Check failure on line 259 in old/lib/LedgerSMB/Batch.pm

View workflow job for this annotation

GitHub Actions / test-remainder (5.40, 13, operablink, 1, 7)

( STDERR ) job 13 Use of uninitialized value in concatenation (.) or string

Check failure on line 259 in old/lib/LedgerSMB/Batch.pm

View workflow job for this annotation

GitHub Actions / test-remainder (5.38, 14, chrome, 1, 3)

( STDERR ) job 10 Use of uninitialized value in concatenation (.) or string

Check failure on line 259 in old/lib/LedgerSMB/Batch.pm

View workflow job for this annotation

GitHub Actions / test-remainder (5.38, 14, chrome, 1, 3)

( STDERR ) job 10 Use of uninitialized value in concatenation (.) or string

Check failure on line 259 in old/lib/LedgerSMB/Batch.pm

View workflow job for this annotation

GitHub Actions / test-remainder (5.38, 14, chrome, 1, 3)

( STDERR ) job 13 Use of uninitialized value in concatenation (.) or string

Check failure on line 259 in old/lib/LedgerSMB/Batch.pm

View workflow job for this annotation

GitHub Actions / test-remainder (5.38, 14, chrome, 1, 3)

( STDERR ) job 13 Use of uninitialized value in concatenation (.) or string
if (not (defined $self->{batch_class_id}
and ($self->{batch_class_id} == BC_PAYMENT
or $self->{batch_class_id} == BC_PAYMENT_REVERSAL
or $self->{batch_class_id} == BC_RECEIPT
or $self->{batch_class_id} == BC_RECEIPT_REVERSAL))) {
# payments and receipts (and reversals) are part of a transaction
# which may already have been approved, meaning that 'batch-approve'
# isn't available...
Expand Down

0 comments on commit 0e3bd75

Please sign in to comment.