Patch level : 12.0 594
Files correlati : cg Commento : Patch di Alessandro, corretta generazione buoni automatici e ritenute sociali
This commit is contained in:
parent
d58c695098
commit
94a91ea0a3
@ -222,20 +222,17 @@ bool TCausale::link_industriale() const
|
||||
bool TCausale::ok() const
|
||||
{ return iva() != iva_errata; }
|
||||
|
||||
char TCausale::sezione(int riga) const
|
||||
char TCausale::sezione(int riga, bool low_level) const
|
||||
{
|
||||
const TRectype* rec = row(riga);
|
||||
char sez = rec ? toupper(rec->get_char(RCA_SEZIONE)) : ' ';
|
||||
if (sez <= ' ') // Guess section on tipocf
|
||||
if (sez <= ' ' && !low_level) // Guess section on tipocf
|
||||
{
|
||||
const TRectype* uno = row(1);
|
||||
char tipocf = uno ? toupper(uno->get_char(RCA_TIPOCF)) : ' ';
|
||||
if (tipocf <= ' ')
|
||||
tipocf = (iva() == iva_vendite) ? 'C' : 'F'; // Guess tipocf on IVA
|
||||
if (tipomov() <= tm_nota_credito)
|
||||
sez = (tipocf == 'C') ? 'D' : 'A';
|
||||
else
|
||||
sez = (tipocf == 'C') ? 'A' : 'D';
|
||||
sez = (tipocf == 'C') ? 'D' : 'A';
|
||||
}
|
||||
return sez;
|
||||
}
|
||||
@ -252,9 +249,9 @@ char TCausale::sezione_ritsoc() const
|
||||
if (_sezione_ritsoc <= ' ')
|
||||
{
|
||||
const tipo_movimento tm = tipomov();
|
||||
(char&)_sezione_ritsoc = sezione(tm<=tm_nota_credito ? RIGA_RITENUTE_SOCIALI : RIGA_PAG_RITSOC);
|
||||
(char&)_sezione_ritsoc = sezione(tm<=tm_nota_credito ? RIGA_RITENUTE_SOCIALI : RIGA_PAG_RITSOC, true);
|
||||
if (_sezione_ritsoc < 'A')
|
||||
(char&)_sezione_ritsoc = sezione_clifo();
|
||||
(char&)_sezione_ritsoc = (tm <= tm_nota_credito ? sezione_clifo() : (sezione_clifo()=='D' ? 'A' :'D'));
|
||||
}
|
||||
return _sezione_ritsoc;
|
||||
}
|
||||
@ -264,10 +261,10 @@ char TCausale::sezione_ritfis() const
|
||||
if (_sezione_ritfis == ' ')
|
||||
{
|
||||
const tipo_movimento tm = tipomov();
|
||||
(char&)_sezione_ritfis = sezione(tm<=tm_nota_credito ? RIGA_RITENUTE_FISCALI : RIGA_PAG_RITFIS); // Fatture o Pagamenti
|
||||
(char&)_sezione_ritfis = sezione(tm<=tm_nota_credito ? RIGA_RITENUTE_FISCALI : RIGA_PAG_RITFIS, true); // Fatture o Pagamenti
|
||||
if (_sezione_ritfis < 'A')
|
||||
(char&)_sezione_ritfis = sezione_clifo();
|
||||
}
|
||||
(char&)_sezione_ritfis = (tm <= tm_nota_credito ? sezione_clifo() : (sezione_clifo() == 'D' ? 'A' : 'D'));
|
||||
}
|
||||
return _sezione_ritfis;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
|
||||
const TString& compatible(const TCausale& c) const;
|
||||
|
||||
char sezione(int riga) const;
|
||||
char sezione(int riga, bool low_level = false) const;
|
||||
char sezione_clifo() const;
|
||||
char sezione_ritsoc() const;
|
||||
char sezione_ritfis() const;
|
||||
|
@ -1277,19 +1277,20 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
|
||||
const real new_ritenute(new_pag.get(PAGSCA_RITENUTE));
|
||||
if (old_ritenute != new_ritenute)
|
||||
{
|
||||
const TImporto grow_ritenute(sez, new_ritenute-old_ritenute);
|
||||
const int riga = type2pos('F');
|
||||
if (riga < 0)
|
||||
const TImporto grow_ritenute(causale().sezione_ritfis(), new_ritenute - old_ritenute);
|
||||
const int riga = type2pos('F');
|
||||
|
||||
if (riga < 0)
|
||||
{
|
||||
TBill conto_rit; causale().bill(RIGA_PAG_RITFIS, conto_rit);
|
||||
const TString desc(causale().desc_agg(RIGA_PAG_RITFIS));
|
||||
set_cgs_row(riga, grow_ritenute, conto_rit, desc, 'F');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool empty = add_cgs_imp(riga, grow_ritenute);
|
||||
if (empty) sheet.destroy(riga);
|
||||
}
|
||||
if (empty) sheet.destroy(riga);
|
||||
}
|
||||
}
|
||||
|
||||
// Aggiornamento ritenute sociali
|
||||
@ -1299,17 +1300,17 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
|
||||
{
|
||||
const TImporto grow_ritenute(causale().sezione_ritsoc(), new_ritsoc-old_ritsoc);
|
||||
const int riga = type2pos('S');
|
||||
if (riga < 0)
|
||||
if (riga < 0)
|
||||
{
|
||||
TBill conto_rit; causale().bill(RIGA_PAG_RITSOC, conto_rit);
|
||||
const TString desc(causale().desc_agg(RIGA_PAG_RITSOC));
|
||||
set_cgs_row(riga, grow_ritenute, conto_rit, desc, 'S');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool empty = add_cgs_imp(riga, grow_ritenute);
|
||||
if (empty) sheet.destroy(riga);
|
||||
}
|
||||
if (empty) sheet.destroy(riga);
|
||||
}
|
||||
}
|
||||
} // if (deleting >= 0)
|
||||
|
||||
|
@ -196,8 +196,9 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad,
|
||||
const TRiga_partite& sum = p.riga(nrigp);
|
||||
_assigned = oldpag.get_int(PAGSCA_NRIGA) != TPartita::UNASSIGNED;
|
||||
_tipomov = sum.tipo();
|
||||
_swap_ritsoc = sum.sezione() != sum.sezione_ritsoc();
|
||||
|
||||
_swap_ritfis = sum.sezione() != sum.sezione_ritfis();
|
||||
_swap_ritsoc = sum.sezione() != sum.sezione_ritsoc();
|
||||
|
||||
const TRiga_partite& fatt = _assigned ? scad.riga() : sum;
|
||||
|
||||
TRelation rel(LF_PAGSCA); // Working relation
|
||||
@ -283,12 +284,15 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad,
|
||||
real oldimp = oldpag.get_real(in_valuta ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO);
|
||||
if (!in_valuta)
|
||||
{
|
||||
oldimp += oldpag.get_real(PAGSCA_RITENUTE);
|
||||
|
||||
if (_swap_ritsoc)
|
||||
oldimp += oldpag.get_real(PAGSCA_RITENUTE);
|
||||
else
|
||||
oldimp -= oldpag.get_real(PAGSCA_RITENUTE);
|
||||
|
||||
if (_swap_ritsoc)
|
||||
oldimp -= oldpag.get_real(PAGSCA_RITSOC);
|
||||
else
|
||||
oldimp += oldpag.get_real(PAGSCA_RITSOC);
|
||||
else
|
||||
oldimp -= oldpag.get_real(PAGSCA_RITSOC);
|
||||
}
|
||||
|
||||
// Ricorda l'importo da pagare
|
||||
@ -414,8 +418,13 @@ bool TPay_mask::importo_handler(TMask_field& f, KEY k)
|
||||
imp = m.field(S_RESIDUORATA).shown() ? m._da_pagare : m._pagabile;
|
||||
#endif
|
||||
|
||||
if (m.field(S_RITENUTE).active())
|
||||
imp -= m.get_real(S_RITENUTE);
|
||||
if (m.field(S_RITENUTE).active())
|
||||
{
|
||||
if (m._swap_ritfis)
|
||||
imp += m.get_real(S_RITENUTE);
|
||||
else
|
||||
imp -= m.get_real(S_RITENUTE);
|
||||
}
|
||||
if (m.field(S_RITSOC).active())
|
||||
{
|
||||
if (m._swap_ritsoc)
|
||||
@ -436,13 +445,18 @@ bool TPay_mask::importo_handler(TMask_field& f, KEY k)
|
||||
|
||||
real i(f.get());
|
||||
if (m.field(S_RITENUTE).active())
|
||||
i += m.get_real(S_RITENUTE);
|
||||
{
|
||||
if (m._swap_ritfis)
|
||||
i += m.get_real(S_RITENUTE);
|
||||
else
|
||||
i -= m.get_real(S_RITENUTE);
|
||||
}
|
||||
if (m.field(S_RITSOC).active())
|
||||
{
|
||||
if (m._swap_ritsoc)
|
||||
i -= m.get_real(S_RITSOC);
|
||||
else
|
||||
i += m.get_real(S_RITSOC);
|
||||
else
|
||||
i -= m.get_real(S_RITSOC);
|
||||
}
|
||||
|
||||
TMask_field& sa = m.field(S_SALDOACC);
|
||||
@ -949,6 +963,8 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
}
|
||||
|
||||
const int lastp = scad.last();
|
||||
TImporto ritenute;
|
||||
|
||||
for (int pa = scad.first(); pa <= lastp; pa = scad.succ(pa))
|
||||
{
|
||||
const TRectype& pag = scad.row(pa);
|
||||
@ -967,7 +983,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
if (in_valuta)
|
||||
{
|
||||
gm.add_importo(row, imp);
|
||||
gm.add_importo(row, TImporto(sez, pag.get_real(PAGSCA_IMPORTOVAL)), prima_valuta.codice());
|
||||
gm.add_importo(row, TImporto(sum.sezione_ritfis(), pag.get_real(PAGSCA_IMPORTOVAL)), prima_valuta.codice());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -980,26 +996,31 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
row.add("");
|
||||
row.add((int)sum.tipo());
|
||||
row.add(pa);
|
||||
|
||||
|
||||
// Le ritenute non possono esistere in valuta
|
||||
if (!in_valuta)
|
||||
{
|
||||
const TImporto rit(sez, pag.get_real(PAGSCA_RITENUTE));
|
||||
if (!rit.is_zero())
|
||||
const TImporto rit(sum.sezione_ritfis() == 'A' ? 'D' : 'A', pag.get_real(PAGSCA_RITENUTE));
|
||||
|
||||
if (!rit.is_zero())
|
||||
{
|
||||
TToken_string& rrit = gm.add_colored_row(sheet, 'R');
|
||||
rrit.add(TR("Ritenute professionali"), 4);
|
||||
gm.add_importo(rrit, rit, FALSE);
|
||||
rrit.add((int)sum.tipo(), 11);
|
||||
ritenute += rit;
|
||||
}
|
||||
|
||||
const TImporto soc(sum.sezione_ritsoc(), pag.get_real(PAGSCA_RITSOC));
|
||||
if (!soc.is_zero())
|
||||
const TImporto soc(sum.sezione_ritsoc() == 'A' ? 'D' : 'A', pag.get_real(PAGSCA_RITSOC));
|
||||
|
||||
if (!soc.is_zero())
|
||||
{
|
||||
TToken_string& rrit = gm.add_colored_row(sheet, 'R');
|
||||
rrit.add(TR("Ritenute sociali"), 4);
|
||||
TToken_string& rrit = gm.add_colored_row(sheet, 'R');
|
||||
|
||||
rrit.add(TR("Ritenute sociali"), 4);
|
||||
gm.add_importo(rrit, soc, FALSE);
|
||||
rrit.add((int)sum.tipo(), 11);
|
||||
ritenute += soc;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1047,7 +1068,10 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
rsal.add(TR("Saldo rata "), 4); rsal << ra;
|
||||
if (!scad.chiusa())
|
||||
{
|
||||
TImporto sl = scad.residuo(false);
|
||||
TImporto sl = scad.residuo(false, 0x7);
|
||||
|
||||
if (!in_valuta)
|
||||
sl += ritenute;
|
||||
gm.add_importo(rsal, sl);
|
||||
tot_lit += sl;
|
||||
|
||||
|
@ -39,8 +39,9 @@ class TPay_mask : public TMask
|
||||
|
||||
bool _assigned;
|
||||
bool _can_solder;
|
||||
bool _swap_ritsoc;
|
||||
|
||||
bool _swap_ritfis;
|
||||
bool _swap_ritsoc;
|
||||
|
||||
protected:
|
||||
static bool importo_handler(TMask_field& f, KEY k);
|
||||
static bool importolire_handler(TMask_field& f, KEY k);
|
||||
|
@ -400,8 +400,8 @@ TImporto TRiga_scadenze::importo_pagato(bool val, int mode) const
|
||||
totale += TImporto(sez, pag.get_real(imp_field));
|
||||
if (!in_val && (mode & 0x8)) // Le ritenute non esistono nei pagamenti in valuta
|
||||
{
|
||||
totale += TImporto(sez, pag.get_real(PAGSCA_RITENUTE));
|
||||
totale += TImporto(sum.sezione_ritsoc(), pag.get_real(PAGSCA_RITSOC));
|
||||
totale -= TImporto(sum.sezione_ritsoc(), pag.get_real(PAGSCA_RITENUTE));
|
||||
totale -= TImporto(sum.sezione_ritsoc(), pag.get_real(PAGSCA_RITSOC));
|
||||
}
|
||||
|
||||
if (mode & 0x2) // Voglio anche gli abbuoni
|
||||
@ -823,12 +823,20 @@ tipo_pagamento TRiga_partite::tipo_pag() const
|
||||
}
|
||||
|
||||
// Calcola il segno delle ritenute sociali in base alla causale
|
||||
char TRiga_partite::sezione_ritfis() const
|
||||
{
|
||||
const int anno = get_int(PART_ANNO);
|
||||
const TCausale & caus = cached_causale(get(PART_CODCAUS), anno);
|
||||
|
||||
return caus.sezione_ritfis();
|
||||
}
|
||||
|
||||
char TRiga_partite::sezione_ritsoc() const
|
||||
{
|
||||
TString16 key; key << get(PART_CODCAUS) << '|' << RIGA_PAG_RITSOC; // Riga ritenute sociali
|
||||
const char sez_cau = cache().get(LF_RCAUSALI, key, RCA_SEZIONE)[0];
|
||||
const char sez_rit = sez_cau > ' ' ? (sez_cau == 'D' ? 'A' : 'D') : sezione();
|
||||
return sez_rit;
|
||||
const int anno = get_int(PART_ANNO);
|
||||
const TCausale & caus = cached_causale(get(PART_CODCAUS), anno);
|
||||
|
||||
return caus.sezione_ritsoc();
|
||||
}
|
||||
|
||||
// Legge le rate relative ad una riga di fattura
|
||||
@ -979,12 +987,15 @@ TImporto TRiga_partite::importo(bool valuta, int mode) const
|
||||
if (in_euro && (mode & 0x8)) // Ritenute Fiscali e/o sociali
|
||||
{
|
||||
// Ritenute Fiscali
|
||||
i.valore() += get_real(PART_RITENUTE);
|
||||
// Ritenute Sociali
|
||||
if (sezione() == sezione_ritsoc())
|
||||
i.valore() -= get_real(PART_RITENUTE);
|
||||
else
|
||||
i.valore() += get_real(PART_RITENUTE);
|
||||
// Ritenute Sociali
|
||||
if (sezione() == sezione_ritsoc())
|
||||
i.valore() += get_real(PART_RITSOC);
|
||||
else
|
||||
i.valore() -= get_real(PART_RITSOC);
|
||||
else
|
||||
i.valore() += get_real(PART_RITSOC);
|
||||
}
|
||||
|
||||
if (mode & 0x2)
|
||||
|
@ -191,7 +191,8 @@ public:
|
||||
int ultima_rata_con_abbuoni_diffcam() const;
|
||||
|
||||
char sezione() const { return get_char(PART_SEZ); }
|
||||
char sezione_ritsoc() const;
|
||||
char sezione_ritfis() const;
|
||||
char sezione_ritsoc() const;
|
||||
|
||||
TImporto importo(bool valuta, int mode = 0xF) const;
|
||||
TImporto esposto(bool valuta, const TDate & data_scad, const TDate & data_rischio, bool & sbf) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user