diff --git a/src/tf/tf0100.cpp b/src/tf/tf0100.cpp index 5281d8029..773ae0ee0 100644 --- a/src/tf/tf0100.cpp +++ b/src/tf/tf0100.cpp @@ -311,6 +311,12 @@ inline const char * noSpecial(char a) return ""; } +bool bd2017() +{ + static TDate today = TDate(TODAY), lastDay = TDate(31,12,2017); + return today <= lastDay; +} + ///////////////////////////////////////////////////////////////////////////////////// // TTrFa_record ///////////////////////////////////////////////////////////////////////////////////// @@ -1105,6 +1111,11 @@ bool TTrFa_app::tff0400(TSheet_field& sheet) TVariant vtipocf = strarr->get(_tipocf), vcodcf = strarr->get(_codcf), voccas = strarr->get(_occas); +#ifdef DBG + if(vtipocf.as_string() == "F" && vcodcf.as_string() == "358") + bool tolla = true; +#endif + TRectype r_cedeprest = getCli(vtipocf.as_string(), vcodcf.as_string(), voccas.as_string()); TAnagrafica cedeprest; @@ -1149,7 +1160,8 @@ bool TTrFa_app::tff0400(TSheet_field& sheet) { // Ovviamente tutte le bolle doganali fatte prima del rilascio // non avranno questo campo compilato e quindi dovrò passare la partita IVA "OO99999999999" - if(strcmp(strarr->get(_codnum),"BD") == 0) + // Controllo anche di essere in una data entro il 31/12/2017, dopo tale data sto ragionamento non è valido + if(strcmp(strarr->get(_codnum),"BD") == 0 && bd2017()) { tff0400f.set("P4_FISCIVAPAESE", "OO"); tff0400f.set("P4_FISCIVACOD", "99999999999"); @@ -1192,8 +1204,13 @@ bool TTrFa_app::tff0400(TSheet_field& sheet) { // Devo indovinare quale è il nome e il cognome TToken_string nomeCog(cedeprest.cognome(), ' '); // Notare il separatore spazio + // Se ho solo un nominativo è una ditta per Diana + if(nomeCog.items() == 1) + { + rsoc = true; + } // Controllo se ho solo un nome e un cognome - if(nomeCog.items() <= 2) + else if(nomeCog.items() == 2) { tff0400f.set("P4_ANANOME", nomeCog.get(1)); tff0400f.set("P4_ANACOGNOME", nomeCog.get(0)); @@ -1339,7 +1356,7 @@ bool TTrFa_app::tff2200(TToken_string* strarr, int nriga) real aliquota = cache().get("%IVA", strarr->get(_aliquota), "R0"); tff2200f.set("PL_ALIQUOTAIVA", aliquota); TRectype thisMov = cache().get(LF_MOV, strarr->get(_numero)); - tff2200f.set("PL_ESIGIVA", is_split_payment(thisMov) ? "S" : is_IVA_diff(thisMov) ? "D" : "I"); + tff2200f.set("PL_ESIGIVA", is_split_payment(thisMov) ? "S" : is_IVA_diff(thisMov) || is_IVAxCassa(thisMov) ? "D" : "I"); tff2200f.set("PL_NATURA", strarr->get(_natura)); real det(strarr->get(_detraibile)); // Nella conversione la vigola viene persa e 100,00 diventa 10.000 quindi divido diff --git a/src/tf/tf0100a.uml b/src/tf/tf0100a.uml index f468b9311..2dbea2f80 100644 --- a/src/tf/tf0100a.uml +++ b/src/tf/tf0100a.uml @@ -373,14 +373,14 @@ BEGIN FLAGS "D" END -CURRENCY A_IMPONIBILE 12 +NUMBER A_IMPONIBILE 12 2 BEGIN PROMPT 42 8 "Imponibile" FIELD IMPORTO CHEKTYPE REQUIRED END -CURRENCY A_IMPOSTA 12 +NUMBER A_IMPOSTA 12 2 BEGIN PROMPT 42 9 "Imposta " FIELD IMPOSTA diff --git a/src/tf/tf0100b.h b/src/tf/tf0100b.h index e6b2eb4b1..7bc1734e2 100644 --- a/src/tf/tf0100b.h +++ b/src/tf/tf0100b.h @@ -115,6 +115,8 @@ inline TDate toDate(const char * date) { return TDate(date).string(); } #define IF_IS_ENABLED(strarr) if(strcmp(strarr->get(_invio), FLAG_INVIO) != 0 && strcmp(strarr->get(_invio), FLAG_FORZATO) != 0) continue; // Ritorno il carattere senza accento maiuscolo inline const char * noSpecial(char a); +// Ritorno se è ancora valida la bolla doganale senza informazioni fornitore +bool bd2017(); ///////////////////////////////////////////////////////////////////////////////////// // TTrFa_record diff --git a/src/tf/tf0101.cpp b/src/tf/tf0101.cpp index a866262c3..e4cbf2417 100644 --- a/src/tf/tf0101.cpp +++ b/src/tf/tf0101.cpp @@ -123,7 +123,8 @@ bool TTrFa_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) if(imponibile > 0) { imposta = imponibile * real(cache().get("%IVA", o.get(), "R0")) / 100; - o.mask().set(A_IMPOSTA, imposta.round(2).string()); + if(imposta != o.mask().get_real(A_IMPOSTA) && yesno_box("Aggiornare l'imposta?")) + o.mask().set(A_IMPOSTA, imposta.round(2).string()); } } break; @@ -136,7 +137,8 @@ bool TTrFa_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) if(codiva != "") { imposta = imponibile * real(cache().get("%IVA", codiva, "R0")) / 100; - o.mask().set(A_IMPOSTA, imposta.round(2).string()); + if(imposta != o.mask().get_real(A_IMPOSTA) && yesno_box("Aggiornare l'imposta?")) + o.mask().set(A_IMPOSTA, imposta.round(2).string()); } } break; @@ -251,32 +253,38 @@ bool TTrFa_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) const long progr = o.mask().get_long(A_NUMERO); TString codalq = o.mask().get(A_ALIQUOTA); TString key; key << progr << "|" << codalq; - if (progr >= MOV_CUSTOM) - { - if(cache().get(LF_TRASFATT, key).full()) - { - TLocalisamfile trasfat(LF_TRASFATT); - trasfat.put("NUMREG", progr); - trasfat.put("CODIVA", codalq); - const int err = trasfat.remove(); - if (err != NOERR) - return error_box(FR("Errore di cancellazione: %d"), err); - } - // In qualsiasi caso elimino sta riga - TSheet_field& sheet = sfield(F_RIGHE); - // Vado a cercare la riga - FOR_EACH_SHEET_ROW(sheet, r, strarr) - { - long thisProg; - TString thisAlq; - strarr->get(_numero, thisProg); - strarr->get(_aliquota, thisAlq); - if(thisProg == progr && thisAlq == codalq) break; - } - sheet.destroy(r); // Aggiorna in automatico - } - else + if(cache().get(LF_TRASFATT, key).full()) + { + TLocalisamfile trasfat(LF_TRASFATT); + trasfat.put("NUMREG", progr); + trasfat.put("CODIVA", codalq); + const int err = trasfat.remove(); + if (err != NOERR) + return error_box(FR("Errore di cancellazione: %d"), err); + } + else return error_box(TR("Riga non cancellabile")); + + // Elimino la riga + TSheet_field& sheet = sfield(F_RIGHE); + // Vado a cercare la riga + FOR_EACH_SHEET_ROW(sheet, r, strarr) + { + long thisProg; + TString thisAlq; + strarr->get(_numero, thisProg); + strarr->get(_aliquota, thisAlq); + if(thisProg == progr && thisAlq == codalq) break; + } + sheet.destroy(r); // Aggiorna in automatico + + // Se ha cancellato un movimento custom che deriva dalla prima nota propongo di andarlo a ripescare + if(progr < MOV_CUSTOM && yesno_box("Hai cancellato una riga custom di un movimento in prima nota, vuoi ricaricare la tabella?\n(Tutti i record verranno salvati per non perdere le modifiche!)")) + { + saveAll(); + load_sheet(); + return true; + } } break; case DLG_EMAIL: