191 lines
6.2 KiB
Java
191 lines
6.2 KiB
Java
package it.acxent.contab;
|
|
|
|
import it.acxent.anag.Clifor;
|
|
import it.acxent.anag._AnagAdapter;
|
|
import it.acxent.db.ApplParmFull;
|
|
import it.acxent.db.WcString;
|
|
import it.acxent.util.DoubleOperator;
|
|
import it.acxent.util.Vectumerator;
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.SQLException;
|
|
|
|
public class RigaDocumentoProgettista extends _AnagAdapter {
|
|
private long id_rigaDocumentoProgettista;
|
|
|
|
private long id_rigaDocumento;
|
|
|
|
private long id_cliforRDA;
|
|
|
|
private double percRDA;
|
|
|
|
private double importoRDA;
|
|
|
|
private Clifor progettista;
|
|
|
|
private RigaDocumento rigaDocumento;
|
|
|
|
public RigaDocumentoProgettista() {}
|
|
|
|
public RigaDocumentoProgettista(ApplParmFull newApplParm) {
|
|
super(newApplParm);
|
|
}
|
|
|
|
public long getId_cliforRDA() {
|
|
return this.id_cliforRDA;
|
|
}
|
|
|
|
public void setId_cliforRDA(long id_clifor) {
|
|
this.id_cliforRDA = id_clifor;
|
|
}
|
|
|
|
public double getImportoRDA() {
|
|
if (getId_rigaDocumentoProgettista() > 0L && getId_rigaDocumento() > 0L &&
|
|
this.importoRDA == -1.0D) {
|
|
DoubleOperator dp = new DoubleOperator(getRigaDocumento().getTotImponibileRigaConSconto());
|
|
dp.setScale(2, 5);
|
|
dp.multiply(getPercRDA());
|
|
dp.divide(100.0F);
|
|
this.importoRDA = dp.getResult();
|
|
}
|
|
return (this.importoRDA == -1.0D) ? 0.0D : this.importoRDA;
|
|
}
|
|
|
|
public void setImportoRDA(double importo) {
|
|
this.importoRDA = importo;
|
|
}
|
|
|
|
public double getPercRDA() {
|
|
return this.percRDA;
|
|
}
|
|
|
|
public void setPercRDA(double percArticolo) {
|
|
this.percRDA = percArticolo;
|
|
}
|
|
|
|
public Vectumerator findByRigaDocumento(long id_rigaDocumento) {
|
|
String s_Sql_Find = "SELECT A.* FROM RIGA_DOCUMENTO_PROGETTISTA AS A ";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
wc.addWc(" A.id_rigaDocumento = " + id_rigaDocumento);
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
return findRows(stmt);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
public Vectumerator findByDocumento(long id_documento) {
|
|
String s_Sql_Find = "SELECT A.* FROM RIGA_DOCUMENTO_PROGETTISTA AS A INNER JOIN RIGA_DOCUMENTO AS B ON A.id_rigaDocumento = B.id_rigaDocumento INNER JOIN DOCUMENTO AS C ON B.id_documento = C.id_documento ";
|
|
String s_Sql_Order = " order by id_rigaDocumento, id_articolo, id_cliforRDA, percRDA";
|
|
WcString wc = new WcString();
|
|
wc.addWc(" C.id_documento = " + id_documento);
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
return findRows(stmt);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
public long getId_rigaDocumentoProgettista() {
|
|
return this.id_rigaDocumentoProgettista;
|
|
}
|
|
|
|
public void setId_rigaDocumentoProgettista(long id_rigaDocumentoProgettista) {
|
|
this.id_rigaDocumentoProgettista = id_rigaDocumentoProgettista;
|
|
}
|
|
|
|
public long getId_rigaDocumento() {
|
|
return this.id_rigaDocumento;
|
|
}
|
|
|
|
public void setId_rigaDocumento(long id_rigaDocumento) {
|
|
this.id_rigaDocumento = id_rigaDocumento;
|
|
setRigaDocumento(null);
|
|
}
|
|
|
|
public Clifor getProgettista() {
|
|
this.progettista = new Clifor(getApFull());
|
|
this.progettista.findByPrimaryKey(getId_cliforRDA());
|
|
return this.progettista;
|
|
}
|
|
|
|
public void setProgettista(Clifor clifor) {
|
|
this.progettista = clifor;
|
|
}
|
|
|
|
public void findByRigaDocumentoProgettista(long id_rigaDocumento, long id_progettista) {
|
|
String s_Sql_Find = "SELECT A.* FROM RIGA_DOCUMENTO_PROGETTISTA AS A ";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
wc.addWc(" A.id_rigaDocumento = " + id_rigaDocumento);
|
|
wc.addWc(" A.id_clifor = " + id_progettista);
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
findFirstRecord(stmt);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
}
|
|
}
|
|
|
|
protected void initFields() {
|
|
super.initFields();
|
|
this.importoRDA = -1.0D;
|
|
}
|
|
|
|
public RigaDocumento getRigaDocumento() {
|
|
this.rigaDocumento = new RigaDocumento(getApFull());
|
|
this.rigaDocumento.findByPrimaryKey(getId_rigaDocumento());
|
|
return this.rigaDocumento;
|
|
}
|
|
|
|
public void setRigaDocumento(RigaDocumento rigaDocumento) {
|
|
this.rigaDocumento = rigaDocumento;
|
|
}
|
|
|
|
public Vectumerator findByCR(RigaDocumentoProgettistaCR CR, int pageNumber, int pageRows) {
|
|
String s_Sql_Find = "select A.* from RIGA_DOCUMENTO_PROGETTISTA AS A inner join CLIFOR AS B on A.id_cliforRDA=B.id_clifor inner join RIGA_DOCUMENTO AS D ON A.id_rigaDocumento=D.id_rigaDocumento inner join DOCUMENTO as C on D.id_documento=C.id_documento";
|
|
String s_Sql_Order = " order by B.cognome, B.nome, A.id_cliforRDA";
|
|
WcString wc = new WcString();
|
|
if (CR.getId_documento() != 0L)
|
|
wc.addWc("A.id_documento = " + CR.getId_documento());
|
|
if (CR.getId_cliforDA() != 0L)
|
|
wc.addWc("A.id_cliforRDA = " + CR.getId_cliforDA());
|
|
if (CR.getFlgPagata() == 0L) {
|
|
wc.addWc("(C.flgPagata is null or C.flgPagata=0)");
|
|
} else if (CR.getFlgPagata() > 0L) {
|
|
wc.addWc("C.flgPagata =" + CR.getFlgPagata());
|
|
}
|
|
if (CR.getDataDocumentoDa() != null)
|
|
wc.addWc("C.dataDocumento>=?");
|
|
if (CR.getDataDocumentoA() != null)
|
|
wc.addWc("C.dataDocumento<=?");
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
int dataCount = 0;
|
|
if (CR.getDataDocumentoDa() != null) {
|
|
dataCount++;
|
|
stmt.setDate(dataCount, CR.getDataDocumentoDa());
|
|
}
|
|
if (CR.getDataDocumentoA() != null) {
|
|
dataCount++;
|
|
stmt.setDate(dataCount, CR.getDataDocumentoA());
|
|
}
|
|
return findRows(stmt, pageNumber, pageRows);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
public void deleteByRigaDocumento(long id_rigaDocumento) {
|
|
Vectumerator vec = new RigaDocumentoProgettista(getApFull()).findByRigaDocumento(id_rigaDocumento);
|
|
while (vec.hasMoreElements()) {
|
|
RigaDocumentoProgettista row = (RigaDocumentoProgettista)vec.nextElement();
|
|
row.delete();
|
|
}
|
|
}
|
|
}
|