Bug 37096 - Required fields in budget creation are ignored if left blank
Summary: Required fields in budget creation are ignored if left blank
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: 23.11
Hardware: All All
: P5 - low minor
Assignee: Sam Lau
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-14 15:40 UTC by Esther Melander
Modified: 2024-10-29 22:20 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 37096: Display error message for budget creation/modification if start/end date is left blank (5.76 KB, patch)
2024-07-30 16:51 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 37096: Display error message for budget creation/modification if start/end date is left blank (5.81 KB, patch)
2024-07-30 18:24 UTC, Roman Dolny
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Esther Melander 2024-06-14 15:40:25 UTC
To Replicate

1. In Acquisitions, Budgets, add a new budget.
2. Fill in the Start date, Description, Total Amount, and make active. Leave the end date BLANK.
3. Save.

See that the user is returned to the budget listing page but the budget creation silently fails. The behavior is repeated if both the start date and end date are blank. A save failure error message does appear if the description is left blank.

I would expect a save fail error message if either the start or end date was blank.
Comment 1 Sam Lau 2024-07-30 16:51:11 UTC
Created attachment 169869 [details] [review]
Bug 37096: Display error message for budget creation/modification if start/end date is left blank

This patch adds an error message for a failed budget creation or modifcation due to the dates being empty.

To test:
1) Go to the acquisitions tab, then on the side under 'Administration' select the 'Budgets' tab.
2) Click 'New budget', enter only a description and press save.
3) Note that the budget was not created, but no messages were displayed.
4) Apply patch, restart_all
5) Once again select 'New budget' and enter only a description.
6) This time when submitting, you will see an error message that says the process failed.
7) Edit an exisitng budget and remove the start date from this budget.
8) Attempt to save and note that the error message displays properly.
Comment 2 Roman Dolny 2024-07-30 18:24:19 UTC
Created attachment 169873 [details] [review]
Bug 37096: Display error message for budget creation/modification if start/end date is left blank

This patch adds an error message for a failed budget creation or modifcation due to the dates being empty.

To test:
1) Go to the acquisitions tab, then on the side under 'Administration' select the 'Budgets' tab.
2) Click 'New budget', enter only a description and press save.
3) Note that the budget was not created, but no messages were displayed.
4) Apply patch, restart_all
5) Once again select 'New budget' and enter only a description.
6) This time when submitting, you will see an error message that says the process failed.
7) Edit an exisitng budget and remove the start date from this budget.
8) Attempt to save and note that the error message displays properly.

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Comment 3 Roman Dolny 2024-07-30 18:24:53 UTC
This works as described, but shouldn't we prevent the form from being saved until all required fields are filled in?
Comment 4 Sam Lau 2024-07-30 18:43:17 UTC
(In reply to Roman Dolny from comment #3)
> This works as described, but shouldn't we prevent the form from being saved
> until all required fields are filled in?

Validating flatpickr values isn't the easiest thing to do. I couldn't find a way to make both of them required before submission while still utilizing jquery validation, so this solution was the next best thing for now