677 lines
21 KiB
Plaintext
677 lines
21 KiB
Plaintext
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.completing.*
|
|
import it.integry.ems.rules.util.*
|
|
import java.text.*
|
|
import java.sql.Connection
|
|
import it.integry.ems_model.types.OperationType
|
|
import it.integry.ems.utility.UtilityLogger
|
|
import it.integry.ems.utility.UtilityEntity
|
|
import it.integry.ems_model.utility.UtilityHashMap
|
|
import it.integry.ems_model.utility.UtilityDate
|
|
|
|
global Connection conn
|
|
global String username
|
|
global Boolean postRulesEnabled
|
|
global Boolean checkRulesEnabled
|
|
global Boolean completeRulesEnabled
|
|
|
|
//MOVIMENTI
|
|
|
|
//TESTATE
|
|
rule "completeAzioneSuPartita"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovr(codCcau != null && azioneSuPartita == null)
|
|
then
|
|
String sql = "SELECT azione_su_partita FROM ctb_caus WHERE cod_ccau = '" + $entity.getCodCcau() + "'";
|
|
Integer azioneSuPartita = (Integer) QueryRules.getSingleValue(conn, sql);
|
|
modify ( $entity ) { setAzioneSuPartita(azioneSuPartita) }
|
|
end
|
|
|
|
|
|
rule "completeTipoAnagMov"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovr(codCcon != null && codAnag != null && tipoAnag == null )
|
|
then
|
|
String sql = "SELECT ctb_tipo_riep.tipo_anag " +
|
|
"FROM ctb_cont "+
|
|
" INNER JOIN ctb_tipo_riep ON ctb_cont.tipo_riep = ctb_tipo_riep.tipo_riep "+
|
|
"WHERE ctb_cont.cod_ccon = '" + $entity.getCodCcon() + "'";
|
|
String tipoAnag = (String) QueryRules.getSingleValue(conn, sql);
|
|
modify ( $entity ) { setTipoAnag(tipoAnag) }
|
|
end
|
|
|
|
rule "completeNumIreg"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovt(numIreg == null && codIreg != null)
|
|
then
|
|
Integer numIreg = AccountingRules.completeNumIreg(conn, $entity.getCodIreg());
|
|
modify ( $entity ) { setNumIreg(numIreg) }
|
|
end
|
|
|
|
rule "completeNumCmov"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovt((numCmov == null || numCmov == 0) && annoComp != null)
|
|
then
|
|
Integer numCmov = AccountingRules.completeNumCmov(conn, $entity);
|
|
modify ( $entity ) { setNumCmov(numCmov) }
|
|
end
|
|
|
|
rule "completeNumProt"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovt((operation == OperationType.INSERT ||operation == OperationType.INSERT_OR_UPDATE || operation == OperationType.DELETE_THEN_INSERT ) && codIreg != null && numIreg != null && annoComp != null && tipoNumerazione == "IMMEDIATA")
|
|
then
|
|
Integer numProt = AccountingRules.completeNumProt(conn, $entity);
|
|
modify ( $entity ) { setNumProt(numProt) }
|
|
end
|
|
|
|
rule "completeAnnoComp"
|
|
salience 1
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovt(annoComp == null)
|
|
then
|
|
Integer anno = AccountingRules.getAnnoComp( conn, $entity.getDataCmov());
|
|
modify ( $entity ) { setAnnoComp(anno) }
|
|
end
|
|
|
|
rule "completeCodBiva"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovt(codAnag != null && tipoAnag != null && (tipoAnag == "F" || isAutofattura == "S") && ctbMovi.size() > 0 )
|
|
then
|
|
List<CtbMovi> movi = AccountingRules.completeCodBivaCtbMovi(conn, $entity);
|
|
modify ( $entity ) { setCtbMovi(movi) }
|
|
end
|
|
|
|
rule "completeDatiCausale"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovt((descrizioneCaus == null || codIreg == null || tipoAnag == null || codCcauRc == null ) && codCcau != null)
|
|
then
|
|
HashMap<String, Object>dati = AccountingRules.completeDatiCausale(conn, $entity);
|
|
modify ( $entity )
|
|
{
|
|
setDescrizioneCaus(dati.get("descrizioneCaus").toString() ),
|
|
setCodIreg(dati.get("codIreg") == null ? null : dati.get("codIreg").toString()),
|
|
setTipoAnag(dati.get("tipoAnag") == null ? null : dati.get("tipoAnag").toString() ),
|
|
setCodCcauRc(dati.get("codCcauRc") == null ? null : dati.get("codCcauRc").toString())
|
|
}
|
|
end
|
|
|
|
rule "completeDataRicezione"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovt(dataRicezione == null && crlMovAttached.size() > 0 )
|
|
then
|
|
Date date = AccountingRules.completeDataRicezione(conn, $entity);
|
|
modify ( $entity )
|
|
{
|
|
setDataRicezione(date)
|
|
}
|
|
end
|
|
|
|
rule "completeDataCompIva"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovt(dataCompIva == null && codIreg != null)
|
|
then
|
|
Date dataCompIva = AccountingRules.completeDataCompIva(conn, $entity);
|
|
modify ( $entity )
|
|
{
|
|
setDataCompIva(dataCompIva)
|
|
}
|
|
end
|
|
|
|
rule "completeCodJfasMov"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovr(codJfas == null && codCcon != null)
|
|
then
|
|
String codJfas= AccountingRules.completeCodJfas(conn, $entity.getCodCcon());
|
|
modify ( $entity ) { setCodJfas(codJfas) }
|
|
end
|
|
|
|
rule "completeCodCcauMov"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovr(codCcau == null && ((CtbMovt) $entity.getParent()).getCodCcau() != null)
|
|
then
|
|
modify ( $entity ) { setCodCcau(((CtbMovt) $entity.getParent()).getCodCcau()) }
|
|
end
|
|
|
|
// MOVIMENTI IVA
|
|
rule "completeCifreDecDiviCont"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovi(cifreDecDiviCont == null && codDiviCont != null)
|
|
then
|
|
Integer cifreDecDiviCont = CommonRules.completeCifreDecDiviCont(conn, $entity.getCodDiviCont());
|
|
modify ( $entity ) { setCifreDecDiviCont(cifreDecDiviCont) }
|
|
end
|
|
|
|
rule "completeImposta"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovi(imposta == null && imponibile != null && codAliq != null && cifreDecDiviCont != null && codAliq != null)
|
|
then
|
|
HashMap<String, BigDecimal> dati = AccountingRules.completeImpostaImponibile(conn, $entity);
|
|
BigDecimal imposta = UtilityHashMap.getValueIfExists(dati, "imposta");
|
|
BigDecimal imponibile = UtilityHashMap.getValueIfExists(dati, "imponibile");
|
|
|
|
modify($entity){
|
|
setImposta(imposta)
|
|
}
|
|
end
|
|
|
|
rule "completeImpostaImponibile"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovi((imposta == null && imponibile == null ) && cifreDecDiviCont != null && codAliq != null)
|
|
then
|
|
HashMap<String, BigDecimal> dati = AccountingRules.completeImpostaImponibile(conn, $entity);
|
|
BigDecimal imposta = UtilityHashMap.getValueIfExists(dati, "imposta");
|
|
BigDecimal imponibile = UtilityHashMap.getValueIfExists(dati, "imponibile");
|
|
|
|
modify($entity){
|
|
setImposta(imposta),
|
|
setImponibile(imponibile)
|
|
}
|
|
end
|
|
|
|
rule "completeFlagReverseCharge"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovi(flagReverseCharge == null && codAliq != null )
|
|
then
|
|
String flagReverseCharge = AccountingRules.completeFlagReverseCharge(conn, $entity.getCodAliq());
|
|
modify ( $entity ) { setFlagReverseCharge(flagReverseCharge) }
|
|
end
|
|
|
|
rule "completeCtbMovrCoan"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovr((ctbMovrCoan == null || ctbMovrCoan.size() == 0) && (tipo == "5" || tipo == "4"))
|
|
then
|
|
List<CtbMovrCoan> list = AccountingRules.completeCtbMovrCoan(conn, $entity);
|
|
modify($entity){
|
|
setCtbMovrCoan(list)
|
|
}
|
|
end
|
|
|
|
rule "completeCodJcomRiga"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovr(codJcom == null && ((CtbMovt) $entity.getParent()).getCodJcom() !=null && (tipo == "5" || tipo == "4"))
|
|
then
|
|
modify($entity){
|
|
setCodJcom(((CtbMovt) $entity.getParent()).getCodJcom())
|
|
}
|
|
end
|
|
|
|
rule "completeDatiRegIva"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovt((flagScorporo == null || tipoNumerazione == null ) && codIreg != null)
|
|
then
|
|
HashMap<String, Object>dati = AccountingRules.completeDatiRegIva(conn, $entity);
|
|
modify($entity){
|
|
setTipoNumerazione(dati.get("tipoNumerazione").toString()),
|
|
setFlagScorporo(dati.get("flagScorporo").toString())
|
|
}
|
|
end
|
|
|
|
rule "setAnnoPartCtbPart"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity: CtbPart(annoPart == null && dataDoc != null && operation != OperationType.DELETE )
|
|
then
|
|
int annoPart = UtilityDate.getYear($entity.getDataDoc());
|
|
modify ( $entity ) { setAnnoPart(annoPart)}
|
|
end
|
|
|
|
|
|
rule "insertNewPartita"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity: CtbMovt(ctbPart == null && generaScad == "S" && tipoPartita !=null && operation != OperationType.DELETE )
|
|
then
|
|
CtbPart partita = AccountingRules.completePartita(conn, $entity);
|
|
modify ( $entity ) { setCtbPart(partita)}
|
|
end
|
|
|
|
rule "completeTotaliPartita"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity: CtbMovt((totIva == null || totImponib == null) && generaScad == "S" )
|
|
then
|
|
HashMap<String, BigDecimal> dati = AccountingRules.completeTotaliPartita(conn, $entity);
|
|
BigDecimal totImponib = UtilityHashMap.getValueIfExists(dati, "tot_imponib");
|
|
BigDecimal totIva = UtilityHashMap.getValueIfExists(dati, "tot_iva");
|
|
|
|
|
|
modify($entity){
|
|
setTotImponib(totImponib),
|
|
setTotIva(totIva)
|
|
}
|
|
end
|
|
|
|
|
|
rule "completeTipoPartitaMov"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity: CtbMovt(generaScad == "S" && tipoPartita == null )
|
|
then
|
|
Integer tipoPartita = AccountingRules.completeTipoPartita(conn, $entity);
|
|
modify ( $entity ) { setTipoPartita(tipoPartita)}
|
|
end
|
|
|
|
rule "completeDatiAnagPartita"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity: CtbPart(codAnag != null && tipoAnag != null)
|
|
then
|
|
HashMap<String, Object>dati= AccountingRules.completeDatiAnagPartita(conn, $entity);
|
|
modify($entity){
|
|
setCodVage(dati.get("codVage") == null ? null : dati.get("codVage").toString()),
|
|
setCodBanc(dati.get("codBanc") == null ? null : dati.get("codBanc").toString()),
|
|
setCodAbi(dati.get("codAbi") == null ? null : dati.get("codAbi").toString()),
|
|
setCodCab(dati.get("codCab") == null ? null : dati.get("codCab").toString()),
|
|
setCodPaga(dati.get("codPaga") == null ? null : dati.get("codPaga").toString())
|
|
}
|
|
end
|
|
|
|
rule "completeDatiContoPDC"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity: CtbMovr((tipo == null || sezione == null || percDed == null ) && codCcon != null )
|
|
then
|
|
HashMap<String, Object>dati = AccountingRules.completeDatiContoPDC(conn, $entity );
|
|
BigDecimal percDed = (BigDecimal) dati.get("percDed");
|
|
modify($entity){
|
|
setPercDed(percDed),
|
|
setTipo(dati.get("tipo") == null ? null: dati.get("tipo").toString()),
|
|
setSezione(dati.get("sezione") == null ? null: dati.get("sezione").toString()),
|
|
setTipoRiep(dati.get("tipoRiep") == null ? null: dati.get("tipoRiep").toString()),
|
|
setConsidPartita(dati.get("considPartita") == null ? null: dati.get("considPartita").toString())
|
|
}
|
|
end
|
|
|
|
rule "completeNumDocMov"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity: CtbMovt(numDoc == null && tipoAnag != null && codAnag != null && serDoc != null && dataDoc != null && codIreg != null && numIreg !=null)
|
|
then
|
|
Integer numDoc = AccountingRules.completeNumDocMov(conn, $entity);
|
|
modify ( $entity ) { setNumDoc(numDoc)}
|
|
end
|
|
|
|
rule "completeDatiPartitaCtbMovr"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity: CtbMovr((codAnag == null && (annoPart == null || serDoc == null || numDoc == null) ) &&
|
|
tipo == 2 && sezione == 1 && ((CtbMovt) $entity.getParent()).getDataDoc() != null && tipoAnag != null && tipoRiep != null && considPartita == "S")
|
|
then
|
|
Integer annoPart = Integer.parseInt( new SimpleDateFormat("yyyy").format(((CtbMovt) $entity.getParent()).getDataDoc()));
|
|
modify ( $entity ) {
|
|
setCodAnag(((CtbMovt) $entity.getParent()).getCodAnag()),
|
|
setAnnoPart(annoPart),
|
|
setSerDoc(((CtbMovt) $entity.getParent()).getSerDoc()),
|
|
setNumDoc(((CtbMovt) $entity.getParent()).getNumDoc())
|
|
}
|
|
end
|
|
|
|
rule "completeInsertCtbParr"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity: CtbMovr(( ctbParr == null || ctbParr.size == 0 ) && tipoAnag != null && codAnag != null && !UtilityEntity.isNull(annoPart) && serDoc != null && numDoc != null && considPartita == "S" &&
|
|
operation != OperationType.DELETE)
|
|
then
|
|
List<CtbParr> list = AccountingRules.InsertCtbParr(conn, $entity );
|
|
modify ($entity){
|
|
setCtbParr(list)
|
|
}
|
|
end
|
|
|
|
rule "completePagaScad"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity: CtbParr((ctbScad == null || ctbScad.size == 0) && chiudiScad == "S")
|
|
then
|
|
List<CtbScad> list = AccountingRules.pagaScadenze(conn, $entity );
|
|
modify ($entity){
|
|
setCtbScad(list)
|
|
}
|
|
end
|
|
|
|
rule "completeDataDocScad"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity: CtbScad(dataDoc == null && annoPart != null && codAnag != null && tipoAnag != null && serDoc != null && numDoc != null )
|
|
then
|
|
String sql =
|
|
"SELECT data_doc " +
|
|
" FROM ctb_part " +
|
|
" WHERE anno_part = " + $entity.getAnnoPart() + " AND " +
|
|
"tipo_anag = '" + $entity.getTipoAnag() + "' AND " +
|
|
"cod_anag = '" + $entity.getCodAnag() + "' AND " +
|
|
"ser_doc = '" + $entity.getSerDoc() + "' AND " +
|
|
"num_doc = " + $entity.getNumDoc();
|
|
Date dataDoc = (Date) QueryRules.getSingleValue(conn, sql);
|
|
modify ( $entity ) { setDataDoc(dataDoc) }
|
|
end
|
|
|
|
|
|
|
|
rule "completeCrlParrScad"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity: CtbScad(riaperta != null && riaperta && numCmov !=null)
|
|
then
|
|
List<CrlScadParr> crlScadParrs = AccountingRules.completeCrlParrScadScad(conn, $entity);
|
|
modify ( $entity ) { setCrlScadParr(crlScadParrs) }
|
|
end
|
|
|
|
|
|
rule "completeCodPagaMov"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity: CtbMovt(codPaga == null && generaScad == "S" && codAnag != null )
|
|
then
|
|
String codPaga = AccountingRules.completeCodPaga(conn, $entity);
|
|
modify ( $entity ) { setCodPaga(codPaga) }
|
|
end
|
|
|
|
rule "completeDatiScad"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity: CtbMovt(( ctbScad != null && ctbScad.size > 0 ) && tipoAnag != null && codAnag != null && dataDoc != null && serDoc != null && numDoc != null)
|
|
then
|
|
List<CtbScad> scad = AccountingRules.completeDatiScad(conn, $entity);
|
|
modify ( $entity ) { setCtbScad(scad) }
|
|
end
|
|
|
|
rule "completeDescrPagaScad"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity: CtbScad(descrizPag == null && codPaga != null )
|
|
then
|
|
String descrizione = CommonRules.completeDescrizionePaga(conn, $entity.getCodPaga());
|
|
modify ( $entity ) { setDescrizPag(descrizione) }
|
|
end
|
|
|
|
rule "completeInseritoDaCtbMovt"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity: CtbMovt(inseritoDa == null && operation != OperationType.DELETE)
|
|
then
|
|
String fullName = CommonRules.getFullName(conn, username);
|
|
modify ( $entity ) { setInseritoDa(fullName) }
|
|
end
|
|
|
|
rule "completeModificatoDaCtbMovt"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovt( operation != OperationType.DELETE )
|
|
then
|
|
String fullName = CommonRules.getFullName(conn, username);
|
|
modify ( $entity ) {
|
|
setDataMod(new Date()),
|
|
setModificatoDa(fullName)
|
|
}
|
|
end
|
|
|
|
rule "completeCodDiviContCtbMovt"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$testata : CtbMovt(codDiviCont == null && dataCmov != null)
|
|
then
|
|
HashMap<String, Object>dati = CommonRules.completeCodDivi(conn, $testata.getDataCmov());
|
|
modify ( $testata ) { setCodDiviCont(dati.get("cod_divi_contab").toString()) }
|
|
end
|
|
|
|
rule "completeCodDiviContCtbFondi"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$testata : CtbFondi(codDiviCont == null)
|
|
then
|
|
HashMap<String, Object>dati = CommonRules.completeCodDivi(conn);
|
|
modify ( $testata ) { setCodDiviCont(dati.get("cod_divi_contab").toString()) }
|
|
end
|
|
|
|
rule "completeCodDiviContCtbMovr"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$testata : CtbMovr(codDiviCont == null)
|
|
then
|
|
HashMap<String, Object>dati = CommonRules.completeCodDivi(conn);
|
|
modify ( $testata ) { setCodDiviCont(dati.get("cod_divi_contab").toString()) }
|
|
end
|
|
|
|
rule "completeCodDiviContCtbMovrCoan"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$testata : CtbMovrCoan(codDiviCont == null)
|
|
then
|
|
HashMap<String, Object>dati = CommonRules.completeCodDivi(conn);
|
|
modify ( $testata ) { setCodDiviCont(dati.get("cod_divi_contab").toString()) }
|
|
end
|
|
;
|
|
rule "completeCodDiviContCtbMovi"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$testata : CtbMovi(codDiviCont == null)
|
|
then
|
|
HashMap<String, Object>dati = CommonRules.completeCodDivi(conn);
|
|
modify ( $testata ) { setCodDiviCont(dati.get("cod_divi_contab").toString()) }
|
|
end
|
|
|
|
rule "completeCodDiviContCtbParr"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$testata : CtbParr(codDiviCont == null)
|
|
then
|
|
HashMap<String, Object>dati = CommonRules.completeCodDivi(conn);
|
|
modify ( $testata ) { setCodDiviCont(dati.get("cod_divi_contab").toString()) }
|
|
end
|
|
|
|
rule "completeCodDiviContCtbPart"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$testata : CtbPart(codDiviCont == null)
|
|
$t: java.util.HashMap() from CommonRules.completeCodDivi(conn)
|
|
then
|
|
HashMap<String, Object>dati = CommonRules.completeCodDivi(conn);
|
|
modify ( $testata ) { setCodDiviCont(dati.get("cod_divi_contab").toString()) }
|
|
end
|
|
|
|
rule "completeCodDiviCtbPart"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbPart( codDivi == null && dataDoc !=null)
|
|
then
|
|
HashMap<String, Object>dati = CommonRules.completeCodDivi(conn, $entity.getDataDoc() );
|
|
modify ( $entity ) { setCodDivi(dati.get("cod_divi_contab").toString()) }
|
|
end
|
|
|
|
rule "completeCambioCtbPart"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbPart( cambio == null && codDivi != null)
|
|
then
|
|
BigDecimal cambio = CommonRules.completeCambio(conn, $entity.getCodDiviCont());
|
|
modify ( $entity ) { setCambio(cambio) }
|
|
end
|
|
|
|
|
|
rule "completeCambioDiviCtbMovt"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$testata : CtbMovt(cambioDiviCont == null && codDiviCont != null )
|
|
then
|
|
BigDecimal cambio = CommonRules.completeCambio(conn, $testata.getCodDiviCont());
|
|
modify ( $testata ) { setCambioDiviCont(cambio) }
|
|
end
|
|
|
|
rule "completeCambioDiviCtbFondi"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$testata : CtbFondi(cambioDiviCont == null && codDiviCont != null )
|
|
then
|
|
BigDecimal cambio = CommonRules.completeCambio(conn, $testata.getCodDiviCont());
|
|
modify ( $testata ) { setCambioDiviCont(cambio) }
|
|
end
|
|
|
|
rule "completeCambioDiviCtbMovr"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$testata : CtbMovr(cambioDiviCont == null && codDiviCont != null )
|
|
then
|
|
BigDecimal cambio = CommonRules.completeCambio(conn, $testata.getCodDiviCont());
|
|
modify ( $testata ) { setCambioDiviCont(cambio) }
|
|
end
|
|
|
|
rule "completeCambioDiviCtbMovrCoan"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$testata : CtbMovrCoan(cambioDiviCont == null && codDiviCont != null )
|
|
then
|
|
BigDecimal cambio = CommonRules.completeCambio(conn, $testata.getCodDiviCont());
|
|
modify ( $testata ) { setCambioDiviCont(cambio) }
|
|
end
|
|
|
|
rule "completeCambioDiviCtbMovi"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$testata : CtbMovi(cambioDiviCont == null && codDiviCont != null )
|
|
then
|
|
BigDecimal cambio = CommonRules.completeCambio(conn, $testata.getCodDiviCont());
|
|
modify ( $testata ) { setCambioDiviCont(cambio) }
|
|
end
|
|
|
|
rule "completeDatiReverseCharge"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$testata : CtbMovt((generaReverseCharge == "S" || operation == OperationType.DELETE) && (numCmovRc == null || numDocRc == null || numProtRc == null ))
|
|
then
|
|
HashMap<String, Object>dati = AccountingRules.completeDatiReverseCharge(conn, $testata) ;
|
|
Integer numCmovRc = $testata.getNumCmovRc();
|
|
Integer numDocRc = $testata.getNumDocRc();
|
|
Integer numProtRc = $testata.getNumProtRc();
|
|
if (dati != null && dati.size() == 0) {
|
|
numCmovRc = (Integer) dati.get("numCmovRc");
|
|
numDocRc = (Integer) dati.get("numDocRc");
|
|
numProtRc = (Integer) dati.get("numProtRc");
|
|
}
|
|
modify($testata){
|
|
setNumCmovRc(numCmovRc),
|
|
setNumDocRc(numDocRc),
|
|
setNumProtRc(numProtRc)
|
|
}
|
|
end
|
|
|
|
rule "completeCambioDiviCtbPart"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$testata : CtbPart(cambioDiviCont == null && codDiviCont != null )
|
|
then
|
|
BigDecimal cambio = CommonRules.completeCambio(conn, $testata.getCodDiviCont());
|
|
modify ( $testata ) { setCambioDiviCont(cambio) }
|
|
end
|
|
|
|
rule "completeCambioDiviCtbParr"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$testata : CtbParr(cambioDiviCont == null && codDiviCont != null )
|
|
then
|
|
BigDecimal cambio = CommonRules.completeCambio(conn, $testata.getCodDiviCont());
|
|
modify ( $testata ) { setCambioDiviCont(cambio) }
|
|
end
|
|
|
|
rule "completeTipoRiepConto"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovr(codCcon != null && tipoRiep == null )
|
|
then
|
|
String sql = "SELECT tipo_riep FROM ctb_cont WHERE cod_ccon = '" + $entity.getCodCcon() + "'";
|
|
String tipoRiep = (String) QueryRules.getSingleValue(conn, sql);
|
|
modify ( $entity ) { setTipoRiep(tipoRiep) }
|
|
end
|
|
|
|
rule "completeCtbAnag"
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbMovr(codAnag != null && codCcon != null && tipoRiep != null && ctbAnag == null && operation != OperationType.DELETE && operation != OperationType.SUBSTITUTE && operation != OperationType.DELETE_THEN_INSERT)
|
|
then
|
|
CtbAnag ctbAnag= AccountingRules.completeCtbAnag(conn, $entity);
|
|
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
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbRitAcc(numCmovFat != null && generaScadenze != null && generaScadenze == "S")
|
|
then
|
|
CtbMovt ctbMovt = AccountingRules.completeScadRitAcc(conn, $entity);
|
|
modify ( $entity ) { setCtbMovt(ctbMovt)}
|
|
end
|
|
|
|
//CtbInum
|
|
|
|
|
|
rule "completeDataUltStampCtbInum"
|
|
no-loop
|
|
when
|
|
eval(completeRulesEnabled)
|
|
$entity : CtbInum(ultDataStp == null && anno !=null)
|
|
then
|
|
modify ( $entity ) { setUltDataStp(UtilityDate.dateFromPart($entity.getAnno() -1, 12, 13))}
|
|
end
|