[
https://issues.apache.org/jira/browse/FINERACT-2890?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Adam Saghy updated FINERACT-2890:
---------------------------------
Fix Version/s: 1.16.0
> Create Accounting Rules with list of accounts
> ---------------------------------------------
>
> Key: FINERACT-2890
> URL: https://issues.apache.org/jira/browse/FINERACT-2890
> Project: Apache Fineract
> Issue Type: Bug
> Components: Accounting
> Reporter: Foo Developer
> Assignee: Foo Developer
> Priority: Major
> Labels: Beginner, beginner-friendly
> Fix For: 1.16.0
>
>
> Summary
> Creating or updating an Accounting Rule using tag-based debit/credit accounts
> (creditTags / debitTags) always fails with a 400 Bad Request validation
> error, even when the request payload is valid and contains existing tag IDs
> retrieved from GET /v1/accountingrules/template.
> The issue affects both create and update Accounting Rule APIs because the
> tag-based fields are removed during request binding before validation is
> performed.
> Steps to Reproduce
> Call:
> GET /v1/accountingrules/template
> Retrieve valid IDs from:
> allowedCreditTagOptions
> allowedDebitTagOptions
> Example:
> 22 → Cash
> 23 → Bank
> Create an Accounting Rule using tags:
> {
> "name": "Compound Cash-Bank Rule",
> "officeId": 1,
> "creditTags": [22, 23],
> "debitTags": [24, 205],
> "allowMultipleCreditEntries": true,
> "allowMultipleDebitEntries": true,
> "description": "test compound rule"
> }
> Actual Result
> The API returns:
> 400 Bad Request
> with validation errors:
> "The parameter accountToCredit or creditTags required"
> "The parameter accountToDebit or debitTags required"
> Server-side request logging confirms that the incoming JSON payload contains
> creditTags and debitTags correctly. However, these fields are missing before
> validation is executed.
> Expected Result
> The Accounting Rule should be created or updated successfully using the
> provided debit and credit tags, in the same way that rules using
> accountToDebit and accountToCredit currently work.
> Root Cause
> The issue is caused by AccountRuleRequest:
> fineract-accounting/src/main/java/org/apache/fineract/accounting/rule/data/request/AccountRuleRequest.java
> This class is the request DTO used by JAX-RS to bind the request body in:
> AccountingRuleApiResource#createAccountingRule
> AccountingRuleApiResource#updateAccountingRule
> The DTO only contains:
> name
> officeId
> accountToDebit
> accountToCredit
> description
> but does not define:
> creditTags
> debitTags
> allowMultipleCreditEntries
> allowMultipleDebitEntries
> During request processing, the bound AccountRuleRequest object is
> re-serialized:
> apiJsonSerializerService.serialize(accountRuleRequest)
> and the generated JSON is passed to:
> AccountingRuleCommandFromApiJsonDeserializer
> for validation.
> Since the missing fields are not part of the DTO, they are discarded during
> deserialization and never appear in the serialized command JSON. As a result,
> validation always receives null values for creditTags and debitTags, causing
> the request to fail even though the client sent valid data.
> Impact
> Tag-based Accounting Rules cannot currently be created or updated through the
> REST API.
> Verification on the development tenant showed that all existing Accounting
> Rules use:
> accountToDebit
> accountToCredit
> and no rules currently use creditTags or debitTags, confirming that tag-based
> rules have not been functional through the API.
> Required Fix
> Update AccountRuleRequest to support all Accounting Rule fields, including:
> creditTags
> debitTags
> allowMultipleCreditEntries
> allowMultipleDebitEntries
> Ensure these fields are preserved during request binding and re-serialization
> so that AccountingRuleCommandFromApiJsonDeserializer can validate and process
> tag-based Accounting Rules correctly.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)