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@14723 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
6bc8185742
commit
f8c0767fb8
@ -257,7 +257,6 @@ class TInvioP : public TSkeleton_application
|
|||||||
TInvioP_mask* _msk;
|
TInvioP_mask* _msk;
|
||||||
TDate _dataini, _datafin;
|
TDate _dataini, _datafin;
|
||||||
long _nregcosto, _nregpag;
|
long _nregcosto, _nregpag;
|
||||||
bool _chiusa;
|
|
||||||
real _importo;
|
real _importo;
|
||||||
TConfig* _configfile;
|
TConfig* _configfile;
|
||||||
TAssoc_array _fiscali,_sociali, _costi, _pagamenti; //array che contengono i conti
|
TAssoc_array _fiscali,_sociali, _costi, _pagamenti; //array che contengono i conti
|
||||||
@ -273,7 +272,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(TMovimentoPN& pn) const;
|
real totale_documento(TMovimentoPN& pn, const bool includi_ritenute = true) 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;
|
||||||
@ -292,7 +291,6 @@ public:
|
|||||||
const real get_importo() {return _importo;};
|
const real get_importo() {return _importo;};
|
||||||
const long get_nregcosto() const {return _nregcosto;};
|
const long get_nregcosto() const {return _nregcosto;};
|
||||||
const long get_nregpag() const {return _nregpag;};
|
const long get_nregpag() const {return _nregpag;};
|
||||||
const bool get_chiusa() const {return _chiusa;};
|
|
||||||
const TString& get_vocespesa(const TString& zio) const;
|
const TString& get_vocespesa(const TString& zio) const;
|
||||||
TInvioP_file* apri_file(const char* nome);
|
TInvioP_file* apri_file(const char* nome);
|
||||||
void chiudi_file(TInvioP_file* trasfile);
|
void chiudi_file(TInvioP_file* trasfile);
|
||||||
@ -335,7 +333,9 @@ void TInvioP_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TS
|
|||||||
}
|
}
|
||||||
else if (code == "_FLAG")
|
else if (code == "_FLAG")
|
||||||
{
|
{
|
||||||
const bool chiusa = app().get_chiusa();
|
bool chiusa = true;
|
||||||
|
if (cur.file().num() == LF_PAGSCA)
|
||||||
|
chiusa = cur.curr().get_char(PAGSCA_ACCSAL) == 'S';
|
||||||
if (chiusa)
|
if (chiusa)
|
||||||
valore = "S";
|
valore = "S";
|
||||||
else
|
else
|
||||||
@ -822,7 +822,7 @@ 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(TMovimentoPN& pn) const
|
real TInvioP::totale_documento(TMovimentoPN& pn, const bool includi_ritenute) const
|
||||||
{
|
{
|
||||||
//testata del movimento di prima nota
|
//testata del movimento di prima nota
|
||||||
const TRectype& mov = pn.curr();
|
const TRectype& mov = pn.curr();
|
||||||
@ -830,6 +830,8 @@ real TInvioP::totale_documento(TMovimentoPN& pn) const
|
|||||||
real tot = mov.get_real(MOV_TOTDOC); // Legge totale
|
real tot = mov.get_real(MOV_TOTDOC); // Legge totale
|
||||||
//i conti sulle ritenute li deve fare solo se il movimento e' iva!!
|
//i conti sulle ritenute li deve fare solo se il movimento e' iva!!
|
||||||
if (pn.iva_items() > 0)
|
if (pn.iva_items() > 0)
|
||||||
|
{
|
||||||
|
if (includi_ritenute)
|
||||||
{
|
{
|
||||||
const real ritfis = mov.get_real(MOV_RITFIS);
|
const real ritfis = mov.get_real(MOV_RITFIS);
|
||||||
tot += ritfis; // Somma ritenute fiscali
|
tot += ritfis; // Somma ritenute fiscali
|
||||||
@ -847,6 +849,7 @@ real TInvioP::totale_documento(TMovimentoPN& pn) const
|
|||||||
tot += ritsoc;
|
tot += ritsoc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else //movimenti non iva; calcolo delle ritenute
|
else //movimenti non iva; calcolo delle ritenute
|
||||||
{
|
{
|
||||||
TCausale caus(mov.get(MOV_CODCAUS));
|
TCausale caus(mov.get(MOV_CODCAUS));
|
||||||
@ -858,14 +861,13 @@ real TInvioP::totale_documento(TMovimentoPN& pn) const
|
|||||||
const TRectype& rmov = pn.cg(i);
|
const TRectype& rmov = pn.cg(i);
|
||||||
const TBill conto(rmov);
|
const TBill conto(rmov);
|
||||||
const TImporto importo(rmov.get_char(RMV_SEZIONE), rmov.get_real(RMV_IMPORTO));
|
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) > ' ')
|
if (tot_is_zero && rmov.get_char(RMV_TIPOC) > ' ')
|
||||||
totdoc += importo;
|
totdoc += importo;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (includi_ritenute && (cerca_fiscali(conto) || cerca_sociali(conto)))
|
||||||
|
totdoc += importo; //valore da stampare nella colonna Tot.fattura con ritenute
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tot = totdoc.valore();
|
tot = totdoc.valore();
|
||||||
@ -948,12 +950,16 @@ 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
|
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);
|
totpagato = pag_rec.get_real(PAGSCA_IMPORTO);
|
||||||
|
|
||||||
TMovimentoPN pn;
|
TMovimentoPN pn;
|
||||||
pn.curr().put(MOV_NUMREG, nreg);
|
pn.curr().put(MOV_NUMREG, nreg);
|
||||||
bool ok = nreg > 0 && pn.read() == NOERR;
|
bool ok = nreg > 0 && pn.read() == NOERR;
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
|
//percentuale di pagamento sul totale documento senza ritenute
|
||||||
|
const real totdoc_no_rit = totale_documento(pn, false);
|
||||||
|
const real perc_ritenute = totpagato / totdoc_no_rit;
|
||||||
//Movimenti CON SALDACONTO
|
//Movimenti CON SALDACONTO
|
||||||
//se movimento IVA..
|
//se movimento IVA..
|
||||||
if (pn.iva_items() > 0)
|
if (pn.iva_items() > 0)
|
||||||
@ -961,12 +967,23 @@ bool TInvioP::calcola_imponibile_totdoc(const long nreg, const TRectype& pag_rec
|
|||||||
real imposta;
|
real imposta;
|
||||||
const TRectype& movfat = pn.curr();
|
const TRectype& movfat = pn.curr();
|
||||||
|
|
||||||
const real ritfis = movfat.get_real(MOV_RITFIS);
|
real ritfis = movfat.get_real(MOV_RITFIS); //ritenute sulla fattura: verranno pagate percentualmente
|
||||||
|
if (perc_ritenute < UNO)
|
||||||
|
{
|
||||||
|
ritfis *= perc_ritenute;
|
||||||
|
ritfis.round(2);
|
||||||
|
}
|
||||||
|
totpagato += pag_rec.get_real(PAGSCA_RITENUTE); //ritenute eventuali sul pagamento
|
||||||
totpagato += ritfis;
|
totpagato += ritfis;
|
||||||
|
|
||||||
//Le ritenute sociali invece vanno testate con la test_swap..
|
//Le ritenute sociali invece vanno testate con la test_swap..
|
||||||
real ritsoc = pag_rec.get_real(PAGSCA_RITSOC);
|
real ritsoc = movfat.get_real(MOV_RITSOC);
|
||||||
ritsoc += movfat.get_real(MOV_RITSOC);
|
if (perc_ritenute < UNO)
|
||||||
|
{
|
||||||
|
ritsoc *= perc_ritenute;
|
||||||
|
ritsoc.round(2);
|
||||||
|
}
|
||||||
|
ritsoc += pag_rec.get_real(PAGSCA_RITSOC);
|
||||||
|
|
||||||
if (!ritsoc.is_zero())
|
if (!ritsoc.is_zero())
|
||||||
{
|
{
|
||||||
@ -1013,7 +1030,13 @@ bool TInvioP::calcola_imponibile_totdoc(const long nreg, const TRectype& pag_rec
|
|||||||
const TBill conto(rmov);
|
const TBill conto(rmov);
|
||||||
if (cerca_fiscali(conto) || cerca_sociali(conto))
|
if (cerca_fiscali(conto) || cerca_sociali(conto))
|
||||||
{
|
{
|
||||||
const TImporto importo(rmov.get_char(RMV_SEZIONE), rmov.get_real(RMV_IMPORTO));
|
real imp = rmov.get_real(RMV_IMPORTO);
|
||||||
|
if (perc_ritenute < UNO)
|
||||||
|
{
|
||||||
|
imp *= perc_ritenute;
|
||||||
|
imp.round(2);
|
||||||
|
}
|
||||||
|
const TImporto importo(rmov.get_char(RMV_SEZIONE), imp);
|
||||||
totpag += importo; //valore da stampare nella colonna Tot.fattura con ritenute
|
totpag += importo; //valore da stampare nella colonna Tot.fattura con ritenute
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1047,17 +1070,30 @@ real TInvioP::calcola_pagamento(TRectype& curpag_rec)
|
|||||||
if (calcola_imponibile_totdoc(nreg, curpag_rec, imponibile, totdoc, totpagato))
|
if (calcola_imponibile_totdoc(nreg, curpag_rec, imponibile, totdoc, totpagato))
|
||||||
{
|
{
|
||||||
const real percentuale = totpagato /totdoc;
|
const real percentuale = totpagato /totdoc;
|
||||||
|
bool ricalcola = true;
|
||||||
const long fdr = calcola_fattura_originale(nreg);
|
const long fdr = calcola_fattura_originale(nreg);
|
||||||
if (fdr != nreg)
|
if (fdr != nreg)
|
||||||
{
|
{
|
||||||
real imponibile_fdr, totdoc_fdr, totpagato_fdr;
|
real imponibile_fdr, totdoc_fdr, totpagato_fdr;
|
||||||
if (calcola_imponibile_totdoc(fdr, curpag_rec, imponibile_fdr, totdoc_fdr, totpagato_fdr))
|
if (calcola_imponibile_totdoc(fdr, curpag_rec, imponibile_fdr, totdoc_fdr, totpagato_fdr))
|
||||||
|
{
|
||||||
|
const real rapporto_pagati = totdoc / totdoc_fdr;
|
||||||
|
//la fattura con totdoc paga una parte di una precedente fdr con totdoc maggiore!
|
||||||
|
//in questo caso totpagato e' quello della fattura e deve uscire senza ricalcolare..
|
||||||
|
//..percentuali e cazzi vari
|
||||||
|
if (rapporto_pagati < 0.7)
|
||||||
|
ricalcola = false;
|
||||||
|
else //la fattura paga per intero la fdr
|
||||||
imponibile = imponibile_fdr;
|
imponibile = imponibile_fdr;
|
||||||
}
|
}
|
||||||
|
} //if(fdr!=nreg..
|
||||||
|
|
||||||
|
if (ricalcola)
|
||||||
|
{
|
||||||
//calcolo finale del pagato
|
//calcolo finale del pagato
|
||||||
totpagato = imponibile * percentuale;
|
totpagato = imponibile * percentuale;
|
||||||
totpagato.round(2);
|
totpagato.round(2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return totpagato;
|
return totpagato;
|
||||||
@ -1201,7 +1237,7 @@ bool TInvioP::i_proforma_pagamenti()
|
|||||||
const long nregfatt = fattura.get_long(PART_NREG);
|
const long nregfatt = fattura.get_long(PART_NREG);
|
||||||
_nregcosto = calcola_fattura_originale(nregfatt);
|
_nregcosto = calcola_fattura_originale(nregfatt);
|
||||||
_importo = *cp;
|
_importo = *cp;
|
||||||
_chiusa = fattura.get_bool(PART_CHIUSA);
|
|
||||||
TRecord_text recpag;
|
TRecord_text recpag;
|
||||||
recpag.set_type("G");
|
recpag.set_type("G");
|
||||||
trasfilepag->autoload(recpag, curpag);
|
trasfilepag->autoload(recpag, curpag);
|
||||||
@ -1265,7 +1301,6 @@ bool TInvioP::i_proforma_pagamenti()
|
|||||||
_nregpag = numregcg;
|
_nregpag = numregcg;
|
||||||
_nregcosto = numregcg;
|
_nregcosto = numregcg;
|
||||||
_importo = imp.valore();
|
_importo = imp.valore();
|
||||||
_chiusa = true;
|
|
||||||
|
|
||||||
//e finalmente aggiunge il record al file di esportazione
|
//e finalmente aggiunge il record al file di esportazione
|
||||||
TRecord_text recpag;
|
TRecord_text recpag;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user