Skip to content

Commit

Permalink
Merge pull request #8611 from ehuelsmann/fix/master/8610-batch-approve
Browse files Browse the repository at this point in the history
Load batch data before approving
  • Loading branch information
ehuelsmann authored Jan 22, 2025
2 parents eeee701 + 67928b0 commit fb3f4fc
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 18 deletions.
16 changes: 8 additions & 8 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ requires 'Text::CSV';
requires 'Text::Markdown';
requires 'URI';
requires 'URI::Escape';
requires 'Workflow', '1.59';
requires 'Workflow::Action', '1.59';
requires 'Workflow::Condition', '1.59';
requires 'Workflow::Context', '1.59';
requires 'Workflow::Exception', '1.59';
requires 'Workflow::Factory', '1.59';
requires 'Workflow::Persister::DBI', '1.59';
requires 'Workflow::Persister::DBI::ExtraData', '1.59';
requires 'Workflow', '>=1.59, <2.0';
requires 'Workflow::Action', '>=1.59, <2.0';
requires 'Workflow::Condition', '>=1.59, <2.0';
requires 'Workflow::Context', '>=1.59, <2.0';
requires 'Workflow::Exception', '>=1.59, <2.0';
requires 'Workflow::Factory', '>=1.59, <2.0';
requires 'Workflow::Persister::DBI', '>=1.59, <2.0';
requires 'Workflow::Persister::DBI::ExtraData', '>=1.59, <2.0';
requires 'XML::LibXML';
requires 'XML::LibXML::XPathContext';
requires 'YAML::PP';
Expand Down
3 changes: 2 additions & 1 deletion lib/LedgerSMB/Routes/ERP/API/Invoices.pm
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ sub _get_invoices_by_id {

$inv{workflow} = {
state => $wf->state,
actions => [ sort $wf->get_current_actions ]
actions => [ grep { ($wf->get_action( $_ )->ui // '') ne 'none' }
sort $wf->get_current_actions ]
};

return [ HTTP_OK,
Expand Down
3 changes: 2 additions & 1 deletion lib/LedgerSMB/Routes/ERP/API/Orders.pm
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ sub _get_orders_by_id {

$ord{workflow} = {
state => $wf->state,
actions => [ sort $wf->get_current_actions ]
actions => [ grep { ($wf->get_action( $_ )->ui // '') ne 'none' }
sort $wf->get_current_actions ]
};

return [ HTTP_OK,
Expand Down
1 change: 1 addition & 0 deletions lib/LedgerSMB/Scripts/vouchers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,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 parent qw(LedgerSMB::PGOld);

use LedgerSMB::Magic qw( BC_PAYMENT BC_PAYMENT_REVERSAL BC_RECEIPT BC_RECEIPT_REVERSAL );
use LedgerSMB::Setting;
use parent 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.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

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
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
9 changes: 7 additions & 2 deletions t/24-workflow-action-spawnworkflow.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ BEGIN {
}

use Workflow;
use Workflow::History;
use Workflow::Persister;
use LedgerSMB::Workflow::Action::SpawnWorkflow;

package TestFactory {};

my $c = Workflow::Context->new();
my $f = bless {}, 'TestFactory';
my $wf = Workflow->new( 'id', 'INITIAL', { type => 'test' }, [], $f );
my $wf2 = Workflow->new( 'id2', 'INITIAL', { type => 'test' }, [], $f );
my $wf = Workflow->new(
'id', 'INITIAL', { type => 'test',
history_class => 'Workflow::History' }, [], $f );
my $wf2 = Workflow->new(
'id2', 'INITIAL', { type => 'test',
history_class => 'Workflow::History' }, [], $f );

$wf->context( $c );

Expand Down

0 comments on commit fb3f4fc

Please sign in to comment.