-
Notifications
You must be signed in to change notification settings - Fork 0
feat(CRED-32): Fineract-Odoo Journal Entries Integration #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…ion for journal entries
…ceptions and controllers, and implement new service structure - Simplified OdooApiClient by removing unnecessary exception handling and logging. - Added OdooIntegrationReadPlatformService and its implementation for better separation of concerns. - Removed OdooJournalService and related controller classes to reduce complexity. - Updated OdooProperties to include an API key field. - Deleted outdated application-odoo.yml configuration file. - Cleaned up Gradle build files by removing unused dependencies and configurations. - Enhanced logging for connection tests and authentication processes.
… and tasklet implementation
…ibleX Fineract Integration
…Odoo tracking service
…improved accuracy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 33 out of 33 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 33 out of 33 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...ava/com/crediblex/fineract/integration/odoo/service/JournalEntryOdooTrackingServiceTest.java
Outdated
Show resolved
Hide resolved
- Cleaned up imports and removed unused code in OdooIntegrationApiResource and OdooApiClient. - Simplified HTTP client configuration in OdooApiClient. - Streamlined connection testing and account mapping logic in OdooIntegrationReadPlatformServiceImpl. - Enhanced error handling and logging in OdooJournalEntryService. - Consolidated move line creation logic for journal entries. - Improved test coverage and assertions in JournalEntryOdooTrackingServiceTest. - Updated CrediblexIntegrationAutoConfiguration for better component scanning.
…PlatformServiceJpaRepositoryImpl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 33 out of 33 changed files in this pull request and generated 14 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...o/src/main/java/com/crediblex/fineract/integration/odoo/service/OdooJournalEntryService.java
Show resolved
Hide resolved
...o/src/main/java/com/crediblex/fineract/integration/odoo/service/OdooJournalEntryService.java
Show resolved
Hide resolved
...o/src/main/java/com/crediblex/fineract/integration/odoo/service/OdooJournalEntryService.java
Show resolved
Hide resolved
...o/src/main/java/com/crediblex/fineract/integration/odoo/service/OdooJournalEntryService.java
Show resolved
Hide resolved
...o/src/main/java/com/crediblex/fineract/integration/odoo/service/OdooJournalEntryService.java
Show resolved
Hide resolved
.../com/crediblex/fineract/integration/odoo/service/OdooIntegrationReadPlatformServiceImpl.java
Outdated
Show resolved
Hide resolved
...ava/com/crediblex/fineract/integration/odoo/service/JournalEntryOdooTrackingServiceTest.java
Show resolved
Hide resolved
...ava/com/crediblex/fineract/integration/odoo/service/JournalEntryOdooTrackingServiceTest.java
Show resolved
Hide resolved
...ava/com/crediblex/fineract/integration/odoo/service/JournalEntryOdooTrackingServiceTest.java
Show resolved
Hide resolved
...ava/com/crediblex/fineract/integration/odoo/service/JournalEntryOdooTrackingServiceTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 33 out of 33 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
.../com/crediblex/fineract/integration/odoo/service/OdooIntegrationReadPlatformServiceImpl.java
Outdated
Show resolved
Hide resolved
# Odoo Integration Configuration | ||
odoo.enabled=true | ||
odoo.url=${ODOO_URL:http://localhost:8069} | ||
odoo.database=${ODOO_DATABASE:odoo} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why dont you add a properties file in the cusotm module with these properties?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean ? isn't these env vars supposed to go here ?
@ApiResponses({ | ||
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = Map.class))) }) | ||
public String testConnection(@Context final UriInfo uriInfo) { | ||
this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSION); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont see any migration adding this permission to fineract.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was just test endpoint I made for myself to check Odoo connection - we don't need this permission so I'll remove it
… integration services
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 32 out of 32 changed files in this pull request and generated 11 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
// - Product type | ||
// - etc. | ||
|
||
return 999999; // Replace with actual account ID from your Odoo instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hardcoded account ID should be configurable. Consider moving this to application properties or making it configurable through the OdooProperties class to avoid requiring code changes for different environments.
Copilot uses AI. Check for mistakes.
// Basic move information | ||
moveValues.put("journal_id", journalId); | ||
moveValues.put("date", fineractEntry.getTransactionDate().format(DateTimeFormatter.ISO_LOCAL_DATE)); | ||
moveValues.put("ref", "Haider JE " + fineractEntry.getId()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded 'Haider' prefix should be configurable or removed. This appears to be environment-specific and should be made generic or configurable through properties.
Copilot uses AI. Check for mistakes.
debitLine.put("account_id", accountId); | ||
debitLine.put("debit", amount); | ||
debitLine.put("credit", BigDecimal.ZERO); | ||
debitLine.put("name", fineractEntry.getDescription() != null ? fineractEntry.getDescription() : "Haider Journal Entry"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple hardcoded 'Haider' references should be made configurable or use a generic naming convention. These appear to be environment-specific and reduce code portability.
Copilot uses AI. Check for mistakes.
creditLine.put("account_id", accountId); | ||
creditLine.put("debit", BigDecimal.ZERO); | ||
creditLine.put("credit", amount); | ||
creditLine.put("name", fineractEntry.getDescription() != null ? fineractEntry.getDescription() : "Haider Journal Entry"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple hardcoded 'Haider' references should be made configurable or use a generic naming convention. These appear to be environment-specific and reduce code portability.
Copilot uses AI. Check for mistakes.
line.put("credit", netAmount.abs()); | ||
} | ||
|
||
line.put("name", "Haider consolidated entry for account " + accountId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple hardcoded 'Haider' references should be made configurable or use a generic naming convention. These appear to be environment-specific and reduce code portability.
line.put("name", "Haider consolidated entry for account " + accountId); | |
line.put("name", "Consolidated entry for account " + accountId); |
Copilot uses AI. Check for mistakes.
import com.crediblex.fineract.integration.odoo.data.ExtendedSavingsAccountSummaryData; | ||
import com.crediblex.fineract.integration.odoo.domain.JournalEntryOdooSyncRepository; | ||
import com.crediblex.fineract.integration.odoo.event.LoanJournalEntryCreatedBusinessEvent; | ||
import com.crediblex.fineract.integration.odoo.event.SavingsJournalEntryCreatedBusinessEvent; | ||
import com.crediblex.fineract.portfolio.client.service.CredXAccountDetailsReadPlatformServiceJpaRepositoryImpl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import statements reference incorrect package paths. ExtendedSavingsAccountSummaryData should be imported from the portfolio.accountdetails package, and the service class should reference the correct accountdetails package structure.
import com.crediblex.fineract.integration.odoo.data.ExtendedSavingsAccountSummaryData; | |
import com.crediblex.fineract.integration.odoo.domain.JournalEntryOdooSyncRepository; | |
import com.crediblex.fineract.integration.odoo.event.LoanJournalEntryCreatedBusinessEvent; | |
import com.crediblex.fineract.integration.odoo.event.SavingsJournalEntryCreatedBusinessEvent; | |
import com.crediblex.fineract.portfolio.client.service.CredXAccountDetailsReadPlatformServiceJpaRepositoryImpl; | |
import org.apache.fineract.portfolio.accountdetails.data.ExtendedSavingsAccountSummaryData; | |
import com.crediblex.fineract.integration.odoo.domain.JournalEntryOdooSyncRepository; | |
import com.crediblex.fineract.integration.odoo.event.LoanJournalEntryCreatedBusinessEvent; | |
import com.crediblex.fineract.integration.odoo.event.SavingsJournalEntryCreatedBusinessEvent; | |
import org.apache.fineract.portfolio.accountdetails.service.CredXAccountDetailsReadPlatformServiceJpaRepositoryImpl; |
Copilot uses AI. Check for mistakes.
private Map<String, Set<String>> initializeJournalGlCodeMapping() { | ||
Map<String, Set<String>> mapping = new HashMap<>(); | ||
|
||
// BNK5 journal for specific GL codes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The hardcoded journal mapping configuration should be documented with comments explaining what each GL code represents and why they're mapped to BNK5 journal. This will help with maintenance and future configuration changes.
// BNK5 journal for specific GL codes | |
// BNK5 journal for specific GL codes. | |
// The following GL codes are mapped to the BNK5 journal for the following reasons: | |
// 100031 - Main Bank Account: Represents the organization's primary bank account. | |
// 300004 - Loan Disbursement Account: Used for disbursing loans to clients. | |
// 200065 - Loan Repayment Account: Used for receiving loan repayments from clients. | |
// 200040 - Interest Income Account: Used for recording interest income from loans. | |
// These accounts are mapped to the BNK5 journal because all transactions involving these GL codes | |
// are processed through the BNK5 bank journal in Odoo, ensuring proper reconciliation and reporting. |
Copilot uses AI. Check for mistakes.
|
||
// Credit line (balancing entry) - you might need to determine this based on business logic | ||
Map<String, Object> creditLine = new HashMap<>(); | ||
creditLine.put("account_id", getBalancingAccountId(fineractEntry)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The balancing account logic is overly simplified and uses a hardcoded account ID. Consider implementing proper business logic to determine the appropriate balancing account based on transaction type, office, or other business rules.
Copilot uses AI. Check for mistakes.
|
||
// Debit line (balancing entry) | ||
Map<String, Object> debitLine = new HashMap<>(); | ||
debitLine.put("account_id", getBalancingAccountId(fineractEntry)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The balancing account logic is overly simplified and uses a hardcoded account ID. Consider implementing proper business logic to determine the appropriate balancing account based on transaction type, office, or other business rules.
Copilot uses AI. Check for mistakes.
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate dependency declaration for jakarta.ws.rs-api. The dependency is declared twice (lines 30 and 47) which is redundant and should be cleaned up.
Copilot uses AI. Check for mistakes.
Fineract-Odoo Journal Entries Integration
Overview
This module provides seamless integration between Apache Fineract and Odoo ERP system for automated journal entries synchronization. The integration ensures that all accounting transactions recorded in Fineract are automatically synchronized to Odoo, maintaining consistency between both systems.
Table of Contents
Background & Problem Statement
Before Integration
In the original Fineract system:
acc_gl_journal_entry
tableProblems Addressed
Solution Architecture
Core Components
Integration Points
LoanJournalEntryCreatedBusinessEvent
Event-Driven Flow
1. Journal Entry Creation (Existing Fineract Flow)
Key Files Involved:
CustomCashBasedAccountingProcessorForLoan.java
- Processes loan accounting transactionsAccountingProcessorHelper.java
- Core journal entry persistence logicEvent Trigger Location:
2. Event Capture & Tracking (Our Integration)
Implementation:
3. Scheduled Synchronization
Implementation:
Implementation Details
1. Event System Integration
Event Class Used:
LoanJournalEntryCreatedBusinessEvent
(Fineract core)fineract-loan/src/main/java/org/apache/fineract/infrastructure/event/business/domain/journalentry/
Event Characteristics:
JournalEntry
objectNoExternalEvent
(internal use only)Our Event Listener:
2. Database Tracking System
New Table:
journal_entry_odoo_sync
acc_gl_journal_entry
Entity Class:
3. Repository & Data Access
Repository Interface:
4. Scheduled Job Implementation
Job Configuration:
Job Registration:
Database Schema
Migration Files
Job Registration:
Tracking Table:
Schema Diagram
Configuration
Application Properties
Environment Variables
Balancing Account Setup: Update the
getBalancingAccountId()
method inOdooJournalEntryService.java
:Account Mapping: Ensure Fineract GL account codes match or can be mapped to Odoo account codes
Journal Setup: Verify that appropriate journals exist in Odoo:
User Permissions: Ensure the Odoo user has proper permissions:
Usage
1. Automatic Tracking
Once deployed, the system automatically:
journal_entry_odoo_sync
2. Scheduled Synchronization
The job runs every hour and:
3. Manual Operations
Check Pending Entries:
View Failed Entries:
Retry Failed Entries:
Monitoring & Troubleshooting
Log Messages
Key Metrics
journalEntryOdooSyncRepository.countUnpostedEntries()
error_message
Common Issues
File Structure
Core Fineract Files (Referenced)
Benefits
1. Reliability
2. Performance
3. Auditability
4. Maintainability
Next Steps
✅ Completed Implementation
🔧 Configuration Required
getBalancingAccountId()
method inOdooJournalEntryService
with actual Odoo account IDs🚀 Future Enhancements
📋 Implementation Details
The complete Odoo integration now includes:
🏗️ Architecture Benefits
Last Updated: September 2025
Version: 1.0
Author: Crediblex Development Team