git-svn-id: svn://10.65.10.50/branches/R_10_00@23192 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
3c7e9a5c69
commit
7f77af2a62
126
m770/770400.cpp
Normal file
126
m770/770400.cpp
Normal file
@ -0,0 +1,126 @@
|
||||
#include <tabapp.h>
|
||||
#include <recset.h>
|
||||
#include <msksheet.h>
|
||||
|
||||
#include <nditte.h>
|
||||
|
||||
class TTabelle_770 : public TTable_application
|
||||
{
|
||||
protected:
|
||||
virtual int read(TMask& m);
|
||||
virtual int write(const TMask& m);
|
||||
virtual int rewrite(const TMask& m);
|
||||
virtual bool remove();
|
||||
|
||||
public:
|
||||
bool is_ENT() const { return get_tabname() == "%ENT"; }
|
||||
TSheet_field* sheet_ENT() const;
|
||||
void write_rewrite_ENT() const;
|
||||
};
|
||||
|
||||
TSheet_field* TTabelle_770::sheet_ENT() const
|
||||
{
|
||||
if (is_ENT())
|
||||
{
|
||||
TMask& m = curr_mask();
|
||||
for (int i = m.fields()-1; i > 0; i--)
|
||||
{
|
||||
TMask_field& f = m.fld(i);
|
||||
if (f.is_sheet())
|
||||
return (TSheet_field*)&f;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int TTabelle_770::read(TMask& m)
|
||||
{
|
||||
const int err = TTable_application::read(m);
|
||||
|
||||
TSheet_field* se = sheet_ENT();
|
||||
if (err == NOERR && se != NULL)
|
||||
{
|
||||
const TString& ent = m.get_key_field(1, true)->get();
|
||||
se->destroy();
|
||||
TLocalisamfile mr(LF_MULTIREL);
|
||||
TISAM_recordset nditte("USE NDITTE");
|
||||
for (bool go = nditte.move_first(); go; go = nditte.move_next())
|
||||
{
|
||||
TToken_string& r = se->row(-1);
|
||||
const long n = nditte.get(NDT_CODDITTA).as_int();
|
||||
TString8 cod; cod.format("%05ld", n);
|
||||
r = cod;
|
||||
r.add(nditte.get(NDT_RAGSOC).as_string());
|
||||
|
||||
mr.put("COD", "77ENT");
|
||||
mr.put("FIRST", ent);
|
||||
mr.put("SECOND", cod);
|
||||
if (mr.read() == NOERR)
|
||||
r.add(mr.get("DATA"));
|
||||
}
|
||||
se->force_update();
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void TTabelle_770::write_rewrite_ENT() const
|
||||
{
|
||||
TSheet_field& s = *sheet_ENT();
|
||||
const TString& ent = s.mask().get_key_field(1, true)->get();
|
||||
TLocalisamfile mr(LF_MULTIREL);
|
||||
TString8 cod;
|
||||
FOR_EACH_SHEET_ROW(s, r, row)
|
||||
{
|
||||
mr.zero();
|
||||
mr.put("COD", "77ENT");
|
||||
mr.put("FIRST", ent);
|
||||
cod.format("%05ld", row->get_long(0));
|
||||
mr.put("SECOND", cod);
|
||||
const TFixed_string data = row->get(2);
|
||||
if (data.full())
|
||||
{
|
||||
mr.put("DATA", data);
|
||||
mr.rewrite_write();
|
||||
}
|
||||
else
|
||||
mr.remove();
|
||||
}
|
||||
}
|
||||
|
||||
int TTabelle_770::write(const TMask& m)
|
||||
{
|
||||
const int err = TTable_application::write(m);
|
||||
if (err == NOERR && is_ENT())
|
||||
write_rewrite_ENT();
|
||||
return err;
|
||||
}
|
||||
|
||||
int TTabelle_770::rewrite(const TMask& m)
|
||||
{
|
||||
const int err = TTable_application::rewrite(m);
|
||||
if (err == NOERR && is_ENT())
|
||||
write_rewrite_ENT();
|
||||
return err;
|
||||
}
|
||||
|
||||
bool TTabelle_770::remove()
|
||||
{
|
||||
const bool done = TTable_application::remove();
|
||||
if (done && is_ENT())
|
||||
{
|
||||
TSheet_field& s = *sheet_ENT();
|
||||
FOR_EACH_SHEET_ROW(s, r, row)
|
||||
row->add(" ", 2);
|
||||
write_rewrite_ENT();
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
int TableManager(int argc, char* argv[])
|
||||
{
|
||||
TTabelle_770 a;
|
||||
a.run(argc, argv, TR("Tabella 770"));
|
||||
return 0;
|
||||
}
|
220
m770/771230.cpp
220
m770/771230.cpp
@ -34,7 +34,7 @@ TRectype& operator += (TRectype& dst, const TRectype& src)
|
||||
for (int i = dst.items()-1; i >= 0; i--)
|
||||
{
|
||||
const char* name = dst.fieldname(i);
|
||||
if (dst.type(name) == _realfld && dst.length(name) >= 9)
|
||||
if (dst.type(name) == _realfld && dst.length(name) >= 9) // somma importi
|
||||
{
|
||||
real num = dst.get_real(name);
|
||||
num += src.get_real(name);
|
||||
@ -44,97 +44,157 @@ TRectype& operator += (TRectype& dst, const TRectype& src)
|
||||
return dst;
|
||||
}
|
||||
|
||||
class TRighe_pagamento : public TAssoc_array
|
||||
class TRighe_riepilogo : public TArray
|
||||
{
|
||||
TString4 _quadro; // Codice quadro
|
||||
TArray _prosp_e1; // Righe prospetto e1
|
||||
|
||||
protected:
|
||||
void genera_aliquota(TRectype& quadro, const char* aliquota,
|
||||
const char* imponibile, const char* imposta) const;
|
||||
void genera_la(TRectype& quadro, const TRectype& riga, const TString& codcaus) const;
|
||||
|
||||
public:
|
||||
void add_riga(const TRectype& scheda, const TRectype& riga);
|
||||
bool add_riga_pag(const TRectype& riga, const TRectype& scheda);
|
||||
const TRectype* prospetto_e1(char caus);
|
||||
|
||||
TRighe_pagamento(const char* quadro);
|
||||
virtual ~TRighe_pagamento() { }
|
||||
TRighe_riepilogo(const char* quadro);
|
||||
};
|
||||
|
||||
TRighe_pagamento::TRighe_pagamento(const char* quadro)
|
||||
TRighe_riepilogo::TRighe_riepilogo(const char* quadro)
|
||||
: _quadro(quadro)
|
||||
{ }
|
||||
|
||||
const TRectype* TRighe_pagamento::prospetto_e1(char caus)
|
||||
const TRectype* TRighe_riepilogo::prospetto_e1(char caus)
|
||||
{
|
||||
const int index = caus - 'C';
|
||||
return (const TRectype*)_prosp_e1.objptr(index);
|
||||
}
|
||||
|
||||
void TRighe_pagamento::add_riga(const TRectype& scheda, const TRectype& riga)
|
||||
void TRighe_riepilogo::genera_aliquota(TRectype& quadro, const char* aliquota,
|
||||
const char* imponibile, const char* imposta) const
|
||||
{
|
||||
TString16 chiave;
|
||||
real aliq = quadro.get_real(aliquota);
|
||||
if (aliq.is_zero())
|
||||
{
|
||||
const real impon = quadro.get(imponibile);
|
||||
if (!impon.is_zero())
|
||||
{
|
||||
const real impos = quadro.get(imposta);
|
||||
aliq = impos * CENTO / impon;
|
||||
if (aliq % UNO == ZERO)
|
||||
quadro.put(aliquota, aliq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TRighe_riepilogo::genera_la(TRectype& quadro, const TRectype& riga, const TString& codcaus) const
|
||||
{
|
||||
#ifdef DBG
|
||||
if (riga.get_long(SPR_CODANAGR) == 3072)
|
||||
int minimo = 1;
|
||||
#endif
|
||||
|
||||
const TDate datapag = riga.get(PAG_DATAPAG);
|
||||
const real compenso = riga.get_real(PAG_COMPENSO);
|
||||
const real imponibile = riga.get(PAG_IMPONIBILE);
|
||||
|
||||
quadro.put("ANNO", datapag.year());
|
||||
quadro.put(QUD_PERC, riga.get(PAG_PERC));
|
||||
quadro.put(QUD_CODCAUS, codcaus);
|
||||
|
||||
real ammlordo = imponibile;
|
||||
ammlordo += riga.get_real(PAG_SOMNSRIT);
|
||||
ammlordo += riga.get_real(PAG_CONTROBB);
|
||||
ammlordo += riga.get_real(PAG_SOMREGCONV);
|
||||
quadro.put(QUD_TOTALE, ammlordo);
|
||||
|
||||
real somme = compenso;
|
||||
somme -= imponibile;
|
||||
somme += riga.get_real(PAG_SPESA);
|
||||
somme -= riga.get_real(PAG_IMPCPA);
|
||||
somme -= riga.get_real(PAG_SOMREGCONV);
|
||||
quadro.put(QUD_SOMME, somme); // altre somme non soggette
|
||||
|
||||
quadro.put(QUD_SOMREGCONV, riga.get(PAG_SOMREGCONV));
|
||||
quadro.put(QUD_IMPONIBILE, imponibile); // AUXXX008
|
||||
quadro.put(QUD_IMPORTO, riga.get(PAG_RITENUTA));
|
||||
|
||||
const real inps_tot = riga.get(PAG_INPSCOMP);
|
||||
if (inps_tot > ZERO /*&& riga.get_real(PAG_IMPONIBILE) > 5000.0*/)
|
||||
{
|
||||
const real inps_perc = riga.get_real(PAG_INPSPERC);
|
||||
const real inps_erog = inps_tot - inps_perc;
|
||||
quadro.put(QUD_CTINPSEROG, inps_erog); // AUXXX020
|
||||
quadro.put(QUD_CTINPSPERC, inps_perc); // AUXXX021
|
||||
}
|
||||
|
||||
const TRectype& perc = cache().get_rec(LF_PERC, riga.get(SPR_CODDITTA), riga.get(SPR_TIPOA), riga.get(SPR_CODANAGR));
|
||||
quadro.put("ENTEPREV", perc.get("ENTEPREV")); // AUXXX029 / 32
|
||||
quadro.put("CATEGORIA", perc.get("CATEGORIA")); // AUXXX033
|
||||
|
||||
if (somme.is_zero() && quadro.get(QUD_TOTALE) == quadro.get(QUD_IMPONIBILE))
|
||||
{
|
||||
const TRectype& ca7 = cache().get("%CA7", codcaus);
|
||||
if (ca7.get_int("I1") == 3)
|
||||
{
|
||||
quadro.put(QUD_SOMME, quadro.get(QUD_IMPONIBILE));
|
||||
quadro.zero(QUD_IMPONIBILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TRighe_riepilogo::add_riga_pag(const TRectype& riga, const TRectype& scheda)
|
||||
{
|
||||
const TString4 codcaus = scheda.get(SPR_CODCAUS);
|
||||
const char causqua = toupper(scheda.get_char(SPR_CAUSQUA));
|
||||
chiave.format("%-2s%c", (const char*)codcaus, causqua);
|
||||
if (_quadro == "C")
|
||||
chiave << scheda.get(SPR_FLAGTS); else
|
||||
if (_quadro == "E1")
|
||||
|
||||
// cerca riga compatibile
|
||||
int i = 0;
|
||||
for (i = last(); i >= 0; i--)
|
||||
{
|
||||
// Le righe del prospetto vengono trattate a parte
|
||||
if (causqua >= 'C')
|
||||
{
|
||||
const int index = causqua - 'C';
|
||||
TRectype* rec = (TRectype*)_prosp_e1.objptr(index);
|
||||
if (rec)
|
||||
*rec += riga;
|
||||
else
|
||||
_prosp_e1.add(riga, index);
|
||||
return;
|
||||
const TRectype* rr = (const TRectype*)objptr(i);
|
||||
if (rr->get_char("CAUSALE") == causqua)
|
||||
break;
|
||||
}
|
||||
chiave << riga.get("PERC");
|
||||
if (i < 0)
|
||||
{
|
||||
TRectype* rec = NULL;
|
||||
if (_quadro == "LA")
|
||||
rec = new TRectype(LF_QUALA);
|
||||
|
||||
if (rec == NULL)
|
||||
return false;
|
||||
|
||||
rec->put(PAG_CODDITTA, riga.get(PAG_CODDITTA));
|
||||
rec->put(PAG_TIPOA, riga.get(PAG_TIPOA));
|
||||
rec->put(PAG_CODANAGR, riga.get(PAG_CODANAGR));
|
||||
rec->put("NPROG", i+1);
|
||||
rec->put("CODCAUS", codcaus);
|
||||
rec->put("CAUSALE", causqua);
|
||||
rec->put("ANNO", riga.get_date(PAG_DATAPAG).year());
|
||||
rec->put("GENERATA", true);
|
||||
i = add(rec);
|
||||
}
|
||||
|
||||
TRectype* rec = (TRectype*)objptr(chiave);
|
||||
if (rec)
|
||||
TRectype& riep = *(TRectype*)objptr(i);
|
||||
switch (riep.num())
|
||||
{
|
||||
*rec += riga;
|
||||
if (_quadro == "C") // Nel caso di quadro C somma anche i giorni detr dip.
|
||||
case LF_QUALA:
|
||||
{
|
||||
const real gglav = riga.get(PAG_GIOLAVDIP);
|
||||
rec->add(PAG_GIOLAVDIP, gglav);
|
||||
TRectype curr(riep.num());
|
||||
genera_la(curr, riga, codcaus);
|
||||
riep += curr;
|
||||
genera_aliquota(riep, QUD_PERC, QUD_IMPONIBILE, QUD_IMPORTO);
|
||||
if (riep.get("CODCAUS") != codcaus)
|
||||
riep.zero("CODCAUS"); // Azzero codice se fondo diverse causali 770 nella stesa causale quadro
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rec = new TRectype(riga);
|
||||
add(chiave, rec);
|
||||
}
|
||||
|
||||
if (_quadro == "DB")
|
||||
{
|
||||
// Calcola il flag per il contributo del 10%
|
||||
// Esso deve essere A se tutte le righe sono A,
|
||||
// C se tutte sono C, B in tutti gli altri casi
|
||||
char cod10 = toupper(riga.get_char(PAG_COD10)); // Valore scheda attuale
|
||||
if (cod10 < 'A' || cod10 > 'C') // Mette a posto archivi incompleti
|
||||
cod10 = 'B';
|
||||
char lcq = rec->get_char(PAG_COD10); // Valore ultima scheda
|
||||
switch (lcq)
|
||||
{
|
||||
case 'A':
|
||||
if (cod10 != 'A')
|
||||
lcq = 'B';
|
||||
break;
|
||||
case 'B':
|
||||
break;
|
||||
case 'C':
|
||||
if (cod10 != 'C')
|
||||
lcq = 'B';
|
||||
break;
|
||||
default:
|
||||
lcq = cod10;
|
||||
break;
|
||||
}
|
||||
rec->put(PAG_COD10, lcq); // Aggiorna valore
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -194,7 +254,7 @@ protected:
|
||||
void genera_e(TRectype& quadro, const TRectype& riga) const;
|
||||
void genera_e1(TRectype& quadro, const TRectype& riga) const;
|
||||
void genera_la(TRectype& quadro, const TRectype& riga,const TString& codcaus) const;
|
||||
void genera_righe(TRighe_pagamento& righe) const;
|
||||
void salva_righe(const TRighe_riepilogo& righe) const;
|
||||
void distruzione() const;
|
||||
void generazione();
|
||||
|
||||
@ -706,7 +766,6 @@ void TQuadroC_E2::genera_e(TRectype& quadro, const TRectype& riga) const
|
||||
nonsog -= riga.get_real(PAG_IMPONIBILE);
|
||||
nonsog += riga.get_real(PAG_SPESA);
|
||||
quadro.put(QUE_SOMME, nonsog); // 16
|
||||
|
||||
genera_aliquota(quadro, QUE_PERC, QUE_IMPONIBILE, QUE_IMPORTO); // 13
|
||||
}
|
||||
|
||||
@ -787,9 +846,11 @@ void TQuadroC_E2::genera_la(TRectype& quadro, const TRectype& riga, const TStrin
|
||||
}
|
||||
|
||||
|
||||
void TQuadroC_E2::genera_righe(TRighe_pagamento& righe) const
|
||||
void TQuadroC_E2::salva_righe(const TRighe_riepilogo& righe) const
|
||||
{
|
||||
TFast_isamfile file(_file);
|
||||
|
||||
/*
|
||||
TRectype& curr = file.curr();
|
||||
int nriga = 1;
|
||||
righe.restart();
|
||||
@ -803,13 +864,13 @@ void TQuadroC_E2::genera_righe(TRighe_pagamento& righe) const
|
||||
curr.put(PAG_TIPOA, riga.get(PAG_TIPOA));
|
||||
curr.put(PAG_CODANAGR, riga.get(PAG_CODANAGR));
|
||||
curr.put("NPROG", nriga);
|
||||
curr.put("CAUSALE", chiave[2]);
|
||||
curr.put("CAUSALE", chiave[0]);
|
||||
curr.put("GENERATA", true);
|
||||
|
||||
switch (_quadro[0])
|
||||
{
|
||||
case 'C':
|
||||
curr.put("TASSAZIONE", chiave[3]);
|
||||
curr.put("TASSAZIONE", chiave[1]);
|
||||
genera_c(curr, riga);
|
||||
break;
|
||||
case 'D':
|
||||
@ -831,7 +892,7 @@ void TQuadroC_E2::genera_righe(TRighe_pagamento& righe) const
|
||||
break;
|
||||
case 'L':
|
||||
if (_quadro[1] == 'A')
|
||||
genera_la(curr, riga, chiave.left(2));
|
||||
genera_la(curr, riga);
|
||||
break;
|
||||
default:
|
||||
CHECK(FALSE, "Quadro non generabile dalle schede");
|
||||
@ -896,6 +957,25 @@ void TQuadroC_E2::genera_righe(TRighe_pagamento& righe) const
|
||||
}
|
||||
read_prospetto_e1();
|
||||
}
|
||||
*/
|
||||
|
||||
int nriga = 1;
|
||||
for (int i = 0; i < righe.items(); i++)
|
||||
{
|
||||
const TRectype& rec = *(const TRectype*)righe.objptr(i);
|
||||
file.curr() = rec;
|
||||
int err = _isreinsert;
|
||||
while (err == _isreinsert)
|
||||
{
|
||||
file.put("NPROG", nriga++);
|
||||
err = file.write();
|
||||
}
|
||||
if (err != NOERR)
|
||||
{
|
||||
error_box("Errore %d durante la scrittura", err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TQuadroC_E2::generazione()
|
||||
@ -926,7 +1006,7 @@ void TQuadroC_E2::generazione()
|
||||
char last_type = ' ';
|
||||
long last_code = 0L;
|
||||
|
||||
TRighe_pagamento righe(_quadro);
|
||||
TRighe_riepilogo righe(_quadro);
|
||||
|
||||
for (cur = 0; cur.pos() < items; ++cur)
|
||||
{
|
||||
@ -939,7 +1019,7 @@ void TQuadroC_E2::generazione()
|
||||
{
|
||||
if (righe.items() > 0)
|
||||
{
|
||||
genera_righe(righe);
|
||||
salva_righe(righe);
|
||||
righe.destroy();
|
||||
}
|
||||
last_type = tipoa;
|
||||
@ -950,12 +1030,12 @@ void TQuadroC_E2::generazione()
|
||||
{
|
||||
const TDate datapag = riga.get(PAG_DATAPAG);
|
||||
if (datapag.year() == anno770)
|
||||
righe.add_riga(scheda, riga);
|
||||
righe.add_riga_pag(riga, scheda);
|
||||
}
|
||||
}
|
||||
|
||||
if (righe.items() > 0)
|
||||
genera_righe(righe);
|
||||
salva_righe(righe);
|
||||
_registra = true;
|
||||
}
|
||||
|
||||
|
@ -752,11 +752,6 @@ bool TTrasferimentoCU::append_record_h(const TRectype& qla, int modulo, TLog_rep
|
||||
const TString& azienda = cache().get(LF_MULTIREL, cod_az, "DATA");
|
||||
rec.np_put("AU001032", azienda); // codice azienda presso ente previdenziale
|
||||
}
|
||||
else
|
||||
{
|
||||
TString msg; msg.format(FR("Percipiente privo di dati previdenziali %c/%ld %s"), tipoanag, codanagr, (const char*)perc.codice_fiscale());
|
||||
log.log(1, msg);
|
||||
}
|
||||
|
||||
rec.np_put("AU001033", cat);
|
||||
rec.np_put("AU001034", cce); // contributi a carico erogante
|
||||
|
Loading…
x
Reference in New Issue
Block a user