Bug 41889: [Rmaint] Fix error in conflict resolution

This commit is contained in:
Baptiste Wojtkowski 2026-09-14 10:08:11 +00:00
parent 75e0d65da6
commit 671f27eeb1
No known key found for this signature in database
GPG Key ID: 47A8A13E10BC0D40
1 changed files with 0 additions and 111 deletions

View File

@ -601,116 +601,6 @@ subtest 'add checkout' => sub {
$schema->storage->txn_rollback;
};
<<<<<<< HEAD
||||||| parent of 64bea0833a (Bug 41889: Update API to allow for null patron_id to be returned when listing checkouts)
subtest 'renew with fine override (x-koha-override: debt_limit)' => sub {
plan tests => 15;
$schema->storage->txn_begin;
# Create a librarian with circulate permission
my $librarian = $builder->build_object(
{
class => 'Koha::Patrons',
value => { flags => 2 } # Superlibrarian
}
);
my $password = 'thePassword123';
$librarian->set_password( { password => $password, skip_validation => 1 } );
my $userid = $librarian->userid;
# Create a regular patron
my $patron = $builder->build_object(
{
class => 'Koha::Patrons',
value => { flags => 0 }
}
);
# Create a branch and set up userenv
my $branch = $builder->build( { source => 'Branch' } );
t::lib::Mocks::mock_userenv(
{ branchcode => $branch->{branchcode}, borrowernumber => $librarian->borrowernumber } );
# Set up circulation rules
Koha::CirculationRules->set_rules(
{
categorycode => undef,
itemtype => undef,
branchcode => undef,
rules => {
renewalperiod => 7,
renewalsallowed => 10,
issuelength => 5,
}
}
);
my $item = $builder->build_sample_item;
# Check out the item
my $checkout = AddIssue( $patron, $item->barcode );
# Set FineNoRenewals to a low amount
t::lib::Mocks::mock_preference( 'FineNoRenewals', 5 );
# Add a fine that exceeds the limit
my $account = Koha::Account->new( { patron_id => $patron->borrowernumber } );
$account->add_debit(
{
amount => 10.00,
type => 'OVERDUE',
interface => 'test',
description => 'Test fine',
item_id => $item->itemnumber,
}
);
my $checkout_id = $checkout->id;
# Test 1: Renewal should be blocked due to excessive fines
$t->post_ok("//$userid:$password@/api/v1/checkouts/$checkout_id/renewal")
->status_is(403)
->json_like( '/error' => qr/too_much_owing/ );
# Test 2: Override should fail when AllowFineOverrideRenewing is disabled
t::lib::Mocks::mock_preference( 'AllowFineOverrideRenewing', 0 );
$t->post_ok( "//$userid:$password@/api/v1/checkouts/$checkout_id/renewal" => { 'x-koha-override' => 'debt_limit' } )
->status_is(403)
->json_like( '/error' => qr/too_much_owing/ );
# Test 3: Override should succeed when AllowFineOverrideRenewing is enabled
t::lib::Mocks::mock_preference( 'AllowFineOverrideRenewing', 1 );
$t->post_ok( "//$userid:$password@/api/v1/checkouts/$checkout_id/renewal" => { 'x-koha-override' => 'debt_limit' } )
->status_is(201)
->json_has('/due_date');
# Refresh checkout
$checkout = Koha::Checkouts->find($checkout_id);
# Test 4: Test with /renewals endpoint (alternative endpoint)
# Add another checkout to test the other endpoint
my $item2 = $builder->build_sample_item;
my $checkout2 = AddIssue( $patron, $item2->barcode );
my $checkout2_id = $checkout2->id;
# Should be blocked without override
$t->post_ok("//$userid:$password@/api/v1/checkouts/$checkout2_id/renewals")
->status_is(403)
->json_like( '/error' => qr/too_much_owing/ );
# Should succeed with override
$t->post_ok(
"//$userid:$password@/api/v1/checkouts/$checkout2_id/renewals" => { 'x-koha-override' => 'debt_limit' } )
->status_is(201)
->json_has('/due_date');
$schema->storage->txn_rollback;
};
=======
subtest 'renew with fine override (x-koha-override: debt_limit)' => sub {
plan tests => 15;
@ -873,4 +763,3 @@ subtest 'list checkouts that have been checked in and the patron has been delete
$schema->storage->txn_rollback;
};
>>>>>>> 64bea0833a (Bug 41889: Update API to allow for null patron_id to be returned when listing checkouts)