Files correlati : tf Commento : Controllo preventivo della presenza di un cliente/fornitore nel checkRecord() git-svn-id: svn://10.65.10.50/branches/R_10_00@24125 c028cbd2-c16b-5b4b-a496-9718f37d4682
112 lines
3.4 KiB
C++
112 lines
3.4 KiB
C++
#include <recarray.h> // cache()
|
||
|
||
#include "../ve/velib05.h"
|
||
#include "../cg/cglib03.h"
|
||
#include "../fe/felib.h"
|
||
#include "tfutility.h"
|
||
|
||
|
||
// Ritorna il record da trasfatt
|
||
TRectype getTrasFatt(TString reg, TString codiva)
|
||
{
|
||
TString key = reg; key << "|" << codiva;
|
||
return cache().get(LF_TRASFATT, key);
|
||
}
|
||
|
||
// Ritorna il cliente
|
||
TRectype getCli(const TString& tipocf, const TString& codcf, const TString& ocfpi)
|
||
{
|
||
TString key = tipocf; key << "|" << codcf;
|
||
const TRectype& cli = cache().get(LF_CLIFO, key);
|
||
if(cli.get_bool("OCCAS"))
|
||
{
|
||
TRectype cli(LF_CLIFO);
|
||
TRectype occas = cache().get(LF_OCCAS, ocfpi);
|
||
cli.put("RAGSOC" , occas.get("RAGSOC"));
|
||
cli.put("CODRFSO" , "");
|
||
cli.put("PAIV" , occas.get("PAIV"));
|
||
cli.put("COFI" , occas.get("COFI"));
|
||
return cli;
|
||
}
|
||
else
|
||
return cli;
|
||
}
|
||
|
||
// Controlla se l'azienda ha un RFSO
|
||
bool haveRFSO(TString& codrfso)
|
||
{
|
||
codrfso = cache().get(LF_NDITTE, prefix().firm().codice(), "CODRFSO");
|
||
if(codrfso == "") return false;
|
||
return true;
|
||
}
|
||
|
||
const char * natura(const TString& codiva)
|
||
{
|
||
const TRectype& ai = cache().get("%IVA", codiva);
|
||
TString & natura = get_tmp_string(4);
|
||
|
||
natura = ai.get("S12");
|
||
return natura;
|
||
}
|
||
|
||
TString findDetraib(TString tipodet)
|
||
{
|
||
real perc = cache().get("%DET", tipodet, "R0");
|
||
return perc.stringa(6,2);
|
||
}
|
||
|
||
real get_IVA(const TString& codiva)
|
||
{
|
||
const TRectype& ai = cache().get("%IVA", codiva);
|
||
return ai.get_real("R0");
|
||
}
|
||
|
||
TString revCharge(TString numreg)
|
||
{
|
||
// Controllo se la causale ha il reverse charge, se il cliente non l'ha impostata giusta sono ARAZZI suoi
|
||
TString key = numreg;
|
||
TCausale caus(cache().get(LF_MOV, key, "CODCAUS"));
|
||
if(caus.reverse_charge())
|
||
bool tolla = true;
|
||
return caus.reverse_charge() ? "X" : "";
|
||
}
|
||
|
||
TString getRFSO(TString codrfso)
|
||
{
|
||
TString key; key << codrfso[0] << "|" << codrfso.mid(1);
|
||
return cache().get(LF_ANAG, key, "RAGSOC");
|
||
}
|
||
|
||
/* Utilizzo questa funzione per filtrare al meglio i record, tutti i casi che devo omettere verranno rilevati e ritorneranno false
|
||
* Nota bene: viene sfruttato un puntatore di TISA_Recordset per non creare nuovi oggetti e velocizzare la chiamata
|
||
* a questo punto il programma non ha ancora creato un record di $trasfatt con i dati che mi interessano
|
||
*/
|
||
bool checkRecord(TISAM_recordset* rec)
|
||
{
|
||
// Il record non <20> valido se non <20> presente un cliente
|
||
if(rec->get("23.TIPO").as_string()[0] == '\0' || rec->get("23.CODCF").as_int() == 0)
|
||
return false;
|
||
|
||
TAnagrafica anaCli(rec->get("23.TIPO").as_string()[0], rec->get("23.CODCF").as_int(), rec->get("23.OCFPI").as_string());
|
||
|
||
static TString keyClifo; keyClifo.cut(0) << rec->get("23.TIPO").as_string() << "|" << rec->get("23.CODCF").as_string();
|
||
TRectype rclifo = cache().get(LF_CLIFO, keyClifo);
|
||
// Salto le schede carburanti
|
||
if(rclifo.get("ALLEG") == "C")
|
||
return false;
|
||
|
||
// Clienti
|
||
if(rec->get("23.TIPO").as_string() == "C")
|
||
{
|
||
// Tolgo tutti i movimenti di sola IVA e in reverse charge o di tipo 3 (Acquisto di beni e servizi di soggetti non residenti)
|
||
TCausale caus(rec->get("23.CODCAUS").as_string());
|
||
if(caus.soloiva() && (caus.reverse_charge() || caus.regime_speciale() == 3))
|
||
return false;
|
||
} else if(anaCli.italiano() && anaCli.partita_IVA()[0] != '0' && anaCli.partita_IVA()[0] != '1' && anaCli.codice_fiscale()[0] > '8')
|
||
// Salto tutti i fornitori con cod cf che inizia per 8 o 9 e con p.iva non valida
|
||
{
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
} |