From 61f9244fd1e033b8dad1cff0380d54a617c6c81a Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 10 Jan 2020 11:10:50 +0100 Subject: [PATCH] Bug 24408: Do not compare floats with precision in tests We should not compare floating precision in tests. Test plan: Confirm that the tests still pass after this patch --- t/Prices.t | 20 +++---- t/db_dependent/Accounts.t | 24 ++++---- t/db_dependent/Circulation.t | 44 +++++++------- t/db_dependent/Circulation/GetHardDueDate.t | 8 +-- .../Circulation/NoIssuesChargeGuarantees.t | 4 +- t/db_dependent/Koha/Account.t | 28 ++++----- t/db_dependent/Koha/ItemTypes.t | 4 +- t/db_dependent/Overdues.t | 68 +++++++++++----------- 8 files changed, 99 insertions(+), 101 deletions(-) diff --git a/t/Prices.t b/t/Prices.t index b82e17dfe4..740bfe5e11 100644 --- a/t/Prices.t +++ b/t/Prices.t @@ -56,15 +56,15 @@ for my $currency_format ( qw( US FR ) ) { my $order_0_0 = { biblionumber => $biblionumber_0_0, quantity => 2, - listprice => 82.000000, - unitprice => 73.80000, + listprice => 82, + unitprice => 73.80, quantityreceived => 2, basketno => $basketno_0_0, invoiceid => $invoiceid_0_0, rrp => 82.00, ecost => 73.80, tax_rate => 0.0500, - discount => 10.0000, + discount => 10, datereceived => $today }; $order_0_0 = C4::Acquisition::populate_order_with_prices( @@ -157,15 +157,15 @@ for my $currency_format ( qw( US FR ) ) { my $order_1_1 = { biblionumber => $biblionumber_1_1, quantity => 2, - listprice => 82.000000, - unitprice => 73.800000, + listprice => 82, + unitprice => 73.80, quantityreceived => 2, basketno => $basketno_1_1, invoiceid => $invoiceid_1_1, rrp => 82.00, ecost => 73.80, tax_rate => 0.0500, - discount => 10.0000, + discount => 10, datereceived => $today }; @@ -259,7 +259,7 @@ for my $currency_format ( qw( US FR ) ) { my $order_1_0 = { biblionumber => $biblionumber_1_0, quantity => 2, - listprice => 82.000000, + listprice => 82, unitprice => 0, quantityreceived => 2, basketno => $basketno_1_1, @@ -267,7 +267,7 @@ for my $currency_format ( qw( US FR ) ) { rrp => 82.00, ecost => 73.80, tax_rate => 0.0500, - discount => 10.0000, + discount => 10, datereceived => $today }; @@ -380,7 +380,7 @@ for my $currency_format ( qw( US FR ) ) { my $order_0_1 = { biblionumber => $biblionumber_0_1, quantity => 2, - listprice => 82.000000, + listprice => 82, unitprice => 0, quantityreceived => 2, basketno => $basketno_1_1, @@ -388,7 +388,7 @@ for my $currency_format ( qw( US FR ) ) { rrp => 82.00, ecost => 73.80, tax_rate => 0.0500, - discount => 10.0000, + discount => 10, datereceived => $today }; diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t index 9236edfde8..5ae8c20c66 100644 --- a/t/db_dependent/Accounts.t +++ b/t/db_dependent/Accounts.t @@ -78,7 +78,7 @@ my $userenv_branchcode = $branchcode; my $itemtype = $builder->build( { source => 'Itemtype' } ); my $item = $builder->build( { source => 'Item', value => { itype => $itemtype->{itemtype} } } ); my $patron = $builder->build( { source => 'Borrower' } ); -my $amount = '5.000000'; +my $amount = 5; my $description = "Test fee!"; my $type = 'LOST'; my $note = 'Test note!'; @@ -94,7 +94,7 @@ my ($accountline) = Koha::Account::Lines->search( } ); is( $accountline->debit_type_code, $type, 'Debit type set correctly for manualinvoice' ); -is( $accountline->amount, $amount, 'Accountline amount set correctly for manualinvoice' ); +is( $accountline->amount+0, $amount, 'Accountline amount set correctly for manualinvoice' ); ok( $accountline->description =~ /^$description/, 'Accountline description set correctly for manualinvoice' ); is( $accountline->note, $note, 'Accountline note set correctly for manualinvoice' ); is( $accountline->branchcode, $branchcode, 'Accountline branchcode set correctly for manualinvoice' ); @@ -296,9 +296,9 @@ subtest "Koha::Account::pay tests" => sub { my $line3 = $account->add_debit({ type => 'ACCOUNT', amount => 42, interface => 'commandline' }); my $payment_id = $account->pay( { lines => [$line3], amount => 42 } ); my $payment = Koha::Account::Lines->find( $payment_id ); - is( $payment->amount(), '-42.000000', "Payment paid the specified fine" ); + is( $payment->amount()+0, -42, "Payment paid the specified fine" ); $line3 = Koha::Account::Lines->find( $line3->id ); - is( $line3->amountoutstanding, '0.000000', "Specified fine is paid" ); + is( $line3->amountoutstanding+0, 0, "Specified fine is paid" ); is( $payment->branchcode, undef, 'branchcode passed, then undef' ); }; @@ -338,13 +338,13 @@ subtest "Koha::Account::pay particular line tests" => sub { $_->_result->discard_changes foreach ( $line1, $line2, $line3, $line4 ); # Line1 is not paid at all, as it was not passed in the lines param - is( $line1->amountoutstanding, "1.000000", "Line 1 was not paid" ); + is( $line1->amountoutstanding+0, 1, "Line 1 was not paid" ); # Line2 was paid in full, as it was the first in the lines list - is( $line2->amountoutstanding, "0.000000", "Line 2 was paid in full" ); + is( $line2->amountoutstanding+0, 0, "Line 2 was paid in full" ); # Line3 was paid partially, as the remaining balance did not cover it entirely - is( $line3->amountoutstanding, "1.000000", "Line 3 was paid to 1.00" ); + is( $line3->amountoutstanding+0, 1, "Line 3 was paid to 1.00" ); # Line4 was not paid at all, as the payment was all used up by that point - is( $line4->amountoutstanding, "4.000000", "Line 4 was not paid" ); + is( $line4->amountoutstanding+0, 4, "Line 4 was not paid" ); }; subtest "Koha::Account::pay writeoff tests" => sub { @@ -380,13 +380,13 @@ subtest "Koha::Account::pay writeoff tests" => sub { $line->_result->discard_changes(); - is( $line->amountoutstanding, "0.000000", "Line was written off" ); + is( $line->amountoutstanding+0, 0, "Line was written off" ); my $writeoff = Koha::Account::Lines->find( $id ); is( $writeoff->credit_type_code, 'WRITEOFF', 'Type is correct for WRITEOFF' ); is( $writeoff->description, 'Writeoff', 'Description is correct' ); - is( $writeoff->amount, '-42.000000', 'Amount is correct' ); + is( $writeoff->amount+0, -42, 'Amount is correct' ); }; subtest "More Koha::Account::pay tests" => sub { @@ -428,7 +428,7 @@ subtest "More Koha::Account::pay tests" => sub { $account->pay({ lines => [$line], amount => $amount, library_id => $branch, note => 'A payment note' }); my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->{accountlines_id} })->next(); - is( $offset->amount(), '-100.000000', 'Offset amount is -100.00' ); + is( $offset->amount+0, -100, 'Offset amount is -100.00' ); is( $offset->type(), 'Payment', 'Offset type is Payment' ); my $stat = $schema->resultset('Statistic')->search({ @@ -488,7 +488,7 @@ subtest "Even more Koha::Account::pay tests" => sub { $account->pay({ lines => [$line], amount => $partialamount, library_id => $branch, note => 'A payment note' }); my $offset = Koha::Account::Offsets->search( { debit_id => $accountline->{ accountlines_id } } )->next(); - is( $offset->amount, '-60.000000', 'Offset amount is -60.00' ); + is( $offset->amount+0, -60, 'Offset amount is -60.00' ); is( $offset->type, 'Payment', 'Offset type is payment' ); my $stat = $schema->resultset('Statistic')->search({ diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index 2cf83118b6..c0e2dacece 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -934,13 +934,13 @@ subtest "CanBookBeRenewed tests" => sub { my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower->{borrowernumber} })->next(); is( $line->debit_type_code, 'OVERDUE', 'Account line type is OVERDUE' ); is( $line->status, 'UNRETURNED', 'Account line status is UNRETURNED' ); - is( $line->amountoutstanding, '15.000000', 'Account line amount outstanding is 15.00' ); - is( $line->amount, '15.000000', 'Account line amount is 15.00' ); + is( $line->amountoutstanding+0, 15, 'Account line amount outstanding is 15.00' ); + is( $line->amount+0, 15, 'Account line amount is 15.00' ); is( $line->issue_id, $issue->id, 'Account line issue id matches' ); my $offset = Koha::Account::Offsets->search({ debit_id => $line->id })->next(); is( $offset->type, 'OVERDUE', 'Account offset type is Fine' ); - is( $offset->amount, '15.000000', 'Account offset amount is 15.00' ); + is( $offset->amount+0, 15, 'Account offset amount is 15.00' ); t::lib::Mocks::mock_preference('WhenLostForgiveFine','0'); t::lib::Mocks::mock_preference('WhenLostChargeReplacementFee','0'); @@ -961,7 +961,7 @@ subtest "CanBookBeRenewed tests" => sub { undef, $renewing_borrower->{borrowernumber} ); - is( $total_due, '15.000000', 'Borrower only charged replacement fee with both WhenLostForgiveFine and WhenLostChargeReplacementFee enabled' ); + is( $total_due+0, 15, 'Borrower only charged replacement fee with both WhenLostForgiveFine and WhenLostChargeReplacementFee enabled' ); C4::Context->dbh->do("DELETE FROM accountlines"); @@ -2523,7 +2523,7 @@ subtest '_FixOverduesOnReturn' => sub { $accountline->_result()->discard_changes(); - is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' ); + is( $accountline->amountoutstanding+0, 99, 'Fine has the same amount outstanding as previously' ); isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )'); is( $accountline->status, 'RETURNED', 'Passed status has been used to set as RETURNED )'); @@ -3119,7 +3119,7 @@ subtest 'Incremented fee tests' => sub { value => { notforloan => undef, rentalcharge => 0, - rentalcharge_daily => 1.000000 + rentalcharge_daily => 1, } } )->store; @@ -3131,8 +3131,8 @@ subtest 'Incremented fee tests' => sub { } ); - is( $itemtype->rentalcharge_daily, - '1.000000', 'Daily rental charge stored and retreived correctly' ); + is( $itemtype->rentalcharge_daily+0, + 1, 'Daily rental charge stored and retreived correctly' ); is( $item->effective_itemtype, $itemtype->id, "Itemtype set correctly for item" ); @@ -3145,13 +3145,13 @@ subtest 'Incremented fee tests' => sub { my $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); - is( $accountline->amount, '7.000000', + is( $accountline->amount+0, 7, "Daily rental charge calculated correctly with finesCalendar = ignoreCalendar" ); $accountline->delete(); AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); - is( $accountline->amount, '6.000000', + is( $accountline->amount+0, 6, "Daily rental charge calculated correctly with finesCalendar = ignoreCalendar, for renewal" ); $accountline->delete(); @@ -3161,13 +3161,13 @@ subtest 'Incremented fee tests' => sub { $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); - is( $accountline->amount, '7.000000', + is( $accountline->amount+0, 7, "Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed" ); $accountline->delete(); AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); - is( $accountline->amount, '6.000000', + is( $accountline->amount+0, 6, "Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed, for renewal" ); $accountline->delete(); @@ -3188,20 +3188,20 @@ subtest 'Incremented fee tests' => sub { $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); - is( $accountline->amount, '6.000000', + is( $accountline->amount+0, 6, "Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed $closed_day_name" ); $accountline->delete(); AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } ); - is( $accountline->amount, '5.000000', + is( $accountline->amount+0, 5, "Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed $closed_day_name, for renewal" ); $accountline->delete(); $issue->delete(); - $itemtype->rentalcharge('2.000000')->store; - is( $itemtype->rentalcharge, '2.000000', + $itemtype->rentalcharge(2)->store; + is( $itemtype->rentalcharge+0, 2, 'Rental charge updated and retreived correctly' ); $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); @@ -3216,8 +3216,8 @@ subtest 'Incremented fee tests' => sub { "Fixed charge and accrued charge recorded distinctly, for renewal" ); $accountlines->delete(); $issue->delete(); - $itemtype->rentalcharge('00.000000')->store; - is( $itemtype->rentalcharge, '00.000000', + $itemtype->rentalcharge(0)->store; + is( $itemtype->rentalcharge+0, 0, 'Rental charge reset and retreived correctly' ); # Hourly @@ -3331,11 +3331,11 @@ subtest 'CanBookBeIssued & RentalFeesCheckoutConfirmation' => sub { my $dt_from = dt_from_string(); my $dt_due = dt_from_string()->add( days => 3 ); - $itemtype->rentalcharge('1.000000')->store; + $itemtype->rentalcharge(1)->store; ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, $dt_due, undef, undef, undef ); is_deeply( $needsconfirmation, { RENTALCHARGE => '1.00' }, 'Item needs rentalcharge confirmation to be issued' ); $itemtype->rentalcharge('0')->store; - $itemtype->rentalcharge_daily('1.000000')->store; + $itemtype->rentalcharge_daily(1)->store; ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, $dt_due, undef, undef, undef ); is_deeply( $needsconfirmation, { RENTALCHARGE => '3' }, 'Item needs rentalcharge confirmation to be issued, increment' ); $itemtype->rentalcharge_daily('0')->store; @@ -3380,8 +3380,8 @@ subtest "Test Backdating of Returns" => sub { my ( undef, $message ) = AddReturn( $item->barcode, $branch, undef, $due_date ); my $accountline = Koha::Account::Lines->find( { issue_id => $issue->id } ); - is( $accountline->amountoutstanding, '0.000000', 'Fee amount outstanding was reduced to 0' ); - is( $accountline->amount, '0.000000', 'Fee amount was reduced to 0' ); + is( $accountline->amountoutstanding+0, 0, 'Fee amount outstanding was reduced to 0' ); + is( $accountline->amount+0, 0, 'Fee amount was reduced to 0' ); }; $schema->storage->txn_rollback; diff --git a/t/db_dependent/Circulation/GetHardDueDate.t b/t/db_dependent/Circulation/GetHardDueDate.t index af13311918..c70c727759 100644 --- a/t/db_dependent/Circulation/GetHardDueDate.t +++ b/t/db_dependent/Circulation/GetHardDueDate.t @@ -113,7 +113,7 @@ my $default = { #Test GetIssuingRule my $sampleissuingrule1 = { - reservecharge => '0.000000', + reservecharge => 0, restrictedtype => 0, accountsent => 0, finedays => 0, @@ -124,13 +124,13 @@ my $sampleissuingrule1 = { issuelength => 5, chargeperiod => 0, chargeperiod_charge_at => 0, - rentaldiscount => '2.000000', + rentaldiscount => 2, reservesallowed => 0, hardduedate => '2013-01-01', branchcode => $samplebranch1->{branchcode}, - fine => '0.000000', + fine => 0, hardduedatecompare => 0, - overduefinescap => '0.000000', + overduefinescap => 0, renewalsallowed => 0, firstremind => 0, itemtype => 'BOOK', diff --git a/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t b/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t index 7f496aed83..341ecd7756 100644 --- a/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t +++ b/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t @@ -86,12 +86,12 @@ $account->add_debit({ amount => 10.00, type => 'LOST', interface => 'test' }); is( $issuingimpossible->{DEBT_GUARANTEES} + 0, '10.00' + 0, "Patron cannot check out item due to debt for guarantee" ); my $accountline = Koha::Account::Lines->search({ borrowernumber => $guarantee->id })->next(); -is( $accountline->amountoutstanding, "10.000000", "Found 10.00 amount outstanding" ); +is( $accountline->amountoutstanding+0, 10, "Found 10.00 amount outstanding" ); is( $accountline->debit_type_code, "LOST", "Debit type is LOST" ); my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id })->next(); is( $offset->type, 'Lost Item', 'Got correct offset type' ); -is( $offset->amount, '10.000000', 'Got amount of $10.00' ); +is( $offset->amount+0, 10, 'Got amount of $10.00' ); $schema->storage->txn_rollback; diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t index 02383c7d80..85ddb5eb50 100755 --- a/t/db_dependent/Koha/Account.t +++ b/t/db_dependent/Koha/Account.t @@ -754,28 +754,28 @@ subtest 'pay() handles lost items when paying a specific lost fee' => sub { $account->pay( { - amount => "0.500000", + amount => .5, library_id => $library->id, lines => [$accountline], } ); $accountline = Koha::Account::Lines->find( $accountline->id ); - is( $accountline->amountoutstanding, '0.500000', 'Account line was paid down by half' ); + is( $accountline->amountoutstanding+0, .5, 'Account line was paid down by half' ); $checkout = Koha::Checkouts->find( $checkout->id ); ok( $checkout, 'Item still checked out to patron' ); $account->pay( { - amount => "0.500000", + amount => 0.5, library_id => $library->id, lines => [$accountline], } ); $accountline = Koha::Account::Lines->find( $accountline->id ); - is( $accountline->amountoutstanding, '0.000000', 'Account line was paid down by half' ); + is( $accountline->amountoutstanding+0, 0, 'Account line was paid down by half' ); $checkout = Koha::Checkouts->find( $checkout->id ); ok( !$checkout, 'Item was removed from patron account' ); @@ -827,26 +827,26 @@ subtest 'pay() handles lost items when paying by amount ( not specifying the los $account->pay( { - amount => "0.500000", + amount => .5, library_id => $library->id, } ); $accountline = Koha::Account::Lines->find( $accountline->id ); - is( $accountline->amountoutstanding, '0.500000', 'Account line was paid down by half' ); + is( $accountline->amountoutstanding+0, .5, 'Account line was paid down by half' ); $checkout = Koha::Checkouts->find( $checkout->id ); ok( $checkout, 'Item still checked out to patron' ); $account->pay( { - amount => "0.500000", + amount => .5,, library_id => $library->id, } ); $accountline = Koha::Account::Lines->find( $accountline->id ); - is( $accountline->amountoutstanding, '0.000000', 'Account line was paid down by half' ); + is( $accountline->amountoutstanding+0, 0, 'Account line was paid down by half' ); $checkout = Koha::Checkouts->find( $checkout->id ); ok( !$checkout, 'Item was removed from patron account' ); @@ -900,8 +900,8 @@ subtest 'Koha::Account::Line::apply() handles lost items' => sub { { borrowernumber => $patron->id, date => '1900-01-01', - amount => "-0.500000", - amountoutstanding => "-0.500000", + amount => -.5, + amountoutstanding => -.5, interface => 'commandline', credit_type_code => 'PAYMENT' } @@ -910,7 +910,7 @@ subtest 'Koha::Account::Line::apply() handles lost items' => sub { $credit->apply({ debits => [ $debits->as_list ] }); $debit = Koha::Account::Lines->find( $debit->id ); - is( $debit->amountoutstanding, '0.500000', 'Account line was paid down by half' ); + is( $debit->amountoutstanding+0, .5, 'Account line was paid down by half' ); $checkout = Koha::Checkouts->find( $checkout->id ); ok( $checkout, 'Item still checked out to patron' ); @@ -919,8 +919,8 @@ subtest 'Koha::Account::Line::apply() handles lost items' => sub { { borrowernumber => $patron->id, date => '1900-01-01', - amount => "-0.500000", - amountoutstanding => "-0.500000", + amount => -.5, + amountoutstanding => -.5, interface => 'commandline', credit_type_code => 'PAYMENT' } @@ -929,7 +929,7 @@ subtest 'Koha::Account::Line::apply() handles lost items' => sub { $credit->apply({ debits => [ $debits->as_list ] }); $debit = Koha::Account::Lines->find( $debit->id ); - is( $debit->amountoutstanding, '0.000000', 'Account line was paid down by half' ); + is( $debit->amountoutstanding+0, 0, 'Account line was paid down by half' ); $checkout = Koha::Checkouts->find( $checkout->id ); ok( !$checkout, 'Item was removed from patron account' ); diff --git a/t/db_dependent/Koha/ItemTypes.t b/t/db_dependent/Koha/ItemTypes.t index 2baef5a7ed..ff14ecd40e 100755 --- a/t/db_dependent/Koha/ItemTypes.t +++ b/t/db_dependent/Koha/ItemTypes.t @@ -113,7 +113,7 @@ my $type = Koha::ItemTypes->find('type1'); ok( defined($type), 'first result' ); is( $type->itemtype, 'type1', 'itemtype/code' ); is( $type->description, 'description', 'description' ); -is( $type->rentalcharge, '0.000000', 'rentalcharge' ); +is( $type->rentalcharge+0, 0, 'rentalcharge' ); is( $type->imageurl, 'imageurl', 'imageurl' ); is( $type->summary, 'summary', 'summary' ); is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' ); @@ -123,7 +123,7 @@ $type = Koha::ItemTypes->find('type2'); ok( defined($type), 'second result' ); is( $type->itemtype, 'type2', 'itemtype/code' ); is( $type->description, 'description', 'description' ); -is( $type->rentalcharge, '0.000000', 'rentalcharge' ); +is( $type->rentalcharge+0, 0, 'rentalcharge' ); is( $type->imageurl, 'imageurl', 'imageurl' ); is( $type->summary, 'summary', 'summary' ); is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' ); diff --git a/t/db_dependent/Overdues.t b/t/db_dependent/Overdues.t index 88388163ba..ab069447ba 100644 --- a/t/db_dependent/Overdues.t +++ b/t/db_dependent/Overdues.t @@ -186,8 +186,8 @@ subtest 'UpdateFine tests' => sub { { borrowernumber => $patron->borrowernumber } ); is( $fines->count, 1, "Fine added when amount is greater than 0" ); my $fine = $fines->next; - is( $fine->amount, '50.000000', "Fine amount correctly set to 50" ); - is( $fine->amountoutstanding, '50.000000', "Fine amountoutstanding correctly set to 50" ); + is( $fine->amount+0, 50, "Fine amount correctly set to 50" ); + is( $fine->amountoutstanding+0, 50, "Fine amountoutstanding correctly set to 50" ); is( $fine->issue_id, $checkout1->issue_id, "Fine is associated with the correct issue" ); is( $fine->itemnumber, $checkout1->itemnumber, "Fine is associated with the correct item" ); # Total : Outstanding : MaxFine @@ -208,8 +208,8 @@ subtest 'UpdateFine tests' => sub { { borrowernumber => $patron->borrowernumber } ); is( $fines->count, 1, "Existing fine updated" ); $fine = $fines->next; - is( $fine->amount, '80.000000', "Fine amount correctly updated to 80" ); - is( $fine->amountoutstanding, '80.000000', "Fine amountoutstanding correctly updated to 80" ); + is( $fine->amount+0, 80, "Fine amount correctly updated to 80" ); + is( $fine->amountoutstanding+0, 80, "Fine amountoutstanding correctly updated to 80" ); # Total : Outstanding : MaxFine # 80 : 80 : 100 @@ -230,11 +230,11 @@ subtest 'UpdateFine tests' => sub { ); is( $fines->count, 2, "New fine added for second checkout" ); $fine = $fines->next; - is( $fine->amount, '80.000000', "First fine amount unchanged" ); - is( $fine->amountoutstanding, '80.000000', "First fine amountoutstanding unchanged" ); + is( $fine->amount+0, 80, "First fine amount unchanged" ); + is( $fine->amountoutstanding+0, 80, "First fine amountoutstanding unchanged" ); my $fine2 = $fines->next; - is( $fine2->amount, '20.000000', "Second fine capped at '20' by MaxFine" ); - is( $fine2->amountoutstanding, '20.000000', "Second fine amountoutstanding capped at '20' by MaxFine" ); + is( $fine2->amount+0, 20, "Second fine capped at '20' by MaxFine" ); + is( $fine2->amountoutstanding+0, 20, "Second fine amountoutstanding capped at '20' by MaxFine" ); is( $fine2->issue_id, $checkout2->issue_id, "Second fine is associated with the correct issue" ); is( $fine2->itemnumber, $checkout2->itemnumber, "Second fine is associated with the correct item" ); is( $fine->amount + $fine2->amount, '100', "Total fines = 100" ); @@ -243,7 +243,7 @@ subtest 'UpdateFine tests' => sub { # 100 : 100 : 100 # Partial pay fine 1 - $fine->amountoutstanding('50.000000')->store; + $fine->amountoutstanding(50)->store; # Total : Outstanding : MaxFine # 100 : 50 : 100 @@ -264,11 +264,11 @@ subtest 'UpdateFine tests' => sub { ); is( $fines->count, 2, "Still two fines after second checkout update" ); $fine = $fines->next; - is( $fine->amount, '80.000000', "First fine amount unchanged" ); - is( $fine->amountoutstanding, '50.000000', "First fine amountoutstanding unchanged" ); + is( $fine->amount+0, 80, "First fine amount unchanged" ); + is( $fine->amountoutstanding+0, 50, "First fine amountoutstanding unchanged" ); $fine2 = $fines->next; - is( $fine2->amount, '30.000000', "Second fine increased after partial payment of first" ); - is( $fine2->amountoutstanding, '30.000000', "Second fine amountoutstanding increased after partial payment of first" ); + is( $fine2->amount+0, 30, "Second fine increased after partial payment of first" ); + is( $fine2->amountoutstanding+0, 30, "Second fine amountoutstanding increased after partial payment of first" ); is( $fine->amount + $fine2->amount, '110', "Total fines = 100" ); is( $fine->amountoutstanding + $fine2->amountoutstanding, '80', "Total outstanding = 80" ); # Total : Outstanding : MaxFine @@ -294,14 +294,14 @@ subtest 'UpdateFine tests' => sub { ); is( $fines->count, 3, "Third fine added for overdue renewal" ); $fine = $fines->next; - is( $fine->amount, '80.000000', "First fine amount unchanged" ); - is( $fine->amountoutstanding, '50.000000', "First fine amountoutstanding unchanged" ); + is( $fine->amount+0, 80, "First fine amount unchanged" ); + is( $fine->amountoutstanding+0, 50, "First fine amountoutstanding unchanged" ); $fine2 = $fines->next; - is( $fine2->amount, '30.000000', "Second fine amount unchanged" ); - is( $fine2->amountoutstanding, '30.000000', "Second fine amountoutstanding unchanged" ); + is( $fine2->amount+0, 30, "Second fine amount unchanged" ); + is( $fine2->amountoutstanding+0, 30, "Second fine amountoutstanding unchanged" ); my $fine3 = $fines->next; - is( $fine3->amount, '20.000000', "Third fine amount capped due to MaxFine" ); - is( $fine3->amountoutstanding, '20.000000', "Third fine amountoutstanding capped at '20' by MaxFine" ); + is( $fine3->amount+0, 20, "Third fine amount capped due to MaxFine" ); + is( $fine3->amountoutstanding+0, 20, "Third fine amountoutstanding capped at '20' by MaxFine" ); is( $fine3->issue_id, $checkout1->issue_id, "Third fine is associated with the correct issue" ); is( $fine3->itemnumber, $checkout1->itemnumber, "Third fine is associated with the correct item" ); is( $fine->amount + $fine2->amount + $fine3->amount, '130', "Total fines = 130" ); @@ -333,14 +333,14 @@ subtest 'UpdateFine tests' => sub { ); is( $fines->count, 3, "Still three fines after third checkout update" ); $fine = $fines->next; - is( $fine->amount, '80.000000', "First fine amount unchanged" ); - is( $fine->amountoutstanding, '50.000000', "First fine amountoutstanding unchanged" ); + is( $fine->amount+0, 80, "First fine amount unchanged" ); + is( $fine->amountoutstanding+0, 50, "First fine amountoutstanding unchanged" ); $fine2 = $fines->next; - is( $fine2->amount, '30.000000', "Second fine amount unchanged" ); - is( $fine2->amountoutstanding, '30.000000', "Second fine amountoutstanding unchanged" ); + is( $fine2->amount+0, 30, "Second fine amount unchanged" ); + is( $fine2->amountoutstanding+0, 30, "Second fine amountoutstanding unchanged" ); $fine3 = $fines->next; - is( $fine3->amount, '40.000000', "Third fine amount capped due to MaxFine" ); - is( $fine3->amountoutstanding, '20.000000', "Third fine amountoutstanding increased ..." ); + is( $fine3->amount+0, 40, "Third fine amount capped due to MaxFine" ); + is( $fine3->amountoutstanding+0, 20, "Third fine amountoutstanding increased ..." ); is( $fine3->issue_id, $checkout1->issue_id, "Third fine is associated with the correct issue" ); is( $fine3->itemnumber, $checkout1->itemnumber, "Third fine is associated with the correct item" ); is( $fine->amount + $fine2->amount + $fine3->amount, '150', "Total fines = 150" ); @@ -369,12 +369,12 @@ subtest 'UpdateFine tests' => sub { ); is( $fines->count, 3, "Still only three fines after MaxFine cap removed" ); $fine = $fines->next; - is( $fine->amount, '80.000000', "First fine amount unchanged" ); + is( $fine->amount+0, 80, "First fine amount unchanged" ); $fine2 = $fines->next; - is( $fine2->amount, '30.000000', "Second fine amount unchanged" ); + is( $fine2->amount+0, 30, "Second fine amount unchanged" ); $fine3 = $fines->next; - is( $fine3->amount, '50.000000', "Third fine increased now MaxFine cap is disabled" ); - is( $fine3->amountoutstanding, '30.000000', "Third fine increased now MaxFine cap is disabled" ); + is( $fine3->amount+0, 50, "Third fine increased now MaxFine cap is disabled" ); + is( $fine3->amountoutstanding+0, 30, "Third fine increased now MaxFine cap is disabled" ); # If somehow the fine should be reduced, we changed rules or checkout date or something UpdateFine( @@ -393,14 +393,12 @@ subtest 'UpdateFine tests' => sub { ); is( $fines->count, 3, "Still only three fines after MaxFine cap removed and third fine altered" ); $fine = $fines->next; - is( $fine->amount, '80.000000', "First fine amount unchanged" ); + is( $fine->amount+0, 80, "First fine amount unchanged" ); $fine2 = $fines->next; - is( $fine2->amount, '30.000000', "Second fine amount unchanged" ); + is( $fine2->amount+0, 30, "Second fine amount unchanged" ); $fine3 = $fines->next; - is( $fine3->amount, '30.000000', "Third fine reduced" ); - is( $fine3->amountoutstanding, '10.000000', "Third fine amount outstanding is reduced" ); - - + is( $fine3->amount+0, 30, "Third fine reduced" ); + is( $fine3->amountoutstanding+0, 10, "Third fine amount outstanding is reduced" ); $schema->storage->txn_rollback; }; -- 2.11.0