Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
2024-06-19 17:29:59 +02:00

View File

@@ -851,29 +851,30 @@ public class SalesRules extends QueryRules {
public static Boolean checkArtPromoVendita(Connection conn, MtbLisvData entity) throws Exception {
Boolean ret = false;
String query =
Query.format(
"SELECT TOP 1 cod_promo, " +
"data_iniz, " +
"data_fine, " +
"versione " +
" FROM dbo.getPromozioneVendita(" + UtilityDB.valueDateToString(entity.getDataIniz(), CommonConstants.DATE_FORMAT_YMD) + ", "
+ UtilityDB.valueDateToString(entity.getDataFine(), CommonConstants.DATE_FORMAT_YMD) + ", "
+ UtilityDB.valueToString(entity.getCodVlis()) + ", null, "
+ UtilityDB.valueToString(entity.getCodMart()) + ") " +
" FROM dbo.getPromozioneVendita( %s, %s, %s , null, %s) " +
" WHERE tipo_variazione <> 'D' AND" +
" versione <> " + UtilityDB.valueToString(entity.getVersione());
" versione <> %s",
entity.getDataIniz(),
entity.getDataFine(),
entity.getCodVlis(),
entity.getCodMart(),
entity.getVersione()==null?0:entity.getVersione()
);
PreparedStatement ps = conn.prepareStatement(query);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
HashMap<String, Object> datiPromo = UtilityDB.executeSimpleQueryOnlyFirstRow(conn, query);
if (UtilityHashMap.isPresent(datiPromo)) {
String errorMessage =
"Impossibile salvare la promozione sul listino " + entity.getCodVlis() + ". " +
"Articolo " + entity.getCodMart() + " già presente nella promozione " +
rs.getString(1) +
" valida dal " + new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(rs.getDate(2)) +
" al " + new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(rs.getDate(3)) +
" versione " + rs.getString(4);
rs.close();
ps.close();
datiPromo.get("cod_promo") +
" valida dal " + new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(datiPromo.get("data_iniz")) +
" al " + new SimpleDateFormat(CommonConstants.DATE_FORMAT_DMY).format(datiPromo.get("data_fine")) +
" versione " + datiPromo.get("versione");
throw new Exception(errorMessage);
}