[Ordify] Inserito calcolo provigione in esportazione ordini
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
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.IntegryCustomerDB;
|
||||||
|
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||||
|
|
||||||
|
public class Migration_20240925105952 extends BaseMigration implements MigrationModelInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void up() throws Exception {
|
||||||
|
if (isHistoryDB())
|
||||||
|
return;
|
||||||
|
|
||||||
|
String value = null;
|
||||||
|
|
||||||
|
if (isCustomer(IntegryCustomer.SaporiVeri)){
|
||||||
|
value = "0.2";
|
||||||
|
}
|
||||||
|
|
||||||
|
createSetup("ORDIFY", "SETUP", "PERC_PROVVIGIONE", value,
|
||||||
|
"Percentuale di provvigione da applicare per ogni punto percentuale non applicato", false, null, false, false,
|
||||||
|
false, false, false, null, false, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void down() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -247,31 +247,7 @@ public class OrdiniImportService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<DtbOrdt> dtbOrdtList = new ArrayList<>(dtbOrdtMap.values());
|
List<DtbOrdt> dtbOrdtList = new ArrayList<>(dtbOrdtMap.values());
|
||||||
|
List<EntityBase> entityBases = entityProcessor.processEntityList(dtbOrdtList, multiDBTransactionManager, true);
|
||||||
List<EntityBase> entityBases = new ArrayList<>();
|
|
||||||
|
|
||||||
boolean isDeadLock;
|
|
||||||
|
|
||||||
do {
|
|
||||||
try {
|
|
||||||
entityBases = entityProcessor.processEntityList(dtbOrdtList, multiDBTransactionManager, true);
|
|
||||||
UtilityEntity.throwEntitiesException(entityBases);
|
|
||||||
} catch (Exception e) {
|
|
||||||
if (e instanceof EntityException) {
|
|
||||||
if (((EntityException) e).getSqlErrorCode() != null) {
|
|
||||||
if (((EntityException) e).getSqlErrorCode() == 1205) {
|
|
||||||
//deadlock
|
|
||||||
isDeadLock = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Exception(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
isDeadLock = false;
|
|
||||||
} while (isDeadLock);
|
|
||||||
|
|
||||||
String emailDestination = setup.get("EMAIL_FOR_LOG");
|
String emailDestination = setup.get("EMAIL_FOR_LOG");
|
||||||
if (!UtilityString.isNullOrEmpty(emailDestination)) {
|
if (!UtilityString.isNullOrEmpty(emailDestination)) {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static it.integry.ems.order.dto.UserGroupENUM.*;
|
import static it.integry.ems.order.dto.UserGroupENUM.*;
|
||||||
@@ -176,22 +177,30 @@ public class OrdifyService {
|
|||||||
throw new Exception("Codice articolo " + orderRow.getCodMart() + " inesistente. Ordine del cliente: " + ragSoc);
|
throw new Exception("Codice articolo " + orderRow.getCodMart() + " inesistente. Ordine del cliente: " + ragSoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
WdtbOrdr wdtbOrdr = new WdtbOrdr();
|
BigDecimal sconto = orderRow.getSconto5().add(orderRow.getSconto6());
|
||||||
|
BigDecimal percProv = setupGest.getSetupBigDecimal("ORDIFY", "SETUP", "PERC_PROVVIGIONE");
|
||||||
|
BigDecimal maxSconto = setupGest.getSetupBigDecimal("ORDIFY", "SETUP", "MAX_SCONTO");
|
||||||
|
|
||||||
|
BigDecimal prov = percProv == null || percProv.equals(BigDecimal.ZERO) ? null : maxSconto.subtract(sconto).multiply(percProv);
|
||||||
|
|
||||||
|
WdtbOrdr wdtbOrdr = new WdtbOrdr()
|
||||||
|
.setCodMart(orderRow.getCodMart())
|
||||||
|
.setUntOrd(orderRow.getUntOrd())
|
||||||
|
.setQtaOrd(orderRow.getQtaOrd())
|
||||||
|
.setSconto5(orderRow.getSconto5())
|
||||||
|
.setSconto6(orderRow.getSconto6())
|
||||||
|
.setSconto7(orderRow.getSconto7())
|
||||||
|
.setSconto8(orderRow.getSconto8())
|
||||||
|
.setPercProv(prov)
|
||||||
|
.setImportoRiga(orderRow.getImporto())
|
||||||
|
.setValUnt(orderRow.getValUnt())
|
||||||
|
.setNote(orderRow.getNote())
|
||||||
|
.setQtaOmg(orderRow.getQtaOmg())
|
||||||
|
.setQtaReso(orderRow.getQtaReso())
|
||||||
|
.setCodPromo(orderRow.getCodPromo())
|
||||||
|
.setDataCons(dataCons);
|
||||||
|
|
||||||
wdtbOrdr.setOperation(OperationType.INSERT);
|
wdtbOrdr.setOperation(OperationType.INSERT);
|
||||||
wdtbOrdr.setCodMart(orderRow.getCodMart());
|
|
||||||
wdtbOrdr.setUntOrd(orderRow.getUntOrd());
|
|
||||||
wdtbOrdr.setQtaOrd(orderRow.getQtaOrd());
|
|
||||||
wdtbOrdr.setSconto5(orderRow.getSconto5());
|
|
||||||
wdtbOrdr.setSconto6(orderRow.getSconto6());
|
|
||||||
wdtbOrdr.setSconto7(orderRow.getSconto7());
|
|
||||||
wdtbOrdr.setSconto8(orderRow.getSconto8());
|
|
||||||
wdtbOrdr.setImportoRiga(orderRow.getImporto());
|
|
||||||
wdtbOrdr.setValUnt(orderRow.getValUnt());
|
|
||||||
wdtbOrdr.setNote(orderRow.getNote());
|
|
||||||
wdtbOrdr.setQtaOmg(orderRow.getQtaOmg());
|
|
||||||
wdtbOrdr.setQtaReso(orderRow.getQtaReso());
|
|
||||||
wdtbOrdr.setCodPromo(orderRow.getCodPromo());
|
|
||||||
wdtbOrdr.setDataCons(dataCons);
|
|
||||||
|
|
||||||
orderRowList.add(wdtbOrdr);
|
orderRowList.add(wdtbOrdr);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user