Patch level : 1090

Files correlati     : cg2.exe
Ricompilazione Demo : [ ]
Commento            :
Modificato calcolo scorporo IVA in base alle nuove direttive


git-svn-id: svn://10.65.10.50/branches/R_10_00@22443 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2011-10-06 10:38:38 +00:00
parent c4c0fe6efb
commit 075485d3e0
3 changed files with 29 additions and 77 deletions

View File

@ -7,15 +7,15 @@ int main(int argc,char** argv)
const int s = argc > 1 ? argv[1][1] - '0' : 0; const int s = argc > 1 ? argv[1][1] - '0' : 0;
switch (s) switch (s)
{ {
case 1 : cg3200(argc,argv) ; break; // Stampa mastrini case 1 : cg3200(argc,argv); break; // Stampa mastrini
//case 2 : cg3300(argc,argv) ; break; // Stampa allegati iva // case 2 : cg3300(argc,argv); break; // Stampa allegati iva
case 3 : cg3400(argc,argv) ; break; // Stampa libro giornale case 3 : cg3400(argc,argv); break; // Stampa libro giornale
case 4 : cg3500(argc,argv) ; break; // Stampa ripilogo gruppi conti case 4 : cg3500(argc,argv); break; // Stampa ripilogo gruppi conti
case 5 : cg3600(argc,argv) ; break; // Visualizzazione mastrini case 5 : cg3600(argc,argv); break; // Visualizzazione mastrini
case 6 : cg3700(argc,argv) ; break; // Lista fatture case 6 : cg3700(argc,argv); break; // Lista fatture
case 7 : cg3800(argc,argv) ; break; // Lista fatture doppie case 7 : cg3800(argc,argv); break; // Lista fatture doppie
case 8 : cg3900(argc,argv) ; break; // Lista clienti fornitori in allegato case 8 : cg3900(argc,argv); break; // Lista clienti fornitori in allegato
default: cg3100(argc,argv) ; break; // Lista movimenti[1]/fatture[2] default: cg3100(argc,argv); break; // Lista movimenti[1]/fatture[2]
} }
return 0; return 0;
} }

View File

@ -573,86 +573,37 @@ bool TCodiceIVA::read(const char* cod)
return !empty(); return !empty();
} }
real TCodiceIVA::imposta(const real& imponibile, int ndec, const char* codval) const void TCodiceIVA::round(real& n, int ndec, const char* codval) const
{ {
const real percent = percentuale();
real iva = imponibile * percent / CENTO;
switch (ndec) switch (ndec)
{ {
case AUTO_DECIMALS: case AUTO_DECIMALS : ndec = (codval && *codval) ? TExchange(codval).decimals(false) : 2; break;
ndec = TExchange(codval).decimals(FALSE); case AUTO_PRICES_DECIMALS: ndec = TExchange(codval).decimals(true); break;
break; default : break;
case AUTO_PRICES_DECIMALS:
ndec = TExchange(codval).decimals(TRUE);
break;
default:
break;
} }
if (ndec < 20) if (ndec < 10)
{ n.round(ndec);
if (ndec == 0) // VECCHIE LIRE! }
{
if (imponibile > ZERO) real TCodiceIVA::imposta(const real& imponibile, int ndec, const char* codval) const
iva.ceil(ndec); {
else real iva = imponibile * percentuale() / CENTO;
iva.floor(ndec); round(iva, ndec, codval);
}
else
iva.round(ndec);
}
return iva; return iva;
} }
real TCodiceIVA::scorpora(real& lordo, int ndec, const char* codval) const real TCodiceIVA::scorpora(real& lordo, int ndec, const char* codval) const
{ {
const real percent = percentuale(); round(lordo, ndec, codval); // Arrotondo importo lordo
real iva = (lordo * percent) / (percent + CENTO); real imponibile = lordo * CENTO / (CENTO + percentuale());
real imponibile = lordo - iva; round(imponibile, ndec, codval); // Arrotondo importo netto
const real iva = lordo - imponibile;
switch (ndec)
{
case AUTO_DECIMALS:
ndec = TExchange(codval).decimals(FALSE);
break;
case AUTO_PRICES_DECIMALS:
ndec = TExchange(codval).decimals(TRUE);
break;
default:
break;
}
if (ndec < 20) // E' richiesto un arrotondamento significativo?
{
lordo.round(ndec); // Arrotondo importo lordo
if (ndec == 0) // Probabile caso Lire: arrotondo per eccesso l'IVA
{
if (imponibile > ZERO)
iva.ceil(ndec);
else
iva.floor(ndec);
}
else
iva.round(ndec); // Probabile caso Euro: arrotondo matematicamente l'IVA
imponibile.round(ndec); // Arrotondo imponibile
real diff = lordo - imponibile - iva;
diff.round(ndec); // Arrotondo la differenza (importantissimo per evitare valori del tipo 1E-18)
if (!diff.is_zero())
{
if (iva.sign() == diff.sign()) // Faccio crescere l'iva o l'imponibile ?
iva += diff;
else
imponibile += diff;
}
}
lordo = imponibile; // lordo è un reference da aggiornare con l'imponibile! lordo = imponibile; // lordo è un reference da aggiornare con l'imponibile!
return iva; return iva;
} }
real TCodiceIVA::lordo(const real& imponibile, int ndec, const char* codval) const real TCodiceIVA::lordo(const real& imponibile, int ndec, const char* codval) const
{ { return imponibile + imposta(imponibile, ndec, codval); }
return imponibile + imposta(imponibile, ndec, codval);
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////

View File

@ -138,6 +138,7 @@ class TCodiceIVA : public TRectype
{ {
protected: protected:
void copy(const TRectype & iva) { TRectype::operator =(iva); } void copy(const TRectype & iva) { TRectype::operator =(iva); }
void round(real& n, int ndec, const char* codval) const;
public: // TObject public: // TObject
virtual bool ok() const { return !empty(); } virtual bool ok() const { return !empty(); }
@ -152,8 +153,8 @@ public: // TObject
int allegato(char tipocf) const { return get_int(tipocf == 'F' ? "S8" : "S7"); } int allegato(char tipocf) const { return get_int(tipocf == 'F' ? "S8" : "S7"); }
real imposta(const real& imponibile, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Calcola l'imposta sull'imponibile l'imposta e la ritorna real imposta(const real& imponibile, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Calcola l'imposta sull'imponibile l'imposta e la ritorna
real scorpora(real& imponibile, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Scorpora dall'imponibile l'imposta e la ritorna real scorpora(real& imponibile, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Scorpora dall'imponibile l'imposta e la ritorna
real lordo(const real& imponibile, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Calcola il lordo dell'imponibile l'imposta e la ritorna real lordo(const real& imponibile, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Calcola il lordo dell'imponibile l'imposta e la ritorna
TCodiceIVA(const char* codice = NULL); TCodiceIVA(const char* codice = NULL);
TCodiceIVA(const TRectype & rec) : TRectype(rec) {} TCodiceIVA(const TRectype & rec) : TRectype(rec) {}