diff --git a/src/tf/f173.dir b/src/tf/f173.dir index 20d41e0ce..deadc502e 100644 --- a/src/tf/f173.dir +++ b/src/tf/f173.dir @@ -1,3 +1,3 @@ 173 0 -$trasfatt|1|1|107|0|Tabella trasferimento fatture||| +$trasfatt|2|2|110|0|Tabella trasferimento fatture||| diff --git a/src/tf/f173.trr b/src/tf/f173.trr index b6395f9d2..56625851a 100644 --- a/src/tf/f173.trr +++ b/src/tf/f173.trr @@ -1,6 +1,6 @@ 173 15 -NUMREG|3|7|0|Codice esercizio +NUMREG|3|10|0|Codice esercizio TIPO|7|1|0|Tipo liente o ornitore CODCF|3|6|0|Codice TIPODOC|1|2|0|Tipo documento @@ -13,7 +13,7 @@ IMPOSTA|4|18|3|Imposta CODIVA|1|4|0|Codice IVA TIPODET|1|1|0|Codice detraibilità AUTOFATT|8|1|0|Booleano autofattura -TFINVIO|8|1|0|Flag Invio +TFINVIO|7|1|0|Flag Invio TFDATA|5|8|0|Data ultimo invio 1 NUMREG+CODIVA| diff --git a/src/tf/tf0100.cpp b/src/tf/tf0100.cpp index 1b9927c84..fc402dcfa 100644 --- a/src/tf/tf0100.cpp +++ b/src/tf/tf0100.cpp @@ -642,7 +642,7 @@ TRectype TTrFa_cursors::_nextCust(return_code& code, TString& tipocf, TString& c bool TTrFa_cursors::checkRecord(TISAM_recordset* rec) { TString codiva = rec->get("25.CODIVA").as_string(); - + // Tolgo i non soggetti TCodiceIVA cod(codiva); if(cod.tipo() == "NS") @@ -743,7 +743,6 @@ void TTrFa_mask::next_page(int p) bool TTrFa_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) { - switch (o.dlg()) { case F_DATAINI: @@ -1073,6 +1072,10 @@ bool TTrFa_mask::checkAll() TExternal_app servizio("cg1 -2 L"); servizio.run(); } + + // Sistemo i flag + theFinalCheckDown(); + static TPrinter stampa; stampa.reset(); stampa.open(); @@ -1085,7 +1088,7 @@ bool TTrFa_mask::checkAll() riga.put("Tipo errore", 40); stampa.setheaderline(3, riga); riga.reset(); - riga.put(TR("Tutti i record errati sono stati segnati con il codice \"Errore\" e non verranno inviati"), 0); + riga.put(TR("Tutti i record qui elencati sono stati segnati con il codice \"Errore\" e non verranno inviati"), 0); stampa.setheaderline(2, riga); riga.reset(); stampa.setheaderline(4, riga); @@ -1181,6 +1184,43 @@ bool TTrFa_mask::checkNotEmpty() return sheet.full(); } +void TTrFa_mask::theFinalCheckDown() +{ + TSheet_field& sheet = sfield(F_RIGHE); + TAssoc_array cliDocs; + FOR_EACH_SHEET_ROW(sheet, r, strarr) + { + // Chiave: TIPOCF + CODCF + NUMDOC + CODIVA + TString key; key << strarr->get_char(_tipocf) << "|" << strarr->get_int(_codcf) << "|" << strarr->get(_numdoc) << "|" << strarr->get(_aliquota); + TToken_string newNumero; newNumero.add(r, 0); newNumero.add(strarr->get_char(_invio), 1); + if(cliDocs.is_key(key)) + { + TToken_string oldnumero = *(TToken_string*)cliDocs.objptr(key); + TString oldflag; oldnumero.get(1, oldflag); + if(oldflag == FLAG_FORZATO) + flagRow(r, FLAG_NINVIO); + else + { + int oldr; oldnumero.get(0, oldr); + flagRow(oldr, FLAG_NINVIO); + } + + cliDocs.add(key, newNumero); + } + else + { + cliDocs.add(key, newNumero); + } + } +} + +void TTrFa_mask::flagRow(int nrow, TString flag) +{ + TSheet_field& sheet = sfield(F_RIGHE); + TToken_string& row = sheet.row(nrow); + row.add(flag, _invio); +} + TRecnotype TTrFa_mask::nuovo_progr() const { static TRectype app(LF_TRASFATT); @@ -1844,6 +1884,7 @@ bool TTrFa_app::tff0400(TSheet_field& sheet) TAnagrafica cedeprest(LF_CLIFO, strarr->get_char(_tipocf), strarr->get_long(_codcf)); TString keyCedPrest; keyCedPrest << strarr->get_char(_tipocf) << "|" << strarr->get_long(_codcf); + TRectype r_cedeprest = cache().get(LF_CLIFO, keyCedPrest); TString statocli = cache().get("%STA", r_cedeprest.get("STATOCF"), "S10"); // Se rimane vuoto è italiano @@ -1874,12 +1915,63 @@ bool TTrFa_app::tff0400(TSheet_field& sheet) } } - if (cedeprest.fisica()) + // Sono sicuro che se è di tipo 3,7 o 8 ha la ragione sociale + char tipo = r_cedeprest.get_char(CLI_ALLEG); + bool rsoc = cedeprest.giuridica() || (tipo == '3' || tipo == '7' || tipo == '8'); + bool privato = tipo == '6'; + + if (!rsoc) { - tff0400f.set("P4_ANANOME", cedeprest.nome()); - tff0400f.set("P4_ANACOGNOME", cedeprest.cognome()); + // Bisogna fare un ragionamento più complesso, esistono ancora record salvati con Nome e Cognome nella prima parte + // e non divisi come si fa adesso quindi farò così: + + // Controllo se il nome è pieno + if(cedeprest.nome().full()) + { + // La vita è bella faccio che scrivere + tff0400f.set("P4_ANANOME", cedeprest.nome()); + tff0400f.set("P4_ANACOGNOME", cedeprest.cognome()); + } + else + { + // Devo indovinare quale è il nome e il cognome + TToken_string nomeCog(cedeprest.cognome(), ' '); // Notare il separatore spazio + // Controllo se ho solo un nome e un cognome + if(nomeCog.items() <= 2) + { + tff0400f.set("P4_ANANOME", nomeCog.get(1)); + tff0400f.set("P4_ANACOGNOME", nomeCog.get(0)); + } + else + { + TString cognome; cognome << nomeCog.get(0); + + // Potrebbe essere un cognome tipo "De Fischello" + // Dai quante persone hanno più di 4 parole per nome e cognome? + if(privato || (cognome.len() >= 2 && cognome.len() <= 4)) + { + // Controllo che non sia una Ragione sociale! Tipo "ZG di Gianluigi Zibello" + // Se è segnato privato me ne sbatto anche di sto controllo + if(privato || TString(nomeCog.get(1)).len() > 2) + { + cognome << " " << nomeCog.get(1); + TString nome; + for(int i = 2; i < nomeCog.items(); i++) + nome << nomeCog.get(i) << " "; + tff0400f.set("P4_ANANOME", cognome); + tff0400f.set("P4_ANACOGNOME", nome); + } + else + rsoc = true; + } + else + rsoc = true; + } + } } - else + + // Ricontrollo!!!! rsoc potrebbe essere cambiato sopra + if(rsoc) { tff0400f.set("P4_ANADENOM", cedeprest.ragione_sociale()); } diff --git a/src/tf/tf0100a.uml b/src/tf/tf0100a.uml index 34369d908..61ec3518e 100644 --- a/src/tf/tf0100a.uml +++ b/src/tf/tf0100a.uml @@ -191,11 +191,13 @@ BEGIN FLAGS "D" END -LIST A_INVIO 1 10 +LIST A_INVIO 1 15 BEGIN PROMPT 1 10 "Da inviare" ITEM "X|Da Inviare" - ITEM "E|Errore" + ITEM "N|Da non inviare" + ITEM "F|Forzato" + ITEM "E|Errato" FIELD INVIO END diff --git a/src/tf/tf0100b.h b/src/tf/tf0100b.h index dfb74467c..688dae476 100644 --- a/src/tf/tf0100b.h +++ b/src/tf/tf0100b.h @@ -45,6 +45,11 @@ enum filter_fatt #define DTE_PROVV "DTE0000001" #define DTR_PROVV "DTR0000001" #define TOLLARANZA 0.05 +// Flag invio +#define FLAG_INVIO "X" +#define FLAG_ERRORE "E" +#define FLAG_NINVIO "N" +#define FLAG_FORZATO "F" /* Così facendo basta modificare la maschera (e le dichiarazioni di conseguenza) * per avere l'inserimento nello sheet corretto */ @@ -209,6 +214,11 @@ public: bool checkRec(TPrinter* stampa, TToken_string rec); // Controllo che siano presenti records bool checkNotEmpty(); + // Controllo finale prima di inviare il tutto, se ci sono fatture + // con più volte lo stesso codice aliquota disabilito il precedente + void theFinalCheckDown(); + // Mette il flag di invio = [flag] per la riga numero [nrow] + void flagRow(int nrow, TString flag); }; // Funzione inline di stampa inline void printError(TPrinter* stampa, TString movimento, TString documento, TString msgerr);