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> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
parent
74640683f0
commit
522e9c5861
3 changed files with 38 additions and 1 deletions
|
@ -231,6 +231,10 @@ if ($op eq 'add_form') {
|
||||||
# END $OP eq DELETE_CONFIRM
|
# END $OP eq DELETE_CONFIRM
|
||||||
# called by delete_confirm, used to effectively confirm deletion of data in DB
|
# called by delete_confirm, used to effectively confirm deletion of data in DB
|
||||||
} elsif ( $op eq 'delete_confirmed' ) {
|
} elsif ( $op eq 'delete_confirmed' ) {
|
||||||
|
if ( BudgetHasChildren( $budget_id ) ) {
|
||||||
|
# We should never be here, the interface does not provide this action.
|
||||||
|
die("Delete a fund with children is not possible");
|
||||||
|
}
|
||||||
my $rc = DelBudget($budget_id);
|
my $rc = DelBudget($budget_id);
|
||||||
$op = 'list';
|
$op = 'list';
|
||||||
} elsif( $op eq 'add_validate' ) {
|
} elsif( $op eq 'add_validate' ) {
|
||||||
|
@ -330,6 +334,8 @@ if ( $op eq 'list' ) {
|
||||||
@budget_hierarchy = reverse(@budget_hierarchy);
|
@budget_hierarchy = reverse(@budget_hierarchy);
|
||||||
|
|
||||||
$budget->{budget_hierarchy} = \@budget_hierarchy;
|
$budget->{budget_hierarchy} = \@budget_hierarchy;
|
||||||
|
|
||||||
|
$budget->{budget_has_children} = BudgetHasChildren( $budget->{budget_id} );
|
||||||
}
|
}
|
||||||
|
|
||||||
my $budget_period_total = $period->{budget_period_total};
|
my $budget_period_total = $period->{budget_period_total};
|
||||||
|
|
|
@ -9669,6 +9669,28 @@ if ( CheckVersion($DBversion) ) {
|
||||||
SetVersion ($DBversion);
|
SetVersion ($DBversion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$DBversion = "3.18.00.001";
|
||||||
|
if ( CheckVersion($DBversion) ) {
|
||||||
|
my $orphan_budgets = $dbh->selectall_arrayref(q|
|
||||||
|
SELECT budget_id, budget_name, budget_code
|
||||||
|
FROM aqbudgets
|
||||||
|
WHERE budget_parent_id IS NOT NULL
|
||||||
|
AND budget_parent_id NOT IN (
|
||||||
|
SELECT DISTINCT budget_id FROM aqbudgets
|
||||||
|
)
|
||||||
|
|, { Slice => {} } );
|
||||||
|
|
||||||
|
if ( @$orphan_budgets ) {
|
||||||
|
for my $b ( @$orphan_budgets ) {
|
||||||
|
print "Fund $b->{budget_name} (code:$b->{budget_code}, id:$b->{budget_id}) does not have a parent, it may cause problem\n";
|
||||||
|
}
|
||||||
|
print "Upgrade to $DBversion done (Bug 12905: Check budget integrity: FAIL)\n";
|
||||||
|
} else {
|
||||||
|
print "Upgrade to $DBversion done (Bug 12905: Check budget integrity: OK)\n";
|
||||||
|
}
|
||||||
|
SetVersion($DBversion);
|
||||||
|
}
|
||||||
|
|
||||||
=head1 FUNCTIONS
|
=head1 FUNCTIONS
|
||||||
|
|
||||||
=head2 TableExists($table)
|
=head2 TableExists($table)
|
||||||
|
|
|
@ -225,6 +225,11 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
|
||||||
$("#filterbutton").click(function() {
|
$("#filterbutton").click(function() {
|
||||||
$("#fundfilters").slideToggle(0);
|
$("#fundfilters").slideToggle(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".deletefund-disabled").on("click", function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
alert("This fund has children. It cannot be deleted.");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
//]]>
|
//]]>
|
||||||
</script>
|
</script>
|
||||||
|
@ -398,7 +403,11 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id %]_[% budget.budget_period_id %]">
|
<ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id %]_[% budget.budget_period_id %]">
|
||||||
<li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&budget_id=[% budget.budget_id %]&budget_period_id=[% budget.budget_period_id %]" >Edit</a></li>
|
<li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&budget_id=[% budget.budget_id %]&budget_period_id=[% budget.budget_period_id %]" >Edit</a></li>
|
||||||
<li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=delete_confirm&budget_id=[% budget.budget_id %]&budget_period_id=[% budget.budget_period_id %]">Delete</a></li>
|
[% IF budget.budget_has_children %]
|
||||||
|
<li class="disabled"><a href="#" class="deletefund-disabled" data-toggle="tooltip" data-placement="left" title="This fund has children">Delete</a></li>
|
||||||
|
[% ELSE %]
|
||||||
|
<li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=delete_confirm&budget_id=[% budget.budget_id %]&budget_period_id=[% budget.budget_period_id %]">Delete</a></li>
|
||||||
|
[% END %]
|
||||||
<li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&budget_parent_id=[% budget.budget_id %]&budget_period_id=[% budget.budget_period_id %]">Add child fund</a></li>
|
<li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&budget_parent_id=[% budget.budget_id %]&budget_period_id=[% budget.budget_period_id %]">Add child fund</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue