[ 
https://issues.apache.org/jira/browse/FINERACT-2653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18090453#comment-18090453
 ] 

Farooq Ayoade commented on FINERACT-2653:
-----------------------------------------

PR: https://github.com/apache/fineract/pull/6011

> DELETE /provisioningcategory/{id} fails with "The parameter categoryname is 
> mandatory" and never deletes the category
> ---------------------------------------------------------------------------------------------------------------------
>
>                 Key: FINERACT-2653
>                 URL: https://issues.apache.org/jira/browse/FINERACT-2653
>             Project: Apache Fineract
>          Issue Type: Bug
>          Components: Accounting
>            Reporter: Farooq Ayoade
>            Priority: Minor
>
> h3. Observed behavior
> Deleting a loan-loss provisioning category always returns HTTP 400, 
> regardless of input:
> The parameter `categoryname` is mandatory.
>  
> The category is never deleted.
> h3. Expected behavior
>  * Deleting an unused category succeeds.
>  * Deleting a category referenced by a loan product returns the proper domain 
> error 
> ({{{}error.msg.provisioningcategory.cannot.be.deleted.it.is.already.used.in.loanproduct{}}}
>  — "This provisioning category cannot be deleted; it is already used in a 
> loan product"), *not* the misleading {{categoryname}} validation error.
>  * Deleting a non-existent ID returns *404 Not Found* 
> ({{{}ProvisioningCategoryNotFoundException{}}}).
> h3. Steps to reproduce
>  # Create a category: {{POST /fineract-provider/api/v1/provisioningcategory}} 
> with body {{{}{"categoryname":"Test","description":"x"}{}}}.
>  # Delete it: {{DELETE 
> /fineract-provider/api/v1/provisioningcategory/\{categoryId}}} (no body).
>  # Observe HTTP 400: {{{}The parameter \{}}}categoryname` is mandatory.` The 
> row remains in the database.
> h3. Root cause
> {{{}ProvisioningCategoryWritePlatformServiceJpaRepositoryImpl.deleteProvisioningCateogry(JsonCommand){}}}:
>  
>  
> public CommandProcessingResult deleteProvisioningCateogry(JsonCommand 
> command) {
>     this.fromApiJsonDeserializer.validateForCreate(command.json());           
>        // BUG 1
>     final ProvisioningCategory provisioningCategory = 
> ProvisioningCategory.fromJson(command); // BUG 2
>     boolean isProvisioningCategoryInUse =
>         
> isAnyLoanProductsAssociateWithThisProvisioningCategory(provisioningCategory.getId());
>     ...
>     this.provisioningCategoryRepository.delete(provisioningCategory);
>     return new 
> CommandProcessingResultBuilder().withEntityId(provisioningCategory.getId()).build();
> }
> {{}}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to