diff --git a/src/cg/cg2100.cpp b/src/cg/cg2100.cpp index b478d9859..7230996f1 100755 --- a/src/cg/cg2100.cpp +++ b/src/cg/cg2100.cpp @@ -123,11 +123,11 @@ TMask* TPrimanota_application::load_mask(int n) ism.set_handler(309, sheet_clifo_handler); ism.set_handler(CG_RATEO, sheet_rateo_handler); ism.set_handler(CG_RISCONTO, sheet_risconto_handler); - if (!has_f1_db(m)) + if (!has_module(FPAUT)) { if (m->find_by_id(F_COLFPPRO) != NULL) m->hide(F_COLFPPRO); - if(m->find_by_id(DLG_LINK) != NULL) + if (m->find_by_id(DLG_LINK) != NULL) m->disable(DLG_LINK); } else @@ -1634,14 +1634,14 @@ void TPrimanota_application::set_has_f1_db(TMask* m) if (m->find_by_id(F_DATAREG) != NULL && !m->get(F_DATAREG).empty()) { if (TDate(m->get(F_DATAREG)) >= TDate(fp_settings().get_data_start_fatt())) - _isfp = has_module(F1AUT) && !fp_settings().get_db_indirizzo().empty(); + _isf1 = has_module(F1AUT) && !fp_settings().get_db_indirizzo().empty(); else - _isfp = false; + _isf1 = false; _is_set_fpcheck = true; } else if (!_is_set_fpcheck) { - _isfp = false; + _isf1 = false; _is_set_fpcheck = true; } } @@ -1649,7 +1649,7 @@ void TPrimanota_application::set_has_f1_db(TMask* m) bool TPrimanota_application::has_f1_db(TMask* m) { set_has_f1_db(m); - return _isfp; + return _isf1; } bool TPrimanota_application::remove() @@ -2426,7 +2426,7 @@ int TPrimanota_application::save_fppro() else return pro_notsaved; // In altre modalita' esco senza fare nulla sul db } - // Controllo che sto registrando un documento FA Fattura di Acquisto o NC Acquisto + // Controllo che sto registrando un documento d'acquisto if (!check_causale(msk.get(F_CODCAUS))) return pro_notsaved; diff --git a/src/cg/cg2102.cpp b/src/cg/cg2102.cpp index fae48ad15..cdf61e698 100755 --- a/src/cg/cg2102.cpp +++ b/src/cg/cg2102.cpp @@ -2263,7 +2263,7 @@ bool TPrimanota_application::caus_query_handler(TMask_field& f, KEY key) void TPrimanota_application::check_fppro_fields(TMask& m) { const bool after_data = TDate(m.get(F_DATAREG)) >= TDate(fp_settings().get_data_start_fatt()); - if (!check_causale(m.get(F_CODCAUS)) || !app().has_f1_db(&m) || !after_data) + if (!check_causale(m.get(F_CODCAUS)) || !app().has_module(FPAUT) || !after_data) { if(m.find_by_id(DLG_LINK) != NULL) m.disable(DLG_LINK); @@ -3850,7 +3850,7 @@ bool TPrimanota_application::quadratura_handler(TMask_field& f, KEY key) bool TPrimanota_application::fppro_mask(TMask_field& f, KEY key) { TMask& cg_msk = f.mask(); - if (!app().get_isfp() || key != K_SPACE && key != K_TAB || !check_causale(f.mask().get(F_CODCAUS))) + if (!app().has_module(FPAUT) || key != K_SPACE && key != K_TAB || !check_causale(cg_msk.get(F_CODCAUS))) return true; auto msk = std::make_shared(cg_msk); app()._pro_mask = msk; @@ -3858,12 +3858,15 @@ bool TPrimanota_application::fppro_mask(TMask_field& f, KEY key) if (msk->load_fppro_mask(msk.get())) { msk->run(); - // Riporto dati FPPRO su maschera Prima Nota - cg_msk.set(F_NUMDOCEXT, msk->get_numdoc()); - cg_msk.set(F_NUMDOC, msk->get_numdoc().right(7)); - cg_msk.set(F_DATADOC, msk->get_datadoc()); - cg_msk.set(F_TOTALE, msk->get_totdoc()); - //cg_msk.set(F_PROTFPPRO, msk->get_protocollo()); + // Riporto dati FPPRO su maschera Prima Nota (solo se hai F1) + // Se non hai F1 collego senza riportarti i dati (solo le chiavi db) + if(app().has_f1_db(&cg_msk)) + { + cg_msk.set(F_NUMDOCEXT, msk->get_numdoc()); + cg_msk.set(F_NUMDOC, msk->get_numdoc().right(7)); + cg_msk.set(F_DATADOC, msk->get_datadoc()); + cg_msk.set(F_TOTALE, msk->get_totdoc()); + } cg_msk.set(F_PROKEY, msk->get_fpprokeys()); is_collegato(cg_msk.field(F_COLFPPRO)); diff --git a/src/cg/cg2102.h b/src/cg/cg2102.h index 12295e703..3c093028b 100755 --- a/src/cg/cg2102.h +++ b/src/cg/cg2102.h @@ -96,7 +96,7 @@ class TPrimanota_application : public TRelation_application TEsercizi_contabili _esercizi; // Tabella degli esercizi contabili TAssoc_array _colori; // Colori delle righe - bool _isfp; + bool _isf1; shared_ptr _pro_mask; bool _is_set_fpcheck; int _last_date; @@ -365,7 +365,7 @@ public: static char row_type(const TToken_string& s); static bool iva_notify(TSheet_field& s, int r, KEY key); static bool cg_notify(TSheet_field& s, int r, KEY key); - bool get_isfp() const { return _isfp; } + bool get_isf1() const { return _isf1; } int get_lastdate() { return _last_date; } TMask * mask(CGMaskType type) { return _msk[type]; } diff --git a/src/cg/cg2FPPRO.uml b/src/cg/cg2FPPRO.uml index db9c04dea..5f8dcfc52 100644 --- a/src/cg/cg2FPPRO.uml +++ b/src/cg/cg2FPPRO.uml @@ -10,7 +10,7 @@ END BUTTON DLG_LINK 2 2 BEGIN - PROMPT 3 1 "Riporta Dati" + PROMPT 3 1 "Collega Documento" PICTURE TOOL_LINK END @@ -73,7 +73,7 @@ END TEXT F_SHEET_TEXT BEGIN - PROMPT 0 6 "@BSelezionare la fattura, quindi premere 'Riporta Dati'" + PROMPT 0 6 "@BSelezionare la fattura, quindi premere 'Collega Documento'" END BOOLEAN F_SHOWALL diff --git a/src/f1/f1lib.cpp b/src/f1/f1lib.cpp index d66d27e12..1c198b0d9 100644 --- a/src/f1/f1lib.cpp +++ b/src/f1/f1lib.cpp @@ -271,26 +271,38 @@ void set_periodprec(bool flag) ini_set_bool(CONFIG_DITTA, FILE_SECTION, "flag_periodprec", flag); } -bool check_causale(const TString& cod_caus) +bool check_causale(const TString& cod_caus, bool acq) { - return check_causale(cod_caus, "FA") || check_causale(cod_caus, "NC"); + return + check_causale(cod_caus, "FA", acq) || + check_causale(cod_caus, "BD", acq) || + check_causale(cod_caus, "AF", acq) || + check_causale(cod_caus, "FF", acq) || + check_causale(cod_caus, "NC", acq) || + check_causale(cod_caus, "ND", acq); } -bool check_causale(const TString& cod_caus, const TString& tipo_doc) +bool check_causale(const TString& cod_caus, const TString& tipo_doc, bool acq) { - TCausale caus(cod_caus); + const TCausale caus(cod_caus); - if(tipo_doc == "FA") - return caus.tipo_doc() == "FA"; + if(tipo_doc == "FA" || tipo_doc == "BD" || tipo_doc == "AF" || tipo_doc == "FF") + return caus.tipo_doc() == tipo_doc; - if (tipo_doc == "NC") + if (tipo_doc == "NC" || tipo_doc == "ND") { - bool nc; - bool nc_acq = false; - if ((nc = caus.tipo_doc() == "NC")) - nc_acq = caus.reg().tipo() == iva_acquisti; - return nc && nc_acq; + bool nota; + bool nota_iva = false; + if ((nota = caus.tipo_doc() == tipo_doc)) + { + if (acq) + nota_iva = caus.reg().tipo() == iva_acquisti; + else + nota_iva = caus.reg().tipo() == iva_vendite; + } + return nota && nota_iva; } + return false; } diff --git a/src/f1/f1lib.h b/src/f1/f1lib.h index cf33e46b3..ee4243678 100644 --- a/src/f1/f1lib.h +++ b/src/f1/f1lib.h @@ -107,8 +107,8 @@ void set_dataendreg(const TString& date); void set_periodprec(bool flag); // Controlla se il "cod_caus" e' per Fatture d'acquisto o Note Credito d'Acquisto -bool check_causale(const TString& cod_caus); +bool check_causale(const TString& cod_caus, bool acq = true); // Controlla se il "cod_caus" ha come "tipo_doc" FA o NC (di acquisto) -bool check_causale(const TString& cod_caus, const TString& tipo_doc); +bool check_causale(const TString& cod_caus, const TString& tipo_doc, bool acq = true); void run_cont_ini(bool liq); #endif \ No newline at end of file