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
117
cg/cg7200.cpp
117
cg/cg7200.cpp
@ -257,7 +257,6 @@ class TInvioP : public TSkeleton_application
|
||||
TInvioP_mask* _msk;
|
||||
TDate _dataini, _datafin;
|
||||
long _nregcosto, _nregpag;
|
||||
bool _chiusa;
|
||||
real _importo;
|
||||
TConfig* _configfile;
|
||||
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_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);
|
||||
bool cerca_conto(const TBill& bill, const TAssoc_array& assoc, const char tipoconto) const;
|
||||
bool cerca_fiscali(const TBill& bill) const;
|
||||
@ -292,7 +291,6 @@ public:
|
||||
const real get_importo() {return _importo;};
|
||||
const long get_nregcosto() const {return _nregcosto;};
|
||||
const long get_nregpag() const {return _nregpag;};
|
||||
const bool get_chiusa() const {return _chiusa;};
|
||||
const TString& get_vocespesa(const TString& zio) const;
|
||||
TInvioP_file* apri_file(const char* nome);
|
||||
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")
|
||||
{
|
||||
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)
|
||||
valore = "S";
|
||||
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
|
||||
// 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
|
||||
const TRectype& mov = pn.curr();
|
||||
@ -831,20 +831,23 @@ real TInvioP::totale_documento(TMovimentoPN& pn) const
|
||||
//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())
|
||||
if (includi_ritenute)
|
||||
{
|
||||
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;
|
||||
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
|
||||
@ -858,14 +861,13 @@ real TInvioP::totale_documento(TMovimentoPN& pn) const
|
||||
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;
|
||||
else
|
||||
{
|
||||
if (tot_is_zero && rmov.get_char(RMV_TIPOC) > ' ')
|
||||
totdoc += importo;
|
||||
if (includi_ritenute && (cerca_fiscali(conto) || cerca_sociali(conto)))
|
||||
totdoc += importo; //valore da stampare nella colonna Tot.fattura con ritenute
|
||||
}
|
||||
}
|
||||
tot = totdoc.valore();
|
||||
@ -948,26 +950,41 @@ 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;
|
||||
totpagato = pag_rec.get_real(PAGSCA_IMPORTO);
|
||||
|
||||
TMovimentoPN pn;
|
||||
pn.curr().put(MOV_NUMREG, nreg);
|
||||
bool ok = nreg > 0 && pn.read() == NOERR;
|
||||
if (ok)
|
||||
{
|
||||
//Movimenti CON SALDACONTO
|
||||
//se movimento IVA..
|
||||
//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
|
||||
//se movimento IVA..
|
||||
if (pn.iva_items() > 0)
|
||||
{
|
||||
real imposta;
|
||||
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;
|
||||
|
||||
//Le ritenute sociali invece vanno testate con la test_swap..
|
||||
real ritsoc = pag_rec.get_real(PAGSCA_RITSOC);
|
||||
ritsoc += movfat.get_real(MOV_RITSOC);
|
||||
|
||||
real 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())
|
||||
{
|
||||
const TRectype& mov = pn.curr();
|
||||
@ -1013,7 +1030,13 @@ bool TInvioP::calcola_imponibile_totdoc(const long nreg, const TRectype& pag_rec
|
||||
const TBill conto(rmov);
|
||||
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
|
||||
}
|
||||
}
|
||||
@ -1047,17 +1070,30 @@ real TInvioP::calcola_pagamento(TRectype& curpag_rec)
|
||||
if (calcola_imponibile_totdoc(nreg, curpag_rec, imponibile, totdoc, totpagato))
|
||||
{
|
||||
const real percentuale = totpagato /totdoc;
|
||||
|
||||
bool ricalcola = true;
|
||||
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;
|
||||
{
|
||||
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;
|
||||
}
|
||||
} //if(fdr!=nreg..
|
||||
|
||||
if (ricalcola)
|
||||
{
|
||||
//calcolo finale del pagato
|
||||
totpagato = imponibile * percentuale;
|
||||
totpagato.round(2);
|
||||
}
|
||||
//calcolo finale del pagato
|
||||
totpagato = imponibile * percentuale;
|
||||
totpagato.round(2);
|
||||
}
|
||||
|
||||
return totpagato;
|
||||
@ -1201,7 +1237,7 @@ bool TInvioP::i_proforma_pagamenti()
|
||||
const long nregfatt = fattura.get_long(PART_NREG);
|
||||
_nregcosto = calcola_fattura_originale(nregfatt);
|
||||
_importo = *cp;
|
||||
_chiusa = fattura.get_bool(PART_CHIUSA);
|
||||
|
||||
TRecord_text recpag;
|
||||
recpag.set_type("G");
|
||||
trasfilepag->autoload(recpag, curpag);
|
||||
@ -1265,7 +1301,6 @@ bool TInvioP::i_proforma_pagamenti()
|
||||
_nregpag = numregcg;
|
||||
_nregcosto = numregcg;
|
||||
_importo = imp.valore();
|
||||
_chiusa = true;
|
||||
|
||||
//e finalmente aggiunge il record al file di esportazione
|
||||
TRecord_text recpag;
|
||||
|
Loading…
x
Reference in New Issue
Block a user