diff --git a/cg/cg2101.cpp b/cg/cg2101.cpp index 610f9fa5f..8607b9b2e 100755 --- a/cg/cg2101.cpp +++ b/cg/cg2101.cpp @@ -11,6 +11,7 @@ #include #include #include +#include // Calcola l'anno di esercizio di una data // Certified 99% diff --git a/cg/cg4300.cpp b/cg/cg4300.cpp index 2ed039e8f..08fb764ac 100755 --- a/cg/cg4300.cpp +++ b/cg/cg4300.cpp @@ -178,8 +178,9 @@ bool TLiquidazione_app::user_create() _lam_mese = new TRecfield(*_lam_r,"CODTAB",4,6); _rmb_anno = new TRecfield(*_rmb_r,"CODTAB",0,3); - _rmb_mese = new TRecfield(*_rmb_r,"CODTAB",4,6); - _rmb_codiva = new TRecfield(*_rmb_r,"CODTAB",7,10); + _rmb_mese = new TRecfield(*_rmb_r,"CODTAB",4,5); + _rmb_codiva = new TRecfield(*_rmb_r,"CODTAB",6,9); + _rmb_tiporeg = new TRecfield(*_rmb_r,"CODTAB",10,10); __firm = TApplication::get_firm(); @@ -431,8 +432,7 @@ void TLiquidazione_app::build_nomiditte(TProgind* pnd) if (good) { // check no parametri liquidazione - TApplication::set_firm(dt.get_long("CODDITTA")); - if (!look_lia()) good = FALSE; + if (!look_lia(dt.get_long("CODDITTA"))) good = FALSE; } TToken_string* d = new TToken_string(64); @@ -446,7 +446,6 @@ void TLiquidazione_app::build_nomiditte(TProgind* pnd) _nomiditte.add(d); } if (pnd) pnd->addstatus(1); - TApplication::set_firm(__firm); } bool TLiquidazione_app::to_ditt_handler(TMask_field& f, KEY key) diff --git a/cg/cg4300.h b/cg/cg4300.h index 6aef84137..3c884773d 100755 --- a/cg/cg4300.h +++ b/cg/cg4300.h @@ -424,7 +424,7 @@ public: bool look_del(int month, int type, bool create = FALSE); bool look_iva(const char* cod); bool look_reg(const char* reg); - bool look_lia(bool create = FALSE, int anno = 0); + bool look_lia(long ditta = 0l, bool create = FALSE, int anno = 0); bool look_rmb(int month, const char* codiva, tiporeg tr, bool create); _VendItem* look_vendita(int m, const char* codreg); diff --git a/cg/cg4301.cpp b/cg/cg4301.cpp index 18c055930..67dfdab72 100755 --- a/cg/cg4301.cpp +++ b/cg/cg4301.cpp @@ -570,7 +570,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) ok = (tipocr == 0 || tipocr == 1 || tipocr == 5); if (tipomov == vendita && !ok) - ok = !tipoiva.empty() && tipodoc != "CR" && + ok = tipoiva.empty() && tipodoc != "CR" && tipodoc != "SC" && tipodoc != "RF"; if (ok) @@ -837,7 +837,13 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) _pim_r->put("R5",ifs); _pim_r->put("R6",vfs); _pim_r->put("R7",adf); - _pim_r->put("R8",adi); + _pim_r->put("R8",adi); + + // questi servono per i ricalcoli altrui (classify_pim) + _pim_r->put("I1", (long)tipomov); + _pim_r->put("B3", ivarimb ? "X" : ""); + _pim_r->put("B4", _isricacq ? "X" : ""); + _pim_r->put("S5", tipoiva); _pim->rewrite(); } while (_cur->next_match(LF_RMOVIVA)); diff --git a/cg/cg4302.cpp b/cg/cg4302.cpp index 5f17a9998..ebb74252d 100755 --- a/cg/cg4302.cpp +++ b/cg/cg4302.cpp @@ -452,10 +452,11 @@ bool TLiquidazione_app::look_del(int month, int type, bool create) return ok; } -bool TLiquidazione_app::look_lia(bool create, int year) +bool TLiquidazione_app::look_lia(long ditta, bool create, int year) { - if (year == 0) year = atoi(_year); - TString16 y; y.format("%05ld%04d", get_firm(), year); + if (year == 0) year = atoi(_year); + if (ditta == 0l) ditta = get_firm(); + TString16 y; y.format("%05ld%04d", ditta, year); _lia->zero(); _lia->put("CODTAB", y); diff --git a/cg/cg4303.cpp b/cg/cg4303.cpp index fab67434f..d78ead7fe 100755 --- a/cg/cg4303.cpp +++ b/cg/cg4303.cpp @@ -309,10 +309,12 @@ _DescrItem* TLiquidazione_app::recalc_rimborso(int month, const char* codatts) // scorri i bellissimi progressivi mensili rimborso for (_rmb->first(); !_rmb->eof(); _rmb->next()) - { - if (_year != (const char*)_rmb_anno || - ( atoi((const char*)_rmb_mese) < month -2 || - atoi((const char*)_rmb_mese) > month)) + { + int year = atoi((const char*)_year); + int ryear = atoi((const char*)(*_rmb_anno)); + int rmese = atoi((const char*)(*_rmb_mese)); + + if (year != ryear || (rmese < (month - 2) || rmese > month)) continue; real imp = _rmb->get("R0"); @@ -324,7 +326,7 @@ _DescrItem* TLiquidazione_app::recalc_rimborso(int month, const char* codatts) rb->_iva = iva; rb->_perc = per; - TArray& arr = (tiporeg)atoi((const char*)_rmb_tiporeg) == vendita ? varr : aarr; + TArray& arr = (tiporeg)atoi((const char*)(*_rmb_tiporeg)) == vendita ? varr : aarr; for (int i = 0; i < arr.items(); i++) { @@ -335,7 +337,7 @@ _DescrItem* TLiquidazione_app::recalc_rimborso(int month, const char* codatts) arr.insert(rb, i); // totali imponibili - if ((tiporeg)atoi((const char*)_rmb_tiporeg) == vendita) + if ((tiporeg)atoi((const char*)(*_rmb_tiporeg)) == vendita) vtot += imp; else atot += imp; diff --git a/cg/cg5300.cpp b/cg/cg5300.cpp index efdaa57bc..4f5fc82e9 100755 --- a/cg/cg5300.cpp +++ b/cg/cg5300.cpp @@ -36,7 +36,6 @@ protected: virtual bool user_create(); virtual bool user_destroy(); - virtual void on_firm_change(); // minchia di cristo virtual TRelation* get_relation() const { return _rel; } @@ -53,7 +52,9 @@ protected: // creati automaticamente virtual int write(const TMask& m) { return rewrite(m);} virtual int read(TMask& m); - + + void init_array(TMask& m); + // notifier static bool sheet_action(int r, KEY k); @@ -119,9 +120,9 @@ void TParaliq_app::check_registers(int year) } -void TParaliq_app::on_firm_change() +void TParaliq_app::init_array(TMask& m) { - const long newditta = get_firm(); + const long newditta = m.get_long(F_CODDITTA); if (newditta != _lastditta) { @@ -146,7 +147,7 @@ void TParaliq_app::on_firm_change() _freqiva = _ditte->get(NDT_FREQVIVA); else _freqiva = ""; - } + } } bool TParaliq_app::user_create() @@ -191,7 +192,9 @@ void TParaliq_app::init_insert_mode(TMask& m) { TSheet_field& sf = (TSheet_field&)m.field(F_SHEET_PLA); TToken_string tt(60); - + + init_array(m); + m.set(F_FREQ_VERS, _freqiva); for (int i = 0; i < _atts.items(); i++) @@ -210,7 +213,7 @@ void TParaliq_app::init_insert_mode(TMask& m) sf.row(-1) = tt; } } - + int TParaliq_app::rewrite(const TMask& m) { // scrive %LIA @@ -309,35 +312,27 @@ int TParaliq_app::read(TMask& m) m.autoload(get_relation()); TSheet_field& sf = (TSheet_field&)m.field(F_SHEET_PLA); TToken_string tt(60); - const long firm = get_firm(); - const int year = m.get_int(F_YEAR); + const long firm = m.get_long(F_CODDITTA); + const int year = m.get_int(F_YEAR); sf.reset(); - for (int i = 0; i < _atts.items(); i++) + const TString16 ctab = format("%05ld%d", firm, year); + _pla->zero(); + _pla->put("CODTAB", ctab); + + for (int err = _pla->read(_isgteq); err == NOERR; _pla->next()) { - TString& att = (TString&)_atts[i]; - - // cerca l'attivita' in pla - _pla->zero(); - _pla->put("CODTAB", format("%05ld%d%s1", firm, year, (const char *) att)); - tt = ""; - tt.add(att); - if (_pla->read() == NOERR) + if (ctab == _pla->get("CODTAB").left(9)) { + tt = ""; + tt.add(ctab.mid(9,5)); tt.add(_pla->get("S7")); // tipo attivita' tt.add(_pla->get("R8")); // prorata tt.add(_pla->get("R5")); // plafond art. 8 tt.add(_pla->get("R6")); // plafond art. 8bis tt.add(_pla->get("R7")); // plafond art. 9 } - else - { - tt.add(""); - tt.add(""); - tt.add(""); - tt.add(""); - tt.add(""); - } + else break; sf.row(-1) = tt; } diff --git a/cg/cg5300a.uml b/cg/cg5300a.uml index 7bed7c4bc..45956351a 100755 --- a/cg/cg5300a.uml +++ b/cg/cg5300a.uml @@ -37,7 +37,8 @@ BEGIN DISPLAY "Ragione Sociale@50" RAGSOC DISPLAY "Codice" CODDITTA COPY OUTPUT F_CODDITTA - CHECKTYPE REQUIRED + CHECKTYPE REQUIRED + KEY 2 END NUMBER F_YEAR 4 diff --git a/cg/cg5500.cpp b/cg/cg5500.cpp index a443b7d7b..df5837b07 100755 --- a/cg/cg5500.cpp +++ b/cg/cg5500.cpp @@ -67,7 +67,7 @@ bool Visliq_app::create() "Cod.@5|Ragione Sociale@50|Vers."); _del = new TTable("%DEL"); - _lia = new TTable("LIA"); + _lia = new TTable("%LIA"); _lim = new TTable("LIM"); _del_r = &(_del->curr()); _lim_r = &(_lim->curr()); @@ -147,6 +147,7 @@ void Visliq_app::build_nomiditte() // ricostruire _nomiditte e rifare build_ditte_sheet TLocalisamfile& dt = _nditte->lfile(); TString fr(2); + TTable lia("%LIA"); for (dt.first(); !dt.eof(); dt.next()) { @@ -157,9 +158,7 @@ void Visliq_app::build_nomiditte() if (good) { // check no parametri liquidazione - TApplication::set_firm(dt.get_long("CODDITTA")); - TTable lia("LIA"); - lia.put("CODTAB", format("%d",_year)); + lia.put("CODTAB", format("%05ld%d",dt.get_long("CODDITTA"),_year)); if (lia.read() != NOERR) good = FALSE; else fr = lia.get("S7"); } @@ -173,7 +172,6 @@ void Visliq_app::build_nomiditte() _nomiditte.add(d); } - TApplication::set_firm(_firm); } diff --git a/cg/cg5500.h b/cg/cg5500.h index 466ff81aa..f35285a42 100755 --- a/cg/cg5500.h +++ b/cg/cg5500.h @@ -65,7 +65,7 @@ public: void build_ditte_sheet(); void build_nomiditte(); - bool look_lia(int year = 0); + bool look_lia(long ditta = 0l, int year = 0); bool look_lim(int m); bool look_del(int month, int type, bool create = FALSE); diff --git a/cg/cg5501.cpp b/cg/cg5501.cpp index 92bd9fc26..4ded0dbe5 100755 --- a/cg/cg5501.cpp +++ b/cg/cg5501.cpp @@ -35,10 +35,11 @@ bool Visliq_app::look_del(int month, int type, bool create) return ok; } -bool Visliq_app::look_lia(int year) +bool Visliq_app::look_lia(long ditta, int year) { - if (year == 0) year = _year; - TString16 y; y << year; + if (year == 0) year = _year; + if (ditta == 0l) ditta = get_firm(); + TString16 y; y << format("%05ld", ditta); y << year; _lia->zero(); _lia->put("CODTAB", y);