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:
parent
c4c0fe6efb
commit
075485d3e0
18
cg/cg3.cpp
18
cg/cg3.cpp
@ -7,15 +7,15 @@ int main(int argc,char** argv)
|
||||
const int s = argc > 1 ? argv[1][1] - '0' : 0;
|
||||
switch (s)
|
||||
{
|
||||
case 1 : cg3200(argc,argv) ; break; // Stampa mastrini
|
||||
//case 2 : cg3300(argc,argv) ; break; // Stampa allegati iva
|
||||
case 3 : cg3400(argc,argv) ; break; // Stampa libro giornale
|
||||
case 4 : cg3500(argc,argv) ; break; // Stampa ripilogo gruppi conti
|
||||
case 5 : cg3600(argc,argv) ; break; // Visualizzazione mastrini
|
||||
case 6 : cg3700(argc,argv) ; break; // Lista fatture
|
||||
case 7 : cg3800(argc,argv) ; break; // Lista fatture doppie
|
||||
case 8 : cg3900(argc,argv) ; break; // Lista clienti fornitori in allegato
|
||||
default: cg3100(argc,argv) ; break; // Lista movimenti[1]/fatture[2]
|
||||
case 1 : cg3200(argc,argv); break; // Stampa mastrini
|
||||
// case 2 : cg3300(argc,argv); break; // Stampa allegati iva
|
||||
case 3 : cg3400(argc,argv); break; // Stampa libro giornale
|
||||
case 4 : cg3500(argc,argv); break; // Stampa ripilogo gruppi conti
|
||||
case 5 : cg3600(argc,argv); break; // Visualizzazione mastrini
|
||||
case 6 : cg3700(argc,argv); break; // Lista fatture
|
||||
case 7 : cg3800(argc,argv); break; // Lista fatture doppie
|
||||
case 8 : cg3900(argc,argv); break; // Lista clienti fornitori in allegato
|
||||
default: cg3100(argc,argv); break; // Lista movimenti[1]/fatture[2]
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -573,86 +573,37 @@ bool TCodiceIVA::read(const char* cod)
|
||||
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)
|
||||
{
|
||||
case AUTO_DECIMALS:
|
||||
ndec = TExchange(codval).decimals(FALSE);
|
||||
break;
|
||||
case AUTO_PRICES_DECIMALS:
|
||||
ndec = TExchange(codval).decimals(TRUE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case AUTO_DECIMALS : ndec = (codval && *codval) ? TExchange(codval).decimals(false) : 2; break;
|
||||
case AUTO_PRICES_DECIMALS: ndec = TExchange(codval).decimals(true); break;
|
||||
default : break;
|
||||
}
|
||||
if (ndec < 20)
|
||||
{
|
||||
if (ndec == 0) // VECCHIE LIRE!
|
||||
{
|
||||
if (imponibile > ZERO)
|
||||
iva.ceil(ndec);
|
||||
else
|
||||
iva.floor(ndec);
|
||||
}
|
||||
else
|
||||
iva.round(ndec);
|
||||
}
|
||||
if (ndec < 10)
|
||||
n.round(ndec);
|
||||
}
|
||||
|
||||
real TCodiceIVA::imposta(const real& imponibile, int ndec, const char* codval) const
|
||||
{
|
||||
real iva = imponibile * percentuale() / CENTO;
|
||||
round(iva, ndec, codval);
|
||||
return iva;
|
||||
}
|
||||
|
||||
real TCodiceIVA::scorpora(real& lordo, int ndec, const char* codval) const
|
||||
{
|
||||
const real percent = percentuale();
|
||||
real iva = (lordo * percent) / (percent + CENTO);
|
||||
real imponibile = lordo - iva;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
round(lordo, ndec, codval); // Arrotondo importo lordo
|
||||
real imponibile = lordo * CENTO / (CENTO + percentuale());
|
||||
round(imponibile, ndec, codval); // Arrotondo importo netto
|
||||
const real iva = lordo - imponibile;
|
||||
lordo = imponibile; // lordo è un reference da aggiornare con l'imponibile!
|
||||
return iva;
|
||||
}
|
||||
|
||||
real TCodiceIVA::lordo(const real& imponibile, int ndec, const char* codval) const
|
||||
{
|
||||
return imponibile + imposta(imponibile, ndec, codval);
|
||||
}
|
||||
{ return imponibile + imposta(imponibile, ndec, codval); }
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
@ -138,6 +138,7 @@ class TCodiceIVA : public TRectype
|
||||
{
|
||||
protected:
|
||||
void copy(const TRectype & iva) { TRectype::operator =(iva); }
|
||||
void round(real& n, int ndec, const char* codval) const;
|
||||
|
||||
public: // TObject
|
||||
virtual bool ok() const { return !empty(); }
|
||||
@ -152,8 +153,8 @@ public: // TObject
|
||||
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 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 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
|
||||
|
||||
TCodiceIVA(const char* codice = NULL);
|
||||
TCodiceIVA(const TRectype & rec) : TRectype(rec) {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user