diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index 53b78b864..fc540f334 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -122,6 +122,7 @@ TMask* TPrimanota_application::load_mask(int n) m->set_handler(SK_TOTDOCVAL, totdocval_handler); m->set_handler(F_CODPAG, codpag_handler); m->set_handler(F_LINKDOC, linkdoc_handler); + m->set_handler(F_MASTRINO, mastrino_handler); TSheet_field& cg = m->sfield(F_SHEETCG); cg.set_notify(cg_notify); diff --git a/cg/cg2100.h b/cg/cg2100.h index ce1f764db..ab3903fe4 100755 --- a/cg/cg2100.h +++ b/cg/cg2100.h @@ -41,6 +41,7 @@ #define F_ANNORIF 124 #define F_NUMRIF 125 #define F_LINKDOC 126 +#define F_MASTRINO 127 #define F_PROVVISORIO 129 #define F_OCCASEDIT 131 #define F_SOLAIVA 132 @@ -76,9 +77,7 @@ #define CG_SOTTOCONTO 106 #define CG_DESCR 109 #define CG_ROWTYPE 115 -#define CG_MASTRINO 116 - - +#define CG_MASTRINO 199 // Campi ripetuti sulla seconda pagina #define H_DATAREG 201 diff --git a/cg/cg2100b.uml b/cg/cg2100b.uml index 2371cbc5f..16edfecea 100755 --- a/cg/cg2100b.uml +++ b/cg/cg2100b.uml @@ -395,22 +395,27 @@ END NUMBER F_GRUPPO 3 BEGIN - PROMPT 1 -2 "Conto riga corrente " + PROMPT 1 -2 "Conto riga corrente " FLAGS "D" END NUMBER F_CONTO 3 BEGIN - PROMPT 31 -2 "" + PROMPT 26 -2 "" FLAGS "D" END NUMBER F_SOTTOCONTO 6 BEGIN - PROMPT 36 -2 "" + PROMPT 31 -2 "" FLAGS "D" END +BUTTON F_MASTRINO 8 +BEGIN + PROMPT 39 -2 "Mastrino" +END + STRING F_SALDOCONTO 20 BEGIN PROMPT 51 -2 "Saldo " diff --git a/cg/cg2100c.uml b/cg/cg2100c.uml index 95e9e2fde..1ee00f6d9 100755 --- a/cg/cg2100c.uml +++ b/cg/cg2100c.uml @@ -691,22 +691,27 @@ END NUMBER F_GRUPPO 3 BEGIN - PROMPT 1 -2 "Conto riga corrente " + PROMPT 1 -2 "Conto riga corrente " FLAGS "D" END NUMBER F_CONTO 3 BEGIN - PROMPT 31 -2 "" + PROMPT 26 -2 "" FLAGS "D" END NUMBER F_SOTTOCONTO 6 BEGIN - PROMPT 36 -2 "" + PROMPT 31 -2 "" FLAGS "D" END +BUTTON F_MASTRINO 8 +BEGIN + PROMPT 39 -2 "Mastrino" +END + STRING F_SALDOCONTO 20 BEGIN PROMPT 51 -2 "Saldo " diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index 87a906042..860c78c11 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -551,7 +551,7 @@ HIDDEN bool imptot_error(const TImporto& imptot, const TImporto& impsal, bool va { TPrimanota_application& a = app(); const TMask& m = a.curr_mask(); - TString16 codval; + TString4 codval; if (val) codval = m.get(SK_VALUTA); TCurrency euro(imptot.valore(), codval); @@ -1822,14 +1822,10 @@ bool TPrimanota_application::sheet_clifo_handler(TMask_field& f, KEY k) return true; } -bool TPrimanota_application::sheet_mastrino_handler(TMask_field& f, KEY k) +void TPrimanota_application::link_mastrino(const TBill& bill) const { - if (k == K_SPACE) + if (bill.ok()) { - TMask& m = f.mask(); - const TString& tipo = m.get(CG_TIPO); - const short id_sotto = CG_SOTTOCONTO + (tipo.blank() ? 0 : (tipo == "C" ? 100 : 200)); - TPrimanota_application& a = app(); const TMask& cm = a.curr_mask(); @@ -1838,21 +1834,25 @@ bool TPrimanota_application::sheet_mastrino_handler(TMask_field& f, KEY k) { TDate date = cm.get(F_DATACOMP); if (!date.ok()) + { date = cm.get_date(F_DATAREG); + if (!date.ok()) + date = TDate(TODAY); + } anno = a._esercizi.date2esc(date); } TFilename ininame; ininame.tempdir(); ininame.add("mastrino.ini"); - if (anno > 0 && !m.field(id_sotto).empty()) + if (anno > 0) { TConfig ini(ininame, "Transaction"); ini.set("Action", "Modify"); - ini.set_paragraph("23"); + ini.set_paragraph("24"); ini.set(RMV_ANNOES, anno); - ini.set(RMV_TIPOC, tipo); - ini.set(RMV_GRUPPO, m.get(CG_GRUPPO)); - ini.set(RMV_CONTO, m.get(CG_CONTO)); - ini.set(RMV_SOTTOCONTO, m.get(id_sotto)); + ini.set(RMV_TIPOC, bill.tipo()); + ini.set(RMV_GRUPPO, bill.gruppo()); + ini.set(RMV_CONTO, bill.conto()); + ini.set(RMV_SOTTOCONTO, bill.sottoconto()); } if (ininame.exist()) { @@ -1860,8 +1860,32 @@ bool TPrimanota_application::sheet_mastrino_handler(TMask_field& f, KEY k) cmd << "cg3 -5 -i" << ininame; TExternal_app app(cmd); app.run(); + xvt_fsys_removefile(ininame); } } +} + +bool TPrimanota_application::mastrino_handler(TMask_field& f, KEY k) +{ + if (k == K_SPACE) + { + TMask& m = f.mask(); + TBill bill; bill.get(m, F_GRUPPO, F_CONTO, F_SOTTOCONTO); + app().link_mastrino(bill); + } + return true; +} + +bool TPrimanota_application::sheet_mastrino_handler(TMask_field& f, KEY k) +{ + if (k == K_SPACE) + { + TMask& m = f.mask(); + const char tipo = m.get(CG_TIPO)[0]; + const short id_sotto = CG_SOTTOCONTO + (tipo <= ' ' ? 0 : (tipo == 'C' ? 100 : 200)); + TBill bill; bill.get(m, CG_GRUPPO, CG_CONTO, id_sotto, CG_TIPO); + app().link_mastrino(bill); + } return true; } diff --git a/cg/cg2102.h b/cg/cg2102.h index 4bf91cf4f..cc4fc2f9e 100755 --- a/cg/cg2102.h +++ b/cg/cg2102.h @@ -133,6 +133,7 @@ class TPrimanota_application : public TRelation_application static bool tipopag_handler(TMask_field& f, KEY key); static bool prorata_handler(TMask_field& f, KEY k); static bool linkdoc_handler(TMask_field& f, KEY k); + static bool mastrino_handler(TMask_field& f, KEY k); static bool ratalit_handler(TMask_field& f, KEY key); static bool rataval_handler(TMask_field& f, KEY key); @@ -148,6 +149,7 @@ class TPrimanota_application : public TRelation_application void reset_sheet_row(TSheet_field& s, int n); int crea_somma_spese(TImporto& imp); void update_saldo_riga(int r); + void link_mastrino(const TBill& bill) const; protected: // TApplication virtual void on_firm_change(); diff --git a/cg/cg3600.cpp b/cg/cg3600.cpp index ba3dbc172..b1e9f9e90 100755 --- a/cg/cg3600.cpp +++ b/cg/cg3600.cpp @@ -2487,7 +2487,7 @@ bool TMastrini_video::menu(MENU_TAG mt) TFilename ininame = argv(2)+2; if (ininame.exist()) { - TConfig ini(ininame, "23"); + TConfig ini(ininame, "24"); qm.set(F_ESERCIZIO, ini.get(RMV_ANNOES)); qm.set(F_TIPO, ini.get(RMV_TIPOC)); qm.set(F_GRUPPO, ini.get(RMV_GRUPPO)); @@ -2504,7 +2504,6 @@ bool TMastrini_video::menu(MENU_TAG mt) if (codesc <= 0) codesc = esercizi.last(); if (esercizi.exist(codesc)) - { const TEsercizio& esercizio = esercizi.esercizio(codesc); qm.set(F_ESERCIZIO, codesc); diff --git a/cg/cglib01.cpp b/cg/cglib01.cpp index 96563c97c..6db845c10 100755 --- a/cg/cglib01.cpp +++ b/cg/cglib01.cpp @@ -882,7 +882,12 @@ int TBill::indicatore_bilancio() const str.format("%d|%d", gruppo(), conto()); const int ib = atoi(cache().get(LF_PCON, str, PCN_INDBIL)); if (ib <= 0) - NFCHECK("Impossibile stabilire l'indicatore di bilancio"); + { + TString msg = str; + msg.replace('|', '.'); + msg.insert(TR("Impossibile stabilire l'indicatore di bilancio del conto ")); + NFCHECK(msg); + } return ib; }