Piotr Wargulak created FINERACT-3008:
----------------------------------------

             Summary: Deleting a Working Capital loan application fails when a 
datatable row exists for it
                 Key: FINERACT-3008
                 URL: https://issues.apache.org/jira/browse/FINERACT-3008
             Project: Apache Fineract
          Issue Type: Bug
            Reporter: Piotr Wargulak
            Assignee: Piotr Wargulak


{{WorkingCapitalLoanApplicationWritePlatformServiceImpl#deleteApplication}} 
(:155) deletes the application's notes and its projected amortization model, 
then the loan, but not the rows of datatables registered on {{{}m_wc_loan{}}}. 
A datatable has a foreign key to {{{}m_wc_loan{}}}, so once any of its rows 
exists for the application, the delete fails:
{code:java}
DELETE /working-capital-loans/<loanId>
-> 403 error.msg.data.integrity.issue
{code}
The same happens by external id and through the batch API. When the datatable 
is mandatory through an entity datatable check, the row cannot be deleted first 
either, so such an application can never be deleted.

Steps to reproduce:
 # Register a datatable on {{m_wc_loan}} ({{{}POST /datatables{}}}, 
{{{}apptableName: m_wc_loan{}}}, one column).
 # Create a Working Capital loan application and add a row to the datatable for 
it.
 # {{DELETE /working-capital-loans/<loanId>}} -> 403 data integrity issue. The 
application stays.

Expected: the application is deleted together with its datatable rows, as with 
its notes.

Proposed fix: before deleting the loan, delete the rows of every datatable 
registered on {{m_wc_loan}} for that loan id (the registered tables are in 
{{{}x_registered_table{}}}; {{DatatableWriteService#deleteDatatableEntries}} 
deletes them by application-table id).



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to