When a patron changes to a category with enrollment fee, they are not generated.
Created attachment 19071 [details] [review] Bug 10481: FIX No enrollment fee when changing patron category. When a patron changes to a category with enrollment fee, they are not generated. Test plan: - Choose a category without fee (e.g. Kid) - Add an enrollment fee for another category (e.g. Young adult) - Choose a kid and change his category to "Young adult". - Note the warning message "Fees & Charges: Patron has Outstanding fees & charges of XX" on the check out page.
There are two other places in C4/Members.pm that calculate and add the enrollment fee. Time for a new function rather than copy-pasta.
Created attachment 19556 [details] [review] Bug 10481: FIX No enrollment fee when changing patron category. When a patron changes to a category with enrollment fee, they are not generated. Test plan: - Choose a category without fee (e.g. Kid) - Add an enrollment fee for another category (e.g. Young adult) - Choose a kid and change his category to "Young adult". - Note the warning message "Fees & Charges: Patron has Outstanding fees & charges of XX" on the check out page.
Created attachment 19557 [details] [review] Bug 10481: Unit tests for C4::Members::AddEnrolmentFeeIfNeeded prove t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t .. ok All tests successful. Files=1, Tests=3, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.38 cusr 0.01 csys = 0.41 CPU) Result: PASS
(In reply to Galen Charlton from comment #2) > There are two other places in C4/Members.pm that calculate and add the > enrollment fee. Time for a new function rather than copy-pasta. Yes of course, you are right. Last 2 patches refactores code into 1 routine and add unit tests for it.
prove t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t .. Use of uninitialized value in pattern match (m//) at C4/SQLHelper.pm line 407. DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha`.`borrowers`, CONSTRAINT `borrowers_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)) at C4/SQLHelper.pm line 184.
(In reply to Srdjan Jankovic from comment #6) > prove t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t > t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t .. Use of uninitialized > value in pattern match (m//) at C4/SQLHelper.pm line 407. > DBD::mysql::st execute failed: Cannot add or update a child row: a foreign > key constraint fails (`koha`.`borrowers`, CONSTRAINT `borrowers_ibfk_1` > FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`)) at > C4/SQLHelper.pm line 184. It seems you don't have the good category codes. You have to insert sample data before executing this unit tests file.
installer/data/mysql/sample_only_param_tables.sql?
(In reply to Srdjan Jankovic from comment #8) > installer/data/mysql/sample_only_param_tables.sql? The patch for bug 10337 creates a DB with all sample data.
Created attachment 19694 [details] [review] [SIGNED-OFF] Bug 10481: FIX No enrollment fee when changing patron category. When a patron changes to a category with enrollment fee, they are not generated. Test plan: - Choose a category without fee (e.g. Kid) - Add an enrollment fee for another category (e.g. Young adult) - Choose a kid and change his category to "Young adult". - Note the warning message "Fees & Charges: Patron has Outstanding fees & charges of XX" on the check out page. Signed-off-by: Owen Leonard <oleonard@myacpl.org>
> The patch for bug 10337 creates a DB with all sample data. Sorry, did not know of that. It is in discussion, what is the instruction for using it atm?
(In reply to Srdjan Jankovic from comment #11) > > The patch for bug 10337 creates a DB with all sample data. > > Sorry, did not know of that. It is in discussion, what is the instruction > for using it atm? There is no instruction atm. I sent an email to the mailing list, but I did not get an answer. The patch allows to create a new DB with sample data only. These sample data are required for some unit tests (indeed, it is really boring to create *all* data for each unit tests).
(In reply to Owen Leonard from comment #10) > Created attachment 19694 [details] [review] [review] > [...] > Signed-off-by: Owen Leonard <oleonard@myacpl.org> Owen, did you forgot to change the status to Signed Off?
(In reply to Jonathan Druart from comment #13) > (In reply to Owen Leonard from comment #10) > > Created attachment 19694 [details] [review] [review] [review] > > [...] > > Signed-off-by: Owen Leonard <oleonard@myacpl.org> > > Owen, did you forgot to change the status to Signed Off? Ok, I understood after sending the comment, only 1 patch is signed off.
I still got the same result after applying 10337
(In reply to Srdjan Jankovic from comment #15) > I still got the same result after applying 10337 the sql file installer/data/mysql/en/optional/patron_categories.sql inserts needed categories (K, J, YA).
prove t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t .. DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha`.`borrowers`, CONSTRAINT `borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)) at C4/SQLHelper.pm line 184. DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha`.`accountlines`, CONSTRAINT `accountlines_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE) at C4/Accounts.pm line 474. DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha`.`accountlines`, CONSTRAINT `accountlines_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE) at C4/Accounts.pm line 474. # Looks like your test exited with 255 before it could output anything.
The branchcode "CPL" does not exist in your DB (added by installer/data/mysql/en/optional/sample_libraries.sql).
Created attachment 19787 [details] [review] [SIGNED-OFF] Bug 10337: Unit tests is based on an existing database This patchs adds a new unit tests file which will launched before all others db_dependent tests. It will drop and recreate the database with sample data. Prerequisite: The database 'koha_ut' have to be created with CREATE DATABASE $dbname CHARACTER SET utf8 COLLATE utf8_bin
Srdjan, Thanks for signing off this patch! But you did not sent the good one :)
Created attachment 19797 [details] [review] [SIGNED-OFF] Bug 10481: Unit tests for C4::Members::AddEnrolmentFeeIfNeeded prove t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t .. ok All tests successful. Files=1, Tests=3, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.38 cusr 0.01 csys = 0.41 CPU) Result: PASS Signed-off-by: Srdjan <srdjan@catalyst.net.nz>
Oh what a mess... Terribly sorry.
Created attachment 20406 [details] [review] Bug 10481: FIX No enrollment fee when changing patron category. When a patron changes to a category with enrollment fee, they are not generated. Test plan: - Choose a category without fee (e.g. Kid) - Add an enrollment fee for another category (e.g. Young adult) - Choose a kid and change his category to "Young adult". - Note the warning message "Fees & Charges: Patron has Outstanding fees & charges of XX" on the check out page. Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 20407 [details] [review] Bug 10481: Unit tests for C4::Members::AddEnrolmentFeeIfNeeded prove t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t .. ok All tests successful. Files=1, Tests=3, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.38 cusr 0.01 csys = 0.41 CPU) Result: PASS Signed-off-by: Srdjan <srdjan@catalyst.net.nz> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment on attachment 20407 [details] [review] Bug 10481: Unit tests for C4::Members::AddEnrolmentFeeIfNeeded Review of attachment 20407 [details] [review]: ----------------------------------------------------------------- ::: t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t @@ +50,5 @@ > + > +# Check with calling directly AddEnrolmentFeeIfNeeded > +C4::Members::AddEnrolmentFeeIfNeeded( 'YA', $borrowernumber ); > +( $total ) = C4::Members::GetMemberAccountRecords( $borrowernumber ); > +is( $total, $enrolmentfee_K + $enrolmentfee_J + $enrolmentfee_YA, "Juvenile growing and become an young adult, he should pay " . ( $enrolmentfee_K + $enrolmentfee_J + $enrolmentfee_YA ) ); If I were a kid in this library district, I would think twice about reporting my age! ;)
Pushed to master. Thanks, Jonathan!
This patch has been pushed to 3.12.x, will be in 3.12.5. Thanks Jonathan!
Pushed to 3.10.x, will be in 3.10.11
Pushed to 3.8.x, will be in 3.8.19
This patch introduce a new bug in 3.8.x It uses C4::Members::GetBorrowerCategorycode that is introduced only in 3.10 with http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=5742 This patch should be reverted for 3.8.x version
(In reply to Sophie MEYNIEUX from comment #30) > This patch introduce a new bug in 3.8.x > It uses C4::Members::GetBorrowerCategorycode that is introduced only in 3.10 > with http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=5742 > > This patch should be reverted for 3.8.x version This patch has now been reverted in 3.8.x and the reversion will be part of 3.8.22 Kyle