Patch level :4.0 nopatch x ora

Files correlati     :cg7.exe
Ricompilazione Demo : [ ]
Commento            :tentativo di correggere errori enrichettici


git-svn-id: svn://10.65.10.50/trunk@14706 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca 2007-01-03 12:40:58 +00:00
parent d4fc7c73aa
commit 75ab480d62

View File

@ -273,7 +273,7 @@ protected:
bool i_proforma_clifor(char tipocf = 'C'); bool i_proforma_clifor(char tipocf = 'C');
bool i_proforma_conti(); bool i_proforma_conti();
real totale_documento(const TRectype& mov) const; real totale_documento(TMovimentoPN& pn) const;
void lettura_conti(TAssoc_array& assoc, const char tipoconto); void lettura_conti(TAssoc_array& assoc, const char tipoconto);
bool cerca_conto(const TBill& bill, const TAssoc_array& assoc, const char tipoconto) const; bool cerca_conto(const TBill& bill, const TAssoc_array& assoc, const char tipoconto) const;
bool cerca_fiscali(const TBill& bill) const; bool cerca_fiscali(const TBill& bill) const;
@ -822,25 +822,54 @@ void TInvioP::stringa_grcosot(TRecord_text& recrighe, const TString& zio)
// Calcola il totale del documento tenendo conto del segno della prima riga e di quella delle // Calcola il totale del documento tenendo conto del segno della prima riga e di quella delle
// ritenute sociali sulla causale // ritenute sociali sulla causale
real TInvioP::totale_documento(const TRectype& mov) const real TInvioP::totale_documento(TMovimentoPN& pn) const
{ {
real tot = mov.get_real(MOV_TOTDOC); // Legge totale //testata del movimento di prima nota
const real ritfis = mov.get_real(MOV_RITFIS); const TRectype& mov = pn.curr();
tot += ritfis; // Somma ritenute fiscali
const real ritsoc = mov.get_real(MOV_RITSOC);
if (!ritsoc.is_zero()) real tot = mov.get_real(MOV_TOTDOC); // Legge totale
//i conti sulle ritenute li deve fare solo se il movimento e' iva!!
if (pn.iva_items() > 0)
{
const real ritfis = mov.get_real(MOV_RITFIS);
tot += ritfis; // Somma ritenute fiscali
const real ritsoc = mov.get_real(MOV_RITSOC);
if (!ritsoc.is_zero())
{
TCausale caus(mov.get(MOV_CODCAUS));
const bool swapt = test_swap(caus, false); // Totale invertito ?
const bool swaps = test_swap(caus, true); // Ritenute sociali invertite ?
if (swapt ^ swaps) // Somma ritenute sociali con segno
tot -= ritsoc;
else
tot += ritsoc;
}
}
else //movimenti non iva; calcolo delle ritenute
{ {
TCausale caus(mov.get(MOV_CODCAUS)); TCausale caus(mov.get(MOV_CODCAUS));
const bool swapt = test_swap(caus, false); // Totale invertito ? const char sez = caus.sezione_clifo();
const bool swaps = test_swap(caus, true); // Ritenute sociali invertite ? bool tot_is_zero = tot.is_zero();
if (swapt ^ swaps) // Somma ritenute sociali con segno TImporto totdoc(sez, tot);
tot -= ritsoc; for (int i = 0; i < pn.cg_items(); i++)
else {
tot += ritsoc; const TRectype& rmov = pn.cg(i);
const TBill conto(rmov);
const TImporto importo(rmov.get_char(RMV_SEZIONE), rmov.get_real(RMV_IMPORTO));
if (cerca_fiscali(conto) || cerca_sociali(conto))
{
totdoc += importo; //valore da stampare nella colonna Tot.fattura con ritenute
}
else //non si puo' avere un conto C/F tra quelli fiscali e sociali!
{
if (tot_is_zero && rmov.get_char(RMV_TIPOC) > ' ')
totdoc += importo;
}
}
tot = totdoc.valore();
} }
return tot; return tot;
} }
@ -891,11 +920,17 @@ int TInvioP::cerca_pagamento(const TBill& bill) const
bool TInvioP::cerca_fiscali(const TBill& bill) const bool TInvioP::cerca_fiscali(const TBill& bill) const
{ {
if (bill.tipo() > ' ') //non si vogliono i conti tipo Cliente Fornitore
return false;
return cerca_conto(bill, _fiscali, 'F'); return cerca_conto(bill, _fiscali, 'F');
} }
bool TInvioP::cerca_sociali(const TBill& bill) const bool TInvioP::cerca_sociali(const TBill& bill) const
{ {
if (bill.tipo() > ' ') //non si vogliono i conti tipo Cliente Fornitore
return false;
return cerca_conto(bill, _sociali, 'S'); return cerca_conto(bill, _sociali, 'S');
} }
@ -962,40 +997,28 @@ bool TInvioP::calcola_imponibile_totdoc(const long nreg, const TRectype& pag_rec
imposta += iva; imposta += iva;
} }
} }
totdoc = totale_documento(pn.curr()); //tot doc con ritenute fiscali + ritenute sociali (da stampare) totdoc = totale_documento(pn); //tot doc con ritenute fiscali + ritenute sociali
} //if pn.iva_items()..
else //movimento NON iva
{
for (int i = 0; i < pn.cg_items(); i++)
{
const TRectype& rmov = pn.cg(i);
const TBill conto(rmov);
TImporto importo(rmov.get_char(RMV_SEZIONE), rmov.get_real(RMV_IMPORTO)); } //if pn.iva_items()..
importo.normalize('D'); else //NON iva
{
totdoc = totale_documento(pn); //tot doc con ritenute fiscali + ritenute sociali
imponibile = totdoc; //nel caso di non iva
if (conto.tipo() > ' ') //e' un conto cliente/fornitore... TCausale caus(pn.curr().get(MOV_CODCAUS));
totdoc -= importo.valore(); TImporto totpag(caus.sezione_clifo(), totpagato);
else //..e' un conto normale for (int i = 0; i < pn.cg_items(); i++)
{ {
if (cerca_fiscali(conto) || cerca_sociali(conto)) const TRectype& rmov = pn.cg(i);
totdoc -= importo.valore(); //valore da stampare nella colonna Tot.fattura con ritenute const TBill conto(rmov);
else if (cerca_fiscali(conto) || cerca_sociali(conto))
{ {
if (rmov.get_char(RMV_ROWTYPE) != 'T' && conto.indicatore_bilancio() != 5) const TImporto importo(rmov.get_char(RMV_SEZIONE), rmov.get_real(RMV_IMPORTO));
{ totpag += importo; //valore da stampare nella colonna Tot.fattura con ritenute
imponibile += importo.valore(); }
totdoc += importo.valore(); }
} totpagato = totpag.valore();
} }
} //else di if (conto.tipo()
} //for (int i = 0...
//tanti calcoli per nulla?
const real totdoc_testata = totale_documento(pn.curr());
if (totdoc_testata != ZERO)
totdoc = totdoc_testata;
} //end di else pn.iva_items()...
} //if (pn.read() == NOERR } //if (pn.read() == NOERR
return ok; return ok;
} }