etendosoftware / etendo_core

Etendo Classic source code
10 stars 11 forks source link

EPL-1452: Unposting record having docbase type with no facct results in wrong error #369

Closed RubenEtendo closed 4 months ago

RubenEtendo 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

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

Core - Latest

Version number: 24.1.3

Solution Design

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. 1f426ec6-4141-4dac-98c6-c92faca7a033

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

Automatic Tests

Create automatic tests for this issue. The tests will consist of the following scenarios:

  1. Post a register that has no Document Type. Expect failure
  2. Unpost a register that has no Document Type. Expect failure