Repository navigation
Conversation
AccountingRuleApiResource binds the create/update body to AccountRuleRequest and re-serializes it before validation. The record only declared name, officeId, accountToDebit, accountToCredit and description, so creditTags, debitTags, allowMultipleCreditEntries and allowMultipleDebitEntries were dropped during binding. Tag-based rules therefore always failed with "accountToCredit or creditTags required" and the multiple-entry flags were ignored on update. Add the four fields to the record. Null components are omitted by the command serializer, so account-based requests produce the same command JSON as before. Assisted-By: claude-opus-5-5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
JIRA: https://issues.apache.org/jira/browse/FINERACT-2890
AccountingRuleApiResource#createAccountingRule/#updateAccountingRulebind the request body toAccountRuleRequestand re-serialize it beforeAccountingRuleCommandFromApiJsonDeserializervalidates it. The record only declaredname,officeId,accountToDebit,accountToCreditanddescription, socreditTags,debitTags,allowMultipleCreditEntriesandallowMultipleDebitEntrieswere dropped during binding. As a result, a tag-based rule always failed withvalidation.msg.accountToCredit.or.creditTags.required/validation.msg.accountToDebit.or.debitTags.required, and the multiple-entry flags were ignored on update.This change adds the four fields to the record. The command serializer omits null components, so account-based requests produce the same command JSON as before, and update keeps its "parameter present" semantics.
Tests
AccountRuleRequestSerializationTest(fineract-accounting) round-trips the record throughExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGsoninto the real create/update validators. It covers a tag-based request (tags and flags kept, validation passes), an account-based request (unchanged JSON, validation passes) and a request with neither (still rejected). 3/3 pass;spotlessJavaCheckpasses.4684c66380), two newAssetAccountTagscode values as tags:AccountRuleRequest):POST /v1/accountingrules{"name":"r1","officeId":1,"creditTags":[<a>],"debitTags":[<b>],"allowMultipleCreditEntries":true,"allowMultipleDebitEntries":true}→ 400 withvalidation.msg.accountToCredit.or.creditTags.requiredandvalidation.msg.accountToDebit.or.debitTags.required. An account-based rule → 200.GET /v1/accountingrules/{id}returns both tags andallowMultiple*Entries: true;PUTswapping the tags withallowMultiple*Entries: false→ 200 with all four inchanges, and a re-GETshows them applied; an account-based rule still → 200.API
No new endpoint. The
POST/PUT /v1/accountingrulesrequest schema (generated from the record via@Schema(implementation = AccountRuleRequest.class)) now also listscreditTags,debitTags,allowMultipleCreditEntriesandallowMultipleDebitEntries, which the validator already accepted.Checklist
Your assigned reviewer(s) will follow our guidelines for code reviews.