All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.cnr.contab.docamm00.docs.bulk.Fattura_passivaHome Maven / Gradle / Ivy

/*
 * Copyright (C) 2019  Consiglio Nazionale delle Ricerche
 *
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU Affero General Public License as
 *     published by the Free Software Foundation, either version 3 of the
 *     License, or (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU Affero General Public License for more details.
 *
 *     You should have received a copy of the GNU Affero General Public License
 *     along with this program.  If not, see .
 */

package it.cnr.contab.docamm00.docs.bulk;

import it.cnr.jada.bulk.BulkHome;
import it.cnr.jada.persistency.*;
import it.cnr.jada.persistency.sql.SQLBuilder;

import java.sql.Timestamp;
import java.util.List;

public class Fattura_passivaHome extends BulkHome {
    protected Fattura_passivaHome(Class clazz, java.sql.Connection connection) {
        super(clazz, connection);
    }

    protected Fattura_passivaHome(Class clazz, java.sql.Connection connection, PersistentCache persistentCache) {
        super(clazz, connection, persistentCache);
    }

    public Fattura_passivaHome(java.sql.Connection conn) {
        super(Fattura_passivaBulk.class, conn);
    }

    public Fattura_passivaHome(java.sql.Connection conn, PersistentCache persistentCache) {
        super(Fattura_passivaBulk.class, conn, persistentCache);
    }

    public java.util.List findDuplicateFatturaFornitore(Persistent clause) throws PersistencyException {
        return fetchAll(selectDuplicateFatturaFornitore((Fattura_passivaBulk) clause));
    }

    /**
     * Viene ricercata la Data di Registrazione del documento immediatamente precedente
     * a quello che si sta registrando/modificando.
     * Viene restituita la data trovata, NULL altrimenti
     *
     * @param FatturaPassivaBulk
     * @return Timestamp
     * @throws PersistencyException, IntrospectionException
     */
    public Timestamp findDataRegFatturaPrecedente(Fattura_passivaBulk fatturaPassiva) throws PersistencyException, IntrospectionException {
        SQLBuilder sql = createSQLBuilder();
        sql.setHeader("SELECT TRUNC(MAX(DT_REGISTRAZIONE)) AS DT_REGISTRAZIONE");
        sql.addClause("AND", "cd_cds", SQLBuilder.EQUALS, fatturaPassiva.getCd_cds());
        sql.addClause("AND", "cd_unita_organizzativa", SQLBuilder.EQUALS, fatturaPassiva.getCd_unita_organizzativa());
        sql.addClause("AND", "esercizio", SQLBuilder.EQUALS, fatturaPassiva.getEsercizio());
        sql.addClause("AND", "pg_fattura_passiva", SQLBuilder.LESS, fatturaPassiva.getPg_fattura_passiva());

        Broker broker = createBroker(sql);
        Object value = null;
        if (broker.next()) {
            value = broker.fetchPropertyValue("dt_registrazione", getIntrospector().getPropertyType(getPersistentClass(), "dt_registrazione"));
            broker.close();
        }
        return (Timestamp) value;
    }

    /**
     * Viene ricercata la Data di Registrazione del documento immediatamente successivo
     * a quello che si sta registrando/modificando.
     * Viene restituita la data trovata, NULL altrimenti
     *
     * @param FatturaPassivaBulk
     * @return Timestamp
     * @throws PersistencyException, IntrospectionException
     */
    public Timestamp findDataRegFatturaSuccessiva(Fattura_passivaBulk fatturaPassiva) throws PersistencyException, IntrospectionException {
        SQLBuilder sql = createSQLBuilder();
        sql.setHeader("SELECT TRUNC(MIN(DT_REGISTRAZIONE)) AS DT_REGISTRAZIONE");
        sql.addClause("AND", "cd_cds", SQLBuilder.EQUALS, fatturaPassiva.getCd_cds());
        sql.addClause("AND", "cd_unita_organizzativa", SQLBuilder.EQUALS, fatturaPassiva.getCd_unita_organizzativa());
        sql.addClause("AND", "esercizio", SQLBuilder.EQUALS, fatturaPassiva.getEsercizio());
        sql.addClause("AND", "pg_fattura_passiva", SQLBuilder.GREATER, fatturaPassiva.getPg_fattura_passiva());

        Broker broker = createBroker(sql);
        Object value = null;
        if (broker.next()) {
            value = broker.fetchPropertyValue("dt_registrazione", getIntrospector().getPropertyType(getPersistentClass(), "dt_registrazione"));
            broker.close();
        }
        return (Timestamp) value;
    }

    public SQLBuilder selectDuplicateFatturaFornitore(Fattura_passivaBulk clause) {

        clause.setTi_fattura(null);
        SQLBuilder sql = createSQLBuilder();
        sql.addClausesUsing(clause, false);
        return sql;
    }

    public SQLBuilder selectModalita(Fattura_passivaBulk fatturaPassivaBulk, it.cnr.contab.docamm00.tabrif.bulk.DivisaHome divisaHome, it.cnr.contab.docamm00.tabrif.bulk.DivisaBulk clause) {

        return divisaHome.createSQLBuilder();
    }

    public SQLBuilder selectTermini(Fattura_passivaBulk fatturaPassivaBulk, it.cnr.contab.docamm00.tabrif.bulk.DivisaHome divisaHome, it.cnr.contab.docamm00.tabrif.bulk.DivisaBulk clause) {

        return divisaHome.createSQLBuilder();
    }

    public SQLBuilder selectValuta(Fattura_passivaBulk fatturaPassivaBulk, it.cnr.contab.docamm00.tabrif.bulk.DivisaHome divisaHome, it.cnr.contab.docamm00.tabrif.bulk.DivisaBulk clause) {

        SQLBuilder sql = divisaHome.createSQLBuilder();

        sql.addTableToHeader("CAMBIO");
        sql.addSQLJoin("DIVISA.CD_DIVISA", "CAMBIO.CD_DIVISA");

        return sql;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy