Patch level : 12.0 no-patch
Files correlati : Commento : Aggiunta e modifica colonne, sistemati gli importi, aggiunta documenti V02 git-svn-id: svn://10.65.10.50/branches/R_10_00@23482 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
9dfe16c68e
commit
4abb862806
@ -34,13 +34,17 @@ public:
|
||||
long codcf; // Codice del cliente
|
||||
real p98; // > 0 se trovo un P98 per quel cliente // Viene già inizializzata a 0?
|
||||
real importoPagato; // Importo pagato per quest'anno dal cliente
|
||||
TString nome; // Nome e cognome del cliente
|
||||
TString nome; // Nome
|
||||
TString cognome; // Cognome
|
||||
TString indirizzo; // Indirizzo
|
||||
TString citta; // Città
|
||||
TString provincia; // Provincia
|
||||
TString codF; // Codice Fiscale
|
||||
real totale; // Totale pagato durante l'anno
|
||||
real p98Ini;
|
||||
|
||||
TClifo(): codcf(0), p98(ZERO), p98Ini(ZERO), importoPagato(ZERO), nome(""), codF(""), totale(ZERO){}
|
||||
TClifo(long cod, TString nome, TString codF) : codcf(cod), nome(nome), codF(codF){}
|
||||
TClifo(): codcf(0), p98(ZERO), p98Ini(ZERO), importoPagato(ZERO), nome(""), cognome(""), indirizzo (""), citta(""), provincia(""), codF(""), totale(ZERO){}
|
||||
TClifo(long cod, TString nom, TString cog, TString ind, TString cit, TString prov, TString codFisc) : codcf(cod), nome(nom), cognome(cog), indirizzo(ind), citta(cit), provincia(prov), codF(codFisc){}
|
||||
virtual ~TClifo(){}
|
||||
|
||||
TClifo & operator = (const TClifo& r);
|
||||
@ -53,6 +57,10 @@ TClifo& TClifo::operator =(const TClifo& r)
|
||||
p98Ini = r.p98Ini;
|
||||
importoPagato = r.importoPagato;
|
||||
nome = r.nome;
|
||||
cognome = r.cognome;
|
||||
indirizzo = r.indirizzo;
|
||||
citta = r.citta;
|
||||
provincia = r.provincia;
|
||||
codF = r.codF;
|
||||
totale = r.totale;
|
||||
return *this;
|
||||
@ -90,12 +98,14 @@ protected:
|
||||
bool elabPayment(int anno, TString userPath);
|
||||
TString toEur(real val);
|
||||
bool findErase(TToken_string *tn, long val);
|
||||
void splitName(TString ragsoc, TString &nome, TString &cognome);
|
||||
void getLocalita(TString cod, TString &comune, TString &provincia);
|
||||
public:
|
||||
virtual void main_loop();
|
||||
};
|
||||
|
||||
TString TTessan_app::toEur(real val)
|
||||
{
|
||||
{
|
||||
return TString(TCurrency(val).string(true)) << " €";
|
||||
}
|
||||
|
||||
@ -117,6 +127,44 @@ bool TTessan_app::findErase(TToken_string *tn, long find)
|
||||
return false;
|
||||
}
|
||||
|
||||
void TTessan_app::splitName(TString ragsoc, TString &nome, TString &cognome)
|
||||
{
|
||||
/* Casi:
|
||||
* COGNOME NOME
|
||||
* COGNOME NOME
|
||||
* Prima cerco più di uno spazio così da mantenere eventuali nomi/cognomi multipli (come GUIDI GIORGI GABRIELLA ANNUNZIATA FILOMENA)
|
||||
*/
|
||||
int f , l = -1, offset = 2;
|
||||
for(int i = 0; i < ragsoc.len(); i++)
|
||||
{
|
||||
if(ragsoc[i] == ' ' && ragsoc[i + 1] == ' ') l = i;
|
||||
}
|
||||
if(l == -1)
|
||||
{
|
||||
f = ragsoc.find(' ');
|
||||
cognome = ragsoc.sub(0, f);
|
||||
nome = ragsoc.sub(f + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
f = ragsoc.find(" ");
|
||||
cognome = ragsoc.sub(0, f);
|
||||
nome = ragsoc.sub(l + 2);
|
||||
}
|
||||
}
|
||||
void TTessan_app::getLocalita(TString cod, TString &comune, TString &provincia)
|
||||
{
|
||||
TRelation com(LF_COMUNI);
|
||||
TRectype filCom(com.curr());
|
||||
filCom.put("STATO", "");
|
||||
filCom.put("COM", cod);
|
||||
TCursor curCom(&com, "", 1, &filCom, &filCom);
|
||||
curCom.items();
|
||||
curCom = 0;
|
||||
TRectype rowCom = curCom.curr();
|
||||
comune = rowCom.get("DENCOM");
|
||||
provincia = rowCom.get("PROVCOM"); // Teoricamente le province saranno sempre di 2 ma non si sa mai
|
||||
}
|
||||
|
||||
bool TTessan_app::elabPayment(int anno, TString userPath)
|
||||
{
|
||||
@ -141,8 +189,11 @@ bool TTessan_app::elabPayment(int anno, TString userPath)
|
||||
if (!a.add_status())
|
||||
break;
|
||||
// Riga cliente attuale
|
||||
TRectype rowClifo = curClifo.curr();
|
||||
TClifo cliente(rowClifo.get_long("CODCF"), rowClifo.get("RAGSOC"), rowClifo.get("COFI"));
|
||||
TRectype rowClifo = curClifo.curr();
|
||||
TString nome, cognome, comune, provincia;
|
||||
splitName(rowClifo.get("RAGSOC"), nome, cognome);
|
||||
getLocalita(rowClifo.get("COMCF"), comune, provincia);
|
||||
TClifo cliente(rowClifo.get_long("CODCF"), nome, cognome, (TString)rowClifo.get("INDCF") << " " << rowClifo.get("CIVCF"), comune, provincia, rowClifo.get("COFI"));
|
||||
clienti[curClifo.pos()] = cliente;
|
||||
}
|
||||
|
||||
@ -276,8 +327,7 @@ bool TTessan_app::elabPayment(int anno, TString userPath)
|
||||
//***********************************************************************************
|
||||
|
||||
// Inizio a scriverci
|
||||
outputFile << "Anno " << anno -1 << "\n\n";
|
||||
outputFile << "Data Documento;Numero Documento;Importo;Residuo P98;Conto;Codice Cliente;Cognome Nome;Codice Fiscale;\n";
|
||||
outputFile << "CodiceAnagrafico;CodiceFiscale;Cognome;Nome;Indirizzo;Citta;Provincia;NumeroDocumento;DataDocumento;DataPagamento;Dispositivo;TipoOperazione;NumeroDocumentoOriginale;DataDocumentoOriginale;DispositivoDocumentoOriginale;TipoSpesa;FlagSpesa;Importo;OperazioneEsclusa\n";
|
||||
|
||||
|
||||
int clientsSatisfied = 0; // Numero di clienti con P98 <= 0 (Quindi ho trovato tutte le fatture vecchie)
|
||||
@ -293,7 +343,7 @@ bool TTessan_app::elabPayment(int anno, TString userPath)
|
||||
filLastOld.put("DATAREG", lastOld);
|
||||
|
||||
// Creo il cursore e conto gli elementi
|
||||
TSorted_cursor curMovOld(&mov, "DATAREG-", "CODCAUS = 'V01'", 2, &filFirstOld, &filLastOld);
|
||||
TSorted_cursor curMovOld(&mov, "DATAREG-", "", 2, &filFirstOld, &filLastOld);
|
||||
int numMovOld = curMovOld.items();
|
||||
|
||||
TProgress_monitor e(numMovOld, (TString)"Aggiungo al file i movimenti del " << anno -1);
|
||||
@ -304,29 +354,30 @@ bool TTessan_app::elabPayment(int anno, TString userPath)
|
||||
// Movimento attuale
|
||||
TRectype rowMovOld = curMovOld.curr();
|
||||
if(rowMovOld.get("TIPO") != "C") continue; // Non riesco a metterlo nel filtro
|
||||
if(rowMovOld.get("CODCAUS") != 'V01' && rowMovOld.get("CODCAUS") == 'V02') continue;
|
||||
|
||||
for(int i = 0; i < numCli; i++)
|
||||
{
|
||||
if(clienti[i].codcf == rowMovOld.get_long("CODCF") && clienti[i].p98 > 0) // Trova più spesso il cliente diverso dal codice all'inizio
|
||||
{
|
||||
clienti[i].p98 -= rowMovOld.get_real("TOTDOC");
|
||||
|
||||
// Aggiungo il documento al file
|
||||
TString codcfFilled; codcfFilled << rowMovOld.get("CODCF");
|
||||
for(int j = codcfFilled.len(); j <= 6; j++) codcfFilled.insert("0",0);
|
||||
|
||||
outputFile << rowMovOld.get("DATADOC") << ";" << rowMovOld.get("NUMDOC") << ";" << toEur(rowMovOld.get_real("TOTDOC")) << ";" << toEur(clienti[i].p98) << ";" << "001 002 " << codcfFilled << ";" << rowMovOld.get("CODCF") << ";" << clienti[i].nome << ";" << clienti[i].codF << "\n";
|
||||
real totdoc = rowMovOld.get_real("TOTDOC");
|
||||
real importo = clienti[i].p98 - totdoc >= 0 ? totdoc : clienti[i].p98;
|
||||
|
||||
outputFile << rowMovOld.get("CODCF") << ";" << clienti[i].codF << ";" << clienti[i].cognome << ";" << clienti[i].nome << ";" << clienti[i].indirizzo << ";" << clienti[i].citta << ";" << clienti[i].provincia << ";" << rowMovOld.get("NUMDOC") << ";" << rowMovOld.get("DATADOC") << ";" << rowMovOld.get("DATAREG") << ";1;I;;;AA;;;" << toEur(importo) << ";\n";
|
||||
|
||||
clienti[i].p98 -= totdoc;
|
||||
|
||||
// Se ha trovato tutti i documenti incremento la variabile sentinella
|
||||
if(clienti[i].p98 <= 0) clientsSatisfied ++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Spazio dal 2016
|
||||
outputFile << "\n\nAnno " << anno << "\n\n";
|
||||
outputFile << "Data Documento;Numero documento;Importo;Residuo pagamenti;Conto;Codice Cliente;Cognome Nome;Codice Fiscale;\n";
|
||||
|
||||
// Creo il cursore di Mov Nuovo
|
||||
// Creo la stringa per i filtri
|
||||
@ -339,7 +390,7 @@ bool TTessan_app::elabPayment(int anno, TString userPath)
|
||||
filLastNew.put("DATAREG", lastNew);
|
||||
|
||||
// Creo il cursore e conto gli elementi
|
||||
TSorted_cursor curMovNew(&mov, "DATAREG", "CODCAUS = 'V01'", 2, &filFirstNew, &filLastNew);
|
||||
TSorted_cursor curMovNew(&mov, "DATAREG", "", 2, &filFirstNew, &filLastNew);
|
||||
//TCursor curMov(&mov, "", 3, &filFirst, &filLast);
|
||||
int numMovNew = curMovNew.items();
|
||||
|
||||
@ -352,18 +403,25 @@ bool TTessan_app::elabPayment(int anno, TString userPath)
|
||||
// Movimento attuale
|
||||
TRectype rowMovNew = curMovNew.curr();
|
||||
if(rowMovNew.get("TIPO") != "C") continue; // Non riesco a metterlo nel filtro
|
||||
if(rowMovNew.get("CODCAUS") != 'V01' && rowMovNew.get("CODCAUS") == 'V02') continue;
|
||||
|
||||
for(int i = 0; i < numCli; i++)
|
||||
{
|
||||
if(rowMovNew.get_long("CODCF") == clienti[i].codcf && clienti[i].importoPagato >= 0)
|
||||
{
|
||||
// Sottraggo quanto ha pagato
|
||||
clienti[i].importoPagato -= rowMovNew.get_real("TOTDOC");
|
||||
// Scrivo su file
|
||||
TString codcfFilled; codcfFilled << rowMovNew.get("CODCF");
|
||||
for(int j = codcfFilled.len(); j <= 6; j++) codcfFilled.insert("0",0);
|
||||
|
||||
real totdoc = rowMovNew.get_real("TOTDOC");
|
||||
real importo = clienti[i].importoPagato - totdoc >= 0 ? totdoc : clienti[i].importoPagato;
|
||||
|
||||
outputFile << rowMovNew.get("DATADOC") << ";" << rowMovNew.get("NUMDOC") << ";" << toEur(rowMovNew.get_real("TOTDOC")) << ";" << toEur(clienti[i].importoPagato) << ";" << "001 002 " << codcfFilled << ";" << rowMovNew.get("CODCF") << ";" << clienti[i].nome << ";" << clienti[i].codF << "\n";
|
||||
outputFile << rowMovNew.get("CODCF") << ";" << clienti[i].codF << ";" << clienti[i].cognome << ";" << clienti[i].nome << ";" << clienti[i].indirizzo << ";" << clienti[i].citta << ";" << clienti[i].provincia << ";" << rowMovNew.get("NUMDOC") << ";" << rowMovNew.get("DATADOC") << ";" << rowMovNew.get("DATAREG") << ";1;I;;;AA;;;" << toEur(importo) << ";\n";
|
||||
|
||||
clienti[i].importoPagato -= totdoc;
|
||||
|
||||
//outputFile << rowMovNew.get("DATADOC") << ";" << rowMovNew.get("NUMDOC") << ";" << toEur(rowMovNew.get_real("TOTDOC")) << ";" << toEur(clienti[i].importoPagato) << ";" << "001 002 " << codcfFilled << ";" << rowMovNew.get("CODCF") << ";" << clienti[i].nome << ";" << clienti[i].codF << "\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user