Patch level : 12.0 1058
Files correlati : tf0.exe tff.ini Commento : Eliminato il controllo sui nuovi tipi documenti e nature Interno : La natura è già a 4 caratteri bisogna controllare se il database TF<ditta> viene aggiornato.
This commit is contained in:
parent
cd28f8ec9f
commit
e87d605919
@ -132,10 +132,10 @@ int get_tipo_doc(const TString id)
|
||||
* TD10: Fatt di acquisto intra beni
|
||||
* TD11: Fatt di acquisto intra servizi
|
||||
*/
|
||||
const char* decod_tipo(TToken_string* strarr)
|
||||
const char* decod_tipo(TToken_string & strarr)
|
||||
{
|
||||
const TString tipodoc = strarr->get(_codnum);
|
||||
TRectype mov = cache().get(LF_MOV, strarr->get(_numero));
|
||||
const TString tipodoc = strarr.get(_codnum);
|
||||
TRectype mov = cache().get(LF_MOV, strarr.get(_numero));
|
||||
TCausale caus(mov.get("CODCAUS"), mov.get_int("ANNOIVA"));
|
||||
// Le autofatture possono essere solo di tipo TDO1 e le bolle doganali nel dubbio pure
|
||||
if(tipodoc == "AF" || tipodoc == "BD" || tipodoc == "FF" || tipodoc == "FV" || tipodoc == "FS")
|
||||
@ -151,7 +151,7 @@ const char* decod_tipo(TToken_string* strarr)
|
||||
// Per capire se sono beni o servizi devo prendere il movimento, e trovare quale dei due ha un importo più alto
|
||||
TAssoc_array intraval;
|
||||
TRelation r_moviva(LF_RMOVIVA);
|
||||
TRectype filter(r_moviva.curr()); filter.put("NUMREG", strarr->get(_numero));
|
||||
TRectype filter(r_moviva.curr()); filter.put("NUMREG", strarr.get(_numero));
|
||||
TCursor c_moviva(&r_moviva, "", 1, &filter, &filter);
|
||||
for(c_moviva = 0; c_moviva.pos() < c_moviva.items(); ++c_moviva)
|
||||
{
|
||||
@ -203,7 +203,7 @@ const char* decod_tipo(TToken_string* strarr)
|
||||
// Devo capire a che documento è associato
|
||||
TRelation r(LF_RMOV);
|
||||
TRectype filter(r.curr());
|
||||
filter.put("NUMREG", strarr->get(_numero));
|
||||
filter.put("NUMREG", strarr.get(_numero));
|
||||
TCursor c(&r, "", 1, &filter, &filter);
|
||||
for(c = 0; c.pos() < c.items(); ++c)
|
||||
{
|
||||
@ -553,14 +553,13 @@ void TTrFa_app::log(int severity, const char* msg)
|
||||
}
|
||||
}
|
||||
|
||||
bool TTrFa_app::show_log()
|
||||
bool TTrFa_app::display_log()
|
||||
{
|
||||
bool ok = true;
|
||||
if (_log)
|
||||
{
|
||||
_log->preview();
|
||||
delete _log;
|
||||
_log = NULL;
|
||||
safe_delete(_log);
|
||||
ok = noyes_box(TR("Si desidera procedere con la generazione file xml?"));
|
||||
}
|
||||
return ok;
|
||||
|
@ -109,7 +109,7 @@ int get_tipo_doc(TString id);
|
||||
// Aggiorna il file dst se più vecchio di src (Potrebbe diventare una funzione di XVT.h)
|
||||
//bool xvt_fsys_fupdate(const char* src, const char* dst);
|
||||
// Decodifica il tipo di documento per il trasferimento fatture
|
||||
const char * decod_tipo(TToken_string* strarr);
|
||||
const char * decod_tipo(TToken_string & strarr);
|
||||
// Salvo un singolo record
|
||||
bool save_rec(TToken_string row, bool esportato = false);
|
||||
// Ritorno una data in formato ANSI
|
||||
@ -304,7 +304,7 @@ private:
|
||||
|
||||
protected:
|
||||
void log(int severity, const char* msg);
|
||||
bool show_log();
|
||||
bool display_log();
|
||||
bool syncronize_db();
|
||||
bool verify_db(const bool create);
|
||||
bool copy_ssa();
|
||||
|
@ -656,127 +656,118 @@ void TTrFa_mask::update_stato(const TString& da_stato, const TString& a_stato)
|
||||
|
||||
void TTrFa_mask::load_sheet()
|
||||
{
|
||||
const char tipo = get(F_TIPOCF)[0];
|
||||
const char tipo = get(F_TIPOCF)[0];
|
||||
const long codice = get_long(F_CODCF);
|
||||
TDate dal = get_date(F_DATAINI), al = get_date(F_DATAFIN);
|
||||
|
||||
// Importanti! Evito errori dopo premendo il bottone invia
|
||||
if(!dal.ok())
|
||||
{
|
||||
dal = TDate(01, 01, 2017); // Data inizio validità questo spesometro
|
||||
set(F_DATAINI, dal);
|
||||
}
|
||||
if(!al.ok())
|
||||
{
|
||||
al = TDate(TODAY);
|
||||
set(F_DATAFIN, al);
|
||||
}
|
||||
//TString key; key << "TIPOA=" << prefix().firm().get("TIPOA")<< ",CODANAGR=" << prefix().firm().get("CODANAGR");
|
||||
TString key; key << prefix().firm().get("TIPOA") << "|" << prefix().firm().get("CODANAGR");
|
||||
static const TString piva_ditta = cache().get(LF_ANAG, key, "PAIV");
|
||||
static const TString cofi_ditta = cache().get(LF_ANAG, key, "COFI");
|
||||
|
||||
TTrFa_cursors c;
|
||||
TDate dal = get_date(F_DATAINI), al = get_date(F_DATAFIN);
|
||||
|
||||
TSheet_field& sheet = sfield(F_RIGHE);
|
||||
|
||||
// Nascondo lo sheet per guadagnare un 20% di velocità di caricamento, le ottimizzazioni da PRO!
|
||||
sheet.destroy();
|
||||
TAssoc_array recimposte;
|
||||
const int items = c.update_filters(tipo, codice, dal, al, get_int(F_FATTSEL));
|
||||
TString tipocf, codcf, ocfpi, nat;
|
||||
for(bool ok = true; items > 0 && ok;)
|
||||
{
|
||||
tipocf.cut(0), codcf.cut(0), ocfpi.cut(0), nat.cut(0);
|
||||
const int err = c.next(recimposte, ok, tipocf, codcf, ocfpi);
|
||||
// Importanti! Evito errori dopo premendo il bottone invia
|
||||
if (!dal.ok())
|
||||
{
|
||||
dal = TDate(01, 01, 2017); // Data inizio validità questo spesometro
|
||||
set(F_DATAINI, dal);
|
||||
}
|
||||
if (!al.ok())
|
||||
{
|
||||
al = TDate(TODAY);
|
||||
set(F_DATAFIN, al);
|
||||
}
|
||||
//TString key; key << "TIPOA=" << prefix().firm().get("TIPOA")<< ",CODANAGR=" << prefix().firm().get("CODANAGR");
|
||||
TString key; key << prefix().firm().get("TIPOA") << "|" << prefix().firm().get("CODANAGR");
|
||||
static const TString piva_ditta = cache().get(LF_ANAG, key, "PAIV");
|
||||
static const TString cofi_ditta = cache().get(LF_ANAG, key, "COFI");
|
||||
|
||||
// Carico i clienti
|
||||
TRectype cli = getCli(tipocf, codcf, ocfpi);
|
||||
|
||||
FOR_EACH_ASSOC_OBJECT(recimposte, h, iva, rec)
|
||||
{
|
||||
TRectype movimento = *dynamic_cast<TRectype*>(rec);
|
||||
// Controllo che sia un tipo documento da leggere
|
||||
const int tipo_doc = get_tipo_doc(movimento.get("TIPODOC"));
|
||||
if(tipo_doc != -1 && !get_bool(tipo_doc)) continue;
|
||||
// A volte mi pesca movimenti con invio sbagliato
|
||||
if(!check_invio(movimento.get("TFINVIO"))) continue;
|
||||
TTrFa_cursors c;
|
||||
|
||||
// Creo una nuova riga nello sheet
|
||||
TToken_string& row = sheet.row(-1);
|
||||
|
||||
/* Siccome mi cambiano l'ordine ogni volta e non ho voglia di cambiare tutto ovunque
|
||||
* basta settare i valori negli enum e lo sheet
|
||||
*/
|
||||
TRectype is_cust = getTrasFatt(movimento.get("NUMREG"), iva);
|
||||
TSheet_field& sheet = sfield(F_RIGHE);
|
||||
|
||||
sheet.reset();
|
||||
TAssoc_array recimposte;
|
||||
const int items = c.update_filters(tipo, codice, dal, al, get_int(F_FATTSEL));
|
||||
TString tipocf, codcf, ocfpi, nat;
|
||||
|
||||
for (bool ok = true; items > 0 && ok;)
|
||||
{
|
||||
tipocf.cut(0), codcf.cut(0), ocfpi.cut(0), nat.cut(0);
|
||||
const int err = c.next(recimposte, ok, tipocf, codcf, ocfpi);
|
||||
|
||||
// Carico i clienti
|
||||
TRectype cli = getCli(tipocf, codcf, ocfpi);
|
||||
|
||||
FOR_EACH_ASSOC_OBJECT(recimposte, h, iva, rec)
|
||||
{
|
||||
TRectype movimento = *dynamic_cast<TRectype*>(rec);
|
||||
// Controllo che sia un tipo documento da leggere
|
||||
const int tipo_doc = get_tipo_doc(movimento.get("TIPODOC"));
|
||||
if (tipo_doc != -1 && !get_bool(tipo_doc)) continue;
|
||||
// A volte mi pesca movimenti con invio sbagliato
|
||||
if (!check_invio(movimento.get("TFINVIO"))) continue;
|
||||
|
||||
TRectype is_cust = getTrasFatt(movimento.get("NUMREG"), iva);
|
||||
#ifdef DBG
|
||||
if(is_cust.full() && (err < foundcust || err > foundidcust))
|
||||
bool tolla = true;
|
||||
if (is_cust.full() && (err < foundcust || err > foundidcust))
|
||||
bool tolla = true;
|
||||
#endif
|
||||
const char * to_send = movimento.get("TFINVIO").blank() ? FLAG_INVIO : movimento.get("TFINVIO");
|
||||
row.add(movimento.get("TFINVIO") == FLAG_INVIATO ? "X" : "", _spedita); // Spedita
|
||||
row.add(to_send); // Da spedire
|
||||
row.add(is_cust.full() ? "X" : "", _forzata); // Modificato
|
||||
row.add(movimento.get_long("NUMREG"), _numero); // Numero registrazione
|
||||
row.add(movimento.get_date("DATAREG"), _datareg); // Data Registrazione
|
||||
row.add(movimento.get("TIPO"), _tipocf); // Tipo Cli/For
|
||||
row.add(movimento.get("CODCF"), _codcf); // Codice Cli/For
|
||||
row.add(movimento.get("OCCAS"), _occas); // Codice Occasionale
|
||||
row.add(cli.get("RAGSOC"), _ragsoc); // Ragione sociale
|
||||
row.add(cli.get("CODRFSO"), _rfso); // Codice RF/SO
|
||||
row.add(get_rfso(cli.get("CODRFSO")), _ragsocrfso); // Ragione Sociale RF/SO
|
||||
row.add(movimento.get("NUMDOC"), _numdoc); // Numero documento
|
||||
row.add(movimento.get_date("DATADOC"), _datadoc); // Data documento
|
||||
nat = movimento.get("NATURA");
|
||||
const char * to_send = movimento.get("TFINVIO").blank() ? FLAG_INVIO : movimento.get("TFINVIO");
|
||||
const int nrow = sheet.set_row_cell(A_SPEDITA, movimento.get("TFINVIO") == FLAG_INVIATO); // Spedita
|
||||
|
||||
sheet.set_row_cell(A_INVIO, to_send, nrow);
|
||||
// Da spedire
|
||||
sheet.set_row_cell(A_FORZATA, is_cust.full(), nrow); // Modificato
|
||||
sheet.set_row_cell(A_NUMERO, movimento.get_long("NUMREG"), nrow); // Numero registrazione
|
||||
sheet.set_row_cell(A_DATAREG, movimento.get_date("DATAREG"), nrow); // Data Registrazione
|
||||
sheet.set_row_cell(A_TIPOCF, movimento.get("TIPO"), nrow); // Tipo Cli/For
|
||||
sheet.set_row_cell(A_CODCF, movimento.get("CODCF"), nrow); // Codice Cli/For
|
||||
sheet.set_row_cell(A_OCFPI, movimento.get("OCCAS"), nrow); // Codice Occasionale
|
||||
sheet.set_row_cell(A_RAGSOC, cli.get("RAGSOC"), nrow); // Ragione sociale
|
||||
sheet.set_row_cell(A_RFSO, cli.get("CODRFSO"), nrow); // Codice RF/SO
|
||||
sheet.set_row_cell(A_RAGSOCRFSO, get_rfso(cli.get("CODRFSO")), nrow); // Ragione Sociale RF/SO
|
||||
sheet.set_row_cell(A_NUMDOC, movimento.get("NUMDOC"), nrow); // Numero documento
|
||||
sheet.set_row_cell(A_DATADOC, movimento.get_date("DATADOC"), nrow); // Data documento
|
||||
nat = movimento.get("NATURA");
|
||||
if (nat.blank())
|
||||
{
|
||||
TCodiceIVA civa(iva);
|
||||
|
||||
nat = civa.natura();
|
||||
}
|
||||
row.add(nat, _natura); // NATURA!
|
||||
row.add(iva, _aliquota); // Codice aliquota!
|
||||
row.add(find_detraib(movimento.get("TIPODET")), _detraibile); // Detraibilità
|
||||
row.add(movimento.get_real("IMPONIBILE"), _imponibile); // Imponibile
|
||||
row.add(movimento.get_real("IMPOSTA"), _importoIVA); // Imposta
|
||||
row.add(rev_charge(movimento.get("NUMREG"), movimento.get_date("DATAREG").year()), _reverse); // Rev.Charge
|
||||
sheet.set_row_cell(A_NATURA, nat, nrow); // NATURA!
|
||||
sheet.set_row_cell(A_ALIQUOTA, iva, nrow); // Codice aliquota!
|
||||
sheet.set_row_cell(A_DETRAIB, find_detraib(movimento.get("TIPODET")), nrow); // Detraibilità
|
||||
sheet.set_row_cell(A_IMPONIBILE, movimento.get_real("IMPONIBILE"), nrow); // Imponibile
|
||||
sheet.set_row_cell(A_IMPOSTA, movimento.get_real("IMPOSTA"), nrow); // Imposta
|
||||
sheet.set_row_cell(A_REVERSE, rev_charge(movimento.get("NUMREG"), movimento.get_date("DATAREG").year()), nrow); // Rev.Charge
|
||||
sheet.set_row_cell(A_TIPODOC, movimento.get("TIPODOC"), nrow);
|
||||
// Calcolo il tipo documento alla fine per sicurezza
|
||||
if (is_cust.full())
|
||||
sheet.set_row_cell(A_TIPODOCAE, movimento.get("TIPODOCAE").blank() ? decod_tipo(sheet.row(nrow)) : movimento.get("TIPODOCAE"), nrow); // Tipo documento
|
||||
else
|
||||
sheet.set_row_cell(A_TIPODOCAE, decod_tipo(sheet.row(nrow)), nrow); // Tipo documento
|
||||
|
||||
|
||||
row.add(movimento.get("TIPODOC"), _codnum);
|
||||
// Calcolo il tipo documento alla fine per sicurezza
|
||||
if (is_cust.full())
|
||||
{
|
||||
row.add(movimento.get("TIPODOCAE").blank() ? decod_tipo(&row) : movimento.get("TIPODOCAE"), _codnumAE); // Tipo documento
|
||||
}
|
||||
else
|
||||
row.add(decod_tipo(&row), _codnumAE); // Tipo documento
|
||||
|
||||
/*
|
||||
* Possono esistere movimenti custom dove il cliente ha una partita IVA propria
|
||||
* ma è stato flaggato l'autofattura, quindi in trasfat è presente il codice cliente con PIVA e CODFIS della ditta.
|
||||
* Controllo sia il movimento che il cliente
|
||||
*/
|
||||
if(movimento.get("AUTOFATT") == "X" || piva_ditta == cli.get("PAIV")) // Se è un autofattura
|
||||
{
|
||||
row.add("X", _autofatt); // AutoFatt
|
||||
row.add(piva_ditta, _paiv); // P.IVA
|
||||
row.add(cofi_ditta, _codfis); // Codice Fiscale
|
||||
}
|
||||
else
|
||||
{
|
||||
row.add("", _autofatt); // AutoFatt
|
||||
row.add(cli.get("PAIV"), _paiv); // P.IVA
|
||||
row.add(cli.get("COFI"), _codfis); // Codice Fiscale
|
||||
}
|
||||
sheet.enable_cell(sheet.items()-1, _occas, movimento.get("OCCAS").full());
|
||||
}
|
||||
recimposte.destroy();
|
||||
}
|
||||
sheet.force_update();
|
||||
sheet.show();
|
||||
/*
|
||||
* Possono esistere movimenti custom dove il cliente ha una partita IVA propria
|
||||
* ma è stato flaggato l'autofattura, quindi in trasfat è presente il codice cliente con PIVA e CODFIS della ditta.
|
||||
* Controllo sia il movimento che il cliente
|
||||
*/
|
||||
if (movimento.get_bool("AUTOFATT") || piva_ditta == cli.get("PAIV")) // Se è un autofattura
|
||||
{
|
||||
sheet.set_row_cell(A_AUTOFATT, true, nrow); // AutoFatt
|
||||
sheet.set_row_cell(A_PAIV, piva_ditta, nrow); // P.IVA
|
||||
sheet.set_row_cell(A_COFI, cofi_ditta, nrow); // Codice Fiscale
|
||||
}
|
||||
else
|
||||
{
|
||||
sheet.set_row_cell(A_AUTOFATT, false, nrow); // AutoFatt
|
||||
sheet.set_row_cell(A_PAIV, cli.get("PAIV"), nrow); // P.IVA
|
||||
sheet.set_row_cell(A_COFI, cli.get("COFI"), nrow); // Codice Fiscale
|
||||
}
|
||||
sheet.enable_cell(nrow, A_OCFPI, movimento.get("OCCAS").full());
|
||||
}
|
||||
recimposte.destroy();
|
||||
}
|
||||
sheet.force_update();
|
||||
sheet.show();
|
||||
}
|
||||
|
||||
|
||||
bool TTrFa_mask::check_invio(const TString& invio) const
|
||||
{
|
||||
bool ok;
|
||||
|
Loading…
x
Reference in New Issue
Block a user