Bug 40225: Send stockrotation report even when all items are stationary

The stockrotation cronjob was only sending email reports when there were
actionable items (items that needed to be moved between branches). This
meant that libraries would not receive any notification when all items
in their rotation were stationary, even when the --send-all flag was
passed to the script.

This patch modifies the report logic to also send reports when there are
only stationary items, ensuring libraries have visibility into the complete
status of their stock rotation items.

Test plan:
1. Set up a stock rotation rota with items that are all stationary
   (items that should stay at their current branch)
2. Run the stockrotation cronjob: perl misc/cronjobs/stockrotation.pl
3. Without this patch: No email report is generated
4. Apply this patch
5. Run the cronjob again
6. Verify that an email report is now generated showing the stationary items
7. Test with mixed scenarios (some actionable, some stationary items)
8. Confirm reports are sent in all cases where items exist in the rotation

Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Martin Renvoize 2025-06-24 13:01:41 +01:00 committed by Pedro Amorim
parent 369236bb31
commit cb993ee5ef
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 1 additions and 1 deletions

View File

@ -318,7 +318,7 @@ sub report_by_branch {
if ($branch) { # Branch limited report
push @{$out}, _report_per_branch( $branched->{ $branch->branchcode } );
} elsif ( $data->{actionable} ) { # Full email report
} elsif ( $data->{actionable} || $data->{stationary} ) { # Full email report
while ( my ( $branchcode_id, $details ) = each %{$branched} ) {
push @{$out}, _report_per_branch($details)
if ( @{ $details->{items} } );