diff --git a/cg/cg4301.cpp b/cg/cg4301.cpp index aec28e2a4..54739c48c 100755 --- a/cg/cg4301.cpp +++ b/cg/cg4301.cpp @@ -1052,7 +1052,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) iva_vend += _plm->get_real("R0"); iva_acq += _plm->get_real("R1"); - risultato += (_plm->get_real("R0") - _plm->get_real("R1")); + risultato += (_plm->get_real("R0") + _plm->get_real("R1")); detrazioni+= (_plm->get_real("R3") + _plm->get_real("R4")); res_debt += _plm->get_real("R0"); res_cred += _plm->get_real("R1"); @@ -1249,10 +1249,17 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) if (tot_cong.sign() < 0) res_cred += abs(tot_cong); look_lim(month,TRUE); - // azzeriamo tutto - TString codtab = _lim->get("CODTAB"); + // azzeriamo tutto (tranne r1, r5, s7) + TString codtab = _lim->get("CODTAB"); + + real r5(_lim->get("R5")), r1(_lim->get("R1")); + TString s7(_lim->get("S7")); + _lim->zero(); - _lim->put("CODTAB", codtab); + _lim->put("CODTAB", codtab); + _lim->put("R1", r1); + _lim->put("R5", r5); + _lim->put("S7", s7); /* * versamenti effettuati: si conteggiano in R0, diff --git a/cg/cg4302.cpp b/cg/cg4302.cpp index 93414ca54..963c2e21d 100755 --- a/cg/cg4302.cpp +++ b/cg/cg4302.cpp @@ -341,7 +341,6 @@ bool TLiquidazione_app::look_rmb(int month, const char* codiva, tiporeg tr, bool return ok; } - bool TLiquidazione_app::look_del(int month, int type, bool create) { long ditta = _nditte->curr().get_long("CODDITTA"); @@ -360,7 +359,22 @@ bool TLiquidazione_app::look_del(int month, int type, bool create) { _del->zero(); _del->put("CODTAB",ctab); - _del->write(); + + // TBI infila ufficio concessione in S9 + + // sistema codice tributo + int ctri = 6000; + if (month == 13 && type == 7) + ctri = 6035; // acconto IVA annuale (trimestrali?) + else if (month == 13 && type == 1) + ctri = 6099; // IVA annuale + else if (month < 13 && type == 7) + ctri = 6013; // acconto mensile + else if (month < 13 && type == 1) // regular + ctri = _freqviva == "M" ? 6000 + month : 6030 + (month/3); + + _del->put("S6", format("%d",ctri)); + _del->write(); } return ok; } diff --git a/cg/cg5500.cpp b/cg/cg5500.cpp index 7a98ae456..f4109972a 100755 --- a/cg/cg5500.cpp +++ b/cg/cg5500.cpp @@ -201,12 +201,10 @@ bool Visliq_app::sheet_action(int r, KEY k) bool Visliq_app::vers_action(int r, KEY k) { - // non si possono cancellare o aggiungere righe + // non si possono cancellare o aggiungere righe return (k != K_DEL && k != K_INS); } - - const char* Visliq_app::link_handler(TMask& m, int n, const char* txt, bool doubleclick) { @@ -307,7 +305,7 @@ bool Visliq_app::sel_mese_sh1 (TMask_field& f, KEY k) { if (k != K_SPACE) return TRUE; - TMask& m = *(((Visliq_app&)main_app()).get_main_mask()); + TMask& m = *(app().get_main_mask()); TSheet_field& sh = (TSheet_field&)m.field(F_VISLIQ1); int month = sh.selected()+1; TToken_string& tt = sh.row(sh.selected()); @@ -331,18 +329,18 @@ bool Visliq_app::sel_mese_sh2 (TMask_field& f, KEY k) { if (k != K_SPACE) return TRUE; - TMask& m = *(((Visliq_app&)main_app()).get_main_mask()); + TMask& m = *(app().get_main_mask()); TSheet_field& sh = (TSheet_field&)m.field(F_VISLIQ2); int month = sh.selected()+1; if (sh.items() == 4) month *= 3; - ((Visliq_app&)main_app()).vis_one(month); + app().vis_one(month); return TRUE; } void Visliq_app::update_sheet_row(TToken_string& t) { - // t.add(abs(_lim->get_real("R0")).string(),2); - // t.add((_lim->get_real("R0")).sign() > 0 ? "D" : "C", 3); + t.add(abs(_lim->get_real("R0")).string(),2); + t.add((_lim->get_real("R0")).sign() > 0 ? "D" : "C", 3); t.add((_lim->get_real("R1")).string(),4); t.add(abs(_lim->get_real("R5")).string(),5); t.add((_lim->get_real("R5")).sign() > 0 ? "D" : "C", 6); @@ -414,9 +412,12 @@ bool Visliq_app::vis_all() TSheet_field& sh = (TSheet_field&)m.field(F_VISLIQ1); TSheet_field& sv = (TSheet_field&)m.field(F_VISLIQ2); + _liq_sheet = &sh; + _vers_sheet = &sv; + // disabilita aggiunta/eliminazione righe sh.set_notify(sheet_action); - // TBI qui occorre modificare le deleghe + // qui occorre modificare le deleghe sv.set_notify(vers_action); sh.sheet_mask().set_handler(101,sel_mese_sh1); @@ -428,9 +429,16 @@ bool Visliq_app::vis_all() for (int i = 1; i <= 12; i++) { - if (!is_month_ok(i) || !look_lim(i)) + if (!is_month_ok(i)) + continue; + + if (!look_lim(i)) + { + sh.row(i-1) = *(new TToken_string("||||||")); + sh.disable_cell(i-1, -1); continue; - + } + TToken_string* tt = new TToken_string(80); tt->add(""); // questo e' il bottone @@ -447,6 +455,7 @@ bool Visliq_app::vis_all() // calcola versamenti real versamenti[13]; TDate date[13]; + TToken_string banche[13]; for (_del->first(); !_del->eof(); _del->next()) { @@ -456,7 +465,7 @@ bool Visliq_app::vis_all() // uso solo deleghe normali (tipo == 1) e acconti (tipo == 7) int tipod = atoi(*_del_tipo); - if (tipod != 1 || tipod != 7) + if (tipod != 1 && tipod != 7) continue; // somma versamenti nel mese adeguato @@ -465,11 +474,11 @@ bool Visliq_app::vis_all() if (m >= 12) m = tipod == 7 ? 12 : 13; - versamenti[m-1] += _del->get_real("R0"); + versamenti[m-1] += _del->get_real("R0") + _del->get_real("R1"); date[m-1] = _del->get_date("D0"); - abi = _del->get("S7"); - cab = _del->get("S8"); - cnc = _del->get("S9"); + banche[m-1].add(_del->get("S7"),0); + banche[m-1].add(_del->get("S8"),1); + banche[m-1].add(_del->get("S9"),2); } TString nomemese(26); @@ -488,21 +497,129 @@ bool Visliq_app::vis_all() tt->add(""); // questo e' il bottone tt->add(nomemese); // mese tt->add(date[i-1].string()); // data vers. - tt->add(abi); // azienda - tt->add(cab); // dipendenza - tt->add(cnc); // concessionaria + tt->add(banche[i-1].get(0)); // azienda + tt->add(banche[i-1].get(1)); // dipendenza + tt->add(banche[i-1].get(2)); // concessionaria tt->add(versamenti[i-1].string());// versamenti - tt->add(versamenti[i-1].sign() < 0 ? "C" : "D"); // debito/credito (che senso ha?) sv.row(i-1) = (*tt); } - sh.disable(); - sv.disable(); + sh.enable_column(0, FALSE); + sv.enable_column(0, FALSE); - m.run(); - _mask = NULL; + // save initial rows + _vers_rows = sv.rows_array(); + _liq_rows = sh.rows_array(); + KEY k = m.run(); + + bool save = k == K_SAVE; + bool asked = save; + + if (k != K_ESC) + { + if (m.field(F_CREDPREC).dirty()) + { + real r(m.get(F_CREDPREC)); + if (!asked && !save) + { + save = yesno_box("Modifiche non registrate: salvare?"); + asked = TRUE; + } + if (save) + { + _lia->put("R0",r); + _lia->rewrite(); + if (look_lim(1)) + { + _lim->put("B0",""); + _lim->rewrite(); + } + } + } + + // check modifiche liquidazione + for (int i = 0; i < _liq_rows.items(); i++) + { + // compare sheet row with previous + TToken_string& tt = sh.row(i); + TToken_string& ot = (TToken_string&)_liq_rows[i]; + + real rmb1(tt.get(4)), rmb2(ot.get(4)), + rtt1(tt.get(5)), rtt2(ot.get(5)); + char deb1 = tt.get_char(6), deb2 = ot.get_char(6); + + bool modified = (rmb1 != rmb2 || rtt1 != rtt2 || deb1 != deb2); + + if (modified) + { + if (!asked && !save) + { + save = yesno_box("Modifiche non registrate: salvare?"); + asked = TRUE; + } + if (save) + { + int month = i + 1; + if (sh.items() == 4) month *= 3; + look_lim(month); + _lim->put("R1", rmb1); + if (deb1 == 'C') rtt1 = -rtt1; + _lim->put("R5", rtt1); + _lim->put("S7", deb1); + _lim->put("B0", ""); + _lim->rewrite(); + } + } + } + // check modifiche versamenti + for (i = 0; i < _vers_rows.items(); i++) + { + // compare sheet row with previous + TToken_string& tt = sv.row(i); + TToken_string& ot = (TToken_string&)_vers_rows[i]; + + TDate d1(tt.get(2)), d2(ot.get(2)); + TString abi1(tt.get(3)), abi2(ot.get(3)), + cab1(tt.get(4)), cab2(ot.get(4)), + con1(tt.get(5)), con2(ot.get(5)); + real imp1(tt.get(6)), imp2(ot.get(6)); + + bool modified = (d1 != d2 || abi1 != abi2 || + cab1 != cab2 || con1 != con2 || + imp1 != imp2); + + if (modified) + { + if (!asked && !save) + { + save = yesno_box("Modifiche non registrate: salvare?"); + asked = TRUE; + } + if (save) + { + int mult = sv.items() == 4 ? 3 : 1; + int month = 12; + if (i < 11) month = (i+1) * mult; + int type = i == 11 ? 7 : 1; + look_del(month, type, TRUE); + + _del->put("D0", d1); + _del->put("S7", abi1); + _del->put("S8", cab1); + _del->put("S9", con1); + _del->put("R0", imp1); + _del->put("R1", ""); // azzeriamo l'eventuale interesse + _del->rewrite(); + } + } + } + + } + + _mask = NULL; + return TRUE; } @@ -661,6 +778,7 @@ bool Visliq_app::vis_one(int m) _lim->put("R5", n_rettifica); _lim->put("S7", msk.get(F_DEBCRE)); + _lim->put("R0", risultato); set_risultato(vsw, lvers, risultato); @@ -680,6 +798,7 @@ bool Visliq_app::vis_one(int m) risc -= acconto; risc += n_acconto; _lia->put("R4", n_acconto); + _lim->put("R0", risultato); vsw->replace(lrisc, risc.string("###.###.###.###"), 58); set_risultato(vsw, lvers, risultato); } @@ -694,6 +813,7 @@ bool Visliq_app::vis_one(int m) risd -= rimborso; risd += n_rimborso; _lim->put("R1", n_rimborso); + _lim->put("R0", risultato); vsw->replace(lrisd, risd.string("###.###.###.###"), 75); set_risultato(vsw, lvers, risultato); } diff --git a/cg/cg5500.h b/cg/cg5500.h index b8bdb8438..466ff81aa 100755 --- a/cg/cg5500.h +++ b/cg/cg5500.h @@ -1,10 +1,11 @@ #include #include -#include +#include + +class TSheet_field; class Visliq_app : public TApplication { - TString _freqviva; int _year; long _firm; @@ -26,6 +27,9 @@ class Visliq_app : public TApplication TRecfield* _lim_anno; TRecfield* _lim_mese; + TSheet_field* _vers_sheet, *_liq_sheet; + TArray _vers_rows, _liq_rows; + TMask* _mask; const char* itoname(int m); @@ -63,7 +67,7 @@ public: bool look_lia(int year = 0); bool look_lim(int m); - bool look_del(int month, int type); + bool look_del(int month, int type, bool create = FALSE); void set_freqviva(); void set_freqviva(const char* f) { _freqviva = f; } @@ -72,6 +76,7 @@ public: void set_year(int y) { _year = y; } void reset_fields(); + // 2 palle TMask* get_main_mask() { return _mask; } void update_sheet_row(TToken_string& t); diff --git a/cg/cg5500b.uml b/cg/cg5500b.uml index 98756a0c7..67dd100f5 100755 --- a/cg/cg5500b.uml +++ b/cg/cg5500b.uml @@ -2,14 +2,20 @@ TOOLBAR "" 0 20 0 2 +BUTTON DLG_SAVEREC 8 2 +BEGIN +PROMPT -13 -1 "~Registra" +MESSAGE EXIT,K_SAVE +END + BUTTON DLG_CANCEL 8 2 BEGIN -PROMPT -12 -1 "" +PROMPT -23 -1 "" END BUTTON DLG_QUIT 8 2 BEGIN -PROMPT -22 -1 "" +PROMPT -33 -1 "" MESSAGE EXIT,K_QUIT END @@ -42,7 +48,8 @@ END NUMBER F_CREDPREC 15 BEGIN PROMPT 1 5 "Credito inizio anno " - FLAGS "D" + FLAGS "R" + PICTURE "." END SPREADSHEET F_VISLIQ1 0 11 @@ -88,7 +95,7 @@ BEGIN ITEM "Dipend.@5" ITEM "Concess.@5" ITEM "Versamenti@15" - ITEM "D/C" +// ITEM "D/C" END ENDPAGE @@ -99,12 +106,15 @@ PAGE "Prospetto mensile" -1 -1 50 10 STRING 102 20 BEGIN PROMPT 1 2 "Mese " + FLAGS "D" END NUMBER 103 15 0 BEGIN PROMPT 1 3 "Risultato " + FLAGS "DR" + PICTURE "." END LIST 104 1 8 @@ -113,17 +123,22 @@ BEGIN ITEM "D|Debito" ITEM "C|Credito" INPUT 105 - OUTPUT 105 + OUTPUT 105 + FLAGS "D" END NUMBER 105 15 BEGIN PROMPT 22 5 "IVA a rimborso " + FLAGS "R" + PICTURE "." END NUMBER 106 15 BEGIN PROMPT 22 6 "Debito/Credito " + FLAGS "R" + PICTURE "." END LIST 107 1 8 @@ -137,12 +152,17 @@ END BUTTON DLG_OK 10 2 BEGIN - PROMPT -12 -1 "" + PROMPT -13 -1 "" +END + +BUTTON DLG_CANCEL 10 2 +BEGIN + PROMPT -23 -1 "" END BUTTON 101 10 2 BEGIN - PROMPT -22 -1 "Calcola" + PROMPT -33 -1 "Dettaglio" END ENDPAGE @@ -150,10 +170,10 @@ ENDMASK PAGE "Prospetto versamenti" -1 -1 50 12 - STRING 102 20 BEGIN PROMPT 1 2 "Mese " + FLAGS "D" END DATE 103 @@ -161,26 +181,53 @@ BEGIN PROMPT 1 5 "Data " END -STRING 104 5 +NUMBER 104 5 BEGIN - PROMPT 1 6 "Azienda " -END - -STRING 105 5 -BEGIN - PROMPT 1 7 "Dipendenza " + PROMPT 4 8 "Codice ABI " + HELP "Codice ABI banca di appoggio" + FIELD S7 + FLAGS "RZ" + USE %BAN + INPUT CODTAB[1,5] 104 + INPUT CODTAB[6,10] 105 + DISPLAY "Codice ABI" CODTAB[1,5] + DISPLAY "Codice CAB" CODTAB[6,10] + DISPLAY "Descrizione @50" S0 + OUTPUT 104 CODTAB[1,5] + OUTPUT 105 CODTAB[6,10] + CHECKTYPE NORMAL END -STRING 106 5 + +NUMBER 105 5 BEGIN - PROMPT 1 8 "Concessionaria " + PROMPT 40 8 "Codice CAB " + HELP "Codice CAB banca di appoggio" + FIELD S8 + FLAGS "RZ" + COPY ALL 104 + CHECKTYPE NORMAL + WARNING "Banca assente" END + +NUMBER 106 3 +BEGIN + PROMPT 4 9 "Concessione " + HELP "Codice Concessione del Comune di residenza fiscale" +// FIELD S9 + FLAGS "RZ" +END + + NUMBER 107 15 0 BEGIN PROMPT 1 4 "Versamenti " + FLAGS "R" + PICTURE "." END +/* LIST 108 1 8 BEGIN PROMPT 1 9 "Importo a " @@ -189,15 +236,21 @@ BEGIN INPUT 105 OUTPUT 105 END - +*/ + BUTTON DLG_OK 10 2 BEGIN - PROMPT -12 -1 "" + PROMPT -13 -1 "" +END + +BUTTON DLG_CANCEL 10 2 +BEGIN + PROMPT -23 -1 "" END BUTTON 101 10 2 BEGIN - PROMPT -22 -1 "Calcola" + PROMPT -33 -1 "Dettaglio" END ENDPAGE diff --git a/cg/cg5500c.uml b/cg/cg5500c.uml index fa902d99a..292a7904c 100755 --- a/cg/cg5500c.uml +++ b/cg/cg5500c.uml @@ -2,14 +2,20 @@ TOOLBAR "" 0 20 0 2 +BUTTON DLG_SAVEREC 8 2 +BEGIN +PROMPT -13 -1 "~Registra" +MESSAGE EXIT,K_SAVE +END + BUTTON DLG_CANCEL 8 2 BEGIN -PROMPT -12 -1 "" +PROMPT -23 -1 "" END BUTTON DLG_QUIT 8 2 BEGIN -PROMPT -22 -1 "" +PROMPT -33 -1 "" MESSAGE EXIT,K_QUIT END @@ -41,12 +47,13 @@ END NUMBER F_CREDPREC 15 BEGIN PROMPT 1 4 "Credito inizio anno " - FLAGS "D" + FLAGS "R" + PICTURE "." END SPREADSHEET F_VISLIQ1 0 5 BEGIN - PROMPT 1 6 "Liquidazione" + PROMPT 1 7 "Liquidazione" ITEM "V@1F#109" ITEM "Mese@10" ITEM "Risultato@15" @@ -66,7 +73,7 @@ BEGIN ITEM "Dipend.@5" ITEM "Concess.@5" ITEM "Versamenti@15" - ITEM "D/C" +// ITEM "D/C" END ENDPAGE @@ -77,12 +84,15 @@ PAGE "Prospetto mensile" -1 -1 50 10 STRING 102 20 BEGIN PROMPT 1 2 "Mese " + FLAGS "D" END NUMBER 103 15 0 BEGIN PROMPT 1 3 "Risultato " + FLAGS "DR" + PICTURE "." END LIST 104 1 8 @@ -91,17 +101,22 @@ BEGIN ITEM "D|Debito" ITEM "C|Credito" INPUT 105 - OUTPUT 105 + OUTPUT 105 + FLAGS "D" END NUMBER 105 15 BEGIN PROMPT 22 5 "IVA a rimborso " + FLAGS "R" + PICTURE "." END NUMBER 106 15 BEGIN PROMPT 22 6 "Debito/Credito " + FLAGS "R" + PICTURE "." END LIST 107 1 8 @@ -112,76 +127,109 @@ BEGIN INPUT 105 OUTPUT 105 END - + BUTTON DLG_OK 10 2 -BEGIN - PROMPT -12 -1 "" -END - -BUTTON 101 10 2 -BEGIN - PROMPT -22 -1 "Calcola" -END - -ENDPAGE -ENDMASK - -PAGE "Prospetto versamenti" -1 -1 50 12 - -STRING 102 20 -BEGIN - PROMPT 1 2 "Mese " -END - -DATE 103 -BEGIN - PROMPT 1 3 "Data " -END - -STRING 104 5 -BEGIN - PROMPT 1 4 "Azienda " -END - -STRING 105 5 -BEGIN - PROMPT 1 5 "Dipendenza " -END - -STRING 106 5 -BEGIN - PROMPT 1 6 "Concessionaria " -END - -NUMBER 107 15 0 -BEGIN - PROMPT 1 7 "Versamenti " -END - -LIST 108 1 8 -BEGIN - PROMPT 1 8 "Importo a " - ITEM "D|Debito" - ITEM "C|Credito" - INPUT 105 - OUTPUT 105 -END - -BUTTON DLG_CANCEL 10 2 BEGIN PROMPT -13 -1 "" END -BUTTON DLG_OK 10 2 +BUTTON DLG_CANCEL 10 2 BEGIN PROMPT -23 -1 "" END BUTTON 101 10 2 BEGIN - PROMPT -33 -1 "Calcola" + PROMPT -33 -1 "Dettaglio" END +ENDPAGE +ENDMASK + +PAGE "Prospetto versamenti" -1 -1 50 12 + +STRING 102 20 +BEGIN + PROMPT 1 2 "Mese " + FLAGS "D" +END + +DATE 103 +BEGIN + PROMPT 1 5 "Data " +END + +NUMBER 104 5 +BEGIN + PROMPT 4 8 "Codice ABI " + HELP "Codice ABI banca di appoggio" + FIELD S7 + FLAGS "RZ" + USE %BAN + INPUT CODTAB[1,5] 104 + INPUT CODTAB[6,10] 105 + DISPLAY "Codice ABI" CODTAB[1,5] + DISPLAY "Codice CAB" CODTAB[6,10] + DISPLAY "Descrizione @50" S0 + OUTPUT 104 CODTAB[1,5] + OUTPUT 105 CODTAB[6,10] + CHECKTYPE NORMAL +END + + +NUMBER 105 5 +BEGIN + PROMPT 40 8 "Codice CAB " + HELP "Codice CAB banca di appoggio" + FIELD S8 + FLAGS "RZ" + COPY ALL 104 + CHECKTYPE NORMAL + WARNING "Banca assente" +END + + +NUMBER 106 3 +BEGIN + PROMPT 4 9 "Concessione " + HELP "Codice Concessione del Comune di residenza fiscale" +// FIELD S9 + FLAGS "RZ" +END + + +NUMBER 107 15 0 +BEGIN + PROMPT 1 4 "Versamenti " + FLAGS "R" + PICTURE "." +END + +/* +LIST 108 1 8 +BEGIN + PROMPT 1 9 "Importo a " + ITEM "D|Debito" + ITEM "C|Credito" + INPUT 105 + OUTPUT 105 +END +*/ + +BUTTON DLG_OK 10 2 +BEGIN + PROMPT -13 -1 "" +END + +BUTTON DLG_CANCEL 10 2 +BEGIN + PROMPT -23 -1 "" +END + +BUTTON 101 10 2 +BEGIN + PROMPT -33 -1 "Dettaglio" +END ENDPAGE diff --git a/cg/cg5501.cpp b/cg/cg5501.cpp index f40b6a498..92bd9fc26 100755 --- a/cg/cg5501.cpp +++ b/cg/cg5501.cpp @@ -13,18 +13,26 @@ bool Visliq_app::look_lim(int m) return _lim->good(); } -bool Visliq_app::look_del(int month, int type) +bool Visliq_app::look_del(int month, int type, bool create) { - long ditta = get_firm(); - _del->zero(); - (*_del_ditta) = format("%ld",ditta); - (*_del_anno) = format("%d",_year); - (*_del_mese) = format("%d",month); - (*_del_tipo) = format("%d",type); + (*_del_ditta) = format("%05ld", get_firm()); + (*_del_anno) = _year; + (*_del_mese) = format("%02d", month); + (*_del_tipo) = format("%1d", type); + + TString16 ctab = _del->get("CODTAB"); _del->read(); - return _del->good(); + bool ok = _del->good(); + + if (!ok && create) + { + _del->zero(); + _del->put("CODTAB",ctab); + _del->write(); + } + return ok; } bool Visliq_app::look_lia(int year)