It is possible to create two aqbudgets records with a parent-child relationship (i.e. budget_parent_id of the 'child' record is the 'budget_id' of the parent), then delete the parent record. The Child record will then be un-editable, because it will always trigger a 'Fund amount exceeds parent allocation' message. Replicating issue: From acqui-home.pl on staff client, 1) Click 'funds' link, navigating to cgi-bin/koha/admin/aqbudgets.pl 2) Click 'New budget' link. 3) Populate Start Date, End date, description and amount. Click 'Make budget active' and save changes. 4) Click on budget description, this will navigate to cgi-bin/koha/admin/aqbudgets.pl 5) Click 'New', select 'New fund for ...' 6) Populate Fund code (I used PARENT01) Fund name (Parent 1) Amount (Will be less than or equal to budget amound populated earlier). 7) Click submit 8) For Parent 1, click 'Actions', then 'Add Child Fund'. 9) Populate Child: Fund code (I used CHILD01) Fund name (Child 1) Amount (Will be less than or equal to amount for Parent 1) 10) Click submit 11) Choose Actions->delete for 'Parent 1' fund. Choose 'Delete' when prompted. 12) Find 'Child 1' fund, click actions->edit 13) Click Submit. A pop-up will appear with the following text: Form not submitted because of the following problem(s) ------------------------------------------------------------------------------------ - Fund amount exceeds parent allocation I see the following problems * There should be a referential integrity check for aqbudgets.budget_parent_id: if it exists, it must point to a valid parent record. * Deleting an aqbudgets record with a child should issue an explicit warning that the fund has children. * The user should have the choice of deleting children with the parent or removing the link to the parent, thus promoting them to first class funds. * function budgetExceedsParent in acq.js should be able to handle an unknown error * cgi-bin/admin/check_parent_total.pl should check that the parent record exists, and should *not* pass $returncode = 1 if the parent record does not exist, even if budget_parent_id is not NULL.
Created attachment 33413 [details] [review] Bug 12905: funds with children could not be deleted The interface should prevent to delete funds with children. Otherwise the relationship is broken and problems occur: 1/ You don't see the orphan fund in the fund list 2/ You cannot edit the orphan fund amount ('Fund amount exceeds parent allocation'). This patch: - adds a JS check, template side - adds a check in the perl script (should never be true) - adds an updatedatabase check, in order to alert users with inconsistent data. Test plan: Verify you are not allow to delete a fund with children.
*** Bug 4292 has been marked as a duplicate of this bug. ***
Created attachment 33457 [details] [review] Bug 12905: funds with children could not be deleted The interface should prevent to delete funds with children. Otherwise the relationship is broken and problems occur: 1/ You don't see the orphan fund in the fund list 2/ You cannot edit the orphan fund amount ('Fund amount exceeds parent allocation'). This patch: - adds a JS check, template side - adds a check in the perl script (should never be true) - adds an updatedatabase check, in order to alert users with inconsistent data. Test plan: Verify you are not allow to delete a fund with children. Signed-off-by: jeremie.benarros <jeremie.benarros@inlibro.com> Javascript verification is working, but i got an error when i'm 'hacking' the JS : Undefined subroutine &main::HasChildren called at /inlibro/git/koha-try4jeremie-dev-inlibro/admin/aqbudgets.pl line 234
Created attachment 33474 [details] [review] Bug 12905: funds with children could not be deleted The interface should prevent to delete funds with children. Otherwise the relationship is broken and problems occur: 1/ You don't see the orphan fund in the fund list 2/ You cannot edit the orphan fund amount ('Fund amount exceeds parent allocation'). This patch: - adds a JS check, template side - adds a check in the perl script (should never be true) - adds an updatedatabase check, in order to alert users with inconsistent data. Test plan: Verify you are not allow to delete a fund with children.
(In reply to Jeremie from comment #3) > Javascript verification is working, but i got an error when i'm 'hacking' > the JS : > Undefined subroutine &main::HasChildren called at > /inlibro/git/koha-try4jeremie-dev-inlibro/admin/aqbudgets.pl line 234 Hello Jeremie, Thanks for testing it! Yes, the routine's name is BudgetHasChildren, not HasChildren... Fixed in the last patch, please retest.
Jonathan and Barton, Can you verify that this problem still exists? Without the patch on master, I go through steps 1 through 11, and when I delete the parent, the child fund is deleted as well. There is no longer any sign of the child. Christopher
(In reply to Christopher Brannon from comment #6) > Jonathan and Barton, > Can you verify that this problem still exists? > > Without the patch on master, I go through steps 1 through 11, and when I > delete the parent, the child fund is deleted as well. There is no longer > any sign of the child. > > Christopher Hi Christopher, I tested 2 weeks ago and the problems were there. They are: 1/ You don't see the orphan fund in the fund list 2/ You cannot edit the orphan fund amount ('Fund amount exceeds parent allocation'). for 1/ you need to use the MySQL CLI. Please back to "In discussion" if you confirm that you did not reproduce these 2 problems.
Created attachment 34133 [details] [review] Bug 12905: funds with children could not be deleted On master (head 12123) the problem was still present at my tests. I deleted the parent fund/aqbudget and I still saw the child fund using the MySQL client. In intranet, the child fund was not listed anymore from "Funds" and it could be seen only by this link [X is the budget_id of the aqbudget]: </koha/admin/aqbudgets.pl?op=add_form&budget_id=X> I've applied the patch (head 12123). The patch needed a trivial rebase (on 3.19?). On a parent fund, the "Delete" action: was present in grey, warned "This fund has children." as mouse moved on it; and prevented me from deleting the fund by the message: "This fund has children. It cannot be deleted." when selected. On upgrading the database I saw the check alerting me about my inconsistent data, just as required. Everything seemed OK to me, I pass the patch to "Signed Off" status.
Created attachment 34364 [details] [review] [PASSED QA] Bug 12905: funds with children could not be deleted The interface should prevent to delete funds with children. Otherwise the relationship is broken and problems occur: 1/ You don't see the orphan fund in the fund list 2/ You cannot edit the orphan fund amount ('Fund amount exceeds parent allocation'). This patch: - adds a JS check, template side - adds a check in the perl script (should never be true) - adds an updatedatabase check, in order to alert users with inconsistent data. Test plan: Verify you are not allow to delete a fund with children. Signed-off-by: Paola Rossi <paola.rossi@cineca.it> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Patch pushed to master. Thanks Jonathan!
Pushed to 3.18.x will be in 3.18.4