diff --git a/tc/tc1.cpp b/tc/tc1.cpp index 744ceb179..53e9d1957 100755 --- a/tc/tc1.cpp +++ b/tc/tc1.cpp @@ -13,7 +13,6 @@ int main(int argc, char** argv) case 1: tc1200(argc,argv); break; // Tabelle default: tc1100(argc,argv); break; // trasferimento zucchetti } - exit(0); return 0; } diff --git a/tc/tc2.cpp b/tc/tc2.cpp index 6c475caed..ba8af2a9a 100755 --- a/tc/tc2.cpp +++ b/tc/tc2.cpp @@ -13,7 +13,6 @@ int main(int argc, char** argv) case 7: tc2800(argc,argv); break; // Riclassificazione conti TeamSystem default: ; tc2100(argc,argv); break; } - exit(0); return 0; } diff --git a/tc/tc9200.cpp b/tc/tc9200.cpp index 6080a77d6..b029be52a 100755 --- a/tc/tc9200.cpp +++ b/tc/tc9200.cpp @@ -50,7 +50,7 @@ bool TInvioW_mask::on_field_event(TOperable_field& o, TField_event e, long jolly if (e==fe_init && o.empty()) { set(F_CODDITTA, main_app().get_firm()); - ((TEdit_field&) o).check(); + ((TEdit_field&)o).check(); disable(F_CODDITTA); } break; diff --git a/tc/tc9300.cpp b/tc/tc9300.cpp index 7c19f543c..d27979896 100755 --- a/tc/tc9300.cpp +++ b/tc/tc9300.cpp @@ -22,7 +22,9 @@ #include #include #include + #include "../ca/rip.h" +#include "../ca/rrip.h" #define SLF_MOV "23" #define ALIAS_REG 100 @@ -36,17 +38,19 @@ class TRiclassifica_cache : public TCache { TLocalisamfile _multirel; + protected: virtual TObject* key2obj(const char* key); + public: const char * sdecode(const char* tab, const TString& cod); long decode(const char* tab, const TString& cod); - const TString & sdecode_caufor(const TString& cod); - const TString & sdecode_caureg(const TString& cod); - const TString & sdecode_caugiro(const TString& cod); - const TString & sdecode_contov(const TString& cod); - const TString & sdecode_caucon(const TString& cod); - const TString & sdecode_sezcon(const TString& cod); + const TString& sdecode_caufor(const TString& cod); + const TString& sdecode_caureg(const TString& cod); + const TString& sdecode_caugiro(const TString& cod); + const TString& sdecode_contov(const TString& cod); + const TString& sdecode_caucon(const TString& cod); + const TString& sdecode_sezcon(const TString& cod); bool sdecode_rc(const TString& cod); TRiclassifica_cache() : _multirel(LF_MULTIREL) { _multirel.setkey(2);} }; @@ -63,7 +67,7 @@ TObject* TRiclassifica_cache::key2obj(const char* key) _multirel.put(MULTI_SECOND, ""); int err = _multirel.read(_isgteq); if (err == NOERR && _multirel.get(MULTI_FIRST) == cod) - return new TString(_multirel.get(MULTI_SECOND)); + return _multirel.get(MULTI_SECOND).dup(); return NULL; } @@ -232,6 +236,69 @@ const char * TRiclassifica_cache::sdecode(const char* tab, const TString& cod) return ric ? (const char *) *ric : ""; } +/////////////////////////////////////////////////////////// +// TRip_cache +/////////////////////////////////////////////////////////// + +class TRip_cache : public TCache +{ + TLocalisamfile _rip, _rrip; + +protected: + virtual TObject* key2obj(const char* key); + +public: + bool cdc(int gruppo, int conto, long sottoconto, TString& cdc, TString& cms); + + TRip_cache() : _rip(LF_RIP), _rrip(LF_RRIP) { _rip.setkey(3); } +}; + +TObject* TRip_cache::key2obj(const char* key) +{ + TToken_string* tok = new TToken_string(key); + + const int g = tok->get_int(); + const int c = tok->get_int(); + const long s = tok->get_long(); + + tok->cut(0); + + _rip.zero(); + _rip.put(RIP_TIPO, "I"); + _rip.put(RIP_GRUPPO, g); + _rip.put(RIP_CONTO, c); + _rip.put(RIP_SOTTOCONTO, s); + if (_rip.read(_isgteq) == NOERR && _rip.get_int(RIP_GRUPPO)==g && _rip.get_int(RIP_CONTO)==c && _rip.get_long(RIP_SOTTOCONTO)==s) + { + _rrip.zero(); + _rrip.put(RRIP_TIPO, _rip.get(RIP_TIPO)); + _rrip.put(RRIP_CODICE, _rip.get(RIP_CODICE)); + _rrip.put(RRIP_NRIGA, 1); + + if (_rrip.read() == NOERR) + { + tok->add(_rrip.get(RRIP_CODFASE), 0); // CDC contabile + tok->add(_rrip.get(RRIP_CODCMS), 1); // CDC analitico + } + } + + return tok; +} + +bool TRip_cache::cdc(int gruppo, int conto, long sottoconto, TString& cdc, TString& cms) +{ + TString16 gcs; gcs.format("%d|%d|%d", gruppo, conto, sottoconto); + const TToken_string* tok = (const TToken_string*)objptr(gcs); + if (tok && tok->full()) + { + tok->get(0, cdc); + tok->get(1, cms); + } + else + cdc = cms = ""; + return cms.full(); +} + /////////////////////////////////////////////////////////// // TSISPAC_set /////////////////////////////////////////////////////////// @@ -659,6 +726,8 @@ protected: void invio_sispac(); void sispac_cli(); void sispac_for(); + const TString& bill2code(const TISAM_recordset& input) const; + void sispac_reverse_movim(long numreg, TMovim_set & recset, long firstmov, long lastmov, const TString & cofi, const TString & paiv, const TString & ragsoc, const TString & esiva, @@ -667,6 +736,7 @@ protected: const TString & cofi, const TString & paiv, const TString & ragsoc, const TString & esiva, const TString & annoes, bool comp); + void fill_last_cdc(const TString& cdc, TMovim_set& recset) const; void sispac_movim(); void sispac_reverse_moviva(long numreg, TIvamov_set & recset, const TString & cofi, const TString & paiv, const TString & ragsoc); @@ -716,51 +786,41 @@ const TString & TInvioSispac::scod2caucf(const TString& cod) const TString & TInvioSispac::scod2caureg(const TString& cod) { - TString & codricl = get_tmp_string(); - if (cod.full()) - codricl = _tabelle->sdecode_caureg(cod); - return codricl; + return _tabelle->sdecode_caureg(cod); + return EMPTY_STRING; } const TString & TInvioSispac::scod2caugiro(const TString& cod) { - TString & codricl = get_tmp_string(); - if (cod.full()) - codricl = _tabelle->sdecode_caugiro(cod); - return codricl; + return _tabelle->sdecode_caugiro(cod); + return EMPTY_STRING; } const TString & TInvioSispac::scod2caucon(const TString& cod) { - TString& codricl = get_tmp_string(); if (cod.full()) - codricl = _tabelle->sdecode_caucon(cod); - return codricl; + return _tabelle->sdecode_caucon(cod); + return EMPTY_STRING; } const TString & TInvioSispac::scod2sezcon(const TString& cod) { - TString& codricl = get_tmp_string(); if (cod.full()) - codricl = _tabelle->sdecode_sezcon(cod); - return codricl; + return _tabelle->sdecode_sezcon(cod); + return EMPTY_STRING; } const TString & TInvioSispac::scod2contov(const TString& cod) { - TString & codricl = get_tmp_string(); - if (cod.full()) - codricl = _tabelle->sdecode_contov(cod); - return codricl; + return _tabelle->sdecode_contov(cod); + return EMPTY_STRING; } bool TInvioSispac::scod2rc(const TString& cod) { - TString & codricl = get_tmp_string(); - if (cod.full()) return _tabelle->sdecode_rc(cod); return false; @@ -917,6 +977,23 @@ void TInvioSispac::sispac_for() recset.save_as(outputname); } +const TString& TInvioSispac::bill2code(const TISAM_recordset& input) const +{ + const char tipocf = input.get(RMV_TIPOC).as_string()[0]; + const long sottoconto = input.get(RMV_SOTTOCONTO).as_int(); + const int conto = input.get(RMV_CONTO).as_int(); + int gruppo = input.get(RMV_GRUPPO).as_int(); + if (gruppo >= 10) + gruppo = 0; + + TString& codice = get_tmp_string(); + if (tipocf > 0) + codice.format("%01d%02d001%06ld", gruppo, conto, sottoconto); + else + codice.format("%01d%02d%03ld ", gruppo, conto, sottoconto); + return codice; +} + void TInvioSispac::sispac_reverse_movim(long numreg, TMovim_set & recset, long firstmov, long lastmov, const TString & cofi, const TString & paiv, const TString & ragsoc, const TString & esiva, @@ -958,42 +1035,31 @@ void TInvioSispac::sispac_reverse_movim(long numreg, TMovim_set & recset, long f var = "V"; treg = "03"; recset.set("ARGOMENTO", var); - var = "N"; - const TDate datareg(input.get(SLF_MOV "." MOV_DATAREG).as_date()); - - if (comp) - var = "1"; + var = comp ? "1" : "N"; recset.set("COMPETENZA", var); - var = format("%07ld", input.get(RMV_NUMREG).as_int() + REG_OFFSET); + + var = format("%07ld", input.get(RMV_NUMREG).as_int() + REG_OFFSET); recset.set("NUMPART", var); var = format("%03ld", input.get(RMV_NUMRIG).as_int()); recset.set("NUMINT", var); + const TDate datareg(input.get(SLF_MOV "." MOV_DATAREG).as_date()); recset.set("DATAOP", datareg.string(brief, '\0', full, full, amg_date)); + const TString8 ccaus(input.get(SLF_MOV "." MOV_CODCAUS).as_string()); + TString16 codice; - long gruppo = input.get(RMV_GRUPPO).as_int(); - const long conto = input.get(RMV_CONTO).as_int(); - const long sottoconto = input.get(RMV_SOTTOCONTO).as_int(); - TString8 ccaus(input.get(SLF_MOV "." MOV_CODCAUS).as_string()); - - if (gruppo == 10) - gruppo = 0; - if (rowtype == "I") // verificare codice = scod2contov(ccaus); else - if (input.get(RMV_TIPOC).as_string().full()) - codice.format("%01ld%02ld000%06ld", gruppo, conto, sottoconto); - else - codice.format("%01ld%02ld%03ld000000", gruppo, conto, sottoconto); - var = codice; - recset.set("CODCONTO", var); - recset.set("TIPOREG", treg); + codice = bill2code(input); + recset.set("CODCONTO", codice); + + recset.set("TIPOREG", treg); recset.set("CODREG", TVariant("01")); // in futuro campo su registro const long prot = input.get(SLF_MOV "." MOV_PROTIVA).as_int(); var = format("%07ld", prot); recset.set("NUMPROT", var); - const real * v = (real *) tipoart.objptr(lastmov - firstmov); // qui + const real* v = (real*)tipoart.objptr(lastmov - firstmov); // qui if (v != NULL) recset.set("TIPOART", *v); @@ -1112,28 +1178,18 @@ void TInvioSispac::sispac_reverse_giro(long numreg, TMovim_set & recset, long fi var = format("%03ld", input.get(RMV_NUMRIG).as_int()); recset.set("NUMINT", var); recset.set("DATAOP", datareg.string(brief, '\0', full, full, amg_date)); - TString16 codice; - long gruppo = input.get(RMV_GRUPPO).as_int(); - const long conto = input.get(RMV_CONTO).as_int(); - const long sottoconto = input.get(RMV_SOTTOCONTO).as_int(); - TString8 ccaus(input.get(SLF_MOV "." MOV_CODCAUS).as_string()); + const TString8 ccaus(input.get(SLF_MOV "." MOV_CODCAUS).as_string()); - if (gruppo == 10) - gruppo = 0; - + TString16 codice; if (rowtype == "I") // verificare codice = scod2contov(ccaus); else + { if (rowtype == "D" || rowtype == "N") // verificare codice = codice_cf; else - if (input.get(RMV_TIPOC).as_string().full()) - { - codice.format("%01ld%02ld000%06ld", gruppo, conto, sottoconto); - codice_cf = codice; - } - else - codice.format("%01ld%02ld%03ld000000", gruppo, conto, sottoconto); + codice = bill2code(input); + } var = codice; recset.set("CODCONTO", var); recset.set("TIPOREG", treg); @@ -1202,6 +1258,16 @@ void TInvioSispac::sispac_reverse_giro(long numreg, TMovim_set & recset, long fi } } +void TInvioSispac::fill_last_cdc(const TString& cdc, TMovim_set& recset) const +{ + for (bool ok = recset.move_last(); ok; ok = recset.move_prev()) + { + if (recset.get("CODCOST").as_int() == 0) + recset.set("CODCOST", cdc); + else + break; + } +} void TInvioSispac::sispac_movim() { @@ -1213,6 +1279,8 @@ void TInvioSispac::sispac_movim() TEsercizi_contabili esc; long numregrev = -1L; + TRip_cache rip; + key << prefix().get_codditta(); const TRectype & ditta = cache().get(LF_NDITTE, key); @@ -1275,7 +1343,7 @@ void TInvioSispac::sispac_movim() rdare++; else ravere++; - p.addstatus(1L);; + p.addstatus(1L); if (p.iscancelled()) break; } @@ -1296,6 +1364,10 @@ void TInvioSispac::sispac_movim() lastmov = 0; int nrow = 0; + + TString8 lastcdc; + real impcdc; + for (bool ok = input.move_first(); ok ; ok = input.move_next()) { const long codes = input.get(RMV_ANNOES).as_int(); @@ -1310,6 +1382,10 @@ void TInvioSispac::sispac_movim() { lastmov = numreg; nrow = 0; + if (lastcdc.full()) + fill_last_cdc(lastcdc, recset); + lastcdc.cut(0); + impcdc = ZERO; } if (numregrev < 0L && scod2rc(ccaus)) numregrev = numreg; @@ -1368,9 +1444,7 @@ void TInvioSispac::sispac_movim() } const TString4 tipomov = var.as_string(); recset.set("ARGOMENTO", var); - var = "N"; - if (comp) - var = "1"; + var = comp ? "1" : "N"; recset.set("COMPETENZA", var); var = format("%07ld", numreg); recset.set("NUMPART", var); @@ -1378,22 +1452,10 @@ void TInvioSispac::sispac_movim() recset.set("NUMINT", var); recset.set("DATAOP", datareg.string(brief, '\0', full, full, amg_date)); - const char tipocf = input.get(RMV_TIPOC).as_string()[0]; - long gruppo = input.get(RMV_GRUPPO).as_int(); - const long conto = input.get(RMV_CONTO).as_int(); - const long sottoconto = input.get(RMV_SOTTOCONTO).as_int(); - if (gruppo == 10) - gruppo = 0; - - TString16 codice; - if (tipocf >= 'C') - codice.format("%01ld%02ld000%06ld", gruppo, conto, sottoconto); - else - codice.format("%01ld%02ld%03ld000000", gruppo, conto, sottoconto); - var = codice; - recset.set("CODCONTO", var); + const TString16 codice = bill2code(input); + recset.set("CODCONTO", codice); recset.set("TIPOREG", treg); - recset.set("CODREG", TVariant("01")); // in futuro campo su registro + recset.set("CODREG", reg.right(2)); // in futuro campo su registro const long prot = input.get(SLF_MOV "." MOV_PROTIVA).as_int(); var = format("%07ld", prot); recset.set("NUMPROT", var); @@ -1407,6 +1469,7 @@ void TInvioSispac::sispac_movim() const TString8 codcauscon = scod2caucon(ccaus); const TString4 sezcon = scod2sezcon(ccaus); + const char tipocf = input.get(RMV_TIPOC).as_string()[0]; if (tipocf >= 'C') { if (codcauscf.full()) @@ -1416,16 +1479,14 @@ void TInvioSispac::sispac_movim() codcaus = codcauscon; } else + { if (sezcon == sezione && codcauscon.full()) codcaus = codcauscon; - var = "R"; - if (codcaus == "00255") - var = "S"; + } + var = (atoi(codcaus) == 255) ? "S" : "R"; // Come da tracciato recset.set("TIPOMOV", var); recset.set("CODCOST", TVariant("000")); - var = codcaus; - recset.set("CODCAUS", var); - + recset.set("CODCAUS", codcaus); recset.set("NUMDESC", TVariant("0")); real importo = input.get(RMV_IMPORTO).as_real(); @@ -1468,16 +1529,24 @@ void TInvioSispac::sispac_movim() if (tipocf <= ' ' && has_module(CMAUT, CHK_DONGLE) /*&& !has_module(CAAUT, CHK_DONGLE)*/) { - TLocalisamfile rip(LF_RIP); rip.setkey(3); - rip.put(RIP_TIPO, 'B'); - rip.put(RIP_GRUPPO, gruppo); - rip.put(RIP_CONTO, conto); - rip.put(RIP_SOTTOCONTO, sottoconto); - // if (rip.read(_isgteq) == NOERR && rip.get_int(RIP_GRUPPO)==gruppo && rip.get_int(RIP_CONTO)==conto && rip.get_long(RIP_SOTTOCONTO)==sottoconto) + const int gruppo = input.get(RMV_GRUPPO).as_int(); + const int conto = input.get(RMV_CONTO).as_int(); + const long sottoconto = input.get(RMV_SOTTOCONTO).as_int(); + + TString8 cdc, cms; + if (rip.cdc(gruppo, conto, sottoconto, cdc, cms)) { + const real imp = recset.get("IMPORTO").as_real(); + if (lastcdc.blank() || imp > impcdc) + { + lastcdc = cdc; + impcdc = imp; + } + analset.new_rec(); analset.set("COFI", recset.get("COFI")); - analset.set("PAIV", recset.get("RAGSOC")); + analset.set("PAIV", recset.get("PAIV")); + analset.set("RAGSOC", recset.get("RAGSOC")); analset.set("ESCOGE", recset.get("ESCOGE")); analset.set("NUMPART", recset.get("NUMPART")); analset.set("NUMINT", recset.get("NUMINT")); @@ -1493,10 +1562,10 @@ void TInvioSispac::sispac_movim() analset.set("NUMDOC", recset.get("NUMDOC")); analset.set("DATADOC", recset.get("DATADOC")); analset.set("NUMPROT", recset.get("NUMPROT")); + analset.set("CDCCONT", cdc); // Centro di costo contabile analset.set("DATAOPANAL", recset.get("DATAOP")); - analset.set("CDC", recset.get("CODCONTO")); - analset.set("CDC1", rip.get(RIP_CODCMS)); - analset.set("CDC2", rip.get(RIP_CODFASE)); + analset.set("CDC", recset.get("CODCONTO")); // Conto analitico = conto contabile + analset.set("CDC1", cms); // Centro di costo analitico analset.set("FINEREC", "\r\n"); } } @@ -1504,6 +1573,8 @@ void TInvioSispac::sispac_movim() if (!p.addstatus(1L)) break; } + if (lastcdc.full()) + fill_last_cdc(lastcdc, recset); TFilename outputname = _configfile->get("PATH", "OPZIONI"); outputname << "\\movim"; diff --git a/tc/tc9400.cpp b/tc/tc9400.cpp index ce3c774cb..37241bacc 100755 --- a/tc/tc9400.cpp +++ b/tc/tc9400.cpp @@ -49,6 +49,7 @@ void TSispac_multirel_app::init_query_insert_mode(TMask& m) m.show(-2); m.enable(-4); } + void TSispac_multirel_app::init_modify_mode(TMask& m) { TMultirel_application::init_modify_mode(m); @@ -58,7 +59,7 @@ void TSispac_multirel_app::init_modify_mode(TMask& m) m.disable(-4); } -void TSispac_multirel_app::init_insert_mode(TMask& m) +void TSispac_multirel_app::init_insert_mode(TMask& m) { TMultirel_application::init_insert_mode(m); m.show(-1); @@ -73,12 +74,12 @@ bool TSispac_multirel_app::user_create() if (ok) { - TMask & m = *get_mask(); - + TMask& m = *get_mask(); set_search_field(F_CODTAB); } return ok; } + int tc9400(int argc, char* argv[]) { TSispac_multirel_app a; diff --git a/tc/tcsc.h b/tc/tcsc.h index 12d86935e..b790824a2 100755 --- a/tc/tcsc.h +++ b/tc/tcsc.h @@ -10,3 +10,4 @@ #define F_COD_CONTOV 110 #define F_COD_CAUSCO 111 #define F_COD_SEZCO 112 +#define F_COD_IVA 113 diff --git a/tc/tcsciva.uml b/tc/tcsciva.uml index 2eeb8c272..cbfe23de1 100755 --- a/tc/tcsciva.uml +++ b/tc/tcsciva.uml @@ -16,7 +16,7 @@ BEGIN PROMPT 50 50 "" ITEM "SCIVA|SCIVA" FIELD COD - FLAGS "D" + FLAGS "DG" KEY 1 END @@ -26,16 +26,17 @@ BEGIN FIELD FIRST FLAGS "U" USE LF_MULTIREL + JOIN %IVA INTO CODTAB==FIRST INPUT COD F_COD SELECT INPUT FIRST F_CODTAB DISPLAY "Codice" FIRST - DISPLAY "Descrizione@60" DATA + DISPLAY "Descrizione@50" 4->S0 DISPLAY "Codice IVA Sispac" SECOND OUTPUT F_CODTAB FIRST OUTPUT F_CODTAB1 FIRST - OUTPUT F_DESC DATA - OUTPUT F_COD_CAMPO SECOND -// CHECKTYPE REQUIRED + OUTPUT F_DESC 4->S0 + OUTPUT F_COD_IVA SECOND + CHECKTYPE REQUIRED FIELD FIRST KEY 1 GROUP 1 @@ -46,40 +47,32 @@ BEGIN PROMPT 2 2 "" USE %IVA INPUT CODTAB F_CODTAB1 - DISPLAY "Cod." CODTAB + DISPLAY "Codice" CODTAB DISPLAY "Descrizione@50" S0 OUTPUT F_CODTAB CODTAB OUTPUT F_CODTAB1 CODTAB - OUTPUT F_DESC S0 -// CHECKTYPE REQUIRED + CHECKTYPE REQUIRED FIELD FIRST KEY 1 - FLAGS "U" + FLAGS "UH" GROUP 2 END STRING F_DESC 50 BEGIN PROMPT 10 2 "Descrizione " - USE LF_MULTIREL KEY 2 - INPUT COD F_COD SELECT - INPUT DATA F_DESC - DISPLAY "Descrizione@60" DATA - DISPLAY "Codice" FIRST - DISPLAY "Codice IVA Sispac" SECOND - COPY OUTPUT F_CODTAB - FIELD DATA - KEY 3 - CHECKTYPE REQUIRED + FLAGS "D" END -STRING F_COD_CAMPO 3 +STRING F_COD_IVA 3 BEGIN PROMPT 2 4 "Codice IVA Sispac " - CHECKTYPE NORMAL - KEY 1 - GROUP 3 FIELD SECOND + KEY 1 + GROUP 3 + CHECKTYPE NORMAL + VALIDATE NOT_EMPTY_FUNC + WARNIG "E' necessario inserire il codice IVA corrispondente" END ENDPAGE