Corretta gestione descrizione clienti/fornitori e descrizioni aggiuntivi
git-svn-id: svn://10.65.10.50/trunk@2281 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
6b0ab4cb09
commit
5449ef19fe
@ -307,7 +307,7 @@ void TPrimanota_application::disable_cgs_cells(int n, char tipo)
|
||||
case 'F': // Ritenute Fiscali
|
||||
case 'L': // Contropartita delle spese
|
||||
case 'N': // IVA Non detraibile
|
||||
case 'P': // Abbuoni passsivi
|
||||
case 'P': // Abbuoni passivi
|
||||
case 'R': // Ritenute professionali
|
||||
case 'S': // Ritenute Sociali
|
||||
last = 3;
|
||||
@ -463,9 +463,9 @@ real TPrimanota_application::calcola_saldo() const
|
||||
|
||||
if (pag)
|
||||
{
|
||||
const char tipo = row_type(r);
|
||||
if (strchr("ACGKP", tipo) != NULL)
|
||||
{
|
||||
const char tipo = row_type(r);
|
||||
if (strchr("ACGKP", tipo) != NULL) // Abbuoni attivi, differenze cambio,
|
||||
{ // spese, clienti/fornitori, abbuoni passivi
|
||||
const char sez = dare.is_zero() ? 'A' : 'D';
|
||||
const TImporto importo(sez, sez == 'A' ? avere : dare);
|
||||
saldaconto += importo;
|
||||
@ -493,10 +493,12 @@ real TPrimanota_application::calcola_saldo() const
|
||||
}
|
||||
|
||||
if (pag)
|
||||
{
|
||||
real t(m.get(F_TOTALE));
|
||||
t -= saldaconto.normalize().valore();
|
||||
m.set(K_RESIDUO, t.string());
|
||||
{
|
||||
const char s(causale().sezione(2));
|
||||
const real t(m.get(F_TOTALE));
|
||||
TImporto totdoc(s, t);
|
||||
totdoc += saldaconto;
|
||||
m.set(K_RESIDUO, totdoc.valore().string());
|
||||
}
|
||||
|
||||
return sbilancio;
|
||||
@ -764,7 +766,8 @@ bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
|
||||
const TString80 desc(app().causale().desc_agg(k));
|
||||
const char sez = app().causale().sezione(k);
|
||||
const real imp(cg.mask().get(K_RESIDUO));
|
||||
app().set_cgs_row(r, TImporto(sez, imp), conto, desc, tipo);
|
||||
TImporto importo(sez, imp);
|
||||
app().set_cgs_row(r, importo, conto, desc, tipo);
|
||||
|
||||
if (tipo == 'K')
|
||||
{
|
||||
@ -782,8 +785,14 @@ bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!imp.is_zero())
|
||||
app().crea_somma_spese(TImporto(sez, imp));
|
||||
if (!importo.is_zero())
|
||||
{
|
||||
const int s = type2pos('L');
|
||||
if (s < 0)
|
||||
app().crea_somma_spese(importo);
|
||||
else
|
||||
app().sub_cgs_imp(s, importo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1211,8 +1220,8 @@ bool TPrimanota_application::iva_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (imp != tot)
|
||||
{
|
||||
TString16 t(tot.string("."));
|
||||
TString16 i(imp.string("."));
|
||||
const TString t(tot.string("."));
|
||||
const TString i(imp.string("."));
|
||||
return error_box("La somma del totale documento e delle ritenute (%s) e' diverso dalla "
|
||||
"somma degli imponibili e delle imposte (%s)", (const char*)t, (const char*)i);
|
||||
}
|
||||
@ -2032,7 +2041,7 @@ bool TPrimanota_application::corrlire_handler(TMask_field& f, KEY key)
|
||||
|
||||
if (key == K_ENTER)
|
||||
{
|
||||
const TString16 im(m.get(F_IMPONIBILI));
|
||||
const TString im(m.get(F_IMPONIBILI));
|
||||
const char* cl = f.get();
|
||||
if (im != cl)
|
||||
warning_box("Il corrispettivo in lire e' diverso dal totale degli imponibili");
|
||||
|
@ -266,8 +266,6 @@ TCausale::TCausale(const char* cod, int year)
|
||||
// Legge le righe della causale attualmente selezionata sulla maschera
|
||||
bool TCausale::read(const char* cod, int year)
|
||||
{
|
||||
TLocalisamfile caus(LF_CAUSALI);
|
||||
|
||||
_rec.zero(); // Delete header
|
||||
destroy(); // Delete all rows
|
||||
_iva = iva_errata; // Delete misc info
|
||||
@ -276,15 +274,15 @@ bool TCausale::read(const char* cod, int year)
|
||||
|
||||
if (*cod > ' ')
|
||||
{
|
||||
caus.setkey(1);
|
||||
TLocalisamfile caus(LF_CAUSALI);
|
||||
caus.put(CAU_CODCAUS, cod);
|
||||
|
||||
int err = caus.read();
|
||||
if (err != NOERR) return FALSE;
|
||||
if (err != NOERR)
|
||||
return FALSE;
|
||||
_rec = caus.curr();
|
||||
|
||||
TLocalisamfile rcaus(LF_RCAUSALI);
|
||||
rcaus.setkey(1);
|
||||
rcaus.put(CAU_CODCAUS, cod);
|
||||
rcaus.put(CAU_NRIGA, 0);
|
||||
|
||||
@ -295,13 +293,15 @@ bool TCausale::read(const char* cod, int year)
|
||||
{
|
||||
const int riga = rcaus.get_int(CAU_NRIGA);
|
||||
add(rcaus.curr(), riga);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
rcaus.zero();
|
||||
for (int riga = 1; riga < size(); riga++) // Fill gaps
|
||||
if (objptr(riga) == NULL) add(rcaus.curr(), riga);
|
||||
|
||||
TString16 codreg(caus.get(CAU_REG));
|
||||
if (row(riga) == NULL) add(rcaus.curr(), riga);
|
||||
*/
|
||||
|
||||
const TString codreg(caus.get(CAU_REG));
|
||||
const bool ok = _reg.read(codreg, year); // Read register
|
||||
if (!ok && codreg.not_empty())
|
||||
return error_box("Non esiste il registro '%s' per l'anno %d",
|
||||
@ -319,17 +319,9 @@ bool TCausale::read(const char* cod, int year)
|
||||
}
|
||||
|
||||
|
||||
const TRectype& TCausale::row(int num) const
|
||||
{
|
||||
const TRectype* rec = (const TRectype*)objptr(num);
|
||||
CHECKD(rec, "Manca la riga di causale ", num);
|
||||
return *rec;
|
||||
}
|
||||
|
||||
|
||||
TBill& TCausale::bill(int num, TBill& conto) const
|
||||
{
|
||||
const TRectype* rec = (const TRectype*)objptr(num);
|
||||
const TRectype* rec = row(num);
|
||||
if (rec != NULL)
|
||||
conto.set(rec->get_int(RCA_GRUPPO), rec->get_int(RCA_CONTO),
|
||||
rec->get_long(RCA_SOTTOCONTO), rec->get_char(RCA_TIPOCF));
|
||||
@ -337,17 +329,23 @@ TBill& TCausale::bill(int num, TBill& conto) const
|
||||
}
|
||||
|
||||
const char* TCausale::desc_agg(int num) const
|
||||
{
|
||||
const TRectype* rec = (const TRectype*)objptr(num);
|
||||
if (rec == NULL)
|
||||
return "";
|
||||
|
||||
TTable da("%DPN");
|
||||
const char* cod = rec->get(RCA_CODDESC);
|
||||
da.put("CODTAB", cod);
|
||||
if (da.read() != NOERR)
|
||||
da.zero();
|
||||
return da.get("S0");
|
||||
{
|
||||
const char* deag = "";
|
||||
|
||||
const TRectype* rec = row(num);
|
||||
if (rec != NULL)
|
||||
{
|
||||
const TString& cod = rec->get(RCA_CODDESC);
|
||||
if (cod.not_empty())
|
||||
{
|
||||
TTable da("%DPN");
|
||||
da.put("CODTAB", cod);
|
||||
if (da.read() == NOERR)
|
||||
deag = da.get("S0");
|
||||
}
|
||||
}
|
||||
|
||||
return deag;
|
||||
}
|
||||
|
||||
const char* TCausale::descrizione() const
|
||||
@ -406,12 +404,13 @@ bool TCausale::ok() const
|
||||
|
||||
|
||||
char TCausale::sezione(int riga) const
|
||||
{
|
||||
const TRectype& r = row(riga);
|
||||
char sez = toupper(r.get_char(RCA_SEZIONE));
|
||||
{
|
||||
const TRectype* rec = row(riga);
|
||||
char sez = rec ? toupper(rec->get_char(RCA_SEZIONE)) : ' ';
|
||||
if (sez <= ' ') // Guess section on tipocf
|
||||
{
|
||||
char tipocf = toupper(row(1).get_char(RCA_TIPOCF));
|
||||
const TRectype* uno = row(1);
|
||||
char tipocf = uno ? toupper(uno->get_char(RCA_TIPOCF)) : ' ';
|
||||
if (tipocf <= ' ')
|
||||
tipocf = (iva() == iva_vendite) ? 'C' : 'F'; // Guess tipocf on IVA
|
||||
sez = (tipocf == 'C') ? 'D' : 'A';
|
||||
|
@ -90,7 +90,7 @@ class TCausale : public TArray
|
||||
char _sezione_clifo, _sezione_ritsoc;
|
||||
|
||||
protected:
|
||||
const TRectype& row(int num) const;
|
||||
const TRectype* row(int num) const { return (const TRectype*)objptr(num); }
|
||||
void calcIVA();
|
||||
|
||||
public: // TObject
|
||||
|
11
cg/conto.cpp
11
cg/conto.cpp
@ -184,10 +184,13 @@ bool TBill::find()
|
||||
const char tipoa = clifo.get_char("TIPOAPER");
|
||||
if (tipoa == 'F')
|
||||
{
|
||||
TString80 nome = _descrizione.mid(30);
|
||||
_descrizione.cut(30);
|
||||
_descrizione.trim(); nome.trim();
|
||||
_descrizione << ' ' << nome;
|
||||
TString nome(_descrizione.mid(30));
|
||||
if (nome.not_empty())
|
||||
{
|
||||
_descrizione.cut(30);
|
||||
_descrizione.trim(); nome.trim();
|
||||
_descrizione << ' ' << nome;
|
||||
}
|
||||
}
|
||||
if (_gruppo == 0 || _conto == 0)
|
||||
{
|
||||
|
@ -543,23 +543,30 @@ word TPagamento::validate() const
|
||||
|
||||
void TPagamento::strerr(word err, TString& s)
|
||||
{
|
||||
s = "Errore:";
|
||||
s = "Errore:\n";
|
||||
if (err & P_RSUM)
|
||||
s << "\n Le percentuali non sommano a 100";
|
||||
s << "Le percentuali non sommano a 100\n";
|
||||
if (err & P_IMPNC)
|
||||
s << "\n Le percentuali sono inconsistenti con gli importi";
|
||||
s << "Le percentuali sono inconsistenti con gli importi\n";
|
||||
if (err & P_SCAD)
|
||||
s << "\n Le scadenze non sono consecutive";
|
||||
s << "Le scadenze non sono consecutive\n";
|
||||
if (err & P_INIZIO)
|
||||
s << "\n La prima rata e' antecedente alla data documento";
|
||||
s << "La prima rata e' antecedente alla data documento\n";
|
||||
if (err & P_NEG)
|
||||
s << "\n L'importo dato e' inferiore al minimo possibile";
|
||||
s << "L'importo dato e' inferiore al minimo possibile\n";
|
||||
if (err & P_TROP)
|
||||
s << "\n L'importo dato e' superiore al massimo possibile";
|
||||
s << "L'importo dato e' superiore al massimo possibile\n";
|
||||
if (err & P_TOTNC)
|
||||
s << "\n La somma degli importi e' diversa dal totale del pagamento";
|
||||
{
|
||||
const real tot = _firstr + _secndr;
|
||||
real imp;
|
||||
for (int i = 0; i < n_rate(); i++)
|
||||
imp += tpay_rata(i);
|
||||
s << "La somma degli importi (" << imp.string(".");
|
||||
s << ") e' diversa dal totale del pagamento (" << tot.string(".") << ")\n";
|
||||
}
|
||||
if (err & P_MCOMM)
|
||||
s << "\n Scadenze incompatibili con il mese commerciale";
|
||||
s << "Scadenze incompatibili con il mese commerciale\n";
|
||||
}
|
||||
|
||||
const char* TPagamento::desc_tpr() const
|
||||
@ -1176,7 +1183,7 @@ bool TPagamento::read(TTable* t, TTable* r)
|
||||
r->put("CODTAB", (const char*)s);
|
||||
if (r->read() != NOERR)
|
||||
break;
|
||||
TToken_string* tt = new TToken_string(16);
|
||||
TToken_string* tt = new TToken_string(48);
|
||||
tt->add((const char*)(r->get("I0"))); // scadenza
|
||||
tt->add((const char*)(r->get("R0"))); // percentuale
|
||||
tt->add((const char*)(r->get("I1"))); // tipo
|
||||
@ -1249,12 +1256,13 @@ int TPagamento::rewrite(TTable& r)
|
||||
|
||||
int TPagamento::remove(TTable& r)
|
||||
{
|
||||
TString s(16); int err = NOERR;
|
||||
TString16 s; int err = NOERR;
|
||||
for (int i = 0 ; err == NOERR; i++)
|
||||
{
|
||||
r.zero(); s.format("%s%3d",(const char*)_code, i);
|
||||
r.put("CODTAB", (const char*)s);
|
||||
if (r.read() == NOERR) err = r.remove();
|
||||
r.zero(); s.format("%s%3d", _code, i);
|
||||
r.put("CODTAB", s);
|
||||
if (r.read() == NOERR)
|
||||
err = r.remove();
|
||||
else break;
|
||||
}
|
||||
return err;
|
||||
|
@ -305,7 +305,7 @@ bool TRiga_scadenze::chiusa(bool update) const
|
||||
// Calcola il totale dei pagamenti (eventualmente in valuta)
|
||||
TImporto TRiga_scadenze::importo_pagato(bool val, int mode) const
|
||||
{
|
||||
CHECKD(mode > 0x0 && mode < 0x8, "Bad importo_pagato mode ", mode);
|
||||
CHECKD(mode > 0x0 && mode <= 0xF, "Bad importo_pagato mode ", mode);
|
||||
const TPartita& game = partita();
|
||||
const bool in_val = in_valuta();
|
||||
const char* imp_field = (val && in_val) ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO;
|
||||
@ -319,14 +319,14 @@ TImporto TRiga_scadenze::importo_pagato(bool val, int mode) const
|
||||
|
||||
if (mode & 0x1)
|
||||
totale += TImporto(sez, pag.get_real(imp_field));
|
||||
if ((mode & 0x8) && !in_val)
|
||||
if (!in_val && (mode & 0x8)) // Le ritenute non esistono nei pagamenti in valuta
|
||||
totale += TImporto(sez, pag.get_real(PAGSCA_RITENUTE));
|
||||
|
||||
if (mode & 0x2) // Voglio anche gli abbuoni
|
||||
if (mode & 0x2) // Voglio anche gli abbuoni
|
||||
{
|
||||
real abb(pag.get_real(PAGSCA_ABBUONI));
|
||||
if (in_val && !val)
|
||||
{
|
||||
if (in_val && !val) // Gli abbuoni sono sempre in valuta e quindi
|
||||
{ // devono essere convertiti opportunamente
|
||||
abb *= sum.get_real(PART_CAMBIO);
|
||||
abb.round();
|
||||
}
|
||||
@ -334,7 +334,7 @@ TImporto TRiga_scadenze::importo_pagato(bool val, int mode) const
|
||||
}
|
||||
|
||||
if (in_val && !val && (mode & 0x4)) // Voglio anche le differenze cambio
|
||||
{
|
||||
{ // Esse esistono solo nei pagamenti in valuta
|
||||
const TImporto diffcam(sez, pag.get_real(PAGSCA_DIFFCAM));
|
||||
totale += diffcam;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user