Finish Hotfix-100
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:
@@ -791,35 +791,6 @@ public class AccountingRules extends QueryRules {
|
||||
return ctbAnag;
|
||||
}
|
||||
|
||||
public static String completeFlagRegAccDist(Connection connection, VtbDistIncar entity) throws Exception {
|
||||
Date dataPrevistaFat = null;
|
||||
String flagRegAcc = "S", metodoFatturazione = "";
|
||||
|
||||
String sql = "SELECT flag_tipo_fatturazione FROM azienda ";
|
||||
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
if (rs.next()) {
|
||||
metodoFatturazione = rs.getString(1);
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
if (UtilityString.isNullOrEmpty(metodoFatturazione) == true) {
|
||||
flagRegAcc = "S";
|
||||
} else if ("M".equals(metodoFatturazione)) {
|
||||
dataPrevistaFat = (Date) getSingleValue(connection, "select dbo.f_getLastDayOfMonth(" + UtilityDB.valueDateToString(entity.getDataDoc(), CommonConstants.DATE_FORMAT_YMD) + ")");
|
||||
} else if ("Q".equals(metodoFatturazione)) {
|
||||
dataPrevistaFat = (Date) getSingleValue(connection, "select dateadd(day, 14, dbo.f_getFirstDayOfMonth(" + UtilityDB.valueDateToString(entity.getDataDoc(), CommonConstants.DATE_FORMAT_YMD) + ")");
|
||||
}
|
||||
if (dataPrevistaFat == null) {
|
||||
flagRegAcc = "S";
|
||||
} else if (UtilityString.isNullOrEmpty(metodoFatturazione) == false && entity.getDataDist().after(dataPrevistaFat)) {
|
||||
flagRegAcc = "N";
|
||||
}
|
||||
|
||||
return flagRegAcc;
|
||||
}
|
||||
|
||||
public static void completeIdRigaScad(Connection conn, CtbScad ctbScad) throws Exception {
|
||||
if (ctbScad.getParent() != null && ctbScad.getParent() instanceof CtbPart) return;
|
||||
String sql =
|
||||
|
||||
@@ -1091,16 +1091,28 @@ public class CommonRules extends QueryRules {
|
||||
"SELECT prevista_fat FROM dtb_tipi WHERE cod_dtip = " + UtilityDB.valueToString(vtbDistIncar.getCodDtip());
|
||||
String previstaFat = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
|
||||
if (UtilityString.streNull(vtbDistIncar.getFlagTipoFatturazione()).equals("M") && previstaFat.equals("S")) {
|
||||
sql =
|
||||
"SELECT dbo.f_getLastDayOfMonth ( " + UtilityDB.valueDateToString(vtbDistIncar.getDataDoc(), CommonConstants.DATE_FORMAT_YMD) + ")";
|
||||
|
||||
Date dataFattura = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
|
||||
if (vtbDistIncar.getDataDoc().compareTo(dataFattura) < 0 && vtbDistIncar.getDataDist().compareTo(dataFattura) >= 0) {
|
||||
if (previstaFat.equalsIgnoreCase("N")) {
|
||||
flagRegAcc = "N";
|
||||
} else if (!UtilityString.isNullOrEmpty(vtbDistIncar.getFlagTipoFatturazione())) {
|
||||
LocalDate dataFattura = null;
|
||||
int year = UtilityDate.getYear(vtbDistIncar.getDataDoc());
|
||||
int month = UtilityDate.datePart(Calendar.MONTH, vtbDistIncar.getDataDoc());
|
||||
switch (vtbDistIncar.getFlagTipoFatturazione()) {
|
||||
case "M":
|
||||
dataFattura = UtilityLocalDate.getLastDayOfMonth(year, month);
|
||||
break;
|
||||
case "Q":
|
||||
dataFattura = UtilityLocalDate.dateFromPart(year, month, 15);
|
||||
break;
|
||||
}
|
||||
|
||||
LocalDate dataDoc = UtilityLocalDate.localDateFromDate(vtbDistIncar.getDataDoc());
|
||||
LocalDate dataDist = UtilityLocalDate.localDateFromDate(vtbDistIncar.getDataDist());
|
||||
|
||||
if ((dataDoc.equals(dataFattura) || dataDoc.isBefore(dataFattura)) &&
|
||||
(dataDist.equals(dataFattura) || dataDist.isAfter(dataFattura))) {
|
||||
flagRegAcc = "N";
|
||||
}
|
||||
}
|
||||
return flagRegAcc;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class DroolsDataCompleting {
|
||||
"LisV.drl", "retail.drl", "logistic.drl",
|
||||
"contabilita.drl", "config_activity.drl", "anag.drl", "DocV.drl",
|
||||
"documenti.drl", "LisA.drl", "OrdA.drl", "OrdV.drl", "DocWebA.drl",
|
||||
"DocWebV.drl", "Utenti.drl", "vendite.drl",
|
||||
"DocWebV.drl", "Utenti.drl", "vendite.drl", "distinte.drl",
|
||||
"DocA.drl", "post_calc.drl", "check_cond.drl",
|
||||
"OrdL.drl", "docOrd.drl",
|
||||
"OrdP.drl", "DocL.drl", "LottiProd.drl", "Agenti.drl",
|
||||
|
||||
@@ -256,6 +256,9 @@ public class UtilityDate {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
int partOfDate = calendar.get(datepart);
|
||||
if ( datepart == Calendar.MONTH) {
|
||||
partOfDate++;
|
||||
}
|
||||
return partOfDate;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package it.integry.ems_model.utility;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -23,6 +20,14 @@ public class UtilityLocalDate {
|
||||
} else return null;
|
||||
}
|
||||
|
||||
public static LocalDate getLastDayOfMonth(int year, int month) {
|
||||
YearMonth yearMonth = YearMonth.of(year, month);
|
||||
return yearMonth.atEndOfMonth();
|
||||
}
|
||||
|
||||
public static LocalDate dateFromPart(int year, int month, int day) {
|
||||
return LocalDate.of(year, month, day);
|
||||
}
|
||||
|
||||
public static String formatDate(LocalDateTime dateToFormat, String format) {
|
||||
if (dateToFormat != null) {
|
||||
|
||||
@@ -701,16 +701,6 @@ then
|
||||
modify ( $entity ) { setCtbAnag(ctbAnag)}
|
||||
end
|
||||
|
||||
rule "completeFlagRegAccDist"
|
||||
no-loop
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$entity : VtbDistIncar(dataDoc != null && dataDist != null && flagRegAcc == null)
|
||||
then
|
||||
String flagRegAccDist = AccountingRules.completeFlagRegAccDist(conn, $entity);
|
||||
modify ( $entity ) { setFlagRegAcc(flagRegAccDist)}
|
||||
end
|
||||
|
||||
rule "completeScadenzeRitAcc"
|
||||
no-loop
|
||||
when
|
||||
|
||||
87
ems-core/src/main/resources/rules/distinte.drl
Normal file
87
ems-core/src/main/resources/rules/distinte.drl
Normal file
@@ -0,0 +1,87 @@
|
||||
package it.integry.rules
|
||||
|
||||
import java.math.*
|
||||
import java.util.*
|
||||
import it.integry.ems_model.entity.*
|
||||
import it.integry.ems_model.base.EntityBase
|
||||
import it.integry.ems.rules.util.*
|
||||
import it.integry.ems.rules.completing.*
|
||||
import it.integry.ems_model.utility.UtilityDB
|
||||
import it.integry.ems_model.types.OperationType
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
|
||||
global Connection conn
|
||||
global String username
|
||||
global Boolean postRulesEnabled
|
||||
global Boolean checkRulesEnabled
|
||||
global Boolean completeRulesEnabled
|
||||
|
||||
rule "completeNumDist"
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$vtbDistIncat : VtbDistIncat((numDist == null || numDist == 0) && dataDist != null )
|
||||
|
||||
then
|
||||
Integer numDist = CommonRules.completeNumDist(conn, $vtbDistIncat);
|
||||
modify ( $vtbDistIncat ) { setNumDist(numDist) }
|
||||
end
|
||||
|
||||
rule "completeDescrizPagaDistinta"
|
||||
no-loop
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$vtbDistIncar : VtbDistIncar(descrizPaga == null && codPaga != null)
|
||||
then
|
||||
String sql = "SELECT descrizione FROM gtb_paga WHERE cod_paga = " + UtilityDB.valueToString($vtbDistIncar.getCodPaga());
|
||||
String descrPaga = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
|
||||
modify($vtbDistIncar){
|
||||
setDescrizPaga(descrPaga)
|
||||
}
|
||||
end
|
||||
|
||||
rule "completeRegistratoDaVtbDistIncat"
|
||||
no-loop
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$vtbDistIncat : VtbDistIncat(registratoDa == null && operation != OperationType.DELETE && operation != OperationType.UPDATE )
|
||||
then
|
||||
String fullName = CommonRules.getFullName(conn, username);
|
||||
modify($vtbDistIncat){
|
||||
setRegistratoDa(fullName),
|
||||
setDataReg($vtbDistIncat.getDataReg()==null?new Date():$vtbDistIncat.getDataReg())
|
||||
}
|
||||
end
|
||||
|
||||
rule "completeCompilatoDaVtbDistIncar"
|
||||
no-loop
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$vtbDistIncar : VtbDistIncar(compilatoDa == null && operation != OperationType.DELETE && operation != OperationType.UPDATE )
|
||||
then
|
||||
String fullName = CommonRules.getFullName(conn, username);
|
||||
modify($vtbDistIncar){
|
||||
setCompilatoDa(fullName)
|
||||
}
|
||||
end
|
||||
|
||||
rule "completeFlagTipoFatturazione"
|
||||
no-loop
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$vtbDistIncar : VtbDistIncar( flagTipoFatturazione == null )
|
||||
then
|
||||
String sql = "SELECT flag_tipo_fatturazione FROM azienda";
|
||||
String flagTipoFatturazione = (String) QueryRules.getSingleValue(conn, sql);
|
||||
modify ( $vtbDistIncar ) { setFlagTipoFatturazione(flagTipoFatturazione) }
|
||||
end
|
||||
|
||||
rule "completeFlagRegAcc"
|
||||
no-loop
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$vtbDistIncar : VtbDistIncar( dataDoc != null )
|
||||
then
|
||||
String flagRegAcc = CommonRules.completeFlagRegAcc(conn, $vtbDistIncar);
|
||||
modify ( $vtbDistIncar ) { setFlagRegAcc(flagRegAcc) }
|
||||
end
|
||||
@@ -16,98 +16,6 @@ global Boolean postRulesEnabled
|
||||
global Boolean checkRulesEnabled
|
||||
global Boolean completeRulesEnabled
|
||||
|
||||
rule "completeNumDist"
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$vtbDistIncat : VtbDistIncat((numDist == null || numDist == 0) && dataDist != null )
|
||||
|
||||
then
|
||||
Integer numDist = CommonRules.completeNumDist(conn, $vtbDistIncat);
|
||||
modify ( $vtbDistIncat ) { setNumDist(numDist) }
|
||||
end
|
||||
|
||||
rule "completeDescrizPagaDistinta"
|
||||
no-loop
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$vtbDistIncar : VtbDistIncar(descrizPaga == null && codPaga != null)
|
||||
then
|
||||
String sql = "SELECT descrizione FROM gtb_paga WHERE cod_paga = " + UtilityDB.valueToString($vtbDistIncar.getCodPaga());
|
||||
String descrPaga = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
|
||||
modify($vtbDistIncar){
|
||||
setDescrizPaga(descrPaga)
|
||||
}
|
||||
end
|
||||
|
||||
rule "completeRegistratoDaVtbDistIncat"
|
||||
no-loop
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$vtbDistIncat : VtbDistIncat(registratoDa == null && operation != OperationType.DELETE && operation != OperationType.UPDATE )
|
||||
then
|
||||
String fullName = CommonRules.getFullName(conn, username);
|
||||
modify($vtbDistIncat){
|
||||
setRegistratoDa(fullName),
|
||||
setDataReg($vtbDistIncat.getDataReg()==null?new Date():$vtbDistIncat.getDataReg())
|
||||
}
|
||||
end
|
||||
|
||||
rule "completeCompilatoDaVtbDistIncar"
|
||||
no-loop
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$vtbDistIncar : VtbDistIncar(compilatoDa == null && operation != OperationType.DELETE && operation != OperationType.UPDATE )
|
||||
then
|
||||
String fullName = CommonRules.getFullName(conn, username);
|
||||
modify($vtbDistIncar){
|
||||
setCompilatoDa(fullName)
|
||||
}
|
||||
end
|
||||
|
||||
rule "completeFlagTipoFatturazione"
|
||||
no-loop
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$vtbDistIncar : VtbDistIncar( flagTipoFatturazione == null )
|
||||
then
|
||||
String sql = "SELECT flag_tipo_fatturazione FROM azienda";
|
||||
String flagTipoFatturazione = (String) QueryRules.getSingleValue(conn, sql);
|
||||
modify ( $vtbDistIncar ) { setFlagTipoFatturazione(flagTipoFatturazione) }
|
||||
end
|
||||
|
||||
rule "completeFlagRegAcc"
|
||||
no-loop
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$vtbDistIncar : VtbDistIncar( ( flagRegAcc == null || flagRegAcc == "S" ))
|
||||
then
|
||||
String flagRegAcc = CommonRules.completeFlagRegAcc(conn, $vtbDistIncar);
|
||||
modify ( $vtbDistIncar ) { setFlagRegAcc(flagRegAcc) }
|
||||
end
|
||||
|
||||
rule "completeIdRilPrz"
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$entity : VtbRilPrzt(idRil == null || idRil == 0)
|
||||
then
|
||||
Integer idRil = CommonRules.completeIdRilPrz(conn, $entity.getDataRil());
|
||||
modify ( $entity ) { setIdRil(idRil) }
|
||||
end
|
||||
|
||||
rule "completeDataInsRilPrz"
|
||||
when
|
||||
eval(completeRulesEnabled)
|
||||
$entity : VtbRilPrzt(dataIns == null)
|
||||
then
|
||||
modify ( $entity ) {
|
||||
setDataIns(new Date()),
|
||||
setCompilatoDa(username),
|
||||
setDataUltMod(new Date()),
|
||||
setModificatoDa(username)
|
||||
}
|
||||
end
|
||||
|
||||
rule "completeDataUltModRilPrz"
|
||||
no-loop
|
||||
when
|
||||
|
||||
@@ -73,7 +73,7 @@ public class DistinteIncassiService {
|
||||
|
||||
boolean existBolleDaFatt = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
if (existBolleDaFatt) {
|
||||
new Exception("Impossibile registrare in contabilità la distinta n° " + numDist + " del " + new SimpleDateFormat("dd/MM/yyyy").format(dataDist) + "." +
|
||||
throw new Exception("Impossibile registrare in contabilità la distinta n° " + numDist + " del " + new SimpleDateFormat("dd/MM/yyyy").format(dataDist) + "." +
|
||||
"Ci sono dei documenti di trasporto non ancora fatturati.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user