correzione a registrazione distinte raggruppate e sync rossogargano
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20240702170547 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (isCustomer(IntegryCustomer.Carelli))
|
||||
updateSetupValue("NTB_DOCT", "PROMOZIONI", "ESCLUDI_PROMO_INFORMATIVE", "S");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,17 +43,14 @@ public class CtbParr extends EntityBase {
|
||||
private String codAnag;
|
||||
|
||||
@PK
|
||||
@ImportFromParent
|
||||
@SqlField(value = "anno_part", nullable = false)
|
||||
private Integer annoPart;
|
||||
|
||||
@PK
|
||||
@ImportFromParent
|
||||
@SqlField(value = "ser_doc", maxLength = 2, nullable = false)
|
||||
private String serDoc;
|
||||
|
||||
@PK
|
||||
@ImportFromParent
|
||||
@SqlField(value = "num_doc", nullable = false)
|
||||
private Integer numDoc;
|
||||
|
||||
@@ -61,11 +58,9 @@ public class CtbParr extends EntityBase {
|
||||
@SqlField(value = "data_cmov", nullable = false)
|
||||
private Date dataCmov;
|
||||
|
||||
@ImportFromParent
|
||||
@SqlField(value = "imp_dare", nullable = false, defaultObjectValue = "0")
|
||||
private BigDecimal impDare;
|
||||
|
||||
@ImportFromParent
|
||||
@SqlField(value = "imp_avere", nullable = false, defaultObjectValue = "0")
|
||||
private BigDecimal impAvere;
|
||||
|
||||
|
||||
@@ -1042,9 +1042,9 @@ public class ContabilService {
|
||||
BigDecimal impScadDivisa = impScad.multiply(cambioPart);
|
||||
elencoScadenze = AccountingBusinessLogic.loadScadenze(multiDBTransactionManager.getPrimaryConnection(), riga.getTipoAnag(), codAnag, UtilityDate.getYear(riga.getDataDoc()), riga.getSerDoc(), riga.getNumDoc());
|
||||
if (elencoScadenze != null && elencoScadenze.size() > 0) {
|
||||
elencoScadenze = Stream.of(elencoScadenze).filter(s -> s.getIdRiga().equals(riga.getNumScad())).toList();
|
||||
|
||||
AccountingBusinessLogic.pagaScadenze(datiMov.getDataReg(), impScadDivisa.abs(), elencoScadenze, nextIdRiga);
|
||||
elencoScadenze = Stream.of(elencoScadenze).filter(s -> s.getIdRiga().equals(riga.getNumScad()) && s.getDataPag() == null).toList();
|
||||
if ( elencoScadenze != null && !elencoScadenze.isEmpty() )
|
||||
AccountingBusinessLogic.pagaScadenze(datiMov.getDataReg(), impScadDivisa.abs(), elencoScadenze, nextIdRiga);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1067,9 +1067,9 @@ public class ContabilService {
|
||||
}
|
||||
ctbMovr.setImpDare(ctbMovr.getImpDare().add(impDare));
|
||||
ctbMovr.setImpAvere(ctbMovr.getImpAvere().add(impAvere));
|
||||
if (elencoScadenze != null) {
|
||||
if (elencoScadenze != null && !elencoScadenze.isEmpty()) {
|
||||
List<CtbScad> ctbScadPagate = Stream.of(elencoScadenze).filter(x -> x.getIdRigaMov() != null && x.getIdRigaMov().equals(nextIdRiga)).toList();
|
||||
if (ctbMovr.getCtbScad() == null ) ctbMovr.setCtbScad(new ArrayList<>());
|
||||
if (ctbMovr.getCtbScad() == null ) ctbMovr.setCtbScad(new ArrayList<>());
|
||||
ctbMovr.getCtbScad().addAll(ctbScadPagate);
|
||||
|
||||
List<CtbScad> ctbScadNew =
|
||||
@@ -1078,6 +1078,22 @@ public class ContabilService {
|
||||
|
||||
if (ctbMovt.getCtbScad() == null ) ctbMovt.setCtbScad(new ArrayList<>());
|
||||
ctbMovt.getCtbScad().addAll(ctbScadNew);
|
||||
} else {
|
||||
CtbParr ctbParr =
|
||||
new CtbParr()
|
||||
.setImpAvere(impAvere)
|
||||
.setImpDare(impDare);
|
||||
|
||||
if (chiudiPartita ) {
|
||||
ctbParr
|
||||
.setAnnoPart(UtilityDate.getYear(riga.getDataDoc()))
|
||||
.setSerDoc(riga.getSerDoc())
|
||||
.setNumDoc(riga.getNumDoc());
|
||||
|
||||
}
|
||||
|
||||
if (ctbMovr.getCtbParr() == null) ctbMovr.setCtbParr(new ArrayList<>());
|
||||
ctbMovr.getCtbParr().add(ctbParr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -118,11 +118,14 @@ public class RossoGarganoSyncService {
|
||||
"FROM " + multiDBTransactionManager.getPrimaryDatasource().getDbName() + ".dbo.rg_crl_movt m\n" +
|
||||
"WHERE NOT EXISTS (SELECT *\n" +
|
||||
" FROM pnota\n" +
|
||||
" WHERE pnota.pn_data_competenza = m.pn_data_competenza AND pnota.pn_nro_reg = m.pn_nro_reg)\n";
|
||||
" WHERE pnota.pn_data_competenza = m.pn_data_competenza AND pnota.pn_nro_reg = m.pn_nro_reg) AND\n" +
|
||||
" EXISTS (SELECT *\n" +
|
||||
" FROM " + multiDBTransactionManager.getPrimaryDatasource().getDbName() + ".dbo.ctb_movt\n" +
|
||||
" WHERE ctb_movt.num_cmov = m.num_cmov) \n";
|
||||
|
||||
List<Integer> listNumCmov = UtilityDB.executeSimpleQueryOnlyFirstColumn(sourceData, sql);
|
||||
|
||||
for ( Integer numCmov : listNumCmov) {
|
||||
for (Integer numCmov : listNumCmov) {
|
||||
CtbMovt ctbMovt =
|
||||
new CtbMovt().setNumCmov(numCmov);
|
||||
ctbMovt.setOperation(OperationType.DELETE);
|
||||
@@ -317,7 +320,7 @@ public class RossoGarganoSyncService {
|
||||
.setSerDoc(serDoc)
|
||||
.setNumDocForn(numDocForn);
|
||||
//ctbMovtRv =
|
||||
getCtbMovi(sourceData, ctbMovt, c);
|
||||
getCtbMovi(sourceData, ctbMovt, c);
|
||||
|
||||
if (ctbMovt.getCtbMovr() != null) {
|
||||
List<CtbMovi> listIva =
|
||||
@@ -332,7 +335,7 @@ public class RossoGarganoSyncService {
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
generateAutofattura = true;
|
||||
if ( movCont.stream().noneMatch(x->((String) x.get("PN_COD_ANAG")).equalsIgnoreCase("01820005"))) {
|
||||
if (movCont.stream().noneMatch(x -> ((String) x.get("PN_COD_ANAG")).equalsIgnoreCase("01820005"))) {
|
||||
ctbMovrIva =
|
||||
new CtbMovr()
|
||||
.setCodCcon("182001")
|
||||
@@ -368,7 +371,7 @@ public class RossoGarganoSyncService {
|
||||
if (UtilityString.isNullOrEmpty(codCcon))
|
||||
throw new Exception(String.format("Codice P.D.C. non trovato per il diacod %s", pnCodAnag));
|
||||
|
||||
if ( generateAutofattura && codCcon.equalsIgnoreCase("480505"))
|
||||
if (generateAutofattura && codCcon.equalsIgnoreCase("480505"))
|
||||
continue;
|
||||
|
||||
CtbMovr ctbMovr =
|
||||
@@ -436,7 +439,7 @@ public class RossoGarganoSyncService {
|
||||
entityProcessor.processEntity(ctbMovt, true, multiDBTransactionManager);
|
||||
UtilityEntity.throwEntityException(ctbMovt);
|
||||
|
||||
if ( generateAutofattura) {
|
||||
if (generateAutofattura) {
|
||||
generateAutofattura(ctbMovt);
|
||||
}
|
||||
|
||||
@@ -447,8 +450,18 @@ public class RossoGarganoSyncService {
|
||||
// UtilityEntity.throwEntityException(ctbMovtRv);
|
||||
// }
|
||||
|
||||
sql = Query.format("INSERT INTO rg_crl_movt VALUES (%s, %s, %s,%s )", ctbMovt.getNumCmov(), pnDataCompetenza, pnNroReg, new Date());
|
||||
|
||||
sql = Query.format("SELECT cast(count(*) as bit) FROM rg_crl_movt WHERE PN_DATA_COMPETENZA = %s AND PN_NRO_REG = %s", pnDataCompetenza, pnNroReg);
|
||||
|
||||
boolean existMov = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
Statement statement = multiDBTransactionManager.getPrimaryConnection().createStatement();
|
||||
if (existMov) {
|
||||
sql = Query.format("DELETE FROM rg_crl_movt WHERE PN_DATA_COMPETENZA = %s AND PN_NRO_REG = %s", pnDataCompetenza, pnNroReg);
|
||||
statement.execute(sql);
|
||||
}
|
||||
|
||||
sql = Query.format("INSERT INTO rg_crl_movt VALUES (%s, %s, %s,%s )", ctbMovt.getNumCmov(), pnDataCompetenza, pnNroReg, new Date());
|
||||
statement.execute(sql);
|
||||
multiDBTransactionManager.commitAll();
|
||||
// break;
|
||||
@@ -465,6 +478,7 @@ public class RossoGarganoSyncService {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void generateAutofattura(CtbMovt ctbMovt) throws Exception {
|
||||
existClieAutofattura(ctbMovt.getCodAnag());
|
||||
String codDtip = "TD17";
|
||||
@@ -474,15 +488,15 @@ public class RossoGarganoSyncService {
|
||||
|
||||
String sql = Query.format("SELECT segno_ireg FROM ctb_caus WHERE cod_ccau = %s ", ctbMovt.getCodCcau());
|
||||
BigDecimal segnoReg = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
if (UtilityBigDecimal.lowerThan(segnoReg, BigDecimal.ZERO) ) {
|
||||
if (UtilityBigDecimal.lowerThan(segnoReg, BigDecimal.ZERO)) {
|
||||
codDtip = "N" + codDtip;
|
||||
}
|
||||
|
||||
AutofatturaDTO autofatturaDTO =
|
||||
new AutofatturaDTO().setCodDtip(codDtip)
|
||||
.setDescrizione(String.format("AUTOFATTURA EMESSA A FRONTE DELLA FATTURA N.%s DEL %s",
|
||||
ctbMovt.getNumDocForn(),
|
||||
new SimpleDateFormat("dd/MM/yyyy").format(ctbMovt.getDataDoc())))
|
||||
ctbMovt.getNumDocForn(),
|
||||
new SimpleDateFormat("dd/MM/yyyy").format(ctbMovt.getDataDoc())))
|
||||
.setNumCmov(ctbMovt.getNumCmov());
|
||||
|
||||
autofatturaService.generaAutofattura(autofatturaDTO);
|
||||
@@ -620,7 +634,7 @@ public class RossoGarganoSyncService {
|
||||
if (codIva.equalsIgnoreCase("92")) {
|
||||
codIva = "9222";
|
||||
percAliq = new BigDecimal(22);
|
||||
imposta = imponibile.divide(percAliq, 5);
|
||||
imposta = imponibile.multiply(percAliq.divide(cento)).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
Result result = getCodAliq(codIva, percAliq, percDetr);
|
||||
|
||||
Reference in New Issue
Block a user