gestito flag su movimenti contabili per ventilazione iva
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
package it.integry.ems.migration.model;import it.integry.ems.migration._base.BaseMigration;
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20241212153041 extends BaseMigration implements MigrationModelInterface{
|
||||
public class Migration_20241212153041 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up()throws Exception {
|
||||
if(isHistoryDB())
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("ALTER TABLE mtb_depo ADD data_iniz_vent datetime",
|
||||
"ALTER TABLE mtb_depo ADD data_fine_vent datetime");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down()throws Exception {
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,28 @@
|
||||
package it.integry.ems.migration.model;import it.integry.ems.migration._base.BaseMigration;
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20241212153857 extends BaseMigration implements MigrationModelInterface{
|
||||
public class Migration_20241212153857 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up()throws Exception {
|
||||
if(isHistoryDB())
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
executeStatement("ALTER TABLE ctb_movi ADD ventilazione bit not null default 1",
|
||||
"update ctb_movi set ventilazione = 1\n" +
|
||||
"from ctb_movt inner join ctb_movi on ctb_movt.num_cmov = ctb_movi.num_cmov\n" +
|
||||
"inner join gtb_aliq on ctb_movi.cod_aliq = gtb_aliq.cod_aliq\n" +
|
||||
"where gtb_aliq.flag_iva_acq_merci = 's'\n" +
|
||||
"and ctb_movt.anno_comp >= (select anno_contab from azienda)",
|
||||
"update mtb_depo set data_iniz_vent = '2001/01/01'\n" +
|
||||
"from mtb_depo\n" +
|
||||
"where exists(select * from ctb_ireg where flag_iva_da_ventilare = 's')\n" +
|
||||
"and cod_vlis is not null");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down()throws Exception {
|
||||
public void down() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -500,7 +500,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
Integer maxRigaSpesa = 0;
|
||||
String whereCondExcSpese = null;
|
||||
boolean calcScpese = false;
|
||||
boolean flagSpeseArt = false, isOrdine = false;
|
||||
boolean flagSpeseArt = false, isOrdine = false, ventilazioneIva = false;
|
||||
if (testata instanceof DtbOrdt) {
|
||||
righe = ((DtbOrdt) testata).getDtbOrdr();
|
||||
flagIvaInclusa = ((DtbOrdt) testata).getFlagPrzIva();
|
||||
@@ -525,6 +525,18 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
if (((DtbDoct) testata).getVtbClie() != null) {
|
||||
flagSpeseArt = ((DtbDoct) testata).getVtbClie().getFlagSpeseArt().equalsIgnoreCase("S");
|
||||
}
|
||||
if (insMovCont){
|
||||
String sql =
|
||||
Query.format(
|
||||
"SELECT CAST(COUNT(*) AS BIT)\n" +
|
||||
"FROM mtb_depo\n" +
|
||||
"WHERE %s BETWEEN ISNULL(data_iniz_vent, %s) AND ISNULL(data_fine_vent, CAST(GETDATE() AS DATE))\n" +
|
||||
" AND mtb_depo.cod_mdep = %s\n",
|
||||
((DtbDoct) testata).getDataReg(),
|
||||
((DtbDoct) testata).getDataReg(),
|
||||
testata.getCodMdep());
|
||||
ventilazioneIva = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
}
|
||||
}
|
||||
|
||||
if ("N".equals(flagPrezziScontati)) {
|
||||
@@ -768,7 +780,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
setNumColliPeso(testata, calcColli, datiTrasp, colli, colliFromDB);
|
||||
|
||||
//CALCOLO TOTALI E CASTELLETTO IVA
|
||||
calcTotImponib(testata, conn, flagIvaInclusa, lhm_castelletto, castellettoIva, cifreDec);
|
||||
calcTotImponib(testata, conn, flagIvaInclusa, lhm_castelletto, castellettoIva, cifreDec, ventilazioneIva);
|
||||
|
||||
//Prima di calcolare l'acconto estrerre l'elenco delle bolle agganciate alla fatture differita
|
||||
if (testata instanceof DtbDoct && ((DtbDoct) testata).getDtbTipi().getTipoEmissioneEnum() == TipoEmissione.DIFFERITA) {
|
||||
@@ -789,7 +801,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
CALCOLO SPESE DIPENDENTI DAL TOTALE DOCUMNETO
|
||||
*/
|
||||
if (testata instanceof DtbDoct && calcScpese) {
|
||||
List<DtbDocs> speseDoc = addSpese(conn, ((DtbDoct) testata), lhm_castelletto, flagIvaInclusa, castellettoIva, maxRigaSpesa, whereCondExcSpese, cifreDec);
|
||||
List<DtbDocs> speseDoc = addSpese(conn, ((DtbDoct) testata), lhm_castelletto, castellettoIva, maxRigaSpesa, whereCondExcSpese, cifreDec, ventilazioneIva);
|
||||
((DtbDoct) testata).getDtbDocs().addAll(speseDoc);
|
||||
BigDecimal totSpeseCalc = calcTotSpese(conn, lhm_castelletto, speseDoc, false, flagIvaInclusa, cifreDec);
|
||||
totSpese = totSpese.add(totSpeseCalc);
|
||||
@@ -865,7 +877,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
}
|
||||
|
||||
private static void calcTotImponib(DtbDocOrdT testata, Connection conn, String flagIvaInclusa, HashMap<String, BigDecimal> lhm_castelletto,
|
||||
List<CtbMovi> castellettoIva, Integer cifreDec) throws Exception {
|
||||
List<CtbMovi> castellettoIva, Integer cifreDec, boolean ventilazioneIva) throws Exception {
|
||||
BigDecimal totImponib = BigDecimal.ZERO;
|
||||
BigDecimal totImposta = BigDecimal.ZERO;
|
||||
castellettoIva.clear();
|
||||
@@ -881,11 +893,12 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
BigDecimal totImponibAliq = entry.getValue();
|
||||
BigDecimal totImpostaAliq = BigDecimal.ZERO;
|
||||
if (!UtilityString.isNullOrEmpty(codAliq)) {
|
||||
String sql = "SELECT tipo_iva, flag_marca_da_bollo, perc_aliq FROM gtb_aliq WHERE cod_aliq = " + UtilityDB.valueToString(codAliq);
|
||||
String sql = "SELECT tipo_iva, flag_marca_da_bollo, perc_aliq, flag_iva_acq_merci FROM gtb_aliq WHERE cod_aliq = " + UtilityDB.valueToString(codAliq);
|
||||
HashMap<String, Object> dati = UtilityDB.executeSimpleQueryOnlyFirstRow(conn, sql);
|
||||
String tipoIva = (String) dati.get("tipo_iva");
|
||||
String flagAddMarcaBollo = (String) dati.get("flag_marca_da_bollo");
|
||||
BigDecimal percAliq = (BigDecimal) dati.get("perc_aliq");
|
||||
boolean flagIvaAcqMerci = UtilityHashMap.<String>getValueIfExists(dati, "flag_iva_acq_merci").equalsIgnoreCase("S");
|
||||
|
||||
if ("S".equals(flagIvaInclusa)) {
|
||||
BigDecimal totImpScorporo = IntegerUtility.round(CommonRules.scorporoIva(conn, totImponibAliq, codAliq), 2);
|
||||
@@ -902,7 +915,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
iva.setImponibile(totImponibAliq);
|
||||
iva.setImposta(totImpostaAliq);
|
||||
iva.setFlagMarcaDaBollo(flagAddMarcaBollo);
|
||||
|
||||
iva.setVentilazione(flagIvaAcqMerci && ventilazioneIva);
|
||||
castellettoIva.add(iva);
|
||||
} else {
|
||||
totImponibAliq = BigDecimal.ZERO;
|
||||
@@ -1297,8 +1310,8 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
}
|
||||
|
||||
private static List<DtbDocs> addSpese(Connection connection, DtbDoct testata, HashMap<String, BigDecimal> lhm_castelletto,
|
||||
String flagIvaInclusa, List<CtbMovi> castellettoIva, Integer maxRigaSpesa,
|
||||
String whereCondExcSpese, Integer cifreDec) throws Exception {
|
||||
List<CtbMovi> castellettoIva, Integer maxRigaSpesa,
|
||||
String whereCondExcSpese, Integer cifreDec, boolean ventilazioneIva) throws Exception {
|
||||
List<DtbDocs> speseCalc = new ArrayList<>();
|
||||
|
||||
String flagSpese = "", costoEsenzione = "", flagAddBollo = "";
|
||||
@@ -1314,8 +1327,8 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
!UtilityBigDecimal.isNullOrZero(testata.getTotImponib().add(testata.getTotIva()).subtract(testata.getAcconto())) &&
|
||||
(!UtilityString.isNullOrEmpty(testata.getCodPaga()) || !UtilityString.isNullOrEmpty(costoEsenzione) || !UtilityString.isNullOrEmpty(testata.getCodVvet()))) {
|
||||
|
||||
maxRigaSpesa = addAltreSpese(connection, testata, lhm_castelletto, castellettoIva, speseCalc, maxRigaSpesa, whereCondExcSpese, cifreDec);
|
||||
calcTotImponib(testata, connection, testata.getFlagPrzIva(), lhm_castelletto, castellettoIva, cifreDec);
|
||||
maxRigaSpesa = addAltreSpese(connection, testata, lhm_castelletto, castellettoIva, speseCalc, maxRigaSpesa, whereCondExcSpese, cifreDec, ventilazioneIva);
|
||||
calcTotImponib(testata, connection, testata.getFlagPrzIva(), lhm_castelletto, castellettoIva, cifreDec, ventilazioneIva);
|
||||
}
|
||||
|
||||
//Imposta di bollo
|
||||
@@ -1332,8 +1345,8 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
totDoc = totDoc.add(iva.getImponibile().add(iva.getImposta()));
|
||||
}
|
||||
if (totDoc.compareTo(BigDecimal.ZERO) != 0) {
|
||||
maxRigaSpesa = addImpostaBollo(connection, testata, lhm_castelletto, speseCalc, maxRigaSpesa, whereCondExcSpese, totDoc);
|
||||
calcTotImponib(testata, connection, testata.getFlagPrzIva(), lhm_castelletto, castellettoIva, cifreDec);
|
||||
addImpostaBollo(connection, testata, lhm_castelletto, speseCalc, maxRigaSpesa, whereCondExcSpese, totDoc);
|
||||
calcTotImponib(testata, connection, testata.getFlagPrzIva(), lhm_castelletto, castellettoIva, cifreDec, ventilazioneIva);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1441,15 +1454,13 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
private static Integer addAltreSpese(Connection connection, DtbDoct testata, HashMap<String, BigDecimal> lhm_castelletto,
|
||||
List<CtbMovi> castellettoIva, List<DtbDocs> speseCalc,
|
||||
Integer maxRigaSpesa, String whereCondExcSpese,
|
||||
Integer cifreDec) throws Exception {
|
||||
String sql = "SELECT cifre_dec FROM gtb_divi WHERE cod_divi = " + UtilityDB.valueToString(testata.getCodDivi());
|
||||
|
||||
Integer cifreDec, boolean ventilazioneIva) throws Exception {
|
||||
String costoEsenzione = null;
|
||||
if (testata.getVtbClie() != null) {
|
||||
costoEsenzione = testata.getVtbClie().getCostoEsenzione();
|
||||
}
|
||||
|
||||
sql =
|
||||
String sql =
|
||||
"SELECT gtb_spes.cod_spes, " +
|
||||
" gtb_spes.descrizione, " +
|
||||
" gtb_spes.tipo_calcolo as 'tipo_calcolo', " +
|
||||
@@ -1524,7 +1535,7 @@ public class DocOrdCalTotaliRules extends QueryRules {
|
||||
maxRigaSpesa = setDtbDocs(testata, lhm_castelletto, spesa, BigDecimal.ZERO, importo, speseCalc, maxRigaSpesa);
|
||||
}
|
||||
}
|
||||
calcTotImponib(testata, connection, testata.getFlagPrzIva(), lhm_castelletto, castellettoIva, cifreDec);
|
||||
calcTotImponib(testata, connection, testata.getFlagPrzIva(), lhm_castelletto, castellettoIva, cifreDec, ventilazioneIva);
|
||||
}
|
||||
/*
|
||||
calcolo spese sul totale del documento
|
||||
|
||||
@@ -56,6 +56,9 @@ public class CtbMovi extends EntityBase {
|
||||
@SqlField(value = "cambio_divi_cont", nullable = false)
|
||||
private BigDecimal cambioDiviCont;
|
||||
|
||||
@SqlField(value = "ventilazione", nullable = false, defaultObjectValue = "true")
|
||||
private Boolean ventilazione;
|
||||
|
||||
@ImportFromParent
|
||||
private String flagScorporo;
|
||||
|
||||
@@ -195,4 +198,13 @@ public class CtbMovi extends EntityBase {
|
||||
this.flagMarcaDaBollo = flagMarcaDaBollo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getVentilazione() {
|
||||
return ventilazione;
|
||||
}
|
||||
|
||||
public CtbMovi setVentilazione(Boolean ventilazione) {
|
||||
this.ventilazione = ventilazione;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import it.integry.ems_model.utility.UtilityDB;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -121,6 +122,12 @@ public class MtbDepo extends EntityBase {
|
||||
@SqlField(value = "chk_giacenza_neg", nullable = false, defaultObjectValue = "0")
|
||||
private Boolean chkGiacenzaNeg;
|
||||
|
||||
@SqlField(value = "data_iniz_vent")
|
||||
private Date dataInizVent;
|
||||
|
||||
@SqlField(value = "data_fine_vent")
|
||||
private Date dataFineVent;
|
||||
|
||||
@EntityChild
|
||||
private List<MtbDepoOper> mtbDepoOper = new ArrayList<>();
|
||||
|
||||
@@ -434,6 +441,24 @@ public class MtbDepo extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataInizVent() {
|
||||
return dataInizVent;
|
||||
}
|
||||
|
||||
public MtbDepo setDataInizVent(Date dataInizVent) {
|
||||
this.dataInizVent = dataInizVent;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDataFineVent() {
|
||||
return dataFineVent;
|
||||
}
|
||||
|
||||
public MtbDepo setDataFineVent(Date dataFineVent) {
|
||||
this.dataFineVent = dataFineVent;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getFlagGestisciTracc() {
|
||||
return flagGestisciTracc;
|
||||
}
|
||||
|
||||
@@ -8,62 +8,61 @@ import java.util.List;
|
||||
|
||||
public class DatiCorrispettiviDTO {
|
||||
@MapToTable("cod_mdep")
|
||||
String codMdep;
|
||||
private String codMdep;
|
||||
|
||||
@MapToTable("descrizione")
|
||||
String descrizione;
|
||||
private String descrizione;
|
||||
|
||||
@MapToTable("cod_dtip")
|
||||
String codDtip;
|
||||
private String codDtip;
|
||||
|
||||
@MapToTable("cod_anag")
|
||||
String codAnag;
|
||||
private String codAnag;
|
||||
|
||||
@MapToTable("data_doc")
|
||||
Date dataDoc;
|
||||
private Date dataDoc;
|
||||
|
||||
@MapToTable("ser_doc")
|
||||
String serDoc;
|
||||
private String serDoc;
|
||||
|
||||
@MapToTable("num_doc")
|
||||
Integer numDoc;
|
||||
private Integer numDoc;
|
||||
|
||||
@MapToTable("tot_doc")
|
||||
BigDecimal totDoc;
|
||||
private BigDecimal totDoc;
|
||||
|
||||
@MapToTable("count_scontrini")
|
||||
Integer countScontrini;
|
||||
private Integer countScontrini;
|
||||
|
||||
@MapToTable("count_tot_scontrini")
|
||||
Integer countTotScontrini;
|
||||
private Integer countTotScontrini;
|
||||
|
||||
@MapToTable("cod_ccau")
|
||||
String codCcau;
|
||||
private String codCcau;
|
||||
|
||||
@MapToTable("cod_ccon")
|
||||
String codCcon;
|
||||
private String codCcon;
|
||||
|
||||
@MapToTable("flag_iva_da_ventilare")
|
||||
String flagIvaDaVentilare;
|
||||
private Boolean flagIvaDaVentilare;
|
||||
|
||||
@MapToTable("num_cmov")
|
||||
Integer numCmov;
|
||||
private Integer numCmov;
|
||||
|
||||
@MapToTable("cod_ireg")
|
||||
String codIreg;
|
||||
private String codIreg;
|
||||
|
||||
@MapToTable("num_ireg")
|
||||
Integer numIreg;
|
||||
private Integer numIreg;
|
||||
|
||||
@MapToTable("segno_qta_scar")
|
||||
Integer segnoQtaScar;
|
||||
private Integer segnoQtaScar;
|
||||
|
||||
@MapToTable("tot_corr_gg")
|
||||
BigDecimal totCorrGg;
|
||||
private BigDecimal totCorrGg;
|
||||
|
||||
|
||||
List<CastellettoIva> castellettoIva;
|
||||
List<TipoIncasso> tipoIncasso;
|
||||
private List<CastellettoIva> castellettoIva;
|
||||
private List<TipoIncasso> tipoIncasso;
|
||||
|
||||
public String getCodMdep() {
|
||||
return codMdep;
|
||||
@@ -161,12 +160,13 @@ public class DatiCorrispettiviDTO {
|
||||
this.codCcon = codCcon;
|
||||
}
|
||||
|
||||
public String getFlagIvaDaVentilare() {
|
||||
public Boolean getFlagIvaDaVentilare() {
|
||||
return flagIvaDaVentilare;
|
||||
}
|
||||
|
||||
public void setFlagIvaDaVentilare(String flagIvaDaVentilare) {
|
||||
public DatiCorrispettiviDTO setFlagIvaDaVentilare(Boolean flagIvaDaVentilare) {
|
||||
this.flagIvaDaVentilare = flagIvaDaVentilare;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getNumCmov() {
|
||||
@@ -227,15 +227,15 @@ public class DatiCorrispettiviDTO {
|
||||
|
||||
public static class CastellettoIva {
|
||||
@MapToTable("cod_aliq")
|
||||
String codAliq;
|
||||
private String codAliq;
|
||||
@MapToTable("perc_aliq")
|
||||
BigDecimal percAliq;
|
||||
private BigDecimal percAliq;
|
||||
@MapToTable("imponib")
|
||||
BigDecimal imponib;
|
||||
private BigDecimal imponib;
|
||||
@MapToTable("imposta")
|
||||
BigDecimal imposta;
|
||||
private BigDecimal imposta;
|
||||
@MapToTable("cod_ccon")
|
||||
String codCcon;
|
||||
private String codCcon;
|
||||
|
||||
public String getCodAliq() {
|
||||
return codAliq;
|
||||
@@ -280,10 +280,10 @@ public class DatiCorrispettiviDTO {
|
||||
|
||||
public static class TipoIncasso {
|
||||
@MapToTable("cod_ccon")
|
||||
String codCcon;
|
||||
private String codCcon;
|
||||
|
||||
@MapToTable("imp_inca")
|
||||
BigDecimal impInca;
|
||||
private BigDecimal impInca;
|
||||
|
||||
public String getCodCcon() {
|
||||
return codCcon;
|
||||
|
||||
@@ -89,42 +89,45 @@ public class RegCorrispettivoService {
|
||||
}
|
||||
|
||||
String queryDatiCorrispettivo =
|
||||
"SELECT dtb_doct.cod_mdep,"
|
||||
+ " dtb_doct.cod_anag, "
|
||||
+ " dtb_doct.cod_dtip, "
|
||||
+ " dtb_doct.data_doc, "
|
||||
+ " dtb_doct.ser_doc, "
|
||||
+ " dtb_doct.num_doc, "
|
||||
+ " dtb_doct.tot_imponib+dtb_doct.tot_iva as tot_doc, "
|
||||
+ " ctb_ireg.flag_iva_da_ventilare, "
|
||||
+ " mtb_depo.descrizione, "
|
||||
+ " nvw_count_scontrini_doc.count_scontrini, "
|
||||
+ " mtb_depo.cod_ccau, "
|
||||
+ " mtb_depo.cod_ccon, "
|
||||
+ " dtb_doct.num_cmov, "
|
||||
+ " dtb_tipi.cod_ireg, "
|
||||
+ " dtb_tipi.num_ireg, "
|
||||
+ " (select count(*) from ntb_doct where ntb_doct.cod_mdep = dtb_doct.cod_mdep and ntb_doct.data_doc_val = dtb_doct.data_doc and data_doc_val is not null) as 'count_tot_scontrini', "
|
||||
+ " dtb_tipi.segno_qta_scar, "
|
||||
+ "Sum( (CASE WHEN dtb_tipi.segno_qta_scar = 0 THEN -1 ELSE 1 END ) * (dtb_doct.tot_imponib+dtb_doct.tot_iva) ) OVER (PARTITION BY dtb_doct.cod_mdep, dtb_doct.data_doc) as tot_corr_gg "
|
||||
+ " FROM dtb_doct, "
|
||||
+ " dtb_tipi, "
|
||||
+ " ctb_ireg, "
|
||||
+ " mtb_depo, "
|
||||
+ " nvw_count_scontrini_doc, "
|
||||
+ " gtb_anag "
|
||||
+ " WHERE dtb_doct.cod_dtip = dtb_tipi.cod_dtip AND "
|
||||
+ " dtb_tipi.cod_ireg = ctb_ireg.cod_ireg AND "
|
||||
+ " dtb_doct.cod_mdep = mtb_depo.cod_mdep AND "
|
||||
+ " dtb_doct.cod_anag = nvw_count_scontrini_doc.cod_anag_val AND "
|
||||
+ " dtb_doct.cod_dtip = nvw_count_scontrini_doc.cod_dtip_val AND "
|
||||
+ " dtb_doct.data_doc = nvw_count_scontrini_doc.data_doc_val AND "
|
||||
+ " dtb_doct.ser_doc = nvw_count_scontrini_doc.ser_doc_val AND "
|
||||
+ " dtb_doct.num_doc = nvw_count_scontrini_doc.num_doc_val AND "
|
||||
+ " mtb_depo.cod_anag = gtb_anag.cod_anag "
|
||||
+ "ORDER BY dtb_doct.cod_mdep,"
|
||||
+ " dtb_doct.data_doc, "
|
||||
+ " nvw_count_scontrini_doc.count_scontrini desc ";
|
||||
"SELECT dtb_doct.cod_mdep,\n" +
|
||||
" dtb_doct.cod_anag,\n" +
|
||||
" dtb_doct.cod_dtip,\n" +
|
||||
" dtb_doct.data_doc,\n" +
|
||||
" dtb_doct.ser_doc,\n" +
|
||||
" dtb_doct.num_doc,\n" +
|
||||
" dtb_doct.tot_imponib + dtb_doct.tot_iva AS tot_doc,\n" +
|
||||
" CAST(CASE\n" +
|
||||
" WHEN ctb_ireg.flag_iva_da_ventilare = 'N' THEN 'N'\n" +
|
||||
" ELSE IIF(\n" +
|
||||
" dtb_doct.data_reg BETWEEN ISNULL(mtb_depo.data_iniz_vent, dtb_doct.data_reg) AND ISNULL(mtb_depo.data_fine_vent, CAST(GETDATE() AS DATE)),\n" +
|
||||
" 'S', 'N') END AS BIT) flag_iva_da_ventilare,\n" +
|
||||
" mtb_depo.descrizione,\n" +
|
||||
" nvw_count_scontrini_doc.count_scontrini,\n" +
|
||||
" mtb_depo.cod_ccau,\n" +
|
||||
" mtb_depo.cod_ccon,\n" +
|
||||
" dtb_doct.num_cmov,\n" +
|
||||
" dtb_tipi.cod_ireg,\n" +
|
||||
" dtb_tipi.num_ireg,\n" +
|
||||
" (SELECT COUNT(*)\n" +
|
||||
" FROM ntb_doct\n" +
|
||||
" WHERE ntb_doct.cod_mdep = dtb_doct.cod_mdep\n" +
|
||||
" AND ntb_doct.data_doc_val = dtb_doct.data_doc\n" +
|
||||
" AND data_doc_val IS NOT NULL) AS 'count_tot_scontrini',\n" +
|
||||
" dtb_tipi.segno_qta_scar,\n" +
|
||||
" SUM((CASE WHEN dtb_tipi.segno_qta_scar = 0 THEN -1 ELSE 1 END) * (dtb_doct.tot_imponib + dtb_doct.tot_iva))\n" +
|
||||
" OVER (PARTITION BY dtb_doct.cod_mdep, dtb_doct.data_doc) AS tot_corr_gg\n" +
|
||||
"FROM dtb_doct\n" +
|
||||
" INNER JOIN dtb_tipi ON dtb_doct.cod_dtip = dtb_tipi.cod_dtip\n" +
|
||||
" INNER JOIN ctb_ireg ON dtb_tipi.cod_ireg = ctb_ireg.cod_ireg\n" +
|
||||
" INNER JOIN mtb_depo ON dtb_doct.cod_mdep = mtb_depo.cod_mdep\n" +
|
||||
" INNER JOIN nvw_count_scontrini_doc ON dtb_doct.cod_anag = nvw_count_scontrini_doc.cod_anag_val AND\n" +
|
||||
" dtb_doct.cod_dtip = nvw_count_scontrini_doc.cod_dtip_val AND\n" +
|
||||
" dtb_doct.data_doc = nvw_count_scontrini_doc.data_doc_val AND\n" +
|
||||
" dtb_doct.ser_doc = nvw_count_scontrini_doc.ser_doc_val AND\n" +
|
||||
" dtb_doct.num_doc = nvw_count_scontrini_doc.num_doc_val\n" +
|
||||
" INNER JOIN gtb_anag ON mtb_depo.cod_anag = gtb_anag.cod_anag\n" +
|
||||
" WHERE 1 = 1 \n"+
|
||||
"ORDER BY dtb_doct.cod_mdep, dtb_doct.data_doc, nvw_count_scontrini_doc.count_scontrini DESC";
|
||||
queryDatiCorrispettivo = UtilityDB.addwhereCond(queryDatiCorrispettivo, whereCond, true);
|
||||
List<DatiCorrispettiviDTO> datiCorrispettivi = new ResultSetMapper().mapQuerySetToList(multiDBTransactionManager.getPrimaryConnection(), queryDatiCorrispettivo, DatiCorrispettiviDTO.class, OperationType.INSERT);
|
||||
|
||||
@@ -150,20 +153,16 @@ public class RegCorrispettivoService {
|
||||
corrispettiviDTO.setCastellettoIva(castellettoIva);
|
||||
}
|
||||
|
||||
// if (corrispettiviDTO.getCountScontrini() > 1 || stornaFatture ) {
|
||||
List<DatiCorrispettiviDTO.TipoIncasso> incassi = getIncassi(corrispettiviDTO, colName, contoContanti, stornaFatture);
|
||||
List<DatiCorrispettiviDTO.TipoIncasso> incassi = getIncassi(corrispettiviDTO, colName, contoContanti, stornaFatture);
|
||||
|
||||
|
||||
if (Stream.of(incassi).filter(x -> x.getCodCcon() == null).findFirst().isPresent()) {
|
||||
throw new Exception(
|
||||
String.format("Impossibile procedere, verificare se tutti i tipi incasso del punto vendita %s è stato assegnato il conto.",
|
||||
codMdep));
|
||||
}
|
||||
if (Stream.of(incassi).filter(x -> x.getCodCcon() == null).findFirst().isPresent()) {
|
||||
throw new Exception(
|
||||
String.format("Impossibile procedere, verificare se tutti i tipi incasso del punto vendita %s è stato assegnato il conto.",
|
||||
codMdep));
|
||||
}
|
||||
|
||||
corrispettiviDTO.setTipoIncasso(incassi);
|
||||
// } else {
|
||||
// corrispettiviDTO.setTipoIncasso(new ArrayList<>());
|
||||
// }
|
||||
corrispettiviDTO.setTipoIncasso(incassi);
|
||||
|
||||
}
|
||||
|
||||
@@ -174,12 +173,9 @@ public class RegCorrispettivoService {
|
||||
}
|
||||
|
||||
private List<DatiCorrispettiviDTO.CastellettoIva> getCastellettoIvaCorr(DatiCorrispettiviDTO corrispettiviDTO) throws Exception {
|
||||
PreparedStatement ps;
|
||||
ResultSet rs;
|
||||
boolean isIvaDaVentilare = "S".equalsIgnoreCase(corrispettiviDTO.getFlagIvaDaVentilare());
|
||||
List<DatiCorrispettiviDTO.CastellettoIva> castellettoIva = new ArrayList();
|
||||
|
||||
if (isIvaDaVentilare) {
|
||||
if (corrispettiviDTO.getFlagIvaDaVentilare()) {
|
||||
DatiCorrispettiviDTO.CastellettoIva iva = new DatiCorrispettiviDTO.CastellettoIva();
|
||||
|
||||
String query =
|
||||
@@ -235,12 +231,8 @@ public class RegCorrispettivoService {
|
||||
+ " dtb_tipi.flag_prz_iva, "
|
||||
+ " gtb_aliq.cod_ccon_ric ) tmp ";
|
||||
|
||||
ps = multiDBTransactionManager.prepareStatement(queryInfoIva);
|
||||
rs = ps.executeQuery();
|
||||
ResultSetMapper rsCastelletto = new ResultSetMapper();
|
||||
castellettoIva = rsCastelletto.mapResultSetToList(rs, DatiCorrispettiviDTO.CastellettoIva.class, OperationType.INSERT);
|
||||
rs.close();
|
||||
ps.close();
|
||||
castellettoIva = new ResultSetMapper().mapQuerySetToList(multiDBTransactionManager.getPrimaryConnection(), queryInfoIva, DatiCorrispettiviDTO.CastellettoIva.class, OperationType.INSERT);
|
||||
|
||||
}
|
||||
return castellettoIva;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user