Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,150 @@
"null",
"boolean"
]
},
{
"default": null,
"name": "interestPaymentWaiver",
"type": [
"null",
"boolean"
]
},
{
"default": null,
"name": "chargeAdjustment",
"type": [
"null",
"boolean"
]
},
{
"default": null,
"name": "chargeoff",
"type": [
"null",
"boolean"
]
},
{
"default": null,
"name": "downPayment",
"type": [
"null",
"boolean"
]
},
{
"default": null,
"name": "reAge",
"type": [
"null",
"boolean"
]
},
{
"default": null,
"name": "reAmortize",
"type": [
"null",
"boolean"
]
},
{
"default": null,
"name": "accrualActivity",
"type": [
"null",
"boolean"
]
},
{
"default": null,
"name": "interestRefund",
"type": [
"null",
"boolean"
]
},
{
"default": null,
"name": "accrualAdjustment",
"type": [
"null",
"boolean"
]
},
{
"default": null,
"name": "capitalizedIncome",
"type": [
"null",
"boolean"
]
},
{
"default": null,
"name": "capitalizedIncomeAmortization",
"type": [
"null",
"boolean"
]
},
{
"default": null,
"name": "capitalizedIncomeAdjustment",
"type": [
"null",
"boolean"
]
},
{
"default": null,
"name": "capitalizedIncomeAmortizationAdjustment",
"type": [
"null",
"boolean"
]
},
{
"default": null,
"name": "contractTermination",
"type": [
"null",
"boolean"
]
},
{
"default": null,
"name": "buyDownFee",
"type": [
"null",
"boolean"
]
},
{
"default": null,
"name": "buyDownFeeAdjustment",
"type": [
"null",
"boolean"
]
},
{
"default": null,
"name": "buyDownFeeAmortization",
"type": [
"null",
"boolean"
]
},
{
"default": null,
"name": "buyDownFeeAmortizationAdjustment",
"type": [
"null",
"boolean"
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "WorkingCapitalLoanTransactionAdjustmentDataV1",
"namespace": "org.apache.fineract.avro.workingcapitalloan.v1",
"type": "record",
"fields": [
{
"default": null,
"name": "transactionToAdjust",
"type": [
"null",
"org.apache.fineract.avro.workingcapitalloan.v1.WorkingCapitalLoanTransactionDataV1"
]
},
{
"default": null,
"name": "newTransactionDetail",
"type": [
"null",
"org.apache.fineract.avro.workingcapitalloan.v1.WorkingCapitalLoanTransactionDataV1"
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
"string"
]
},
{
"default": null,
"name": "currency",
"type": [
"null",
"org.apache.fineract.avro.generic.v1.CurrencyDataV1"
]
},
{
"default": null,
"name": "transactionAmount",
Expand Down Expand Up @@ -123,6 +131,14 @@
"bigdecimal"
]
},
{
"default": null,
"name": "overpaymentPortion",
"type": [
"null",
"bigdecimal"
]
},
{
"default": null,
"name": "chargePaidByList",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ public interface BusinessEventNotifierService {
*/
void notifyPostBusinessEvent(BusinessEvent<?> businessEvent);

boolean isExternalEventPostingEnabled(BusinessEvent<?> businessEvent);

/**
* Answers the same question as {@link #isExternalEventPostingEnabled(BusinessEvent)} without an event instance, for
* callers that need to know whether an event type is worth assembling a payload for.
*/
boolean isExternalEventPostingEnabled(String eventType);

/**
* Method is to register a class as listener for pre-processing of any Business event
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,36 @@ public <T extends BusinessEvent<?>> void addPreBusinessEventListener(Class<T> ev
@Override
public void notifyPostBusinessEvent(BusinessEvent<?> businessEvent) {
throwExceptionIfBulkEvent(businessEvent);
boolean isExternalEvent = !(businessEvent instanceof NoExternalEvent);
List<BusinessEventListener> businessEventListeners = findSuitableListeners(postListeners, businessEvent.getClass());
for (BusinessEventListener eventListener : businessEventListeners) {
eventListener.onBusinessEvent(businessEvent);
}
if (isExternalEvent && isExternalEventPostingEnabled()) {
// we only want to create external events for operations that were successful, hence the post listener
if (externalBusinessEventConfigurationService.isExternalEventConfiguredForPosting(businessEvent)) {
if (isExternalEventRecordingEnabled()) {
recordedEvents.get().add(businessEvent);
// we only want to create external events for operations that were successful, hence the post listener
if (isExternalEventPostingEnabled(businessEvent)) {
if (isExternalEventRecordingEnabled()) {
recordedEvents.get().add(businessEvent);
} else {
if (transactionHelper.hasTransaction()) {
storeTransactionalBusinessEvent(businessEvent);
} else {
if (transactionHelper.hasTransaction()) {
storeTransactionalBusinessEvent(businessEvent);
} else {
externalEventService.postEvent(businessEvent);
}
externalEventService.postEvent(businessEvent);
}
}
}
}

@Override
public boolean isExternalEventPostingEnabled(final BusinessEvent<?> businessEvent) {
return !(businessEvent instanceof NoExternalEvent) && isExternalEventPostingEnabled()
&& externalBusinessEventConfigurationService.isExternalEventConfiguredForPosting(businessEvent);
}

@Override
public boolean isExternalEventPostingEnabled(final String eventType) {
return isExternalEventPostingEnabled()
&& externalBusinessEventConfigurationService.isExternalEventTypeConfiguredForPosting(eventType);
}

private List<BusinessEventListener> findSuitableListeners(Map<Class, List<BusinessEventListener>> listeners, Class<?> eventClazz) {
List<BusinessEventListener> result = new ArrayList<>();
for (Map.Entry<Class, List<BusinessEventListener>> entry : listeners.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
public interface ExternalBusinessEventConfigurationService {

boolean isExternalEventConfiguredForPosting(BusinessEvent<?> businessEvent);

boolean isExternalEventTypeConfiguredForPosting(String eventType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ public boolean isExternalEventConfiguredForPosting(BusinessEvent<?> businessEven
if (businessEvent == null) {
return false;
}
return eventConfigurationRepository.findExternalEventConfigurationByTypeWithNotFoundDetection(businessEvent.getType()).isEnabled();
return isExternalEventTypeConfiguredForPosting(businessEvent.getType());
}

@Override
@Transactional(readOnly = true)
public boolean isExternalEventTypeConfiguredForPosting(final String eventType) {
if (eventType == null) {
return false;
}
return eventConfigurationRepository.findExternalEventConfigurationByTypeWithNotFoundDetection(eventType).isEnabled();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ For a loan that was charged off, the mirrors flip the reclassification instead:

== Business Events

* `WorkingCapitalLoanWrittenOffBusinessEvent` — emitted after a write-off.
* `WorkingCapitalLoanUndoWrittenOffBusinessEvent` — emitted after an undo write-off.
* `WorkingCapitalLoanWriteOffTransactionBusinessEvent` — emitted after a write-off.
* `WorkingCapitalLoanUndoWriteOffTransactionBusinessEvent` — emitted after an undo write-off.
* `WorkingCapitalLoanBalanceChangedBusinessEvent` — emitted by both operations, since the write-off zeroes the
outstanding balance and the undo restores it.
* `WorkingCapitalLoanStatusChangedBusinessEvent` — emitted by both operations, for the transition to
Expand Down
Loading
Loading