Patch level : 12.0 1244

Files correlati     : ve0.exe cg5.exe Mcg5500c.msk

Commento:
Aggiunto un controllo opzionale sulla contbilizzazione fatture che derivano da una fattura da emettere o ricevere se la fattura appartiene alo strsso esercizio della da emettere o ricevere viene contabilizzata normlmente e non storna la fattura da emettere o ricevere.
This commit is contained in:
Alessandro Bonazzi 2023-02-17 20:41:16 +01:00
parent ebd79dffd1
commit e7d97d4305
3 changed files with 29 additions and 19 deletions

View File

@ -261,7 +261,7 @@ void TCopydoc_app::main_loop()
} }
else else
newdoc.put(DOC_NDOC, ndoc++); newdoc.put(DOC_NDOC, ndoc++);
newdoc.copy_contents(olddoc); newdoc.copy_contents(olddoc, false);
newdoc.put(DOC_DATADOC, data); newdoc.put(DOC_DATADOC, data);
const TString& oldstr = m.get(F_OLD_STR); const TString& oldstr = m.get(F_OLD_STR);

View File

@ -854,7 +854,7 @@ void TDocumento::copy_data(TRiga_documento& dst, const TRiga_documento& src)
dst.put(RDOC_CODCOSTO, src.codice_costo()); dst.put(RDOC_CODCOSTO, src.codice_costo());
} }
void TDocumento::copy_contents(const TDocumento& src, bool copy_header) void TDocumento::copy_contents(const TDocumento& src, bool link_row, bool copy_header)
{ {
if (copy_header) if (copy_header)
copy_data(head(), src.head()); copy_data(head(), src.head());
@ -866,7 +866,8 @@ void TDocumento::copy_contents(const TDocumento& src, bool copy_header)
TRiga_documento & r = new_row(s.tipo().codice()); TRiga_documento & r = new_row(s.tipo().codice());
copy_data(r, s); copy_data(r, s);
r.set_original_rdoc_key(s); if (link_row)
r.set_original_rdoc_key(s);
} }
} }

View File

@ -302,30 +302,39 @@ bool TContabilizzazione_analitica::search_costo_ricavo(const TRiga_documento& r,
if (rdoc != NULL && rdoc->get(RDOC_PROVV).not_empty()) if (rdoc != NULL && rdoc->get(RDOC_PROVV).not_empty())
{ {
TString80 key = rdoc->get(RDOC_CODNUM); TString80 key = rdoc->get(RDOC_CODNUM);
const TCodice_numerazione& num = cached_numerazione(key); const TCodice_numerazione& num = cached_numerazione(key);
const TRectype * orig_doc = r.find_original_doc();
const TRectype * rdoc = r.find_original_rdoc();
if (num.fattura_emettere_ricevere()) if (num.fattura_emettere_ricevere())
{ {
key.format("%3d%3d%6ld", conto.gruppo(), conto.conto(), conto.sottoconto()); const int act_es = esercizi().date2esc(r.doc().get_date(DOC_DATADOC));
const TRectype* rs = &cache().get("MRE", key); const int orig_es = esercizi().date2esc(orig_doc->get_date(DOC_DATADOC));
if (rs->empty())
if (!num.fattura_emettere_ricevere_check_ese() || act_es != orig_es)
{ {
key.cut(6); key.format("%3d%3d%6ld", conto.gruppo(), conto.conto(), conto.sottoconto());
rs = &cache().get("MRE", key); const TRectype* rs = &cache().get("MRE", key);
if (rs->empty()) if (rs->empty())
{ {
key.cut(3); key.cut(6);
rs = &cache().get("MRE", key); rs = &cache().get("MRE", key);
if (rs->empty())
{
key.cut(3);
rs = &cache().get("MRE", key);
}
} }
} if (!rs->empty())
if (!rs->empty()) {
{ const int gr = rs->get_int("I0");
const int gr = rs->get_int("I0"); const int co = rs->get_int("I1");
const int co = rs->get_int("I1"); const long so = rs->get_int("I2");
const long so = rs->get_int("I2"); const char tipo = rs->get_char("S6");
const char tipo = rs->get_char("S6");
conto.set(gr, co, so, tipo); conto.set(gr, co, so, tipo);
}
} }
} }
} }