modifiche per registrazione movimenti contabili
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
package it.integry.ems.migration.model;
|
||||||
|
|
||||||
|
import it.integry.ems.migration._base.BaseMigration;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20250519153211 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isDMS()) return;
|
||||||
|
|
||||||
|
updateSetupValue("DATI_AZIENDA","MENU_GENERALE","LOAD_MENU_FROM_DB", "S");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,6 +44,7 @@ public class CtbPart extends EntityBase {
|
|||||||
@SqlField(value = "num_doc", nullable = false)
|
@SqlField(value = "num_doc", nullable = false)
|
||||||
private Integer numDoc;
|
private Integer numDoc;
|
||||||
|
|
||||||
|
@ImportFromParent (value = "data_doc")
|
||||||
@SqlField(value = "data_doc")
|
@SqlField(value = "data_doc")
|
||||||
private Date dataDoc;
|
private Date dataDoc;
|
||||||
|
|
||||||
|
|||||||
@@ -265,6 +265,16 @@ then
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
rule "insertNewPartita"
|
||||||
|
no-loop
|
||||||
|
when
|
||||||
|
eval(completeRulesEnabled)
|
||||||
|
$entity: CtbMovt(ctbPart == null && generaScad == "S" && tipoPartita !=null && operation != OperationType.DELETE )
|
||||||
|
then
|
||||||
|
CtbPart partita = AccountingRules.completePartita(conn, $entity);
|
||||||
|
modify ( $entity ) { setCtbPart(partita)}
|
||||||
|
end
|
||||||
|
|
||||||
rule "insertNewPartita"
|
rule "insertNewPartita"
|
||||||
no-loop
|
no-loop
|
||||||
when
|
when
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package it.integry.ems.contabil.controller;
|
||||||
|
|
||||||
|
import it.integry.common.var.CommonConstants;
|
||||||
|
import it.integry.ems.contabil.service.MovimentiContabiliServices;
|
||||||
|
import it.integry.ems.response.ServiceRestResponse;
|
||||||
|
import it.integry.ems_model.entity.CtbMovt;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Scope("request")
|
||||||
|
@RequestMapping("movimenti-contabili")
|
||||||
|
public class MovimentiContabiliController {
|
||||||
|
@Autowired
|
||||||
|
private MovimentiContabiliServices movimentiContabiliServices;
|
||||||
|
|
||||||
|
@PostMapping(value = "save")
|
||||||
|
public @ResponseBody
|
||||||
|
ServiceRestResponse save(HttpServletRequest request,
|
||||||
|
@RequestParam(CommonConstants.PROFILE_DB) String configuration,
|
||||||
|
@RequestBody CtbMovt ctbMovt) throws Exception {
|
||||||
|
|
||||||
|
return ServiceRestResponse.createPositiveResponse(movimentiContabiliServices.save(ctbMovt));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package it.integry.ems.contabil.service;
|
||||||
|
|
||||||
|
import it.integry.ems.javabeans.RequestDataDTO;
|
||||||
|
import it.integry.ems.service.EntityProcessor;
|
||||||
|
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||||
|
import it.integry.ems.utility.UtilityDebug;
|
||||||
|
import it.integry.ems.utility.UtilityEntity;
|
||||||
|
import it.integry.ems_model.base.EntityBase;
|
||||||
|
import it.integry.ems_model.base.EntityInterface;
|
||||||
|
import it.integry.ems_model.entity.CtbMovt;
|
||||||
|
import it.integry.ems_model.entity.CtbParr;
|
||||||
|
import it.integry.ems_model.entity.CtbPart;
|
||||||
|
import it.integry.ems_model.entity.DtbDoct;
|
||||||
|
import it.integry.ems_model.service.SetupGest;
|
||||||
|
import it.integry.ems_model.types.OperationType;
|
||||||
|
import it.integry.ems_model.utility.Query;
|
||||||
|
import it.integry.ems_model.utility.UtilityBigDecimal;
|
||||||
|
import it.integry.ems_model.utility.UtilityDB;
|
||||||
|
import it.integry.ems_model.utility.UtilityDate;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Scope("request")
|
||||||
|
public class MovimentiContabiliServices {
|
||||||
|
@Autowired
|
||||||
|
private EntityProcessor entityProcessor;
|
||||||
|
@Autowired
|
||||||
|
private MultiDBTransactionManager multiDBTransactionManager;
|
||||||
|
|
||||||
|
public CtbMovt save(CtbMovt ctbMovt) throws Exception {
|
||||||
|
List<EntityBase> entitiesToSave = new ArrayList<>();
|
||||||
|
|
||||||
|
if (ctbMovt.getNumCmov() != null && ctbMovt.getOperation() != OperationType.DELETE) {
|
||||||
|
String sql =
|
||||||
|
Query.format( "SELECT cod_anag FROM ctb_movt WHERE num_cmov = %s", ctbMovt.getNumCmov() );
|
||||||
|
|
||||||
|
String codAnagOld = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||||
|
|
||||||
|
if (codAnagOld != null && !codAnagOld.equalsIgnoreCase(ctbMovt.getCodAnag())) {
|
||||||
|
sql = Query.format(
|
||||||
|
"SELECT DISTINCT ctb_part.*\n" +
|
||||||
|
"FROM ctb_part\n" +
|
||||||
|
" INNER JOIN ctb_parr ON ctb_part.tipo_anag = ctb_parr.tipo_anag AND ctb_part.cod_anag = ctb_parr.cod_anag AND\n" +
|
||||||
|
" ctb_part.anno_part = ctb_parr.anno_part AND ctb_part.ser_doc = ctb_parr.ser_doc AND\n" +
|
||||||
|
" ctb_part.num_doc = ctb_parr.num_doc\n" +
|
||||||
|
" INNER JOIN ctb_caus ON ctb_parr.cod_ccau = ctb_caus.cod_ccau\n" +
|
||||||
|
"WHERE ctb_parr.num_cmov = %s",
|
||||||
|
ctbMovt.getNumCmov());
|
||||||
|
|
||||||
|
CtbPart ctbPart = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, CtbPart.class);
|
||||||
|
|
||||||
|
if ( ctbPart != null) {
|
||||||
|
if ( ctbPart.getTipoPartita() == 1 && !UtilityBigDecimal.isNullOrZero(ctbPart.getAverePart())) {
|
||||||
|
throw new Exception("Impossibile modificare il movimento! Documento già incassato");
|
||||||
|
} else if (ctbPart.getTipoPartita() == 0 && !UtilityBigDecimal.isNullOrZero(ctbPart.getDarePart())) {
|
||||||
|
throw new Exception("Impossibile modificare il movimento! Documento già incassato");
|
||||||
|
}
|
||||||
|
ctbPart.setOperation(OperationType.DELETE);
|
||||||
|
entitiesToSave.add(ctbPart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
entitiesToSave.add(ctbMovt);
|
||||||
|
} else {
|
||||||
|
entitiesToSave = Collections.singletonList(ctbMovt);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<EntityBase> entityRet = entityProcessor.processEntityList(entitiesToSave, true);
|
||||||
|
UtilityEntity.throwEntitiesException(entityRet);
|
||||||
|
|
||||||
|
CtbMovt ctbMovtRet = entityRet.stream().filter(x->x instanceof CtbMovt).map(x->(CtbMovt)x).findFirst().orElse(null);
|
||||||
|
return ctbMovtRet;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user