This is an automated email from the ASF dual-hosted git repository.
mridulpathak pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push:
new d58c46138e Fixed: updateBudgetStatus silent success on invalid status
transitions (OFBIZ-13558)
d58c46138e is described below
commit d58c46138e9cfa743ba148331df90046fddbb46d
Author: Mridul Pathak <[email protected]>
AuthorDate: Thu Sep 10 22:19:50 2026 +0530
Fixed: updateBudgetStatus silent success on invalid status transitions
(OFBIZ-13558)
Validate status transitions against StatusValidChange and return an error
on invalid transitions instead of silently succeeding.
---
.../ofbiz/accounting/budget/BudgetServices.groovy | 23 ++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git
a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/budget/BudgetServices.groovy
b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/budget/BudgetServices.groovy
index 9726ed6785..22e56f4b57 100644
---
a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/budget/BudgetServices.groovy
+++
b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/budget/BudgetServices.groovy
@@ -22,13 +22,24 @@ import org.apache.ofbiz.entity.GenericValue
Map updateBudgetStatus() {
Map result = success()
- List budgetStatuses = from('BudgetStatus').where([budgetId:
parameters.budgetId]).orderBy('-statusDate').queryList()
- GenericValue statusValidChange = null
+ List budgetStatuses = from('BudgetStatus')
+ .where(budgetId: parameters.budgetId)
+ .orderBy('-statusDate')
+ .queryList()
if (budgetStatuses) {
- budgetStatus = budgetStatuses[0]
- statusValidChange = from('StatusValidChange').where([statusId:
budgetStatus.statusId, statusIdTo: parameters.statusId]).queryOne()
- }
- if (! budgetStatuses || budgetStatuses && statusValidChange) {
+ GenericValue budgetStatus = budgetStatuses[0]
+ if (budgetStatus.statusId != parameters.statusId) {
+ GenericValue statusValidChange = from('StatusValidChange')
+ .where(statusId: budgetStatus.statusId, statusIdTo:
parameters.statusId)
+ .cache()
+ .queryOne()
+ if (!statusValidChange) {
+ return error(label('CommonUiLabels',
'CommonErrorNoStatusValidChange',
+ [lookedUpValue: [statusId: budgetStatus.statusId]]))
+ }
+ result = run service: 'createBudgetStatus', with: parameters
+ }
+ } else {
result = run service: 'createBudgetStatus', with: parameters
}
return result