FINERACT-1932: Fineract modularization#5562
FINERACT-1932: Fineract modularization#5562nidhiii128 wants to merge 1 commit intoapache:developfrom
Conversation
156e5f7 to
42eb73f
Compare
| lastnameChanged = true; | ||
| } | ||
|
|
||
| // Fixed: Combined the flags you created above |
There was a problem hiding this comment.
I feel such comments should be avoided.
| "Staff with externalId `" + externalId + "` already exists", "externalId", externalId); | ||
| } else if (realCause.getMessage().contains("display_name")) { | ||
| final String lastname = command.stringValueOfParameterNamed("lastname"); | ||
| // FIX: Use 'request' getters, not 'command' |
There was a problem hiding this comment.
This comments belongs to PR description, we should keep code clean.
IOhacker
left a comment
There was a problem hiding this comment.
@nidhiii128 I think the Fineract modularization has another approach. This looks to me to be a Refactor of the Staff. Please check how other modules have been executed. I suggest to have a conversation about this change in the Apache Fineract developer list.
|
@nidhiii128 please work on this jira ticket, I am unable to assign this to you, but please pick it: https://issues.apache.org/jira/browse/FINERACT-2515 |
Hi @IOhacker, I saw the updates to the ticket. I actually started working on the refactor the moment you posted the task, focusing on the 'bad practice' note regarding the PortfolioAccountType methods. I have just submitted a Pull Request that addresses exactly what was discussed: I've removed the redundant isSavingsAccount() and isLoanAccount() methods from the Enum and updated all callers across the provider and core modules to use direct enum comparisons. The build is passing locally after a fresh rebase against develop. Looking forward to your feedback! PR Link: #5563 |
| return new Staff(staffOffice, firstname, lastname, externalId, mobileNo, isLoanOfficer, isActive, joiningDate); | ||
| } | ||
|
|
||
| public static Staff fromRequest(final Office staffOffice, final StaffRequest request) { |
There was a problem hiding this comment.
This is more a comment to us as a community and less for you @nidhiii128 ... we have functions like this all over the place, but I have some doubts about the usefulness of them in general. I don't see where this is actually used and/or where it would be useful. Do we really optimize here anything? Isn't it just easier to return the whole updated object if we really have to (I wouldn't... if the client needs that information really from the backend then it should just call the "read" endpoint). The client initiates the change... if a http 200 is received then it "knows" that the changes are ok, if 4xx or 5xx then the updates didn't succeed... all needed information is already available on the client side.
But let's assume this is really necessary and I'm missing something essential here... then I would really urge to use a library that does diffing way better than any of our handwritten (boilerplate) code: https://javers.org
There was a problem hiding this comment.
Hi @vidakovic , I completely agree with your point. The manual boilerplate we have for these updates is definitely not ideal and makes the code harder to maintain. Using a library like Javers would be a much cleaner and more professional way to handle object diffing across Fineract. I've followed the current fromRequest pattern here just to stay consistent with the existing modules for now, but I'm definitely in favor of the community moving toward a better solution like the one you suggested.
There was a problem hiding this comment.
All good @nidhiii128 your approach makes sense to get this PR approved; introducing new libs/dependencies "on the fly" without at least a Jira ticket usually doesn't get a PR approved. Will start the build so that we can see where we are with this.
42eb73f to
c69d38b
Compare
|
c69d38b to
079e581
Compare
hi @adamsaghy, All local Checkstyle and compilation tasks are now passing. |
Description
This PR modernizes the Staff API by replacing manual JSON Map parsing with a structured StaffRequest DTO and migrating date handling from the deprecated java.util.Date to the modern java.time.LocalDate.
Key Changes
Architectural Refactor: Moved StaffRequest from fineract-provider to fineract-core to allow for better separation of concerns and reuse across modules.
Type Safety: Replaced Map<String, Object> in StaffWritePlatformService with the StaffRequest DTO, enabling compile-time checks and reducing runtime errors.
Modern Date Handling: Updated the Staff entity, commands, and validators to use java.time.LocalDate, aligning with the project's goal to eliminate legacy date objects.
Command Handling: Refactored CreateStaffCommandHandler and StaffCommandFromApiJsonDeserializer to leverage the new DTO structure.
Test Alignment: Updated StaffTest.java and related integration tests (including Feign client tests) to ensure compatibility with the new API structure.
Impact
Improves code readability and maintainability.
Simplifies the validation logic by using DTO-based constraints.
Ensures consistent date/time behavior across different database engines (MariaDB/PostgreSQL).
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
Your assigned reviewer(s) will follow our guidelines for code reviews.