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@14699 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
e9a4e4b36b
commit
d11ebcd2ea
205
cg/cg7200.cpp
205
cg/cg7200.cpp
@ -285,6 +285,8 @@ protected:
|
||||
bool sottrai_iva(TMovimentoPN& pn, const TRectype& rigaiva);
|
||||
void stringa_grcosot(TRecord_text& recrighe, const TString& zio);
|
||||
long calcola_fattura_originale(long nreg) const;
|
||||
bool calcola_imponibile_totdoc(const long nreg, const TRectype& pag_rec,
|
||||
real& imponibile, real& totdoc, real& totpagato) const;
|
||||
|
||||
public:
|
||||
const real get_importo() {return _importo;};
|
||||
@ -909,10 +911,97 @@ void TInvioP::lettura_conti(TAssoc_array& assoc, const char tipoconto)
|
||||
}
|
||||
}
|
||||
|
||||
bool TInvioP::calcola_imponibile_totdoc(const long nreg, const TRectype& pag_rec, real& imponibile, real& totdoc, real& totpagato) const
|
||||
{
|
||||
totpagato = pag_rec.get_real(PAGSCA_IMPORTO) + pag_rec.get_real(PAGSCA_RITENUTE);
|
||||
TMovimentoPN pn;
|
||||
pn.curr().put(MOV_NUMREG, nreg);
|
||||
bool ok = nreg > 0 && pn.read() == NOERR;
|
||||
if (ok)
|
||||
{
|
||||
//Movimenti CON SALDACONTO
|
||||
//se movimento IVA..
|
||||
if (pn.iva_items() > 0)
|
||||
{
|
||||
real imposta;
|
||||
const TRectype& movfat = pn.curr();
|
||||
|
||||
const real ritfis = movfat.get_real(MOV_RITFIS);
|
||||
totpagato += ritfis;
|
||||
|
||||
//Le ritenute sociali invece vanno testate con la test_swap..
|
||||
real ritsoc = pag_rec.get_real(PAGSCA_RITSOC);
|
||||
ritsoc += movfat.get_real(MOV_RITSOC);
|
||||
|
||||
if (!ritsoc.is_zero())
|
||||
{
|
||||
const TRectype& mov = pn.curr();
|
||||
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
|
||||
totpagato -= ritsoc;
|
||||
else
|
||||
totpagato += ritsoc;
|
||||
}
|
||||
for (int i = 0; i < pn.iva_items(); i++)
|
||||
{
|
||||
const TRectype& rmoviva = pn.iva(i);
|
||||
const TBill conto(rmoviva);
|
||||
|
||||
if (conto.indicatore_bilancio() != 5)
|
||||
{
|
||||
const real importo = rmoviva.get_real(RMI_IMPONIBILE);
|
||||
real iva = rmoviva.get_real(RMI_IMPOSTA);
|
||||
const TString& tipodet = rmoviva.get(RMI_TIPODET);
|
||||
|
||||
imponibile += importo;
|
||||
if (tipodet.full())
|
||||
imponibile += iva;
|
||||
else
|
||||
imposta += iva;
|
||||
}
|
||||
}
|
||||
totdoc = totale_documento(pn.curr()); //tot doc con ritenute fiscali + ritenute sociali (da stampare)
|
||||
} //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));
|
||||
importo.normalize('D');
|
||||
|
||||
if (conto.tipo() > ' ') //e' un conto cliente/fornitore...
|
||||
totdoc -= importo.valore();
|
||||
else //..e' un conto normale
|
||||
{
|
||||
if (cerca_fiscali(conto) || cerca_sociali(conto))
|
||||
totdoc -= importo.valore(); //valore da stampare nella colonna Tot.fattura con ritenute
|
||||
else
|
||||
{
|
||||
if (rmov.get_char(RMV_ROWTYPE) != 'T' && conto.indicatore_bilancio() != 5)
|
||||
{
|
||||
imponibile += importo.valore();
|
||||
totdoc += importo.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
|
||||
return ok;
|
||||
}
|
||||
|
||||
real TInvioP::calcola_pagamento(TRectype& curpag_rec)
|
||||
{
|
||||
real totpagato = curpag_rec.get_real(PAGSCA_IMPORTO) + curpag_rec.get_real(PAGSCA_RITENUTE);
|
||||
|
||||
//deve costruirsi la riga di partita che riguarda il documento di origine
|
||||
//per prima cosa crea tale riga a partire dal pagamento, che ha una chiave lunghissima...
|
||||
TToken_string key_part;
|
||||
@ -928,99 +1017,26 @@ real TInvioP::calcola_pagamento(TRectype& curpag_rec)
|
||||
//..da cui prende nreg
|
||||
const long nreg = rec_partite.get_long(PART_NREG);
|
||||
//se nreg esiste...
|
||||
if (nreg != 0)
|
||||
{
|
||||
TMovimentoPN pn;
|
||||
pn.curr().put(MOV_NUMREG, nreg);
|
||||
if (pn.read() == NOERR)
|
||||
{
|
||||
//dichiariamo una serie di simpatici real utilizzati in seguito
|
||||
real totdoc,imponibile;
|
||||
|
||||
//Movimenti CON SALDACONTO
|
||||
//se movimento IVA..
|
||||
if (pn.iva_items() > 0)
|
||||
{
|
||||
real imposta;
|
||||
const TRectype& movfat = pn.curr();
|
||||
//dichiariamo una serie di simpatici real utilizzati in seguito
|
||||
real totdoc,imponibile,totpagato;
|
||||
|
||||
const real ritfis = movfat.get_real(MOV_RITFIS);
|
||||
totpagato += ritfis;
|
||||
if (calcola_imponibile_totdoc(nreg, curpag_rec, imponibile, totdoc, totpagato))
|
||||
{
|
||||
const real percentuale = totpagato /totdoc;
|
||||
|
||||
//Le ritenute sociali invece vanno testate con la test_swap..
|
||||
real ritsoc = curpag_rec.get_real(PAGSCA_RITSOC);
|
||||
ritsoc += movfat.get_real(MOV_RITSOC);
|
||||
const long fdr = calcola_fattura_originale(nreg);
|
||||
if (fdr != nreg)
|
||||
{
|
||||
real imponibile_fdr, totdoc_fdr, totpagato_fdr;
|
||||
if (calcola_imponibile_totdoc(fdr, curpag_rec, imponibile_fdr, totdoc_fdr, totpagato_fdr))
|
||||
imponibile = imponibile_fdr;
|
||||
}
|
||||
//calcolo finale del pagato
|
||||
totpagato = imponibile * percentuale;
|
||||
totpagato.round(2);
|
||||
}
|
||||
|
||||
if (!ritsoc.is_zero())
|
||||
{
|
||||
const TRectype& mov = pn.curr();
|
||||
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
|
||||
totpagato -= ritsoc;
|
||||
else
|
||||
totpagato += ritsoc;
|
||||
}
|
||||
for (int i = 0; i < pn.iva_items(); i++)
|
||||
{
|
||||
const TRectype& rmoviva = pn.iva(i);
|
||||
const TBill conto(rmoviva);
|
||||
|
||||
if (conto.indicatore_bilancio() != 5)
|
||||
{
|
||||
const real importo = rmoviva.get_real(RMI_IMPONIBILE);
|
||||
real iva = rmoviva.get_real(RMI_IMPOSTA);
|
||||
const TString& tipodet = rmoviva.get(RMI_TIPODET);
|
||||
|
||||
imponibile += importo;
|
||||
if (tipodet.full())
|
||||
imponibile += iva;
|
||||
else
|
||||
imposta += iva;
|
||||
}
|
||||
}
|
||||
totdoc = totale_documento(pn.curr()); //tot doc con ritenute fiscali + ritenute sociali (da stampare)
|
||||
} //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));
|
||||
importo.normalize('D');
|
||||
|
||||
if (conto.tipo() > ' ') //e' un conto cliente/fornitore...
|
||||
totdoc -= importo.valore();
|
||||
else //..e' un conto normale
|
||||
{
|
||||
if (cerca_fiscali(conto) || cerca_sociali(conto))
|
||||
totdoc -= importo.valore(); //valore da stampare nella colonna Tot.fattura con ritenute
|
||||
else
|
||||
{
|
||||
if (rmov.get_char(RMV_ROWTYPE) != 'T' && conto.indicatore_bilancio() != 5)
|
||||
{
|
||||
imponibile += importo.valore();
|
||||
totdoc += importo.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()...
|
||||
|
||||
//calcolo finale del pagato
|
||||
real percentuale = totpagato /totdoc;
|
||||
totpagato = imponibile * percentuale;
|
||||
|
||||
}
|
||||
}
|
||||
return totpagato;
|
||||
}
|
||||
|
||||
@ -1056,7 +1072,9 @@ long TInvioP::calcola_fattura_originale(long nreg) const
|
||||
//..come nreg da ritornare (attenzione che se il doc originale non e' stato contabilizzato..
|
||||
//..nreg diventa 0!)
|
||||
if (!original_doc.empty())
|
||||
{
|
||||
nreg = original_doc.get_long(DOC_NUMREG);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1155,9 +1173,10 @@ bool TInvioP::i_proforma_pagamenti()
|
||||
keypart.add(curpart_rec.get(PART_SOTTOCONTO));
|
||||
keypart.add(pagame.get_hashobj()->key());
|
||||
const TRectype& fattura = cache().get(LF_PARTITE, keypart);
|
||||
_nregpag = cur_rec.get_long(MOV_NUMREG);
|
||||
_nregpag = cur_rec.get_long(MOV_NUMREG); //registrazione del movimento di pagamento
|
||||
//deve cercare la prima registrazione da cui deriva il pagamento..
|
||||
_nregcosto = calcola_fattura_originale(fattura.get_long(PART_NREG));
|
||||
const long nregfatt = fattura.get_long(PART_NREG);
|
||||
_nregcosto = calcola_fattura_originale(nregfatt);
|
||||
_importo = *cp;
|
||||
_chiusa = fattura.get_bool(PART_CHIUSA);
|
||||
TRecord_text recpag;
|
||||
|
Loading…
x
Reference in New Issue
Block a user