From 51f9bfd5caaa8f49b8d859fcc990f5e013b02a74 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Sun, 16 Dec 2018 13:11:42 +0000 Subject: [PATCH] Bug 21756: Replace manualinvoice with add_debit in tests Signed-off-by: Kyle M Hall --- t/db_dependent/Circulation.t | 28 +++++++++++++++++-- .../Circulation/NoIssuesChargeGuarantees.t | 5 ++-- t/db_dependent/api/v1/patrons_accounts.t | 1 - 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index b7fc4d6496..fd718d8680 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -680,19 +680,41 @@ my ( $reused_itemnumber_1, $reused_itemnumber_2 ); C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1'); C4::Context->set_preference('OPACFineNoRenewals','10'); my $fines_amount = 5; - C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); + my $account = Koha::Account->new({patron_id => $renewing_borrowernumber}); + $account->add_debit( + { + amount => $fines_amount, + type => 'fine', + item_id => $item_to_auto_renew->{itemnumber}, + description => "Some fines" + } + )->accounttype->('F')->store; ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); is( $renewokay, 0, 'Do not renew, renewal is automatic' ); is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' ); - C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); + $account->add_debit( + { + amount => $fines_amount, + type => 'fine', + item_id => $item_to_auto_renew->{itemnumber}, + description => "Some fines" + } + )->accounttype->('F')->store; ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); is( $renewokay, 0, 'Do not renew, renewal is automatic' ); is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' ); - C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); + $account->add_debit( + { + amount => $fines_amount, + type => 'fine', + item_id => $item_to_auto_renew->{itemnumber}, + description => "Some fines" + } + )->accounttype->('F')->store; ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); is( $renewokay, 0, 'Do not renew, renewal is automatic' ); diff --git a/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t b/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t index 971208f494..2814405515 100644 --- a/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t +++ b/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t @@ -22,8 +22,8 @@ use Test::More tests => 6; use t::lib::TestBuilder; use t::lib::Mocks; -use C4::Accounts qw( manualinvoice ); use C4::Circulation qw( CanBookBeIssued ); +use Koha::Account; use Koha::Account::Lines; use Koha::Account::Offsets; @@ -68,7 +68,8 @@ t::lib::Mocks::mock_preference( 'AllowFineOverride', '' ); my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->{barcode} ); is( $issuingimpossible->{DEBT_GUARANTEES}, undef, "Patron can check out item" ); -manualinvoice( $guarantee->{borrowernumber}, undef, undef, 'L', 10.00 ); +my $account = Koha::Account->new( { patron_id => $guarantee->{borrowernumber} } ); +$account->add_debit({ amount => 10.00, type => 'lost_item' }); ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->{barcode} ); is( $issuingimpossible->{DEBT_GUARANTEES} + 0, '10.00' + 0, "Patron cannot check out item due to debt for guarantee" ); diff --git a/t/db_dependent/api/v1/patrons_accounts.t b/t/db_dependent/api/v1/patrons_accounts.t index 9f1c4f23e5..8983812cd5 100644 --- a/t/db_dependent/api/v1/patrons_accounts.t +++ b/t/db_dependent/api/v1/patrons_accounts.t @@ -25,7 +25,6 @@ use Test::Warn; use t::lib::TestBuilder; use t::lib::Mocks; -use C4::Accounts qw(manualinvoice); use C4::Auth; use Koha::Account::Line; -- 2.17.2 (Apple Git-113)