etendosoftware / etendo_core

Etendo Classic source code
10 stars 11 forks source link

EE-919: Unposting record having docbase type with no facct results in wrong error #375

Closed juanfunes1996 closed 4 months ago

juanfunes1996 commented 4 months ago

Error's description

When attempting to unpost a record and remove its accounting data, the process consistently throws the error 'No Document Type for this register'. This issue occurs during execution of tests for the modules 'com.etendoerp.bulk.posting' and 'com.etendoerp.payment.removal'.

Steps to reproduce the error

Required Configurations (if necessary)

Run any one of the ‘com.etendoerp.bulk.posting’ tests Run any one of the ‘com.etendoerp.payment.removal’ tests

Important: Not only this bug is being reproduced locally in my computer, but also on the Jenkins pipeline that runs bundles tests, executed automatically after any bundle release.

The steps to reproduce this bug are:

Set up and build an Etendo core environment, in the 24.1.0 version

Install the com.etendoerp.bulk.posting and com.etendoerp.payment.removal modules into the environment

For the com.etendoerp.paymentremoval module, the com.etendoerp.payment.removal.template module must be installed as well

Fully compile the environment

Run both modules tests. To do so, execute the following commands in the environment’s root directory ./gradlew test --tests "com.etendoerp.bulk.posting." --info ,/gradlew test --tests "com.etendoerp.payment.removal." --info

Both tests execution should yield assertion failures. Every test executed should fail because of the @NoDocTypeForDocument@ error being thrown.

Expected behavior

The tests should pass.

The unposting process should successfully remove accounting data without the error, especially when the necessary document type is present or not required for the operation.

Affected Version

¿ Latest/Specific ? Core - Latest Version number: 24.1.3

Solution Design (optional)

The function validateOpenPeriodsForDocBaseType lacks a check for when the variable docBaseTypesWithoutFacctAcct is empty. This oversight leads to the function always triggering the NoDocTypeForDocument exception, regardless of whether there is actually a missing document type. The proposed solution involves adding a condition to bypass the exception when docBaseTypesWithoutFacctAcct is empty.

(See attachment)

Also, move the check up for it to be a proper early-return condition

Other test cases

Given: When: Then: