Gestione incassi PUDDY e importazione ordini
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:
@@ -0,0 +1,27 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
|
||||
public class Migration_20250320181355 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB())
|
||||
return;
|
||||
|
||||
if (!isCustomerDb(IntegryCustomerDB.Salpar_MasabaSrl))
|
||||
return;
|
||||
|
||||
createSetup("IMPORT_ORDINI", "PUDDY", "COD_ALIQ_IVA_OMG", "051",
|
||||
"Codice aliquota iva omaggio", false, null, false, false,
|
||||
false, false, false, null, false, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -584,8 +584,10 @@ public class PuddyService {
|
||||
|
||||
String gestioneScontofreschezza = UtilityString.streNull(setupGest.getSetup(conn, "W_MLUPDSRV_CONFIG_DLG", "SETUP", "GESTIONE_SCONTO_FRESCHEZZA"));
|
||||
String profileDBVG = setupGest.getSetup("IMPORT_ORDINI", "PUDDY", "PROFILE_DB_VG");
|
||||
String codAliqOmg = setupGest.getSetup("IMPORT_ORDINI", "PUDDY", "COD_ALIQ_IVA_OMG");
|
||||
String profileDB = multiDBTransactionManager.getPrimaryDatasource().getProfile();
|
||||
|
||||
|
||||
// Creazione condizione di where righe ordine
|
||||
String condWhereRigheOrdine =
|
||||
" x_puddy3_prev_ordini.flag_elaborato = 'N' AND " +
|
||||
@@ -675,23 +677,28 @@ public class PuddyService {
|
||||
" ,x_puddy3_prev_ordini.data_cons" +
|
||||
" ,x_puddy3_prev_ordini.partita_mag" +
|
||||
" ,x_puddy3_prev_agenti_info.deposito " +
|
||||
" ,x_puddy3_prev_ordini.sconto1 " +
|
||||
" ,x_puddy3_prev_ordini.sconto2 " +
|
||||
" ,x_puddy3_prev_ordini.sconto3 " +
|
||||
" ,x_puddy3_prev_ordini.sconto4 " +
|
||||
" ,case when x_puddy3_prev_ordini.sconto1 = 99 then 100 else x_puddy3_prev_ordini.sconto1 end " +
|
||||
" ,case when x_puddy3_prev_ordini.sconto2 = 99 then 100 else x_puddy3_prev_ordini.sconto2 end " +
|
||||
" ,case when x_puddy3_prev_ordini.sconto3 = 99 then 100 else x_puddy3_prev_ordini.sconto3 end " +
|
||||
" ,case when x_puddy3_prev_ordini.sconto4 = 99 then 100 else x_puddy3_prev_ordini.sconto4 end " +
|
||||
" ,case when x_puddy3_prev_ordini.cod_promo IS NOT NULL AND substring(x_puddy3_prev_ordini.cod_promo, 1, 2) <> 'SE' then x_puddy3_prev_ordini.cod_promo else replace(x_puddy3_prev_ordini.cod_promo, 'SE', '20') end as cod_promo " +
|
||||
" ,x_puddy3_prev_intercode_clienti_VG.cod_anag_vg, " +
|
||||
" ,x_puddy3_prev_intercode_clienti_VG.cod_vdes_vg " +
|
||||
" ,x_puddy3_prev_agenti.cod_vage_vg " +
|
||||
" ,case when x_puddy3_prev_griglie_art_vg.cod_mart is null then 'SEVENBAR' else 'VG' end as azienda " +
|
||||
" ,x_puddy3_prev_agenti.serie_vg " +
|
||||
" ,vtb_promo.cod_aliq " +
|
||||
" ,mtb_aart.cod_aliq " +
|
||||
" FROM x_puddy3_prev_ordini left outer join x_puddy3_prev_intercode_clienti_VG on x_puddy3_prev_ordini.cod_anag = x_puddy3_prev_intercode_clienti_VG.cod_anag and " +
|
||||
" x_puddy3_prev_ordini.cod_vdes = x_puddy3_prev_intercode_clienti_VG.cod_vdes " +
|
||||
" left outer join on x_puddy3_prev_ordini.cod_mart = x_puddy3_prev_griglie_art_vg.cod_mart , " +
|
||||
" left outer join on x_puddy3_prev_ordini.cod_mart = x_puddy3_prev_griglie_art_vg.cod_mart " +
|
||||
" left outer join vtb_promo on x_puddy3_prev_ordini.cod_promo = vtb_promo.cod_promo" +
|
||||
" left outer join mtb_aart on x_puddy3_prev_ordini.cod_mart = mtb_aart.cod_mart , " +
|
||||
" vtb_clie, " +
|
||||
" x_puddy3_prev_agenti_info inner join x_puddy3_prev_intercode_agenti_VG on x_puddy3_prev_agenti_info.CodAgente = x_puddy3_prev_intercode_agenti_VG.cod_vage " +
|
||||
" inner join x_puddy3_prev_agenti on x_puddy3_prev_intercode_agenti_VG.cod_vage = x_puddy3_prev_agenti.CodAgente " +
|
||||
" mtb_aart_anag " +
|
||||
" mtb_aart_anag, " +
|
||||
" azienda " +
|
||||
"WHERE x_puddy3_prev_ordini.cod_anag = vtb_clie.cod_anag AND " +
|
||||
" x_puddy3_prev_agenti_info.codAgente = x_puddy3_prev_ordini.cod_vage AND " +
|
||||
" mtb_aart_anag.cod_mart = x_puddy3_prev_ordini.cod_mart AND " +
|
||||
@@ -711,19 +718,23 @@ public class PuddyService {
|
||||
" ,x_puddy3_prev_ordini.data_cons" +
|
||||
" ,x_puddy3_prev_ordini.partita_mag" +
|
||||
" ,x_puddy3_prev_agenti_info.deposito " +
|
||||
" ,x_puddy3_prev_ordini.sconto1 " +
|
||||
" ,x_puddy3_prev_ordini.sconto2 " +
|
||||
" ,x_puddy3_prev_ordini.sconto3 " +
|
||||
" ,x_puddy3_prev_ordini.sconto4 " +
|
||||
" ,case when x_puddy3_prev_ordini.sconto1 = 99 then 100 else x_puddy3_prev_ordini.sconto1 end " +
|
||||
" ,case when x_puddy3_prev_ordini.sconto2 = 99 then 100 else x_puddy3_prev_ordini.sconto2 end " +
|
||||
" ,case when x_puddy3_prev_ordini.sconto3 = 99 then 100 else x_puddy3_prev_ordini.sconto3 end " +
|
||||
" ,case when x_puddy3_prev_ordini.sconto4 = 99 then 100 else x_puddy3_prev_ordini.sconto4 end " +
|
||||
" ,case when x_puddy3_prev_ordini.cod_promo IS NOT NULL AND substring(x_puddy3_prev_ordini.cod_promo, 1, 2) <>'SE' then x_puddy3_prev_ordini.cod_promo else replace(x_puddy3_prev_ordini.cod_promo, 'SE', '20') end as cod_promo " +
|
||||
" ,x_puddy3_prev_intercode_clienti_VG.cod_anag_vg " +
|
||||
" ,x_puddy3_prev_intercode_clienti_VG.cod_vdes_vg " +
|
||||
" ,x_puddy3_prev_agenti.cod_vage_vg " +
|
||||
" ,case when x_puddy3_prev_griglie_art_vg.cod_mart is null then 'SEVENBAR' else 'VG' end as azienda " +
|
||||
" ,x_puddy3_prev_agenti.serie_vg " +
|
||||
" ,vtb_promo.cod_aliq " +
|
||||
" ,mtb_aart.cod_aliq " +
|
||||
" FROM x_puddy3_prev_ordini left outer join x_puddy3_prev_intercode_clienti_VG on x_puddy3_prev_ordini.cod_anag = x_puddy3_prev_intercode_clienti_VG.cod_anag and " +
|
||||
" x_puddy3_prev_ordini.cod_vdes = x_puddy3_prev_intercode_clienti_VG.cod_vdes " +
|
||||
" left outer join x_puddy3_prev_griglie_art_vg on x_puddy3_prev_ordini.cod_mart = x_puddy3_prev_griglie_art_vg.cod_mart , " +
|
||||
" left outer join x_puddy3_prev_griglie_art_vg on x_puddy3_prev_ordini.cod_mart = x_puddy3_prev_griglie_art_vg.cod_mart " +
|
||||
" left outer join vtb_promo on x_puddy3_prev_ordini.cod_promo = vtb_promo.cod_promo" +
|
||||
" left outer join mtb_aart on x_puddy3_prev_ordini.cod_mart = mtb_aart.cod_mart , " +
|
||||
" vtb_clie, " +
|
||||
" x_puddy3_prev_agenti_info inner join x_puddy3_prev_intercode_agenti_VG on x_puddy3_prev_agenti_info.CodAgente = x_puddy3_prev_intercode_agenti_VG.cod_vage " +
|
||||
" inner join x_puddy3_prev_agenti on x_puddy3_prev_intercode_agenti_VG.cod_vage = x_puddy3_prev_agenti.CodAgente " +
|
||||
@@ -759,6 +770,8 @@ public class PuddyService {
|
||||
codVageVG = res.getString(21);
|
||||
azienda = res.getString(22);
|
||||
serieVG = res.getString(23);
|
||||
String codAliqPromo = res.getString(24);
|
||||
String codAliqArt = res.getString(25);
|
||||
i++;
|
||||
|
||||
// Se si tratta di un cliente non presente in VG allora viene letto il codice cliente nuovo fittizio dell'agente
|
||||
@@ -819,6 +832,7 @@ public class PuddyService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Inserimento righe ordine
|
||||
ordR = new DtbOrdr();
|
||||
ordR.setCodMart(codMart);
|
||||
@@ -835,15 +849,28 @@ public class PuddyService {
|
||||
/*OMAGGIO*/
|
||||
ordR.setQtaOrd(qtaOmg);
|
||||
ordR.setSconto5(scontoMerce);
|
||||
|
||||
// Se si tratta di un cliente servito in TD allora sulla riga dell'omaggio va messo il codice aliquota
|
||||
// dell'articolo altrimenti il codice esenzione specificato sulla promozione
|
||||
if ("N".equals(flagTD) ) {
|
||||
ordR.setCodAliq(codAliqPromo);
|
||||
if (codAliqPromo == null){ordR.setCodAliq(codAliqOmg);}
|
||||
} else {
|
||||
ordR.setCodAliq(codAliqArt);
|
||||
}
|
||||
} else if (qtaResi.compareTo(BigDecimal.ZERO) != 0 && "O".equals(flagTipoReso)) {
|
||||
/*OMAGGIO RESO*/
|
||||
ordR.setSconto5(cambioMerce);
|
||||
ordR.setQtaOrd(qtaResi);
|
||||
ordR.setCodAliq(codAliqPromo);
|
||||
if (codAliqPromo == null){ordR.setCodAliq(codAliqOmg);}
|
||||
} else if (qtaResi.compareTo(BigDecimal.ZERO) != 0 && "C".equals(flagTipoReso)) {
|
||||
/*SCONTO FRESCHEZZA*/
|
||||
ordR.setQtaOrd(qtaResi);
|
||||
ordR.setCodAliq(null);
|
||||
ordR.setSconto8(scontoFreschezza);
|
||||
ordR.setCodAliq(codAliqPromo);
|
||||
if (codAliqPromo == null){ordR.setCodAliq(codAliqOmg);}
|
||||
|
||||
if (gestioneScontofreschezza.equals("S")) {
|
||||
sql = "SELECT TOP 1 round(importo_riga / qta_doc, 5) " +
|
||||
@@ -929,7 +956,9 @@ public class PuddyService {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
multiDBTransactionManagerVG.rollbackAll();
|
||||
|
||||
|
||||
if (azienda == null){
|
||||
azienda = profileDB;
|
||||
}
|
||||
List.setEsito(EsitoType.KO);
|
||||
List.setErrorMessage("Errore durante l'importazione dell'ordine di vendita provvisorio N." + numOrdProv + " serie " + serieOrd + " per l'agente " + codVage + " nel database " + azienda + CommonConstants.A_CAPO + CommonConstants.A_CAPO + e.getMessage());
|
||||
return List;
|
||||
@@ -1138,7 +1167,7 @@ public class PuddyService {
|
||||
for (int i = 0; i < datiDistintaPuddy.size(); i++) {
|
||||
DistintaIncassiPrevPuddyDTO datoDistinta = datiDistintaPuddy.get(i);
|
||||
|
||||
if (i == 1) {
|
||||
if (i == 0) {
|
||||
vtbDistIncat.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
vtbDistIncat.setDataDist(dataIncasso);
|
||||
vtbDistIncat.setNumDist(numDistinta);
|
||||
|
||||
Reference in New Issue
Block a user