Patch level : 10.0 1158

Files correlati     : fe0.exe
Ricompilazione Demo : [ ]
Commento            :
Migliorata gestione note di variazione a fatture con contratto
Migliorata gestione flag di forzatura


git-svn-id: svn://10.65.10.50/branches/R_10_00@22503 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2011-11-25 08:39:50 +00:00
parent ae155f5dbb
commit 5dcf051f0a

View File

@ -269,7 +269,7 @@ public:
int items() const { return _data.items(); }
const TRectype& operator[](int i) { return (const TRectype&)_data[i]; }
TExclusion_mode add(const TRectype& alleg, bool send_all, TLog_report& log);
void add(const TArray& note, bool send_all, TLog_report& log);
void add(TArray& fatture, TArray& note, bool send_all, TLog_report& log);
};
TExclusion_mode TDati_rilevanti_array::segnala_riga(const TRectype& alleg, TExclusion_mode motivo, TLog_report& log) const
@ -302,84 +302,43 @@ TExclusion_mode TDati_rilevanti_array::add(const TRectype& alleg, bool send_all,
if (a.codice_fiscale().blank() && a.partita_IVA().blank())
return segnala_riga(alleg, em_no_allegato, log);
const TString80 contratto = alleg.get(ALL_CONTRATTO);
const TString8 numrett = alleg.get(ALL_NUMRETT);
if (contratto.full() || numrett.full())
if (is_nota_variazione(alleg))
{
TString16 curr_idcf = alleg.get(ALL_OCFPI);
if (curr_idcf.blank()) curr_idcf = alleg.get(ALL_CODCF);
TRectype* sum = NULL;
for (int i = _data.last(); i >= 0; i--)
const TString8 numrett = alleg.get(ALL_NUMRETT);
// Ignora le note di variazione non collegate e di importo non rilevante
if (!send_all && ignora == em_incluso)
{
TRectype& rec = (TRectype&)_data[i];
TString16 idcf = rec.get(ALL_OCFPI);
if (idcf.blank()) idcf = rec.get(ALL_CODCF);
if (idcf == curr_idcf)
{
if ((numrett.full() && numrett == rec.get(ALL_NUMDOC)) ||
(contratto.full() && contratto == rec.get(ALL_CONTRATTO)))
{
sum = &rec;
break;
}
}
const int anno = alleg.get_int(ALL_ANNO);
const real importo = abs(alleg.get_real(ALL_IMPORTO));
if (importo < importo_limite(anno))
ignora = segnala_riga(alleg, em_importo_limite, log);
else
break;
{
const TDate datarett = alleg.get(ALL_DATARETT);
if (datarett.year() != anno)
return segnala_riga(alleg, em_data_limite, log); // Non posso fare la add con DATARETT errata
if (numrett.blank() || numrett == INVALID_NUMDOC)
return segnala_riga(alleg, em_altro, log); // Non posso fare la add in assenza di NUMRETT
}
}
if (sum != NULL)
}
else
{
const TString80 contratto = alleg.get(ALL_CONTRATTO);
if (ignora <= em_importo_limite)
{
sum->add(ALL_IMPORTO, importo);
sum->add(ALL_IMPOSTA, imposta);
if (contratto.full()) // In caso di contratto riporta i dati dell'ultimo documento
const int anno = alleg.get_int(ALL_ANNO);
TExclusion_mode new_mode = (alleg.get_real(ALL_IMPORTO) < importo_limite(anno)) ? em_importo_limite : em_incluso;
if (new_mode == em_importo_limite && contratto.full())
{
const TDate sum_data = sum->get(ALL_DATAREG);
const TDate all_data = alleg.get(ALL_DATAREG);
if (all_data > sum_data)
{
sum->put(ALL_DATAREG, all_data);
sum->put(ALL_NUMDOC, alleg.get(ALL_NUMDOC));
}
}
const int old_mode = sum->get_int(ALL_IGNORA);
if (old_mode <= 1)
{
const int anno = sum->get_int(ALL_ANNO);
int new_mode = sum->get_real(ALL_IMPORTO) < importo_limite(anno);
if (new_mode && contratto.full())
{
const TContratto c(alleg);
real imp, iva;
if (c.totale_annuale(anno, imp, iva))
new_mode = imp < importo_limite(anno);
}
if (old_mode != new_mode)
sum->put(ALL_IGNORA, new_mode);
}
return em_incluso; // Aggiunto a record preesistente
}
else
{
// Ignora le note di variazione non collegate e di importo non rilevante
if (!send_all && ignora == em_incluso && is_nota_variazione(alleg))
{
const int anno = alleg.get_int(ALL_ANNO);
const real importo = abs(alleg.get_real(ALL_IMPORTO));
if (importo < importo_limite(anno))
ignora = segnala_riga(alleg, em_importo_limite, log);
else
{
const TDate datarett = alleg.get(ALL_DATARETT);
if (datarett.year() != anno)
return segnala_riga(alleg, em_data_limite, log); // Non posso fare la add con DATARETT errata
const TString& nr = alleg.get(ALL_NUMRETT);
if (nr.blank() || nr == INVALID_NUMDOC)
return segnala_riga(alleg, em_altro, log); // Non posso fare la add in assenza di NUMRETT
}
const TContratto c(alleg);
real imp, iva;
if (c.totale_annuale(anno, imp, iva))
new_mode = (imp < importo_limite(anno)) ? em_importo_limite : em_incluso;
}
if (ignora != new_mode)
ignora = new_mode;
}
}
@ -391,11 +350,68 @@ TExclusion_mode TDati_rilevanti_array::add(const TRectype& alleg, bool send_all,
return em_incluso;
}
void TDati_rilevanti_array::add(const TArray& note, bool send_all, TLog_report& log)
void TDati_rilevanti_array::add(TArray& fatture, TArray& note, bool send_all, TLog_report& log)
{
FOR_EACH_ARRAY_ITEM(note, t, obj)
// Cerca di scalare le note dalle relative fatture
FOR_EACH_ARRAY_ITEM_BACK(note, n, pnota)
{
const TRectype& nota = *(const TRectype*)obj;
const TRectype& nota = *(const TRectype*)pnota;
const TString8 numrett = nota.get(ALL_NUMRETT);
if (numrett.full() && numrett != INVALID_NUMDOC)
{
const TDate datarett = nota.get(ALL_DATARETT);
FOR_EACH_ARRAY_ITEM(fatture, f, pfatt)
{
TRectype& fatt= *(TRectype*)pfatt;
if (fatt.get(ALL_NUMDOC) == numrett && fatt.get_date(ALL_DATAREG) == datarett)
{
fatt.add(ALL_IMPORTO, nota.get_real(ALL_IMPORTO));
fatt.add(ALL_IMPOSTA, nota.get_real(ALL_IMPOSTA));
note.destroy(n);
break;
}
}
}
}
// Cerca di raggruppare le fatture per contratto
FOR_EACH_ARRAY_ITEM_BACK(fatture, c, pcont)
{
const TRectype& cont = *(const TRectype*)pcont;
const TString80 contratto = cont.get(ALL_CONTRATTO);
if (contratto.full())
{
FOR_EACH_ARRAY_ITEM(fatture, f, pfatt) if (f < c)
{
TRectype& fatt= *(TRectype*)pfatt;
if (fatt.get(ALL_CONTRATTO) == contratto)
{
fatt.add(ALL_IMPORTO, cont.get_real(ALL_IMPORTO));
fatt.add(ALL_IMPOSTA, cont.get_real(ALL_IMPOSTA));
const TDate sum_data = fatt.get(ALL_DATAREG);
const TDate all_data = cont.get(ALL_DATAREG);
if (all_data > sum_data)
{
fatt.put(ALL_DATAREG, all_data);
fatt.put(ALL_NUMDOC, cont.get(ALL_NUMDOC));
}
fatture.destroy(c);
break;
}
}
}
}
// Aggiunge fatture
FOR_EACH_ARRAY_ITEM(fatture, f, pfatt)
{
const TRectype& fatt = *(const TRectype*)pfatt;
add(fatt, send_all, log);
}
// Aggiunge note
FOR_EACH_ARRAY_ITEM(note, n, pnot)
{
const TRectype& nota = *(const TRectype*)pnot;
add(nota, send_all, log);
}
}
@ -1164,7 +1180,7 @@ bool TDati_rilevanti_msk::send_alleg()
const TRectype& rec = alleg.cursor()->curr();
TString16 last_clifo;
TArray note;
TArray fatt, note;
TProgind pi(tot_alleg, TR("Elaborazione file"));
for (bool ok = alleg.move_first(); ok; ok = alleg.move_next())
@ -1178,19 +1194,21 @@ bool TDati_rilevanti_msk::send_alleg()
if (clifo != last_clifo)
{
if (clifo == "833")
int caaozne = 1;
data.add(note, send_all, *_log);
note.destroy();
if (!fatt.empty() || !note.empty())
{
data.add(fatt, note, send_all, *_log);
fatt.destroy();
note.destroy();
}
last_clifo = clifo;
}
if (is_nota_variazione(rec))
note.add(rec);
else
data.add(rec, send_all, *_log);
fatt.add(rec);
}
data.add(note, send_all, *_log);
data.add(fatt, note, send_all, *_log);
if (_log->recordset()->items())
_log->preview();
@ -1517,6 +1535,7 @@ void TDati_rilevanti_msk::enable_buttons()
}
enable(DLG_CANCEL, full_rows);
enable(DLG_SAVEREC, _sheet_dirty);
enable(DLG_EXPORT, full_rows);
enable(DLG_RECALC, !full_rows && good_year && !one_sent);
enable(DLG_ELABORA, good_year && !(one_sent && def));
@ -1667,9 +1686,7 @@ bool TDati_rilevanti_msk::on_field_event(TOperable_field& o, TField_event e, lon
if (e == se_notify_modify)
{
set_dirty( true);
TSheet_field& s = (TSheet_field&)o;
TToken_string& row = s.row(jolly);
row.add("X", s.cid2index(A_FORZATA));
enable_buttons();
} else
if (e == se_query_add)
{
@ -1720,6 +1737,14 @@ bool TDati_rilevanti_msk::on_field_event(TOperable_field& o, TField_event e, lon
default:
break;
}
if (e == fe_modify && jolly == 1)
{
const short id = o.dlg();
if (id >= A_RIGA && id < A_COFI && id != A_FORZATA)
o.mask().set(A_FORZATA, true);
}
return true;
}