diff --git a/ba/ba1700.cpp b/ba/ba1700.cpp index 3b4e96bbc..67ffed847 100755 --- a/ba/ba1700.cpp +++ b/ba/ba1700.cpp @@ -353,7 +353,18 @@ bool TInstaller_mask::autoload() if (module[0] == '_') add_header(ini, module, FALSE); else - add_module(ini, module, FALSE); + { + TFilename mod_ini = ininame.path(); + mod_ini.add(module); + mod_ini << "inst.ini"; + if (mod_ini.exist()) + { + TInstall_ini moduleini(mod_ini); + add_module(moduleini, module, FALSE); + } + else + add_module(ini, module, FALSE); + } } } } @@ -1134,7 +1145,7 @@ bool TInstaller_mask::install_handler(TMask_field& fld, KEY key) if (some) _curr_mask->install_selection(); else - error_box("Selezionare uno piu' moduli da installare."); + error_box("Selezionare uno o piu' moduli da installare."); } return TRUE; } diff --git a/ba/ba4200.cpp b/ba/ba4200.cpp index b1a7f6d09..649818342 100755 --- a/ba/ba4200.cpp +++ b/ba/ba4200.cpp @@ -37,7 +37,7 @@ protected: virtual TMask* get_mask(int mode) ; virtual void write_enable(bool on = TRUE); - static bool fax_handler(TMask_field& f, KEY k); +// static bool fax_handler(TMask_field& f, KEY k); static bool email_handler(TMask_field& f, KEY k); static bool ba4200_handler(TMask& m, KEY k); static bool ind_handler(TMask_field& f, KEY k); @@ -94,7 +94,7 @@ bool TPersone_app::ba4200_handler(TMask& m, KEY k) return FALSE; } -bool TPersone_app::fax_handler(TMask_field& f, KEY k) +/*bool TPersone_app::fax_handler(TMask_field& f, KEY k) { bool ok = TRUE; if (k == K_SPACE) @@ -117,7 +117,7 @@ bool TPersone_app::fax_handler(TMask_field& f, KEY k) } } return ok; -} +} */ bool TPersone_app::email_handler(TMask_field& f, KEY k) { @@ -550,7 +550,7 @@ TMask* TPersone_app::get_mask(int mode) _msk[MSKF]->set_handler(F_UFFCONC, uff_conc); _msk[MSKF]->set_handler(F_CODREG96, cod_reg); _msk[MSKF]->set_handler(F_TITCF, tit_cf); - _msk[MSKF]->set_handler(DLG_FAX, fax_handler); +// _msk[MSKF]->set_handler(DLG_FAX, fax_handler); _msk[MSKF]->set_handler(DLG_EMAIL, email_handler); _msk[MSKF]->set_handler(ba4200_handler); @@ -567,7 +567,7 @@ TMask* TPersone_app::get_mask(int mode) _msk[MSKG]->set_handler(FLD_AG1_PAIV, no_dup_iva_g); _msk[MSKG]->set_handler(F_UFFCONC, uff_conc); _msk[MSKG]->set_handler(F_TITCF, tit_cf); - _msk[MSKG]->set_handler(DLG_FAX, fax_handler); +// _msk[MSKG]->set_handler(DLG_FAX, fax_handler); _msk[MSKG]->set_handler(DLG_EMAIL, email_handler); _msk[MSKG]->set_handler(ba4200_handler); diff --git a/ba/ba4200b.uml b/ba/ba4200b.uml index fa8bd66f3..097bd034c 100755 --- a/ba/ba4200b.uml +++ b/ba/ba4200b.uml @@ -15,12 +15,6 @@ PROMPT -36 -3 "~Ditte" MESSAGE K_F5 END -BUTTON DLG_FAX 10 2 -BEGIN - PROMPT -46 -3 "Fa~x" - PICTURE BMP_FAX -END - BUTTON DLG_EMAIL 10 2 BEGIN PROMPT -56 -3 "~Posta" diff --git a/ba/ba4200c.uml b/ba/ba4200c.uml index e6eceb2d4..0d5a3c88d 100755 --- a/ba/ba4200c.uml +++ b/ba/ba4200c.uml @@ -14,12 +14,6 @@ BEGIN MESSAGE K_F5 END -BUTTON DLG_FAX 10 2 -BEGIN - PROMPT -46 -3 "Fa~x" - PICTURE BMP_FAX -END - BUTTON DLG_EMAIL 10 2 BEGIN PROMPT -56 -3 "~Posta" diff --git a/ba/ba4300.cpp b/ba/ba4300.cpp index 480c43083..2599aa11d 100755 --- a/ba/ba4300.cpp +++ b/ba/ba4300.cpp @@ -74,7 +74,8 @@ protected: virtual bool protected_record(TRectype& rec) { return prefix().exist(rec.get_long("CODDITTA")); } void set_att_prev(const TMask& m); - static bool fax_handler(TMask_field& f, KEY k); +// static bool fax_handler(TMask_field& f, KEY k); + static bool email_handler(TMask_field& f, KEY k); public: TDitte_application(); @@ -172,7 +173,7 @@ bool ba4300_handler(TMask& m, KEY k) TDitte_application::TDitte_application() : _cespiti(FALSE) {} -bool TDitte_application::fax_handler(TMask_field& f, KEY k) +/*bool TDitte_application::fax_handler(TMask_field& f, KEY k) { bool ok = TRUE; if (k == K_SPACE) @@ -195,10 +196,21 @@ bool TDitte_application::fax_handler(TMask_field& f, KEY k) } } return ok; +} */ + +bool TDitte_application::email_handler(TMask_field& f, KEY k) +{ + if (k == K_SPACE) + { + TMail_message msg(f.mask().get(F_MAIL)); + msg.send(); + } + return TRUE; } bool TDitte_application::user_create() // initvar e arrmask { + _rel = new TRelation(LF_NDITTE); _anag = new TLocalisamfile(LF_ANAG); _unloc = new TLocalisamfile(LF_UNLOC); @@ -207,20 +219,9 @@ bool TDitte_application::user_create() // initvar e arrmask _cespiti = has_module(CEAUT); _msk = new TMask("ba4300a") ; - _msk->set_handler(DLG_FAX, fax_handler); _msk->set_handler(ba4300_handler); set_search_field(FLD_GD1_CODDITTA); -/* - if (argc() > 2) - { - get_mask(MODE_QUERY); - TString16 s("1|"); - - s << argv(2) << "|" << argv(2); - set_link(*_msk, s); - } -*/ return TRUE; } @@ -435,4 +436,3 @@ int ba4300(int argc, char* argv[]) a.run(argc, argv, "Anagrafica Ditte"); return 0; } - diff --git a/ba/ba4300.h b/ba/ba4300.h index eae8b73f8..017a14742 100755 --- a/ba/ba4300.h +++ b/ba/ba4300.h @@ -137,4 +137,6 @@ #define FLD_IN_DESSOGDEL 201 #define CHK_IN_NONOBBSTAT 202 +#define F_MAIL 203 + #endif // __BA4300_H diff --git a/ba/ba4300a.uml b/ba/ba4300a.uml index 1ca0ea5f6..d64e271cb 100755 --- a/ba/ba4300a.uml +++ b/ba/ba4300a.uml @@ -28,14 +28,14 @@ END BUTTON DLG_REG1 10 2 BEGIN - PROMPT -56 -3 "Reg.Ces~p." + PROMPT -56 -3 "Reg.~Cesp." MESSAGE K_F3 END -BUTTON DLG_FAX 10 2 +BUTTON DLG_EMAIL 10 2 BEGIN - PROMPT -66 -3 "Fa~x" - PICTURE BMP_FAX + PROMPT -66 -3 "~Posta" + PICTURE BMP_EMAIL END #include diff --git a/ba/batbind.uml b/ba/batbind.uml index 105ffc57e..55e6b5919 100755 --- a/ba/batbind.uml +++ b/ba/batbind.uml @@ -16,8 +16,8 @@ BEGIN KEY 1 USE %IND INPUT CODTAB[1,5] F_DITTAINV - DISPLAY "Ditta" CODTAB - DISPLAY "Num.inv." I0 + DISPLAY "Codice Ditta" CODTAB + DISPLAY "Numero inv." I0 DISPLAY "Data invio" D0 DISPLAY "Stato" S6 OUTPUT F_DITTAINV CODTAB diff --git a/ba/batbnoc.uml b/ba/batbnoc.uml index 9ab6078d1..82505572c 100755 --- a/ba/batbnoc.uml +++ b/ba/batbnoc.uml @@ -80,16 +80,20 @@ LIST NOC_UMS_OBB 1 50 BEGIN PROMPT 2 10 "Obbligatorieta' " ITEM " |Non obbligatoria" + MESSAGE NORMAL,NOC_UMS_CODICE ITEM "A|Obbligatoria per acquisti" + MESSAGE REQUIRED,NOC_UMS_CODICE ITEM "C|Obbligatoria per cessioni" + MESSAGE REQUIRED,NOC_UMS_CODICE ITEM "E|Obbligatoria per acquisti e cessioni" + MESSAGE REQUIRED,NOC_UMS_CODICE FIELD S4 GROUP 1 END STRING NOC_UMS_CODICE 2 BEGIN - PROMPT 2 12 "Descrizione " + PROMPT 2 12 "Unita' " USE %UMS FLAGS "U" INPUT CODTAB NOC_UMS_CODICE @@ -98,6 +102,7 @@ BEGIN OUTPUT NOC_UMS_CODICE CODTAB OUTPUT NOC_UMS_DESCR S0 CHECKTYPE NORMAL + WARNING "Inserire l'unita` di misura obbligatoria" FIELD S5 GROUP 1 END diff --git a/ba/batbpor.uml b/ba/batbpor.uml index 0e1f6d2ea..3fc1951c5 100755 --- a/ba/batbpor.uml +++ b/ba/batbpor.uml @@ -46,41 +46,31 @@ OUTPUT F_DESCR S0 CHECKTYPE REQUIRED END -LIST F_TRASPORTO 1 20 +NUMBER F_TRASPORTO 1 BEGIN PROMPT 4 7 "Modo di trasporto " - ITEM "1|Marittimo" - ITEM "2|Ferroviario" - ITEM "3|Stradale" - ITEM "4|Aereo" - ITEM "5|Spedizione postale" - ITEM "7|Installazioni fisse" - ITEM "8|Via acqua" - ITEM "9|Propulsione propria" + USE %IMT + INPUT CODTAB F_TRASPORTO + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_TRASPORTO CODTAB + CHECKTYPE NORMAL FIELD I0 END STRING F_CONSEGNA 3 BEGIN PROMPT 4 9 "Condizioni consegna " - SHEET "Codice|Descrizione@45" - INPUT F_CONSEGNA - ITEM "EXW|Franco fabbrica" - ITEM "FCA|Franco vettore" - ITEM "FAS|Franco sotto bordo" - ITEM "FOB|Franco a bordo" - ITEM "CFR|Costo e nolo" - ITEM "CIF|Costo, assicurazione, nolo" - ITEM "CPT|Nolo/porto pagato fino a ..." - ITEM "CIP|Nolo/porto e assicurazione pagati fino a ..." - ITEM "DAF|Reso frontiera" - ITEM "DES|Reso franco bordo nave a destino" - ITEM "DEQ|Reso franco banchina" - ITEM "DDU|Reso non sdoganato" - ITEM "DDP|Reso sdoganato" - OUTPUT F_CONSEGNA + USE %ICC + FLAGS "U" + INPUT CODTAB F_CONSEGNA + DISPLAY "Codice" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT F_CONSEGNA CODTAB + CHECKTYPE NORMAL FIELD S3 END ENDPAGE + ENDMASK diff --git a/ba/batbsce.uml b/ba/batbsce.uml index 360a2de4f..1cb39a698 100755 --- a/ba/batbsce.uml +++ b/ba/batbsce.uml @@ -22,6 +22,7 @@ BEGIN DISPLAY "Codice" CODTAB DISPLAY "Descrizione@50" S0 OUTPUT F_CODICE CODTAB + OUTPUT F_DESCR S0 CHECKTYPE REQUIRED FIELD CODTAB KEY 1 diff --git a/ce/ce1500.cpp b/ce/ce1500.cpp index 2e506483e..4f16b9e24 100755 --- a/ce/ce1500.cpp +++ b/ce/ce1500.cpp @@ -610,7 +610,8 @@ bool TMov_emask::calc_amm(int tipo) } void TMov_emask::set_fondi_inputability() -{ +{ +/* if (cespite_nuovo()) { // Disabilito tutti i campi della pagina per i nuovi cespiti @@ -620,6 +621,7 @@ void TMov_emask::set_fondi_inputability() set_inputability(prv_ids, ' '); } else +*/ { set_inputability(fis_ids, _s5[10]); set_inputability(civ_ids, _s5[11]); diff --git a/ce/ce3100a.frm b/ce/ce3100a.frm index e861e406b..97ce5f80e 100755 --- a/ce/ce3100a.frm +++ b/ce/ce3100a.frm @@ -35,7 +35,9 @@ SECTION HEADER FIRST 9 MESSAGE RESET,F0->FR_TG_VNONAMM MESSAGE RESET,F0->FR_TG_TOTRIV MESSAGE RESET,F0->FR_TG_VALAMM - MESSAGE RESET,F0->FR_TG_RESAMM + MESSAGE RESET,F0->FR_TG_RESAMM + MESSAGE RESET,F0->FR_TG_MINUSVALENZA + MESSAGE RESET,F0->FR_TG_PLUSVALENZA MESSAGE RESET,F0->FR_TG_PLUSREIN MESSAGE RESET,F0->FR_TG_FONDOAMM MESSAGE RESET,F0->FR_TG_QNONAMM @@ -258,7 +260,9 @@ SECTION HEADER EVEN 2 MESSAGE RESET,F1->FR_TC_VNONAMM MESSAGE RESET,F1->FR_TC_TOTRIV MESSAGE RESET,F1->FR_TC_VALAMM - MESSAGE RESET,F1->FR_TC_RESAMM + MESSAGE RESET,F1->FR_TC_RESAMM + MESSAGE RESET,F1->FR_TC_MINUSVALENZA + MESSAGE RESET,F1->FR_TC_PLUSVALENZA MESSAGE RESET,F1->FR_TC_PLUSREIN MESSAGE RESET,F1->FR_TC_FONDOAMM MESSAGE RESET,F1->FR_TC_QNONAMM @@ -1527,7 +1531,7 @@ SECTION FOOTER EVEN 6 BEGIN KEY "Minusvalenza" PROMPT 8 4 "" - MESSAGE ADD,FO->FR_TG_MINUSVALENZA + MESSAGE ADD,FO->FR_TG_MINUSVALENZA PICTURE "##.###.###.###.@@@" END diff --git a/ce/celib.cpp b/ce/celib.cpp index 28d715b33..5f2fffb18 100755 --- a/ce/celib.cpp +++ b/ce/celib.cpp @@ -118,7 +118,7 @@ void TDitta_cespiti::init_mask(TMask& m) TBit_array found; bool started = FALSE; bool finished = FALSE; - for (int i = 0; !finished && i < 18; i++) + for (int i = 0; !finished && i < 18 && i < m.fields(); i++) { TMask_field& f = m.fld(i); if (started) diff --git a/ce/f140.trr b/ce/f140.trr index 5f50d2beb..f6b1c6a82 100755 --- a/ce/f140.trr +++ b/ce/f140.trr @@ -1,8 +1,8 @@ 140 30 CODGRUPPO|2|2|0|Codice gruppo (CGCDGR) -CODSPECIE|2|4|0|Codice specie (CGCDSP) -TIPO|2|1|0|Tipo collegamento ("X" per categoria, " " per cespite) (CGTIPO) +CODSPECIE|1|4|0|Codice specie (CGCDSP) +TIPO|2|1|0|Tipo collegamento ("1" per categoria, "2" per cespite) (CGTIPO) IDCESPITE|1|10|0|Codice cespite (CGCESP) CODCAT|2|2|0|Codice categoria (CGCDCT) COMPL|8|1|0|Riferimenti completati per collegamento (CGCOMP) diff --git a/cg/cg0200.cpp b/cg/cg0200.cpp index 68805cdbb..5b8143141 100755 --- a/cg/cg0200.cpp +++ b/cg/cg0200.cpp @@ -75,7 +75,7 @@ protected: static bool tipo_handler(TMask_field& f, KEY key); static bool percip_handler(TMask_field& f, KEY key); - static bool fax_handler(TMask_field& f, KEY k); +// static bool fax_handler(TMask_field& f, KEY k); static bool email_handler(TMask_field& f, KEY k); static bool rsoc_handler(TMask_field& f, KEY k); @@ -307,7 +307,7 @@ bool TClifo_application::percip_handler(TMask_field& f, KEY key) return TRUE; } -bool TClifo_application::fax_handler(TMask_field& f, KEY k) +/*bool TClifo_application::fax_handler(TMask_field& f, KEY k) { bool ok = TRUE; if (k == K_SPACE) @@ -329,7 +329,7 @@ bool TClifo_application::fax_handler(TMask_field& f, KEY k) } } return ok; -} +} */ bool TClifo_application::email_handler(TMask_field& f, KEY k) { @@ -515,7 +515,7 @@ int TClifo_application::read(TMask& m) TString16 key(rec.get(IND_STATO)); key << "|" << rec.get(IND_COM); const TRectype & com = cache().get(LF_COMUNI, key); riga.add(com.get(COM_DENCOM)); -// riga.add(rec.get(IND_CODIND)); + riga.add(rec.get(IND_CODIND)); indsp_sheet().row(i)=riga; @@ -843,7 +843,7 @@ bool TClifo_application::user_create() // initvar e arrmask _msk->set_handler(F_TIPOPERS, tipo_handler); _msk->set_handler(F_ALLEG, alleg_handler); _msk->set_handler(F_CODALLEG, codalleg_handler); - _msk->set_handler(DLG_FAX, fax_handler); +// _msk->set_handler(DLG_FAX, fax_handler); _msk->set_handler(DLG_EMAIL, email_handler); _msk->set_handler(F_RAGSOC, rsoc_handler); diff --git a/cg/cg0200a.uml b/cg/cg0200a.uml index 4d10caa5c..c54c49d17 100755 --- a/cg/cg0200a.uml +++ b/cg/cg0200a.uml @@ -2,12 +2,6 @@ TOOLBAR "" 0 18 0 4 -BUTTON DLG_FAX 10 2 -BEGIN - PROMPT -46 -3 "Fa~x" - PICTURE BMP_FAX -END - BUTTON DLG_EMAIL 10 2 BEGIN PROMPT -56 -3 "~Posta" diff --git a/cg/cg0500a.uml b/cg/cg0500a.uml index dcd089734..f00846d07 100755 --- a/cg/cg0500a.uml +++ b/cg/cg0500a.uml @@ -70,6 +70,8 @@ BEGIN CHECKTYPE NORMAL FLAGS "U" ADD NONE + MESSAGE EMPTY CLEAR,F_SOLAIVA + MESSAGE ENABLE,F_SOLAIVA END STRING F_DES_DOC 50 @@ -145,9 +147,9 @@ LISTBOX F_TIPO_MOV_1 1 20 BEGIN PROMPT 2 5 "Tipo movimento " FIELD TIPOMOV - ITEM " |Nessuno" MESSAGE COPY,F_TIPO_MOV - ITEM "1|Fattura" MESSAGE COPY,F_TIPO_MOV - ITEM "2|Nota credito" MESSAGE COPY,F_TIPO_MOV + ITEM " |Nessuno" MESSAGE COPY,F_TIPO_MOV + ITEM "1|Fattura" MESSAGE COPY,F_TIPO_MOV + ITEM "2|Nota credito" MESSAGE COPY,F_TIPO_MOV // GROUP 2 END @@ -156,10 +158,10 @@ LISTBOX F_TIPO_MOV_2 1 20 BEGIN PROMPT 2 5 "Tipo movimento " FIELD TIPOMOV - ITEM " |Nessuno" MESSAGE COPY,F_TIPO_MOV - ITEM "3|Incasso/pagamento " MESSAGE COPY,F_TIPO_MOV - ITEM "5|Insoluto" MESSAGE COPY,F_TIPO_MOV - ITEM "6|Pagamento insoluto" MESSAGE COPY,F_TIPO_MOV + ITEM " |Nessuno" MESSAGE COPY,F_TIPO_MOV + ITEM "3|Incasso/pagamento " MESSAGE COPY,F_TIPO_MOV + ITEM "5|Insoluto" MESSAGE COPY,F_TIPO_MOV + ITEM "6|Pagamento insoluto" MESSAGE COPY,F_TIPO_MOV FLAGS "H" END @@ -291,6 +293,12 @@ BEGIN GROUP 2 END +BOOLEAN F_SOLAIVA +BEGIN + PROMPT 34 12 "Movimento di sola IVA" + FIELD SOLOIVA +END + BOOLEAN F_MOV_SEZ BEGIN PROMPT 34 12 "Movimento solo sezionale" @@ -333,12 +341,6 @@ BEGIN FIELD MOVIND END -BOOLEAN F_SOLAIVA -BEGIN - PROMPT 2 18 "Movimento di sola IVA" - FIELD SOLOIVA -END - ENDPAGE ENDMASK diff --git a/cg/cg1500.cpp b/cg/cg1500.cpp index 362580db8..d4afb2979 100755 --- a/cg/cg1500.cpp +++ b/cg/cg1500.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -44,6 +45,23 @@ #include "cglib01.h" #include "cglib02.h" +class TSaldo_cdc : public TSaldo +{ +public: + bool data_limite_commessa(int bilancio, int g, int c, long s, const char* commessa, const TDate& data_inf, + const TDate& data_sup, int indbil, int stp_prov); +}; + + +//per bilancio scalare (ovvero a sezioni contrapposte) per data limite +bool TSaldo_cdc::data_limite_commessa(int bilancio, int g, int c, long s, const char* commessa, const TDate& data_inf, + const TDate& data_sup, int indbil, int stp_prov) +{ + TString filter; + filter << RMV_CODCMS << "==\"" << commessa << '"'; + return data_limite_bilancio(bilancio, g, c, s, data_inf, data_sup, indbil, stp_prov, filter); +} + class TStampa_bilanci : public TPrintapp { static bool mask_anno (TMask_field& f, KEY k); @@ -116,6 +134,8 @@ class TStampa_bilanci : public TPrintapp bool _mov_ap,_quadratura; bool _print_exercise; int _stampa_mov_prov; + + TString _cdc; TArray _clienti, _fornitori; @@ -129,7 +149,10 @@ public: virtual bool user_destroy(); bool set_print(int); - void next_c(); + void next_c(); + + void header_cdc(int& r); + virtual bool preprocess_print(int,int); virtual void preprocess_header(); virtual bool preprocess_page(int,int); @@ -162,7 +185,7 @@ public: int cerca_indbil(int,int); void scrivig_file_temp(); void scrivic_file_temp(); - void scrivis_file_temp(int,int,long,real); + void scrivis_file_temp(int,int,long,const real&); void leggi_files_dare (TIsamtempfile*); void leggi_files_avere(TIsamtempfile*); void leggi_file_tmp(); @@ -174,6 +197,7 @@ public: void controlla_conto(int,int); const char* DescrizioneConto(int,int,long,char); //chiama quella di TConto TDate UltimaData(int,int,long,int); + void stampa_un_bilancio(const TMask& m); TStampa_bilanci() {} }; @@ -678,7 +702,7 @@ void TStampa_bilanci::scrivic_file_temp() } } -void TStampa_bilanci::scrivis_file_temp(int g, int c, long s, real saldo) +void TStampa_bilanci::scrivis_file_temp(int g, int c, long s, const real& saldo) { TIsamtempfile* tmp = NULL; TString16 nome_campo; @@ -799,7 +823,7 @@ void TStampa_bilanci::next_c() bool TStampa_bilanci::bil_sez_contr() { - TSaldo sld; + TSaldo_cdc sld; int indbil_conto=0; int g, c; long s; @@ -928,7 +952,12 @@ bool TStampa_bilanci::bil_sez_contr() } if (_tipo_stampa == 1) //bil. a sez. contrapposte per data limite - movimentato = sld.data_limite_bilancio(_bilancio,g,c,s,_dataini,_datalim,indbil_conto,_stampa_mov_prov); + { + if (_cdc.not_empty()) + movimentato = sld.data_limite_commessa(_bilancio,g,c,s,_cdc,_dataini,_datalim,indbil_conto,_stampa_mov_prov); + else + movimentato = sld.data_limite_bilancio(_bilancio,g,c,s,_dataini,_datalim,indbil_conto,_stampa_mov_prov); + } else if (_tipo_stampa == 2) //bil. a sez. contrapposte all'ultima immissione es. in corso movimentato = sld.ultima_immissione_bilancio(_annoes,g,c,s,indbil_conto,_stampa_mov_prov); @@ -1072,7 +1101,7 @@ bool TStampa_bilanci::bil_sez_contr() bool TStampa_bilanci::ricerca_sottoc_clifo(int g,int c, bool compensa, int indbil_conto,real& saldo) { - TSaldo sld; + TSaldo_cdc sld; int aep=0; long s, items; bool esiste_sc = FALSE; @@ -1097,7 +1126,12 @@ bool TStampa_bilanci::ricerca_sottoc_clifo(int g,int c, bool compensa, int indbi s = r->get_long(SLD_SOTTOCONTO); if (_tipo_stampa == 1) //bil. a sez. contrapposte per data limite - movimentato = sld.data_limite_bilancio(_bilancio,g,c,s,_dataini,_datalim,indbil_conto,_stampa_mov_prov); + { + if (_cdc.not_empty()) + movimentato = sld.data_limite_commessa(_bilancio,g,c,s,_cdc,_dataini,_datalim,indbil_conto,_stampa_mov_prov); + else + movimentato = sld.data_limite_bilancio(_bilancio,g,c,s,_dataini,_datalim,indbil_conto,_stampa_mov_prov); + } else if (_tipo_stampa == 2) //bil. a sez. contrapposte all'ultima immissione es. in corso movimentato = sld.ultima_immissione_bilancio(_annoes,g,c,s,indbil_conto,_stampa_mov_prov); @@ -1285,7 +1319,7 @@ bool TStampa_bilanci::bil_verifica() } //scrivo il record del conto; if ( (_verifica == 1)||( (_verifica == 2)&& - (!((_stampav == 2)&&(saldo_conto == 0))) ) ) + (!((_stampav == 2)&&(saldo_conto == 0))) ) ) { scrivi_record_conto(prg_conto_dare,prg_conto_avere,mov_conto_dare, mov_conto_avere,saldo_conto); @@ -1678,16 +1712,18 @@ return TRUE; //bilancio di verifica per data limite bool TStampa_bilanci::calcola(int g, int c, long s) { - char sezione, provvis; - real importo; int annoe; long num_reg; - TDate data_reg, data, datacomp, data_start; + TDate data_reg, data; bool conto_mov = FALSE; - TLocalisamfile rmov(LF_RMOV); - TLocalisamfile mov(LF_MOV); TDecoder causali(LF_CAUSALI, CAU_MOVAP); + + TRelation rel(LF_RMOV); + rel.add(LF_MOV, "NUMREG==NUMREG"); + + TRectype& rmov = rel.curr(); + const TRectype& mov = rel.curr(LF_MOV); _mov_periodo_dare = ZERO; _mov_periodo_avere = ZERO; @@ -1697,8 +1733,7 @@ bool TStampa_bilanci::calcola(int g, int c, long s) _saldo_ini_avere = ZERO; _u_max = 0l; - data_start = _dataini; - + TDate data_start = _dataini; // Calcolo progressivi precedenti: // e non è indicato l'anno esercizio, prende il primo giorno dell'anno indicato da _datada if (_annoes == 0) @@ -1708,31 +1743,29 @@ bool TStampa_bilanci::calcola(int g, int c, long s) data_start.set_month(1); } - rmov.setkey(2); rmov.zero(); rmov.put(RMV_GRUPPO,g); if (c != 0) rmov.put(RMV_CONTO,c); if (s != 0) rmov.put(RMV_SOTTOCONTO,s); - const TRectype rec(rmov.curr()); - - for (int err = rmov.read(_isgteq); err == NOERR; err = rmov.next()) + + TString filter; + if (_cdc.not_empty()) + filter << '(' << RMV_CODCMS << "=='" << _cdc << "')"; + + TCursor cur(&rel, filter, 2, &rmov, &rmov); + const long items = cur.items(); + cur.freeze(); + + for (cur = 0L; cur.pos() < items; ++cur) { - if (rmov.curr() != rec) - break; - annoe = rmov.get_int(RMV_ANNOES); data = rmov.get_date(RMV_DATAREG); num_reg = rmov.get_long(RMV_NUMREG); - - mov.setkey(1); - mov.put(MOV_NUMREG, num_reg); - if (mov.read() != NOERR) - mov.zero(); - provvis = mov.get_char(MOV_PROVVIS); - datacomp = mov.get_date(MOV_DATACOMP); + const char provvis = mov.get_char(MOV_PROVVIS); + const TDate datacomp = mov.get_date(MOV_DATACOMP); if (_stampa_mov_prov == 1 && provvis != '\0') //bilancio normale (non comprende i provvisori) continue; @@ -1751,8 +1784,8 @@ bool TStampa_bilanci::calcola(int g, int c, long s) continue; } - sezione = rmov.get_char(RMV_SEZIONE); - importo = rmov.get_real(RMV_IMPORTO); + const char sezione = rmov.get_char(RMV_SEZIONE); + const real importo = rmov.get_real(RMV_IMPORTO); if (_annoes == 0) data_reg = data; @@ -1805,7 +1838,7 @@ bool TStampa_bilanci::calcola(int g, int c, long s) _mov_ap = TRUE; } } - return conto_mov; + return conto_mov; } bool TStampa_bilanci::ricerca_cf(int g,int c,char tipocf,int ib, real& saldo_finale,real& saldo_iniziale, @@ -1813,33 +1846,22 @@ bool TStampa_bilanci::ricerca_cf(int g,int c,char tipocf,int ib, real& saldo_fin { TSaldo sld; bool esiste_sc = FALSE; - long s; - int anno; - - if (_tipo_stampa1 == 1) - anno = _annoapp; - else - anno = _annoes; + const int anno = _tipo_stampa1 == 1 ? _annoapp : _annoes; _lista = new TSaldi_list(g, c, anno); - TRecnotype items = _lista->items(); + const TRecnotype items = _lista->items(); - for (int i = 0; i < items; i++) + for (TRecnotype i = 0; i < items; i++) { const TRectype* r = _lista->saldi(); if (r == NULL) break; - s = r->get_long(SLD_SOTTOCONTO); + const long s = r->get_long(SLD_SOTTOCONTO); saldo_finale = saldo_iniziale = ZERO; //saldi relativi a ciascun sottoconto if (_tipo_stampa1 == 1) //bil. di verifica per data limite { - /* - if ( !calcola(g,c,s) ) //il conto non e' movimentato - if (_stampav == 1 || _stampav == 3) //per i C/F anche se seleziono -tutti i conti, voglio solo quelli movimentati - continue; - */ //modifica del 21/11/1995 _mov_ap = FALSE; //modifica del 19/06. Vedi appunti per capire @@ -2259,11 +2281,7 @@ void TStampa_bilanci::leggi_clifo(const TArray& gccf) prg_conto_avere = ZERO; _u_max = 0l; - int anno; - if (_tipo_stampa1 == 1) - anno = _annoapp; - else anno = _annoes; - + const int anno = _tipo_stampa1 == 1 ? _annoapp : _annoes; for (int i=0; i < gccf.items(); i++) { int g = ((TToken_string&)gccf[i]).get_int(0); @@ -3692,28 +3710,30 @@ bool TStampa_bilanci::user_destroy() } void TStampa_bilanci::leggi_pcon() -{ - TLocalisamfile pconti(LF_PCON); - TToken_string gc(10); +{ + TRelation rel(LF_PCON); + TCursor cur(&rel); + const TRectype& pconti = rel.curr(); + + const long items = cur.items(); + cur.freeze(); - for (pconti.first(); !pconti.eof(); pconti.next()) + TToken_string gc(10); + for (cur = 0L; cur.pos() < items; ++cur) { - gc.restart(); - int gruppo = pconti.get_int(PCN_GRUPPO); - int conto = pconti.get_int(PCN_CONTO); - long sottoconto = pconti.get_long(PCN_SOTTOCONTO); + const int gruppo = pconti.get_int(PCN_GRUPPO); + const int conto = pconti.get_int(PCN_CONTO); + const long sottoconto = pconti.get_long(PCN_SOTTOCONTO); if ( (sottoconto == 0l) && (conto != 0) ) //si tratta di un conto { - char tipocf = pconti.get_char(PCN_TMCF); - if ( tipocf == 'C' && - (_situazione.empty() || _situazione == "C") ) + const char tipocf = pconti.get_char(PCN_TMCF); + if ( tipocf == 'C' && (_situazione.empty() || _situazione == "C")) { gc.add(gruppo,0); gc.add(conto,1); _clienti.add(gc); } - else if ( tipocf == 'F' && - (_situazione.empty() || _situazione == "F") ) + else if ( tipocf == 'F' && (_situazione.empty() || _situazione == "F")) { gc.add(gruppo,0); gc.add(conto,1); @@ -3723,10 +3743,86 @@ void TStampa_bilanci::leggi_pcon() } } +void TStampa_bilanci::stampa_un_bilancio(const TMask& m) +{ + if (_bilancio == 1) + { + printer().footerlen(3); + _prog = new TProgind(_pcn->items(),"Elaborazione in corso... prego attendere",FALSE); + _totali = m.get_bool(F_TOTALI); + _codici = m.get_bool(F_CODICI); + _saldo = m.get_bool(F_SALDO); + _tipo_stampa = m.get_int(F_STAMPA); + + if (_tipo_stampa == 1) + { + _datalim = m.get(F_DATALIM); + _print_exercise = TRUE; + if (_annoes == 0) + { + _print_exercise = FALSE; + _annoes = date2esc(_datalim); + } + + if (_annoes != 0) + _dataini = InizioEsercizio(_annoes); + else + _dataini = _inizioEs; + //_stampa_mov_prov = (bool)(m.get(F_STAMPAMPROV) == "X"); + } + bil_sez_contr(); + } + else + { + printer().footerlen(5); + _stampa_width = m.get_int(F_MODULO); + if (_stampa_width == 1) + _stampa_width = 132; + else _stampa_width = 148; //perche' questo e' in realta' il margine dx (vedi es. di stampa AS/400) + _verifica = m.get_int(F_VERIFICA); + if ( (_verifica == 1)||(_verifica == 2) ) + _prog = new TProgind(_pcn->items(),"Elaborazione in corso... prego attendere",FALSE); + _tipo_stampa1 = m.get_int(F_STAMPA1); + if (_tipo_stampa1 == 1) + { + if (_annoes != 0) + _dataini = InizioEsercizio(_annoes); + else + _dataini = _inizioEs; + _datada = m.get(F_DATADA); + _dataa = m.get(F_DATAA); + } + if ((_verifica == 1)||(_verifica == 2)) + { + _stampav = atoi(m.get(F_STAMPAV)); + bil_verifica(); + } + else + { + _situazione = m.get(F_SITUAZIONE); + _stampac = atoi(m.get(F_STAMPAC)); + _ordinamento = atoi(m.get(F_ORDINAMENTO)); + + if (_situazione.not_empty()) + _cur->setfilter(format("TIPOCF=\"%s\"",(const char*)_situazione)); + else + _cur->setfilter(""); + + _clienti.destroy(); + _fornitori.destroy(); + leggi_pcon(); + crea_sort_clifo(); + _sort->endsort(); + delete _cf; + } + } + delete _prog; + print(); +} + bool TStampa_bilanci::set_print(int) { TMask m ("cg1500a"); - KEY tasto; m.set_handler (F_VERIFICA, my_handler); m.set_handler (F_BILANCIO, mask_bilancio); m.set_handler (F_STAMPA1, mask_bilancio); @@ -3735,9 +3831,11 @@ bool TStampa_bilanci::set_print(int) m.set_handler (F_DATADA, mask_date); m.set_handler (F_DATAA, mask_date); m.set_handler (F_ANNO, mask_anno); + + if (!has_module(CMAUT)) + m.hide(-4); // Spegne campi commesse in assenza del modulo relativo - tasto = m.run(); - if (tasto == K_ENTER) + while (m.run() == K_ENTER) { _annoes = m.get_int(F_ANNO); _bilancio = m.get_int(F_BILANCIO); @@ -3746,79 +3844,26 @@ bool TStampa_bilanci::set_print(int) _quadratura = m.get_bool(F_QUADRATURA); _noseparator = m.get_bool(F_SEPARATOR); - if (_bilancio == 1) + if (m.get(F_DACDC).not_empty() || m.get(F_ACDC).not_empty()) { - printer().footerlen(3); - _prog = new TProgind(_pcn->items(),"Elaborazione in corso... prego attendere",FALSE); - _totali = m.get_bool(F_TOTALI); - _codici = m.get_bool(F_CODICI); - _saldo = m.get_bool(F_SALDO); - _tipo_stampa = m.get_int(F_STAMPA); - - if (_tipo_stampa == 1) - { - _datalim = m.get(F_DATALIM); - _print_exercise = TRUE; - if (_annoes == 0) - { - _print_exercise = FALSE; - _annoes = date2esc(_datalim); - } - - if (_annoes != 0) - _dataini = InizioEsercizio(_annoes); - else - _dataini = _inizioEs; - //_stampa_mov_prov = (bool)(m.get(F_STAMPAMPROV) == "X"); + TRelation rel("CMS"); + TRectype da_cdc(rel.curr()), a_cdc(rel.curr()); + da_cdc.put("CODTAB", m.get(F_DACDC)); + a_cdc.put("CODTAB", m.get(F_ACDC)); + TCursor cur(&rel, "", 1, &da_cdc, &a_cdc); + const TRecnotype items = cur.items(); + cur.freeze(); + for (cur = 0L; cur.pos() < items; ++cur) + { + _cdc = cur.curr().get("CODTAB"); + stampa_un_bilancio(m); } - bil_sez_contr(); } else { - printer().footerlen(5); - _stampa_width = m.get_int(F_MODULO); - if (_stampa_width == 1) - _stampa_width = 132; - else _stampa_width = 148; //perche' questo e' in realta' il margine dx (vedi es. di stampa AS/400) - _verifica = m.get_int(F_VERIFICA); - if ( (_verifica == 1)||(_verifica == 2) ) - _prog = new TProgind(_pcn->items(),"Elaborazione in corso... prego attendere",FALSE); - _tipo_stampa1 = m.get_int(F_STAMPA1); - if (_tipo_stampa1 == 1) - { - if (_annoes != 0) - _dataini = InizioEsercizio(_annoes); - else - _dataini = _inizioEs; - _datada = m.get(F_DATADA); - _dataa = m.get(F_DATAA); - } - if ((_verifica == 1)||(_verifica == 2)) - { - _stampav = atoi(m.get(F_STAMPAV)); - bil_verifica(); - } - else - { - _situazione = m.get(F_SITUAZIONE); - _stampac = atoi(m.get(F_STAMPAC)); - _ordinamento = atoi(m.get(F_ORDINAMENTO)); - - if (_situazione.not_empty()) - _cur->setfilter(format("TIPOCF = \"%s\"",(const char*)_situazione)); - else - _cur->setfilter(""); - - _clienti.destroy(); - _fornitori.destroy(); - leggi_pcon(); - crea_sort_clifo(); - _sort->endsort(); - delete _cf; - } + _cdc.cut(0); + stampa_un_bilancio(m); } - delete _prog; - return TRUE; } return FALSE; } @@ -3893,22 +3938,29 @@ int TStampa_bilanci::stampa_intestazione_ditta() get_dati_ditta(); codice_ditta << get_firm(); - set_header (r, "Ditta %s %s %s %s %s %s", (const char*)codice_ditta, + set_header (r++, "Ditta %s %s %s %s %s %s", (const char*)codice_ditta, (const char*)_ragsoc, (const char*)_viafis, (const char*)_cap, (const char*)_comunefis, (const char*)_provfis); - r++; printer().setdate(_data); riga = "Data @> Pag. @#"; riga.right_just(_stampa_width-10); riga.overwrite (format ("Partita iva %s Codice fiscale %s", (const char*)_paiva, (const char*)_cofi)); - set_header (r, "%s", (const char*) riga); - r++; + set_header (r++, "%s", (const char*) riga); return r; } +void TStampa_bilanci::header_cdc(int& r) +{ + if (_cdc.not_empty()) + { + const TString& desc = cache().get("CMS", _cdc, "S0"); + set_header(r++, "@bCommessa %s - %s", (const char*)_cdc, (const char*)desc); + } +} + void TStampa_bilanci::preprocess_header() { int r; @@ -3943,7 +3995,8 @@ void TStampa_bilanci::preprocess_header() set_header(r,"@84gEsercizio %s %s", (const char*)d1, (const char*)d2); /**/ } r++; - riga.fill('-'); + header_cdc(r); + riga.fill('_'); set_header(r, (const char*)riga); r++; riga = ""; @@ -4005,8 +4058,8 @@ void TStampa_bilanci::preprocess_header() set_header(r,"@107gConti con saldo <> 0"); } r++; - - riga.fill('-'); + header_cdc(r); + riga.fill('_'); set_header(r, (const char*)riga); r++; diff --git a/cg/cg1500.h b/cg/cg1500.h index aa4859617..56ea4733a 100755 --- a/cg/cg1500.h +++ b/cg/cg1500.h @@ -24,6 +24,10 @@ #define F_QUADRATURA 123 #define F_SEPARATOR 124 #define F_PICTURE 125 +#define F_DACDC 126 +#define F_DACDC_DES 127 +#define F_ACDC 128 +#define F_ACDC_DES 129 #endif // __CG1500_H diff --git a/cg/cg1500a.uml b/cg/cg1500a.uml index 77118eb27..73ad2e309 100755 --- a/cg/cg1500a.uml +++ b/cg/cg1500a.uml @@ -1,6 +1,6 @@ #include "cg1500.h" -TOOLBAR "" 0 20 0 2 +TOOLBAR "" 0 -2 0 2 BUTTON DLG_OK 10 2 BEGIN @@ -60,7 +60,7 @@ END RADIOBUTTON F_BILANCIO 37 BEGIN - PROMPT 2 5 "Tipo bilancio " + PROMPT 2 5 "@bTipo bilancio" HELP "Indicare il tipo di bilancio da stampare" ITEM "1|Bilancio a sezioni contrapposte" MESSAGE HIDE,F_STAMPA1|RESET,F_STAMPA1|HIDE,F_VERIFICA|RESET,F_VERIFICA @@ -82,24 +82,24 @@ END RADIOBUTTON F_STAMPA 28 BEGIN - PROMPT 41 5 "Tipo stampa " + PROMPT 41 5 "@bTipo stampa" HELP "Indicare il tipo di stampa" ITEM "1|Per date limite" - MESSAGE SHOW,F_DATALIM|SHOW,F_TOTALI|SHOW,F_CODICI|SHOW,F_SALDO + MESSAGE SHOW,F_DATALIM|SHOW,F_TOTALI|SHOW,F_CODICI|SHOW,F_SALDO|ENABLE,4@ ITEM "2|All'ultima immissione" - MESSAGE HIDE,F_DATALIM|RESET,F_DATALIM + MESSAGE HIDE,F_DATALIM|RESET,F_DATALIM|CLEAR,4@ MESSAGE SHOW,F_TOTALI|SHOW,F_CODICI|SHOW,F_SALDO END RADIOBUTTON F_STAMPA1 28 BEGIN - PROMPT 40 5 "Tipo stampa " + PROMPT 40 5 "@bTipo stampa" //FLAGS "G" HELP "Indicare il tipo di stampa" ITEM "1|Per date limite" - MESSAGE SHOW,F_VERIFICA|SHOW,F_MODULO|SHOW,F_STAMPAMPROV + MESSAGE SHOW,F_VERIFICA|SHOW,F_MODULO|SHOW,F_STAMPAMPROV|ENABLE,4@ ITEM "2|All'ultima immissione" - MESSAGE SHOW,F_VERIFICA|SHOW,F_MODULO|SHOW,F_STAMPAMPROV + MESSAGE SHOW,F_VERIFICA|SHOW,F_MODULO|SHOW,F_STAMPAMPROV|CLEAR,4@ MESSAGE COPY,F_STAMPA END @@ -187,13 +187,69 @@ BEGIN PROMPT 2 13 "Quadratura con Libro Giornale" END +GROUPBOX DLG_NULL 73 4 +BEGIN + PROMPT 2 14 "@bCentri di costo" + GROUP 4 +END + +STRING F_DACDC 20 +BEGIN + PROMPT 3 15 "Da " + FLAGS "UZ" + USE CMS + INPUT CODTAB F_DACDC + DISPLAY "Codice@20" CODTAB + DISPLAY "Descrizione@70" S0 + OUTPUT F_DACDC CODTAB + OUTPUT F_DACDC_DES S0 + CHECKTYPE SEARCH + GROUP 4 +END + +STRING F_DACDC_DES 70 41 +BEGIN + PROMPT 30 15 "" + USE CMS KEY 2 + INPUT S0 F_DACDC_DES + DISPLAY "Descrizione@70" S0 + DISPLAY "Codice@20" CODTAB + COPY OUTPUT F_DACDC + CHECKTYPE SEARCH + GROUP 4 +END + +STRING F_ACDC 20 +BEGIN + PROMPT 3 16 "A " + FLAGS "UZ" + COPY USE F_DACDC + INPUT CODTAB F_ACDC + COPY DISPLAY F_DACDC + OUTPUT F_ACDC CODTAB + OUTPUT F_ACDC_DES S0 + CHECKTYPE SEARCH + GROUP 4 +END + +STRING F_ACDC_DES 70 41 +BEGIN + PROMPT 30 16 "" + COPY USE F_DACDC_DES + INPUT S0 F_ACDC_DES + COPY DISPLAY F_DACDC_DES + COPY OUTPUT F_ACDC + CHECKTYPE SEARCH + GROUP 4 +END + ENDPAGE PAGE "Parametri bilancio di verifica" -1 -1 74 20 RADIOBUTTON F_VERIFICA 27 BEGIN - PROMPT 2 1 "Stampa bilancio di verifica " + PROMPT 2 1 "@bStampa bilancio di verifica " HELP "Tipo di bilancio di verifica" ITEM "1|Bilancio" ITEM "2|Saldi di mastro" @@ -202,14 +258,14 @@ END RADIOBUTTON F_STAMPAC 36 BEGIN - PROMPT 34 1 "Tipo stampa " + PROMPT 34 1 "@bTipo stampa" ITEM "1|Conti movimentati" ITEM "2|Conti con saldo diverso da zero" END RADIOBUTTON F_STAMPAV 36 BEGIN - PROMPT 34 1 "Tipo stampa " + PROMPT 34 1 "@bTipo stampa " ITEM "1|Conti movimentati" ITEM "2|Conti con saldo diverso da zero" ITEM "3|Tutti i conti" diff --git a/cg/cg2100.cpp b/cg/cg2100.cpp index 80f3a9f81..640483478 100755 --- a/cg/cg2100.cpp +++ b/cg/cg2100.cpp @@ -16,8 +16,6 @@ #include #include -#define NEW_CESP 1 - /////////////////////////////////////////////////////////// // Dati incasso immediato /////////////////////////////////////////////////////////// @@ -86,7 +84,7 @@ TMask* TPrimanota_application::load_mask(int n) m->set_handler(F_FORNITORE, clifo_handler); m->set_handler(F_RITFIS, ritfis_handler); m->set_handler(F_RITSOC, ritsoc_handler); - m->set_handler(F_CORRLIRE, corrlire_handler); + m->set_handler(F_CORRISPETTIVO, corrlire_handler); m->set_handler(F_CORRVALUTA, corrvaluta_handler); m->set_handler(F_CODIVA, main_codiva_handler); m->set_handler(F_OCCASEDIT, occas_handler); @@ -107,6 +105,15 @@ TMask* TPrimanota_application::load_mask(int n) ism.set_handler(209, sheet_clifo_handler); ism.set_handler(309, sheet_clifo_handler); + // Controlla gestione commesse ed eventualmente elimina colonne relative + if (has_module(CMAUT, CHK_DONGLE)) + ism.set_handler(112, fase_handler); + else + { + ism.hide(111); ism.hide(112); + is.delete_column(112); is.delete_column(111); + } + // Se esiste lo sheet delle rate if (is_fattura()) { @@ -165,10 +172,13 @@ TMask* TPrimanota_application::load_mask(int n) cgm.set_handler(213, sheet_clifo_handler); cgm.set_handler(313, sheet_clifo_handler); - if (!fexist("batbcdc.msk")) + // Controlla gestione commesse ed eventualmente elimina colonne relative + if (has_module(CMAUT, CHK_DONGLE)) + cgm.set_handler(CG_FASE, fase_handler); + else { - cgm.hide(CG_CDC); - cg.delete_column(CG_CDC); + cgm.hide(CG_COMMESSA); cgm.hide(CG_FASE); + cg.delete_column(CG_FASE); cg.delete_column(CG_COMMESSA); } } break; @@ -484,9 +494,10 @@ void TPrimanota_application::init_mask(TMask& m) } m.show(-1, clig); m.show(-2, forg); - if (corrisp) m.hide(F_STATOPAIV); + if (corrisp) + m.hide(F_STATOPAIV); - // Show/Hide campi valuta: F_VALUTAINTRA, F_CAMBIOINTRA, F_CORRLIRE, F_CORRVAL (GROUP 4) + // Show/Hide campi valuta: F_VALUTAINTRA, F_CAMBIOINTRA, F_CORRISPETTIVO, F_CORRVAL (GROUP 4) m.show(-4, causale().valintra()); if (causale().soloiva()) m.set(F_SOLAIVA, "X", TRUE); // Propone movimento di sola iva @@ -757,7 +768,7 @@ int TPrimanota_application::read(TMask& m) const TRectype& r = _rel->cg(i); TToken_string& riga = cgs().row(i); // Vuota la riga - TImporto import(r.get_char("SEZIONE"), r.get_real("IMPORTO")); + TImporto import(r.get_char(RMV_SEZIONE), r.get_real(RMV_IMPORTO)); import.add_to(riga, 0); // Dare/Avere 101-102 TBill conto; conto.get(r); @@ -766,13 +777,15 @@ int TPrimanota_application::read(TMask& m) _saldi.aggiorna(conto, import, FALSE); riga.add(""); // Codice descrizione 108 - riga.add(r.get("DESCR")); // Descrizione riga 109 + riga.add(r.get(RMV_DESCR)); // Descrizione riga 109 conto.get(r, TRUE); riga.add(conto.string(0x3)); // Contropartita 110-114 - riga.add(r.get("NUMGIO")); // Centro di costo 115 - const char tipo = r.get_char("ROWTYPE"); - riga.add(tipo); // Tipo di riga 116 + riga.add(r.get(RMV_CODCMS)); // Commessa 115 + riga.add(r.get(RMV_FASCMS)); // Fase 116 + + const char tipo = r.get_char(RMV_ROWTYPE); + riga.add(tipo, CG_ROWTYPE-FIRST_FIELD); // Tipo di riga 117 disable_cgs_cells(i, tipo); } @@ -805,14 +818,14 @@ int TPrimanota_application::read(TMask& m) TRectype& r = _rel->iva(i); TToken_string& riga = ivas().row(i); - real imponibile(r.get("IMPONIBILE")); + real imponibile(r.get(RMI_IMPONIBILE)); if (to_swap) imponibile = -imponibile; riga.add(imponibile.string()); // Imponibile 101 - riga.add(r.get("CODIVA")); // IVA 102 - riga.add(r.get("TIPODET")); // Detrazione 103 + riga.add(r.get(RMI_CODIVA)); // IVA 102 + riga.add(r.get(RMI_TIPODET)); // Detrazione 103 - real imposta(r.get("IMPOSTA")); + real imposta(r.get(RMI_IMPOSTA)); if (to_swap) imposta = -imposta; if (imponibile.sign() * imposta.sign() < 0) { @@ -820,10 +833,12 @@ int TPrimanota_application::read(TMask& m) "assegnato il segno dell'imponibile"); imposta = -imposta; } - riga.add(imposta.string()); // Imposta 104 + riga.add(imposta.string()); // Imposta 104 TBill c; c.get(r); c.add_to(riga, 4, 0x7); // Conto 105-110 + riga.add(r.get(RMI_CODCMS)); // Commessa 111 + riga.add(r.get(RMI_FASCMS)); // Fase 112 } calcola_imp(); // Calcola totale imponibile ed imposte @@ -892,27 +907,28 @@ void TPrimanota_application::mask2rel(const TMask& m) TRectype &r = _rel->cg(i); r.zero(); - r.put("NUMREG", numreg); // Numero registrazione - r.put("ANNOES", annoes); // Anno esercizio - r.put("DATAREG", datareg); // Data di registrazione - r.put("NUMRIG", i+1); // Numero riga + r.put(RMV_NUMREG, numreg); // Numero registrazione + r.put(RMV_ANNOES, annoes); // Anno esercizio + r.put(RMV_DATAREG, datareg); // Data di registrazione + r.put(RMV_NUMRIG, i+1); // Numero riga - r.put("SEZIONE", n.sezione()); // Sezione - r.put("IMPORTO", n.valore()); // Importo - conto.put(r); // Conto + r.put(RMV_SEZIONE, n.sezione()); // Sezione + r.put(RMV_IMPORTO, n.valore()); // Importo + conto.put(r); // Conto - row.get(); // Codice descrizione (ignorato) - const char* descr = row.get(); // Descrizione aggiuntiva - if (i > 0 || m.get(F_DESCR) != descr) // Salva la prima descrizione se diversa da testata - r.put("DESCR", descr); // Descrizione riga + row.get(); // Codice descrizione (ignorato) + const char* descr = row.get(); // Descrizione aggiuntiva + if (i > 0 || m.get(F_DESCR) != descr) // Salva la prima descrizione se diversa da testata + r.put(RMV_DESCR, descr); // Descrizione riga - r.put("TIPOCC", row.get()); // Contropartita - r.put("GRUPPOC", row.get()); - r.put("CONTOC", row.get()); - r.put("SOTTOCONTC", row.get()); - row.get(); // Descrizione contropartita - r.put("NUMGIO", row.get()); // Numero riga giornale - r.put("ROWTYPE", row.get()); // Tipo riga + r.put(RMV_TIPOCC, row.get()); // Contropartita + r.put(RMV_GRUPPOC, row.get()); + r.put(RMV_CONTOC, row.get()); + r.put(RMV_SOTTOCONTOC, row.get()); + row.get(); // Descrizione contropartita + r.put(RMV_CODCMS, row.get()); // Commessa + r.put(RMV_FASCMS, row.get()); // Fase + r.put(RMV_ROWTYPE, row.get()); // Tipo riga } } @@ -983,33 +999,36 @@ void TPrimanota_application::mask2rel(const TMask& m) TRectype &r = _rel->iva(i); r.zero(); - r.put("NUMREG", numreg); - r.put("NUMRIG", i+1); + r.put(RMI_NUMREG, numreg); + r.put(RMI_NUMRIG, i+1); - r.put("ANNOES", annoes); // Anno d'esercizio della testata (che ca$$ata!) - r.put("INTRA", intra); // Causale intra (che ca$$ata!) + r.put(RMI_ANNOES, annoes); // Anno d'esercizio della testata (che ca$$ata!) + r.put(RMI_INTRA, intra); // Causale intra (che ca$$ata!) real imponibile(row.get(0)); if (to_swap) imponibile = -imponibile; - r.put("IMPONIBILE", imponibile); + r.put(RMI_IMPONIBILE, imponibile); - r.put("CODIVA", row.get()); - r.put("TIPODET", row.get()); + r.put(RMI_CODIVA, row.get()); + r.put(RMI_TIPODET, row.get()); real imposta(row.get()); if (to_swap) imposta = -imposta; - r.put("IMPOSTA", imposta); + r.put(RMI_IMPOSTA, imposta); - r.put("TIPOCR", row.get()); - - const TBill c(row, -1, 0x1); - const int rimp = bill2pos(c, 'I')+1; - r.put("RIGAIMP", rimp); + r.put(RMI_TIPOCR, row.get()); + r.put(RMI_CODCMS, row.get(10)); + r.put(RMI_FASCMS, row.get(11)); + + // Roba obsoleta allo stato brado + const TClinton c(row, TRUE); + const int rimp = clint2pos(c, 'I')+1; + r.put(RMI_RIGAIMP, rimp); c.put(r); + } } - void TPrimanota_application::check_saldi() { TString_array& rows = cgs().rows_array(); @@ -1438,6 +1457,13 @@ HIDDEN void ini2bill(TConfig& ini, TBill& bil, bool contro) bil.set(gruppo, conto, sottoconto, tipo); } +HIDDEN void ini2clinton(TConfig& ini, TClinton& bil) +{ + ini2bill(ini, bil, FALSE); + bil.set_commessa(ini.get("CODCMS")); + bil.set_fase(ini.get("FASCMS")); +} + HIDDEN bool set_not_empty(TMask& msk, int id, TConfig& ini, const char* var) { const TString& val = ini.get(var); @@ -1501,7 +1527,7 @@ void TPrimanota_application::ini2mask(TConfig& ini, TMask& msk, bool query) char tipo = ini.get_char(RMV_ROWTYPE); if (tipo == '\0') tipo = ' '; - TBill conto; ini2bill(ini, conto, FALSE); + TClinton conto; ini2clinton(ini, conto); int numrig = -1; // Normalmente aggiungi la riga in fondo @@ -1509,7 +1535,7 @@ void TPrimanota_application::ini2mask(TConfig& ini, TMask& msk, bool query) if (strchr(" DINT", tipo) != NULL) { if (tipo == 'I' || tipo == ' ') - numrig = bill2pos(conto, tipo); + numrig = clint2pos(conto, tipo); else numrig = type2pos(tipo); if (numrig < 0) @@ -1538,8 +1564,10 @@ void TPrimanota_application::ini2mask(TConfig& ini, TMask& msk, bool query) if (conto.gruppo() > 0) conto.add_to(riga, 9, 0x3); // Contropartita 110-114 - riga.add(ini.get(RMV_NUMGIO), 14); // Centro di costo 115 - riga.add(tipo, 15); // Tipo di riga 116 + riga.add(ini.get(RMV_CODCMS), 14); // Commessa 115 + riga.add(ini.get(RMV_FASCMS), 15); // Fase 116 + + riga.add(tipo, 16); // Tipo di riga 116 } if (is_fattura()) @@ -1569,20 +1597,6 @@ void TPrimanota_application::mask2ini(const TMask& msk, TConfig& ini) { TRelation_application::mask2ini(msk, ini); -#ifndef NEW_CESP - const char mov_cesp = causale().link_cespiti(); - if (mov_cesp > ' ') - { - const char str_cesp[2] = { mov_cesp, '\0' }; - ini.set_paragraph(format("%d", LF_MOV)); - ini.set("MOVCESP", str_cesp); - ini.set("DESCRCAUS", msk.get(F_DESCRCAUS)); - const TEsercizio& annoes = _esercizi[msk.get_int(F_ANNOES)]; - ini.set("INIZIOES", annoes.inizio()); - ini.set("FINEES", annoes.fine()); - } -#endif - int i, f; for (i = 0; i < _rel->cg_items(); i++) { @@ -1592,19 +1606,9 @@ void TPrimanota_application::mask2ini(const TMask& msk, TConfig& ini) for (f = rec.items()-1; f >= 0; f--) { const char* name = rec.fieldname(f); - if (strcmp(name,RMV_NUMGIO) == 0) - continue; // Non scrive il codice del centro di costo ini.set(name, rec.get(name)); } -#ifndef NEW_CESP - const TBill zio(rec); - ini.set("DESCRCONTO", zio.descrizione()); - ini.set("TIPOCR", zio.tipo_cr()); - - const TBill french(rec, TRUE); - ini.set("DESCRCONTOC", french.descrizione()); -#endif } for ( ; ; i++) { @@ -1676,13 +1680,8 @@ bool TPrimanota_application::link_cesp(const TMask& msk, const char* action) return FALSE; // Controlla l'esistenza del programma cespiti -#ifdef NEW_CESP if (!fexist("ce1.exe")) return FALSE; -#else - if (!fexist("cespcg.exe")) - return FALSE; -#endif // Cerca una riga con tipo costo/ricavo 2,3,4,8 for (int i = _rel->cg_items()-1; i >= 0; i--) @@ -1708,15 +1707,10 @@ bool TPrimanota_application::link_cesp(const TMask& msk, const char* action) } TString appname; -#ifdef NEW_CESP appname << "ce1 -4 /c" << cespini; TExternal_app app(appname); bool ok = app.run(); -#else - appname << "cespcg -t /i" << cespini; - TExternal_app app(appname); - bool ok = app.run(FALSE, 0x3) == 0; // Force user name! -#endif + return ok; } @@ -1752,10 +1746,10 @@ bool TPrimanota_application::link_intra(const TMask& m, const char* action) intro.set("Action", action); TString str; // Stringa jolly di lavoro - str.format("%d", LF_INTRA); intro.set_paragraph(str); intro.set("NUMREG", m.get(F_NUMREG)); + if (m.field(F_CLIENTE).shown()) { intro.set("TIPOMOV", "C"); @@ -1768,13 +1762,22 @@ bool TPrimanota_application::link_intra(const TMask& m, const char* action) intro.set("TIPOCF", "F"); intro.set("CODCF", m.get(F_FORNITORE)); } - intro.set("TOTDOC", m.get(F_TOTALE)); - intro.set("CODVAL", m.get(F_VALUTAINTRA)); + + const TString& codval = m.get(F_VALUTAINTRA); + intro.set("CODVAL", codval); intro.set("CAMBIO", m.get(F_CAMBIOINTRA)); intro.set("DATAREG", m.get(F_DATAREG)); - intro.set("NUMDOC", m.get(F_NUMDOC)); - + // Inserisci il totale documento solo in inserimento! + if (action == "Insert") + { + real totdoc = m.get(codval.empty() ? F_IMPONIBILI : F_CORRISPETTIVO); + if (test_swap(FALSE)) + totdoc = -totdoc; + intro.set("TOTDOC", totdoc.string()); + } + else + intro.remove("TOTDOC"); // Evita di cambiare il valore preesistente intro.set_paragraph(""); // Flush diff --git a/cg/cg2100.h b/cg/cg2100.h index 671e15c60..87a79d2ef 100755 --- a/cg/cg2100.h +++ b/cg/cg2100.h @@ -41,7 +41,7 @@ #define F_PROVVISORIO 129 #define F_OCCASEDIT 131 #define F_SOLAIVA 132 -#define F_CORRLIRE 133 +#define F_CORRISPETTIVO 133 #define F_CORRVALUTA 134 #define F_DATA74TER 135 #define F_DESCAGG 136 @@ -68,8 +68,9 @@ #define CG_CONTO 105 #define CG_SOTTOCONTO 106 #define CG_DESCR 109 -#define CG_CDC 115 -#define CG_ROWTYPE 116 +#define CG_COMMESSA 115 +#define CG_FASE 116 +#define CG_ROWTYPE 117 // Campi ripetuti sulla seconda pagina diff --git a/cg/cg2100b.uml b/cg/cg2100b.uml index b7a283457..999b443e5 100755 --- a/cg/cg2100b.uml +++ b/cg/cg2100b.uml @@ -354,7 +354,8 @@ BEGIN ITEM "Co./c@3" ITEM "Sott./c@6" ITEM "Descrizione contropartita@30" - ITEM "*******" + ITEM "Commessa@20" + ITEM "Fase@10" ITEM "Tipo@4" END @@ -376,4 +377,4 @@ ENDMASK #include "cg21cg.uml" - z + diff --git a/cg/cg2100c.uml b/cg/cg2100c.uml index 9eab34f1f..6b9de3d72 100755 --- a/cg/cg2100c.uml +++ b/cg/cg2100c.uml @@ -550,7 +550,7 @@ BEGIN PICTURE ".6" END -CURRENCY F_CORRLIRE 18 +CURRENCY F_CORRISPETTIVO 18 BEGIN PROMPT 1 18 "Corrispettivo " FIELD CORRLIRE @@ -617,7 +617,9 @@ BEGIN ITEM "Gr." ITEM "Co." ITEM "Sottoc.@6" - ITEM "Descrizione Conto@50" + ITEM "Descrizione Conto@30" + ITEM "Commessa@20" + ITEM "Fase@10" END CURRENCY F_IMPONIBILI 18 @@ -649,7 +651,8 @@ BEGIN ITEM "Co./c@3" ITEM "Sott./c@6" ITEM "Descrizione contropartita@30" - ITEM "*******" + ITEM "Commessa@20" + ITEM "Fase@10" ITEM "Tipo@4" END diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index bf2ccdeb1..e1b47ab15 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -13,10 +13,32 @@ #include #include +int TClinton::compare(const TSortable& obj) const +{ + int cmp = TBill::compare(obj); + if (cmp == 0) + { + const TClinton& bill = (const TClinton&)obj; + cmp = _cms.compare(bill.commessa()); + if (cmp == 0) + cmp = _fas.compare(bill.fase()); + } + return cmp; +} + +TClinton::TClinton(TToken_string& row, bool iva) + : TBill(row, iva ? 6 : 3, 0x0) +{ + set_commessa(row.get((iva ? 111 : CG_COMMESSA) - FIRST_FIELD)); + set_fase(row.get((iva ? 112 : CG_FASE) - FIRST_FIELD)); +} + + /////////////////////////////////////////////////////////// // Funzioni di decodifica/calcolo /////////////////////////////////////////////////////////// +// Determina il tipo di una riga contabile in formato TToken_string char TPrimanota_application::row_type(const TToken_string& s) { const int l = s.len()-1; @@ -155,7 +177,6 @@ int TPrimanota_application::type2pos(char tipo) return -1; } - // Trova nelle righe contabili un conto nelle righe di tipo prescelto int TPrimanota_application::bill2pos(const TBill& conto, char tipo) { @@ -175,6 +196,29 @@ int TPrimanota_application::bill2pos(const TBill& conto, char tipo) return -1; } +int TPrimanota_application::clint2pos(const TClinton& conto, char tipo) +{ + int r = bill2pos(conto, tipo); + if (r >= 0 && conto.commessa().not_empty()) + { + TString_array& cg = app().cgs().rows_array(); + const int num_rows = cg.items(); + for (int i = r ; i < num_rows; i++) + { + TToken_string& s = cg.row(i); + const char t = row_type(s); + if (t == tipo) + { + const TClinton c(s, FALSE); + if (c == conto) + return i; + } + } + r = -1; + } + return r; +} + // Trova nelle righe contabili un conto di contropartita per il conto dato int TPrimanota_application::bill2contr(const TBill& conto, char sezione) const @@ -196,7 +240,6 @@ int TPrimanota_application::bill2contr(const TBill& conto, char sezione) const return -1; } - // Controlla se un conto e' usato nelle righe IVA int TPrimanota_application::bill_used(const TBill& conto) const { @@ -350,6 +393,12 @@ void TPrimanota_application::disable_cgs_cells(int n, char tipo) cg.disable_cell(n, i); needs_update = TRUE; } + + if (cg.cell_disabled(n, 5)) // Se disabilito il sottoconto alloro spengo anche le commesse + { + cg.disable_cell(n, CG_COMMESSA); // Commessa + cg.disable_cell(n, CG_FASE); // Fase + } COLOR back_color, fore_color; type2colors(tipo, back_color, fore_color); @@ -371,7 +420,7 @@ void TPrimanota_application::reset_sheet_row(TSheet_field& s, int n) int TPrimanota_application::set_cgs_row(int n, const TImporto& imp, TBill& conto, const char* desc, - char tipo) + char tipo, const char* cms, const char* fas) { TSheet_field& cg = cgs(); if (n < 0) n = cg.first_empty(); @@ -404,7 +453,9 @@ int TPrimanota_application::set_cgs_row(int n, const TImporto& imp, row.add(" | | | | "); } - row << "| |" << tipo; + row.add(cms, CG_COMMESSA-FIRST_FIELD); + row.add(fas, CG_FASE-FIRST_FIELD); + row.add(tipo, CG_ROWTYPE-FIRST_FIELD); disable_cgs_cells(n, tipo); @@ -1033,7 +1084,6 @@ bool TPrimanota_application::descr_handler(TMask_field& f, KEY k) return TRUE; } - // Handler per le colonne 'Dare' e 'Avere' dello sheet contabile. // Scrivendo qualcosa in dare (101) cancella l'importo in avere (102) e viceversa bool TPrimanota_application::dareavere_handler(TMask_field& f, KEY k) @@ -1081,6 +1131,19 @@ bool TPrimanota_application::dareavere_handler(TMask_field& f, KEY k) return TRUE; } +// La fase puo' esistere solo con la commessa +bool TPrimanota_application::fase_handler(TMask_field& f, KEY k) +{ + bool ok = TRUE; + if (f.to_check(k) && !f.empty()) + { + const TEdit_field& cms_fld = f.mask().efield(f.dlg()-1); + if (cms_fld.empty()) + ok = f.error_box("E' necessario specificare anche la commessa"); + } + return ok; +} + TSheet_field& TPrimanota_application::pags() const { CHECK(is_fattura(), "Can't use rate sheet without a fattura"); @@ -1209,10 +1272,11 @@ bool TPrimanota_application::detrazione_handler(TMask_field& f, KEY key) // Certified 90% bool TPrimanota_application::imposta_handler(TMask_field& f, KEY key) { + TMask& m = f.mask(); if ((key == K_ENTER || key == K_TAB) && f.dirty()) { - const real imponibile(f.mask().get(101)); - const real percent = app().causale().corrispettivi() ? ZERO : cod2IVA(f.mask()); + const real imponibile(m.get(101)); + const real percent = app().causale().corrispettivi() ? ZERO : cod2IVA(m); const int dec = TCurrency::get_firm_dec(); real imposta; if (dec == 0) @@ -1239,9 +1303,8 @@ bool TPrimanota_application::imposta_handler(TMask_field& f, KEY key) real imposta(f.get()); if (imposta.is_zero()) { - TMask& m = f.mask(); real imponibile(m.get(101)); - const real& percent = cod2IVA(f.mask()); + const real& percent = cod2IVA(m); imposta = scorpora(imponibile, percent); m.set(101, imponibile); f.set(imposta.string()); @@ -1364,14 +1427,14 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k) } } - TBill oldconto(row, 6, 0x0); // g/c/s 6 7 8 + TClinton oldconto(row, TRUE); if (oldconto.ok()) { - oldpos = bill2pos(oldconto, 'I'); + oldpos = clint2pos(oldconto, 'I'); if (oldpos < 0) { const TString d(cau.desc_agg(2)); - oldpos = a.set_cgs_row(-1, a.real2imp(ZERO, 'I'), oldconto, d, 'I'); + oldpos = a.set_cgs_row(-1, a.real2imp(ZERO, 'I'), oldconto, d, 'I', oldconto.commessa(), oldconto.fase()); } } else @@ -1392,7 +1455,8 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k) i -= oldimp; i.normalize(); a.set_cgs_imp(oldpos, i); - if (i.is_zero()) delimp = oldpos; + if (i.is_zero()) + delimp = oldpos; } if (oldposiva >= 0) // Se conto IVA esisteva anche prima ... { // sottrai la vecchia imposta @@ -1400,7 +1464,8 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k) i -= oldiva; i.normalize(); a.set_cgs_imp(oldposiva, i); - if (i.is_zero()) deliva = oldposiva; + if (i.is_zero()) + deliva = oldposiva; } real imponibile(row.get(0)); // Nuovo imponibile @@ -1413,14 +1478,14 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k) imposta = i.scorpora(imponibile); // ... scorpora imposta dall'imponibile } - TBill conto(row, 5, 0x3); - int newpos = bill2pos(conto, 'I'); // Riga in cui andra' l'imponibile + TClinton conto(row, TRUE); + int newpos = clint2pos(conto, 'I'); // Riga in cui andra' l'imponibile const bool detrarre = detraibile(row); // Determina se IVA detraibile // Calcola riga causale col conto opportuno const int ri = detrarre ? RIGA_IVA_DETRAIBILE : RIGA_IVA_NON_DETRAIBILE; - TBill contoiva; cau.bill(ri, contoiva); + TBill contoiva; cau.bill(ri, contoiva); if (!detrarre && !contoiva.ok()) // Se non c'e' il conto IVA indetraibile ... { // ... somma imponibile e imposta @@ -1434,16 +1499,19 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k) // Aggiorna conto sulla riga contabile if (newpos < 0) { + TString descr; if (delimp >= 0) { + TSheet_field& s = a.cgs(); + descr = s.row(delimp).get(8); // Memorizza vecchia descrizione a.reset_cgs_row(delimp); // Cancella vecchia riga if (deliva > delimp) deliva--; } - - if (conto.ok() && !newimp.is_zero()) // Se c'e' imponibile ... + if (conto.ok() && !newimp.is_zero()) // Se c'e' imponibile ... { // crea una nuova riga contabile - const TString d(cau.desc_agg(2)); - a.set_cgs_row(-1, newimp, conto, d, 'I'); + if (descr.blank()) + descr = cau.desc_agg(2); + newpos = a.set_cgs_row(-1, newimp, conto, descr, 'I', conto.commessa(), conto.fase()); } } else @@ -2132,7 +2200,12 @@ void TPrimanota_application::add_cgs_tot(TMask& m) { // Creazione/Aggiornamento riga totale const real tot(m.get(F_TOTALE)); - set_cgs_row(riga_totale, real2imp(tot, 'T'), nuovo, m.get(F_DESCR), 'T'); + TString descr; + if (riga_totale >= 0) + descr = cgs().row(riga_totale).get(8); + if (descr.blank()) + descr = m.get(F_DESCR); + set_cgs_row(riga_totale, real2imp(tot, 'T'), nuovo, descr, 'T'); } calcola_imp(); // Ricalcola totale IVA @@ -2268,6 +2341,8 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key) const bool occas = clifo.get_bool(CLI_OCCAS); m.show(F_OCCASEDIT, occas); // Bottone Dati anagrafici m.show(F_STATOPAIV, !occas); // Stato partita IVA + if (!occas) + m.set(F_STATOPAIV, clifo.get(CLI_STATOPAIV)); m.show(cf == 'C' ? F_PIVACLIENTE : F_PIVAFORNITORE, !occas); // Partita IVA m.show(cf == 'C' ? F_COFICLIENTE : F_COFIFORNITORE, !occas); // Codice Fiscale @@ -2620,7 +2695,7 @@ bool TPrimanota_application::corrlire_handler(TMask_field& f, KEY key) bool TPrimanota_application::corrvaluta_handler(TMask_field& f, KEY key) { TMask& m = f.mask(); - TMask_field& cl = m.field(F_CORRLIRE); + TMask_field& cl = m.field(F_CORRISPETTIVO); if (key == K_TAB && f.focusdirty()) { diff --git a/cg/cg2102.h b/cg/cg2102.h index 57f738955..e7cf72b6e 100755 --- a/cg/cg2102.h +++ b/cg/cg2102.h @@ -27,6 +27,23 @@ class TDati_incasso; +class TClinton : public TBill +{ + TString _cms, _fas; + +public: + virtual int compare(const TSortable& obj) const; + +public: + void set_commessa(const char* cms) { _cms = cms; _cms.rtrim(); } + void set_fase(const char* fas) { _fas = fas; _fas.rtrim(); } + const TString& commessa() const { return _cms; } + const TString& fase() const { return _fas; } + + TClinton() { } + TClinton(TToken_string& row, bool iva = FALSE); +}; + class TPrimanota_application : public TRelation_application { TMovimentoPN* _rel; // Relazione principale @@ -114,6 +131,7 @@ class TPrimanota_application : public TRelation_application static bool codiva_handler(TMask_field& f, KEY key); static bool imposta_handler(TMask_field& f, KEY key); static bool dareavere_handler(TMask_field& f, KEY k); + static bool fase_handler(TMask_field& f, KEY key); static bool cg_gruppo_handler(TMask_field& f, KEY key); static bool cg_conto_handler(TMask_field& f, KEY key); @@ -200,6 +218,7 @@ protected: static real scorpora(real& imponibile, const real& percentuale); static bool detraibile(TToken_string& row); static int bill2pos(const TBill& conto, char tipo); + static int clint2pos(const TClinton& conto, char tipo); TipoIVA cau2IVA(const char* causale, int anno); bool IVA2bill(const TCodiceIVA& iva, TBill& bill); @@ -227,7 +246,8 @@ protected: real calcola_imp() const; void add_cgs_tot(TMask& m); - int set_cgs_row(int n, const TImporto& importo, TBill& conto, const char* desc, char tipo); + int set_cgs_row(int n, const TImporto& importo, TBill& conto, const char* desc, char tipo, + const char* cms = NULL, const char* fas = NULL); void set_cgs_imp(int n, const TImporto& importo); bool add_cgs_imp(int n, const TImporto& importo); bool sub_cgs_imp(int n, const TImporto& importo); diff --git a/cg/cg2104.cpp b/cg/cg2104.cpp index 932d89ad6..1721a44bf 100755 --- a/cg/cg2104.cpp +++ b/cg/cg2104.cpp @@ -1149,6 +1149,7 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa } + // Importo della contropartita if (!new_importo.is_zero() && new_conto.ok()) { @@ -1373,4 +1374,4 @@ bool TPrimanota_application::notify_cgline_deletion(int numrig) found |= notify_cgline_deletion(*game, nreg, numrig); return found; -} +} \ No newline at end of file diff --git a/cg/cg21cg.uml b/cg/cg21cg.uml index ac1689de2..1db821910 100755 --- a/cg/cg21cg.uml +++ b/cg/cg21cg.uml @@ -313,21 +313,33 @@ BEGIN WARNING "Fornitore inesistente sulla riga contabile" END -NUMBER 115 7 +STRING CG_COMMESSA 20 BEGIN - PROMPT 2 13 "******* " + PROMPT 2 13 "Commessa " FLAGS "UZ" - USE CDC - INPUT CODTAB 115 - DISPLAY "Codice@7" CODTAB + USE CMS + INPUT CODTAB CG_COMMESSA + DISPLAY "Codice@20" CODTAB DISPLAY "Descrizione@50" S0 - OUTPUT 115 CODTAB + OUTPUT CG_COMMESSA CODTAB + CHECKTYPE NORMAL +END + +STRING CG_FASE 10 +BEGIN + PROMPT 36 13 "Fase " + FLAGS "UZ" + USE FSC + INPUT CODTAB CG_FASE + DISPLAY "Codice@10" CODTAB + DISPLAY "Descrizione@50" S0 + OUTPUT CG_FASE CODTAB CHECKTYPE NORMAL END LIST CG_ROWTYPE 24 BEGIN - PROMPT 26 13 "Tipo riga " + PROMPT 26 14 "Tipo riga " ITEM " |Sola contabilita'" ITEM "A|Abbuoni attivi" ITEM "C|Differenza cambi" @@ -347,17 +359,17 @@ BEGIN END -BUTTON DLG_OK 9 2 +BUTTON DLG_OK 10 2 BEGIN PROMPT -14 -1 "" END -BUTTON DLG_CANCEL 9 2 +BUTTON DLG_CANCEL 10 2 BEGIN PROMPT -24 -1 "" END -BUTTON DLG_DELREC 9 2 +BUTTON DLG_DELREC 10 2 BEGIN PROMPT -34 -1 "Elimina" PICTURE BMP_DELREC @@ -370,7 +382,6 @@ BEGIN PROMPT -44 -1 "~Partite" END - ENDPAGE ENDMASK diff --git a/cg/cg21iva.uml b/cg/cg21iva.uml index 5208d7cdb..0ebe8e428 100755 --- a/cg/cg21iva.uml +++ b/cg/cg21iva.uml @@ -235,17 +235,39 @@ BEGIN HELP "Tipo Costo/Ricavo del conto" END -BUTTON DLG_OK 9 2 +STRING 111 20 +BEGIN + PROMPT 2 11 "Commessa " + FLAGS "UZ" + USE CMS + INPUT CODTAB 111 + DISPLAY "Codice@20" CODTAB + DISPLAY "Decrizione@50" S0 + OUTPUT 111 CODTAB +END + +STRING 112 10 +BEGIN + PROMPT 36 11 "Fase " + FLAGS "UZ" + USE FSC + INPUT CODTAB 112 + DISPLAY "Codice@10" CODTAB + DISPLAY "Decrizione@50" S0 + OUTPUT 112 CODTAB +END + +BUTTON DLG_OK 10 2 BEGIN PROMPT -13 -1 "" END -BUTTON DLG_CANCEL 9 2 +BUTTON DLG_CANCEL 10 2 BEGIN PROMPT -23 -1 "" END -BUTTON DLG_DELREC 9 2 +BUTTON DLG_DELREC 10 2 BEGIN PROMPT -33 -1 "Elimina" PICTURE BMP_DELREC diff --git a/cg/cg3100.cpp b/cg/cg3100.cpp index 25f0925b3..77995ca82 100755 --- a/cg/cg3100.cpp +++ b/cg/cg3100.cpp @@ -105,7 +105,8 @@ class TListaMov_application : public TPrintapp liste _tipo_lista; word _flags; char _tipoc; - + TString _cdc; + bool _cdc_only; TDecoder _simbval, _descdoc; protected: @@ -118,7 +119,10 @@ protected: void init_print(const TMask& m); void print_intra(int& rr); - + + void imposta_parametri_stampa(const TMask& msk); + void set_cdc_header(int& soh); + public: bool user_create(); @@ -140,6 +144,8 @@ public: const TString& SimboloValuta (const char* cod); const TString& DescrDoc(const char* cod); + const TString& cdc() const { return _cdc; } + TListaMov_application(char tipost); virtual ~TListaMov_application() {} }; @@ -407,21 +413,6 @@ const TString& TListaMov_application::SimboloValuta(const char* cod) const TString& TListaMov_application::DescrDoc(const char* tipo) { -/* - TTable tab_tpd(TAB_TPD); - TString16 codtab; codtab.format ("%-2s", tipo); - - tab_tpd.zero(); - - tab_tpd.put("CODTAB", codtab); - tab_tpd.read(); - if (tab_tpd.good()) - TMP = tab_tpd.get("S0"); - else - TMP = ""; - - return TMP; -*/ return _descdoc.decode(tipo); } @@ -445,40 +436,48 @@ const char * AttivitaRegistro (const char * cod, int anno) int CodiceRegistro (const char* cod, int anno) { -/* - TTable tab_reg("REG"); - TString16 codtab; - codtab.format("%4d%-3s", anno, cod); - int tipo_reg; - - tab_reg.zero(); - tab_reg.put("CODTAB", codtab); - tab_reg.read(); - if (tab_reg.good()) - tipo_reg = tab_reg.get_int("I0"); - else - tipo_reg = 0; - return tipo_reg; -*/ - static TDecoder tab_reg("REG", "I0"); - TString16 codtab; codtab.format("%4d%-3s", anno, cod); - int tipo_reg = atoi(tab_reg.decode(codtab)); - return tipo_reg; + const TString& tipo_reg = cache().get("REG", codtab, "I0"); + return atoi(tipo_reg); +} + +// Controlla che il movimento abbia almeno una riga con la commessa voluta +bool cdc_filter(const TRelation* rel) +{ + bool ok = FALSE; + TLocalisamfile& rmov = rel->lfile(LF_RMOV); + const TRecnotype oldpos = rmov.recno(); + const long numreg = rel->curr(LF_MOV).get_long(MOV_NUMREG); + const TString& cdc = app().cdc(); + rmov.zero(); + rmov.put(RMV_NUMREG, numreg); + rmov.put(RMV_NUMRIG, 1); + for (int err = rmov.read(_isgteq); err == NOERR; err = rmov.next()) + { + if (rmov.get_long(RMV_NUMREG) != numreg) + break; + if (rmov.get(RMV_CODCMS) == cdc) + { + ok = TRUE; + break; + } + } + rmov.readat(oldpos); + return ok; } bool filter_func_fatture (const TRelation* rel) { - const TRectype& mov = rel->curr(LF_MOV); + const TRectype& mov = rel->curr(LF_MOV); // Altrimenti stampa anche i corrispettivi! Pseudo errore MI2396 long codcf = mov.get_long(MOV_CODCF); if (codcf <= 0) return FALSE; - int ann_reg = mov.get_int (MOV_ANNOIVA); - TString16 cod_reg = mov.get (MOV_REG); - int tipo_reg = CodiceRegistro (cod_reg, ann_reg); + const int ann_reg = mov.get_int(MOV_ANNOIVA); + const TString16 cod_reg = mov.get(MOV_REG); + const int tipo_reg = CodiceRegistro (cod_reg, ann_reg); // Considera solo iva acquisti o vendite if (tipo_reg != 1 && tipo_reg != 2) @@ -501,14 +500,16 @@ bool filter_func_fatture (const TRelation* rel) if (app()._codice_fin != 0) to.put(MOV_CODCF, app()._codice_fin); - if (mov >= from && mov <= to) - return TRUE; + bool ok = mov >= from && mov <= to; + if (ok && app().cdc().not_empty()) + ok = cdc_filter(rel); - return FALSE; + return ok; } bool filter_func (const TRelation * rel) -{ +{ + bool ok = FALSE; int tipo_reg, ann_reg; TString cod_reg, causale; TLocalisamfile* mov = &(rel->lfile(LF_MOV)); @@ -530,8 +531,7 @@ bool filter_func (const TRelation * rel) to.put(MOV_CODCAUS, app()._causale_fin); from.put(MOV_REG, app()._registro_ini); to.put(MOV_REG, app()._registro_fin); - if ((mov->curr() >= from) && (mov->curr() <= to)) - return TRUE; + ok = (mov->curr() >= from) && (mov->curr() <= to); break; case 1: cod_reg = mov->get (MOV_REG); @@ -548,16 +548,17 @@ bool filter_func (const TRelation * rel) from.put(MOV_CODCAUS, app()._causale_ini); to.put(MOV_CODCAUS, app()._causale_fin); - if (((mov->curr() >= from) && (mov->curr() <= to)) && - ((tipo_reg != 1) && (tipo_reg != 2))) - return TRUE; - + ok = ((mov->curr() >= from) && (mov->curr() <= to)) && + ((tipo_reg != 1) && (tipo_reg != 2)); break; - default: break; } - return FALSE; + + if (ok && app().cdc().not_empty()) + ok = cdc_filter(rel); + + return ok; } void TListaMov_application::stampa_errori_rmov() @@ -755,6 +756,20 @@ void TListaMov_application::set_page(int file, int count) if (file == LF_RMOV) { _nr = 1; + if (_cdc.not_empty()) + { + const TRectype& rec = current_cursor()->curr(LF_RMOV); + if (rec.get(RMV_CODCMS) == _cdc) + { + if (!_cdc_only) + set_row(_nr,"@0g@b"); // Grassettiamo le righe interessate + } + else + { + if (_cdc_only) + return; + } + } set_row(_nr,"@3n",FLD(LF_RMOV,RMV_NUMRIG)); set_row(_nr,"@30g@22s",FLD(LF_RMOV,RMV_DESCR)); set_row(_nr,"@54g@3,rn",FLD(LF_RMOV,RMV_GRUPPO)); @@ -1217,7 +1232,7 @@ void TListaMov_application::print_intra(int& rr) const TCurrency cl(mov.get_real(MOV_CORRLIRE)); str = cl.string(TRUE); str.right_just(19); - set_row(rr,"Corr.in lire@14g%s", (const char*)str); + set_row(rr,"Corrispettivo@14g%s", (const char*)str); const TCurrency cv(corrval, codval); str = cv.string(TRUE); str.right_just(19); @@ -1894,58 +1909,36 @@ void TListaMov_application::incrementa_totali() _tabiva->zero(); if ((_tipo_elenco == "C")||(_tipo_elenco == "c")) { - TString colonna = _tabiva->get("S7"); - if ((colonna == "1")||(colonna == "3")) + const int colonna = _tabiva->get_int("S7"); + if ((colonna == 1)||(colonna == 3)) _totimposta += imposta; - if (colonna == "1") + if (colonna == 1) _totimponibile += imponibile; else - if (colonna == "3") + if (colonna == 3) _op_esenti += imponibile; } else { - TString colonna = _tabiva->get("S8"); - if ((colonna == "1")||(colonna == "3")||(colonna == "4")) + const int colonna = _tabiva->get_int("S8"); + if ((colonna == 1)||(colonna == 3)||(colonna == 4)) _totimposta += imposta; - if (colonna == "1") + if (colonna == 1) _totimponibile += imponibile; else - if (colonna == "3") + if (colonna == 3) _op_esenti += imponibile; else - if (colonna == "4") + if (colonna == 4) _op_non_imp += imponibile; } } -bool TListaMov_application::set_print(int m) +void TListaMov_application::imposta_parametri_stampa(const TMask& msk) { - TString16 masc; - switch(toupper(_tipoc)) - { - case 'C': - masc = "cg3100b"; - _tipo_lista = fatture; - break; - case 'M': - default : - masc = "cg3100a"; - _tipo_lista = movimenti; - break; - } - - TMask msk(masc); - msk.set_handler(F_ANNO, annoes_handler); - msk.set_handler(F_DATAINI, data_inizio); - msk.set_handler(F_DATAFIN, data_fine); - if (msk.run() != K_ENTER) - return FALSE; - set_magic_currency(TRUE); - + reset_files(); -// TLocalisamfile* fl; _curr1->set_filterfunction (filter_func); _curr2->set_filterfunction (filter_func); _curr3->set_filterfunction (filter_func_fatture); @@ -1976,12 +1969,12 @@ bool TListaMov_application::set_print(int m) else if (_provvis == 2) //globale _curr1->setfilter(""); else _curr1->setfilter("(PROVVIS!=\"\")"); //solo provvisori - + TRectype da(LF_MOV), a(LF_MOV); da.put(MOV_NUMREG, _numreg_ini); a.put(MOV_NUMREG, _numreg_fin); current_cursor()->setregion(da,a); - + add_file(LF_MOV); add_file(LF_RMOV,LF_MOV); add_file(LF_RMOVIVA,LF_MOV); @@ -2007,7 +2000,7 @@ bool TListaMov_application::set_print(int m) } } break; - + case fatture: { _noseparator = msk.get_bool(F_SEPARATOR); @@ -2026,7 +2019,7 @@ bool TListaMov_application::set_print(int m) _codice_ini = atol(msk.get(F_CODICEINI1)); _codice_fin = atol(msk.get(F_CODICEFIN1)); } - + // _relmov->add(LF_MOV, "NUMREG=NUMREG",1, LF_RMOVIVA,100); //creo un alias per il file LF_MOV if (tipo == "E") { @@ -2052,14 +2045,61 @@ bool TListaMov_application::set_print(int m) add_file(LF_RMOVIVA,LF_MOV); } break; - + default: break; } - init_print(msk); +} - return TRUE; +bool TListaMov_application::set_print(int) +{ + const char* masc; + switch(toupper(_tipoc)) + { + case 'C': + masc = "cg3100b"; + _tipo_lista = fatture; + break; + case 'M': + default : + masc = "cg3100a"; + _tipo_lista = movimenti; + break; + } + + TMask msk(masc); + msk.set_handler(F_ANNO, annoes_handler); + msk.set_handler(F_DATAINI, data_inizio); + msk.set_handler(F_DATAFIN, data_fine); + while (msk.run() == K_ENTER) + { + if (msk.get(F_DACDC).not_empty() || msk.get(F_ACDC).not_empty()) + { + _cdc_only = msk.get_bool(F_CDC_ONLY); + TRelation rel("CMS"); + TRectype darec(rel.curr()), arec(rel.curr()); + darec.put("CODTAB", msk.get(F_DACDC)); + arec.put("CODTAB", msk.get(F_ACDC)); + TCursor cur(&rel, "", 1, &darec, &arec); + const long items = cur.items(); + cur.freeze(); + for (cur = 0L; cur.pos() < items; ++cur) + { + _cdc = rel.curr().get("CODTAB"); + imposta_parametri_stampa(msk); + print(); + } + } + else + { + _cdc_only = FALSE; + _cdc.cut(0); + imposta_parametri_stampa(msk); + print(); + } + } + return FALSE; } @@ -2127,7 +2167,6 @@ void TListaMov_application::init_print(const TMask& msk) printer().footerlen(5); set_magic_currency(TRUE); -// set_curr_codval(msk.get(F_CODVAL)); // Commentato in maschera switch (_tipo_lista) { @@ -2231,13 +2270,13 @@ void TListaMov_application::init_print(const TMask& msk) TString tipo = msk.get(F_TIPOELENCO); if ((tipo=="C")||(tipo=="F")) { - _codice_ini = atol(msk.get(F_CODICEINI)); - _codice_fin = atol(msk.get(F_CODICEFIN)); + _codice_ini = msk.get_long(F_CODICEINI); + _codice_fin = msk.get_long(F_CODICEFIN); } else { - _codice_ini = atol(msk.get(F_CODICEINI1)); - _codice_fin = atol(msk.get(F_CODICEFIN1)); + _codice_ini = msk.get_long(F_CODICEINI1); + _codice_fin = msk.get_long(F_CODICEFIN1); } if (_codice_ini != 0) _flags |= ST_CODICE; @@ -2260,6 +2299,16 @@ void TListaMov_application::init_print(const TMask& msk) } } +void TListaMov_application::set_cdc_header(int& soh) +{ + if (_cdc.not_empty()) + { + TString str; + str.cut(0) << "@bCommessa " << _cdc << " - " << cache().get("CMS", _cdc, "S0"); + set_header(++soh, str); + } +} + void TListaMov_application::preprocess_header() { int soh; // riga d'inizio dell'intestazione @@ -2355,7 +2404,8 @@ void TListaMov_application::preprocess_header() else set_header (soh, "@78gcon messaggio: data competenza"); } - sep.fill('-'); + set_cdc_header(soh); + sep.fill('_'); set_header (++soh, (const char *) sep); set_header (++soh, "Rg Cod Causale@30gDescrizione@56gCodice conto@71gDescrizione conto@103gDare@120gAvere@130gSB"); } @@ -2398,7 +2448,8 @@ void TListaMov_application::preprocess_header() } else set_header (soh++, "@86gtutte le causali"); - sep.fill('-'); + set_cdc_header(soh); + sep.fill('_'); set_header (soh++, (const char *) sep); set_header (soh, "Rg Cod Causale@30gDescrizione@56gCodice conto@71gDescrizione conto@103gDare@120gAvere@130gSB"); } @@ -2429,7 +2480,8 @@ void TListaMov_application::preprocess_header() set_header (soh, "@74gdal codice %ld", _codice_ini); set_header (soh, "@92gal codice %ld", _codice_fin); } - sep.fill('-'); + set_cdc_header(soh); + sep.fill('_'); set_header (++soh, (const char *) sep); set_header (++soh, "Numero Data Cod Prot. M Documento@48gCod Tp @75gTotale@101gCd Tp T O@129gNo"); set_header (++soh, "Regis. Operaz. Reg Num. L Data@41gNumero@48gCau Dc @55gDescrizione@75gDocumento@90gImponibile@101gIv Det A I@121gImposta@129gAll"); @@ -2437,7 +2489,8 @@ void TListaMov_application::preprocess_header() default: break; - } + } + set_header (++soh,(const char*)sep); } diff --git a/cg/cg3100.h b/cg/cg3100.h index 316d51cd0..011c5b5a9 100755 --- a/cg/cg3100.h +++ b/cg/cg3100.h @@ -17,24 +17,27 @@ #define F_CAUSALEFIN 113 #define F_REGISTROINI 114 #define F_REGISTROFIN 115 -#define F_STAMPA 116 -#define F_TIPOELENCO 117 -#define F_CODICEINI 118 -#define F_CODICEFIN 119 -#define F_CAMBIO 120 -#define F_DECIDI 121 -#define F_ANNOC 122 -#define F_CODICEINI1 123 -#define F_CODICEFIN1 124 -#define F_MOVIMENTI 125 -#define F_STAMPAMOVP 126 -#define F_RAGSOCINI 127 -#define F_RAGSOCFIN 128 -#define F_RAGSOCINI1 129 -#define F_RAGSOCFIN1 130 -#define F_SEPARATOR 131 -#define F_CODVAL 132 -#define F_DESVAL 133 +#define F_STAMPA 116 +#define F_TIPOELENCO 117 +#define F_CODICEINI 118 +#define F_CODICEFIN 119 +#define F_CAMBIO 120 +#define F_DECIDI 121 +#define F_ANNOC 122 +#define F_CODICEINI1 123 +#define F_CODICEFIN1 124 +#define F_MOVIMENTI 125 +#define F_STAMPAMOVP 126 +#define F_RAGSOCINI 127 +#define F_RAGSOCFIN 128 +#define F_RAGSOCINI1 129 +#define F_RAGSOCFIN1 130 +#define F_SEPARATOR 131 +#define F_DACDC 132 +#define F_DACDC_DES 133 +#define F_ACDC 134 +#define F_ACDC_DES 135 +#define F_CDC_ONLY 136 #define ST_DATA 0x0001 #define ST_NUMERO 0x0002 diff --git a/cg/cg3100a.uml b/cg/cg3100a.uml index 484c6f3f2..ce3cc0a5e 100755 --- a/cg/cg3100a.uml +++ b/cg/cg3100a.uml @@ -1,6 +1,6 @@ #include "cg3100.h" -TOOLBAR "" 0 20 0 2 +TOOLBAR "" 0 -2 0 2 BUTTON DLG_PRINT 10 2 BEGIN @@ -225,31 +225,66 @@ BEGIN ITEM "3|Solo provvisori" END -/* -STRING F_CODVAL 3 +GROUPBOX DLG_NULL 71 4 BEGIN - PROMPT 2 18 "Valuta " - USE %VAL - INPUT CODTAB F_CODVAL - DISPLAY "Codice" CODTAB - DISPLAY "Descrizione@50" S0 - OUTPUT F_CODVAL CODTAB - OUTPUT F_DESVAL S0 - CHECKTYPE NORMAL - FLAGS "U" + PROMPT 2 18 "@bCentri di costo" + GROUP 4 END -STRING F_DESVAL 50 +BOOLEAN F_CDC_ONLY BEGIN - PROMPT 20 18 "" - USE %VAL KEY 2 - INPUT S0 F_DESVAL - DISPLAY "Descrizione@50" S0 - DISPLAY "Codice" CODTAB - COPY OUTPUT F_CODVAL - CHECKTYPE NORMAL + PROMPT 22 18 "Stampa solo le righe relative ai centri di costo" +END + +STRING F_DACDC 20 +BEGIN + PROMPT 3 19 "Da " + FLAGS "UZ" + USE CMS + INPUT CODTAB F_DACDC + DISPLAY "Codice@20" CODTAB + DISPLAY "Descrizione@70" S0 + OUTPUT F_DACDC CODTAB + OUTPUT F_DACDC_DES S0 + CHECKTYPE SEARCH + GROUP 4 +END + +STRING F_DACDC_DES 70 39 +BEGIN + PROMPT 30 19 "" + USE CMS KEY 2 + INPUT S0 F_DACDC_DES + DISPLAY "Descrizione@70" S0 + DISPLAY "Codice@20" CODTAB + COPY OUTPUT F_DACDC + CHECKTYPE SEARCH + GROUP 4 +END + +STRING F_ACDC 20 +BEGIN + PROMPT 3 20 "A " + FLAGS "UZ" + COPY USE F_DACDC + INPUT CODTAB F_ACDC + COPY DISPLAY F_DACDC + OUTPUT F_ACDC CODTAB + OUTPUT F_ACDC_DES S0 + CHECKTYPE SEARCH + GROUP 4 +END + +STRING F_ACDC_DES 70 39 +BEGIN + PROMPT 30 20 "" + COPY USE F_DACDC_DES + INPUT S0 F_ACDC_DES + COPY DISPLAY F_DACDC_DES + COPY OUTPUT F_ACDC + CHECKTYPE SEARCH + GROUP 4 END -*/ ENDPAGE diff --git a/cg/cg3100b.uml b/cg/cg3100b.uml index 1fa10dcfe..aac16e14e 100755 --- a/cg/cg3100b.uml +++ b/cg/cg3100b.uml @@ -1,5 +1,20 @@ #include "cg3100.h" +TOOLBAR "" 0 -2 0 2 + +BUTTON DLG_PRINT 10 2 +BEGIN + PROMPT -12 -11 "~Stampa" + MESSAGE EXIT,K_ENTER +END + +BUTTON DLG_QUIT 10 2 +BEGIN + PROMPT -22 -11 "" +END + +ENDPAGE + PAGE "Lista Fatture" -1 -1 73 17 NUMBER F_CODDITTA 5 @@ -218,29 +233,65 @@ BEGIN PROMPT 2 13 "Non stampare i separatori delle migliaia" END -/* -STRING F_CODVAL 3 +GROUPBOX DLG_NULL 71 4 BEGIN - PROMPT 2 14 "Valuta " - USE %VAL - INPUT CODTAB F_CODVAL - DISPLAY "Codice" CODTAB - DISPLAY "Descrizione@50" S0 - OUTPUT F_CODVAL CODTAB - CHECKTYPE NORMAL - FLAGS "U" -END -*/ - -BUTTON DLG_PRINT 10 2 -BEGIN - PROMPT -12 -1 "~Stampa" - MESSAGE EXIT,K_ENTER + PROMPT 2 18 "@bCentri di costo" + GROUP 4 END -BUTTON DLG_QUIT 10 2 +BOOLEAN F_CDC_ONLY BEGIN - PROMPT -22 -1 "" + PROMPT 22 18 "Stampa solo le righe relative ai centri di costo" +END + +STRING F_DACDC 20 +BEGIN + PROMPT 3 19 "Da " + FLAGS "UZ" + USE CMS + INPUT CODTAB F_DACDC + DISPLAY "Codice@20" CODTAB + DISPLAY "Descrizione@70" S0 + OUTPUT F_DACDC CODTAB + OUTPUT F_DACDC_DES S0 + CHECKTYPE SEARCH + GROUP 4 +END + +STRING F_DACDC_DES 70 39 +BEGIN + PROMPT 30 19 "" + USE CMS KEY 2 + INPUT S0 F_DACDC_DES + DISPLAY "Descrizione@70" S0 + DISPLAY "Codice@20" CODTAB + COPY OUTPUT F_DACDC + CHECKTYPE SEARCH + GROUP 4 +END + +STRING F_ACDC 20 +BEGIN + PROMPT 3 20 "A " + FLAGS "UZ" + COPY USE F_DACDC + INPUT CODTAB F_ACDC + COPY DISPLAY F_DACDC + OUTPUT F_ACDC CODTAB + OUTPUT F_ACDC_DES S0 + CHECKTYPE SEARCH + GROUP 4 +END + +STRING F_ACDC_DES 70 39 +BEGIN + PROMPT 30 20 "" + COPY USE F_DACDC_DES + INPUT S0 F_ACDC_DES + COPY DISPLAY F_DACDC_DES + COPY OUTPUT F_ACDC + CHECKTYPE SEARCH + GROUP 4 END ENDPAGE diff --git a/cg/cg3200.cpp b/cg/cg3200.cpp index cb3b41776..90877c412 100755 --- a/cg/cg3200.cpp +++ b/cg/cg3200.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -131,6 +132,9 @@ class TMastrini_application : public TPrintapp bool _noseparator; TString _real_picture; + + TString _cdc; + real _totale_commessa_dare, _totale_commessa_avere, _saldo_commessa; TConfig* _collins; @@ -184,6 +188,7 @@ public: void carica_array_totali132(); void carica_array_totali198(); void stampa_totaliiva(); + void stampa_totali_commessa(); void ricerca_classe_IV(bool scelta); void data_fine_esercizio(int); const char* descrizione_gruppo(); @@ -648,50 +653,49 @@ int TMastrini_application::date2esc(const TDate& d) bool TMastrini_application::almeno_un_record() { bool trovato=FALSE; - long record,sottoc; - int gruppo,conto; - TDate datareg, datacomp; - TLocalisamfile& rmov = current_cursor()->file(LF_RMOV); if (current_cursor()->is_first_match(LF_RMOV)) { - record = rmov.recno(); + TLocalisamfile& rmov_file = current_cursor()->file(LF_RMOV); + const TRecnotype record = rmov_file.recno(); + + TRelation rel(LF_RMOV); + rel.add(LF_MOV, "NUMREG==NUMREG"); + TRectype& rmov = rel.curr(); + TRectype& mov = rel.curr(LF_MOV); + + TString filter; + if (_cdc.not_empty()) + filter << RMV_CODCMS << "==\"" << _cdc << '"'; + rmov.zero(); rmov.put(RMV_GRUPPO, _gruppo); rmov.put(RMV_CONTO, _conto); rmov.put(RMV_SOTTOCONTO, _sottoc); - for (rmov.read(); !rmov.eof() ;rmov.next()) - { - int annoes = rmov.get_int (RMV_ANNOES); - long numreg = rmov.get_long(RMV_NUMREG); + TCursor cur(&rel, filter, 2, &rmov, &rmov); + const long items = cur.items(); + cur.freeze(); + for (cur = 0L; cur.pos() < items; ++cur) + { + const int annoes = rmov.get_int (RMV_ANNOES); + const long numreg = rmov.get_long(RMV_NUMREG); - _mov->setkey(1); - _mov->curr().zero(); - _mov->curr().put(MOV_NUMREG,numreg); - _mov->read(); - if (_mov->bad()) - _mov->zero(); - datacomp = (_mov->curr().get(MOV_DATACOMP)); - const TString16 provvis (_mov->curr().get(MOV_PROVVIS)); + const TDate datacomp = mov.get(MOV_DATACOMP); + const TString16 provvis = mov.get(MOV_PROVVIS); + TDate datareg; if (_annomsk == 0) datareg = rmov.get_date(RMV_DATAREG); else datareg = datacomp; - gruppo = rmov.get_int(RMV_GRUPPO); - conto = rmov.get_int(RMV_CONTO); - sottoc = rmov.get_long(RMV_SOTTOCONTO); - if ((gruppo != _gruppo)||(conto != _conto)||(sottoc != _sottoc)) + if ( ((annoes==_annomsk) || (_annomsk==0)) && ((datareg>=_data_ini) && (datareg<=_data_fine)) && (_stampa_mov_prov || provvis.blank())) + { + trovato = TRUE; break; - else - if ( ((annoes==_annomsk) || (_annomsk==0)) && ((datareg>=_data_ini) && (datareg<=_data_fine)) && (_stampa_mov_prov || provvis.blank())) - { - trovato = TRUE; - break; - } + } } - rmov.readat(record); + rmov_file.readat(record); } return trovato; } @@ -1017,6 +1021,33 @@ void TMastrini_application::fai_stampa198() } } +void TMastrini_application::stampa_totali_commessa() +{ + if (_cdc.not_empty()) + { + _rw = 1; + { + _saldo_commessa = _totale_commessa_dare - _totale_commessa_avere; + + set_row (++_rw,"@32g@b%s", trans("TOTALI COMMESSA")); + + if (_numcarat == 1) + { + set_row (_rw,"@66g%r", &_saldo_commessa); + set_row (_rw,"@83g%r", &_totale_commessa_dare); + set_row (_rw,"@100g%r", &_totale_commessa_avere); + } + else + { + set_row (_rw,"@100g%r", &_totale_commessa_dare); + set_row (_rw,"@117g%r", &_totale_commessa_avere); + if (!_stampa_des_contro) + set_row (_rw,"@135g%r", &_saldo_commessa); + } + } + } +} + void TMastrini_application::stampa_totali132() { TString sep(132); @@ -1041,6 +1072,7 @@ void TMastrini_application::stampa_totali132() set_row (_rw,"@66g%r", &_saldo_progre); set_row (_rw,"@83g%r", &_totprogre_dare); set_row (_rw++,"@100g%r", &_totprogre_avere); + if (_stampaprogre) //Progressivi attuali { set_row (_rw,"@32g%s %s", trans("TOTALI PROGRESSIVI AL"), _ultima_data_reg.string()); @@ -1215,27 +1247,24 @@ void TMastrini_application::stampa_totali198() if (_nummast == 1 || _nummast == 3) _rw = 1; - TString sep(198); - sep.fill('_'); //Stampa 198 - (sep(198)) - set_row(_rw++,"@0g%s", (const char*)sep); + TString sep(198); sep.fill('_'); //Stampa 198 - (sep(198)) + set_row(_rw,"@0g%s", (const char*)sep); _totprogre_dare=_progredare+_totale_periodo_dare; _totprogre_avere=_progreavere+_totale_periodo_avere; - set_row (_rw,"@32g%s@100g%r", trans("TOTALI PERIODO"), &_totale_periodo_dare); + set_row (++_rw,"@32g%s@100g%r", trans("TOTALI PERIODO"), &_totale_periodo_dare); set_row (_rw,"@117g%r", &_totale_periodo_avere); - set_row (_rw,"@32g%s@100g%r", trans("TOTALI PROGRESSIVI"), &_totprogre_dare); + set_row (++_rw,"@32g%s@100g%r", trans("TOTALI PROGRESSIVI"), &_totprogre_dare); set_row (_rw,"@117g%r", &_totprogre_avere); - - set_row (_rw++,"@135g%r", &_saldo_progressivi); + set_row (_rw,"@135g%r", &_saldo_progressivi); if (!_stampa_des_contro) - set_row (_rw++,"@151g%r", &_saldo_movimenti); - + set_row (_rw,"@151g%r", &_saldo_movimenti); if (_stampaprogre) //Progressivi attuali { _saldo_progre_al = _totprogre_dare_al - _totprogre_avere_al; - set_row(_rw,"@32g%s@55g%s", trans("TOTALI PROGRESSIVI AL"), _ultima_data_reg.string()); + set_row(++_rw,"@32g%s@55g%s", trans("TOTALI PROGRESSIVI AL"), _ultima_data_reg.string()); set_row (_rw,"@100g%r", &_totprogre_dare_al); set_row (_rw,"@117g%r", &_totprogre_avere_al); if (!_stampa_des_contro) @@ -1398,7 +1427,7 @@ void TMastrini_application::stampa_totali198_II() if (_item_lista <= diff) _lista.destroy(); - + _devi_stampare_footer = FALSE; } @@ -1540,7 +1569,11 @@ bool TMastrini_application::preprocess_page(int file, int counter) break; case LF_RMOV: - { + { + TLocalisamfile& rmov = current_cursor()->file(LF_RMOV); + if (_cdc.not_empty() && rmov.get(RMV_CODCMS) != _cdc) + return FALSE; + //Il flag _gia_stampata_intestazione serve nella stampa in continuo, xche' //sono costretto a richiamare l'intestazione sia nella preprocess_page (per //i mastrini con intestazione a meta' pagina), sia nella preprocess_header @@ -1555,10 +1588,8 @@ bool TMastrini_application::preprocess_page(int file, int counter) // Ricerca la contropartita di quel movimento - TLocalisamfile& rmov = current_cursor()->file(LF_RMOV); - - _numreg = atol (current_cursor()->curr(LF_RMOV).get(RMV_NUMREG)); - _numrig = atoi (current_cursor()->curr(LF_RMOV).get(RMV_NUMRIG)); + _numreg = rmov.get_long(RMV_NUMREG); + _numrig = rmov.get_int(RMV_NUMRIG); _gruppocontr = rmov.get_int (RMV_GRUPPOC); _contocontr = rmov.get_int (RMV_CONTOC); @@ -1570,7 +1601,7 @@ bool TMastrini_application::preprocess_page(int file, int counter) // Stampa solo quelli che hanno anno esercizio uguale a quello specificato // nella maschera. Se non viene specificato li stampa tutti - _importo = current_cursor()->curr(LF_RMOV).get_real(RMV_IMPORTO); + _importo = rmov.get_real(RMV_IMPORTO); _importo_str = real2str(_importo); _mov->setkey(1); _mov->curr().zero(); @@ -1586,11 +1617,11 @@ bool TMastrini_application::preprocess_page(int file, int counter) if (((_annoes == _annomsk) || (_annomsk == 0)) && (_totale_saldo != 0.0)) { - _sezione = current_cursor()->curr(LF_RMOV).get(RMV_SEZIONE); + _sezione = rmov.get(RMV_SEZIONE); if (_annomsk == 0) { - _datareg = (_mov->curr().get(MOV_DATAREG)); + _datareg = _mov->curr().get(MOV_DATAREG); _datareg_stampa = _datareg; } else @@ -1995,6 +2026,7 @@ bool TMastrini_application::preprocess_page(int file, int counter) { _totale_periodo_dare += _importo; _riporto_parziale_dare += _importo; + _totale_commessa_dare += _importo; if (_numcarat == 1) // Stampa 132 caratteri set_row (_rw,"@83g%s", (const char*) _importo_str); @@ -2010,7 +2042,8 @@ bool TMastrini_application::preprocess_page(int file, int counter) { _totale_periodo_avere += _importo; _riporto_parziale_avere += _importo; - + _totale_commessa_avere += _importo; + if (_numcarat == 1) // Stampa 132 caratteri set_row (_rw,"@100g%s", (const char*) _importo_str); else @@ -2105,8 +2138,8 @@ void TMastrini_application::set_page(int file, int counter) reset_print(); if (_numcarat == 1) fai_stampa132(); - else if (_numcarat == 2) - fai_stampa198(); + else + fai_stampa198(); break; default: break; @@ -2169,9 +2202,8 @@ print_action TMastrini_application::postprocess_page(int file, int counter) reset_print(); if (_numcarat == 1) stampa_totali132(); - else if (_numcarat == 2) - stampa_totali198(); - + else + stampa_totali198(); if (_stampatotiva) stampa_totaliiva(); } @@ -2179,10 +2211,12 @@ print_action TMastrini_application::postprocess_page(int file, int counter) { reset_print(); if ((_totale_saldo != 0.0) && (_puoi_stampare)) + { if (_numcarat == 1) stampa_totali132(); - else if (_numcarat == 2) - stampa_totali198(); + else + stampa_totali198(); + } if (_stampatotiva) stampa_totaliiva(); } @@ -2190,10 +2224,12 @@ print_action TMastrini_application::postprocess_page(int file, int counter) { reset_print(); if (_puoi_stampare) + { if (_numcarat == 1) stampa_totali132(); - else if (_numcarat == 2) - stampa_totali198(); + else + stampa_totali198(); + } if (_stampatotiva) stampa_totaliiva(); } @@ -2206,8 +2242,7 @@ print_action TMastrini_application::postprocess_page(int file, int counter) if (_numcarat == 1) carica_array_totali132(); else - if (_numcarat == 2) - carica_array_totali198(); + carica_array_totali198(); } if (_tipostampa == 3) @@ -2215,8 +2250,8 @@ print_action TMastrini_application::postprocess_page(int file, int counter) reset_print(); if (_numcarat == 1) stampa_totali132_II(); - else if (_numcarat == 2) - stampa_totali198_II(); + else + stampa_totali198_II(); } else if (_tipostampa == 2) { @@ -2224,8 +2259,8 @@ print_action TMastrini_application::postprocess_page(int file, int counter) if ((_totale_saldo != 0.0) && (_puoi_stampare)) if (_numcarat == 1) stampa_totali132_II(); - else if (_numcarat == 2) - stampa_totali198_II(); + else + stampa_totali198_II(); } else if (_tipostampa == 1) { @@ -2233,8 +2268,8 @@ print_action TMastrini_application::postprocess_page(int file, int counter) if (_puoi_stampare) if (_numcarat == 1) stampa_totali132_II(); - else if (_numcarat == 2) - stampa_totali198_II(); + else + stampa_totali198_II(); } int item_lista = _lista.items(); @@ -2273,41 +2308,12 @@ print_action TMastrini_application::postprocess_print(int file, int counter) { if (file == LF_SALDI) { -/* Cazzata tremenda - _msk->reset(F_TIPOCF_INI); - - _msk->reset(F_GRUPPOINI); - - _msk->reset(F_CONTOINI_CONTO); - _msk->reset(F_CONTOINI_CLIENTE); - _msk->reset(F_CONTOINI_FORN); - - _msk->reset(F_SOTTOCINI_CONTO); - _msk->reset(F_SOTTOCINI_CLIENTE); - _msk->reset(F_SOTTOCINI_FORN); - - _msk->reset(F_DESCRINI_CONTO); - _msk->reset(F_DESCRINI_CLIENTE); - _msk->reset(F_DESCRINI_FORN); - - _msk->reset(F_TIPOCF_FINE); - - _msk->reset(F_GRUPPOFINE); - - _msk->reset(F_CONTOFINE_CONTO); - _msk->reset(F_CONTOFINE_CLIENTE); - _msk->reset(F_CONTOFINE_FORN); - - _msk->reset(F_SOTTOCFINE_CONTO); - _msk->reset(F_SOTTOCFINE_CLIENTE); - _msk->reset(F_SOTTOCFINE_FORN); - - _msk->reset(F_DESCRFINE_CONTO); - _msk->reset(F_DESCRFINE_CLIENTE); - _msk->reset(F_DESCRFINE_FORN); -*/ + reset_print(); + stampa_totali_commessa(); + print_one(file); + _msk->reset(-9); - } + } return NEXT_PAGE; } // Stampa dei totali documenti iva se richiesta @@ -2320,10 +2326,11 @@ void TMastrini_application::stampa_totaliiva() { _rw = 7; _ddociva_len++; - TString fmt (format("@%dg", _ddociva_len)); - fmt << "%15s"; if (_stampatotiva) + { + TString16 fmt; fmt.format("@%dg", _ddociva_len); + fmt << "%15s"; for (int j = 0; j < _b.items(); j++) { TDociva& riga = (TDociva&)_b[j]; @@ -2332,14 +2339,13 @@ void TMastrini_application::stampa_totaliiva() TString string = real2str(totale); set_row(_rw+j, fmt, (const char*)string); } - + } _b.destroy(); } } // Ricerca della descrizione relativa al codice causale di MOV.dta // sull'archivio CAUS.dta - void TMastrini_application::descrizione_causale() { _caus->setkey(1); @@ -2369,7 +2375,6 @@ void TMastrini_application::documenti_iva() void TMastrini_application::ricerca_regiva() { TString16 dep; - _tabreg->curr().zero(); dep << format("%04d", _annoiva); dep << format("%3s" , (const char*) _regiva); @@ -2417,65 +2422,64 @@ bool TMastrini_application::preprocess_print(int file, int counter) bool TMastrini_application::set_print(int) { - _puoi_stampare = TRUE; - - KEY tasto; - - // Controlla se esistono impostazioni di stampa in coda - if (sheet2mask()) + KEY tasto = K_ENTER; + while (tasto == K_ENTER) { - // Simula l'immediata pressione del tasto stampa senza nemmeno lanciare la maschera - tasto = K_ENTER; - } - else - { - tasto = _msk->run(); - if (tasto == K_ENTER) - { - // Se lo sheet e' vuoto allora usa solo la maschera corrente per la stampa, - // altrimenti estrae il primo elemento sovrascrivendo la maschera corrente. - // Questa figata cerca di correggere gli errori MI6185 e MI3592 in una botta - TSheet_field& sht = (TSheet_field&)_msk->field(F_SCELTE); - if (sht.items() != 0) - sheet2mask(); // Estrae la prima riga dalla coda di stampa + _puoi_stampare = TRUE; + // Controlla se esistono impostazioni di stampa in coda + if (sheet2mask()) + { + // Simula l'immediata pressione del tasto stampa senza nemmeno lanciare la maschera + tasto = K_ENTER; } - } + else + { + tasto = _msk->run(); + if (tasto == K_ENTER) + { + // Se lo sheet e' vuoto allora usa solo la maschera corrente per la stampa, + // altrimenti estrae il primo elemento sovrascrivendo la maschera corrente. + // Questa figata cerca di correggere gli errori MI6185 e MI3592 in una botta + TSheet_field& sht = (TSheet_field&)_msk->field(F_SCELTE); + if (sht.items() != 0) + sheet2mask(); // Estrae la prima riga dalla coda di stampa + } + } + if (tasto != K_ENTER) + break; + + _noseparator = _msk->get_bool(F_SEPARATOR); + if (_noseparator) + _real_picture = "################"; + else + _real_picture = "####.###.###.###"; + set_real_picture(_real_picture); + set_magic_currency(TRUE); - _noseparator = _msk->get_bool(F_SEPARATOR); - if (_noseparator) - _real_picture = "################"; - else - _real_picture = "####.###.###.###"; - set_real_picture(_real_picture); -// set_curr_codval(_msk->get(F_VALUTA)); // Commentato in maschera - set_magic_currency(TRUE); - - if (tasto == K_ENTER) - { _codice_ditta = get_firm(); _annomsk = _msk->get_int(F_ANNO); - + int gruppoini = _msk->get_int(F_GRUPPOINI); int contoini = _msk->get_int(F_CONTOINI_CONTO); long sottocontoini = _msk->get_long(F_SOTTOCINI_CONTO); int gruppofine = _msk->get_int(F_GRUPPOFINE); int contofine = _msk->get_int(F_CONTOFINE_CONTO); long sottocontofine = _msk->get_long(F_SOTTOCFINE_CONTO); - + _stampaprogre = _msk->get_bool(F_STAMPAPROGRE); _stampatotiva = _msk->get_bool(F_STAMPATOTIVA); _stampanum = _msk->get_int(F_STAMPANUM); _stampa_mov_prov = _msk->get_bool(F_STAMPAMOVPROV); _tipostampa = _msk->get_int(F_TIPOSTAMPA); - + _numcarat = _msk->get_int(F_NUMCARAT); _stampa_des_contro = (_numcarat==2) && _msk->get_bool(F_CONTRODES); _nummast = _msk->get_int(F_NUMMAST); _data_ini = _msk->get_date(F_DATAINI); _data_fine = _msk->get_date(F_DATAFINE); - + TEsercizi_contabili esc; - + if (_annomsk != 0) _anno_corrente = _annomsk; else @@ -2484,31 +2488,31 @@ bool TMastrini_application::set_print(int) _anno_corrente = _anno_ghost; _inizioes = esc[_anno_ghost].inizio(); } - + data_fine_esercizio(_anno_corrente); // Ricalcola _data_inizioese e _data_finese if (!_data_ini.ok()) _data_ini = _data_inizioese; if (!_data_fine.ok()) _data_fine = _data_finese; - + _anno_precedente = esc.pred(_anno_corrente); - + ricerca_dati_ditta(); - + if (_nummast == 1 || _nummast == 3) printer().footerlen(4); else printer().footerlen(2); - + //Crea il cursore su gruppo, conto e sottoconto del file RMOV - + reset_files(); //resetta l'albero di stampa add_file(LF_SALDI); add_file(LF_RMOV,LF_SALDI); - + if (_msk->get_bool(F_SORTDESC)) select_cursor(_cur2); else select_cursor(_cur1); - + TRectype da(LF_SALDI), a(LF_SALDI); da.put(SLD_GRUPPO,gruppoini); da.put(SLD_CONTO,contoini); @@ -2519,7 +2523,7 @@ bool TMastrini_application::set_print(int) current_cursor()->setregion(da, a); if (_stampatotiva) _b.destroy(); - + //_inizio_stampa = TRUE; _numero_pag = 1; if (_nummast == 3) @@ -2531,10 +2535,10 @@ bool TMastrini_application::set_print(int) _conta_mastrini = 0; _indice_lista = 0; _ddociva_len = 0; - + _riga.destroy(); _lista.destroy(); - + switch (_tipostampa) { case 1: _totale_saldo = 1.0; break; @@ -2542,14 +2546,33 @@ bool TMastrini_application::set_print(int) case 3: _totale_saldo = 1.0; break; default: break; } - + enable_print_menu(); enable_link("Collegamento prima nota: ", 'b'); - - return TRUE; + + if (_msk->get(F_DACDC).not_empty() || _msk->get(F_ACDC).not_empty()) + { + TRelation rel("CMS"); + TRectype darec(rel.curr()), arec(rel.curr()); + darec.put("CODTAB", _msk->get(F_DACDC)); + arec.put("CODTAB", _msk->get(F_ACDC)); + TCursor cur(&rel, "", 1, &darec, &arec); + const long items = cur.items(); + cur.freeze(); + _totale_commessa_dare = _totale_commessa_avere = ZERO; + for (cur = 0L; cur.pos() < items; ++cur) + { + _cdc = rel.curr().get("CODTAB"); + print(); + } + } + else + { + _cdc.cut(0); + print(); + } } - else - return FALSE; + return FALSE; } void TMastrini_application::data_fine_esercizio(int anno) @@ -2725,6 +2748,7 @@ void TMastrini_application::crea_intestazione() TString sep(133),sep1(198); sep = ""; + reset_header(); int np = get_page_number(); @@ -2746,9 +2770,6 @@ void TMastrini_application::crea_intestazione() sep << "Pag. " << _pagina; sep.right_just(132); set_header(1,(const char*) sep); - sep =""; - set_header(2,"@1g%s",(const char*) sep); - //set_header(1,"@126gPag. %2d", _numero_pag++); } else if (_numcarat == 2) { @@ -2761,9 +2782,6 @@ void TMastrini_application::crea_intestazione() sep1 << "Pagina " << _pagina; sep1.right_just(198); set_header(1,(const char*) sep1); - sep1 =""; - set_header(2,"@1g%s",(const char*) sep1); - //set_header(1,"@190gPagina %2d", _numero_pag++); } if (_nummast != 3) _pagina++; @@ -2777,18 +2795,26 @@ void TMastrini_application::crea_intestazione() set_header (1, "@97g%-.5s", (const char*) _capulc); set_header (1, "@103g%-.18s", (const char*) _com); set_header (1, "@122g%-.3s", (const char*) _prov); + } + + if (_cdc.not_empty()) + { + const char* descr = cache().get("CMS", _cdc, "S0"); + set_header(2, "@bCommessa %s - %s", (const char*)_cdc, descr); } + if (_nummast == 3) set_header (3, "@0g%s@12g@b%3d %3d %6ld", trans("Sottoconto"), _gruppo, _conto, _sottoc); else set_header (3, "@0g%s@12g%3d %3d %6ld", trans("Sottoconto"), _gruppo, _conto, _sottoc); + + switch(_tmcf) + { + case 'C': _tipo_mask = 1; break; + case 'F': _tipo_mask = 2; break; + default : _tipo_mask = 3; break; + } - if (_tmcf == 'C') - _tipo_mask = 1; - else if (_tmcf == 'F') - _tipo_mask = 2; - else if (_tmcf == '\0') - _tipo_mask = 3; switch (_tipo_mask) { case 1: ricerca_clifo(); @@ -3156,39 +3182,40 @@ int TMastrini_application::stampa_progre_riporto(int start_riga) void TMastrini_application::calcola_progressivi_al(const TDate& data_fin) { - long record,sottoc,annoes; - int gruppo,conto; - TDate datareg, datacomp; - TLocalisamfile & rmov = current_cursor()->file(LF_RMOV); - char sezione; - real importo; - TDate data; + TLocalisamfile& rmov_file = current_cursor()->file(LF_RMOV); + const TRecnotype record = rmov_file.recno(); _totale_prima_dare = ZERO; _totale_prima_avere = ZERO; - record = rmov.recno(); + TRelation rel(LF_RMOV); + rel.add(LF_MOV, "NUMREG==NUMREG"); + TRectype& rmov = rel.curr(); + const TRectype& mov = rel.curr(LF_MOV); + + TString filter; + if (_cdc.not_empty()) + filter << RMV_CODCMS << "==\"" << _cdc << "\""; + rmov.zero(); rmov.put(RMV_GRUPPO, _gruppo); rmov.put(RMV_CONTO, _conto); rmov.put(RMV_SOTTOCONTO, _sottoc); - for (rmov.read();!rmov.eof() ;rmov.next()) + TCursor cur(&rel, filter, 2, &rmov, &rmov); + const long items = cur.items(); + cur.freeze(); + for (cur = 0L; cur.pos() < items; ++cur) { - annoes = rmov.get_int (RMV_ANNOES); - datareg = rmov.get_date(RMV_DATAREG); - sezione = rmov.get (RMV_SEZIONE)[0]; - importo = rmov.get_real(RMV_IMPORTO); + const int annoes = rmov.get_int (RMV_ANNOES); + TDate datareg = rmov.get(RMV_DATAREG); + const char sezione = rmov.get_char(RMV_SEZIONE); + const real importo = rmov.get(RMV_IMPORTO); long numreg = rmov.get_long(RMV_NUMREG); - _mov->setkey(1); - _mov->zero(); - _mov->put(MOV_NUMREG,numreg); - _mov->read(); - if (_mov->bad()) - _mov->zero(); - datacomp = _mov->curr().get(MOV_DATACOMP); + const TDate datacomp = mov.get(MOV_DATACOMP); + TDate data; - const TString16 provvis (_mov->curr().get(MOV_PROVVIS)); + const TString16 provvis = mov.get(MOV_PROVVIS); if (_stampa_mov_prov || (!_stampa_mov_prov && provvis.blank())) { if (_annomsk == 0) @@ -3202,9 +3229,9 @@ void TMastrini_application::calcola_progressivi_al(const TDate& data_fin) data = _data_inizioese; } - gruppo = rmov.get_int(RMV_GRUPPO); - conto = rmov.get_int(RMV_CONTO); - sottoc = rmov.get_long(RMV_SOTTOCONTO); + const int gruppo = rmov.get_int(RMV_GRUPPO); + const int conto = rmov.get_int(RMV_CONTO); + const long sottoc = rmov.get_long(RMV_SOTTOCONTO); if ((gruppo != _gruppo)||(conto != _conto)||(sottoc != _sottoc)) break; else @@ -3218,7 +3245,9 @@ void TMastrini_application::calcola_progressivi_al(const TDate& data_fin) } } // if ((_stampa_mov_prov) || ((!_stampa_mov_prov) && (provvis.trim().empty()))) } - rmov.readat(record); + + // Riposiziona rmov + rmov_file.readat(record); } void TMastrini_application::calcola_progressivi(bool finali) @@ -3234,81 +3263,84 @@ void TMastrini_application::calcola_progressivi(bool finali) char salini,salini_attuale,salfine_attuale; saldo = ZERO; // Saldo iniziale (Guy: Ovvio no?) - -// Ricerca sull'archivio saldi dei record con gruppo,conto,sottoconto -// uguali a quelli di rmov per il calcolo dei progressivi precedenti - - saldi.setkey(2); - saldi.zero(); - saldi.put(SLD_GRUPPO, _gruppo); - saldi.put(SLD_CONTO, _conto); - saldi.put(SLD_SOTTOCONTO, _sottoc); - - const TRectype record(saldi.curr()); - - for (saldi.read(_isgteq); saldi.good() && saldi.curr() == record; saldi.next()) - { - if (!saldi.get_bool(SLD_FLSCA)) - { - const int annoes_saldi = saldi.curr().get_int(SLD_ANNOES); - -//Calcola i progressivi dell'esercizio attuale - if (annoes_saldi == _anno_corrente) - { - progdare_attuale = saldi.get_real(SLD_PDARE); - progavere_attuale = saldi.get_real(SLD_PAVERE); - if (_stampa_mov_prov) - { - progdare_attuale += saldi.get_real(SLD_PDAREPRO); - progavere_attuale += saldi.get_real(SLD_PAVEREPRO); - } - - saldo = saldi.get_real(SLD_SALDO); - salini = saldi.get(SLD_FLAGSALINI)[0]; - _ultima_data_reg = saldi.get_date(SLD_DATAULMOV); - saldoini_attuale = saldi.get_real(SLD_SALDO); - salini_attuale = saldi.get_char(SLD_FLAGSALINI); - saldofine_attuale = saldi.get_real(SLD_SALDOFIN); - salfine_attuale = saldi.get_char(SLD_FLAGSALFIN); - } - } // if (!saldi.get_bool(SLD_FLSCA)) - } // FOR -//Se il saldo dell'esercizio attuale non e' diverso da zero, allora il saldo -// finale dell'esercizio precedente devo calcolarmelo tenendo conto dell'indbil - - if (_annomsk != 0 /* && saldo == ZERO */) // Guy: Non capisco perche' sia commentato! - { - if ((_indbil == 1) || (_indbil == 2) || (_indbil == 5)) - { - const TRecnotype pos = saldi.recno(); - // W96SALDI del 18-07-96 saldofin_esprec usa il flag TRUE xche' deve - // considerare anche il saldo finale - saldo = _sld->saldofin_esprec(_anno_corrente,_gruppo,_conto,_sottoc,TRUE, _stampa_mov_prov); - saldi.readat(pos); - - if (saldo > ZERO) + if (_cdc.empty()) + { + // Ricerca sull'archivio saldi dei record con gruppo,conto,sottoconto + // uguali a quelli di rmov per il calcolo dei progressivi precedenti + + saldi.setkey(2); + saldi.zero(); + saldi.put(SLD_GRUPPO, _gruppo); + saldi.put(SLD_CONTO, _conto); + saldi.put(SLD_SOTTOCONTO, _sottoc); + const TRectype record(saldi.curr()); + + for (saldi.read(_isgteq); saldi.good() && saldi.curr() == record; saldi.next()) + { + if (!saldi.get_bool(SLD_FLSCA)) { - progredare_eseprec = saldo; - progdare_prec = saldo; - } - else if (saldo < ZERO) - { - saldo = -saldo; - progreavere_eseprec = saldo; - progavere_prec = saldo; + const int annoes_saldi = saldi.curr().get_int(SLD_ANNOES); + + //Calcola i progressivi dell'esercizio attuale + if (annoes_saldi == _anno_corrente) + { + progdare_attuale = saldi.get_real(SLD_PDARE); + progavere_attuale = saldi.get_real(SLD_PAVERE); + if (_stampa_mov_prov) + { + progdare_attuale += saldi.get_real(SLD_PDAREPRO); + progavere_attuale += saldi.get_real(SLD_PAVEREPRO); + } + + saldo = saldi.get_real(SLD_SALDO); + salini = saldi.get(SLD_FLAGSALINI)[0]; + _ultima_data_reg = saldi.get_date(SLD_DATAULMOV); + saldoini_attuale = saldi.get_real(SLD_SALDO); + salini_attuale = saldi.get_char(SLD_FLAGSALINI); + saldofine_attuale = saldi.get_real(SLD_SALDOFIN); + salfine_attuale = saldi.get_char(SLD_FLAGSALFIN); + } + } // if (!saldi.get_bool(SLD_FLSCA)) + } // FOR + + //Se il saldo dell'esercizio attuale non e' diverso da zero, allora il saldo + // finale dell'esercizio precedente devo calcolarmelo tenendo conto dell'indbil + + if (_annomsk != 0) + { + if ((_indbil == 1) || (_indbil == 2) || (_indbil == 5)) + { + const TRecnotype pos = saldi.recno(); + // W96SALDI del 18-07-96 saldofin_esprec usa il flag TRUE xche' deve + // considerare anche il saldo finale + saldo = _sld->saldofin_esprec(_anno_corrente,_gruppo,_conto,_sottoc,TRUE, _stampa_mov_prov); + saldi.readat(pos); + + if (saldo > ZERO) + { + progredare_eseprec = saldo; + progdare_prec = saldo; + } + else if (saldo < ZERO) + { + saldo = -saldo; + progreavere_eseprec = saldo; + progavere_prec = saldo; + } } } } if (finali) + { calcola_progressivi_al(_data_fine); + } else { TDate giorno_prima = _data_ini; --giorno_prima; // CM500429 calcola_progressivi_al(giorno_prima); } - //Calcolo dei progressivi precedenti: somma di tutti quei movimenti di rmov //che hanno la data di registrazione inferiore alla data di inizio stampa, @@ -3490,7 +3522,7 @@ void TMastrini_application::ricerca_clifo() } else set_header(4,"@23g%-50s",(const char*) descriz); - + dataini = _data_ini.string(); datafine = _data_fine.string(); @@ -3838,6 +3870,12 @@ int TMastrini_application::ricerca_gruppo(int start) { set_row (r, "@r%s@23g@b%s", trans("Periodo di competenza"), (const char*) dataini); set_row (r, "@35g%s@r", (const char*) datafine); + + if (_cdc.not_empty()) + { + const char* descr = cache().get("CMS", _cdc, "S0"); + set_row(++r, "@bCommessa %s - %s", (const char*)_cdc, descr); + } } else { @@ -3986,10 +4024,12 @@ bool TMastrini_application::sheet2mask() short id = F_ANNO; for (int pos = _msk->id2pos(id); pos >= 0; pos = _msk->id2pos(++id)) { - const char* val = row.get(); - // Scarta i listbox perche azzerano i conti! + // Scarta i listbox perche' azzerano i conti! if (id != F_TIPOCF_INI && id != F_TIPOCF_FINE) + { + const char* val = row.get(); _msk->fld(pos).set(val); + } } rows.destroy(0, TRUE); @@ -4031,6 +4071,9 @@ bool TMastrini_application::user_create() set_handlers(_msk); _msk->set_handler(F_MEMORIZZA, memorizza_handler); + if (!has_module(CMAUT)) + _msk->hide(-4); // Spegne campi commesse in assenza del modulo relativo + TSheet_field& sht = (TSheet_field&)_msk->field(F_SCELTE); sht.set_notify(scelte_notify); TMask& sm = sht.sheet_mask(); @@ -4075,4 +4118,3 @@ int cg3200(int argc, char* argv[]) return 0; } - diff --git a/cg/cg3200.h b/cg/cg3200.h index 11435097b..6047d3ac2 100755 --- a/cg/cg3200.h +++ b/cg/cg3200.h @@ -36,10 +36,12 @@ #define F_STAMPATOTIVA 114 #define F_TIPOSTAMPA 115 #define F_STAMPAMOVPROV 116 -#define F_SEPARATOR 117 -#define F_VALUTA 118 -#define F_DESVALUTA 119 -#define F_SORTDESC 120 +#define F_DACDC 117 +#define F_ACDC 118 +#define F_DACDC_DES 157 +#define F_ACDC_DES 158 +#define F_SEPARATOR 150 +#define F_SORTDESC 151 #define F_MEMORIZZA 500 #define F_NUMCARAT 501 #define F_NUMMAST 502 diff --git a/cg/cg3200a.uml b/cg/cg3200a.uml index 9e6c0d19c..1ba0bd62e 100755 --- a/cg/cg3200a.uml +++ b/cg/cg3200a.uml @@ -1,6 +1,6 @@ #include "cg3200.h" -TOOLBAR "" 0 19 0 2 +TOOLBAR "" 0 -2 0 2 BUTTON DLG_PRINT 18 2 BEGIN @@ -446,31 +446,61 @@ BEGIN ITEM "3|Completa" END -/* -STRING F_VALUTA 3 +GROUPBOX DLG_NULL 71 4 BEGIN - PROMPT 4 17 "Valuta di stampa " - FLAGS "U" - USE %VAL - INPUT CODTAB F_VALUTA - DISPLAY "Codice" CODTAB - DISPLAY "Descrizione@60" S0 - OUTPUT F_VALUTA CODTAB - OUTPUT F_DESVALUTA S0 - CHECKTYPE NORMAL + PROMPT 4 17 "@bCentri di costo" + GROUP 4 END -STRING F_DESVALUTA 50 40 +STRING F_DACDC 20 BEGIN - PROMPT 32 17 "" - USE %VAL KEY 2 - INPUT S0 F_DESVALUTA - DISPLAY "Descrizione@60" S0 - DISPLAY "Codice" CODTAB - COPY OUTPUT F_VALUTA - CHECKTYPE NORMAL + PROMPT 5 18 "Da " + FLAGS "UZ" + USE CMS + INPUT CODTAB F_DACDC + DISPLAY "Codice@20" CODTAB + DISPLAY "Descrizione@70" S0 + OUTPUT F_DACDC CODTAB + OUTPUT F_DACDC_DES S0 + CHECKTYPE SEARCH + GROUP 4 +END + +STRING F_DACDC_DES 70 39 +BEGIN + PROMPT 32 18 "" + USE CMS KEY 2 + INPUT S0 F_DACDC_DES + DISPLAY "Descrizione@70" S0 + DISPLAY "Codice@20" CODTAB + COPY OUTPUT F_DACDC + CHECKTYPE SEARCH + GROUP 4 +END + +STRING F_ACDC 20 +BEGIN + PROMPT 5 19 "A " + FLAGS "UZ" + COPY USE F_DACDC + INPUT CODTAB F_ACDC + COPY DISPLAY F_DACDC + OUTPUT F_ACDC CODTAB + OUTPUT F_ACDC_DES S0 + CHECKTYPE SEARCH + GROUP 4 +END + +STRING F_ACDC_DES 70 39 +BEGIN + PROMPT 32 19 "" + COPY USE F_DACDC_DES + INPUT S0 F_ACDC_DES + COPY DISPLAY F_DACDC_DES + COPY OUTPUT F_ACDC + CHECKTYPE SEARCH + GROUP 4 END -*/ ENDPAGE @@ -519,13 +549,15 @@ BEGIN ITEM "Totali IVA" ITEM "Tipo stampa" ITEM "Provv." + ITEM "Da commessa" + ITEM "A commessa" END ENDPAGE ENDMASK -PAGE "Scelte" -1 -1 68 13 +PAGE "Scelte" -1 -1 68 14 NUMBER F_ANNO 4 BEGIN @@ -560,7 +592,7 @@ END NUMBER F_CONTOINI_CLIENTE 3 BEGIN PROMPT 50 2 "" - USE LF_PCON SELECT (TMCF=="C") // && (CONTO!="") && (SOTTOCONTO="") + USE LF_PCON SELECT (TMCF="C") INPUT GRUPPO F_GRUPPOINI INPUT CONTO F_CONTOINI_CLIENTE DISPLAY "Gruppo" GRUPPO @@ -580,7 +612,7 @@ END NUMBER F_CONTOINI_FORN 3 BEGIN PROMPT 50 2 "" - USE LF_PCON SELECT (TMCF="F") // && (CONTO!="") && (SOTTOCONTO="") + USE LF_PCON SELECT (TMCF="F") INPUT GRUPPO F_GRUPPOINI INPUT CONTO F_CONTOINI_FORN DISPLAY "Gruppo" GRUPPO @@ -599,7 +631,7 @@ END NUMBER F_CONTOINI_CONTO 3 BEGIN PROMPT 50 2 "" - USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="") && (TMCF="") + USE LF_PCON SELECT (CONTO!="")&&(SOTTOCONTO="")&&(TMCF="") INPUT GRUPPO F_GRUPPOINI INPUT CONTO F_CONTOINI_CONTO DISPLAY "Gruppo" GRUPPO @@ -876,7 +908,6 @@ END STRING F_DESCRFINE_CONTO 50 BEGIN PROMPT 1 5 "Descrizione " -// FIELD LF_PCON->DESCR USE LF_PCON KEY 2 INPUT DESCR F_DESCRFINE_CONTO DISPLAY "Descrizione@50" DESCR @@ -929,6 +960,29 @@ BEGIN ITEM "3|Completa" END +STRING F_DACDC 20 +BEGIN + PROMPT 1 11 "Da commessa " + FLAGS "UZ" + USE CMS + INPUT CODTAB F_DACDC + DISPLAY "Codice@20" CODTAB + DISPLAY "Descrizione@70" S0 + OUTPUT F_DACDC CODTAB + CHECKTYPE SEARCH +END + +STRING F_ACDC 20 +BEGIN + PROMPT 1 12 "A commessa " + FLAGS "UZ" + COPY USE F_DACDC + INPUT CODTAB F_ACDC + COPY DISPLAY F_DACDC + OUTPUT F_ACDC CODTAB + CHECKTYPE SEARCH +END + BUTTON DLG_OK 10 2 BEGIN PROMPT -13 -1 "" diff --git a/cg/cg3300.cpp b/cg/cg3300.cpp index bf9ec8bfc..8e7b297f8 100755 --- a/cg/cg3300.cpp +++ b/cg/cg3300.cpp @@ -9,8 +9,7 @@ #include #include #include -#include -#include +#include #include #include @@ -35,10 +34,10 @@ const int CODTABLEN = 15; -HIDDEN const char * SEGNO_MENO = "-"; -HIDDEN const char * BARRA_SESSO = "x"; +const char* const SEGNO_MENO = "-"; +const char* const BARRA_SESSO = "x"; -class CG3300_application : public TPrintapp +class TStampa_allegati : public TPrintapp { TFile_printer * _my_file_printer; int _records [13]; // Contatori dei vari tipi-record @@ -59,7 +58,7 @@ class CG3300_application : public TPrintapp TTable * _tpd, * _attiv; TDate _data_stampa; - TString _anno_stampa; + int _anno_stampa; stampe _tipo_stampa; modi_stampa _destinazione_stampa; @@ -67,9 +66,8 @@ class CG3300_application : public TPrintapp _anno_prec, _stampa_tutti, _ricalcola; TString _ricerca_att; - TString _cod_ditta_a; - TString _cod_ditta_da; - TString _tipoa_richiesto; + long _cod_ditta_da, _cod_ditta_a; + char _tipoa_richiesto; int _SortRecLen; int _cur_null; @@ -104,8 +102,8 @@ public: void arrotonda(); void stampa_su_disco(); - void ricalcola(const char *); - void pulisci_alleg(TLocalisamfile *); + void ricalcola(int anno); + void pulisci_alleg(int anno_dic); void stampa_totali(bool); @@ -114,7 +112,7 @@ public: bool da_sommare(); bool buono(); - bool lo_devo_stampare(const char *, long); + bool lo_devo_stampare(char tipo, long codice); void set_rows(int); @@ -133,12 +131,12 @@ public: TPrintrow * get_fornitori () ; TPrintrow * get_record_fine_volume (bool) ; - long cerca_codice_all(TString tipo, long codcf) ; - const char * decodifica_desc_att (TString & codatt); + long cerca_codice_all(char tipo, long codcf) ; + const char * decodifica_desc_att (const TString & codatt); bool corrispettivo (const char * tipodoc); - CG3300_application () {} - virtual ~CG3300_application () {} + TStampa_allegati () {} + virtual ~TStampa_allegati () {} }; @@ -148,25 +146,28 @@ public: // // ---------------------------------------------------------------- -const char * segno (real val) +const char* segno (const real& val) { - if (val < 0) - return (const char *) SEGNO_MENO; - else - return " "; + if (val < ZERO) + return SEGNO_MENO; + return " "; } -const char * filler (int size, char fill_char = ' ') -{ - char * _dep = new char(size+1); - TString dep(size); - - dep.fill (fill_char); - strcpy (_dep, (const char *) dep); - return _dep; +const char* filler (int size) +{ + static TString_array _fill; + + TToken_string* dep = (TToken_string*)_fill.objptr(size); + if (dep == NULL) + { + dep = new TToken_string(size); + dep->fill (' '); + _fill.add(dep, size); + } + return *dep; } -long CG3300_application::cerca_codice_all(TString tipo, long codcf) +long TStampa_allegati::cerca_codice_all(char tipo, long codcf) { TLocalisamfile& clifo = *_clifo; @@ -184,7 +185,7 @@ long CG3300_application::cerca_codice_all(TString tipo, long codcf) return 0L; } -const char * CG3300_application::decodifica_desc_att (TString & codatt) +const char * TStampa_allegati::decodifica_desc_att (const TString & codatt) { TTable& attivita = * _attiv; @@ -201,7 +202,7 @@ const char * CG3300_application::decodifica_desc_att (TString & codatt) return TMP; } -bool CG3300_application::corrispettivo (const char * tipodoc) +bool TStampa_allegati::corrispettivo (const char * tipodoc) { TTable& tpd = * _tpd; TString natura_doc; @@ -229,7 +230,7 @@ bool CG3300_application::corrispettivo (const char * tipodoc) // // -------------------------------------------------------------------- -void CG3300_application::init_sort() +void TStampa_allegati::init_sort() { _sort = new TSort (_SortRecLen); @@ -250,7 +251,7 @@ void CG3300_application::init_sort() _sort->init(); } -bool CG3300_application::user_create() +bool TStampa_allegati::user_create() { _nditte = new TLocalisamfile (LF_NDITTE); _alleg = new TLocalisamfile (LF_ALLEG); @@ -269,7 +270,7 @@ bool CG3300_application::user_create() return TRUE; } -bool CG3300_application::user_destroy() +bool TStampa_allegati::user_destroy() { delete _alleg; delete _clifo; @@ -284,13 +285,13 @@ bool CG3300_application::user_destroy() return TRUE; } -bool CG3300_application::set_ricalcola() +bool TStampa_allegati::set_ricalcola() { - ricalcola (""); + ricalcola(0); return FALSE; } -bool CG3300_application::set_dischetti() +bool TStampa_allegati::set_dischetti() { TMask msk("cg3300c") ; KEY tasto; @@ -300,26 +301,26 @@ bool CG3300_application::set_dischetti() if (tasto == K_ENTER) { _data_stampa = (const char *)msk.get (F_DATA_STAMPA); - _anno_stampa = msk.get (F_ANNO_STAMPA); + _anno_stampa = msk.get_int(F_ANNO_STAMPA); _tipo_stampa = (stampe) atoi(msk.get (F_TIPO_STAMPA2)); _distingui_att = (bool) (msk.get (F_ATTIVITA) == "X"); _ordina_desc = (bool) (msk.get (F_ORDINA_DESC) == "X"); _ricalcola = (bool) (msk.get (F_RICALCOLA) == "X"); - _cod_ditta_da = msk.get (F_DA_DITTA); - _cod_ditta_a = msk.get (F_A_DITTA); + _cod_ditta_da = msk.get_long(F_DA_DITTA); + _cod_ditta_a = msk.get_long(F_A_DITTA); _ricerca_att = msk.get (F_RICERCA_ATT); switch (_tipo_stampa) { case clienti: - _tipoa_richiesto = "C"; + _tipoa_richiesto = 'C'; _width_modulo = 132; break; case fornitori: - _tipoa_richiesto = "F"; + _tipoa_richiesto = 'F'; _width_modulo = 132; break; default: @@ -339,7 +340,7 @@ bool CG3300_application::set_dischetti() return FALSE; } -bool CG3300_application::set_impostazione() +bool TStampa_allegati::set_impostazione() { TMask msk("cg3300a") ; KEY tasto; @@ -350,7 +351,7 @@ bool CG3300_application::set_impostazione() if (tasto == K_ENTER) { _data_stampa = (const char *)msk.get (F_DATA_STAMPA); - _anno_stampa = msk.get (F_ANNO_STAMPA); + _anno_stampa = msk.get_int(F_ANNO_STAMPA); _destinazione_stampa = (modi_stampa)atoi(msk.get (F_MODO_STAMPA)); _tipo_stampa = (stampe)atoi(msk.get (F_TIPO_STAMPA)); @@ -362,8 +363,8 @@ bool CG3300_application::set_impostazione() _ordina_desc = (bool) (msk.get (F_ORDINA_DESC) == "X"); _ricalcola = (bool) (msk.get (F_RICALCOLA) == "X"); - _cod_ditta_da = msk.get (F_DA_DITTA); - _cod_ditta_a = msk.get (F_A_DITTA); + _cod_ditta_da = msk.get_long(F_DA_DITTA); + _cod_ditta_a = msk.get_long(F_A_DITTA); _ricerca_att = msk.get (F_RICERCA_ATT); @@ -372,22 +373,22 @@ bool CG3300_application::set_impostazione() switch (_tipo_stampa) { case clienti: - _tipoa_richiesto = "C"; - descr_modulo = "clienti"; + _tipoa_richiesto = 'C'; + descr_modulo = "clifo"; _width_modulo = 132; break; case fornitori: - _tipoa_richiesto = "F"; - descr_modulo = "fornitori"; + _tipoa_richiesto = 'F'; + descr_modulo = "clifo"; _width_modulo = 132; break; case modulo101: - _tipoa_richiesto = "C"; + _tipoa_richiesto = 'C'; descr_modulo = "modulo101"; _width_modulo = 80; break; case modulo102: - _tipoa_richiesto = "F"; + _tipoa_richiesto = 'F'; descr_modulo = "modulo101"; _width_modulo = 80; break; @@ -406,7 +407,7 @@ bool CG3300_application::set_impostazione() return FALSE; } -bool CG3300_application::set_print(int scelta) +bool TStampa_allegati::set_print(int scelta) { switch (scelta) { @@ -425,46 +426,51 @@ bool CG3300_application::set_print(int scelta) return FALSE; } -void CG3300_application::pulisci_alleg (TLocalisamfile * all) +void TStampa_allegati::pulisci_alleg (int anno_dic) { - TProgind prn (all->items(), "Pulizia allegati in corso...", FALSE, TRUE); - bool immesso; + TString str; str.format("%s=%d", ALL_ANNO, anno_dic); + TRelation rel(LF_ALLEG); + TCursor cur(&rel, str); + TRectype& curr = cur.curr(); + + const long items = cur.items(); + cur.freeze(); - for ( all->first(); !all->eof(); all->next()) + str.format("Pulizia allegati %d in corso...", anno_dic); + TProgind prn (items, str, FALSE, TRUE); + for (cur = 0l; cur.pos() < items; ++cur) { prn.addstatus(1); - immesso = all->curr().get_bool (ALL_IMMESSO); - if (immesso) continue; - else - { - all->curr().put (ALL_IMPESC, "0.00"); - all->curr().put (ALL_IVAESC, "0.00"); - all->curr().put (ALL_NIESC, "0.00"); - all->curr().put (ALL_E8ESC, "0.00"); - all->curr().put (ALL_IMPESP, "0.00"); - all->curr().put (ALL_IVAESP, "0.00"); - all->curr().put (ALL_NIESP, "0.00"); - all->curr().put (ALL_E8ESP, "0.00"); + const bool immesso = curr.get_bool (ALL_IMMESSO); + if (immesso) + continue; - all->curr().put (ALL_NDOCESC, "0"); - all->curr().put (ALL_NDOCESP, "0"); + curr.zero(ALL_IMPESC); + curr.zero(ALL_IVAESC); + curr.zero(ALL_NIESC); + curr.zero(ALL_E8ESC); - all->curr().put (ALL_NALLESP, "0.00"); + curr.zero(ALL_IMPESP); + curr.zero(ALL_IVAESP); + curr.zero(ALL_NIESP); + curr.zero(ALL_E8ESP); - all->curr().put (ALL_PROG101102, "0.00"); + curr.zero(ALL_NDOCESC); + curr.zero(ALL_NDOCESP); - all->rewrite(); - } + curr.zero(ALL_NALLESP); + curr.zero(ALL_PROG101102); + + cur.file().rewrite(); } } -void CG3300_application::ricalcola (const char * anno) +void TStampa_allegati::ricalcola(int anno_dic) { // TProgind prn; KEY tasto; - TString anno_dic; - TString tipo; + char tipo; long codcf; int ndoc = 0; bool immesso; @@ -472,53 +478,56 @@ void CG3300_application::ricalcola (const char * anno) real imponibile; real imposta; real ni, imp, iva, e8, nall, prog101102; - TString tipodoc; - TString campo_codice_iva; - TString codice_iva; + TString16 tipodoc; + TString16 campo_codice_iva; TDate datareg, datadoc; - TString CAMPO_NALL, CAMPO_IMP, CAMPO_IVA, CAMPO_E8, CAMPO_NI, CAMPO_DOC; + TString16 CAMPO_NALL, CAMPO_IMP, CAMPO_IVA, CAMPO_E8, CAMPO_NI, CAMPO_DOC; bool flag_b; - long nuovo_codcf; bool flag_incrementa = FALSE; int ndocesc; - TLocalisamfile all (LF_ALLEG); + + TLocalisamfile all(LF_ALLEG); + all.setkey(2); // Ricerca per anno-tipo-codice - if (*anno == '\0') + if (anno_dic <= 0) { TMask m ("cg3300b"); tasto=m.run(); if (tasto == K_ENTER) - anno_dic = m.get (F_ANNO_RICALCOLA); + anno_dic = m.get_int(F_ANNO_RICALCOLA); else return; } - else - anno_dic = anno; - TRelation rel (LF_MOV); + TRelation rel (LF_MOV); rel.add (LF_RMOVIVA, "NUMREG=NUMREG"); rel.add ("REG", "CODTAB=DATAREG[7,12]+REG"); rel.add (LF_CAUSALI, "CODCAUS=CODCAUS"); - rel.add ("%IVA", "CODTAB=CODIVA",1,LF_RMOVIVA); + rel.add ("%IVA", "CODTAB=CODIVA",1,LF_RMOVIVA, 883); - TCursor * cur = new TCursor (&rel, format ("ANNOES=%s", (const char *)anno_dic)); + TCursor cur(&rel, format("ANNOES=%04d", anno_dic)); - pulisci_alleg(&all); + pulisci_alleg(anno_dic); - for (*cur = 0; !cur->file(LF_MOV).eof(); ++*cur ) + const long items = cur.items(); + cur.freeze(); + TString str; str.format("Ricalcolo anno %d...", anno_dic); + TProgind pi(items, str, FALSE, TRUE); + + const TRectype& mov_curr = cur.curr(LF_MOV); + TRectype& all_curr = all.curr(); + const TRectype& reg = cur.file("REG").curr(); + const TRectype& cau = cur.curr(LF_CAUSALI); + const TRectype& iva_rec = cur.file("%IVA").curr(); + for (cur = 0L; cur.pos() < items; ++cur ) { - TRectype mov_curr (cur->file(LF_MOV).curr()); - TRectype all_curr (all.curr()); - TRectype reg (cur->file("REG").curr()); - TRectype cau (cur->file(LF_CAUSALI).curr()); - TRectype iva_rec (cur->file("%IVA").curr()); - - TString tiporeg = reg.get ("I0"); - - if ((tiporeg != "2") || (tiporeg != "1")) + pi.addstatus(1); + + const int tiporeg = reg.get_int("I0"); + if ((tiporeg != 2) && (tiporeg != 1)) continue; - if (tiporeg == "1") + if (tiporeg == 1) { bool sosp = reg.get_bool ("B0"); if (sosp) continue; @@ -542,17 +551,16 @@ void CG3300_application::ricalcola (const char * anno) flag_b = iva_rec.get_bool("B1"); } - codice_iva = iva_rec.get (campo_codice_iva); - - anno = mov_curr.get (MOV_ANNOES); - tipo = mov_curr.get (MOV_TIPO); + tipo = mov_curr.get_char(MOV_TIPO); codcf = mov_curr.get_long (MOV_CODCF); + if (codcf <= 0L) + continue; - nuovo_codcf = cerca_codice_all (tipo, codcf); + const long nuovo_codcf = cerca_codice_all (tipo, codcf); if (nuovo_codcf != 0) codcf = nuovo_codcf; - all_curr.put (ALL_ANNO, anno); + all_curr.put (ALL_ANNO, anno_dic); all_curr.put (ALL_TIPOCF, tipo); all_curr.put (ALL_CODCF, codcf); @@ -561,47 +569,50 @@ void CG3300_application::ricalcola (const char * anno) if (datareg.year() == datadoc.year()) { - CAMPO_IMP = "impesc"; - CAMPO_IVA = "ivaesc"; - CAMPO_NI = "niesc"; - CAMPO_E8 = "e8esc"; - CAMPO_NALL = "nallesc"; - CAMPO_DOC = "ndocesc"; + CAMPO_IMP = ALL_IMPESC; + CAMPO_IVA = ALL_IVAESC; + CAMPO_NI = ALL_NIESC; + CAMPO_E8 = ALL_E8ESC; + CAMPO_NALL = ALL_NALLESC; + CAMPO_DOC = ALL_NDOCESC; } else { - CAMPO_IMP = "impesp"; - CAMPO_IVA = "ivaesp"; - CAMPO_NI = "niesp"; - CAMPO_E8 = "e8esp"; - CAMPO_NALL = "nallesp"; - CAMPO_DOC = "ndocesp"; + CAMPO_IMP = ALL_IMPESP; + CAMPO_IVA = ALL_IVAESP; + CAMPO_NI = ALL_NIESP; + CAMPO_E8 = ALL_E8ESP; + CAMPO_NALL = ALL_NALLESP; + CAMPO_DOC = ALL_NDOCESP; } flag_incrementa = FALSE; ndoc = 0; - while (cur->next_match (LF_RMOVIVA)) + const TRectype& rmi = cur.curr(LF_RMOVIVA); + while (cur.next_match (LF_RMOVIVA)) { - TRectype rmi (cur->file(LF_RMOVIVA).curr()); + immesso = all.get_bool (ALL_IMMESSO); + if (immesso) continue; // scarta i record immessi + + int err = all.read(); + if (err != NOERR) // aggiungo un record se non presente + { + all_curr.zero(); + all_curr.put (ALL_ANNO, anno_dic); + all_curr.put (ALL_TIPOCF, tipo); + all_curr.put (ALL_CODCF, codcf); + err = all.write(); + } imponibile = rmi.get_real (RMI_IMPONIBILE); imposta = rmi.get_real (RMI_IMPOSTA); - all.read(); - - if (all.bad()) // aggiungo un record se non presente - { - all.write(); - } - - immesso = all.get_bool (ALL_IMMESSO); - if (immesso) continue; // scarta i record immessi - - if ((codice_iva == "1") || (codice_iva == "2") || (codice_iva == "3")) + const int codice_iva = iva_rec.get_int(campo_codice_iva); + if ((codice_iva == 1) || (codice_iva == 2) || (codice_iva == 3)) flag_incrementa = TRUE; - if (codice_iva == "1") + if (codice_iva == 1) { imp = all.get_real(CAMPO_IMP); iva = all.get_real(CAMPO_IVA); @@ -613,14 +624,14 @@ void CG3300_application::ricalcola (const char * anno) all.put (CAMPO_IVA, iva); } else - if (codice_iva == "2") + if (codice_iva == 2) { ni = all.get_real(CAMPO_NI); ni += imponibile; all.put (CAMPO_NI, ni); } else - if (codice_iva == "3") + if (codice_iva == 3) { e8 = all.get_real(CAMPO_E8); e8 += imponibile; @@ -649,22 +660,19 @@ void CG3300_application::ricalcola (const char * anno) } // while next_match() all.rewrite(); - } // for cur=0; ++cur - + cur.freeze(FALSE); } -bool CG3300_application::lo_devo_stampare(const char * tipo, long codcf) +bool TStampa_allegati::lo_devo_stampare(char tipo, long codcf) { _clifo->curr().zero(); _clifo->curr().put (CLI_TIPOCF, tipo); _clifo->curr().put (CLI_CODCF, codcf); if (_clifo->read() == NOERR) { - TString codice_all = _clifo->curr().get (CLI_ALLEG); - if ((codice_all == "0") || - (codice_all == "3") || - (codice_all == "4") ) + const int codice_all = _clifo->curr().get_int(CLI_ALLEG); + if ((codice_all == 0) || (codice_all == 3) || (codice_all == 4) ) return TRUE; else return FALSE; @@ -674,16 +682,16 @@ bool CG3300_application::lo_devo_stampare(const char * tipo, long codcf) } -bool CG3300_application::da_sommare() +bool TStampa_allegati::da_sommare() { TString tipocf2; long codcf2; - TString anno2; + int anno2; TString codatt_dett; TString comodo; tipocf2 = _alleg->curr().get (ALL_TIPOCF); codcf2 = _alleg->curr().get_long (ALL_CODCF); - anno2 = _alleg->curr().get (ALL_ANNO); + anno2 = _alleg->curr().get_int(ALL_ANNO); codatt_dett = _alleg->curr().get (ALL_CODATT); if (_RecordSort->codcf_dett() == -1) @@ -697,7 +705,7 @@ bool CG3300_application::da_sommare() // Se l'anno e' compilato prendo solo i record di quell'anno altrimenti // se e' lasciato in bianco li considero tutti - if (_anno_stampa != "") + if (_anno_stampa > 0) if (_anno_stampa != anno2) return FALSE; @@ -719,18 +727,14 @@ bool CG3300_application::da_sommare() // // QUI COMPILO IL RECORD B PER I FORNITORI // -bool CG3300_application::buono() +bool TStampa_allegati::buono() { - TString dep; - TString tipo; - long codcf; - TString anno; - - if (_alleg->curr().empty()) + const TRectype& curr = _alleg->curr(); + if (curr.empty()) return FALSE; - tipo = _alleg->curr().get (ALL_TIPOCF); - codcf = _alleg->curr().get_long (ALL_CODCF); + char tipo = curr.get_char(ALL_TIPOCF); + long codcf = curr.get_long(ALL_CODCF); // // Se stampo i clienti scarto chi non ha codcf = "C" @@ -742,25 +746,25 @@ bool CG3300_application::buono() // GESTIONE RECORD B // -------------------------------------------------------------------- if ((_tipo_stampa == fornitori) || (_tipo_stampa == modulo102)) - if (tipo == "B") + { + if (tipo == 'B') { _recb->compila(_alleg); return FALSE; } - + } + if (_ricerca_att != "") { // strcpy (_RecordSort->Strutt()->codatt_dett, _alleg->curr().get (ALL_CODATT)); - dep = _alleg->curr().get (ALL_CODATT); - + const TString& dep = curr.get (ALL_CODATT); if (_ricerca_att != dep) return FALSE; } - if (_anno_stampa != "") + if (_anno_stampa > 0) { - anno = _alleg->curr().get (ALL_ANNO); - + int anno = curr.get_int(ALL_ANNO); if (anno != _anno_stampa) return FALSE; } @@ -785,115 +789,81 @@ bool CG3300_application::buono() // Fa le somme su _alleg per ogni ditta // // ---------------------------------------------------------------- -void CG3300_application::calcola () +void TStampa_allegati::calcola () { - static long nuova_ditta = 0; - static long ditta_da, ditta_a; - long ditta_curr; static bool fatto_clienti = FALSE; static bool fatto_fornitori = FALSE; + const long ditta_da = _cod_ditta_da <= 0 ? 1 : _cod_ditta_da; + const long ditta_a = _cod_ditta_a <= 0 ? 99999L : _cod_ditta_a; + _num_cf = 0; // contatore C/F - if (_cod_ditta_da == "") - ditta_da = 0; - else - ditta_da = atol (_cod_ditta_da); - - if (_cod_ditta_a == "") - ditta_a = 99999; - else - ditta_a = atol (_cod_ditta_a); - - _nditte->curr().zero(); - - if (nuova_ditta == 0) - _nditte->curr().put (NDT_CODDITTA, ditta_da); - else + _nditte->zero(); + _nditte->put(NDT_CODDITTA, ditta_da); + for (int err = _nditte->read(_isgteq); err == NOERR; err = _nditte->next()) { - // - // Se e' stata cambiata la ditta con set_firm mi posiziono - // sulla successiva in nditte - // - _nditte->curr().put (NDT_CODDITTA, nuova_ditta); - _nditte->read(); - _nditte->next(); - if (_nditte->good()) - nuova_ditta = _nditte->curr().get_long(NDT_CODDITTA); - } - - bool good = TRUE; - for (int err = _nditte->read(); - ( nuova_ditta =_nditte->curr().get_long(NDT_CODDITTA) ) <= ditta_a; - _nditte->next()) + const long nuova_ditta = _nditte->get_long(NDT_CODDITTA); + if (nuova_ditta > ditta_a) + break; - { - ditta_curr = get_firm(); + if (!prefix().exist(nuova_ditta)) // TBC *** fv mi sembrava ci volesse + continue; + + set_firm(nuova_ditta); - if (ditta_curr != nuova_ditta) - { - if (good = prefix().exist(nuova_ditta)) // TBC *** fv mi sembrava ci volesse - set_firm (nuova_ditta); - } - - if (good) - { - - if (_ricalcola) ricalcola (_anno_stampa); + if (_ricalcola) + ricalcola(_anno_stampa); - // Legge i dati anagrafici del dichiarante - _RecordSort->fill_dati_anag_dic(_nditte); + // Legge i dati anagrafici del dichiarante + _RecordSort->fill_dati_anag_dic(_nditte); - // --------------------------------------------------------------------- - // ELABORAZIONE ALLEGATI - // --------------------------------------------------------------------- - _alleg->zero(); - _alleg->put (ALL_ANNO, _anno_stampa); - _alleg->put (ALL_CODCF, _tipoa_richiesto); + // --------------------------------------------------------------------- + // ELABORAZIONE ALLEGATI + // --------------------------------------------------------------------- + _alleg->zero(); + _alleg->put (ALL_ANNO, _anno_stampa); + _alleg->put (ALL_CODCF, _tipoa_richiesto); - TProgind prnd(_alleg->items(), - "Elaborazione in corso...", - FALSE, TRUE); + TProgind prnd(_alleg->items(), "Elaborazione allegati in corso...", FALSE, TRUE); - if (_ricerca_att != "") - _alleg->curr().put (ALL_CODATT, _ricerca_att); + if (_ricerca_att != "") + _alleg->curr().put (ALL_CODATT, _ricerca_att); - if (_distingui_att) - _alleg->setkey (1); - else - _alleg->setkey (2); // non distinguo le attivita + if (_distingui_att) + _alleg->setkey (1); + else + _alleg->setkey (2); // non distinguo le attivita - // for (_alleg->read(); !_alleg->eof(); _alleg->next()) + for (int err = _alleg->read(_isgteq); err == NOERR; err = _alleg->next()) + { + prnd.addstatus(1); - _alleg->read(); - do + if (buono()) { - prnd.addstatus(1); - - if (buono()) + if (da_sommare ()) + _RecordSort->somma(_alleg->curr(), _tipo_stampa); // somma nella struttura + else { - if (da_sommare ()) - _RecordSort->somma(_alleg, _tipo_stampa); // somma nella struttura - else + if (!_RecordSort->importo().is_zero()) { - if (_RecordSort->importo() != 0) - { - _sort->sort (_RecordSort->Strutt_str()); - _num_cf += 1; // incremento contatore numero di C/F - } - _t->incrementa_totali(_RecordSort->Strutt(), _tipo_stampa); - - _RecordSort->compila(_alleg); - } - } // if buono() - _alleg->next(); - } while (!_alleg->eof()); // for !eof su _alleg - - // rimetto all'inizio il puntatore di _alleg dopo averlo scorso tutto una volta - _alleg->first(); + _sort->sort (_RecordSort->Strutt_str()); + _num_cf += 1; // incremento contatore numero di C/F + } + _t->incrementa_totali(_RecordSort->Strutt(), _tipo_stampa); + _RecordSort->compila(_alleg->curr()); + } + } // if buono() + } + // Sorta anche l'ultimo: BESTIA! + if (!_RecordSort->importo().is_zero()) + { + _sort->sort (_RecordSort->Strutt_str()); + _num_cf += 1; // incremento contatore numero di C/F } - if (_nditte->eof()) break; + // rimetto all'inizio il puntatore di _alleg dopo averlo scorso tutto una volta + _alleg->first(); } // for su nditte // @@ -901,7 +871,6 @@ void CG3300_application::calcola () // prima di una ditta e poi di un'altra (si posiziona sulla successiva // in nditte) // - nuova_ditta = 0; // // Se la stampa e' su disco non chiamo subito endsort() perche' @@ -909,10 +878,10 @@ void CG3300_application::calcola () // if (_destinazione_stampa == dischetto) { - if (_tipoa_richiesto == "C") + if (_tipoa_richiesto == 'C') fatto_clienti = TRUE; - if (_tipoa_richiesto == "F") + if (_tipoa_richiesto == 'F') fatto_fornitori = TRUE; switch (_tipo_stampa) @@ -950,13 +919,13 @@ void CG3300_application::calcola () } -print_action CG3300_application::postprocess_print(int file, int counter) +print_action TStampa_allegati::postprocess_print(int file, int counter) { delete _sort; // E' proprio necessario ??? return NEXT_PAGE; } -print_action CG3300_application::postprocess_page(int file, int counter) +print_action TStampa_allegati::postprocess_page(int file, int counter) { int pagina_corrente = printer().getcurrentpage(); @@ -984,7 +953,7 @@ print_action CG3300_application::postprocess_page(int file, int counter) return NEXT_PAGE; } -bool CG3300_application::preprocess_print (int file, int counter) +bool TStampa_allegati::preprocess_print (int file, int counter) { printer().footerlen (LUNGHEZZA_FOOTER); reset_print(); @@ -1014,27 +983,28 @@ bool CG3300_application::preprocess_print (int file, int counter) } -void CG3300_application::arrotonda() +void TStampa_allegati::arrotonda() { struct alleg_sort *_rec = (struct alleg_sort *) _buff; - _rec->impesc.round(-3); - _rec->ivaesc.round(-3); - _rec->niesc.round(-3); - _rec->e8esc.round(-3); + const int arr = TCurrency::get_firm_dec() == 0 ? -3 : 0; + + _rec->impesc.round(arr); + _rec->ivaesc.round(arr); + _rec->niesc.round(arr); + _rec->e8esc.round(arr); - _rec->tot_rigac.round(-3); + _rec->tot_rigac.round(arr); - _rec->impesp.round(-3); - _rec->ivaesp.round(-3); - _rec->niesp.round(-3); - _rec->e8esp.round(-3); - - _rec->tot_rigap.round(-3); + _rec->impesp.round(arr); + _rec->ivaesp.round(arr); + _rec->niesp.round(arr); + _rec->e8esp.round(arr); + _rec->tot_rigap.round(arr); } -void CG3300_application::tronca() +void TStampa_allegati::tronca() { real dep; @@ -1092,7 +1062,7 @@ void CG3300_application::tronca() } -void CG3300_application::set_rows(int counter) +void TStampa_allegati::set_rows(int counter) { TString cog, nom; TString tipo; @@ -1119,9 +1089,10 @@ void CG3300_application::set_rows(int counter) set_row ( riga(NOM_DETT), formato(NOM_DETT), _rec->nome_dett); set_row ( riga(VIA_DETT), formato(VIA_DETT), _rec->via_dett); set_row ( riga(COM_DETT), formato(COM_DETT), _rec->comune_dett); + set_row ( riga(PRO_DETT), formato(PRO_DETT), _rec->prov_dett); // numero progressivo - set_row (riga(PRO_DETT), formato(PRO_DETT), counter); + set_row (riga(PROG_DETT), formato(PROG_DETT), counter); if (tipo == "F") set_row (riga(CASELLA_PAIVA), formato(CASELLA_PAIVA), "x" ); @@ -1189,7 +1160,7 @@ void CG3300_application::set_rows(int counter) } -bool CG3300_application::preprocess_page(int file,int counter) +bool TStampa_allegati::preprocess_page(int file,int counter) { static long codditta_curr; static TFixed_string codatt_curr(" "); // Sono 5 spazi @@ -1224,7 +1195,7 @@ bool CG3300_application::preprocess_page(int file,int counter) return TRUE; } -void CG3300_application::preprocess_header() +void TStampa_allegati::preprocess_header() { word pagina_corrente; @@ -1237,7 +1208,7 @@ void CG3300_application::preprocess_header() reset_header(); } -void CG3300_application::preprocess_footer() +void TStampa_allegati::preprocess_footer() { word pagina_corrente; bool ultima=FALSE; @@ -1256,7 +1227,7 @@ void CG3300_application::preprocess_footer() } -void CG3300_application::stampa_totali(bool ultima) +void TStampa_allegati::stampa_totali(bool ultima) { real tot, tot_impes, tot_ivaes, tot_nies, tot_e8es; int tot_es; @@ -1285,7 +1256,7 @@ void CG3300_application::stampa_totali(bool ultima) if (ultima) { set_footer (riga(RECB_ESC), formato(RECB_ESC), _recb->esc_int() ); - set_footer (riga(RECB_IMPESP), formato(RECB_IMPESP), _recb->impesc_str() ); + set_footer (riga(RECB_IMPESC), formato(RECB_IMPESC), _recb->impesc_str() ); set_footer (riga(RECB_IVAESC), formato(RECB_IVAESC), _recb->ivaesc_str() ); if (_recb->tot_real() < 0) @@ -1300,20 +1271,14 @@ void CG3300_application::stampa_totali(bool ultima) set_footer (riga(RIP_ESC), formato(RIP_ESC), _t->RipTotEs()); - set_footer (riga(RIP_SEGNO_IMPESP), formato(RIP_SEGNO_IMPESP), - segno(_t->RipTotImpes())); - set_footer (riga(RIP_IMPESP), formato(RIP_IMPESP), - _t->RipTotImpes().string(12,0)); + set_footer (riga(RIP_SEGNO_IMPESP), formato(RIP_SEGNO_IMPESP), segno(_t->RipTotImpes())); + set_footer (riga(RIP_IMPESP), formato(RIP_IMPESP), _t->RipTotImpes().string(12,0)); - set_footer (riga(RIP_SEGNO_IVAESP), formato(RIP_SEGNO_IVAESP), - segno(_t->RipTotIvaes())); - set_footer (riga(RIP_IVAESP), formato(RIP_IVAESP), - _t->RipTotIvaes().string(12,0)); + set_footer (riga(RIP_SEGNO_IVAESP), formato(RIP_SEGNO_IVAESP), segno(_t->RipTotIvaes())); + set_footer (riga(RIP_IVAESP), formato(RIP_IVAESP), _t->RipTotIvaes().string(12,0)); - set_footer (riga(RIP_SEGNO_NIESP), formato(RIP_SEGNO_NIESP), - segno(_t->RipTotNies())); - set_footer (riga(RIP_NIESP), formato(RIP_NIESP), - _t->RipTotNies().string(12,0)); + set_footer (riga(RIP_SEGNO_NIESP), formato(RIP_SEGNO_NIESP), segno(_t->RipTotNies())); + set_footer (riga(RIP_NIESP), formato(RIP_NIESP), _t->RipTotNies().string(12,0)); set_footer (riga(RIP_SEGNO_E8ESP), formato(RIP_SEGNO_E8ESP), segno(_t->RipTotE8es())); @@ -1346,7 +1311,7 @@ void CG3300_application::stampa_totali(bool ultima) // -------------------------------------------------------------------- // INTESTA // -------------------------------------------------------------------- -bool CG3300_application::intesta() +bool TStampa_allegati::intesta() { TString tipoa; struct alleg_sort * buff = (struct alleg_sort *) _buff; @@ -1445,7 +1410,7 @@ bool CG3300_application::intesta() } /****************** - const char * CG3300_application::get_paiva_cf (const char * tipoa, long codcf) + const char * TStampa_allegati::get_paiva_cf (const char * tipoa, long codcf) { TString dep; @@ -1469,27 +1434,27 @@ bool CG3300_application::intesta() // // ---------------------------------------------------------------------- -void CG3300_application::stampa_su_disco() +void TStampa_allegati::stampa_su_disco() { TPrinter old = printer(); if (_tipo_stampa == clienti) { - _tipoa_richiesto = "C"; + _tipoa_richiesto = 'C'; calcola(); } if (_tipo_stampa == fornitori) { - _tipoa_richiesto = "F"; + _tipoa_richiesto = 'F'; calcola(); } if (_tipo_stampa == entrambi) { - _tipoa_richiesto = "C"; + _tipoa_richiesto = 'C'; calcola(); - _tipoa_richiesto = "F"; + _tipoa_richiesto = 'F'; calcola(); } @@ -1502,7 +1467,7 @@ void CG3300_application::stampa_su_disco() // TApplication::set_printer (&old); } -void CG3300_application::scrivi() +void TStampa_allegati::scrivi() { bool finito = FALSE; @@ -1513,7 +1478,7 @@ void CG3300_application::scrivi() } } -bool CG3300_application::scrivi_volume(int volume) +bool TStampa_allegati::scrivi_volume(int volume) { bool finito = FALSE; TPrintrow * riga; @@ -1609,7 +1574,7 @@ bool CG3300_application::scrivi_volume(int volume) return (finito); } -void CG3300_application::scrivi_coda_elenco_clienti() +void TStampa_allegati::scrivi_coda_elenco_clienti() { TPrintrow * riga = new TPrintrow(); TString record (LUNGHEZZA_RECORD); @@ -1685,11 +1650,11 @@ void CG3300_application::scrivi_coda_elenco_clienti() } -void CG3300_application::scrivi_inizio_elenco_clienti() +void TStampa_allegati::scrivi_inizio_elenco_clienti() { TPrintrow * riga = new TPrintrow(); TString record (LUNGHEZZA_RECORD); - TString aa = _anno_stampa.mid(2); + TString8 aa; aa.format("%02d", _anno_stampa%100); TString tipopers; TString datana; int cod_nat_giu=0; @@ -1742,11 +1707,11 @@ void CG3300_application::scrivi_inizio_elenco_clienti() } -void CG3300_application::scrivi_inizio_elenco_fornitori () +void TStampa_allegati::scrivi_inizio_elenco_fornitori () { TPrintrow * riga = new TPrintrow(); TString record (LUNGHEZZA_RECORD); - TString aa = _anno_stampa.mid(2); + TString8 aa; aa.format("%02d", _anno_stampa%100); TString tipopers; TString datana; int cod_nat_giu=0; @@ -1799,8 +1764,8 @@ void CG3300_application::scrivi_inizio_elenco_fornitori () } -//TPrintrow * CG3300_application::get_fornitori (bool* clienti, bool *fornitori) -TPrintrow * CG3300_application::get_fornitori () +//TPrintrow * TStampa_allegati::get_fornitori (bool* clienti, bool *fornitori) +TPrintrow * TStampa_allegati::get_fornitori () { TPrintrow * riga = new TPrintrow(); TString record (LUNGHEZZA_RECORD); @@ -1968,7 +1933,7 @@ TPrintrow * CG3300_application::get_fornitori () return (riga); } -void CG3300_application::scrivi_coda_elenco_fornitori() +void TStampa_allegati::scrivi_coda_elenco_fornitori() { TPrintrow * riga = new TPrintrow(); TString record (LUNGHEZZA_RECORD); @@ -2069,8 +2034,8 @@ void CG3300_application::scrivi_coda_elenco_fornitori() _my_file_printer->print(*riga); } -// bool CG3300_application::get_clienti (bool * clienti, bool * fornitori) -bool CG3300_application::get_clienti () +// bool TStampa_allegati::get_clienti (bool * clienti, bool * fornitori) +bool TStampa_allegati::get_clienti () { TPrintrow * riga = new TPrintrow(); TString record (LUNGHEZZA_RECORD); @@ -2214,11 +2179,11 @@ bool CG3300_application::get_clienti () return TRUE; } -TPrintrow * CG3300_application::get_record_inizio_volume (int volume_progr) +TPrintrow * TStampa_allegati::get_record_inizio_volume (int volume_progr) { TPrintrow * riga = new TPrintrow(); TString record (LUNGHEZZA_RECORD); - TString aa = _anno_stampa.mid(2); + TString16 aa; aa.format("%02d", _anno_stampa%100); record.format ("%2s%02d%1s%2s%121s", "00", volume_progr, "2", (const char *) aa, filler(121)); @@ -2227,7 +2192,7 @@ TPrintrow * CG3300_application::get_record_inizio_volume (int volume_progr) return riga; } -TPrintrow * CG3300_application::get_record_fine_volume (bool finito) +TPrintrow * TStampa_allegati::get_record_fine_volume (bool finito) { TPrintrow * riga = new TPrintrow(); TString record (LUNGHEZZA_RECORD); @@ -2262,7 +2227,7 @@ TPrintrow * CG3300_application::get_record_fine_volume (bool finito) int cg3300(int argc, char* argv[]) { - CG3300_application a; + TStampa_allegati a; a.run(argc, argv, "Stampa Allegati"); return 0; } diff --git a/cg/cg3300.frm b/cg/cg3300.frm index 1dc90bcef..06bc3f2e6 100755 --- a/cg/cg3300.frm +++ b/cg/cg3300.frm @@ -1,8 +1,8 @@ -[clienti] +[clifo] Passo=4 -RigheModulo=19 -3 "@85g%12s" // partita IVA_dichiarante -3 "@112g%d" // numero di pagina +RigheModulo=22 +3 "@85g%12s" // 0 - partita IVA_dichiarante +3 "@112g%d" // numero di pagina 7 "@4g%30s" // cognome | 7 "@41g%20s" // nome | 9 "@4g%2s" // gg_na | @@ -10,18 +10,18 @@ RigheModulo=19 9 "@11g%2s" // aa_na | 9 "@12g%c" // maschio | F I S I C A 9 "@16g%c" // femmina | -9 "@19g%50s" // comune_na | -9 "@56g%5s" // prov_na | +9 "@19g%50s" // comune_na | +9 "@56g%5s" // 10 - prov_na | 11 "@4g%35s" // via e numero civico | 11 "@40g%50s" //_dati_anag.comune_fis); | 11 "@57g%5s" //_dati_anag.prov_fis); | 13 "@4g%12s" //_dati_anag.pa_iva); | 13 "@17g%50s" //_dati_anag.attivita); | -13 "@52g%5s" //_dati_anag.cod_att_prev); +13 "@52g%5s" // _dati_anag.cod_att_prev); 7 "@61g%50s" // _dati_anag.rag_soc); | 7 "@113g%2d" // _dati_anag.nat_giu); | -9 "@61g%45s" // _dati_anag.via_fis); | P E R S O N A -9 "@96g%50s" // _dati_anag.comune_fis); | +9 "@61g%45s" // _dati_anag.via_fis); | P E R S O N A +9 "@96g%50s" // 20 - _dati_anag.comune_fis); | 9 "@114g%5s" // _dati_anag.prov_fis); | G I U R I D I C A 11 "@61g%45s" // _dati_anag.pa_iva); | 11 "@73g%50s" //_dati_anag.attivita); | @@ -29,31 +29,59 @@ RigheModulo=19 15 "@81g%d" //_dati_anag.num_pag numero di pagine stampate 15 "@99g%d" // num_righe numero di clienti fornitori 21 "@6g%d" // numero progressivo di dettaglio -20 "@12%30s" // cognome dettaglio +20 "@12g%30s" // cognome dettaglio 20 "@42g%20s" // nome dettaglio -20 "@67g%26s" // indirizzo dettaglio +20 "@67g%26s" // 30 - indirizzo dettaglio 20 "@94g%18s" // comune dettaglio 20 "@114g%2s" // provincia dettaglio 21 "@12g%16s" // pa IVA dettaglio -21 "@28g%4s" // ESC +21 "@28g%4d" // ESC 21 "@33g%1s" // Segno impesc 21 "@35g%12d" // Impesc 21 "@50g%1s" // Segno ivaesc 21 "@51g%12d" // Ivaesc 21 "@67g%1s" // Segno niesc -21 "@68g%12d" // niesc +21 "@68g%12d" // 40 - niesc 21 "@84g%1s" // Segno e8esc 21 "@85g%12d" // e8esc 21 "@101g%1s" // Segno totale 21 "@102g%12d" // totale -22 "@12%1s" // Casella partita iva +22 "@12g%1s" // Casella partita iva +22 "@28g%4d" // ESP 22 "@33g%1s" // Segno impesp 22 "@35g%12d" // Impesp 22 "@50g%1s" // Segno ivaesp -22 "@51g%12d" // Ivaesp +22 "@51g%12d" // 50 - Ivaesp 22 "@67g%1s" // Segno niesp 22 "@68g%12d" // niesp 22 "@84g%1s" // Segno e8esp 22 "@85g%12d" // e8esp 22 "@101g%1s" // Segno totalep -22 "@102g%12d" // totalep +22 "@102g%12d" // totalep +2 "@28g%4d" // 57 - RECB ESC +2 "@35g%12d" // RECB Impesc +2 "@51g%12d" // RECB Ivaesc +2 "@101g%1s" // RECB Segno totale +2 "@102g%12d" // RECB totale +4 "@28g%12d" // 62 - RIP ESC +4 "@33g%1s" // RIP Segno impesp +4 "@35g%12d" // RIP Impesp +4 "@50g%1s" // RIP Segno ivaesp +4 "@51g%12d" // RIP Ivaesp +4 "@67g%1s" // RIP Segno niesp +4 "@68g%12d" // RIP niesp +4 "@84g%1s" // RIP Segno e8esp +4 "@85g%12d" // 70 - RIP e8esp +4 "@101g%1s" // RIP Segno totalep +4 "@102g%12d" // RIP totalep +6 "@28g%12d" // 73 - TOT ESC +6 "@33g%1s" // TOT Segno impesp +6 "@35g%12d" // TOT Impesp +6 "@50g%1s" // TOT Segno ivaesp +6 "@51g%12d" // TOT Ivaesp +6 "@67g%1s" // TOT Segno niesp +6 "@68g%12d" // TOT niesp +6 "@84g%1s" // 80 - TOT Segno e8esp +6 "@85g%12d" // TOT e8esp +6 "@101g%1s" // TOT Segno totale +6 "@102g%12d" // TOT totale diff --git a/cg/cg3300.h b/cg/cg3300.h index b0f42509c..a39b6f240 100755 --- a/cg/cg3300.h +++ b/cg/cg3300.h @@ -26,8 +26,7 @@ class Array_desc_campi : public TObject public: const desc_campo& campi(int i) { return (const desc_campo&) _campi[i]; } int riga (int i) { return ((const desc_campo&)_campi[i])._riga; } - const char * formato (int i) - { return ((desc_campo&)_campi[i])._formato; } + const char* formato (int i) { return ((desc_campo&)_campi[i])._formato; } void add (int, const char*); void leggi_modulo (const char *, const char *); @@ -38,26 +37,26 @@ public: virtual ~Array_desc_campi() {}; }; -class Record_B { +class Record_B +{ int esc; real impesc; real ivaesc; real tot; public: - void compila (TLocalisamfile *); + void compila (const TRectype& all); void azzera(); void somma(); - real tot_real() { return tot; } - int esc_int() { return esc; } - real impesc_real() { return impesc; } - real ivaesc_real() { return ivaesc; } + const real& tot_real() const { return tot; } + int esc_int() const { return esc; } + const real& impesc_real() { return impesc; } + const real& ivaesc_real() const { return ivaesc; } - const char * tot_str() { return tot.string("@@@@@@@@@@@"); } - // const char * esc_str() { return esc.string("@@@@@@@@@@@"); } - const char * impesc_str() { return impesc.string("@@@@@@@@@@@"); } - const char * ivaesc_str() { return ivaesc.string("@@@@@@@@@@@"); } + const char* tot_str() const { return tot.string("@@@@@@@@@@@"); } + const char* impesc_str() const { return impesc.string("@@@@@@@@@@@"); } + const char* ivaesc_str() const { return ivaesc.string("@@@@@@@@@@@"); } Record_B() : esc(0), impesc(0.00), ivaesc(0.00), tot(0.00) {}; virtual ~Record_B () {}; @@ -129,8 +128,8 @@ class SortRecord { protected: TRectype& look_com(const char *); - long cerca_codice_all(TString tipo, long codcf) ; - const char * decodifica_desc_att (TString & codatt); + long cerca_codice_all(char tipo, long codcf) ; + const char * decodifica_desc_att (const TString & codatt); bool corrispettivo (const char * tipodoc); public: @@ -139,9 +138,9 @@ public: const char * fill_dati_dettaglio (const char * tipo, long codcf); const char * Strutt_str() { return (const char *) _all; } struct alleg_sort * Strutt() { return _all; } - void compila(TLocalisamfile *); - void somma (TLocalisamfile *, stampe); - real importo() { return _all->impesc; } + void compila(const TRectype& alleg); + void somma (const TRectype& rec, stampe); + const real& importo() const { return _all->impesc; } int RecSize () { return sizeof(struct alleg_sort); } long codcf_dett() { return _all->codcf_dett; } const real& Impesc() { return _all->impesc; } @@ -224,7 +223,7 @@ enum posizioni { MASCHIO, FEMMINA, COMUNE_NA, - PROV_NA , + PROV_NA , // 10 IND_FIS , COMUNE_FIS, PROV_FIS , @@ -234,7 +233,7 @@ enum posizioni { RAGSOC_DIC , NAT_GIU , IND_GIU , - COMUNE_GIU , + COMUNE_GIU , // 20 PROV_GIU , PAIVA_GIU, ATT_GIU , @@ -244,7 +243,7 @@ enum posizioni { PROG_DETT, COG_DETT, NOM_DETT, - VIA_DETT, + VIA_DETT, // 30 COM_DETT, PRO_DETT, PAIVA_DETT, @@ -254,7 +253,7 @@ enum posizioni { SEGNO_IVAESC, IVAESC_DETT, SEGNO_NIESC, - NIESC_DETT, + NIESC_DETT, // 40 SEGNO_E8ESC, E8ESC_DETT, SEGNO_TOTC, @@ -264,19 +263,19 @@ enum posizioni { SEGNO_IMPESP, IMPESP_DETT, SEGNO_IVAESP, - IVAESP_DETT, + IVAESP_DETT, // 50 SEGNO_NIESP, NIESP_DETT, SEGNO_E8ESP, E8ESP_DETT, SEGNO_TOTP, TOTP_DETT, - RECB_ESC, - RECB_IMPESP, + RECB_ESC, // 57 + RECB_IMPESC, RECB_IVAESC, - RECB_SEGNO_TOT, + RECB_SEGNO_TOT, // 60 RECB_TOT, - RIP_ESC, + RIP_ESC, // 62 RIP_SEGNO_IMPESP, RIP_IMPESP, RIP_SEGNO_IVAESP, @@ -284,17 +283,17 @@ enum posizioni { RIP_SEGNO_NIESP, RIP_NIESP, RIP_SEGNO_E8ESP, - RIP_E8ESP, + RIP_E8ESP, // 70 RIP_SEGNO_TOTALE, RIP_TOTALE, - TOT_ESC, + TOT_ESC, // 73 TOT_SEGNO_IMPESP, TOT_IMPESP, TOT_SEGNO_IVAESP, TOT_IVAESP, TOT_SEGNO_NIESP, TOT_NIESP, - TOT_SEGNO_E8ESP, + TOT_SEGNO_E8ESP, // 80 TOT_E8ESP, TOT_SEGNO_TOTALE, TOT_TOTALE diff --git a/cg/cg3300b.uml b/cg/cg3300b.uml index 719cd9e56..7d5e0d25e 100755 --- a/cg/cg3300b.uml +++ b/cg/cg3300b.uml @@ -5,7 +5,7 @@ #include "cg3300b.h" -PAGE "" -1 -1 27 6 +PAGE "Anno dichiarazione" -1 -1 27 5 NUMBER F_ANNO_RICALCOLA 4 BEGIN @@ -14,12 +14,12 @@ BEGIN FLAGS "A" END -BUTTON DLG_OK 9 3 +BUTTON DLG_OK 10 2 BEGIN PROMPT -12 3 "" END -BUTTON DLG_CANCEL 9 3 +BUTTON DLG_CANCEL 10 2 BEGIN PROMPT -22 3 "" END diff --git a/cg/cg3301.cpp b/cg/cg3301.cpp index baddb3887..ca13f6bb9 100755 --- a/cg/cg3301.cpp +++ b/cg/cg3301.cpp @@ -3,7 +3,6 @@ // classi di supporto per cg3300_application // -#include #include #include #include @@ -49,7 +48,7 @@ SortRecord::~SortRecord() delete _all; } -long SortRecord::cerca_codice_all(TString tipo, long codcf) +long SortRecord::cerca_codice_all(char tipo, long codcf) { TLocalisamfile& clifo = *_clifo; @@ -67,7 +66,7 @@ long SortRecord::cerca_codice_all(TString tipo, long codcf) return 0L; } -const char * SortRecord::decodifica_desc_att (TString & codatt) +const char* SortRecord::decodifica_desc_att (const TString& codatt) { TTable& attivita = * _attiv; @@ -191,23 +190,23 @@ const char * SortRecord::fill_dati_dettaglio (const char * tipocf, long codcf) // Incrementa SOLO i totali di riga (che sono nella struttura) // NON i totali e i riporti in fondo alla pagina // -void SortRecord::somma (TLocalisamfile * alleg, stampe tipo_stampa) +void SortRecord::somma (const TRectype& alleg, stampe tipo_stampa) { switch (tipo_stampa) { case fornitori: case clienti: - _all->impesc += alleg->curr().get_real (ALL_IMPESC); - _all->ivaesc += alleg->curr().get_real (ALL_IVAESC); - _all->niesc += alleg->curr().get_real (ALL_NIESC); - _all->e8esc += alleg->curr().get_real (ALL_E8ESC); - _all->ndocesc += alleg->curr().get_int (ALL_NDOCESC); + _all->impesc += alleg.get_real (ALL_IMPESC); + _all->ivaesc += alleg.get_real (ALL_IVAESC); + _all->niesc += alleg.get_real (ALL_NIESC); + _all->e8esc += alleg.get_real (ALL_E8ESC); + _all->ndocesc += alleg.get_int (ALL_NDOCESC); - _all->impesp += alleg->curr().get_real (ALL_IMPESP); - _all->ivaesp += alleg->curr().get_real (ALL_IVAESP); - _all->niesp += alleg->curr().get_real (ALL_NIESP); - _all->e8esp += alleg->curr().get_real (ALL_E8ESP); - _all->ndocesp += alleg->curr().get_int (ALL_NDOCESP); + _all->impesp += alleg.get_real (ALL_IMPESP); + _all->ivaesp += alleg.get_real (ALL_IVAESP); + _all->niesp += alleg.get_real (ALL_NIESP); + _all->e8esp += alleg.get_real (ALL_E8ESP); + _all->ndocesp += alleg.get_int (ALL_NDOCESP); // Incremento totali di riga _all->tot_rigac += _all->impesc + _all->ivaesc + _all->niesc + _all->e8esc; @@ -217,7 +216,7 @@ void SortRecord::somma (TLocalisamfile * alleg, stampe tipo_stampa) case modulo101: case modulo102: - _all->prog101102 += alleg->get_real("ALL_PROG101102"); + _all->prog101102 += alleg.get_real("ALL_PROG101102"); break; default: @@ -289,19 +288,19 @@ void SortRecord::azzera_struttura() // Scarta i record con l'anno diverso da quello specificato // nella maschera. // -void SortRecord::compila(TLocalisamfile * _alleg) +void SortRecord::compila(const TRectype& alleg) { TString tipoa; long codcf; // azzera_struttura(); - tipoa = _alleg->curr().get (ALL_TIPOCF); + tipoa = alleg.get (ALL_TIPOCF); strcpy (_all->tipopers_dett, tipoa); // strcpy (_all->tipopers_dett, _alleg->curr().get (ALL_TIPOCF)); - codcf = _alleg->curr().get_long (ALL_CODCF); + codcf = alleg.get_long (ALL_CODCF); _all->codcf_dett = codcf; // _RecordSort->Strutt()->codcf_dett = _alleg->curr().get_long (ALL_CODCF); @@ -311,23 +310,23 @@ void SortRecord::compila(TLocalisamfile * _alleg) // // QUI CAMBIA IL CODICE ATTIVITA // - strcpy (_all->codatt_dett, _alleg->curr().get (ALL_CODATT)); + strcpy (_all->codatt_dett, alleg.get (ALL_CODATT)); - _all->immesso = _alleg->curr().get_bool (ALL_IMMESSO); + _all->immesso = alleg.get_bool (ALL_IMMESSO); - _all->impesc = _alleg->curr().get_real (ALL_IMPESC); - _all->ivaesc = _alleg->curr().get_real (ALL_IVAESC); - _all->niesc = _alleg->curr().get_real (ALL_NIESC); - _all->e8esc = _alleg->curr().get_real (ALL_E8ESC); - _all->ndocesc = _alleg->curr().get_int (ALL_NDOCESC); + _all->impesc = alleg.get_real (ALL_IMPESC); + _all->ivaesc = alleg.get_real (ALL_IVAESC); + _all->niesc = alleg.get_real (ALL_NIESC); + _all->e8esc = alleg.get_real (ALL_E8ESC); + _all->ndocesc = alleg.get_int (ALL_NDOCESC); - _all->impesp = _alleg->curr().get_real (ALL_IMPESP); - _all->ivaesp = _alleg->curr().get_real (ALL_IVAESP); - _all->niesp = _alleg->curr().get_real (ALL_NIESP); - _all->e8esp = _alleg->curr().get_real (ALL_E8ESP); - _all->ndocesp = _alleg->curr().get_int (ALL_NDOCESP); + _all->impesp = alleg.get_real (ALL_IMPESP); + _all->ivaesp = alleg.get_real (ALL_IVAESP); + _all->niesp = alleg.get_real (ALL_NIESP); + _all->e8esp = alleg.get_real (ALL_E8ESP); + _all->ndocesp = alleg.get_int (ALL_NDOCESP); - _all->prog101102 = _alleg->curr().get_real (ALL_PROG101102); + _all->prog101102 = alleg.get_real (ALL_PROG101102); fill_dati_dettaglio (tipoa, codcf); } @@ -523,45 +522,47 @@ void Array_desc_campi::leggi_modulo (const char * file, const char *modulo) { TScanner s(file); - s.paragraph (modulo); - - s.equal(); - _passo = s.integer(); - - s.equal(); - _righe_modulo = s.integer(); - - int riga; - TString formato; - - while (s.ok()) + if (s.paragraph(modulo)) { - riga = s.integer(); - formato = s.string(); - - add (riga, formato); + s.equal(); + _passo = s.integer(); + + s.equal(); + _righe_modulo = s.integer(); + + while (s.ok()) + { + const int riga = s.integer(); + if (riga <= 0) // Ho raggiunto una riga vuota in fondo + break; + const TString& formato = s.string(); + add (riga, formato); + } } + else + error_box("Impossibile trovare la sezione '%s' sul file '%s'", modulo, file); } -void Array_desc_campi::add(int r, const char * f) +void Array_desc_campi::add(int r, const char* f) { - desc_campo * descr = new desc_campo; + CHECKD(r > 0, "Bad print row ", r); + desc_campo * descr = new desc_campo; descr->_riga = r; descr->_formato = f; - - _campi.add (descr); + _campi.add(descr); + } // // Record_B // -void Record_B::compila(TLocalisamfile *all) +void Record_B::compila(const TRectype& all) { - esc = all->get_int (ALL_NDOCESC); - impesc = all->get_real (ALL_IMPESC); - ivaesc = all->get_real (ALL_IVAESC); + esc = all.get_int (ALL_NDOCESC); + impesc = all.get_real(ALL_IMPESC); + ivaesc = all.get_real(ALL_IVAESC); tot = impesc + ivaesc; } diff --git a/cg/cg4300.h b/cg/cg4300.h index a1c4099ff..7bf838cbe 100755 --- a/cg/cg4300.h +++ b/cg/cg4300.h @@ -161,7 +161,7 @@ public: TString _s0, _s1, _s2, _s3, _s4, _s5, _s6; real _r0, _r1, _r2, _r3, _r4, _r5, _r6, _r7, _r8, _r9, _r10, _r11, _r12, - _r13, _r14, _r15, _r16, _r17, _r18, _r19; + _r13, _r14, _r15, _r16, _r17, _r18, _r19, _r20; TArray _arr; TDate _d0; diff --git a/cg/cg4301.cpp b/cg/cg4301.cpp index ad735070a..d23db3744 100755 --- a/cg/cg4301.cpp +++ b/cg/cg4301.cpp @@ -3183,16 +3183,14 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) { // Riporta eventuale credito nella tabella parametri liquidazione dell'anno successivo const real riporto = credito_utilizzabile - risultato; - if (riporto > ZERO) // Risultato a credito + if (riporto >= ZERO) // Risultato a credito { - const TString16 yr = _year; - _year.format("%d", atoi(_year) + 1); - if (look_lia(0l, TRUE)) + const int anno_prossimo = atoi(_year) + 1; + if (look_lia(0l, TRUE, anno_prossimo)) { _lia->put("R0", riporto); _lia->rewrite(); } - _year = yr; } } // ciapa diff --git a/cg/cg4304.cpp b/cg/cg4304.cpp index 79ad6ecb8..0f92642f8 100755 --- a/cg/cg4304.cpp +++ b/cg/cg4304.cpp @@ -1041,12 +1041,13 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool _descr_arr.add(t); } -void TLiquidazione_app::describe_liq(int month, const char* codatts, - _DescrItem* di) +void TLiquidazione_app::describe_liq(int month, const char* codatts, _DescrItem* di) { - if (!_isprint || !_canprint) return; + if (!_isprint || !_canprint) + return; - if (!look_lim(month)) return; + if (!look_lim(month)) + return; _DescrItem* d = new _DescrItem(THE_END); @@ -1096,6 +1097,13 @@ void TLiquidazione_app::describe_liq(int month, const char* codatts, // analogamente in Visualizzazione ma solo nel caso dell'annuale. // In tutti gli altri casi va a cercare la delega d->_r8 = (_month == 13 || !_is_visliq) ? _lim->get_real("R8") : versamenti_IVA(_month, "1"); + + if (_month == 13) + { + const int anno_prossimo = atoi(_year)+1; + if (look_lia(0l, FALSE, anno_prossimo)) + d->_r20 = _lia->get_real("R0"); // Credito da riportare all'anno prossimo + } // aggiunge eventuale satellite per rimborso infraannuale if (di != NULL) @@ -2010,15 +2018,15 @@ void TLiquidazione_app::print_importo(int rw, const char* prompt, real imp, bool void TLiquidazione_app::set_grand_2000(_DescrItem& d, int &rw) { - real& risultato = d._r0; - real& rimborso = d._r1; - real& cred_cost = d._r2; - real& deb_mens = d._r3; - real& rettifiche = d._r5; - real& detrazioni = d._r6; - real& interessi = d._r7; - real& versamenti = d._r8; - real& vers_int = d._r9; + const real& risultato = d._r0; + const real& rimborso = d._r1; + const real& cred_cost = d._r2; + const real& deb_mens = d._r3; + const real& rettifiche = d._r5; + const real& detrazioni = d._r6; + const real& interessi = d._r7; + const real& versamenti = d._r8; + const real& vers_int = d._r9; TToken_string tt(d._s0); real iva_vend(tt.get(0)); real iva_acq(tt.get(1)); @@ -2140,17 +2148,9 @@ void TLiquidazione_app::set_grand_2000(_DescrItem& d, int &rw) { if (_isannual) { - const int year = atoi(_year)+1; - const long ditta = get_firm(); - TString16 cod; cod.format("%05ld%04d", ditta, year); - TTable lia("%LIA"); - lia.put("CODTAB", cod); - if (lia.read() == NOERR) - { - real credito = lia.get_real("R0"); - if (credito > ZERO) - set_row(rw++,"@11gCREDITO RIPORTATO NELL'ANNO SUCCESSIVO@58g%r", &credito); - } + const real& credito = d._r20; + if (credito > ZERO) + set_row(rw++,"@11gCREDITO RIPORTATO NELL'ANNO SUCCESSIVO@58g%r", &credito); } if (_is_visliq) rw++; diff --git a/cg/cg5300.cpp b/cg/cg5300.cpp index 00748829b..cfe4ed6fe 100755 --- a/cg/cg5300.cpp +++ b/cg/cg5300.cpp @@ -130,14 +130,11 @@ bool TParaliq_app::credres_handler(TMask_field& f, KEY k) { if (f.to_check(k)) { + const TMask& m = f.mask(); real r(f.get()); - TCurrency cur(r, f.mask().get(F_CODVAL)); - const int ndec = cur.decimals(); // Decimali di questa valuta per gli importi - - // Arrotondamento alle migliaia nel caso il numero - // di decimali della ditta sia zero (come per le lire) - // altrimenti all'unità - r.round(ndec == 0 ? -3 : 0); + const bool euro = is_euro_value(m.get(F_CODVAL)); + // Arrotondamento alle migliaia le Lire e rispetto i parametri in Euro + r.round(euro ? m.get_int(F_ROUNDDIC) : -3); f.set(r.string()); } @@ -159,14 +156,11 @@ bool TParaliq_app::credpreccost_handler(TMask_field& f, KEY k) { if (f.to_check(k)) { + const TMask& m = f.mask(); real r(f.get()); - TCurrency cur(r, f.mask().get(F_CODVAL)); - const int ndec = cur.decimals(); // Decimali di questa valuta per gli importi - - // Arrotondamento alle migliaia nel caso il numero - // di decimali della ditta sia zero (come per le lire) - // altrimenti all'unità - r.round(ndec == 0 ? -3 : 0); + const bool euro = is_euro_value(m.get(F_CODVAL)); + // Arrotondamento alle migliaia le Lire e rispetto i parametri in Euro + r.round(euro ? m.get_int(F_ROUNDDIC) : -3); f.set(r.string()); } return TRUE; diff --git a/cg/cglib02.cpp b/cg/cglib02.cpp index 086b433f9..52918c13c 100755 --- a/cg/cglib02.cpp +++ b/cg/cglib02.cpp @@ -5,8 +5,7 @@ // ///////////////////////////////////////////////////////////////////////////// -#include - +#include #include #include #include @@ -199,10 +198,8 @@ bool TSaldo::leggi_mov(long nr) //per bilancio scalare (ovvero a sezioni contrapposte) per data limite bool TSaldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDate& data_inf, - const TDate& data_sup, int indbil, int stp_prov) -{ - TLocalisamfile rmov(LF_RMOV); - + const TDate& data_sup, int indbil, int stp_prov, const char* filter) +{ _saldo_iniziale = ZERO; _saldo = ZERO; _movimentato = FALSE; @@ -210,45 +207,24 @@ bool TSaldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDat _rec_presente_ec = FALSE; _prec = FALSE; - rmov.setkey(2); + TRelation rel(LF_RMOV); + TRectype& rmov = rel.curr(); + rmov.zero(); rmov.put(RMV_GRUPPO,g); rmov.put(RMV_CONTO,c); rmov.put(RMV_SOTTOCONTO,s); - + TCursor cur(&rel, filter, 2, &rmov, &rmov); + const TRecnotype items = cur.items(); + cur.freeze(); + // Anche se non movimentato vado a vedere il saldo - if (stp_prov != 3) + if (stp_prov != 3 && (filter == NULL || *filter == '\0')) _saldo = calcola_saldo_iniziale(g,c,s,indbil); - -#ifdef DBG - long num_rec = 0; - const clock_t clock_start = clock(); -#endif - for (rmov.read(_isgteq); !rmov.eof(); rmov.next()) + for (cur = 0L; cur.pos() < items; ++cur) { - const int gruppo = rmov.get_int(RMV_GRUPPO); - const int conto = rmov.get_int(RMV_CONTO); - const long sottoconto = rmov.get_long(RMV_SOTTOCONTO); - if (gruppo != g || conto != c || sottoconto != s) - break; - -#ifdef DBG - num_rec++; - if ((num_rec & 0x7F) == 0) - { - const double sec = (clock() - clock_start) / CLOCKS_PER_SEC; - if (sec > 0.0) - { - TString80 msg; - msg.format("%ld records at %ld rec/sec", num_rec, long(num_rec/sec)); - xvt_statbar_set(msg); - do_events(); - } - } -#endif - - const long num_reg = rmov.get_long(RMV_NUMREG); + const long num_reg = rmov.get_long(RMV_NUMREG); TDate data_mov; // Leggo la testata diff --git a/cg/cglib02.h b/cg/cglib02.h index 0b56803c1..f42063ec9 100755 --- a/cg/cglib02.h +++ b/cg/cglib02.h @@ -108,7 +108,7 @@ public: bool ultima_immissione_bilancio(int anno,int g,int c,long s,int indbil,int prov,bool saldo_chiusura = TRUE); bool ultima_immissione_verifica(int anno,int g,int c,long s,int indbil,int prov); - bool data_limite_bilancio(int,int,int,long,const TDate&,const TDate&,int,int); + bool data_limite_bilancio(int,int,int,long,const TDate&,const TDate&,int,int, const char* = NULL); bool ricerca_progr_prec(int, int, int, long); diff --git a/cg/cglib03.cpp b/cg/cglib03.cpp index 491228531..66a9efbb9 100755 --- a/cg/cglib03.cpp +++ b/cg/cglib03.cpp @@ -174,7 +174,7 @@ void TIva_round::set_default_iva_mode(int year, bool declaration, long ditta) set_default_mode(rm_round, dec); } else - set_default_mode(rm_millelire, 3); + set_default_mode(rm_millelire, -3); } void TIva_round::round(real& n) const diff --git a/cg/cglib04.cpp b/cg/cglib04.cpp index 2f7c7531d..3e3ed1274 100755 --- a/cg/cglib04.cpp +++ b/cg/cglib04.cpp @@ -1461,7 +1461,8 @@ int TTransfer_file::annoes_datacomp(const TString& record, TDate& datacomp) void TTransfer_file::decimali(TString& campo, int dec) { if (dec > 0) - { + { +/* const int l = campo.len(); if (l >= dec) { @@ -1469,6 +1470,28 @@ void TTransfer_file::decimali(TString& campo, int dec) if (p == 0 || campo[p-1] != '.') campo.insert(".", p); } +*/ + if (campo.find('.') < 0) // Controlla che non ci sia già la virgola! + { + int l = campo.len(); + if (campo[0] == '-') + { + while (l-1 <= dec) + { + campo.insert("0", 1); // Aggiunge sù quanti zeri dopo il meno + l++; + } + } + else + { + while (l <= dec) + { + campo.insert("0", 0); // Aggiunge sù quanti zeri in testa + l++; + } + } + campo.insert(".", l-dec); + } } } @@ -1529,7 +1552,6 @@ void TTransfer_file::negativo(TString& importo) // Controlla se la ditta è in euro static bool ditta_in_euro() { -// return TCurrency::get_firm_dec() != 0; return is_euro_value(NULL); } @@ -1611,7 +1633,7 @@ void TTransfer_file::write_tmp_movPN(TString& record) negativo(field); // Cerco di riconoscere gli importi in euro - if (dec == 0 && (to-from) >= 8 && record.size()<1024 && ditta_in_euro()) + if (dec == 0 && (to-from) >= 8 && record.size()==sizeT && ditta_in_euro()) { flag = 3; dec = 2; @@ -1623,8 +1645,8 @@ void TTransfer_file::write_tmp_movPN(TString& record) if (dec > 0) decimali(field,dec); // Non capisco a cosa serva ma mi adeguo: forse toglie gli zeri iniziali - real appoggio = field; - field = appoggio.string(); + const real appoggio = field; + field = appoggio.string(0, dec); } if (logicnum == LF_MOV) @@ -1642,11 +1664,8 @@ void TTransfer_file::write_tmp_movPN(TString& record) //di un numero va riempito con degli 0. Se si tratta di un alfa va allineato a destra. if (fname == "CODPAG") { - TString f = field; - //if (real::is_natural(f)) - // field.format("%04s", (const char*) f); - //else - field.format("%-4s", (const char*) f); + const TString8 f = field; + field.format("%-4s", (const char*)f); } if (fname == "CODCAUS") @@ -1709,7 +1728,7 @@ void TTransfer_file::write_tmp_movPN(TString& record) } if (flag == 2) { - TString f = converti(field,FALSE); + const TString80 f = converti(field,FALSE); dep->put(fname,f); } } @@ -1930,7 +1949,7 @@ void TTransfer_file::write_tmp_movIVA(TString& record) negativo(field); // Cerco di riconoscere gli importi in euro - if (dec == 0 && (to-from) >= 8 && record.size()<1024 && ditta_in_euro()) + if (dec == 0 && (to-from) >= 8 && record.size()==sizeT && ditta_in_euro()) { flag = 3; dec = 2; @@ -1941,9 +1960,8 @@ void TTransfer_file::write_tmp_movIVA(TString& record) { if (dec > 0) decimali(field,dec); - - real appoggio (field); - field = appoggio.string(); + const real appoggio = field; + field = appoggio.string(0, dec); } if (logicnum == LF_RMOVIVA) @@ -2133,9 +2151,10 @@ void TTransfer_file::write_tmp_movSC(TString& record) _prog->addstatus(1); } -void TTransfer_file::calcola_imposta(TString& field, real& imposta) +/* Guy: Funzione in disuso??? +void TTransfer_file::calcola_imposta(const TString& field, real& imposta) { - TString buffer; + TString256 buffer; TRecnotype rec = _ttab->recno(); TIsamtempfile& tab = *_ttab; @@ -2161,12 +2180,12 @@ void TTransfer_file::calcola_imposta(TString& field, real& imposta) if (ditta_in_euro()) app.insert(".", app.len()-2); - real imp (app); + const real imp = app; imposta += imp; } _ttab->readat(rec); } - +*/ bool TTransfer_file::solo_SC(TString& field) { @@ -2283,7 +2302,7 @@ void TTransfer_file::partita(TString& record) negativo(field); // Cerco di riconoscere gli importi in euro - if (dec == 0 && (to-from) >= 8 && record.size()<1024 && ditta_in_euro()) + if (dec == 0 && (to-from) >= 8 && record.size()==sizeT && ditta_in_euro()) { flag = 3; dec = 2; @@ -2294,9 +2313,8 @@ void TTransfer_file::partita(TString& record) { if (dec > 0) decimali(field,dec); - - real appoggio (field); - field = appoggio.string(); + const real appoggio = field; + field = appoggio.string(0, dec); } if (fname == "TIPOC") @@ -2478,9 +2496,8 @@ void TTransfer_file::scadenza(TString& record) { if (dec > 0) decimali(field,dec); - - real appoggio (field); - field = appoggio.string(); + const real appoggio = field; + field = appoggio.string(0, dec); } if (fname == "IMPORTO") @@ -4259,9 +4276,8 @@ void TTransfer_file::write_testata_movimenti(TString& record) { if (dec > 0) decimali(field,dec); - - real appoggio (field); - field = appoggio.string(); + const real appoggio = field; + field = appoggio.string(0, dec); } if (fname == MOV_DESCR) @@ -4477,8 +4493,8 @@ void TTransfer_file::write_righe_contabili(TString& record) if (dec > 0) decimali(field,dec); - real appoggio (field); - field = appoggio.string(); + const real appoggio = field; + field = appoggio.string(0, dec); } if (fname == RMV_IMPORTO) @@ -4620,9 +4636,8 @@ void TTransfer_file::write_righe_IVA(TString& record) { if (dec > 0) decimali(field,dec); - - real appoggio (field); - field = appoggio.string(); + const real appoggio = field; + field = appoggio.string(0, dec); } if (fname == RMI_NUMRIG) { @@ -4824,9 +4839,8 @@ void TTransfer_file::write_partite(TString& record) { if (dec > 0) decimali(field,dec); - - real appoggio (field); - field = appoggio.string(); + const real appoggio = field; + field = appoggio.string(0, dec); } if (fname == PART_NREG) @@ -4963,9 +4977,8 @@ void TTransfer_file::write_scadenze(TString& record) { if (dec > 0) decimali(field,dec); - - real appoggio (field); - field = appoggio.string(); + const real appoggio = field; + field = appoggio.string(0, dec); } if (fname == SCAD_GRUPPO || fname == SCAD_CONTO) @@ -5111,9 +5124,8 @@ void TTransfer_file::write_pagsca(TString& record) { if (dec > 0) decimali(field,dec); - - real appoggio (field); - field = appoggio.string(); + const real appoggio = field; + field = appoggio.string(0, dec); } if (fname == PAGSCA_GRUPPO || fname == PAGSCA_CONTO || diff --git a/cg/cglib04.h b/cg/cglib04.h index 0beb9d691..9d4403578 100755 --- a/cg/cglib04.h +++ b/cg/cglib04.h @@ -219,7 +219,7 @@ private: void partita (TString& record); void scadenza(TString& record); void pagsca (TString& record); - void calcola_imposta(TString& numreg, real& imposta); + void calcola_imposta(const TString& numreg, real& imposta); void calcola_impdocval(long nreg,int nrig,TString& record); bool solo_SC(TString& numreg); void calcola_importo(TString& record); diff --git a/cg/cgsaldac.cpp b/cg/cgsaldac.cpp index 41b30f0cb..5fca8017e 100755 --- a/cg/cgsaldac.cpp +++ b/cg/cgsaldac.cpp @@ -1620,9 +1620,10 @@ TImporto TPartita::importo_pagato_unassigned(bool val, int mode) const if (in_val && !val) // Gli abbuoni sono sempre in valuta e quindi { // devono essere convertiti opportunamente // abb *= sum.get_real(PART_CAMBIO); -// abb.round(); - TCurrency cur(abb, "_FIRM"); - cur *= sum.get_real(PART_CAMBIO); +// abb.round(); + const TExchange cmb(sum); + TCurrency cur(abb, cmb); + cur.change_to_firm_val(); abb = cur.get_num(); } totale += TImporto(sez, abb); diff --git a/db/db1100.cpp b/db/db1100.cpp index 063fe9e5d..9da0a92b7 100755 --- a/db/db1100.cpp +++ b/db/db1100.cpp @@ -142,6 +142,7 @@ class TRiga_esplosione2print : public TRiga_esplosione real _totordfor; TDate _dtacons; TString8 _codmag; + TToken_string _cod_corr; public: const TString& mag() const { return _codmag; } @@ -164,20 +165,39 @@ public: void set_qta2order(const real& r) { _qta2order = r; } void set_ordfor(const real& r) { _ordfor = r; } void set_totordfor(const real& r) { _totordfor = r; } - TRiga_esplosione2print() {}; + const TString& codici_corrispontenti(char tipo) const; + TRiga_esplosione2print() : _cod_corr(80, '\n') {}; TRiga_esplosione2print(const TDistinta_tree& tree, const char *codmag); TRiga_esplosione2print(const TRiga_esplosione& re, const char *codmag); ~TRiga_esplosione2print() {}; }; +const TString& TRiga_esplosione2print::codici_corrispontenti(char tipo) const +{ + TRectype key(LF_CODCORR); + key.put("CODART", articolo()); + TRecord_array a(key, "NRIGA"); + + TToken_string& lista = (TToken_string&)_cod_corr; // Fool the compiler + lista.cut(0); + + const int last = a.last_row(); + for (int i = a.first_row(); i > 0 && i <= last; i = a.succ_row(i)) + { + const TRectype& row = a.row(i); + if (tipo < ' ' || row.get_char("TIPO") == tipo) + lista.add(row.get("CODARTALT")); + } + return lista; +} TRiga_esplosione2print::TRiga_esplosione2print(const TDistinta_tree& tree, const char *codmag) - : TRiga_esplosione(tree), _codmag(codmag) + : TRiga_esplosione(tree), _codmag(codmag), _cod_corr(80, '\n') { } TRiga_esplosione2print::TRiga_esplosione2print(const TRiga_esplosione& re, const char *codmag) - : TRiga_esplosione(re), _codmag(codmag) + : TRiga_esplosione(re), _codmag(codmag), _cod_corr(80, '\n') { } @@ -280,7 +300,8 @@ class TEsplosione_distinta_app : public TSkeleton_application TCodgiac_livelli *_liv_giac; // Dati "i/n/m/putati" ma non ancora condannati... _ParmStruct _parameters; - + int _default_code_width; + protected: static bool sheet_notify(TSheet_field& s, int r, KEY key); virtual bool create(); @@ -763,123 +784,164 @@ bool TExplode_distinta_form::validate(TForm_item &f, TToken_string &t) TRiga_esplosione2print& re = (TRiga_esplosione2print&) _exploded_tree[_curr_row]; const char tipo = re.tipo(); - if (code == "_COD") - { - int liv = re.livello(); - if (liv > 0) // Calcola indentazione - { - if (_p->_separate_dist) - { - if (liv > 10) liv = 10; - if (_p->_ordering) - valore.format("%8ld%*s", re.ordinamento(), liv, ""); - else - valore.spaces(liv); - } - } - else - valore = "@B"; // Radice in grassetto - valore << re.articolo(); - } - else - if (code == "_DES") + if (code[0] != '_') + { + const char tiporiga = t.get()[0]; + if (tipo == tiporiga) { - const TRelation* rel = relation(); - switch (tipo) { case 'A': { - valore = _art_cache.get(re.articolo()).get(ANAMAG_DESCR); + valore = _art_cache.get(re.articolo()).get(code); break; } case 'L': { const TLavorazione lav(re.articolo()); - valore = lav.descr(); + valore = lav.get(code); + break; } case 'V': { - TLocalisamfile& dist = rel->lfile(); + TLocalisamfile& dist = relation()->lfile(); dist.put("CODDIST", re.articolo()); if (dist.read() == NOERR) - valore = dist.get("DESCR"); + valore = dist.get(code); break; } default: break; } - if (livelli_giacenza().enabled()) - { - TString lv = re.giacenza(); - for (int l = livelli_giacenza().last_level(); l > 0 ; l--) - lv.insert(" ",livelli_giacenza().packed_length(l)); - valore.insert(lv); - } } - else - if (code == "_LIV") - { - if (_p->_separate_dist && re.livello() > 0) - valore << re.livello(); + } + else + { + if (code == "_COD") + { + int liv = re.livello(); + if (liv > 0) // Calcola indentazione + { + if (_p->_separate_dist) + { + if (liv > 10) liv = 10; + if (_p->_ordering) + valore.format("%8ld%*s", re.ordinamento(), liv, ""); + else + valore.spaces(liv); + } } else - if (code == "_DCO") + valore = "@B"; // Radice in grassetto + valore << re.articolo(); + } + else + if (code == "_DES") + { + const TRelation* rel = relation(); + + switch (tipo) { - //if (re.articolo() == _d->cod()) - valore = re.datacons(); + case 'A': + { + valore = _art_cache.get(re.articolo()).get(ANAMAG_DESCR); + break; + } + case 'L': + { + const TLavorazione lav(re.articolo()); + valore = lav.descr(); + break; + } + case 'V': + { + TLocalisamfile& dist = rel->lfile(); + dist.put("CODDIST", re.articolo()); + if (dist.read() == NOERR) + valore = dist.get("DESCR"); + break; + } + default: + break; + } + if (livelli_giacenza().enabled()) + { + TString lv = re.giacenza(); + for (int l = livelli_giacenza().last_level(); l > 0 ; l--) + lv.insert(" ",livelli_giacenza().packed_length(l)); + valore.insert(lv); + } + } + else + if (code == "_LIV") + { + if (_p->_separate_dist && re.livello() > 0) + valore << re.livello(); } else - if (code == "_UM") - { - valore = re.um(); - } - else - if (code == "_FAB") + if (code == "_DCO") + { + //if (re.articolo() == _d->cod()) + valore = re.datacons(); + } + else + if (code == "_UM") { - valore = re.fabbisogno().string(); + valore = re.um(); } else - if (code == "_DIS") + if (code == "_FAB") { - valore = re.disponibilita().string(); + valore = re.fabbisogno().string(); } else - if (code == "_ORDPROD") + if (code == "_DIS") { - valore = re.qta2order().string(); + valore = re.disponibilita().string(); } else - if (code == "_RESIDUO") + if (code == "_ORDPROD") { - valore = re.residuo().string(); + valore = re.qta2order().string(); } else - if (code == "_VALORE") + if (code == "_RESIDUO") { - valore = re.value().string(); + valore = re.residuo().string(); } else - if (code == "_VALOREUNIT") + if (code == "_VALORE") { - valore = re.unitary_value().string(); + valore = re.value().string(); } else - if (code == "_ORDFOR") + if (code == "_VALOREUNIT") { - valore = re.ordfor().string(); + valore = re.unitary_value().string(); } else - if (code == "_TOTORDFOR") + if (code == "_ORDFOR") { - valore = re.totordfor().string(); + valore = re.ordfor().string(); } else - if (code == "_CODFORN") - { - valore = _art_cache.get(re.articolo()).get(ANAMAG_CODFORN); + if (code == "_TOTORDFOR") + { + valore = re.totordfor().string(); } + else + if (code == "_CODFORN") + { + valore = _art_cache.get(re.articolo()).get(ANAMAG_CODFORN); + } + else + if (code == "_CODCORR") + { + const char tipo = t.get()[0]; + valore = re.codici_corrispontenti(tipo); + } + } f.set(valore); return TRUE; } @@ -1259,7 +1321,12 @@ void TExplode_distinta_form::print_explosion_rows() if (pr.rows_left() <= (h+1)) pr.formfeed(); for (word j = 0; j < h; j++) - pr.print(body.row(j)); + { + TPrintrow& r = body.row(j); + const TFixed_string t(r.row()); + if (!t.blank()) + pr.print(r); + } } set_last_page(TRUE); @@ -1434,7 +1501,8 @@ bool TEsplosione_distinta_app::check_articoli(TMask_field& f, KEY k) bool TEsplosione_distinta_app::create() { open_files(LF_TAB, LF_TABCOM, LF_UMART, LF_OCCAS, LF_CLIFO, LF_DIST, 0); - open_files(LF_DOC, LF_RIGHEDOC, LF_INDSP, LF_CFVEN, LF_MAG, LF_STOMAG, 0); + open_files(LF_DOC, LF_RIGHEDOC, LF_INDSP, LF_CFVEN, LF_MAG, LF_STOMAG, LF_CODCORR, 0); + _mask = new TMask("db1100a"); TSheet_field& sa = (TSheet_field&) _mask->field(F_SHEETART); sa.sheet_mask().set_handler(F_QTA, check_articoli); @@ -1444,8 +1512,6 @@ bool TEsplosione_distinta_app::create() _mask->set(F_VIRTUALI, "X"); if (!livelli_giacenza().enabled()) //TBI _mask->hide(F_SEPARATE_GIAC); - - rec_cache(LF_TAB).test_file_changes(FALSE); @@ -1460,6 +1526,10 @@ bool TEsplosione_distinta_app::create() } _form = new TExplode_distinta_form("db1100a"); + + TForm_item& fi_cod = _form->find_field('B', odd_page, 1); + _default_code_width = fi_cod.width(); + _liv_giac = new TCodgiac_livelli; _liv_giac->set_sheetcolumn(sa, F_LIV1, 1); _liv_giac->set_sheetcolumn(sa, F_LIV2, 2); @@ -1676,7 +1746,7 @@ void TEsplosione_distinta_app::print() // Calcola la larghezza della colonna codice TForm_item& fi_cod = _form->find_field('B', odd_page, 1); - int c_width = 20; + int c_width = _default_code_width; if (_parameters._separate_dist) { c_width += 10; @@ -1815,4 +1885,4 @@ int db1100(int argc, char* argv[]) a->run(argc, argv, "Stampa esplosione"); delete a; return 0; -} +} \ No newline at end of file diff --git a/db/db1100a.frm b/db/db1100a.frm index 4470e0a5a..e2602eb09 100755 --- a/db/db1100a.frm +++ b/db/db1100a.frm @@ -50,7 +50,7 @@ END //HEADER SECTION BODY ODD 1 COLUMNWISE -STRING 1 30 +STRING 1 20 BEGIN SPECIAL STRINGA INTESTAZIONE "Codice" "Codice" SPECIAL NUMERO OFFSET "0" "Offset iniziale campo" diff --git a/ef/batbbnp.h b/ef/batbbnp.h index b3304019f..9985482f3 100755 --- a/ef/batbbnp.h +++ b/ef/batbbnp.h @@ -8,8 +8,8 @@ #define F_ISTIT 104 #define F_DENOM 105 #define F_CAB 106 -#define F_CC_INC 107 -//#define F_FIDO_INC 108 + +#define F_CC_INC 107 #define F_CC_CONT_INC 109 #define F_CC_SBF 110 #define F_FIDO_SBF 111 @@ -27,4 +27,7 @@ #define F_CONTO_SCN 123 #define F_SOTTOC_SCN 124 #define F_CBI 125 +#define F_DESCR_INC 126 +#define F_DESCR_SBF 127 +#define F_DESCR_SCN 128 #endif//__BATBBNP_H diff --git a/ef/batbbnp.uml b/ef/batbbnp.uml index 11d8a1951..8521a9ec8 100755 --- a/ef/batbbnp.uml +++ b/ef/batbbnp.uml @@ -58,7 +58,6 @@ BEGIN DISPLAY "CAB@5" CODTAB[6,10] DISPLAY "Denominazione@50" 100@->S0 OUTPUT F_ABI CODTAB[1,5] -//OUTPUT F_ISTIT %BAN->S0 MESSAGE COPY,F_CODICEABI MESSAGE CHECK,F_CODICEABI CHECKTYPE REQUIRED @@ -97,7 +96,7 @@ BEGIN FLAG "D" END -GROUPBOX DLG_NULL 78 4 +GROUPBOX DLG_NULL 78 5 BEGIN PROMPT 1 4 "Portafoglio Effetti all' incasso" END @@ -108,15 +107,6 @@ BEGIN FIELD BNP->S0 END -/* -NUMBER F_FIDO_INC 20 2 -BEGIN - PROMPT 45 5 "Fido " - FIELD BNP->R0 - PICTURE "###.###.###.###,@@" -END -*/ - STRING F_CC_CONT_INC 20 BEGIN PROMPT 2 6 "C/Contabile " @@ -125,33 +115,25 @@ END NUMBER F_GRUPPO_INC 3 BEGIN - PROMPT 36 6 "Conto contropartita " + PROMPT 2 7 "Contropartita " FIELD I0 CHECKTYPE NORMAL END NUMBER F_CONTO_INC 3 BEGIN - PROMPT 61 6 "" + PROMPT 21 7 "" FIELD I1 - USE LF_PCON SELECT CONTO!="" - INPUT GRUPPO F_GRUPPO_INC - INPUT CONTO F_CONTO_INC - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Descrizione@50" DESCR - OUTPUT F_GRUPPO_INC GRUPPO - OUTPUT F_CONTO_INC CONTO CHECKTYPE NORMAL END NUMBER F_SOTTOC_INC 6 BEGIN - PROMPT 68 6 "" + PROMPT 28 7 "" FIELD I2 - USE LF_PCON SELECT SOTTOCONTO!="" + USE LF_PCON KEY 1 SELECT SOTTOCONTO!="" INPUT GRUPPO F_GRUPPO_INC - INPUT CONTO F_CONTO_INC + INPUT CONTO F_CONTO_INC INPUT SOTTOCONTO F_SOTTOC_INC DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO @@ -160,62 +142,68 @@ BEGIN OUTPUT F_GRUPPO_INC GRUPPO OUTPUT F_CONTO_INC CONTO OUTPUT F_SOTTOC_INC SOTTOCONTO + OUTPUT F_DESCR_INC DESCR CHECKTYPE NORMAL END -GROUPBOX DLG_NULL 78 4 +STRING F_DESCR_INC 50 38 BEGIN - PROMPT 1 8 "Portafoglio Effetti salvo buon fine" + PROMPT 38 7 "" + USE LF_PCON KEY 2 + INPUT DESCR F_DESCR_INC + DISPLAY "Descrizione@50" DESCR + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + COPY OUTPUT F_SOTTOC_INC + CHECKTYPE NORMAL +END + +GROUPBOX DLG_NULL 78 5 +BEGIN + PROMPT 1 9 "Portafoglio Effetti salvo buon fine" END STRING F_CC_SBF 20 BEGIN - PROMPT 2 9 "C/C " + PROMPT 2 10 "C/C " FIELD BNP->S1 END NUMBER F_FIDO_SBF 20 2 BEGIN - PROMPT 36 9 "Fido " + PROMPT 38 10 "Fido " FIELD BNP->R1 PICTURE "###.###.###.###,@@" END STRING F_CC_CONT_SBF 20 BEGIN - PROMPT 2 10 "C/Contabile " + PROMPT 2 11 "C/Contabile " FIELD BNP->S4 END NUMBER F_GRUPPO_SBF 3 BEGIN - PROMPT 36 10 "Conto contropartita " + PROMPT 2 12 "Contropartita " FIELD I3 CHECKTYPE NORMAL END NUMBER F_CONTO_SBF 3 BEGIN - PROMPT 61 10 "" + PROMPT 21 12 "" FIELD I4 - USE LF_PCON SELECT CONTO!="" - INPUT GRUPPO F_GRUPPO_SBF - INPUT CONTO F_CONTO_SBF - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Descrizione@50" DESCR - OUTPUT F_GRUPPO_SBF GRUPPO - OUTPUT F_CONTO_SBF CONTO CHECKTYPE NORMAL END NUMBER F_SOTTOC_SBF 6 BEGIN - PROMPT 68 10 "" + PROMPT 28 12 "" FIELD I5 - USE LF_PCON SELECT SOTTOCONTO!="" + USE LF_PCON KEY 1 SELECT SOTTOCONTO!="" INPUT GRUPPO F_GRUPPO_SBF - INPUT CONTO F_CONTO_SBF + INPUT CONTO F_CONTO_SBF INPUT SOTTOCONTO F_SOTTOC_SBF DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO @@ -224,62 +212,68 @@ BEGIN OUTPUT F_GRUPPO_SBF GRUPPO OUTPUT F_CONTO_SBF CONTO OUTPUT F_SOTTOC_SBF SOTTOCONTO + OUTPUT F_DESCR_SBF DESCR CHECKTYPE NORMAL END -GROUPBOX DLG_NULL 78 4 +STRING F_DESCR_SBF 50 38 BEGIN - PROMPT 1 12 "Portafoglio Effetti allo sconto" + PROMPT 38 12 "" + USE LF_PCON KEY 2 + INPUT DESCR F_DESCR_SBF + DISPLAY "Descrizione@50" DESCR + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + COPY OUTPUT F_SOTTOC_SBF + CHECKTYPE NORMAL +END + +GROUPBOX DLG_NULL 78 5 +BEGIN + PROMPT 1 14 "Portafoglio Effetti allo sconto" END STRING F_CC_SCN 20 BEGIN - PROMPT 2 13 "C/C " + PROMPT 2 15 "C/C " FIELD BNP->S2 END NUMBER F_FIDO_SCN 20 2 BEGIN - PROMPT 36 13 "Fido " + PROMPT 38 15 "Fido " FIELD BNP->R2 PICTURE "###.###.###.###,@@" END STRING F_CC_CONT_SCN 20 BEGIN - PROMPT 2 14 "C/Contabile " + PROMPT 2 15 "C/Contabile " FIELD BNP->S5 END NUMBER F_GRUPPO_SCN 3 BEGIN - PROMPT 36 14 "Conto contropartita " + PROMPT 2 17 "Contropartita " FIELD I6 CHECKTYPE NORMAL END NUMBER F_CONTO_SCN 3 BEGIN - PROMPT 61 14 "" + PROMPT 21 17 "" FIELD I7 - USE LF_PCON SELECT CONTO!="" - INPUT GRUPPO F_GRUPPO_SCN - INPUT CONTO F_CONTO_SCN - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Descrizione@50" DESCR - OUTPUT F_GRUPPO_SCN GRUPPO - OUTPUT F_CONTO_SCN CONTO CHECKTYPE NORMAL END NUMBER F_SOTTOC_SCN 6 BEGIN - PROMPT 68 14 "" + PROMPT 28 17 "" FIELD I8 - USE LF_PCON SELECT SOTTOCONTO!="" + USE LF_PCON KEY 1 SELECT SOTTOCONTO!="" INPUT GRUPPO F_GRUPPO_SCN - INPUT CONTO F_CONTO_SCN + INPUT CONTO F_CONTO_SCN INPUT SOTTOCONTO F_SOTTOC_SCN DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO @@ -288,12 +282,26 @@ BEGIN OUTPUT F_GRUPPO_SCN GRUPPO OUTPUT F_CONTO_SCN CONTO OUTPUT F_SOTTOC_SCN SOTTOCONTO + OUTPUT F_DESCR_SCN DESCR + CHECKTYPE NORMAL +END + +STRING F_DESCR_SCN 50 38 +BEGIN + PROMPT 38 17 "" + USE LF_PCON KEY 2 + INPUT DESCR F_DESCR_SCN + DISPLAY "Descrizione@50" DESCR + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Sottoconto" SOTTOCONTO + COPY OUTPUT F_SOTTOC_SCN CHECKTYPE NORMAL END BOOLEAN F_CBI BEGIN - PROMPT 2 16 "Tracciato SETIF" + PROMPT 2 19 "Tracciato SETIF" FIELD B0 END diff --git a/ef/ef0100.cpp b/ef/ef0100.cpp index 93ea74ff2..85e3bdfd3 100755 --- a/ef/ef0100.cpp +++ b/ef/ef0100.cpp @@ -30,6 +30,7 @@ protected: virtual void init_insert_mode(TMask&); virtual bool get_next_key(TToken_string& key); virtual void init_modify_mode(TMask&); + static bool datascad_handler(TMask_field& f, KEY k); static bool handle_sheet(TMask_field& f, KEY); static bool cambio_handler(TMask_field& f, KEY k); static bool codval_handler(TMask_field& f, KEY k); @@ -120,15 +121,13 @@ bool TVariazione_effetti::get_next_key(TToken_string& key) // ritorna un riferimento allo sheet dei cessionari TSheet_field& TVariazione_effetti::cess_sheet() const { - TSheet_field& o_sheet = (TSheet_field&)_msk->field(F_SHEET_EFF); - return o_sheet; + return _msk->sfield(F_SHEET_EFF); } // ritorna un riferimento allo sheet delle righe TSheet_field& TVariazione_effetti::righe_sheet() const { - TSheet_field& r_sheet = (TSheet_field&)_msk->field(F_SHEET_RIGHE); - return r_sheet; + return _msk->sfield(F_SHEET_RIGHE); } // metodo che permette di scivere su file i dati inseriti nella maschera; @@ -296,13 +295,14 @@ bool TVariazione_effetti::user_create() _msk = new TMask("ef0100a") ; _rel = new TRelation(LF_EFFETTI); _effetto = new TEffetto; + _msk->set_handler(F_DATASCAD, datascad_handler); _msk->set_handler(F_CODVAL, codval_handler); _msk->set_handler(F_CAMBIO, cambio_handler); _msk->set_handler(F_EFFCONT, contab_handler); _msk->set_handler(F_SHEET_RIGHE, handle_sheet); righe_sheet().set_append(TRUE); righe_sheet().set_notify(impeff_notify); - ((TSheet_field &) _msk->field(F_SHEET_RIGHE)).sheet_mask().set_handler(F_NUMFATT, fatt_handler); + _msk->sfield(F_SHEET_RIGHE).sheet_mask().set_handler(F_NUMFATT, fatt_handler); return TRUE; } @@ -324,7 +324,7 @@ bool TVariazione_effetti::handle_sheet(TMask_field &f, KEY k) // se si vuole salvare e si è in uno dei due modi di funzionamento if ( k == K_ENTER && (mode == MODE_INS || mode == MODE_MOD) ) { // si controllano le righe del effetto nello sheet - TSheet_field& sf = (TSheet_field&)m.field(F_SHEET_RIGHE); + TSheet_field& sf = m.sfield(F_SHEET_RIGHE); int items = sf.items(); bool found = FALSE; for (int i = 0; i < items && !found; i++)// scandisco tutte le righe dello sheet @@ -345,19 +345,34 @@ bool TVariazione_effetti::handle_sheet(TMask_field &f, KEY k) return TRUE; } +bool TVariazione_effetti::datascad_handler(TMask_field& f, KEY k) +{ + if (k == K_ENTER) + { + const TDate datascad = f.get(); + TSheet_field& sf = f.mask().sfield(F_SHEET_RIGHE); + FOR_EACH_SHEET_ROW(sf, r, row) + { + TDate datafat = row->get(F_DATAFATT-FIRST_FIELD); + if (datascad < datafat) + return f.error_box("La data fattura della riga %d è successiva alla data di scadenza", r+1); + } + } + return TRUE; +} + // handler che permette il controllo sulla abilitazione dei campi collegati // al codice valuta bool TVariazione_effetti::codval_handler(TMask_field& f, KEY k) { - TMask &m = f.mask(); -// if (k == K_TAB && f.to_check(k, FALSE)) if (f.to_check(k, TRUE)) { - const TString & val = f.get(); - // se non c'e valuta o se è lire disabilito i campi collegati + TMask& m = f.mask(); + const TString& val = f.get(); + // se non c'e valuta o se è lire disabilitato i campi collegati const bool valuta = (val.not_empty() && val != TCurrency::get_firm_val()); m.enable(-1,valuta); - TSheet_field& sf = (TSheet_field&)m.field(F_SHEET_RIGHE); + TSheet_field& sf = m.sfield(F_SHEET_RIGHE); if (!valuta) { m.reset(-1); @@ -386,7 +401,7 @@ bool TVariazione_effetti::cambio_handler(TMask_field& f, KEY k) { const real cambio = f.get(); const TString& valuta = m.get(F_CODVAL); - TSheet_field& sf = (TSheet_field&)m.field(F_SHEET_RIGHE); + TSheet_field& sf = m.sfield(F_SHEET_RIGHE); int items = sf.items(); real imp, impval; // scandisco tutte le righe dello sheet e modifico gli importi in lire @@ -454,7 +469,7 @@ bool TVariazione_effetti::contab_handler(TMask_field& f, KEY k) { TMask &m = f.mask(); const bool da_contab = f.get().empty(); - TSheet_field& sf = (TSheet_field&)m.field(F_SHEET_RIGHE); + TSheet_field& sf = m.sfield(F_SHEET_RIGHE); sf.enable_column(F_ANNO, da_contab); sf.enable_column(F_NUMPART, da_contab); sf.force_update(); @@ -467,7 +482,7 @@ bool TVariazione_effetti::contab_handler(TMask_field& f, KEY k) void TVariazione_effetti::calcola_totali() { TMask* m = app()._msk; - TSheet_field& sf = (TSheet_field&)m->field(F_SHEET_RIGHE); + TSheet_field& sf = m->sfield(F_SHEET_RIGHE); int items = sf.items(); real imp, impval, impeff, impeffval; // scandisco tutte le righe dello sheet e ne prendo gli importi diff --git a/ef/ef0500.cpp b/ef/ef0500.cpp index 116e9991d..72b3f69b6 100755 --- a/ef/ef0500.cpp +++ b/ef/ef0500.cpp @@ -230,18 +230,26 @@ void TEmissione::conferma() void TEmissione::floppy() { inizializza_cur(); - - const long codabi = _cur->curr().get_long(EFF_CODABIP); - const char tipocf = _cur->curr().get_char(EFF_TIPOCF); - const char tipopag = _cur->curr().get_char(EFF_TIPOPAG); + + *_cur = 0L; // Posizionati all'inizio + const TRectype& eff = _cur->curr(); + const long codabi = eff.get_long(EFF_CODABIP); + const char tipocf = eff.get_char(EFF_TIPOCF); + const char tipopag = eff.get_char(EFF_TIPOPAG); TFilename ribaini; - - ribaini.format("r%c%c%05ld.ini",tipocf, tipopag, codabi);// compongo il nome del tracciato + ribaini.format("r%c%c%05ld.ini", tipocf, tipopag, codabi); // compongo il nome del tracciato if (!ribaini.exist()) // se non esiste ribaini.overwrite("00000", 3); // Elimino codice banca if (!ribaini.exist()) // se non esiste - ribaini = "riba.ini"; // utilizzo quello generico + ribaini.overwrite("0", 2); // Elimino tipo pagamaneto + if (!ribaini.exist()) // se non esiste + ribaini = "riba.ini"; // utilizzo quello generico + if (!ribaini.exist()) // se non esiste ancora! + { + error_box("Impossibile leggere il file %s", (const char*)ribaini); + return; + } _trasfile = new TRiba_file(RIBAFILENAME, ribaini); TTracciato_record * rb = _trasfile->t_rec("RB"); @@ -282,6 +290,9 @@ void TEmissione::floppy() _trasfile->close(); delete _trasfile; _trasfile = NULL; + + delete _cur; + _cur = NULL; } // registro la data ed il numero di emissione dell'effetto corrente @@ -352,6 +363,8 @@ void TEmissione::inizializza_cur() from.zero(); from.put(EFF_TIPODIST, tipodist); from.put(EFF_NDIST, ndist); + if (_cur != NULL) + delete _cur; _cur = new TCursor(_rel,"",4,&from,&from); _cur->freeze(); } @@ -563,6 +576,8 @@ void TEmissione::print() nomeform.format("r%c%c%05ld.frm",tipocf, tipopag, codabi); if (!nomeform.exist()) // se non esiste nomeform.overwrite("00000", 3); // elimino codice banca + if (!nomeform.exist()) // se non esiste + nomeform.overwrite("0", 2); // elimino tipo pagamento if (!nomeform.exist()) // se non esiste nomeform = "rb.frm"; // utilizzo quello generico _formrb = new TRiba_form(nomeform); @@ -574,6 +589,8 @@ void TEmissione::print() nomeform.format("d%c%c%05ld.frm",tipocf, tipopag, codabi);// compongo il nome del form if (!nomeform.exist()) // se non esiste nomeform.overwrite("00000", 3); // elimino codice banca + if (!nomeform.exist()) // se non esiste + nomeform.overwrite("0", 2); // elimino tipo pagamento if (!nomeform.exist()) // se non esiste nomeform = "dse.frm"; // utilizzo quello generico _formdse = new TDistinta_form(nomeform, _firmrel); @@ -699,6 +716,7 @@ bool TRiba_form::validate(TForm_item &cf, TToken_string &s) // sintassi: _CLI, // dove: è uno delle macro seguenti: // "!IND" INDIRIZZO + NR. CIVICO + // "!LOCALITA" LOCALITA // "!PIAZZA" COMUNE + PROVINCIA // "!CAP" CAP // "!RAGSOC" Ragione sociale @@ -714,25 +732,33 @@ bool TRiba_form::validate(TForm_item &cf, TToken_string &s) if (in=="IND") { - valore = rel->lfile(pick_normal ? LF_CLIFO : LF_INDSP).get(pick_normal ? CLI_INDCF : IND_INDIR); - in = rel->lfile(pick_normal ? LF_CLIFO : LF_INDSP).get(pick_normal ? CLI_CIVCF : IND_CIV); - if (in.not_empty()) - valore << ", " << in; + const TRectype& cli = rel->curr(pick_normal ? LF_CLIFO : LF_INDSP); + valore = cli.get(pick_normal ? CLI_INDCF : IND_INDIR); + const TString& civ = cli.get(pick_normal ? CLI_CIVCF : IND_CIV); + if (civ.not_empty()) + valore << ", " << civ; } else - if (in=="PIAZZA") + if (in=="PIAZZA" || in=="COMUNE") { - valore = rel->lfile(pick_normal ? LF_COMUNI : -213).get(COM_DENCOM); - in = rel->lfile(pick_normal ? LF_COMUNI : -213).get(COM_PROVCOM); - if (in.not_empty()) - valore << " (" << in << ")"; + const TRectype& com = rel->curr(pick_normal ? LF_COMUNI : -213); + valore = com.get(COM_DENCOM); + const TString& prov = com.get(COM_PROVCOM); + if (prov.not_empty()) + valore << " (" << prov << ")"; } else - if (in=="RAGSOC") - valore = rel->lfile(pick_normal ? LF_CLIFO : LF_INDSP).get(pick_normal ? CLI_RAGSOC : IND_RAGSOC); - else - if (in=="CAPCF") - valore = rel->lfile(pick_normal ? LF_CLIFO : LF_INDSP).get(pick_normal ? CLI_CAPCF : IND_CAP); + if (in=="LOCALITA") + { + const TRectype& cli = rel->curr(pick_normal ? LF_CLIFO : LF_INDSP); + valore = cli.get(pick_normal ? CLI_LOCCF : IND_LOCALITA); + } + else + if (in=="RAGSOC") + valore = rel->lfile(pick_normal ? LF_CLIFO : LF_INDSP).get(pick_normal ? CLI_RAGSOC : IND_RAGSOC); + else + if (in=="CAPCF") + valore = rel->lfile(pick_normal ? LF_CLIFO : LF_INDSP).get(pick_normal ? CLI_CAPCF : IND_CAP); } cf.put_paragraph(valore); return (TRUE); @@ -848,18 +874,23 @@ bool TDistinta_form::validate(TForm_item &cf, TToken_string &s) valore << ", " << in; } else - if (in=="PIAZZA") + if (in=="PIAZZA" || in=="COMUNE") { - valore = rel->lfile(pick_normal ? LF_COMUNI : -213).get(COM_DENCOM); - in = rel->lfile(pick_normal ? LF_COMUNI : -213).get(COM_PROVCOM); + valore = rel->curr(pick_normal ? LF_COMUNI : -213).get(COM_DENCOM); + in = rel->curr(pick_normal ? LF_COMUNI : -213).get(COM_PROVCOM); if (in.not_empty()) valore << " (" << in << ")"; - } + } else + if (in=="LOCALITA") + { + const TRectype& cli = rel->curr(pick_normal ? LF_CLIFO : LF_INDSP); + valore = cli.get(pick_normal ? CLI_LOCCF : IND_LOCALITA); + } else if (in=="RAGSOC") - valore = rel->lfile(pick_normal ? LF_CLIFO : LF_INDSP).get(pick_normal ? CLI_RAGSOC : IND_RAGSOC); + valore = rel->curr(pick_normal ? LF_CLIFO : LF_INDSP).get(pick_normal ? CLI_RAGSOC : IND_RAGSOC); else if (in=="CAPCF") - valore = rel->lfile(pick_normal ? LF_CLIFO : LF_INDSP).get(pick_normal ? CLI_CAPCF : IND_CAP); + valore = rel->curr(pick_normal ? LF_CLIFO : LF_INDSP).get(pick_normal ? CLI_CAPCF : IND_CAP); } cf.set(valore); cf.put_paragraph(valore); @@ -1038,8 +1069,7 @@ void TRiba_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TStr } else if (in=="INDIRIZZO") { - valore.cut(0); - valore << clifo_2.get(pick_normal ? CLI_INDCF : IND_INDIR); + valore = clifo_2.get(pick_normal ? CLI_INDCF : IND_INDIR); valore.trim(); valore << " " << clifo_2.get_int(pick_normal ? CLI_CIVCF : IND_CIV); valore.trim(); @@ -1048,8 +1078,7 @@ void TRiba_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TStr } else if (in=="COMUNE") { - valore.cut(0); - valore << comuni.get("DENCOM"); + valore = comuni.get("DENCOM"); valore.trim(); } else if (in=="PROV") @@ -1057,6 +1086,21 @@ void TRiba_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TStr valore = comuni.get("PROVCOM"); valore.trim(); } + else if (in=="LOCALITA") + { + valore = clifo_2.get(pick_normal ? CLI_LOCCF : IND_LOCALITA); + valore.trim(); + } + else if (in=="LOCALITA+COMUNE") + { + valore = clifo_2.get(pick_normal ? CLI_LOCCF : IND_LOCALITA); + valore.trim(); + if (valore.not_empty()) + valore << " (" << comuni.get("DENCOM") << ')'; + else + valore = comuni.get("DENCOM"); + valore.trim(); + } else if (in=="CFPI") { valore = clifo_1.get("PAIV"); @@ -1152,9 +1196,26 @@ void TRiba_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TStr CHECK(in[0]=='!',"Macro _IMPORTO senza carattere '!'"); if (in=="!ADD") { + real importo = cur.curr(LF_EFFETTI).get(EFF_IMPORTO); if (_codice_moneta == 'E') importo *= 100.0; +/* GF only + real importo = cur.curr(LF_EFFETTI).get(EFF_IMPORTOVAL); + if (importo.is_zero()) + { + importo = cur.curr(LF_EFFETTI).get_real(EFF_IMPORTO); + importo /= 1936.27; + } + importo *= 100.0; +*/ +/* Allore only + real importo = cur.curr(LF_EFFETTI).get(EFF_IMPORTOVAL); + if (importo.is_zero()) + importo = cur.curr(LF_EFFETTI).get_real(EFF_IMPORTO); + else + importo *= 100.0; +*/ importo.round(0); add_tot_importi(importo); valore = importo.string(13,0); @@ -1187,4 +1248,4 @@ int ef0500(int argc, char* argv[]) TEmissione a ; a.run(argc, argv, "Emissione Effetti e Distinte"); return 0; -} +} \ No newline at end of file diff --git a/ef/ef0600.cpp b/ef/ef0600.cpp index 81269df89..8a031f53d 100755 --- a/ef/ef0600.cpp +++ b/ef/ef0600.cpp @@ -102,12 +102,12 @@ const char* TPrint_effetti_app::look_tab(const char* tabname, const TString& cod // stampa il totale per data di scadenza void TPrint_effetti_app::st_tot_scad() { - _pr.put("___________________________________________",50); + _pr.put("_____________________________________________________",46); printer().print(_pr); _pr.reset(); - _pr.put("TOTALE",50); - _pr.put(_scad_prec.string(),57); - _pr.put(_tot_data.string(PICTURE_IMPORTO),72); + _pr.put("TOTALE",46); //sky totdata + _pr.put(_scad_prec.string(),53); + _pr.put(_tot_data.string(PICTURE_IMPORTO),63); printer().print(_pr); _tot_data = 0.0; _pr.reset(); @@ -116,11 +116,11 @@ void TPrint_effetti_app::st_tot_scad() // stampa il totale per mese delle data di scadenza void TPrint_effetti_app::st_tot_mese() { - _pr.put("TOTALE ",50); + _pr.put("TOTALE",46); //sky totmese if (_scad_prec.ok()) { - _pr.put(itom(_scad_prec.month()),57); - _pr.put(_tot_mese.string(PICTURE_IMPORTO),72); + _pr.put(itom(_scad_prec.month()),53); + _pr.put(_tot_mese.string(PICTURE_IMPORTO),63); } printer().print(_pr); _tot_mese = 0.0; @@ -205,8 +205,8 @@ void TPrint_effetti_app::preprocess_header() ditta = ditta.mid(0,30); ditta.trim(); ditta << " " << s; - set_header(j, "Ditta: %ld %s@125gPag @#", firm, (const char*) ditta); - set_header(j++, "@102gData %s", (const char*) _data_stampa); + set_header(j, "@bDitta: %ld %s@125gPag @#", firm, (const char*) ditta); + set_header(j++, "@b@102gData %s", (const char*) _data_stampa); switch(_pr_type) { @@ -231,11 +231,11 @@ void TPrint_effetti_app::preprocess_header() void TPrint_effetti_app::header_scadenza() { int j =2; - set_header(j, "@52gSTAMPA RI.BA. PER SCADENZA"); j++; + set_header(j, "@52g@bSTAMPA RI.BA. PER SCADENZA"); j++; set_header(j++, (const char *)(TString(_colonne).fill('_'))); - TString head = " Scadenza Banca Cliente N.Riba N.Dist Importo Val. N.Rata St.Def. Fattura del. N."; + TString head = "@b Scadenza Banca Cliente N.Riba N.Dist Importo Imp. in valuta Val Rata Data fattura N."; if (_stampa_bancapp) - head << " ABI CAB Banca d'appoggio"; + head << "@b ABI CAB Banca d'appoggio"; set_header(j++, head); set_header(j, (const char *)(TString(_colonne).fill('_'))); } @@ -244,11 +244,11 @@ void TPrint_effetti_app::header_scadenza() void TPrint_effetti_app::header_banca() { int j = 2; - set_header(j, "@45gSTAMPA RI.BA. PER BANCHE DI PRESENTAZIONE"); j++; + set_header(j, "@45g@bSTAMPA RI.BA. PER BANCHE DI PRESENTAZIONE"); j++; set_header(j++, (const char *)(TString(_colonne).fill('_'))); - TString head = " Banca Scadenza Cliente N.Riba N.Dist Importo Val. N.Rata St.Def. Fattura del. N."; + TString head = "@b Banca Scadenza Cliente N.Riba N.Dist Importo Imp. in valuta Val Rata Data fattura N."; if (_stampa_bancapp) - head << " ABI CAB Banca d'appoggio"; + head << "@b ABI CAB Banca d'appoggio"; set_header(j++, head); set_header(j, (const char *)(TString(_colonne).fill('_'))); } @@ -257,12 +257,12 @@ void TPrint_effetti_app::header_banca() void TPrint_effetti_app::header_distinta() { int j = 2; - set_header(j, "@55gSTAMPA RI.BA. PER DISTINTE"); j++; + set_header(j, "@55g@bSTAMPA RI.BA. PER DISTINTE"); j++; set_header(j++, (const char *)(TString(_colonne).fill('_'))); - set_header(j++, " Distinta "); - TString head = "@1gTipo Num. N.Riba Scadenza Banca Cliente Importo Val. N.Rata St.Def. Fattura del. N."; + set_header(j++, "@b Distinta "); + TString head = "@bTp. Num. N.Riba Scadenza Banca Cliente Importo Imp. in valuta Val Rata Data fattura N."; if (_stampa_bancapp) - head << " ABI CAB Banca d'appoggio"; + head << "@b ABI CAB Banca d'appoggio"; set_header(j++, head); set_header(j, (const char *)(TString(_colonne).fill('_'))); } @@ -271,11 +271,11 @@ void TPrint_effetti_app::header_distinta() void TPrint_effetti_app::header_cliente() { int j = 2; - set_header(j, "@52gSTAMPA RI.BA. PER CLIENTE"); j++; + set_header(j, "@52g@bSTAMPA RI.BA. PER CLIENTE"); j++; set_header(j++, (const char *)(TString(_colonne).fill('_'))); - TString head = " Cliente Scadenza Banca N.Riba N.Dist Importo Val N.Rata St.Def. Fattura del. N."; + TString head = "@b Cliente Scadenza Banca N.Riba N.Dist Importo Imp. in valuta Val Rata Data fattura N."; if (_stampa_bancapp) - head << " ABI CAB Banca d'appoggio"; + head << "@b ABI CAB Banca d'appoggio"; set_header(j++, head); set_header(j, (const char *)(TString(_colonne).fill('_'))); } @@ -291,8 +291,8 @@ print_action TPrint_effetti_app::postprocess_print(int file, int counter) st_tot_mese(); if (_tot_banca != 0.0) { - _pr.put("TOTALE",50); - _pr.put(_tot_banca.string(PICTURE_IMPORTO),72); + _pr.put("TOTALE",46); + _pr.put(_tot_banca.string(PICTURE_IMPORTO),63); printer().print(_pr); _pr.reset(); s = (look_tab("%BAN",_ban_prec)); @@ -305,14 +305,14 @@ print_action TPrint_effetti_app::postprocess_print(int file, int counter) } if (_tot_distinta != 0.0 &&_dist_prec != 0) { - _pr.put("___________________________________________",50); + _pr.put("_____________________________________________________",46); printer().print(_pr); _pr.reset(); - _pr.put("TOTALE",50); + _pr.put("TOTALE",46); s = "Distinta "; s << _dist_prec << " " << _tipo_prec ; _pr.put(s,57); - _pr.put(_tot_distinta.string(PICTURE_IMPORTO),72); + _pr.put(_tot_distinta.string(PICTURE_IMPORTO),63); printer().print(_pr); _tot_distinta = 0.0; _pr.reset(); @@ -321,12 +321,12 @@ print_action TPrint_effetti_app::postprocess_print(int file, int counter) { if (_dist_prec == 0) { - _pr.put("___________________________________________",50); + _pr.put("_____________________________________________________",46); printer().print(_pr); _pr.reset(); } - _pr.put("TOTALE",50); - _pr.put(_tot_tip_dist.string(PICTURE_IMPORTO),72); + _pr.put("TOTALE",46); + _pr.put(_tot_tip_dist.string(PICTURE_IMPORTO),63); printer().print(_pr); _pr.reset(); s = "Distinte"; @@ -353,8 +353,8 @@ print_action TPrint_effetti_app::postprocess_print(int file, int counter) if (_tot_cliente != 0.0) { TString ragsoc; - _pr.put("TOTALE",50); - _pr.put(_tot_cliente.string(PICTURE_IMPORTO),72); + _pr.put("TOTALE",46); //sky totultcli + _pr.put(_tot_cliente.string(PICTURE_IMPORTO),63); printer().print(_pr); _pr.reset(); TString80 cli; @@ -366,17 +366,17 @@ print_action TPrint_effetti_app::postprocess_print(int file, int counter) if (_tot_stampa != 0.0) { _pr.reset(); - _pr.put("___________________________________________",50); + _pr.put("_____________________________________________________",46); printer().print(_pr); _pr.reset(); - _pr.put("TOTALE ",50); - _pr.put(_tot_stampa.string(PICTURE_IMPORTO),72); + _pr.put("TOTALE ",46); + _pr.put(_tot_stampa.string(PICTURE_IMPORTO),63); printer().print(_pr); _pr.reset(); _pr.put("RI.BA. STAMPATE",52); printer().print(_pr); _pr.reset(); - _pr.put("___________________________________________",50); + _pr.put("_____________________________________________________",46); printer().print(_pr); _pr.reset(); _tot_stampa = 0.0; @@ -433,19 +433,24 @@ void TPrint_effetti_app::write_bancapp() void TPrint_effetti_app::set_scadenza() { set_row(1," "); - set_row(2,"@1g@s@13g#t@26g#t@54g@pn@63g@pn@72g@pn@91g#t@98g@pn@106g@s@114g@s@125g@n", + set_row(2,"@1g@s@13g#t@26g#t@49g@pn@55g@pn@63g@pn@105g@pn@111g@s@125g@n", FLD(LF_EFFETTI, EFF_DATASCAD), &_ban, &_cli, FLD(LF_EFFETTI, EFF_NPROGTR, "#####@"), FLD(LF_EFFETTI, EFF_NDIST, "#######@"), FLD(LF_EFFETTI, EFF_IMPORTO, PICTURE_IMPORTO), - &_val, FLD(LF_REFFETTI, REFF_NRATA,"##@"), - FLD(LF_EFFETTI, EFF_EFFSTAMP), FLD(LF_REFFETTI, REFF_DATAFATT), - FLD(LF_REFFETTI, REFF_NFATT)); - + FLD(LF_REFFETTI, REFF_NFATT,"######")); + + const TString8 valuta = current_cursor()->curr().get(EFF_CODVAL); + if (!is_firm_value(valuta)) //effetto in valuta diversa da quella di conto + { + set_row(2,"@81g@pn@100g%s", + FLD(LF_EFFETTI, EFF_IMPORTOVAL, PICTURE_IMPORTO), + (const char *)valuta); + } write_bancapp(); for(int i = 0; i < _interline; i++) set_row(i+1," "); } @@ -455,19 +460,24 @@ void TPrint_effetti_app::set_scadenza() void TPrint_effetti_app::set_banca() { set_row(1," "); - set_row(2,"@1g#t@14g@s@26g#t@54g@pn@63g@pn@72g@pn@91g#t@98g@pn@106g@s@114g@s@125g@n", + set_row(2,"@1g#t@14g@s@26g#t@49g@pn@55g@pn@63g@pn@105g@pn@111g@s@125g@pn", &_ban, FLD(LF_EFFETTI, EFF_DATASCAD), &_cli, FLD(LF_EFFETTI, EFF_NPROGTR, "#####@"), FLD(LF_EFFETTI, EFF_NDIST, "#######@"), FLD(LF_EFFETTI, EFF_IMPORTO, PICTURE_IMPORTO), - &_val, FLD(LF_REFFETTI, REFF_NRATA,"##@"), - FLD(LF_EFFETTI, EFF_EFFSTAMP), FLD(LF_REFFETTI, REFF_DATAFATT), - FLD(LF_REFFETTI, REFF_NFATT)); - + FLD(LF_REFFETTI, REFF_NFATT,"######")); + + const TString8 valuta = current_cursor()->curr().get(EFF_CODVAL); + if (!is_firm_value(valuta)) //effetto in valuta diversa da quella di conto + { + set_row(2,"@81g@pn@100g%s", + FLD(LF_EFFETTI, EFF_IMPORTOVAL, PICTURE_IMPORTO), + (const char *)valuta); + } write_bancapp(); for(int i = 0; i < _interline; i++) set_row(i+1,""); } @@ -476,7 +486,7 @@ void TPrint_effetti_app::set_banca() void TPrint_effetti_app::set_distinta() { set_row(1," "); - set_row(2,"@3g@s@5g@pn@16g@pn@24g@ld@35g#t@48g#-25t@72g@pn@91g#-4t@98g@pn@106g@s@114g@s@128g@n", + set_row(2,"@1g@s@3g@pn@12g@pn@19g@ld@30g#t@42g#-20t@63g@pn@105g@pn@111g@s@125g@pn", FLD(LF_EFFETTI, EFF_TIPODIST), FLD(LF_EFFETTI, EFF_NDIST, "#######@"), FLD(LF_EFFETTI, EFF_NPROGTR, "#####@"), @@ -484,12 +494,17 @@ void TPrint_effetti_app::set_distinta() &_ban, &_cli, FLD(LF_EFFETTI, EFF_IMPORTO, PICTURE_IMPORTO), - &_val, FLD(LF_REFFETTI, REFF_NRATA,"##@"), - FLD(LF_EFFETTI, EFF_EFFSTAMP), FLD(LF_REFFETTI, REFF_DATAFATT), - FLD(LF_REFFETTI, REFF_NFATT)); - + FLD(LF_REFFETTI, REFF_NFATT,"######")); + + const TString8 valuta = current_cursor()->curr().get(EFF_CODVAL); + if (!is_firm_value(valuta)) //effetto in valuta diversa da quella di conto + { + set_row(2,"@81g@pn@100g%s", + FLD(LF_EFFETTI, EFF_IMPORTOVAL, PICTURE_IMPORTO), + (const char *)valuta); + } write_bancapp(); for(int i = 0; i < _interline; i++) set_row(i+1,""); } @@ -498,19 +513,24 @@ void TPrint_effetti_app::set_distinta() void TPrint_effetti_app::set_cliente() { set_row(1," "); - set_row(2,"@5g@pn@25g@s@37g#t@50g@pn@59g@pn@72g@pn@91g#t@98g@pn@106g@s@114g@s@125g@n", + set_row(2,"@5g@pn@25g@s@37g#t@49g@pn@55g@pn@63g@pn@105g@pn@111g@s@125g@pn", FLD(LF_EFFETTI, EFF_CODCF,"@@@@@@"), FLD(LF_EFFETTI, EFF_DATASCAD), &_ban, FLD(LF_EFFETTI, EFF_NPROGTR, "#####@"), FLD(LF_EFFETTI, EFF_NDIST, "#######@"), FLD(LF_EFFETTI, EFF_IMPORTO, PICTURE_IMPORTO), - &_val, FLD(LF_REFFETTI, REFF_NRATA,"##@"), - FLD(LF_EFFETTI, EFF_EFFSTAMP), FLD(LF_REFFETTI, REFF_DATAFATT), - FLD(LF_REFFETTI, REFF_NFATT)); - + FLD(LF_REFFETTI, REFF_NFATT,"######")); + + const TString8 valuta = current_cursor()->curr().get(EFF_CODVAL); + if (!is_firm_value(valuta)) //effetto in valuta diversa da quella di conto + { + set_row(2,"@81g@pn@100g%s", + FLD(LF_EFFETTI, EFF_IMPORTOVAL, PICTURE_IMPORTO), + (const char *)valuta); + } write_bancapp(); for(int i = 0; i < _interline; i++) set_row(i+1," "); } @@ -654,8 +674,8 @@ bool TPrint_effetti_app::preprocess_page(int file, int counter) if (scad.month() ==_scad_prec.month()) st_tot_mese(); // stampo totale banca - _pr.put("TOTALE",50); - _pr.put(_tot_banca.string(PICTURE_IMPORTO),72); + _pr.put("TOTALE",46); + _pr.put(_tot_banca.string(PICTURE_IMPORTO),63); printer().print(_pr); _pr.reset(); s = (look_tab("%BAN",_ban_prec)); @@ -694,14 +714,14 @@ bool TPrint_effetti_app::preprocess_page(int file, int counter) //il totale per nessuna distinta si fa solo per tipo if (_dist_prec != 0) { - _pr.put("___________________________________________",50); + _pr.put("_____________________________________________________",46); printer().print(_pr); _pr.reset(); - _pr.put("TOTALE",50); + _pr.put("TOTALE",46); s = "Distinta "; s << _tipo_prec << " "<< _dist_prec; _pr.put(s,57); - _pr.put(_tot_distinta.string(PICTURE_IMPORTO),72); + _pr.put(_tot_distinta.string(PICTURE_IMPORTO),63); printer().print(_pr); _tot_distinta = 0.0; _pr.reset(); @@ -711,12 +731,12 @@ bool TPrint_effetti_app::preprocess_page(int file, int counter) { if (_dist_prec == 0) { - _pr.put("___________________________________________",50); + _pr.put("_____________________________________________________",46); printer().print(_pr); _pr.reset(); } - _pr.put("TOTALE",50); - _pr.put(_tot_tip_dist.string(PICTURE_IMPORTO),72); + _pr.put("TOTALE",46); + _pr.put(_tot_tip_dist.string(PICTURE_IMPORTO),63); printer().print(_pr); _pr.reset(); s = "Distinte"; @@ -768,8 +788,8 @@ bool TPrint_effetti_app::preprocess_page(int file, int counter) if (scad.month() ==_scad_prec.month()) st_tot_mese(); // stampo totale cliente - _pr.put("TOTALE",50); - _pr.put(_tot_cliente.string(PICTURE_IMPORTO),72); + _pr.put("TOTALE",46); //sky totcli + _pr.put(_tot_cliente.string(PICTURE_IMPORTO),63); printer().print(_pr); _pr.reset(); TString80 cli; diff --git a/ef/ef0600.h b/ef/ef0600.h index dc04d9d85..529e6ecd4 100755 --- a/ef/ef0600.h +++ b/ef/ef0600.h @@ -23,6 +23,10 @@ #define F_ACLI 118 #define F_DA_DATA4 119 #define F_A_DATA4 120 -#define F_BANCA_APP 121 +#define F_BANCA_APP 121 +#define F_DABAN_DESCR 122 +#define F_ABAN_DESCR 123 +#define F_DACLI_DESCR 124 +#define F_ACLI_DESCR 125 #endif//__EF0600_H diff --git a/ef/ef0600a.uml b/ef/ef0600a.uml index 6d40dc737..eb2d5b10c 100755 --- a/ef/ef0600a.uml +++ b/ef/ef0600a.uml @@ -2,27 +2,27 @@ #include "ef0600.h" -PAGE "Stampe di Controllo Effetti" -1 -1 58 15 +PAGE "Stampe di Controllo Effetti" -1 -1 78 15 DATE F_DATA_STAMPA BEGIN - PROMPT 30 1 "Data di stampa " + PROMPT 50 1 "Data di stampa " FLAGS "A" END BOOL F_BANCA_APP BEGIN - PROMPT 30 3 "Stampa banca appoggio" + PROMPT 50 3 "Stampa banca appoggio" END TEXT DLG_NULL BEGIN - PROMPT 32 4 "(richieste 198 colonne)" + PROMPT 52 4 "(richieste 198 colonne)" END -RADIOBUTTON RDB_TIPOST 24 +RADIOBUTTON RDB_TIPOST 25 BEGIN - PROMPT 2 1 "Stampa per " + PROMPT 1 1 "Stampa per " ITEM "1|Banca" MESSAGE SHOW,2@|HIDE,1@|HIDE,3@|HIDE,4@ ITEM "2|Cliente/Fornitore" @@ -33,7 +33,8 @@ BEGIN MESSAGE SHOW,1@|HIDE,2@|HIDE,3@|HIDE,4@ END -GROUPBOX DLG_NULL 55 3 +//---------data----------------------------------------------------------------------------------------------------------// +GROUPBOX DLG_NULL 75 3 BEGIN PROMPT 1 7 "Stampa effetti per Data di scadenza" GROUP 1 @@ -53,7 +54,8 @@ BEGIN WARNING "Data limite superiore non valida" END -GROUPBOX DLG_NULL 55 4 +//---------banca----------------------------------------------------------------------------------------------------------// +GROUPBOX DLG_NULL 75 6 BEGIN PROMPT 1 7 "Stampa effetti per Banca di presentazione" GROUP 2 @@ -67,41 +69,74 @@ BEGIN USE BNP KEY 1 SELECT CODTAB ?= "??????????" JOIN %BAN ALIAS 100 INTO CODTAB==CODTAB INPUT CODTAB F_DABAN - DISPLAY "Codice ABI" CODTAB[1,5] - DISPLAY "Denominazione@50" %BAN->S0 + DISPLAY "ABI@5" CODTAB[1,5] + DISPLAY "CAB@5" CODTAB[6,10] + DISPLAY "Denominazione@50" 100@->S0 OUTPUT F_DABAN CODTAB[1,5] + OUTPUT F_DABAN_DESCR %BAN->S0 CHECKTYPE SEARCH END +STRING F_DABAN_DESCR 50 +BEGIN + PROMPT 23 8 "" + GROUP 2 + USE %BAN KEY 2 SELECT (CODTAB?="??????????")&&(200@->CODTAB!="") + JOIN BNP ALIAS 200 INTO CODTAB==CODTAB + INPUT S0 F_DABAN_DESCR + DISPLAY "Denominazione@50" S0 + DISPLAY "ABI@5" CODTAB[1,5] + DISPLAY "CAB@5" CODTAB[6,10] + COPY OUTPUT F_DABAN + CHECKTYPE SEARCH +END + NUMBER F_ABAN 5 BEGIN - PROMPT 30 8 "Alla Banca " + PROMPT 2 9 "Alla Banca " FLAGS "RZ" GROUP 2 USE BNP KEY 1 SELECT CODTAB ?= "??????????" JOIN %BAN ALIAS 100 INTO CODTAB==CODTAB INPUT CODTAB F_ABAN - DISPLAY "Codice ABI" CODTAB[1,5] - DISPLAY "Denominazione@50" %BAN->S0 + DISPLAY "ABI@5" CODTAB[1,5] + DISPLAY "CAB@5" CODTAB[6,10] + DISPLAY "Denominazione@50" 100@->S0 OUTPUT F_ABAN CODTAB[1,5] + OUTPUT F_ABAN_DESCR %BAN->S0 + CHECKTYPE SEARCH +END + +STRING F_ABAN_DESCR 50 +BEGIN + PROMPT 23 9 "" + GROUP 2 + USE %BAN KEY 2 SELECT (CODTAB?="??????????")&&(200@->CODTAB!="") + JOIN BNP ALIAS 200 INTO CODTAB==CODTAB + INPUT S0 F_ABAN_DESCR + DISPLAY "Denominazione@50" S0 + DISPLAY "ABI@5" CODTAB[1,5] + DISPLAY "CAB@5" CODTAB[6,10] + COPY OUTPUT F_ABAN CHECKTYPE SEARCH END DATA F_DA_DATA2 BEGIN - PROMPT 2 9 "Dalla Data " + PROMPT 2 10 "Dalla Data " GROUP 2 END DATA F_A_DATA2 BEGIN - PROMPT 30 9 "Alla Data " + PROMPT 30 10 "Alla Data " GROUP 2 VALIDATE DATE_CMP_FUNC >= F_DA_DATA2 WARNING "Data limite superiore non valida" END -GROUPBOX DLG_NULL 55 7 +//---------distinta-------------------------------------------------------------------------------------------------------// +GROUPBOX DLG_NULL 75 5 BEGIN PROMPT 1 7 "Stampa effetti per Distinta" GROUP 3 @@ -116,15 +151,9 @@ BEGIN FLAGS "D" END -TEXT DLG_NULL -BEGIN -PROMPT 2 8 "Dalla Distinta " -GROUP 3 -END - LIST F_DATIPODIST 19 BEGIN - PROMPT 4 9 " " + PROMPT 4 8 " " KEY 4 GROUP 3 ITEM " |Senza distinta" MESSAGE CLEAR,F_DADIST|CLEAR,F_ADIST @@ -133,9 +162,15 @@ BEGIN ITEM "S|Allo sconto" MESSAGE ENABLE,F_DADIST|ENABLE,F_ADIST END +TEXT DLG_NULL +BEGIN +PROMPT 2 9 "Dalla Distinta" +GROUP 3 +END + NUMBER F_DADIST 5 BEGIN - PROMPT 4 10 " " + PROMPT 18 9 " " FLAGS "D" GROUP 3 KEY 4 @@ -151,13 +186,13 @@ END TEXT DLG_NULL BEGIN - PROMPT 30 8 "Alla Distinta " + PROMPT 30 9 "Alla Distinta" GROUP 3 END NUMBER F_ADIST 5 BEGIN - PROMPT 31 10 " " + PROMPT 44 9 " " FLAGS "D" KEY 4 GROUP 3 @@ -176,31 +211,32 @@ END TEXT DLG_NULL BEGIN - PROMPT 2 11 "Dalla Data " + PROMPT 2 10 "Dalla Data " GROUP 3 END DATA F_DA_DATA3 BEGIN - PROMPT 4 12 " " + PROMPT 15 10 " " GROUP 3 END TEXT DLG_NULL BEGIN - PROMPT 30 11 "Alla Data " + PROMPT 30 10 "Alla Data " GROUP 3 END DATA F_A_DATA3 BEGIN - PROMPT 31 12 " " + PROMPT 41 10 " " GROUP 3 VALIDATE DATE_CMP_FUNC >= F_DA_DATA3 WARNING "Data limite superiore non valida" END -GROUPBOX DLG_NULL 55 5 +//---------clifo----------------------------------------------------------------------------------------------------------// +GROUPBOX DLG_NULL 75 6 BEGIN PROMPT 1 7 "Stampa effetti per Cliente/Fornitori" GROUP 4 @@ -208,7 +244,7 @@ END LIST F_TIPOCF 11 BEGIN - PROMPT 2 8 "Tipo " + PROMPT 2 8 "Tipo " ITEM "C|Clienti" ITEM "F|Fornitori" GROUP 4 @@ -216,7 +252,7 @@ END NUMBER F_DACLI 6 BEGIN - PROMPT 2 9 "Da Codice " + PROMPT 2 9 "Da Codice " GROUP 4 USE LF_CLIFO INPUT TIPOCF F_TIPOCF SELECT @@ -224,31 +260,59 @@ BEGIN DISPLAY "Codice" CODCF DISPLAY "Ragione sociale@60" RAGSOC OUTPUT F_DACLI CODCF - CHECKTYPE NORMAL + OUTPUT F_DACLI_DESCR RAGSOC + CHECKTYPE SEARCH END +STRING F_DACLI_DESCR 50 +BEGIN + PROMPT 21 9 " " + GROUP 4 + USE LF_CLIFO KEY 2 + INPUT TIPOCF F_TIPOCF SELECT + INPUT RAGSOC F_DACLI_DESCR + DISPLAY "Ragione sociale@60" RAGSOC + DISPLAY "Codice" CODCF + OUTPUT F_DACLI_DESCR RAGSOC + OUTPUT F_DACLI CODCF + CHECKTYPE SEARCH +END + NUMBER F_ACLI 6 BEGIN - PROMPT 30 9 "A Codice " + PROMPT 2 10 "A Codice " GROUP 4 COPY USE F_DACLI INPUT TIPOCF F_TIPOCF SELECT INPUT CODCF F_ACLI COPY DISLAY F_DACLI - DISPLAY "Codice" CODCF OUTPUT F_ACLI CODCF - CHECKTYPE NORMAL + OUTPUT F_ACLI_DESCR RAGSOC + CHECKTYPE SEARCH +END + +STRING F_ACLI_DESCR 50 +BEGIN + PROMPT 21 10 " " + GROUP 4 + COPY USE F_DACLI_DESCR + INPUT TIPOCF F_TIPOCF SELECT + INPUT RAGSOC F_ACLI_DESCR + COPY DISPLAY F_DACLI_DESCR + OUTPUT F_ACLI_DESCR RAGSOC + OUTPUT F_ACLI CODCF + CHECKTYPE SEARCH END DATA F_DA_DATA4 BEGIN - PROMPT 2 10 "Dalla Data " + PROMPT 2 11 "Dalla Data " GROUP 4 END DATA F_A_DATA4 BEGIN - PROMPT 30 10 "Alla Data " + PROMPT 30 11 "Alla Data " GROUP 4 VALIDATE DATE_CMP_FUNC >= F_DA_DATA2 WARNING "Data limite superiore non valida" diff --git a/ef/ef0800.cpp b/ef/ef0800.cpp index 4507f29b6..f92b0e13c 100755 --- a/ef/ef0800.cpp +++ b/ef/ef0800.cpp @@ -29,7 +29,7 @@ */ #include -#include +#include #include #include #include @@ -58,6 +58,17 @@ #define DIST_SBF 'B' #define DIST_SCONTO 'S' +// TContabilizzazione_mask + +class TContabilizzazione_mask : public TAutomask +{ +protected: + virtual bool on_field_event(TOperable_field& f, TField_event e, long jolly); + +public: + TContabilizzazione_mask(); +}; + // TContabilizzazione_effetti_app // Applicazione di contabilizzazione effetti class TContabilizzazione_effetti_app : public TSkeleton_application @@ -162,12 +173,58 @@ public: bool good() const { return _error == no_error;} error_type status() { return _error; } void set_status(error_type e) { _error = e; } + + TArray_sheet& dist_sheet() { return *_dist_sheet; } + TContabilizzazione_effetti_app() : _msk(NULL) {} virtual ~TContabilizzazione_effetti_app() { } }; inline TContabilizzazione_effetti_app& app() { return (TContabilizzazione_effetti_app&) main_app(); } +// TContabilizzazione_mask + +bool TContabilizzazione_mask::on_field_event(TOperable_field& f, TField_event e, long jolly) +{ + switch (f.dlg()) + { + case F_DATA_OP: + if (e == fe_modify || e == fe_close) + { + const TDate data = f.get(); + TEsercizi_contabili esc; + if (esc.date2esc(data) <= 0) + return error_box("La data deve appartenere ad un esercizio valido"); + } + break; + case F_RESET: + if (e == fe_button) + { + app().dist_sheet().check(-1, FALSE); + reset(F_DISTINTE); + } + break; + case F_SELECT: + if (e == fe_button) + { + TArray_sheet& sh = app().dist_sheet(); + if (sh.run() == K_ENTER) + set(F_DISTINTE,sh.checked()); + } + break; + default: + break; + } + return TRUE; +} + +TContabilizzazione_mask::TContabilizzazione_mask() + : TAutomask("ef0800a") +{ +} + +// TContabilizzazione_effetti_app + void TContabilizzazione_effetti_app::build_dist_sheet() { TRelation eff_rel(LF_EFFETTI); @@ -290,9 +347,7 @@ bool TContabilizzazione_effetti_app::create() _caus = NULL; _error = no_error; _can_write = TRUE; - _msk = new TMask("ef0800a"); - _msk->set_handler(F_SELECT,handle_select); - _msk->set_handler(F_RESET,handle_reset); + _msk = new TContabilizzazione_mask(); _cpg = new TTable("%CPG"); _bnp = new TTable("BNP"); _clifo = new TLocalisamfile(LF_CLIFO); @@ -352,24 +407,9 @@ void TContabilizzazione_effetti_app::main_loop() continue; } _data_op = _msk->get_date(F_DATA_OP); - if (!_data_op.ok()) _data_op = TODAY; - -// if (_caus != NULL) delete _caus; -// _caus = new TCausale(_cod_caus,_data_op.year()); -// if (!_caus->ok()) -// { -// error_box("Causale contabile non valida o non presente in parametri effetti"); -// continue; -// } - TEsercizi_contabili esc; - esc.update(); - _cod_es = esc.date2esc(_data_op); - if (_cod_es <= 0) - { - error_box("La data operazione non appartiene a nessun esercizio"); - continue; - } + TEsercizi_contabili esc; + _cod_es = esc.date2esc(_data_op); _dett_rate_att = _msk->get_bool(F_DETT_RATE_ATT); _dett_rate_pas = _msk->get_bool(F_DETT_RATE_PAS); @@ -401,6 +441,11 @@ void TContabilizzazione_effetti_app::display_error() msg.format("Non e' possibile reperire il conto per le spese\n" "dalla causale '%s'", _caus->codice()); break; + case datadoc_error: + msg.format("La data distinta %s non appartiene ad un esercizio valido", + (const char*)_distinta->data_dist().string()); + + break; default: // Errori generici o non indicati vengono visualizzati nel punto dell'errore break; } @@ -739,6 +784,17 @@ void TContabilizzazione_effetti_app::compile_head_mov() const TString80 codval(_distinta->codval()); const real cambio(_distinta->cambio()); const long ndist = _distinta->ndist(); + + TEsercizi_contabili esc; + if (esc.date2esc(datadist) <= 0) + { + if (!yesno_box("Attenzione: la data distinta %s non appartiene ad un esercizio valido:\n" + "Si desidera proseguire ugualmente?", (const char*)datadist.string())) + { + _can_write = FALSE; + return; + } + } TString des; des = (_distinta->tipocf() == 'F') ? _desc_pag : _desc_inc; @@ -790,26 +846,25 @@ void TContabilizzazione_effetti_app::compile_head_mov() mov.put(MOV_CAMBIO, cambio); } // MOV_TOTDOC e MOV_TOTDOCVAL vengono completati prima della scrittura del movimento - // MOV_TOTDOC e MOV_TOTDOCVAL vengono completati prima della scrittura del movimento // e solo nel caso di saldaconto abilitato } void TContabilizzazione_effetti_app::compile_riga_partita(TRiga_partite& riga, const TEffetto& effetto, const TRectype& riga_effetto, int numrig) { - TLocalisamfile& head_mov = _movimento->lfile(); + const TRectype& head_mov = _movimento->curr(); riga.put(PART_TIPOMOV,_caus->tipomov()); - riga.put(PART_TIPOPAG,effetto.get_int(EFF_TIPOPAG)); - riga.put(PART_NREG,head_mov.get_long(MOV_NUMREG)); + riga.put(PART_TIPOPAG,effetto.get(EFF_TIPOPAG)); + riga.put(PART_NREG,head_mov.get(MOV_NUMREG)); riga.put(PART_NUMRIG,numrig); - riga.put(PART_DATAREG,head_mov.get_date(MOV_DATAREG)); - riga.put(PART_DATADOC,head_mov.get_date(MOV_DATADOC)); - riga.put(PART_DATAPAG,effetto.get_date(EFF_DATASCAD)); + riga.put(PART_DATAREG,head_mov.get(MOV_DATAREG)); + riga.put(PART_DATADOC,head_mov.get(MOV_DATADOC)); + riga.put(PART_DATAPAG,effetto.get(EFF_DATASCAD)); riga.put(PART_CODCAUS,head_mov.get(MOV_CODCAUS)); riga.put(PART_NUMDOC,head_mov.get(MOV_NUMDOC)); // Sarebbe il numero della distinta... riga.put(PART_DESCR, head_mov.get(MOV_DESCR)); riga.put(PART_SEZ,sezione()); - const real imp = riga_effetto.get_real(REFF_IMPORTO); - const real imp_val = riga_effetto.get_real(REFF_IMPORTOVAL); + const real imp = riga_effetto.get(REFF_IMPORTO); + const real imp_val = riga_effetto.get(REFF_IMPORTOVAL); /* Non scrivo qui gli importi: li sommo quando faccio i pagamenti riga.put(PART_IMPORTO,imp); riga.put(PART_IMPORTOVAL,imp_val); @@ -904,6 +959,7 @@ void TContabilizzazione_effetti_app::compile_saldac(const TEffetto& eff, numdoc_to_search = numpart; // A mali estremi... estremi rimedi } } + TPartita * partita = _part_array->exist(_cliente,anno,numpart); if (partita == NULL) // Se la partita non esiste nell'array la aggiunge { @@ -1065,59 +1121,65 @@ void TContabilizzazione_effetti_app::aggiorna_saldi() error_type TContabilizzazione_effetti_app::write_all(bool change_status) { TRectype& head = _movimento->lfile().curr(); - head.put(MOV_TOTDOC,_total_mov); - head.put(MOV_TOTDOCVAL,_total_mov_val); - - long orig_numreg, numreg = head.get_long(MOV_NUMREG); - orig_numreg = numreg; - while (_movimento->write() == _isreinsert) - head.put(MOV_NUMREG,++numreg); - if (_movimento->status() != NOERR) + long numreg = head.get_long(MOV_NUMREG); + + if (_movimento->cg_items() >= 2) // Non ha senso un movimento di una riga sola { - error_box("E' stato rilevato l'errore %d scrivendo il movimento %ld.",_movimento->status(),numreg); - _error = generic_error; - } - - if (good()) // nessun errore ? - { - aggiorna_saldi(); + TRectype& head = _movimento->lfile().curr(); + head.put(MOV_TOTDOC,_total_mov); + head.put(MOV_TOTDOCVAL,_total_mov_val); - if (_sc_enabled) // Debbo scrivere anche le partite ? + const long orig_numreg = numreg; + while (_movimento->write() == _isreinsert) + head.put(MOV_NUMREG,++numreg); + if (_movimento->status() != NOERR) { - if (numreg > orig_numreg) // Ha effettuato una rinumerazione ? - { - // Allora scorre le partite in _part_array e aggiorna il campo NREG delle righe di ognuna - for (TPartita * p = _part_array->first(); p != NULL; p = _part_array->next()) - // Scorre le righe della partita corrente - for (int n = p->last(); n > 0; n = p->pred(n)) - { - TRiga_partite& riga = p->riga(n); - if (riga.get_long(PART_NREG) == orig_numreg) // sostituisce il numero registrazione con quello nuovo - riga.put(PART_NREG, numreg); - } - } - if (!_part_array->write()) // L'errore viene gia' segnalato dalla partita - _error = generic_error; + error_box("E' stato rilevato l'errore %d scrivendo il movimento %ld.",_movimento->status(),numreg); + _error = generic_error; } - if (good() && change_status) // deve anche cambiare lo stato alla distinta ? + + if (good()) // nessun errore ? { - TDistinta& distinta = *_distinta; - const int items = distinta.items(); - for (int n = 0; n < items; n++) + aggiorna_saldi(); + + if (_sc_enabled) // Debbo scrivere anche le partite ? { - TRectype& eff = distinta[n]; - eff.put(EFF_EFFCONT, TRUE); - eff.put(EFF_NUMREG, numreg); - } - int err = distinta.rewrite(); - if (err != NOERR) - { - error_box("E' stato rilevato l'errore %d aggiornando lo stato della distinta %c %ld.",err,distinta.tipodist(),distinta.ndist()); - _error = generic_error; + if (numreg > orig_numreg) // Ha effettuato una rinumerazione ? + { + // Allora scorre le partite in _part_array e aggiorna il campo NREG delle righe di ognuna + for (TPartita * p = _part_array->first(); p != NULL; p = _part_array->next()) + // Scorre le righe della partita corrente + for (int n = p->last(); n > 0; n = p->pred(n)) + { + TRiga_partite& riga = p->riga(n); + if (riga.get_long(PART_NREG) == orig_numreg) // sostituisce il numero registrazione con quello nuovo + riga.put(PART_NREG, numreg); + } + } + if (!_part_array->write()) // L'errore viene gia' segnalato dalla partita + _error = generic_error; } } + } + + if (good() && change_status) // deve anche cambiare lo stato alla distinta ? + { + TDistinta& distinta = *_distinta; + const int items = distinta.items(); + for (int n = 0; n < items; n++) + { + TRectype& eff = distinta[n]; + eff.put(EFF_EFFCONT, TRUE); + eff.put(EFF_NUMREG, numreg); + } + int err = distinta.rewrite(); + if (err != NOERR) + { + error_box("E' stato rilevato l'errore %d aggiornando lo stato della distinta %c %ld.",err,distinta.tipodist(),distinta.ndist()); + _error = generic_error; + } } - + return _error; } @@ -1367,9 +1429,10 @@ void TContabilizzazione_effetti_app::contabilize_bill(const char tipo, const lon } } // Ciclo su effetti - if (good() && _can_write && customers.items()) // scrive il movimento residuo ... - { - join_rows(customers, banks, abbuoni_att, abbuoni_pas, differenze_cam, spese); + if (good() && _can_write) // scrive il movimento residuo ... + { + if (customers.items() > 0) + join_rows(customers, banks, abbuoni_att, abbuoni_pas, differenze_cam, spese); if (good() && write_all() == no_error) // Se la scrittura e' andata ok... _total_bills++; // incrementa il numero di distinte contabilizzate } diff --git a/in/bastird.uml b/in/bastird.uml index 2c729dd71..efbd5bd7c 100755 --- a/in/bastird.uml +++ b/in/bastird.uml @@ -16,6 +16,7 @@ BEGIN DISPLAY "Ammontare compl.@18" R0 OUTPUT F_INIZIO1 CODTAB[1,4] OUTPUT F_INIZIO2 CODTAB[5,6] + CHECKTYPE REQUIRED FIELD CODTAB[1,4] GROUP 1 END @@ -37,6 +38,7 @@ BEGIN COPY DISPLAY F_INIZIO1 OUTPUT F_FINE1 CODTAB[1,4] OUTPUT F_FINE2 CODTAB[5,6] + CHECKTYPE REQUIRED FIELD CODTAB[1,4] GROUP 2 END diff --git a/in/batbird.rpt b/in/batbird.rpt index 2ac440e78..82ff2fabd 100755 --- a/in/batbird.rpt +++ b/in/batbird.rpt @@ -10,7 +10,8 @@ Tabella Dati Riassuntivi [Rows] 1|CODTAB[1,4]|@3g@4,rs -1|CODTAB[5,]|@10g@2,rs +1|CODTAB[5,6]|@10g@2,rs + 1|I0|@21g@4,rn 1|I1|@27g@7,rn 1|I2|@36g@7,rn diff --git a/in/in0100.cpp b/in/in0100.cpp index 52678af6e..13e4db376 100755 --- a/in/in0100.cpp +++ b/in/in0100.cpp @@ -281,7 +281,10 @@ void TStampaIntra_form::print() break; default: break; - } + } + bool verygood = good(); + if (!verygood) + break; } } // Exhausting all the rest: diff --git a/in/in0200.cpp b/in/in0200.cpp index 85f2e99a7..75281af13 100755 --- a/in/in0200.cpp +++ b/in/in0200.cpp @@ -287,7 +287,6 @@ void TRecord_intra::put(const TRectype& rec, TIntra_context& ic) } } - // Scrive su file il record void TRecord_intra::print_on(ostream& o) const { @@ -316,6 +315,8 @@ protected: long calcola_totale(TCursor& cur, real& tot) const; bool write_record(ofstream& out, const TRecord_intra& rec, TIntra_context& ic); + + void proponi_numero(); public: void genera_dischetto(); @@ -323,10 +324,41 @@ public: TDischetto_mask(); }; +void TDischetto_mask::proponi_numero() +{ + int a = anno(), p = periodo(); + long d = 0; + + TTable ird("IRD"); + if (ird.last() == NOERR) + { + const TString& str = ird.get("CODTAB"); + a = atoi(str.mid(0,4)); + p = atoi(str.mid(4,2)); + d = ird.get_long("I0"); + } + + if (anno() > a || periodo() > p) + set(F_NUMERO, d+1); + else + set(F_NUMERO, d == 0 ? 1L : d); + set(F_LAST, d); +} + bool TDischetto_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) { switch (o.dlg()) { + case F_ANNO: + if (e == fe_init || e == fe_modify) + proponi_numero(); + break; + case F_PERIODO_M: + case F_PERIODO_T: + case F_PERIODO_A: + if (e == fe_modify) + proponi_numero(); + break; case F_RIEPILOGHI: if (e == fe_button) ::genera_riepiloghi(tipo(), anno(), periodo()); @@ -371,7 +403,9 @@ bool TDischetto_mask::write_record(ofstream& out, const TRecord_intra& rec, TInt out.close(); TFilename name; - name = get(F_DISCO); name.add("scambi.cee"); + name = get(F_DISCO); + name.add(get(F_PATH)); + name.add("scambi.cee"); message_box("Inserire un nuovo dischetto prima di continuare."); out.open(name); @@ -388,7 +422,6 @@ bool TDischetto_mask::write_record(ofstream& out, const TRecord_intra& rec, TInt void TDischetto_mask::genera_dischetto() { - TTable ird("IRD"); TIntra_context ic; ic._tipo = tipo(); ic._anno = anno(); @@ -397,10 +430,12 @@ void TDischetto_mask::genera_dischetto() ic._progr = get_long(F_NUMERO); TString16 codtab; codtab.format("%04d%02d", ic._anno, ic._periodo); + + TTable ird("IRD"); ird.put("CODTAB", codtab); const bool exist = ird.read() == NOERR; - if (exist && !yesno_box("il periodo indicato e' gia' stato generato,\n devo proseguire")) + if (exist && !yesno_box("Il periodo indicato è già stato generato:\nsi desidera proseguire")) return; TRelation rel(LF_RIEPRETT); @@ -418,7 +453,9 @@ void TDischetto_mask::genera_dischetto() ic._righe_rett = calcola_totale(rett, ic._totale_rett); TFilename name; - name = get(F_DISCO); name.add("scambi.cee"); + name = get(F_DISCO); + name.add(get(F_PATH)); + name.add("scambi.cee"); if (name.exist()) { @@ -466,7 +503,7 @@ void TDischetto_mask::genera_dischetto() codtab.format("%04d%02d", ic._anno, ic._periodo); ird.put("CODTAB", codtab); - ird.put("I0", ic._progr); + ird.put("I0", ic._progr); // Numero progressivo dischetto // ird.put("I1", ??? ); ird.put("I2", total); ird.put("R0", ic._totale_riep + ic._totale_rett); diff --git a/in/in0200a.h b/in/in0200a.h index e924230ef..177c98c23 100755 --- a/in/in0200a.h +++ b/in/in0200a.h @@ -6,4 +6,6 @@ #define F_PERIODO_A 105 #define F_DISCO 106 #define F_NUMERO 107 +#define F_LAST 108 +#define F_PATH 109 diff --git a/in/in0200a.uml b/in/in0200a.uml index c955fee02..c14089974 100755 --- a/in/in0200a.uml +++ b/in/in0200a.uml @@ -1,6 +1,6 @@ #include "in0200a.h" -PAGE "Generazione Dischetti INTRA" -1 -1 30 8 +PAGE "Generazione Dischetti INTRA" -1 -1 40 9 LIST F_TIPO 1 10 BEGIN @@ -11,26 +11,20 @@ END NUMBER F_ANNO 4 BEGIN - PROMPT 1 2 "Anno " + PROMPT 30 1 "Anno " FLAGS "AU" END -NUMBER F_NUMERO 6 -BEGIN - PROMPT 15 2 "Numero " - CHECKTYPE REQUIRED -END - LIST F_PERIODO_M 2 17 BEGIN - PROMPT 1 3 "Periodo " + PROMPT 1 2 "Periodo " FLAGS "AM" FIELD PERIODO END LIST F_PERIODO_T 2 17 BEGIN - PROMPT 1 3 "Periodo " + PROMPT 1 2 "Periodo " ITEM "01|Gennaio-Marzo" MESSAGE COPY,F_PERIODO_M ITEM "02|Aprile-Giugno" @@ -43,17 +37,34 @@ END LIST F_PERIODO_A 2 17 BEGIN - PROMPT 1 3 "Periodo " + PROMPT 1 2 "Periodo " ITEM "01|Annuale" MESSAGE COPY,F_PERIODO_M END +NUMBER F_NUMERO 6 +BEGIN + PROMPT 1 3 "Dischetto " + CHECKTYPE REQUIRED +END + +NUMBER F_LAST 6 +BEGIN + PROMPT 26 3 "Ultimo " + FLAGS "D" +END + LIST F_DISCO 2 BEGIN - PROMPT 1 4 "Disco destinazione " - ITEM "A:|A:" - ITEM "B:|B:" - ITEM "C:|C:" + PROMPT 1 4 "Disco destinazione " + ITEM "A:|A:" MESSAGE CLEAR,F_PATH + ITEM "B:|B:" MESSAGE CLEAR,F_PATH + ITEM "C:|C:" MESSAGE ENABLE,F_PATH +END + +STRING F_PATH 50 29 +BEGIN + PROMPT 1 5 "Cartella " END BUTTON F_RIEPILOGHI 26 1 diff --git a/in/in0500.cpp b/in/in0500.cpp index 2580755ed..db4c0fbe2 100755 --- a/in/in0500.cpp +++ b/in/in0500.cpp @@ -31,6 +31,32 @@ public: virtual ~TImmissione_mask() { } }; +/////////////////////////////////////////////////////////// +// Applicazione principale +/////////////////////////////////////////////////////////// + +class TImmissione_intra : public TRelation_application +{ + TRelation* _rel; + TImmissione_mask* _msk; + +protected: + virtual bool user_create(); + virtual TRelation* get_relation() const { return _rel; } + virtual TMask* get_mask(int) { return _msk; } + virtual bool changing_mask(int mode) { return FALSE; } + virtual bool user_destroy(); + virtual bool protected_record(TRectype & rec); + +public: +}; + +TImmissione_intra& app() { return (TImmissione_intra&)main_app(); } + +/////////////////////////////////////////////////////////// +// TImmissione_mask +/////////////////////////////////////////////////////////// + bool TImmissione_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) { const short id = o.dlg(); @@ -39,28 +65,30 @@ bool TImmissione_mask::on_field_event(TOperable_field& o, TField_event e, long j case F_NUM_REG: if (e == fe_modify || e == fe_init) { - if (main_app().has_module(CGAUT)) + if (app().has_module(CGAUT, CHK_DONGLE)) { const TString& numreg = o.get(); - if (numreg.not_empty()) { const TRectype& mov = cache().get(LF_MOV, numreg); if (mov.empty()) - return error_box("Il movimento contabile %s non esiste", (const char *) numreg); + { + if (e == fe_modify && !app().is_transaction()) + warning_box("Il movimento contabile %s non esiste", (const char*)numreg); + } else { + set(F_NUM_DOC, mov.get(MOV_NUMDOC)); + set(F_DATA_DOC, mov.get(MOV_DATADOC)); + const TString16 caus(mov.get(MOV_CODCAUS)); - TCausale c(caus); - - if (c.intra()) - { - set(F_NUM_DOC, mov.get(MOV_NUMDOC)); - set(F_DATA_DOC, mov.get(MOV_DATADOC)); - } - else - return error_box("La causale del movimento contabile %s non e' intracomunitaria", (const char *) numreg); - + const TCausale c(caus); + if (!c.intra()) + return error_box("La causale %s del movimento contabile %s non e' intracomunitaria", + (const char*)caus, (const char*)numreg); + const bool gestval = c.valintra(); + enable(F_VALUTA, gestval); + enable(F_CAMBIO, gestval); } } } @@ -77,8 +105,6 @@ bool TImmissione_mask::on_field_event(TOperable_field& o, TField_event e, long j s.enable_column(F_PAESE_ORIG, acq); s.set_column_header(F_PAESE, acq ? "Paese\nProv." : "Paese\nDest.") ; s.set_column_header(F_PROV, acq ? "Provincia\nDest." : "Provincia\nOrig.") ; - const CheckType chk1 = acq ? CHECK_REQUIRED : CHECK_NORMAL; - field(F_VALUTA).check_type(chk1); TString key ; key << main_app().get_firm(); const bool req = frequenza(anno()) == 'M' && !cache().get(LF_NDITTE, key).get_bool("NONOBBSTAT"); @@ -94,42 +120,39 @@ bool TImmissione_mask::on_field_event(TOperable_field& o, TField_event e, long j case F_CLIFO: if (e == fe_modify) { - const TRectype& curr = efield(F_CLIFO).browse()->cursor()->curr(); - TString16 codval = curr.get("VALINTRA"); - - if (codval.empty()) - codval = curr.get("CODVAL"); - - set(F_VALUTA, codval, TRUE); - + TEdit_field& valu = efield(F_VALUTA); + if (valu.active()) + { + const TRectype& curr = efield(F_CLIFO).browse()->cursor()->curr(); + TString16 codval = curr.get("VALINTRA"); + if (codval.empty()) + codval = curr.get("CODVAL"); + set(F_VALUTA, codval, TRUE); + } } break; case F_VALUTA: - if (e == fe_modify) + if (e == fe_init || e == fe_modify) { TEdit_field& cambio = efield(F_CAMBIO); - if (o.empty()) cambio.reset(); else { const TRectype& curr = cache().get("%VAL", o.get()); const TString& s = curr.get("S4"); - cambio.set(s); } TSheet_field& s = sfield(F_RIGHE); const bool enable_val = is_true_value(get(F_VALUTA)); - + const int col = s.cid2index(F_AMM_VALUTA); + + s.enable_column(col, enable_val); const int rows = s.items(); - for (int i = 0; i < rows; i++) { - const int col = s.cid2index(F_AMM_VALUTA); s.enable_cell(i, col, enable_val); - TToken_string & r = s.row(i); - if (!enable_val) r.add("", col); } @@ -161,7 +184,7 @@ bool TImmissione_mask::on_field_event(TOperable_field& o, TField_event e, long j if (!enable_val) m.reset(F_AMM_VALUTA); else - if (m.get_real(F_AMM_VALUTA).is_zero()) + if (!o.empty() && m.get_real(F_AMM_VALUTA).is_zero()) { curr.change_value(get(F_VALUTA), get_real(F_CAMBIO)); m.set(F_AMM_VALUTA, curr, TRUE); @@ -173,7 +196,7 @@ bool TImmissione_mask::on_field_event(TOperable_field& o, TField_event e, long j if (e == fe_modify) { TMask& m = o.mask(); - if (m.get_real(F_AMM_LIRE).is_zero()) + if (!o.empty() && m.get_real(F_AMM_LIRE).is_zero()) { TCurrency curr(real(o.get()), get(F_VALUTA), get_real(F_CAMBIO)); curr.change_to_firm_val(); @@ -199,11 +222,14 @@ bool TImmissione_mask::on_sheet_event(TSheet_field& s, TField_event e, int row) { if (e == se_notify_add) { - const bool enable_val = is_true_value(get(F_VALUTA)); - const int col = s.cid2index(F_AMM_VALUTA); - - s.enable_cell(s.selected(), col, enable_val); - s.force_update(); + const bool enable_val = is_true_value(get(F_VALUTA)); + if (!enable_val) + { + const int col = s.cid2index(F_AMM_VALUTA); + row = s.items()-1; + s.enable_cell(row, col, enable_val); + s.force_update(row); + } } else if (e == se_notify_modify) @@ -234,7 +260,6 @@ bool TImmissione_mask::on_sheet_field_event(TOperable_field& o, TField_event e, { TMask& m = o.mask(); TString16 key; key << m.get(F_NOMENCLATURA1) << m.get(F_NOMENCLATURA2) << m.get(F_NOMENCLATURA3); - if (key.empty()) return error_box("La nomenclatura combinata e' obbligatoria"); } @@ -279,22 +304,6 @@ TImmissione_mask::TImmissione_mask() // Applicazione principale /////////////////////////////////////////////////////////// -class TImmissione_intra : public TRelation_application -{ - TRelation* _rel; - TImmissione_mask* _msk; - -protected: - virtual bool user_create(); - virtual TRelation* get_relation() const { return _rel; } - virtual TMask* get_mask(int) { return _msk; } - virtual bool changing_mask(int mode) { return FALSE; } - virtual bool user_destroy(); - virtual bool protected_record(TRectype & rec); - -public: -}; - bool TImmissione_intra::protected_record(TRectype & rec) { const char tipo = rec.get_char("TIPOMOV"); diff --git a/in/in0500a.uml b/in/in0500a.uml index 3a5e17b58..91982910f 100755 --- a/in/in0500a.uml +++ b/in/in0500a.uml @@ -6,7 +6,7 @@ TOOLBAR "Toolbar" 0 -3 0 3 BUTTON R_RIEPILOGHI 28 1 BEGIN - PROMPT -11 0 "~Generazione Riepiloghi" + PROMPT -11 -3 "~Generazione Riepiloghi" END ENDPAGE @@ -168,7 +168,7 @@ BEGIN DISPLAY "Codice" CODTAB DISPLAY "Descrizione@50" S0 OUTPUT F_VALUTA CODTAB - CHECKTYPE REQUIRED + CHECKTYPE NORMAL MESSAGE EMPTY CLEAR,F_CAMBIO MESSAGE ENABLE,F_CAMBIO FIELD CODVAL @@ -320,6 +320,7 @@ BEGIN DISPLAY "Codice" CODTAB DISPLAY "Descrizione@50" S0 OUTPUT F_CONSEGNA CODTAB + CHECKTYPE NORMAL FIELD CONSEGNA END @@ -331,6 +332,7 @@ BEGIN DISPLAY "Codice" CODTAB DISPLAY "Descrizione@50" S0 OUTPUT F_TRASPORTO CODTAB + CHECKTYPE NORMAL FIELD TRASPORTO END diff --git a/in/in0500b.uml b/in/in0500b.uml index 15a2cff4b..f6fa6ce72 100755 --- a/in/in0500b.uml +++ b/in/in0500b.uml @@ -13,6 +13,7 @@ NUMBER R_ANNO 4 BEGIN PROMPT 1 2 "Anno " FLAGS "AU" + CHECKTYPE REQUIRED END LIST R_PERIODO_M 2 17 diff --git a/in/in0600.cpp b/in/in0600.cpp index 2e44dbf86..b5e2850f7 100755 --- a/in/in0600.cpp +++ b/in/in0600.cpp @@ -45,22 +45,29 @@ bool TRiepiloghi_mask::on_field_event(TOperable_field& o, TField_event e, long j { TString16 key; key << get(F_NOMENCLATURA1) << get(F_NOMENCLATURA2) << get(F_NOMENCLATURA3); const TRectype& nom = cache().get("%NOC", key); - - key = nom.get("S5"); - set(F_UMS, key); + set(F_UMS, nom.get("S5")); + bool req = frequenza(anno()) == 'M'; + if (req) // Solo la frequenza mensile puo' obbligare + { + const char obb = nom.get_char("S4"); + req = obb == 'E' || obb == tipo(); + } + field(F_MASSA_UMS).check_type(req ? CHECK_REQUIRED : CHECK_NORMAL); } break; case F_VALORE_STAT: if (e == fe_init) { - TMask& m = o.mask(); - TString key ; key << main_app().get_firm(); - const bool req = frequenza(anno()) == 'M' && !cache().get(LF_NDITTE, key).get_bool("NONOBBSTAT"); + bool req = frequenza(anno()) == 'M'; + if (req) + { + TString16 key ; key << main_app().get_firm(); + req = !cache().get(LF_NDITTE, key).get_bool("NONOBBSTAT"); + } const CheckType chk = req ? CHECK_REQUIRED : CHECK_NORMAL; - - m.field(F_VALORE_STAT).check_type(chk); - m.field(F_CONSEGNA).check_type(chk); - m.field(F_TRASPORTO).check_type(chk); + field(F_VALORE_STAT).check_type(chk); + field(F_CONSEGNA).check_type(chk); + field(F_TRASPORTO).check_type(chk); } break; case F_PARTITA_IVA: @@ -78,7 +85,16 @@ bool TRiepiloghi_mask::on_field_event(TOperable_field& o, TField_event e, long j case F_NATURA_TRANS: if (e == fe_modify || e == fe_init) o.check(); - break; + break; + case F_VALUTA: + if (e == fe_modify || e == fe_init) + { + const bool tv = is_true_value(o.get()); + if (!tv) o.reset(); + TEdit_field& av = efield(F_AMM_VALUTA); + av.check_type(tv ? CHECK_REQUIRED : CHECK_NORMAL); + } + break; case F_RIEPILOGHI: if (e == fe_button) ::genera_riepiloghi(tipo(), anno()); @@ -114,7 +130,9 @@ protected: virtual bool get_next_key(TToken_string& k); virtual void init_query_mode(TMask& m); virtual void init_insert_mode(TMask& m); + virtual void init_modify_mode(TMask& m); virtual bool save_and_new() const { return TRUE; }; + virtual void check_existent_disk(const TMask& m); public: }; @@ -158,10 +176,16 @@ bool TRiepiloghi_intra::get_next_key(TToken_string& k) } void TRiepiloghi_intra::init_insert_mode(TMask& m) -{ +{ + check_existent_disk(m); m.enable(F_VALUTA); } +void TRiepiloghi_intra::init_modify_mode(TMask& m) +{ + check_existent_disk(m); +} + int TRiepiloghi_intra::write(const TMask& m) { _rel->curr().put("FREQUENZA", ((TRiepiloghi_mask &) m).frequenza(m.get_int(F_ANNO))); @@ -187,6 +211,28 @@ void TRiepiloghi_intra::init_query_mode(TMask& m) m.disable(F_VALUTA); } +void TRiepiloghi_intra::check_existent_disk(const TMask& m) +{ + int anno = m.get_int(F_ANNO); + int periodo = 0; + if (m.field(F_PERIODO_M).shown()) + periodo = m.get_int(F_PERIODO_M); + else + if (m.field(F_PERIODO_T).shown()) + periodo = m.get_int(F_PERIODO_M); + else + if (m.field(F_PERIODO_A).shown()) + periodo = m.get_int(F_PERIODO_A); + + TString str; + str.format("%4d%02d",anno,periodo); + + const TRectype& ird = cache().get("IRD",str); + if (!ird.empty()) + warning_box("E' già stato generato il dischetto per il periodo %d dell'anno %d", periodo,anno); + +} + int in0600(int argc, char* argv[]) { TRiepiloghi_intra a; diff --git a/in/in0600a.uml b/in/in0600a.uml index a53a02df7..80ad9d18f 100755 --- a/in/in0600a.uml +++ b/in/in0600a.uml @@ -4,6 +4,11 @@ TOOLBAR "Toolbar" 0 -3 0 3 #include +BUTTON F_RIEPILOGHI 28 1 +BEGIN + PROMPT -11 -3 "~Generazione Riepiloghi" +END + ENDPAGE PAGE "Riepiloghi INTRA" -1 -1 78 18 @@ -98,11 +103,14 @@ BEGIN FLAGS "AU" KEY 1 FIELD ANNO + NUM_EXPR #F_ANNO>=1980 + CHECKTYPE REQUIRED + WARNING "Anno non valido" END LIST F_TIPO 1 10 BEGIN - PROMPT 49 3 "Tipo riepilogo " + PROMPT 49 3 "Tipo riepilogo " ITEM "C|Cessioni" MESSAGE "C",F_TIPO_CF|SHOW,GR_CESSIONI@|HIDE,GR_ACQUISTI@ ITEM "A|Acquisti" @@ -311,7 +319,7 @@ END STRING F_PAESE 2 BEGIN - PROMPT 22 13 "" + PROMPT 26 13 "" FLAGS "U" USE %SCE INPUT CODTAB F_PAESE @@ -358,6 +366,8 @@ CURRENCY F_AMM_LIRE 18 BEGIN PROMPT 1 15 "Ammontare " FIELD AMMLIRE + CHECKTYPE REQUIRED + WARNING "E' necessario inserire l'ammontare" END STRING F_VALUTA 3 @@ -370,7 +380,7 @@ BEGIN CHECKTYPE NORMAL OUTPUT F_VALUTA CODTAB FIELD CODVAL - FLAGS "UZ" + FLAGS "GUZ" END CURRENCY F_AMM_VALUTA 18 @@ -378,6 +388,7 @@ BEGIN PROMPT 59 15 "" DRIVENBY F_VALUTA FIELD AMMVALUTA + WARNING "Inserire l'ammontare in valuta" END CURRENCY F_VALORE_STAT 18 @@ -395,7 +406,7 @@ END STRING F_UMS 2 BEGIN - PROMPT 41 17 "In unita'supp." + PROMPT 41 17 "Unita' supp. " FLAGS "DU" END @@ -404,6 +415,7 @@ BEGIN PROMPT 59 17 "" PICTURE ".5" FIELD MASSAUMS + WARNING "Inserire la massa in unità supplementare" END ENDPAGE diff --git a/in/in0700.cpp b/in/in0700.cpp index 42e479a63..6baceb510 100755 --- a/in/in0700.cpp +++ b/in/in0700.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "in0.h" #include "in0700a.h" @@ -14,14 +15,51 @@ class TRettifiche_mask : public TIntra_mask protected: virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); virtual short type_field() const { return F_TIPO; } + void inventa_cambio_intra(); + +public: virtual short period_field() const { return F_PERIODO_M; } virtual int anno() const { return get_int(O_ANNO); } public: - TRettifiche_mask(); virtual ~TRettifiche_mask() { } -}; +}; + +void TRettifiche_mask::inventa_cambio_intra() +{ + const TString& codval = get(F_VALUTA); + if (is_true_value(codval)) + { + TTable cam("CAM"); + cam.put("CODTAB", codval); + const int err = cam.read(_isgteq); + bool yes = err != NOERR; + if (!yes) + { + TString16 v = cam.get("CODTAB"); + v.cut(3).rtrim(); + yes = v != codval; + } + if (yes) + { + TCurrency eur; get_currency(F_AMMONTARE, eur); + TCurrency val; get_currency(F_AMM_VALUTA, val); + if (eur.is_zero()) + { + val.change_to_firm_val(); + set(F_AMMONTARE, val); + } + if (val.is_zero()) + { + const real cambio = cache().get("%VAL", codval, "S4"); + const TExchange exc(codval, cambio); + eur.change_value(exc); + set(F_AMM_VALUTA, eur); + } + } + } +} bool TRettifiche_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) { @@ -67,6 +105,14 @@ bool TRettifiche_mask::on_field_event(TOperable_field& o, TField_event e, long j } } break; + case F_AMMONTARE: + if (e == fe_modify && !o.empty() && field(F_AMM_VALUTA).empty()) + inventa_cambio_intra(); + break; + case F_AMM_VALUTA: + if (e == fe_modify && !o.empty() && field(F_AMMONTARE).empty()) + inventa_cambio_intra(); + break; default: break; } @@ -86,7 +132,9 @@ TRettifiche_mask::TRettifiche_mask() class TRettifiche_intra : public TRelation_application { TRelation* _rel; - TMask* _msk; + TRettifiche_mask* _msk; + + TToken_string _str; // jolly string protected: virtual bool user_create(); @@ -94,7 +142,13 @@ protected: virtual TMask* get_mask(int) { return _msk; } virtual bool changing_mask(int mode) { return FALSE; } virtual bool user_destroy(); + virtual const char* get_next_key(); + virtual void init_query_mode(TMask& m); + virtual void init_insert_mode(TMask& m); + virtual void init_modify_mode(TMask& m); + + void init_mask(TMask& m, bool keyon); public: }; @@ -114,6 +168,57 @@ bool TRettifiche_intra::user_destroy() return TRUE; } +void TRettifiche_intra::init_mask(TMask& m, bool keyon) +{ + m.enable(O_ANNO, keyon); + m.enable(O_PERIODO_M, keyon); + m.enable(O_PERIODO_T, keyon); + m.enable(O_PERIODO_A, keyon); + m.enable(O_NUM_RIG, keyon); + m.enable(-GR_ORIGINAL, keyon); +} + +void TRettifiche_intra::init_query_mode(TMask& m) +{ + init_mask(m, FALSE); +} + +void TRettifiche_intra::init_insert_mode(TMask& m) +{ + init_mask(m, TRUE); +} + +void TRettifiche_intra::init_modify_mode(TMask& m) +{ + init_mask(m, TRUE); +} + +const char* TRettifiche_intra::get_next_key() +{ + TRectype& curr = _rel->curr(); + curr.put("TIPO", _msk->tipo()); + curr.put("ANNO", _msk->anno()); + curr.put("PERIODO", _msk->periodo_str()); + TCursor cur(_rel, "", 1, &curr, &curr); + const long items = cur.items(); + int last_row = 0; + if (items > 0) + { + cur = items-1; + last_row = curr.get_int("NUMRIG"); + } + _str.cut(0); + _str.add(F_TIPO); + _str.add(curr.get("TIPO")); + _str.add(F_ANNO); + _str.add(curr.get("ANNO")); + _str.add(F_PERIODO_M); + _str.add(curr.get("PERIODO")); + _str.add(F_NUM_RIG); + _str.add(last_row+1); + return _str; +} + int in0700(int argc, char* argv[]) { TRettifiche_intra a; diff --git a/in/in0700a.h b/in/in0700a.h index 7bed0d820..3e13f34b0 100755 --- a/in/in0700a.h +++ b/in/in0700a.h @@ -14,7 +14,7 @@ #define O_NATURA_TRANS 121 #define O_NOMENCLATURA1 122 -#define O_AMM_LIRE 123 +#define O_AMMONTARE 123 #define O_AMM_VALUTA 124 #define O_VALUTA 125 #define O_VALORE_STAT 126 @@ -34,7 +34,7 @@ #define F_SEGNO 220 #define F_NATURA_TRANS 221 #define F_NOMENCLATURA1 222 -#define F_AMM_LIRE 223 +#define F_AMMONTARE 223 #define F_AMM_VALUTA 224 #define F_VALUTA 225 #define F_VALORE_STAT 226 diff --git a/in/in0700a.uml b/in/in0700a.uml index 7b1cc2e45..872ebec22 100755 --- a/in/in0700a.uml +++ b/in/in0700a.uml @@ -114,7 +114,7 @@ BEGIN OUTPUT O_NOMENCLATURA1 NOMENCL[1,4] OUTPUT O_NOMENCLATURA2 NOMENCL[5,6] OUTPUT O_NOMENCLATURA3 NOMENCL[7,8] - OUTPUT O_AMM_LIRE AMMLIRE + OUTPUT O_AMMONTARE AMMLIRE OUTPUT O_VALUTA CODVAL OUTPUT F_VALUTA CODVAL OUTPUT O_AMM_VALUTA AMMVALUTA @@ -223,9 +223,9 @@ BEGIN WARNING "Nomenclatura combinata assente" END -CURRENCY O_AMM_LIRE 18 +CURRENCY O_AMMONTARE 18 BEGIN - PROMPT 2 8 "Ammontare in lire " + PROMPT 2 8 "Ammontare " CHECKTYPE REQUIRED GROUP GR_ORIGINAL END @@ -245,10 +245,9 @@ BEGIN GROUP GR_ORIGINAL END -NUMBER O_VALORE_STAT 18 +CURRENCY O_VALORE_STAT 18 BEGIN PROMPT 2 9 "Valore statistico " - PICTURE "." GROUP GR_ORIGINAL END @@ -403,7 +402,7 @@ BEGIN OUTPUT F_NOMENCLATURA3 CODTAB[7,8] VALIDATE REQIF_FUNC 1 F_NOMENCLATURA2 MESSAGE DIRTY,F_NOMENCLATURA3 - FIELD NOMENCL + FIELD NOMENCL[1,4] WARNING "Nomenclatura combinata assente" END @@ -414,6 +413,7 @@ BEGIN COPY ALL F_NOMENCLATURA1 VALIDATE REQIF_FUNC 1 F_NOMENCLATURA3 MESSAGE DIRTY,F_NOMENCLATURA3 + FIELD NOMENCL[5,6] WARNING "Nomenclatura combinata assente" END @@ -423,6 +423,7 @@ BEGIN FLAGS "Z" COPY ALL F_NOMENCLATURA1 CHECKTYPE NORMAL + FIELD NOMENCL[7,8] WARNING "Nomenclatura combinata assente" END @@ -434,9 +435,9 @@ BEGIN FIELD SEGNORETT END -CURRENCY F_AMM_LIRE 18 +CURRENCY F_AMMONTARE 18 BEGIN - PROMPT 2 16 "Ammontare in lire " + PROMPT 2 16 "Ammontare " FIELD AMMLIRE END diff --git a/in/inlib01.cpp b/in/inlib01.cpp index ec1fb967c..c76def9ad 100755 --- a/in/inlib01.cpp +++ b/in/inlib01.cpp @@ -85,7 +85,6 @@ const char* TIntra_mask::periodo_str() const const char* pe = "01"; if (id != DLG_NULL) { -// const int anno = get_int(R_ANNO); switch(frequenza(anno())) { case 'M': pe = get(id); break; @@ -191,13 +190,20 @@ void TDati_riepilogo::write(TRectype& rec) const rec.put("PAESEORIG", paese_orig(str)); rec.put("PROV", provincia(str)); - rec.put("AMMLIRE", _ammlire.get_num()); - rec.put("AMMVALUTA", _ammvaluta.get_num()); - rec.put("CODVAL", _ammvaluta.get_value()); + rec.put("AMMLIRE", _ammlire.get_num()); + if (_ammvaluta.is_zero()) + { + rec.zero("CODVAL"); // Altrimenti genera falsi codici valuta EUR ... + rec.zero("AMMVALUTA"); // ... con importi nulli + } + else + { + rec.put("CODVAL", _ammvaluta.get_value()); + rec.put("AMMVALUTA", _ammvaluta.get_num()); + } rec.put("VALSTAT", _valstat); rec.put("MASSAKG", _massakg); rec.put("MASSAUMS", _massaums); - } TDati_riepilogo::TDati_riepilogo(const TDati_riepilogo& r) @@ -209,7 +215,7 @@ TDati_riepilogo::TDati_riepilogo(const TDati_riepilogo& r) TDati_riepilogo::TDati_riepilogo(const TToken_string& key, const TRectype& rec, const TString& codval) -: _key(key), _ammlire(rec.get_real("AMMLIRE"), "_FIRM"), +: _key(key), _ammlire(rec.get_real("AMMLIRE")), _ammvaluta(rec.get_real("AMMVALUTA"), codval), _valstat(rec.get_real("VALSTAT")), _massakg(rec.get_real("MASSAKG")), @@ -240,7 +246,7 @@ void TRiepiloghi::add(const TRectype& rec, const TRectype& mov) { TString16 cod; const char tipocf = mov.get_char("TIPOCF"); - cod << tipocf << '|' << mov.get_long("CODCF"); + cod << tipocf << '|' << mov.get("CODCF"); const TRectype& clifo = cache().get(LF_CLIFO, cod); cod = mov.get("CODVAL"); @@ -299,7 +305,7 @@ bool TGenerazione_mask::genera_riepiloghi() int da_mese, a_mese; const char freq = frequenza(anno_r); - if (is_riepilogo(tipo, anno_r, peri) && !yesno_box("Attenzione esiste gia' il riepilogo\nper il periodo indicato, devo continuare")) + if (is_riepilogo(tipo, anno_r, peri) && !yesno_box("Attenzione esiste gia' il riepilogo\nper il periodo indicato, si desidera continuare")) return FALSE; switch (freq) diff --git a/in/inprassi.men b/in/inprassi.men index 64dd184c4..d53969060 100755 --- a/in/inprassi.men +++ b/in/inprassi.men @@ -30,7 +30,7 @@ Item_04 = "Condizioni di consegna", "ba3 -1 %icc", "" Item_05 = "Modalita' di trasporto", "ba3 -1 %imt", "" [PRASSIIN_004] -Caption = "Gestione movmenti" +Caption = "Gestione movimenti" Picture = Module = 18 Flags = "F" diff --git a/include/alleg.h b/include/alleg.h index f9a5bc7c0..de676b7e2 100755 --- a/include/alleg.h +++ b/include/alleg.h @@ -1,23 +1,26 @@ #ifndef __ALLEG_H #define __ALLEG_H -#define ALL_ANNO "ANNO" -#define ALL_CODATT "CODATT" -#define ALL_TIPOCF "TIPOCF" -#define ALL_CODCF "CODCF" -#define ALL_IMMESSO "IMMESSO" -#define ALL_IMPESC "IMPESC" -#define ALL_IVAESC "IVAESC" -#define ALL_NIESC "NIESC" -#define ALL_E8ESC "E8ESC" -#define ALL_NDOCESC "NDOCESC" -#define ALL_IMPESP "IMPESP" -#define ALL_IVAESP "IVAESP" -#define ALL_NIESP "NIESP" -#define ALL_E8ESP "E8ESP" -#define ALL_NDOCESP "NDOCESP" -#define ALL_NALLESP "NALLESP" -#define ALL_PROG101102 "PROG101102" +#define ALL_ANNO "ANNO" +#define ALL_CODATT "CODATT" +#define ALL_TIPOCF "TIPOCF" +#define ALL_CODCF "CODCF" +#define ALL_IMMESSO "IMMESSO" +#define ALL_PROG101102 "PROG101102" + +#define ALL_IMPESC "IMPESC" +#define ALL_IVAESC "IVAESC" +#define ALL_NIESC "NIESC" +#define ALL_E8ESC "E8ESC" +#define ALL_NDOCESC "NDOCESC" +#define ALL_NALLESC "NALLESC" + +#define ALL_IMPESP "IMPESP" +#define ALL_IVAESP "IVAESP" +#define ALL_NIESP "NIESP" +#define ALL_E8ESP "E8ESP" +#define ALL_NDOCESP "NDOCESP" +#define ALL_NALLESP "NALLESP" #endif diff --git a/include/isam.cpp b/include/isam.cpp index e529520b0..79f96207e 100755 --- a/include/isam.cpp +++ b/include/isam.cpp @@ -725,9 +725,11 @@ TBaseisamfile::TBaseisamfile( fatal_box("Non posso creare il file %s : errore n.ro %d", name, err); } _lasterr = NOERR; - TFilename filename(name); + TFilename filename(name); + CHECK(filename.not_empty(),"Must define the file to open!"); _logicnum = prefix().get_handle(filename); - _current = new TRectype(this); + _current = new TRectype(this); + } TBaseisamfile::~TBaseisamfile() @@ -3574,4 +3576,3 @@ TRecnotype TRecfield::ptr() const r = (r << 8) + *wp; return n ? -r : r; } - diff --git a/include/printapp.h b/include/printapp.h index e2314af6a..1af2778f1 100755 --- a/include/printapp.h +++ b/include/printapp.h @@ -198,6 +198,8 @@ class TPrint_application : public TApplication // @cmember:(INTERNAL) Indica se la stampa e' stata interrotta bool _cancelled; +// @access Protected Member +protected: // @cmember:(INTERNAL) Setta la stampante void set_printer() { printer().set(); } @@ -228,9 +230,6 @@ class TPrint_application : public TApplication // @cmember:(INTERNAL) Distrugge la finestra virtual bool destroy(); - // @access Protected Member -protected: - // @cmember Utilizzata per la creazione dei cursori necessari virtual bool user_create() pure; // @cmember Utilizzata per la distruzione dei cursori diff --git a/include/rmov.h b/include/rmov.h index b8765a5ac..e923973e0 100755 --- a/include/rmov.h +++ b/include/rmov.h @@ -19,9 +19,7 @@ #define RMV_ROWTYPE "ROWTYPE" // Centro di costo -#define RMV_CDC "NUMGIO" -// To be removed soon -#define RMV_NUMGIO "NUMGIO" -#define RMV_RCONTR "RCONTR" +#define RMV_CODCMS "CODCMS" +#define RMV_FASCMS "FASCMS" #endif diff --git a/include/rmoviva.h b/include/rmoviva.h index e539c95f5..201351755 100755 --- a/include/rmoviva.h +++ b/include/rmoviva.h @@ -21,4 +21,7 @@ #define RMI_TIPOC "TIPOC" #define RMI_RIGAIMP "RIGAIMP" #define RMI_RIGAIVA "RIGAIVA" +#define RMI_CODCMS "CODCMS" +#define RMI_FASCMS "FASCMS" + #endif diff --git a/include/validate.cpp b/include/validate.cpp index 9e97d2284..cf1c6b630 100755 --- a/include/validate.cpp +++ b/include/validate.cpp @@ -63,6 +63,37 @@ HIDDEN bool _emptycopy_val(TMask_field& f, KEY) return TRUE; } +bool check_pi_estera(const TString& st, const TString& paiva) +{ + const char* stpi[] = { "AT09", "BE09", "DE09", "DK08", "EL08", "ES09", + "FI08", "FR11", "GB05", "GB09", "GB12", "IE08", + "LU08", "NL12", "PT09", "SE12", "SM05", NULL }; + bool lenok = FALSE; + bool known = FALSE; + + for (int g = 0; stpi[g] && !lenok; g++) + { + if (st.compare(stpi[g], 2, TRUE) == 0) // Se lo stato corrisponde + { + known = TRUE; + lenok = paiva.len() == atoi(stpi[g]+2); // Confronto lunghezza + } + else + { + if (known) // Inutile cercare ancora + break; + } + } + if (known) + { + if (st=="AT") // Controllo speciale per l'Austria che comincia per U + lenok &= (paiva[0] == 'U'); + } + else + lenok = TRUE; // Gli stati ignoti hanno sempre lunghezza corretta! + return lenok; +} + // @doc EXTERNAL // @func Controlla se la Partita IVA assume un valore valido @@ -111,22 +142,8 @@ bool pi_check( } } else - { - const char* stpi[] = { "AT09", "BE09", "DE09", "DK08", "EL08", "ES09", - "FI08", "FR11", "GB05", "GB09", "GB12", "IE08", - "IT11", "LU08", "NL12", "PT09", "SE12", NULL }; - TString16 test; - test.format("%s%02d", (const char*)stato, pi.len()); - - ok = FALSE; - for (int g = 0; stpi[g]; g++) - { - ok = (test == stpi[g]); - if (ok) - break; - } - if ((test=="AT09") && (ok)) - ok = (pi[0] == 'U'); + { + ok = check_pi_estera(stato, pi); } return ok; diff --git a/mg/mglib02.cpp b/mg/mglib02.cpp index 9bafccc1b..e51d6f447 100755 --- a/mg/mglib02.cpp +++ b/mg/mglib02.cpp @@ -1075,7 +1075,8 @@ void TArticolo_giacenza::agg_storicoLIFO(const char * annoes, const char * codma nuovo_storico.sort(sort_storico_rev); if (giacenza <= ZERO) - giacenza=ZERO; + return; +// giacenza=ZERO; if (giacenza > rim) { qta=giacenza-rim; @@ -1131,8 +1132,6 @@ void TArticolo_giacenza::agg_storicoFIFO(const char * annoes, const char * codma if (giacenza <= ZERO) return ; -// if (giacenza <= acq) -// return; TString nuovoanno; TEsercizi_contabili ese; diff --git a/pr/f122.dir b/pr/f122.dir index e9fef1cda..390661122 100755 --- a/pr/f122.dir +++ b/pr/f122.dir @@ -1,3 +1,3 @@ 122 0 -$agenti|7|8|151|36|Archivio agenti||| +$agenti|0|0|151|0|Archivio agenti||| diff --git a/pr/pr1500.cpp b/pr/pr1500.cpp index 7750875ac..d2b875c43 100755 --- a/pr/pr1500.cpp +++ b/pr/pr1500.cpp @@ -48,17 +48,24 @@ bool TFirr_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) } void TFirr_mask::load_params() -{ +{ + + const bool in_euro = is_euro_value(NULL); + TConfig cfg(CONFIG_STUDIO, "pr"); set(F_PREVID, cfg.get("Previdenza", NULL, -1, "5.75")); set(F_ASSIST, cfg.get("Assistenza", NULL, -1, "2.00")); - set(F_PREV_MIN, cfg.get("PrevMin", NULL, -1, "120000")); - set(F_PREV_MAX, cfg.get("PrevMax", NULL, -1, "4830000")); + set(F_PREV_MIN, cfg.get("PrevMin", NULL, -1, in_euro ? "248" : "480000")); + set(F_PREV_MAX, cfg.get("PrevMax", NULL, -1, in_euro ? "2494" : "4830000")); for (int i = 0; i < 3; i++) { set(F_FIRR_1+i, cfg.get_int("Firr", NULL, i, i+1)); - const char* def = (i == 0) ? "24000000" : "36000000"; + const char* def; + if (i == 0) + def = in_euro ? "12395" : "24000000"; + else + def = in_euro ? "18592" : "36000000"; set(F_LIMITE_1+i, cfg.get("FirrLimit", NULL, i, def)); } } diff --git a/pr/pr1500a.uml b/pr/pr1500a.uml index f6781f145..1b90f6c06 100755 --- a/pr/pr1500a.uml +++ b/pr/pr1500a.uml @@ -77,18 +77,14 @@ BEGIN FLAGS "U" END -NUMBER F_PREV_MIN 15 +CURRENCY F_PREV_MIN 15 BEGIN PROMPT 22 1 "Min." - PICTURE "." - FLAGS "U" END -NUMBER F_PREV_MAX 15 +CURRENCY F_PREV_MAX 15 BEGIN PROMPT 22 2 "Max." - PICTURE "." - FLAGS "U" END GROUPBOX DLG_NULL 42 5 @@ -103,11 +99,9 @@ BEGIN FLAGS "U" END -NUMBER F_LIMITE_1 15 +CURRENCY F_LIMITE_1 15 BEGIN PROMPT 18 5 "Fino a " - PICTURE "." - FLAGS "U" END NUMBER F_FIRR_2 5 2 @@ -117,11 +111,9 @@ BEGIN FLAGS "U" END -NUMBER F_LIMITE_2 15 +CURRENCY F_LIMITE_2 15 BEGIN PROMPT 18 6 "Fino a " - PICTURE "." - FLAGS "U" NUM_EXPR #F_LIMITE_2>=#F_LIMITE_1 MESSAGE COPY,F_LIMITE_3 END @@ -133,11 +125,10 @@ BEGIN FLAGS "U" END -NUMBER F_LIMITE_3 15 +CURRENCY F_LIMITE_3 15 BEGIN PROMPT 18 7 "Oltre " - PICTURE "." - FLAGS "DU" + FLAGS "D" END BUTTON DLG_SAVEREC 10 2 diff --git a/sc/sc2100.cpp b/sc/sc2100.cpp index 5122512c0..9e0cf0d2f 100755 --- a/sc/sc2100.cpp +++ b/sc/sc2100.cpp @@ -52,7 +52,6 @@ protected: int find_magic(TString& s, TString& magic1, TString& magic2) const; void change_magic_body(const TEC_row& o, TString& s); void change_magic_footer(const THash_object& o, TString& s); -// void modify_picture(TForm_item& fi, TString_array& op, const bool in_valuta); void print_total(int riga, const THash_object& o); void stampa_testata(TPrinter& p); @@ -811,42 +810,6 @@ void TEC_form::change_magic_footer(const THash_object& o, TString& s) } } -/* -void TEC_form::modify_picture(TForm_item& fi, TString_array& op, const bool in_valuta) -{ - TString pic(20); - pic = fi.picture(); - op.add(pic); - const int w = fi.width(); - if (in_valuta && _in_valuta) - { - if (pic.find(',') > 0) - pic << ".###"; - else - pic << ",@@@"; - int exceed = w - pic.len(); - if (exceed<0 && w>0) - { - exceed=::abs(exceed); - pic = pic.mid(exceed,pic.len()-exceed); - } - } - // oltre a cio' deve correggere la picture, in modo che tutti gli importi del - // footer risultino incolonnati correttamente. - // (nel body cio' e' fatto in TForm_number::put_paragraph()) - const int l = pic.len(); - if (w>l) - { - int gap = w-l; - TString stmp(gap); // cosi' mette gli spazi necessari davanti alla picture - stmp.fill(' '); // in modo da colmare il vuoto - pic.insert(stmp); - } - - fi.set_picture(pic); -} -*/ - void TEC_form::print_total(int riga, const THash_object& o) { const short MAXID = 4; @@ -1359,18 +1322,16 @@ long TStampaEC_application::find_agents_games(TAssoc_array& agents) const TString& toage = mask().get(F_TO_AGENT); TRelation rel(LF_SCADENZE); - TRectype& curr = rel.curr(); - curr.put(SCAD_TIPOCF, mask().get(SC_CLIFO)); - - TString filter; - filter << "(CODAG!=\"\")"; - if (!mask().get_bool(F_STAMPCHIU)) - filter << "&&(PAGATA==\"\")"; - if (fromage.not_empty()) - filter << "&&(CODAG>=\"" << fromage << "\")"; - if (toage.not_empty()) - filter << "&&(CODAG<=\"" << toage << "\")"; + rel.add(LF_PAGSCA, "TIPOC==TIPOC|GRUPPO==GRUPPO|CONTO==CONTO|SOTTOCONTO==SOTTOCONTO|" + "ANNO==ANNO|NUMPART==NUMPART|NRIGA==NRIGA|NRATA==NRATA"); + TRectype& curr = rel.curr(); + const TRectype& pagsca = rel.curr(LF_PAGSCA); + + curr.put(SCAD_TIPOCF, mask().get(SC_CLIFO)); + TString filter; + if (!mask().get_bool(F_STAMPCHIU)) + filter << "(PAGATA==\"\")"; TCursor cur(&rel, filter, 1, &curr, &curr); const long items = cur.items(); cur.freeze(); @@ -1382,7 +1343,18 @@ long TStampaEC_application::find_agents_games(TAssoc_array& agents) if (pi.iscancelled()) break; - const TString& codag = curr.get(SCAD_CODAG); + const char* codag = pagsca.get(PAGSCA_CODAG); + if (*codag == '\0') + { + codag = curr.get(SCAD_CODAG); + if (*codag == '\0') + continue; + } + if (fromage.not_empty() && fromage > codag) + continue; + if (toage.not_empty() && toage < codag) + continue; + TEC_Game_list* games = (TEC_Game_list*)agents.objptr(codag); if (games == NULL) { diff --git a/sc/sc2200.cpp b/sc/sc2200.cpp index 854fe0b33..d293d429b 100755 --- a/sc/sc2200.cpp +++ b/sc/sc2200.cpp @@ -33,7 +33,7 @@ struct _LinearTotal : public TObject // Oggetto base per gli elementi di tlg, t }; enum tipo_st {nessuno=0, tutti=1, clienti=2, fornitori=3, altri=4}; -enum tipo_pe {daily, monthly, period, single}; +enum tipo_pe {daily, monthly, period, single, bank}; const char * tipi_tab[10] = {"Altro","Rimesse dirette","Tratte","Ricevute bancarie","Cessioni","Paghero'", "Lettere di acc.","Tratte accettate","Rapp. interb. dir.","Bonifici"} ; @@ -67,13 +67,16 @@ class TStampaScadenzario : public TPrintapp _ordcod, // VERO=ordine per codice, FALSO=ordine per ragione sociale _striepilogo, // VERO=stampa il riepilogo mensile per pagamento _stvaluta, // Vero se abilitata la stampa in valuta; - _group_ban; // Vero se abilitato il raggruppamento per banca + _group_ban, // Vero se abilitato il raggruppamento per banca + _totbank_printed; // vero se é stato stampato il totale per banca // Se _tipost=tutti non e' possibile impostare l'ordine primario per // ragione sociale o descrizione. L'unico tipo stampa possibile e' quello // in ordine di data scadenza // Se _tipost=altri scorre il piano dei conti. // Se _tipost=clienti || fornitori scorre clifo. - + TString16 _codag; // codice agente selezionato + int _tipopag; // tipo pagamento selezionato + TRecnotype _last_bank_rec; // ultimo record con banca stampato real _w_imp_pag, _w_imp_res; // Qui dentro memorizza i valori calcolati in calcola_pagamenti, // rispettivamente l'importo pagato e l'importo residuo, relativo alla rata. TAssoc_array _tm, _tp; // Dentro a codesti array vi sono i totali per la stampa prospetti: @@ -120,6 +123,9 @@ public: //ended indica il raggiungimento di fine periodo. // La seguente funzione serve per il riepilogo dei totali nel caso l'ordinamento principale non sia per data. void print_totali_c(int &nriga, bool ended); // ended indica di stampare anche il riepilogo del periodo + + void print_totali_bank(int &nriga); + // Funzioni per calcolo dei pagamenti e di aggiornamento totali void check_add_key_to_tp(int t, char u); // controlla e aggiunge i valori relativi alla chiave k ai totali del prospetto void check_add_key_to_tl(tipo_pe p, int t); // controlla e aggiunge i valori elaborati all'assoc array indicato dal periodo (_tlxxx) @@ -134,6 +140,8 @@ public: void calcola_pagamenti(real& imp_scad, int riga, int rata, TBill& bill); // calcola i pagamenti effettuati per questa rata e il residuo eventuale TLocalisamfile& pagamenti() const { return *_pagsca; } + + void print_intestazione_banca(int &nriga); TStampaScadenzario(); }; @@ -144,7 +152,7 @@ inline TStampaScadenzario& app() {return (TStampaScadenzario&)main_app();} class TScadenza_rec : public TRectype { - TString16 _codice; + TString _codice; protected: virtual const TString& get_str(const char* fieldname) const; @@ -155,7 +163,8 @@ public: const TString& TScadenza_rec::get_str(const char* fieldname) const { - if (strcmp(fieldname, SCAD_CODABIPR) == 0 || strcmp(fieldname, SCAD_CODCABPR) == 0) + if (strcmp(fieldname, SCAD_CODABIPR) == 0 || strcmp(fieldname, SCAD_CODCABPR) == 0 || + strcmp(fieldname, SCAD_CODAG) == 0) { TRectype rec(LF_PAGSCA); rec.put(PAGSCA_TIPOC, TRectype::get_str(SCAD_TIPOCF)); @@ -175,16 +184,18 @@ const TString& TScadenza_rec::get_str(const char* fieldname) const curpag = rec; const int err = pagamenti.read(_isgteq); found = (err == NOERR) && (curpag.compare_key(rec,1,1) == 0); - } + } - long cod = atol(TRectype::get_str(fieldname)); // Valore di default sulla scadenza + TString& cod = ((TScadenza_rec*)this)->_codice; // Fool the compiler + cod = TRectype::get_str(fieldname); // Valore di default sulla scadenza if (found) { - const long val = curpag.get_long(fieldname); - if (val > 0) + const TString& val = curpag.get(fieldname); + if (val.not_empty()) cod = val; // Valore presente sul pagamento effettivo - } - ((TScadenza_rec*)this)->_codice.format("%05ld", cod); + } + if (strcmp(fieldname, SCAD_CODABIPR) == 0 || strcmp(fieldname, SCAD_CODCABPR) == 0) + cod.format("%05ld", atol(_codice)); // riformatta codice banca return _codice; } return TRectype::get_str(fieldname); @@ -236,6 +247,20 @@ bool TStampaScadenzario::filter_func(const TRelation *r) } } } + if (app()._codag.not_empty()) + { + const TRectype& rec = r->curr(); + const TString16 codag = rec.get(SCAD_CODAG); + if (app()._codag != codag) + return FALSE; + } + if (app()._tipopag != 0) + { + const TRectype& rec = r->curr(); + const int tipopag = rec.get_int(SCAD_TIPOPAG); + if (app()._tipopag != tipopag) + return FALSE; + } return TRUE; } @@ -254,6 +279,9 @@ void TStampaScadenzario::check_add_key_to_tl(tipo_pe p, int t) case period: index = 2; break; + case bank: + index = 3; + break; default: // Se p == daily e' gia settato di default (vedi sopra) break; } @@ -650,11 +678,19 @@ bool TStampaScadenzario::preprocess_page(int file, int counter) TAssoc_array& tlm = (TAssoc_array&) _tl[1]; tlm.destroy(); } + if (_group_ban && _totbank_printed) + { + TAssoc_array& tlb = (TAssoc_array&) _tl[3]; + tlb.destroy(); + _totbank_printed = FALSE; + } } // Tiene aggiornati tutti i totali mese/giorno/periodo (Totali lineari per valuta) check_add_key_to_tl(daily, tipo_pag); check_add_key_to_tl(monthly, tipo_pag); check_add_key_to_tl(period, tipo_pag); + if (_group_ban) + check_add_key_to_tl(bank, tipo_pag); // totali per banca // Tiene aggiornati tutti i totali mese/periodo (Totali dei prospetti check_add_key_to_tp(tipo_pag, ult_cla); _cur_data = datascad; @@ -702,6 +738,14 @@ bool TStampaScadenzario::preprocess_page(int file, int counter) _cur_codcf_s = ""; changed = FALSE; } + + if (_group_ban && _totbank_printed) + { + TAssoc_array& tlb = (TAssoc_array&) _tl[3]; + tlb.destroy(); + _totbank_printed = FALSE; + } + if (changed) { _cur_gr_s.format("%3d",gruppo); @@ -714,7 +758,9 @@ bool TStampaScadenzario::preprocess_page(int file, int counter) // Tiene aggiornati i totali per cli/fo/conto e periodo (Totali lineari per valuta) check_add_key_to_tl(single, tipo_pag); check_add_key_to_tl(period, tipo_pag); - // Tiene aggiornati i totali per cli/fo/conto e periodo (Totali per i prospetti) + if (_group_ban) + check_add_key_to_tl(bank, tipo_pag); // totali per banca + // Tiene aggiornati i totali per cli/fo/conto e periodo (Totali per i prospetti) check_add_key_to_tp(tipo_pag, ult_cla); } // Qui stampa il totale generale e lo schema riepilogativo. @@ -729,7 +775,7 @@ bool TStampaScadenzario::preprocess_page(int file, int counter) // per tutti e' obbligatorio l'ordinamento principale per data. print_totali_c(n,TRUE); } - + return TRUE; } @@ -803,7 +849,7 @@ bool TStampaScadenzario::user_create() _ragsoc = new TParagraph_string("",17); _des_conto = new TParagraph_string("",17); - _tl.add(new TAssoc_array);_tl.add(new TAssoc_array);_tl.add(new TAssoc_array); + _tl.add(new TAssoc_array);_tl.add(new TAssoc_array);_tl.add(new TAssoc_array);_tl.add(new TAssoc_array); _uns_cache.add(new TAssoc_array); // Pagamenti _uns_cache.add(new TAssoc_array); // Note di credito _uns_cache.add(new TAssoc_array); // Insoluti @@ -855,10 +901,15 @@ bool TStampaScadenzario::user_destroy() bool TStampaScadenzario::set_print(int) { + _m->reset(F_SORTBAN); + _m->reset(F_CODAG); + _m->reset(F_TIPOPAG); const bool ok = _m->run() == K_ENTER; if (ok) - { + { + _last_bank_rec = 0; _end_printed = FALSE; + _totbank_printed = FALSE; reset_files(); reset_print(); // Inizializza i membri necessari al calcolo totali nel caso sia stato scelto l'ordine @@ -868,6 +919,8 @@ bool TStampaScadenzario::set_print(int) else _tipost = fornitori; _ordcod = _m->get_key() == 1; // Stampa ordinata per codice? _group_ban = _m->get_bool(F_SORTBAN); // Raggruppamento per banca di presentazione + _codag = _m->get(F_CODAG); // codice agente selezionato + _tipopag = _m->get_int(F_TIPOPAG); // tipo pagamento selezionato _cur_data = botime; _tm.destroy(); _tp.destroy(); // Totali per i prospetti for (int it=0; it < _tl.items(); it++) @@ -1080,9 +1133,15 @@ void TStampaScadenzario::print_header() s1 =""; s2 = ""; } set_header (soh++,"@64gPer il periodo dal %s al %s",(const char*)datai,(const char*)dataf); - - if (_group_ban) - set_header(soh++, "@bBANCA DI PRESENTAZIONE %s@r", (const char*)_desc_ban); + + if (_codag.not_empty()) + set_header (soh++,"@bAgente: %s %s@r",(const char*)_codag,(const char*)_m->get(F_CODAG_D)); + if (_tipopag != 0) + { + TList_field& fld_tipopag = (TList_field&) _m->field(F_TIPOPAG); + TToken_string& pagam = (TToken_string) fld_tipopag.get_values(); + set_header (soh++,"@bTipo pagamento: %d %s@r",_tipopag, (const char*)pagam.get(_tipopag)); + } rw.fill('_'); set_header(soh++, (const char *) rw); @@ -1101,6 +1160,16 @@ void TStampaScadenzario::print_header() firm, (const char *)s, (const char *)data); set_header(soh++,"@79g** SCADENZARIO **"); set_header (soh++,"@66gPer il periodo dal %s al %s",(const char*)datai,(const char*)dataf); + + if (_codag.not_empty()) + set_header (soh++,"@bAgente: %s %s@r",(const char*)_codag,(const char*)_m->get(F_CODAG_D)); + if (_tipopag != 0) + { + TList_field& fld_tipopag = (TList_field&) _m->field(F_TIPOPAG); + TToken_string& pagam = (TToken_string) fld_tipopag.get_values(); + set_header (soh++,"@bTipo pagamento: %d %s@r",_tipopag, (const char*)pagam.get(_tipopag)); + } + rw.fill('_'); set_header(soh++, (const char *) rw); set_header(soh++,"@33gRif.@43gData@53gData@82gCd/Tp"); @@ -1122,6 +1191,8 @@ void TStampaScadenzario::print_header() void TStampaScadenzario::set_page_clifo(int nriga) // Setta le righe per stampare le scadenze clienti/fornitori { + if (_group_ban) + print_intestazione_banca(nriga); set_row(nriga++,""); set_row(nriga,"@b#6t@r",&_cur_codcf_s); set_row(nriga,"@b@9g#a@r",_ragsoc); @@ -1148,6 +1219,8 @@ void TStampaScadenzario::set_page_clifo(int nriga) void TStampaScadenzario::set_page_pcon(int nriga) // Setta le righe per stampare le scadenze degli altri conti. { + if (_group_ban) + print_intestazione_banca(nriga); set_row(nriga++,""); set_row(nriga,"@b#3t@5g#3t@9g#6t@r",&_cur_gr_s,&_cur_co_s,&_cur_codcf_s); set_row(nriga,"@b@16g#a@r",_des_conto); @@ -1167,30 +1240,6 @@ void TStampaScadenzario::set_page_pcon(int nriga) void TStampaScadenzario::set_page(int file, int counter) { - // Prepara descrizione banca - if (file == LF_SCADENZE && _group_ban) - { - const TRectype &rc = current_cursor()->curr(LF_SCADENZE); - const TString8 abi = rc.get(SCAD_CODABIPR); - const TString8 cab = rc.get(SCAD_CODCABPR); - TString16 curr_ban; curr_ban << abi << cab; - if (curr_ban != _last_ban) - { - _last_ban = curr_ban; - if (abi != "00000") - { - _desc_ban.cut(0) << abi << ' ' << cab; - _desc_ban << ' ' << cache().get("%BAN", abi, "S0"); - if (cab > 0) - _desc_ban << " - " << cache().get("%BAN", _last_ban, "S0"); - } - else - _desc_ban = "NON INDICATA"; - if (printer().current_row() > 1) - printer().formfeed(); - } - } - print_header(); switch (_tipost) @@ -1202,7 +1251,7 @@ void TStampaScadenzario::set_page(int file, int counter) break; case altri: if (file == LF_PCON) - set_page_pcon(1); + set_page_pcon(1); break; default: break; @@ -1318,6 +1367,9 @@ void TStampaScadenzario::print_rows_totali(int &nriga, tipo_pe p) case period: index = 2; break; + case bank: + index = 3; + break; default: break; } @@ -1370,9 +1422,6 @@ void TStampaScadenzario::print_totali(int &nriga, bool month_changed, bool ended // Setta le righe per stampare i totali (giorno e mese) delle scadenze clienti/fornitori // Ordinamento primario per data! { - if (_group_ban) - return; - set_row(nriga,"@36g** TOTALI DEL @51g%s",_cur_data.string(brief)); print_rows_totali(nriga, daily); if (month_changed) @@ -1383,6 +1432,11 @@ void TStampaScadenzario::print_totali(int &nriga, bool month_changed, bool ended } if (ended) { + if (_group_ban) + { + print_totali_bank(nriga); + set_row(nriga++,""); + } set_row(nriga++,""); set_row(nriga,"@36g** TOTALI PERIODO"); print_rows_totali(nriga, period); @@ -1396,9 +1450,6 @@ void TStampaScadenzario::print_totali_c(int &nriga, bool ended) // Setta le righe per stampare i totali delle scadenze clienti/fornitori/conti // Ordinamento primario per codice o ragione sociale! { - if (_group_ban) - return; - if (_tipost==clienti) set_row(nriga,"@70g** TOTALE CLIENTE"); else @@ -1410,6 +1461,11 @@ void TStampaScadenzario::print_totali_c(int &nriga, bool ended) if (_striepilogo) print_riepilogo(nriga,FALSE); if (ended) { + if (_group_ban) + { + print_totali_bank(nriga); + set_row(nriga++,"");set_row(nriga++,""); + } set_row(nriga,"@70g** TOTALE GENERALE"); print_rows_totali(nriga, period); if (_striepilogo) print_riepilogo(nriga,TRUE); @@ -1418,6 +1474,59 @@ void TStampaScadenzario::print_totali_c(int &nriga, bool ended) } } +void TStampaScadenzario::print_totali_bank(int &nriga) +// Setta le righe per stampare i totali della banca +// Ordinamento primario per codice o ragione sociale! +{ + set_row(nriga++, ""); + if (_ordata) + set_row(nriga,"@36g** TOTALI BANCA"); + else + set_row(nriga,"@70g** TOTALE BANCA"); + print_rows_totali(nriga, bank); + _totbank_printed = TRUE; +} + +void TStampaScadenzario::print_intestazione_banca(int &nriga) +{ + const TRectype &rc = current_cursor()->curr(LF_SCADENZE); + const TString8 abi = rc.get(SCAD_CODABIPR); + const TString8 cab = rc.get(SCAD_CODCABPR); + TString16 curr_ban; curr_ban << abi << cab; + + bool print_bank = FALSE; + if (curr_ban != _last_ban) + { + _last_ban = curr_ban; + if (abi != "00000") + { + _desc_ban.cut(0) << abi << ' ' << cab; + _desc_ban << ' ' << cache().get("%BAN", abi, "S0"); + if (cab > 0) + _desc_ban << " - " << cache().get("%BAN", _last_ban, "S0"); + } + else + _desc_ban = "NON INDICATA"; + _last_bank_rec = current_cursor()->pos(); + print_bank = TRUE; + } + else + { + print_bank = current_cursor()->pos() == _last_bank_rec; + } + + if (print_bank) + { + // stampa totali banca precedente + if (_last_bank_rec != 0) + print_totali_bank(nriga); + + set_row(nriga++, ""); + set_row(nriga++, "@bBANCA DI PRESENTAZIONE %s@r", (const char*)_desc_ban); + set_row(nriga++, ""); + } +} + TStampaScadenzario::TStampaScadenzario() { _rel1=_rel2=_rel3=NULL; diff --git a/sc/sc2200.h b/sc/sc2200.h index 89522304e..d5c93e2d1 100755 --- a/sc/sc2200.h +++ b/sc/sc2200.h @@ -16,3 +16,6 @@ #define F_TOABI 114 #define F_TOCAB 115 #define F_TOBAN 116 +#define F_CODAG 117 +#define F_CODAG_D 118 +#define F_TIPOPAG 119 diff --git a/sc/sc2200a.uml b/sc/sc2200a.uml index aefbfc2f8..575284ab6 100755 --- a/sc/sc2200a.uml +++ b/sc/sc2200a.uml @@ -209,8 +209,8 @@ END BOOLEAN F_SORTBAN BEGIN PROMPT 2 16 "Raggruppamento per banca di presentazione" - MESSAGE FALSE HIDE,7@ - MESSAGE TRUE SHOW,7@ + MESSAGE FALSE HIDE,7@|RESET,7@ + MESSAGE TRUE SHOW,7@|RESET,7@ END NUMBER F_FROMABI 5 @@ -289,5 +289,47 @@ BEGIN GROUP 7 END +STRING F_CODAG 5 +BEGIN + PROMPT 2 19 "Agente " + FLAGS "ZU" + USE LF_AGENTI + INPUT CODAGE F_CODAG + DISPLAY "Codice agente" CODAGE + DISPLAY "Ragione Sociale@50" RAGSOC + OUTPUT F_CODAG CODAGE + OUTPUT F_CODAG_D RAGSOC + CHECKTYPE NORMAL +END + +STRING F_CODAG_D 50 +BEGIN + PROMPT 18 19 "" + USE LF_AGENTI KEY 2 + INPUT RAGSOC F_CODAG_D + DISPLAY "Ragione Sociale@50" RAGSOC + DISPLAY "Codice agente" CODAGE + COPY OUTPUT F_CODAG + CHECKTYPE NORMAL +END + +LIST F_TIPOPAG 1 33 +BEGIN + PROMPT 2 20 "Tipo pagamento " + ITEM "0|Tutti" + ITEM "1|Rimessa Diretta" + ITEM "2|Tratta" + ITEM "3|Ricevuta Bancaria" + ITEM "4|Cessione" + ITEM "5|Paghero'" + ITEM "6|Lettera di credito" + ITEM "7|Tratta accettata" + ITEM "8|Rapporti interbancari diretti" + ITEM "9|Bonifico" +END + + + + ENDPAGE ENDMASK diff --git a/sc/sc2400.cpp b/sc/sc2400.cpp index 288e2f2fc..cb54d0074 100755 --- a/sc/sc2400.cpp +++ b/sc/sc2400.cpp @@ -117,16 +117,15 @@ int TStampaSol_application::print_sol() const TDate data_limite_soll(f.data_limite_operazione()); const TDate data_limite_scad(f.data_limite_scaduto()); - if (sel_tot_saldo) + if (sel_tot_saldo && sel_importo > ZERO) { real saldo; - for (int err = partite.read(_isgteq); err == NOERR && partite.curr() == filter; err = partite.read(_isgreat)) { TPartita game(partite.curr()); - saldo += game.calcola_scaduto_al(FALSE, data_limite_scad); + saldo += game.calcola_scaduto_al(FALSE, data_limite_soll); // Era data_limite_scad! partite.put(PART_NRIGA, 9999); } if (saldo < sel_importo) diff --git a/sc/sc2500.cpp b/sc/sc2500.cpp index b41d85776..585de992f 100755 --- a/sc/sc2500.cpp +++ b/sc/sc2500.cpp @@ -14,9 +14,10 @@ #include "sc2500.h" #include -#include +#include #include #include +#include /////////////////////////////////////////////////////////// // Maschera principale @@ -201,7 +202,22 @@ void TConfronta_mask::fill_browse() TBrowsefile_field& b = (TBrowsefile_field&)field(F_PREVIEW); TViswin& w = b.vis_win(); w.destroy_lines(); - b.add_line("@b STAMPA CONTROLLO SALDI"); +//crea la nuova intestazione + TString intestazione; + TString ragsoc(50); + TLocalisamfile nditte(LF_NDITTE); + nditte.zero(); + nditte.put(NDT_CODDITTA, main_app().get_firm()); + if (nditte.read() == NOERR) + ragsoc = nditte.get(NDT_RAGSOC); + intestazione << "@bDitta " << main_app().get_firm(); + intestazione << " " << ragsoc; + intestazione.rpad(97); + TDate oggi(TODAY); + intestazione << oggi; + + b.add_line(intestazione); + b.add_line("@bSTAMPA CONTROLLO SALDI"); b.add_line("@b_________________________________________________________________________________________________________"); b.add_line(""); b.add_line("@bGrp Cnt Sottoc Descrizione Saldo Contabile Saldo Partite Sbilancio"); @@ -321,12 +337,18 @@ bool TConfronta_mask::on_field_event(TOperable_field& f, TField_event e, long jo { case DLG_ELABORA: if (e == fe_button) - { - disable(-4); + { + // disabilito campi di selezione e bottone elabora + disable(-4); + field(DLG_PRINT).set_focus(); + // sostituisco elabora con annulla hide(DLG_ELABORA); show(F_CANCEL); - fill_browse(); + // elaborazione + fill_browse(); + // sostituisco annulla con elabora hide(F_CANCEL); show(DLG_ELABORA); - enable(-4); + // abilito bottone stampa + enable(-6); } break; case F_CANCEL: @@ -342,6 +364,20 @@ bool TConfronta_mask::on_field_event(TOperable_field& f, TField_event e, long jo f.print(); } break; + case F_AZZERA: + if (e == fe_button) + { + // azzero il campo risultato della stampa + TBrowsefile_field& b = (TBrowsefile_field&)field(F_PREVIEW); + TViswin& w = b.vis_win(); + w.destroy_lines(); + w.goto_top(); + // disabilito bottone stampa + disable(-6); + // abilito campi di selezione e bottone elabora + enable(-4); + } + break; default: break; } @@ -370,9 +406,10 @@ void TConfronta_saldi::main_loop() while (m.run() != K_QUIT); } -int sc2500(int argc, char** argv) +int sc2500(int argc, char** argv) + { TConfronta_saldi app; - app.run(argc, argv, "Controllo saldi"); + app.run(argc, argv, "Stampa controllo saldi"); return 0; } \ No newline at end of file diff --git a/sc/sc2500.uml b/sc/sc2500.uml index 0988564d8..7be252559 100755 --- a/sc/sc2500.uml +++ b/sc/sc2500.uml @@ -6,7 +6,7 @@ BUTTON DLG_ELABORA 10 2 BEGIN PROMPT -13 -11 "~Elabora" PICTURE BMP_ELABORA - GROUP 4 + GROUP 4 END BUTTON F_CANCEL 10 2 @@ -21,18 +21,17 @@ BUTTON DLG_PRINT 10 2 BEGIN PROMPT -23 -11 "" FLAGS "D" - GROUP 4 + GROUP 6 END BUTTON DLG_QUIT 10 2 BEGIN PROMPT -33 -11 "" - GROUP 4 END ENDPAGE -PAGE "Confronto saldi" -1 -1 78 20 +PAGE "Controllo saldi" -1 -1 78 20 GROUPBOX DLG_NULL 78 4 BEGIN @@ -42,36 +41,45 @@ END LIST F_TIPOC 1 10 BEGIN PROMPT 2 1 "Tipo conto " + ITEM " |Conto" + MESSAGE SHOW,1@|HIDE,2@|HIDE,3@|COPY,F_ATIPOC ITEM "C|Cliente" MESSAGE SHOW,2@|HIDE,1@|HIDE,3@|COPY,F_ATIPOC ITEM "F|Fornitore" MESSAGE SHOW,3@|HIDE,1@|HIDE,2@|COPY,F_ATIPOC - ITEM " |Conto" - MESSAGE SHOW,1@|HIDE,2@|HIDE,3@|COPY,F_ATIPOC - GROUP 4 + GROUP 4 5 END NUMBER F_GRUPPO 3 BEGIN PROMPT 30 1 "Gruppo " - USE LF_PCON SELECT (CONTO!="")&&(SOTTOCONTO=="") + USE LF_PCON SELECT (CONTO=="")&&(SOTTOCONTO=="") INPUT GRUPPO F_GRUPPO - INPUT CONTO F_CONTO + //INPUT CONTO F_CONTO DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Tipo" TMCF + //DISPLAY "Conto" CONTO + //DISPLAY "Tipo" TMCF DISPLAY "Descrizione@50" DESCR OUTPUT F_GRUPPO GRUPPO - OUTPUT F_CONTO CONTO - OUTPUT F_TIPOC TMCF + //OUTPUT F_CONTO CONTO + //OUTPUT F_TIPOC TMCF CHECKTYPE SEARCH - GROUP 4 5 + GROUP 4 5 END NUMBER F_CONTO 3 BEGIN PROMPT 46 1 "Conto " - COPY ALL F_GRUPPO + USE LF_PCON SELECT (CONTO!="")&&(SOTTOCONTO=="") + INPUT GRUPPO F_GRUPPO + INPUT CONTO F_CONTO + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Tipo" TMCF + DISPLAY "Descrizione@50" DESCR + OUTPUT F_GRUPPO GRUPPO + OUTPUT F_CONTO CONTO + OUTPUT F_TIPOC TMCF CHECKTYPE SEARCH GROUP 4 5 END @@ -86,7 +94,8 @@ BEGIN DISPLAY "Conto" CONTO DISPLAY "Sottoconto" SOTTOCONTO DISPLAY "Descrizione@50" DESCR - COPY OUTPUT F_CONTO + OUTPUT F_GRUPPO GRUPPO + OUTPUT F_CONTO CONTO OUTPUT F_SOTTOCONTO SOTTOCONTO OUTPUT F_CON_DESCR DESCR CHECKTYPE SEARCH @@ -128,7 +137,7 @@ BEGIN USE LF_CLIFO KEY 2 INPUT TIPOCF "C" INPUT RAGSOC F_CLI_DESCR - DISPLAY "Ragione Sociale@50" RAGSOC + DISPLAY "Ragione Sociale@60" RAGSOC DISPLAY "Codice" CODCF COPY OUTPUT F_CLIENTE CHECKTYPE SEARCH @@ -181,10 +190,10 @@ BEGIN PROMPT 30 5 "Gruppo " COPY USE F_GRUPPO INPUT GRUPPO F_AGRUPPO - INPUT CONTO F_ACONTO + //INPUT CONTO F_ACONTO COPY DISPLAY F_GRUPPO OUTPUT F_AGRUPPO GRUPPO - OUTPUT F_ACONTO CONTO + //OUTPUT F_ACONTO CONTO CHECKTYPE SEARCH GROUP 1 4 5 END @@ -192,7 +201,12 @@ END NUMBER F_ACONTO 3 BEGIN PROMPT 46 5 "Conto " - COPY ALL F_AGRUPPO + COPY USE F_CONTO + INPUT GRUPPO F_AGRUPPO + INPUT CONTO F_ACONTO + COPY DISPLAY F_CONTO + OUTPUT F_AGRUPPO GRUPPO + OUTPUT F_ACONTO CONTO CHECKTYPE SEARCH GROUP 1 4 5 END @@ -201,9 +215,11 @@ NUMBER F_ASOTTOCONTO 6 BEGIN PROMPT 2 6 "Sottoconto " COPY USE F_SOTTOCONTO + COPY INPUT F_ACONTO INPUT SOTTOCONTO F_ASOTTOCONTO COPY DISPLAY F_SOTTOCONTO - COPY OUTPUT F_ACONTO + OUTPUT F_AGRUPPO GRUPPO + OUTPUT F_ACONTO CONTO OUTPUT F_ASOTTOCONTO SOTTOCONTO OUTPUT F_ACON_DESCR DESCR CHECKTYPE SEARCH @@ -282,12 +298,13 @@ END BUTTON F_AZZERA 17 1 BEGIN PROMPT 60 8 "~Azzera selezioni" - MESSAGE RESET,5@ + MESSAGE RESET,5@ END BROWSEFILE F_PREVIEW 0 -1 BEGIN - PROMPT 0 9 "" + PROMPT 0 9 "" + GROUP 5 END ENDPAGE diff --git a/sc/sc3100s.uml b/sc/sc3100s.uml index ec4ea9478..203287955 100755 --- a/sc/sc3100s.uml +++ b/sc/sc3100s.uml @@ -168,6 +168,7 @@ BEGIN ITEM "NUMERO|Numero" ITEM "DATA|Data" ITEM "LISTA|Lista" + ITEM "VALUTA|Valuta" ITEM "GRUPPO|Gruppo" ITEM "LINEA|Linea" ITEM "BOX|Box" diff --git a/sc/scprassi.men b/sc/scprassi.men index 2b3529999..b0c87b806 100755 --- a/sc/scprassi.men +++ b/sc/scprassi.men @@ -15,6 +15,6 @@ Caption = "Servizio" Picture = Module = 13 Flags = "" -Item_01 = "Stampa di controllo saldi", "sc2 -4", "" +Item_01 = "Stampa controllo saldi", "sc2 -4", "" Item_02 = "Creazione saldaconto da saldi", "sc1 -1", "" diff --git a/sv/sv1100.cpp b/sv/sv1100.cpp index a4bbde32e..ba8354a23 100755 --- a/sv/sv1100.cpp +++ b/sv/sv1100.cpp @@ -650,8 +650,8 @@ bool TStampa_schede::fill_rdoc(TRectype& tab, const TRiga_documento& rdoc, const tab.put("S1", descr); const bool is_nota_credito = doc.tipo().nota_credito(); - real ins = rdoc.importo(TRUE, FALSE, 0); - real ils = rdoc.importo(TRUE, TRUE, 0); + real ins = rdoc.importo(TRUE, FALSE); + real ils = rdoc.importo(TRUE, TRUE); if (is_nota_credito) { diff --git a/sv/sv1200.cpp b/sv/sv1200.cpp index 81733a0b2..72da968b7 100755 --- a/sv/sv1200.cpp +++ b/sv/sv1200.cpp @@ -1286,7 +1286,8 @@ int TStampa_stat::handle_levchange(int row, const int level) set_filled_row('R',++row,'_',POS_PRIMACOL,_largcol * _numcol ); partkey_name(rec_grp1.get(SVS_LEVCODE), numlevels() - _last_lev_grp - 1, _wrk_row); - _wrk_row.insert("@Totale ", 0); + _wrk_row.insert("@bTotale ", 0); + _wrk_row << ' ' << rec_grp1.get(SVS_CODICE).mid(lencode); _wrk_row << ' ' << rec_grp1.get(SVS_DESCR).left(23); //_wrk_row.cut(LARG_COLCODICE); there are also @ chars! @@ -1955,7 +1956,7 @@ void TStampa_stat::genera_file(const char *outfn) const int yearfin = datafin.year(); const int periofin = _stats.date2period(datafin); - TProgind statusbar(date2long(datafin,_stats.frequency())-start_status, + TProgind statusbar(period2long(datafin.year(), periofin,_stats.frequency())-start_status, "Creazione del file di output", FALSE, TRUE, 60); int err = riep.read(_isgteq); @@ -2019,7 +2020,7 @@ void TStampa_stat::genera_file(const char *outfn) } } // filtro } // ciclo - statusbar.setstatus(date2long(m.get_date(F_DATAFIN),_stats.frequency())-start_status); + statusbar.setstatus(period2long(datafin.year(), periofin, _stats.frequency())-start_status); _svcache->flush(); delete _svcache; } @@ -2739,4 +2740,4 @@ int sv1200(int argc, char* argv[]) TStampa_stat mainapp; mainapp.run(argc, argv, "Stampa statistiche"); return 0; -} +} \ No newline at end of file diff --git a/sv/svlib01.cpp b/sv/svlib01.cpp index de2f50dbf..f1b49063c 100755 --- a/sv/svlib01.cpp +++ b/sv/svlib01.cpp @@ -227,9 +227,6 @@ const TDate & period2date(const int anno, int periodo, TFrequenza_statistiche f) } return d; } - - - const TDate& floor(TDate& data, TFrequenza_statistiche freq) { @@ -237,11 +234,14 @@ const TDate& floor(TDate& data, TFrequenza_statistiche freq) { case fs_settimanale: { +/* const TDate primo(1, 1, data.year()); int settimana = int((data - primo) / 7); if (settimana > 51) settimana = 51; data = primo; data += settimana * 7; +*/ + data -= data.wday()-1; } break; case fs_quindicinale: @@ -281,10 +281,10 @@ const TDate& ceil(TDate& data, TFrequenza_statistiche freq) switch (freq) { case fs_settimanale: - data += 6; - if (data.month() == 12 && data.day() >= 29) - data.set_end_month(); - break; + data += 6; + if (data.month() == 12 && data.day() >= 29) + data.set_end_month(); + break; case fs_quindicinale: if (data.day() == 1) data.set_day(15); diff --git a/ve/batbprs.h b/ve/batbprs.h index 870c3d871..dc2d889b1 100755 --- a/ve/batbprs.h +++ b/ve/batbprs.h @@ -19,3 +19,7 @@ #define F_DESCRCONTOA 119 #define F_CAMPI 120 #define F_QTA 121 +#define F_GRUPPOPCI 122 +#define F_CONTOPCI 123 +#define F_SOTTOPCI 124 +#define F_DESCRCONTOPCI 125 diff --git a/ve/batbprs.uml b/ve/batbprs.uml index 9e440d658..a238a72d8 100755 --- a/ve/batbprs.uml +++ b/ve/batbprs.uml @@ -288,4 +288,65 @@ BEGIN ADD RUN CG0 -0 END +NUMBER F_GRUPPOPCI 3 +BEGIN + PROMPT 2 18 "Conto industr. " + FIELD I6 + CHECKTYPE NORMAL + END + +NUMBER F_CONTOPCI 3 +BEGIN + PROMPT 22 18 "" + FIELD I7 + USE PCI SELECT (CODTAB[4,6]!="") && (CODTAB[7,12]=="") + INPUT CODTAB[1,3] F_GRUPPOPCI + INPUT CODTAB[4,6] F_CONTOPCI + DISPLAY "Gruppo" CODTAB[1,3] + DISPLAY "Conto" CODTAB[4,6] + DISPLAY "Descrizione@50" S0 + OUTPUT F_GRUPPOPCI CODTAB[1,3] + OUTPUT F_CONTOPCI CODTAB[4,6] + CHECKTYPE NORMAL + ADD RUN BA3 -0 PCI + WARNING "Codice piano dei conti industriale assente" + END + +NUMBER F_SOTTOPCI 6 +BEGIN + PROMPT 30 18 "" + FIELD I8 + USE PCI SELECT CODTAB[7,12]!="" + INPUT CODTAB[1,3] F_GRUPPOPCI + INPUT CODTAB[4,6] F_CONTOPCI + INPUT CODTAB[7,12] F_SOTTOPCI + DISPLAY "Gruppo" CODTAB[1,3] + DISPLAY "Conto" CODTAB[4,6] + DISPLAY "Sottoconto" CODTAB[7,12] + DISPLAY "Descrizione@50" S0 + OUTPUT F_GRUPPOPCI CODTAB[1,3] + OUTPUT F_CONTOPCI CODTAB[4,6] + OUTPUT F_SOTTOPCI CODTAB[7,12] + OUTPUT F_DESCRCONTOPCI S0 + CHECKTYPE NORMAL + WARNING "Sottoconto errato" + ADD RUN BA3 -0 PCI +END + +STRING F_DESCRCONTOPCI 50 +BEGIN + PROMPT 17 19 "" + FLAG "U" + USE PCI KEY 2 SELECT (CODTAB[7,12]!="") + INPUT S0 F_DESCRCONTOPCI + DISPLAY "Descrizione@50" S0 + DISPLAY "Gruppo" CODTAB[1,3] + DISPLAY "Conto" CODTAB[4,6] + DISPLAY "Sottoconto" CODTAB[7,12] + COPY OUTPUT F_SOTTOPCI + CHECKTYPE NORMAL + WARNING "Codice piano conti industriale assente" + ADD RUN BA0 -3 PCI +END + ENDMASK diff --git a/ve/batbspp.uml b/ve/batbspp.uml index d55129ad2..d344ecf65 100755 --- a/ve/batbspp.uml +++ b/ve/batbspp.uml @@ -325,7 +325,8 @@ BEGIN FIELD S9 ITEM " |Spesa normale" ITEM "F|Ritenuta fiscale" - ITEM "S|Ritennuta Sociale" + ITEM "S|Ritenuta Sociale" END -ENDMASK + +ENDMASK \ No newline at end of file diff --git a/ve/batbtri.h b/ve/batbtri.h index ae453ccf0..7226b09cc 100755 --- a/ve/batbtri.h +++ b/ve/batbtri.h @@ -2,3 +2,6 @@ #define F_DESCR 102 #define F_TPR 103 #define F_FORMFEED 104 +#define F_IND 105 +#define F_DESIND 106 +#define F_PERIND 107 diff --git a/ve/batbtri.uml b/ve/batbtri.uml index 370dd1b4e..81cd06da0 100755 --- a/ve/batbtri.uml +++ b/ve/batbtri.uml @@ -14,7 +14,7 @@ PAGE "Tipo di riga" -1 -1 60 14 STRING F_CODICE 4 BEGIN - PROMPT 2 2 "Codice " + PROMPT 2 2 "Codice " FIELD CODTAB FLAGS "U" USE %TRI @@ -29,7 +29,7 @@ PAGE "Tipo di riga" -1 -1 60 14 STRING F_DESCR 50 BEGIN - PROMPT 2 4 "Descrizione " + PROMPT 2 4 "Descrizione " FIELD S0 USE %TRI KEY 2 INPUT S0 F_DESCR @@ -41,7 +41,7 @@ PAGE "Tipo di riga" -1 -1 60 14 LIST F_TPR 16 BEGIN - PROMPT 2 8 "Tipo " + PROMPT 2 8 "Tipo " ITEMS "M|erce" ITEMS "S|pese" ITEMS "P|

restazioni" @@ -53,9 +53,36 @@ PAGE "Tipo di riga" -1 -1 60 14 BOOLEAN F_FORMFEED BEGIN - PROMPT 2 10 "Salto pagina dopo questo tipo" - FIELD B0 + PROMPT 2 10 "Salto pagina dopo questo tipo" + FIELD B0 END +NUMBER F_IND 1 +BEGIN + PROMPT 2 12 "Detraibilita' " + SHEET "Codice|Tipo detraibilita'@75" + INPUT F_IND + ITEM " |Regime normale" + ITEM "1|IVA indetraibile su acquisti riferiti a ricavi esenti" + ITEM "3|IVA indicata per passaggi interni al solo fine del calcolo di ventilazione" + ITEM "9|IVA non detraibile per l'articolo 19" + OUTPUT F_IND + OUTPUT F_DESIND + FIELD I0 END + +STRING F_DESIND 75 50 +BEGIN + PROMPT 20 12 "" + FLAGS "D" +END + +NUMBER F_PERIND 6 2 +BEGIN + PROMPT 2 14 "% Indetraib. " + FIELD R0 +END + +END + ENDMASK diff --git a/ve/ve0100a.uml b/ve/ve0100a.uml index b1cde3d3a..ffb363612 100755 --- a/ve/ve0100a.uml +++ b/ve/ve0100a.uml @@ -70,8 +70,10 @@ PAGE "Estremi del documento" 1 1 60 14 PROMPT 2 3 "Esercizio " FIELD ANNO CHECKTYPE REQUIRED + NUM_EXPR #F_ANNO>0 FLAG "AP" KEY 1 2 + WARNING "Inserire un anno valido" END NUMBER F_NDOC 6 diff --git a/ve/ve0100b.cpp b/ve/ve0100b.cpp index 56821800e..cf1c9056d 100755 --- a/ve/ve0100b.cpp +++ b/ve/ve0100b.cpp @@ -1,6 +1,6 @@ -#include #include #include + #include #include @@ -57,4 +57,4 @@ int numerazione_definitiva(TDocumento& doc) doc.remove(); } return err; -} +} \ No newline at end of file diff --git a/ve/ve0200c.uml b/ve/ve0200c.uml index 4a4560d76..f92b5d74d 100755 --- a/ve/ve0200c.uml +++ b/ve/ve0200c.uml @@ -1,15 +1,15 @@ #include "veconf.h" -TOOLBAR "" 0 20 0 2 +TOOLBAR "" 0 -3 0 3 BUTTON DLG_OK 10 2 BEGIN -PROMPT -12 -1 "" +PROMPT -12 -11 "" END BUTTON DLG_QUIT 10 2 BEGIN -PROMPT -22 -1 "" +PROMPT -22 -11 "" END ENDPAGE @@ -18,10 +18,10 @@ PAGE "Sconti" 1 1 60 14 GROUPBOX DLG_NULL 78 4 BEGIN -PROMPT 1 1 "Gestione sconto a percentuale" +PROMPT 1 1 "@bGestione sconto a percentuale" END -STRING F_SCOPRCODCON1 3 +NUMBER F_SCOPRCODCON1 3 BEGIN PROMPT 2 2 "Codice contabilita' " FIELD SCOPRCODCON[1] @@ -40,7 +40,7 @@ OUTPUT F_SCOPRDESCON DESCR CHECKTYPE NORMAL END -STRING F_SCOPRCODCON2 3 +NUMBER F_SCOPRCODCON2 3 BEGIN PROMPT 30 2 "" FIELD SCOPRCODCON[2] @@ -48,7 +48,7 @@ COPY ALL F_SCOPRCODCON1 CHECKTYPE NORMAL END -STRING F_SCOPRCODCON3 6 +NUMBER F_SCOPRCODCON3 6 BEGIN PROMPT 36 2 "" FIELD SCOPRCODCON[3] @@ -71,10 +71,10 @@ END GROUPBOX DLG_NULL 78 4 BEGIN -PROMPT 1 6 "Gestione sconto ad importo " +PROMPT 1 6 "@bGestione sconto ad importo " END -STRING F_SCOIMCODCON1 3 +NUMBER F_SCOIMCODCON1 3 BEGIN PROMPT 2 7 "Codice contabilita' " FIELD SCOIMCODCON[1] @@ -87,13 +87,13 @@ DISPLAY "Conto" CONTO DISPLAY "Sottoconto" SOTTOCONTO DISPLAY "Descrizione@50" DESCR OUTPUT F_SCOIMCODCON1 GRUPPO -OUTPUT F_SCOIMCODCON2 CONTO +OUTPUT F_SCOIMCODCON2 CONTO OUTPUT F_SCOIMCODCON3 SOTTOCONTO -OUTPUT F_SCOIMDESCON DESCR +OUTPUT F_SCOIMDESCON DESCR CHECKTYPE NORMAL END -STRING F_SCOIMCODCON2 3 +NUMBER F_SCOIMCODCON2 3 BEGIN PROMPT 30 7 "" FIELD SCOIMCODCON[2] @@ -101,7 +101,7 @@ COPY ALL F_SCOIMCODCON1 CHECKTYPE NORMAL END -STRING F_SCOIMCODCON3 6 +NUMBER F_SCOIMCODCON3 6 BEGIN PROMPT 36 7 "" FIELD SCOIMCODCON[3] @@ -116,7 +116,7 @@ USE LF_PCON KEY 2 INPUT DESCR F_SCOIMDESCON DISPLAY "Descrizione@50" DESCR DISPLAY "Gruppo" GRUPPO -DISPLAY "Conto" CONTO +DISPLAY "Conto" CONTO DISPLAY "Sottoconto" SOTTOCONTO COPY OUTPUT F_SCOIMCODCON1 CHECKTYPE NORMAL diff --git a/ve/ve2400.cpp b/ve/ve2400.cpp index f3c7844fa..b182ca097 100755 --- a/ve/ve2400.cpp +++ b/ve/ve2400.cpp @@ -84,8 +84,10 @@ protected: virtual bool user_destroy(); virtual TMask *get_mask(int) { return _msk; } virtual bool changing_mask(int) { return FALSE; } - virtual TRelation *get_relation() const { return _rel; } - virtual void init_insert_mode(TMask &); + virtual void init_query_mode(TMask&); + virtual void init_insert_mode(TMask&); + virtual void init_modify_mode(TMask&); + virtual void on_firm_change(); bool search_on_file(const char * key, int file, int nkey, const char * field); virtual bool protected_record(TRectype&); @@ -99,7 +101,10 @@ protected: virtual void ini2sheet(TConfig& ini, TSheet_field &sheet); virtual void sheet2ini(TSheet_field &sheet,TConfig& ini); + static bool handle_copia(TMask_field &, KEY); // handler della copia articolo + public: + virtual TRelation *get_relation() const { return _rel; } // @cmember Disabilita la verifica del modulo : essendo una anagrafica, va sempre abilitata virtual bool check_autorization() const {return FALSE;} TAnagrafica_magazzino() { _rel = NULL; _msk = NULL;} @@ -234,6 +239,7 @@ void TMask_anamag::set_parametered_fields() TMask_anamag::TMask_anamag(TRelation * rel) : TMask("ve2400") { _rel=rel; + // sheet unità di misura set_handler(F_SHEETUM, handle_sheet_um); TSheet_field &f= sfield(F_SHEETUM); @@ -264,7 +270,6 @@ TMask_anamag::TMask_anamag(TRelation * rel) : TMask("ve2400") for (int i = 1; i <= 10; i++) { - if (c.get_bool("CHK_USER", "ve", i)) { TEditable_field * f = NULL; @@ -429,11 +434,9 @@ bool TMask_anamag::handle_livart(TMask_field &fld, KEY k) bool TMask_anamag::handle_anno(TMask_field &fld, KEY k) { - TMask_anamag &mask=(TMask_anamag &)fld.mask(); - - if (k == K_TAB) { + TMask_anamag &mask=(TMask_anamag &)fld.mask(); TSheet_field& fld_giac = mask.sfield(F_SHEETGIAC); if (mask.get(F_ANNO).empty() ) @@ -1360,7 +1363,7 @@ int TAnagrafica_magazzino::read(TMask& m) if (err == NOERR) { // LETTURA SHEET STORICO MAGAZZINO IN AUTOMATICO - TSheet_field &fld_stomag= (TSheet_field &)m.field(F_SHEETSTOMAG); + TSheet_field &fld_stomag= m.sfield(F_SHEETSTOMAG); fld_stomag.sheet_mask().field(F_STOCODART).set(m.field(F_CODART).get()); // necessario se lo sheet è vuoto // ***************************** @@ -1375,7 +1378,7 @@ void TAnagrafica_magazzino::load_um(TMask& m) { // ***************************** // LETTURA SHEET UNITA' DI MISURA - TSheet_field &fld_um= (TSheet_field &)m.field(F_SHEETUM); // prende lo sheet delle unità di misura + TSheet_field &fld_um= m.sfield(F_SHEETUM); // prende lo sheet delle unità di misura get_relation()->lfile().put(ANAMAG_CODART,m.get(F_CODART)); fld_um.record()->read(*fld_um.putkey(*get_relation())); fld_um.autoload(*get_relation()); @@ -1427,13 +1430,51 @@ int TAnagrafica_magazzino::rewrite(const TMask& m) int err =TRelation_application::rewrite(m); if (err==NOERR) { - TSheet_field &f= (TSheet_field &)m.field(F_SHEETUM); // prende lo sheet delle unità di misura + TSheet_field& f= m.sfield(F_SHEETUM); // prende lo sheet delle unità di misura err|=f.record()->write(TRUE); } ((TMask_anamag &)m).ricalcola_giacenze(); return err; } +static bool non_esiste_handler(TMask_field& f, KEY k) +{ + if (f.to_check(k)) + { + TLocalisamfile anamag(LF_ANAMAG); + anamag.put("CODART", f.mask().get(F_CODART)); + if (anamag.read() == NOERR) + return error_box("Il codice articolo selezionato esiste già"); + } + return TRUE; +} + +bool TAnagrafica_magazzino::handle_copia(TMask_field &fld, KEY k) +{ + if (k == K_SPACE) + { + TMask ask("ve2400k"); + ask.set_handler(F_CODART, non_esiste_handler); + if (ask.run() == K_ENTER) + { + TMask& m = fld.mask(); + m.set(F_CODART, ask.get(F_CODART), TRUE); + + m.sfield(F_SHEETGIAC).destroy(); + m.sfield(F_SHEETSTOMAG).destroy(); + + m.set_mode(MODE_INS); + xvt_statbar_set("Inserimento", TRUE); + } + } + return TRUE; +} + +void TAnagrafica_magazzino::init_query_mode(TMask &m) +{ + m.hide(F_COPY); +} + void TAnagrafica_magazzino::init_insert_mode(TMask &m) { load_um(m); @@ -1442,6 +1483,12 @@ void TAnagrafica_magazzino::init_insert_mode(TMask &m) f.row(0) = " |1"; // aggiunge una riga allo sheet } +void TAnagrafica_magazzino::init_modify_mode(TMask &m) +{ + m.set_handler(F_COPY, handle_copia); + m.show(F_COPY); +} + void TAnagrafica_magazzino::ini2sheet(TConfig& ini, TSheet_field &sheet) { switch(sheet.dlg()) diff --git a/ve/ve2400.h b/ve/ve2400.h index 9bb61baf2..e51b5e9c0 100755 --- a/ve/ve2400.h +++ b/ve/ve2400.h @@ -1,5 +1,6 @@ #define F_CODART 101 #define F_DESCR 102 +#define F_COPY 119 #define F_GRMERC 103 #define F_GRMERCD1 106 @@ -25,6 +26,10 @@ #define F_CONTOV 136 #define F_SOTTOCV 137 #define F_DESCRV 138 +#define F_GRUPPOPCI 110 +#define F_CONTOPCI 111 +#define F_SOTTOPCI 112 +#define F_DESCRCONTOPCI 113 #define F_UMP 139 #define F_PESO 140 #define F_CLASSDOG1 141 @@ -196,4 +201,4 @@ #define SIMBOLO_TOTALI '>' #define F_TOT_ORD_FOR 350 -#define F_TOT_ORD_CLI 351 \ No newline at end of file +#define F_TOT_ORD_CLI 351 diff --git a/ve/ve2400.uml b/ve/ve2400.uml index 6018fd192..fea869927 100755 --- a/ve/ve2400.uml +++ b/ve/ve2400.uml @@ -17,7 +17,7 @@ BEGIN PROMPT 2 1 "Codice art. " FIELD LF_ANAMAG->CODART KEY 1 - FLAG "U" + FLAG "UG" USE LF_ANAMAG INPUT CODART F_CODART DISPLAY "Codice@20" CODART @@ -130,6 +130,12 @@ BEGIN MESSAGE COPY,G_DESART@ END +BUTTON F_COPY 7 2 +BEGIN + PROMPT 68 1 "Copia" + FLAGS "H" +END + ZOOM F_DESCRAGG 50 BEGIN PROMPT 2 4 "Descrizione aggiuntiva " @@ -473,6 +479,67 @@ BEGIN WARNING "Conto assente" END +NUMBER F_GRUPPOPCI 3 +BEGIN + PROMPT 1 12 "Conto industr. " + FIELD I6 + CHECKTYPE NORMAL + END + +NUMBER F_CONTOPCI 3 +BEGIN + PROMPT 22 12 "" + FIELD I7 + //USE PCI SELECT (CODTAB[4,6]!="") && (CODTAB[7,12]=="") + //INPUT CODTAB[1,3] F_GRUPPOPCI + //INPUT CODTAB[4,6] F_CONTOPCI + //DISPLAY "Gruppo" CODTAB[1,3] + //DISPLAY "Conto" CODTAB[4,6] + //DISPLAY "Descrizione@50" S0 + //OUTPUT F_GRUPPOPCI CODTAB[1,3] + //OUTPUT F_CONTOPCI CODTAB[4,6] + CHECKTYPE NORMAL + ADD RUN BA3 -0 PCI + WARNING "Codice piano dei conti industriale assente" + END + +NUMBER F_SOTTOPCI 6 +BEGIN + PROMPT 26 12 "" + FIELD I8 + USE PCI SELECT CODTAB[7,12]!="" + INPUT CODTAB[1,3] F_GRUPPOPCI + INPUT CODTAB[4,6] F_CONTOPCI + INPUT CODTAB[7,12] F_SOTTOPCI + DISPLAY "Gruppo" CODTAB[1,3] + DISPLAY "Conto" CODTAB[4,6] + DISPLAY "Sottoconto" CODTAB[7,12] + DISPLAY "Descrizione@50" S0 + OUTPUT F_GRUPPOPCI CODTAB[1,3] + OUTPUT F_CONTOPCI CODTAB[4,6] + OUTPUT F_SOTTOPCI CODTAB[7,12] + OUTPUT F_DESCRCONTOPCI S0 + CHECKTYPE NORMAL + WARNING "Sottoconto errato" + ADD RUN BA3 -0 PCI +END + +STRING F_DESCRCONTOPCI 50 +BEGIN + PROMPT 36 12 "" + FLAG "U" + USE PCI KEY 2 SELECT (CODTAB[7,12]!="") + INPUT S0 F_DESCRCONTOPCI + DISPLAY "Descrizione@50" S0 + DISPLAY "Gruppo" CODTAB[1,3] + DISPLAY "Conto" CODTAB[4,6] + DISPLAY "Sottoconto" CODTAB[7,12] + COPY OUTPUT F_SOTTOPCI + CHECKTYPE NORMAL + WARNING "Codice piano conti industriale assente" + ADD RUN BA0 -3 PCI +END + BOOLEAN F_ARTFIS BEGIN PROMPT 1 13 "Articolo fiscale" diff --git a/ve/ve2400k.uml b/ve/ve2400k.uml new file mode 100755 index 000000000..7ccda7860 --- /dev/null +++ b/ve/ve2400k.uml @@ -0,0 +1,28 @@ +#include "ve2400.h" + +PAGE "Copia Articolo" -1 -1 66 4 + +STRING F_CODART 20 +BEGIN + PROMPT 1 1 "Nuovo codice " + USE LF_ANAMAG + INPUT CODART F_CODART + DISPLAY "Codice articolo@20" CODART + DISPLAY "Descrizione@50" DESCR + OUTPUT F_CODART CODART + CHECKTYPE SEARCH +END + +BUTTON DLG_OK 10 2 +BEGIN + PROMPT -12 -1 "" +END + +BUTTON DLG_CANCEL 10 2 +BEGIN + PROMPT -22 -1 "" +END + +ENDPAGE + +ENDMASK \ No newline at end of file diff --git a/ve/ve3200.cpp b/ve/ve3200.cpp index 967d803a2..edb2d3ad6 100755 --- a/ve/ve3200.cpp +++ b/ve/ve3200.cpp @@ -187,7 +187,7 @@ bool TStampa_condizioni_vendita::set_print(int) { if (!_gest_val) KILL(F_L_LISTVALUTA); // disabilita condizionalmente la gestione delle valute break; case 'C': // contratti - mask.show(-2);// nasconde i campi dei contratti + mask.show(-2);// mostra i campi dei contratti mask.hide(-8);// nasconde i campi del gr. merc mask.hide(-9); // nasconde i campi del raggr. fisc. mask.hide(-1);// nasconde i campi dei listini @@ -196,9 +196,12 @@ bool TStampa_condizioni_vendita::set_print(int) { DESTROY(F_L_CATVEN); DESTROY(F_L_LISTVALUTA); DESTROY(F_O_COD); - if (!_codcon_codcf) { // disabilita condizionalmente i clienti/fornitori + if (!_codcon_codcf) + { // disabilita condizionalmente i clienti/fornitori KILL(F_C_TIPOCF); KILL(F_C_CODCF); + mask.set(F_C_TIPOCF, ""); + mask.set(F_C_CODCF, 0L); } break; case 'O': // offerte diff --git a/ve/ve3200x.uml b/ve/ve3200x.uml index 7074edbd4..7adbd45ff 100755 --- a/ve/ve3200x.uml +++ b/ve/ve3200x.uml @@ -46,16 +46,17 @@ BEGIN CHECKTYPE NORMAL END -LIST F_C_TIPOCF 9 // tipo cliente/fornitore, solo contratti +LIST F_C_TIPOCF 1 12 // tipo cliente/fornitore, solo contratti BEGIN PROMPT 2 1 "Tipo " + ITEM " | " ITEM "C|Cliente" ITEM "F|Fornitore" END NUMBER F_C_CODCF 6 // codice cliente/fornitore, solo contratti BEGIN - PROMPT 19 1 "Codice " + PROMPT 22 1 "Codice " FLAG "GR" USE LF_CLIFO INPUT TIPOCF F_C_TIPOCF @@ -82,8 +83,8 @@ BEGIN OUTPUT F_TIPO TIPO OUTPUT F_L_CATVEN CATVEN OUTPUT F_L_COD COD - CHECKTYPE REQUIRED - WARNING "Specificare un codice listino" + CHECKTYPE NORMAL + WARNING "Codice listino inesistente" END STRING F_C_COD 3 // codice contratto, solo contratti @@ -103,8 +104,8 @@ BEGIN OUTPUT F_C_TIPOCF TIPOCF OUTPUT F_C_CODCF CODCF OUTPUT F_C_COD COD - CHECKTYPE REQUIRED - WARNING "Specificare un codice contratto" + CHECKTYPE NORMAL + WARNING "Codice contratto inesistente" END STRING F_O_COD 3 // codice offerta, solo offerte @@ -118,8 +119,8 @@ BEGIN DISPLAY "Descrizione@50" DESCR OUTPUT F_TIPO TIPO OUTPUT F_O_COD COD - CHECKTYPE REQUIRED - WARNING "Specificare un codice offerta" + CHECKTYPE NORMAL + WARNING "Codice offerta inesistente" END LIST F_TIPORIGHE 9 // listbox per tipo di selezione righe diff --git a/ve/ve4100.cpp b/ve/ve4100.cpp index a8a567588..534e735ef 100755 --- a/ve/ve4100.cpp +++ b/ve/ve4100.cpp @@ -577,7 +577,8 @@ TCursor& TRicalcolo_mask::create_cursor() if (_cursor) delete _cursor; - _cursor = new TCursor(&create_relation(), filter, key, &start, &stop); + _cursor = new TCursor(&create_relation(), "", key, &start, &stop); + _cursor->setfilter(filter, filter.find("->") > 0); // Update relation when needed return *_cursor; } @@ -966,7 +967,10 @@ bool TRicalcolo_mask::elabora() vw.open_modal(); bool ok = TRUE; - for (cur = 0; cur.ok(); ++cur) + + const TRecnotype items = cur.items(); + cur.freeze(); + for (cur = 0; cur.pos() < items; ++cur) { line.format("#@b%7ld@r - ", cur.pos()+1); const TRectype& curr = cur.curr(); @@ -1057,6 +1061,8 @@ bool TRicalcolo_mask::elabora() rewrite_cursor(cur); } } + cur.freeze(FALSE); + return TRUE; } diff --git a/ve/vearea.men b/ve/vearea.men index 1f6d8629b..b8aec208a 100755 --- a/ve/vearea.men +++ b/ve/vearea.men @@ -50,6 +50,7 @@ Item_09 = "Spese", "ba3 -0 SPP", "F" Item_10 = "Prestazioni", "ba3 -0 PRS", "F" Item_11 = "Banche di presentazione", "ef0 -6 BNP", "F" Item_12 = "Zone", "ba3 -0 ZON", "F" +Item_13 = "Piano dei conti industriale", "ba3 -0 PCI", "F" [ACQVEN_005] Caption = "Tabelle contabili" @@ -113,6 +114,7 @@ Item_09 = "Spese", "ba3 -1 SPP", "F" Item_10 = "Prestazioni", "ba3 -1 PRS", "F" Item_11 = "Banche di presentazione", "ba3 -1 BNP", "F" Item_12 = "Zone", "ba3 -1 ZON", "F" +Item_13 = "Piano dei conti industriale", "ba3 -1 PCI", "F" [ACQVEN_010] Caption = "Stampa tabelle contabili" diff --git a/ve/velib.h b/ve/velib.h index f6d8d0ceb..0a4d8b44a 100755 --- a/ve/velib.h +++ b/ve/velib.h @@ -66,7 +66,7 @@ class TViswin; class TDocumento; class TRiga_documento; class TCond_vendita; -//class TIVA; +class TIVA_array; class TArticolo_giacenza; class TCache_articoli; @@ -387,6 +387,8 @@ public: const int incr_perc_prezzo() const { return _incrp;} const int decr_perc_prezzo() const { return _decrp;} bool formfeed() const { return get_bool("B0"); } + int detraibilita() const { return get_int("I0"); } + real perc_indetraibilita() const { return get_real("R0"); } TFormula_documento* first_formula() { return succ_formula(TRUE); } TFormula_documento* succ_formula(bool restart = FALSE); @@ -484,6 +486,8 @@ public: real quantita() const { return get_real(RDOC_QTA); } real qtaresidua() const; real valore(bool totale, int ndec) const; + const TString & codice_commessa() const; + const TString & fase_commessa() const; TArticolo_giacenza * articolo() const; TRiga_documento(TDocumento* doc, const char* tipo = NULL); @@ -654,6 +658,8 @@ public: bool provvisorio() const { return get_char("PROVV") == 'P'; } char stato() const { return get_char("STATO"); } void stato(char s) { put("STATO", s); } + const TString & codice_commessa() const { return get(DOC_CODCMS);} + const TString & fase_commessa() const { return get(DOC_FASCMS);} bool modificabile() const; bool cancellabile() const; bool stampabile() const; @@ -777,6 +783,9 @@ public: void mask2doc(); void update_giacenza(); + + const TString& stdmag() const { return _std_mag; } + const TString& stddep() const { return _std_dep; } TSheet_field& sheet() const { return *_sheet; } TCodgiac_livelli& livelli() const { return *_livelli_giac; } @@ -1052,11 +1061,11 @@ protected: // cerca la prima tra quelle di contabilita' che corrisponde al tipo indicato int type2pos(char tipo); // Trova nelle righe contabili un conto nelle righe di tipo prescelto - int bill2pos(const TBill& conto, char tipo); + int bill2pos(const TBill& conto, const TString & codcms, const TString & fascms, char tipo); // trasforma un real in TImporto, in base al tipo riga TImporto real2imp(const real& r, char row_type); // setta il record delle righe di contabilita' - int set_cg_rec(int n, const TImporto& imp, TBill& conto, const char* desc, char tipo); + int set_cg_rec(int n, const TImporto& imp, TBill& conto, const char * codcms, const char * fascms, const char* desc, char tipo); // aggiunge l'importo indicato alla n-esima riga di contabilita' bool add_cg_rec(int n, const TImporto& imp); // Legge l'importo della riga n e lo ritorna col segno dovuto @@ -1069,10 +1078,11 @@ public: // ricalcola le righe di contabilita' dalle righe iva presenti // e verifica la quadratura del movimento. Ritorna TRUE se il movimento e' scrivibile bool movement_ok() ; - int recalc_cg_rows(const TString & descr_cr, TCausale* caus = NULL); + int recalc_cg_rows(const TString & descr_cr, TCausale & caus); TMovimentoPN_VE(bool valuta) : _valuta(valuta), _caus(NULL) {}; virtual ~TMovimentoPN_VE() {} }; + class TContabilizzazione : public TElaborazione // velib04b { @@ -1084,12 +1094,12 @@ class TContabilizzazione : public TElaborazione // velib04b bool _can_write; // se TRUE e' abilitata la scrittura. Non appena rileva un errore rimane a FALSE for this instance TString16 _spin_cod, // codice iva spese d'incasso _spbo_cod; // codice iva spese bolli - TAssoc_array _totali_lordi,// array per totalizzare i lordi per aliquota, al fine di aggiustare gli imponibili + TAssoc_array _totali_lordi;// array per totalizzare i lordi per aliquota, al fine di aggiustare gli imponibili // nel caso di calcolo lordo sul documento - _righe_iva; // array per la memorizzazione delle righe iva raggruppate in codesto modo: - // CODICE_IVA+TIPOCF+GRUPPO+CONTO+SOTTOCONTO - // una volta completo, tale array viene scorso per comporre le righe IVA - // del movimento + TIVA_array *_righe_iva; // array per la memorizzazione delle righe iva raggruppate in codesto modo: + // CODICE_IVA+TIPOCF+GRUPPO+CONTO+SOTTOCONTO+COMMESSA+FASE+DETRAIBILITA + // una volta completo, tale array viene scorso per comporre le righe IVA + // del movimento // Files, tabelle, oggetti contabili ed altre amenita'... TLocalisamfile *_anamag, // file delle anagrafiche di magazzino @@ -1134,7 +1144,7 @@ protected: // Funzione per ricercare il conto di costo/ricavo error_type search_costo_ricavo(TBill&, const TRiga_documento&); // Funzione per aggiungere la riga iva al TAssoc_array _righe_iva - error_type add_iva_row(const TBill&, const TRiga_documento&, const int, const real p); +// error_type add_iva_row(const TBill&, const TRiga_documento&, const int ndec, const real p = 1.0); // Funzione atomica per aggiungere le righe di spese d'incasso e bolli al TAssoc_array _righe_iva void calculate_spese(real&, real&, int, bool, bool, const TString &, const TDocumento & ); // Funzione per aggiungere le righe di spese d'incasso e bolli al TAssoc_array _righe_iva (chiama calculate_spese()) @@ -1346,4 +1356,4 @@ public: }; -#endif +#endif \ No newline at end of file diff --git a/ve/velib02.cpp b/ve/velib02.cpp index 7dc76d0fb..709a387ee 100755 --- a/ve/velib02.cpp +++ b/ve/velib02.cpp @@ -473,21 +473,24 @@ real TRiga_documento::importo(bool scontato, bool lordo, int ndec) const if (to_calc) { - case 'Q': - c = _qtaprezzo; - break; - case 'V': - c = _valore; - break; - case 'P': - { - const TString16 field_perc(s.field_perc()); - c = _percentuale; - r1 = doc().get_real(field_perc); - } - break; - default: - break; + switch (s.tipo()) + { + case 'Q': + c = _qtaprezzo; + break; + case 'V': + c = _valore; + break; + case 'P': + { + const TString16 field_perc(s.field_perc()); + c = _percentuale; + r1 = doc().get_real(field_perc); + } + break; + default: + break; + } } } break; @@ -650,6 +653,18 @@ real TRiga_documento::valore(bool totale, int ndec) const return val; } +const TString & TRiga_documento::codice_commessa() const +{ + const TString & cod_cms = get(RDOC_CODCMS); + return cod_cms.empty() ? doc().get(DOC_CODCMS) : cod_cms; +} + +const TString & TRiga_documento::fase_commessa() const +{ + const TString & fas_cms = get(RDOC_FASCMS); + return fas_cms.empty() ? doc().get(DOC_FASCMS) : fas_cms; +} + void TRiga_documento::dirty_fields(bool dirty_document) { for (TDocumento_variable_field * f = (TDocumento_variable_field *) first_variable_field(); diff --git a/ve/velib03.cpp b/ve/velib03.cpp index c95478de3..2e4f0c284 100755 --- a/ve/velib03.cpp +++ b/ve/velib03.cpp @@ -1580,9 +1580,7 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const myself._stato_originale = stato(); const bool doc_bloccato = bloccato(); - const bool check_movmag = dongle().active(MGAUT) && tipo().mov_mag(); const char stato_doc(stato()); - const bool do_movmag = tipo().stato_with_mov_mag(stato_doc); const int rows = physical_rows(); int err = NOERR; @@ -1610,11 +1608,13 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const long num = get_long("MOVMAG"); + const bool check_movmag = dongle().active(MGAUT) && tipo().mov_mag(); if (check_movmag) { + const bool do_movmag = tipo().stato_with_mov_mag(stato_doc) && get(DOC_CAUSMAG).not_empty(); + TMov_mag_doc mov; TLocalisamfile m(LF_MOVMAG); - mov.zero(); if (num == 0 && do_movmag) { @@ -1749,18 +1749,18 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const } } mov.rewrite(m); - } - else - { - mov.remove(m); - for (int i = rows; i > 0; i--) - { - TRiga_documento & r = myself.row(i); - long r_num = r.get_long("MOVMAG"); - //if (r_num == num) per ora non ci sono movimenti diversi per righe diverse - r.zero("MOVMAG"); + } + else + { + mov.remove(m); + for (int i = rows; i > 0; i--) + { + TRiga_documento & r = myself.row(i); + long r_num = r.get_long("MOVMAG"); + //if (r_num == num) per ora non ci sono movimenti diversi per righe diverse + r.zero("MOVMAG"); } - myself.zero("MOVMAG"); + myself.zero("MOVMAG"); } } } diff --git a/ve/velib04b.cpp b/ve/velib04b.cpp index be30ff8d4..6d5142493 100755 --- a/ve/velib04b.cpp +++ b/ve/velib04b.cpp @@ -66,9 +66,11 @@ bool TMovimentoPN_VE::detraibile(TRectype& rec) const return !prorata100; // Se prorata = 100% e' indetraibile } -int TMovimentoPN_VE::bill2pos(const TBill& conto, char tipo) +int TMovimentoPN_VE::bill2pos(const TBill& conto, const TString & codcms, const TString & fascms, char tipo) { const int items = cg_items(); + const bool has_cm = main_app().has_module(CMAUT, CHK_DONGLE); + for (int i = 0; i < items; i++) { TRectype& s = cg(i); @@ -79,9 +81,16 @@ int TMovimentoPN_VE::bill2pos(const TBill& conto, char tipo) const int gr = s.get_int(RMV_GRUPPO); const int co = s.get_int(RMV_CONTO); const long so = s.get_long(RMV_SOTTOCONTO); + c.set(gr,co,so); - if (c == conto) - return i; + if (has_cm) + { + if (c == conto && (codcms == s.get(RMV_CODCMS)) && (fascms == s.get(RMV_FASCMS))) + return i; + } + else + if (c == conto) + return i; } } return -1; @@ -121,12 +130,12 @@ bool TMovimentoPN_VE::add_cg_rec(int n, const TImporto& imp) { TImporto tot(get_cg_imp(n)); tot += imp; - //tot.normalize(); + tot.normalize(); set_cg_imp(n, tot); return tot.is_zero(); } -int TMovimentoPN_VE::set_cg_rec(int n, const TImporto& imp, TBill& conto, +int TMovimentoPN_VE::set_cg_rec(int n, const TImporto& imp, TBill& conto, const char * codcms, const char * fascms, const char* desc, char tipo) { const bool insert = n < 0; @@ -148,7 +157,13 @@ int TMovimentoPN_VE::set_cg_rec(int n, const TImporto& imp, TBill& conto, rec.put(RMV_TIPOC,conto.tipo()); rec.put(RMV_GRUPPO,conto.gruppo()); rec.put(RMV_CONTO,conto.conto()); - rec.put(RMV_SOTTOCONTO,conto.sottoconto()); + rec.put(RMV_SOTTOCONTO,conto.sottoconto()); + + if (main_app().has_module(CMAUT, CHK_DONGLE)) + { + rec.put(RMV_CODCMS,codcms); + rec.put(RMV_FASCMS,fascms); + } rec.put(RMV_DESCR, desc); if (tipo == 'T') // Calcolo contropartita @@ -210,15 +225,15 @@ void TMovimentoPN_VE::create_row(int i, const TString & descr_cr) if (type2pos(tipod) < 0 && !oldiva.is_zero()) { - const int ri = tipod == 'D' ? 3 : 4; // Calcola riga causale per l'IVA + const int ri = tipod == 'D' ? RIGA_IVA_DETRAIBILE : RIGA_IVA_NON_DETRAIBILE; TBill c; _caus->bill(ri, c); if (c.ok()) { const TString80 d(_caus->desc_agg(ri)); - set_cg_rec(-1, real2imp(ZERO, 'I'), c, d, tipod); + set_cg_rec(-1, real2imp(ZERO, 'I'), c, "", "", d, tipod); } else - if (ri == 4) // Se non esiste il conto IVA indetraibile ... + if (ri == RIGA_IVA_NON_DETRAIBILE) // Se non esiste il conto IVA indetraibile ... { // ... somma imponibile e imposta oldimp += oldiva; oldiva = 0.0; @@ -229,14 +244,16 @@ void TMovimentoPN_VE::create_row(int i, const TString & descr_cr) const int gr = cur.get_int(RMI_GRUPPO); const int co = cur.get_int(RMI_CONTO); const long so = cur.get_long(RMI_SOTTOCONTO); + const TString80 codcms = cur.get(RMI_CODCMS); + const TString16 fascms = cur.get(RMI_FASCMS); oldconto.set(gr,co,so); if (oldconto.ok()) { - if (bill2pos(oldconto, 'I') < 0) + if (bill2pos(oldconto, codcms, fascms, 'I') < 0) { const TString d(_caus->desc_agg(2)); - set_cg_rec(-1, real2imp(ZERO, 'I'), oldconto, d.empty() ? descr_cr: d, 'I'); + set_cg_rec(-1, real2imp(ZERO, 'I'), oldconto, codcms, fascms, d.empty() ? descr_cr: d, 'I'); } } } @@ -260,9 +277,11 @@ void TMovimentoPN_VE::enter_row(int i, const TString & descr_cr) const int gr = cur.get_int(RMI_GRUPPO); const int co = cur.get_int(RMI_CONTO); const long so = cur.get_long(RMI_SOTTOCONTO); + const TString80 codcms = cur.get(RMI_CODCMS); + const TString16 fascms = cur.get(RMI_FASCMS); conto.set(gr,co,so,t); - int newpos = bill2pos(conto, 'I'); // Riga in cui andra' l'imponibile + int newpos = bill2pos(conto, codcms, fascms, 'I'); // Riga in cui andra' l'imponibile const bool detrarre = detraibile(cur); // Determina se IVA detraibile @@ -270,9 +289,9 @@ void TMovimentoPN_VE::enter_row(int i, const TString & descr_cr) const int ri = detrarre ? RIGA_IVA_DETRAIBILE : RIGA_IVA_NON_DETRAIBILE; TBill contoiva; _caus->bill(ri, contoiva); - if (ri == 4 && !contoiva.ok()) // Se non c'e' il conto IVA indetraibile ... - { // ... somma imponibile e imposta - imponibile += imposta; + if (ri == RIGA_IVA_NON_DETRAIBILE && !contoiva.ok()) // Se non c'e' il conto IVA indetraibile ... + { // ... somma imponibile e imposta + imponibile += imposta; imposta = 0.0; } @@ -283,7 +302,7 @@ void TMovimentoPN_VE::enter_row(int i, const TString & descr_cr) if (conto.ok() && !val.is_zero()) // Se c'e' imponibile ... { // crea una nuova riga contabile const TString d(_caus->desc_agg(2)); - set_cg_rec(-1, val, conto, d.empty() ? descr_cr : d, 'I'); + set_cg_rec(-1, val, conto, codcms, fascms, d.empty() ? descr_cr : d, 'I'); } } else @@ -304,7 +323,7 @@ void TMovimentoPN_VE::enter_row(int i, const TString & descr_cr) { // ... crea nuova riga per l'IVA const TImporto val(real2imp(imposta, 'I')); const TString d(_caus->desc_agg(ri)); - newposiva = set_cg_rec(-1, val, contoiva, d, tipod); + newposiva = set_cg_rec(-1, val, contoiva, "", "", d, tipod); } } else @@ -355,21 +374,12 @@ bool TMovimentoPN_VE::movement_ok() return TRUE; } -int TMovimentoPN_VE::recalc_cg_rows(const TString & descr_cr, TCausale* caus) +int TMovimentoPN_VE::recalc_cg_rows(const TString & descr_cr, TCausale & caus) { const int righe = iva_items(); - bool external_caus = TRUE; TRectype& head = lfile().curr(); - if (caus == NULL) - { - external_caus = FALSE; - TString16 codcau(head.get(MOV_CODCAUS)); - int year = head.get_int(MOV_ANNOIVA); - _caus = new TCausale (codcau,year); - } - else - _caus = caus; + _caus = &caus; for (int i=0; iintra() && _caus->iva() == iva_acquisti) { - TBill c; _caus->bill(8, c); + TBill c; _caus->bill(RIGA_RITENUTE_FISCALI, c); ok = c.ok(); if (ok) { - const TString80 d(_caus->desc_agg(8)); + const TString80 d(_caus->desc_agg(RIGA_RITENUTE_FISCALI)); const char rowtype = 'F'; - set_cg_rec(-1, real2imp(head.get_real(MOV_RITFIS), rowtype), c, d, rowtype); + set_cg_rec(-1, real2imp(head.get_real(MOV_RITFIS), rowtype), c, "","", d, rowtype); } else return 2; @@ -395,13 +405,13 @@ int TMovimentoPN_VE::recalc_cg_rows(const TString & descr_cr, TCausale* caus) if (ritfis != ZERO) { - TBill c; _caus->bill(8, c); + TBill c; _caus->bill(RIGA_RITENUTE_FISCALI, c); ok = c.ok(); if (ok) { - const TString80 d(_caus->desc_agg(8)); + const TString80 d(_caus->desc_agg(RIGA_RITENUTE_FISCALI)); const char rowtype = 'F'; - set_cg_rec(-1, real2imp(ritfis, rowtype), c, d, rowtype); + set_cg_rec(-1, real2imp(ritfis, rowtype), c, "", "", d, rowtype); } else return 1; @@ -411,18 +421,19 @@ int TMovimentoPN_VE::recalc_cg_rows(const TString & descr_cr, TCausale* caus) if (ritsoc != ZERO) { - TBill c; _caus->bill(9, c); + TBill c; _caus->bill(RIGA_RITENUTE_SOCIALI, c); ok = c.ok(); if (ok) { - const TString80 d(_caus->desc_agg(9)); + const TString80 d(_caus->desc_agg(RIGA_RITENUTE_SOCIALI)); const char rowtype = 'S'; - set_cg_rec(-1, real2imp(ritsoc, rowtype), c, d, rowtype); + set_cg_rec(-1, real2imp(ritsoc, rowtype), c, "", "", d, rowtype); } else return 1; } } + if (_caus->tipomov() == 1) // Elimina eventuali righe vuote dalle fatture { for (int c = cg_items()-1; c >= 0; c--) @@ -433,42 +444,9 @@ int TMovimentoPN_VE::recalc_cg_rows(const TString & descr_cr, TCausale* caus) } } - if (!external_caus) - { - delete _caus; - _caus = NULL; - } return ok && movement_ok() ? 0 : 1; } -// TIVA_element -// classe di elementi da memorizzare nel TAssoc_array (vedi sotto) _righe_iva -class TIVA_element : public TObject -{ - real _imp; - real _iva; - real _ali; // Andrebbe eliminato: basta _cod_iva (Guy was here) - TString4 _cod_iva; - -public: - real& imp() { return _imp;} // Imponibile - real& iva() { return _iva;} // Iva - real& ali() { return _ali;} // Aliquota % - TString& cod_iva() { return _cod_iva;} - void zero() { _imp = _iva = _ali = ZERO; _cod_iva.cut(0); } - virtual TObject* dup() const { return new TIVA_element(*this); } - TIVA_element& operator = (TIVA_element& a); - TIVA_element() { zero(); } - ~TIVA_element() {}; -}; - -TIVA_element& TIVA_element::operator=(TIVA_element& a) -{ - _imp = a.imp(); _iva = a.iva(); _ali = a.ali(); - _cod_iva = a.cod_iva(); - return *this; -} - // Parametri da leggere all'inizio dell'elaborazione tramite load_parameters() static TBill _sco_perc_bill, _sco_imp_bill, // Conti per gli sconti a percentuale ed importi (dalla configurazione) _spin_billa, _spin_billv, @@ -503,6 +481,203 @@ static TCausale *_caus = NULL; // causale del documento cor static TMovimentoPN_VE *_movimento = NULL; // Movimento di prima nota documento vendita static TMovimentoPN *_anticipo = NULL; // Movimento di prima nota relativamente all'anticipo indicato sul documento +class TIVA_array : public TAssoc_array +{ + TCausale * _caus; // causale del documento corrente + +protected: + void copy(const TIVA_array& a); + TObject* dup() const { return new TIVA_array(*this); } + +public: + error_type add(const TRiga_documento & r, const TBill& conto, const int ndec = ALL_DECIMALS, const real & p = 1.0); + error_type add(const TRiga_documento * r, const TBill& conto, const int ndec = ALL_DECIMALS, const real & p = 1.0) { return add(*r, conto, ndec, p);} + error_type add_omaggi(const TRiga_documento & r, const TBill& conto, const int ndec = ALL_DECIMALS, const real & p = 1.0); + error_type add_omaggi(const TRiga_documento * r, const TBill& conto, const int ndec = ALL_DECIMALS, const real & p = 1.0) { return add_omaggi(*r, conto, ndec, p);} + void set_caus(TCausale * caus) { _caus = caus; } + + TIVA_array() {} + // @cmember Costruttore. Copia tutto l'array associativo e ne duplica gli elementi + TIVA_array(const TIVA_array& a) { copy(a); } + virtual ~TIVA_array() {} +}; + +void TIVA_array::copy(const TIVA_array & a) +{ + TAssoc_array::copy(a); + _caus = a._caus; +} + +error_type TIVA_array::add_omaggi(const TRiga_documento & r, const TBill& conto, const int ndec, const real & p) +{ + if (_ivasto.empty()) + return ivasto_error; + add(r, conto, ndec, p); + TRiga_documento r_storno(r); + + r_storno.put(RDOC_CODIVA, _ivasto); + real prezzo = r_storno.get(RDOC_PREZZO); + prezzo = -prezzo; + r_storno.put(RDOC_PREZZO, prezzo); + add(r, conto, ndec, p); + return no_error; +} + +error_type TIVA_array::add(const TRiga_documento & r, const TBill& conto, const int ndec, const real & p) +{ + const TTipo_riga_documento & t = r.tipo(); + TString80 key; + const TCodiceIVA& tiva = r.iva(); + TString16 cod(tiva.codice()); + const char tipo = conto.tipo(); + const int gr = conto.gruppo(); + const int co = conto.conto(); + const long so = conto.sottoconto(); + int ord = 0; + TString80 codcms; + TString16 fascms; + int detr = 0; + real pind = ZERO; + real impon; + const bool sconto_lordo = t.tipo() != RIGA_SCONTI && _contsclor && _sco_perc_bill.ok(); + + if (!sconto_lordo) // Al netto dello sconto + impon = r.imponibile(); + else + impon = r.importo(FALSE,FALSE,ndec); // Imponibile della riga al lordo dello sconto + + switch (t.tipo()) + { + case RIGA_MERCE: + ord = 1; + break; + case RIGA_OMAGGI: + impon = r.imponibile_omaggio(); + ord = 2; + break; + case RIGA_SPESEDOC: + ord = 3; + break; + case RIGA_PRESTAZIONI: + ord = 4; + break; + case RIGA_SCONTI: + ord = 5; + break; + case RIGA_DESCRIZIONI: + default: + return no_error; + break; + } + + impon *= p; + impon.round(ndec); + + if (impon.is_zero()) + return no_error; + + real imposta = tiva.imposta(impon, ndec); + + if (main_app().has_module(CMAUT, CHK_DONGLE)) + { + codcms = r.codice_commessa(); + fascms = r.fase_commessa(); + } + if (_caus->iva() == iva_acquisti) + { + detr = t.detraibilita(); + pind = t.perc_indetraibilita(); + } + + real impres = (impon * pind) / 100.0; + real ivares = (imposta * pind) / 100.0; + + impres.round(ndec); + ivares.round(ndec); + + // Le righe di sconto ad importo o percentuale vanno saltate + // Casistica sulle righe omaggio: + // quelle che non hanno addebito IVA devono venire scartate, quelle che hanno + // addebito IVA vengono aggiunte normalmente ed in piu' viene aggiunta + // una riga IVA con lo stesso imponibile ma di segno opposto, con un cod. IVA + // speciale per lo storno, proveniente da configurazione + + if (pind < 100.0) + { + key.format("%d|%-4s|%c|%3d|%3d|%6ld|%s|%s|%d",ord,(const char*)cod,tipo,gr,co,so, (const char *)codcms, (const char *)fascms, 0); + TRectype * iva = (TRectype *) objptr(key); + + if (iva == NULL) + { + iva = new TRectype(LF_RMOVIVA); + iva->put(RMI_CODIVA,cod); + iva->put(RMI_TIPOCR,conto.tipo_cr()); + iva->put(RMI_INTRA, _caus->intra()); + iva->put(RMI_TIPOC, conto.tipo()); + iva->put(RMI_GRUPPO, conto.gruppo()); + iva->put(RMI_CONTO, conto.conto()); + iva->put(RMI_SOTTOCONTO, conto.sottoconto()); + iva->put(RMI_CODCMS, codcms); + iva->put(RMI_FASCMS, fascms); + TAssoc_array::add(key, iva, TRUE); + } + real val = iva->get_real(RMI_IMPONIBILE); + + val += (impon - impres); + iva->put(RMI_IMPONIBILE,val); + val = iva->get_real(RMI_IMPOSTA); + val += (imposta - ivares); + iva->put(RMI_IMPOSTA, val); + + } + if (pind > ZERO) + { + key.format("%d|%-4s|%c|%3d|%3d|%6ld|%s|%s|%d",ord,(const char*)cod,tipo,gr,co,so, (const char *)codcms, (const char *)fascms, detr); + TRectype * iva = (TRectype *) objptr(key); + + if (iva == NULL) + { + iva = new TRectype(LF_RMOVIVA); + iva->put(RMI_CODIVA,cod); + iva->put(RMI_TIPOCR,conto.tipo_cr()); + iva->put(RMI_INTRA, _caus->intra()); + iva->put(RMI_TIPOC, conto.tipo()); + iva->put(RMI_GRUPPO, conto.gruppo()); + iva->put(RMI_CONTO, conto.conto()); + iva->put(RMI_SOTTOCONTO, conto.sottoconto()); + iva->put(RMI_CODCMS, codcms); + iva->put(RMI_FASCMS, fascms); + iva->put(RMI_TIPODET, detr); + TAssoc_array::add(key, iva, TRUE); + } + real val = iva->get_real(RMI_IMPONIBILE); + + val += impres; + iva->put(RMI_IMPONIBILE,val); + val = iva->get_real(RMI_IMPOSTA); + val += ivares; + iva->put(RMI_IMPOSTA, val); + } + if (ord != 5) + { + if (sconto_lordo) // Se e' settato il flag di contabilizzare anche gli sconti merce + { + real sconto; + + sconto = - r.sconto(); // Imponibile dello sconto (positivo, quindi si cambia di segno) + + if (sconto != ZERO) // Le righe Omaggio con Addebito IVA hanno comunque sconto ZERO! + { + TRiga_documento r_sconto(r); + r_sconto.put(RDOC_QTA, "1.00"); + r_sconto.put(RDOC_PREZZO, sconto); + add(r_sconto, _sco_perc_bill, ndec, p); + } + } + } + return no_error; +} + TContabilizzazione::TContabilizzazione(const char* cod) : TElaborazione(cod), _auto_data(FALSE), _nump_iva(2) { @@ -533,6 +708,8 @@ TContabilizzazione::TContabilizzazione(const char* cod) _cco = new TTable("CCO"); _clifo = new TRelation(LF_CLIFO); _clifo->add(LF_CFVEN,"TIPOCF=TIPOCF|CODCF=CODCF"); + _righe_iva = new TIVA_array; + _can_write = TRUE; _error = no_error; @@ -570,6 +747,7 @@ TContabilizzazione::TContabilizzazione(const TRectype& rec) _cco = new TTable("CCO"); _clifo = new TRelation(LF_CLIFO); _clifo->add(LF_CFVEN,"TIPOCF=TIPOCF|CODCF=CODCF"); + _righe_iva = new TIVA_array; _can_write = TRUE; _error = no_error; @@ -604,6 +782,7 @@ TContabilizzazione::~TContabilizzazione() delete _occas; delete _docfile; delete _rdocfile; + delete _righe_iva; } bool TContabilizzazione::load_parameters() @@ -772,6 +951,7 @@ error_type TContabilizzazione::compile_head_mov(TDocumento& doc) codcaus = caus_cli; _caus = new TCausale(codcaus,data_reg.year()); + _righe_iva->set_caus(_caus); if (!_caus->ok()) { _error = caus_error; @@ -1163,219 +1343,27 @@ error_type TContabilizzazione::search_costo_ricavo(TBill& conto, const TRiga_doc return _error; } -error_type TContabilizzazione::add_iva_row(const TBill& conto, const TRiga_documento& r, const int ndec, const real p) -// Aggiunge le righe iva all'assoc_array di raggruppamento -{ - TIVA_element el_tmp; - const TCodiceIVA& tiva = r.iva(); - TString16 cod(tiva.codice()); - const char tipo = conto.tipo(); - const int gr = conto.gruppo(); - const int co = conto.conto(); - const long so = conto.sottoconto(); - TString80 key; - const char tipo_r = r.tipo().tipo(); - const bool sconto_lordo = tipo_r != 'C' && _contsclor && _sco_perc_bill.ok(); - bool exists; - int ord=0; - // Ordine con cui vengono immesse le righe IVA: - // merce, omaggi, prestazioni, spese, bolli/spese d'incasso, sconti. - - switch (tipo_r) - { - case 'M': - ord = 1; - break; - case 'O': - ord = 2; - break; - case 'P': - ord = 3; - break; - case 'S': - ord = 4; - break; - default: break; - } - - // Le righe di sconto ad importo o percentuale vanno saltate - if (tipo_r != 'C') - { - key.format("%d|%-4s|%c|%3d|%3d|%6ld",ord,(const char*)cod,tipo,gr,co,so); - exists = _righe_iva.is_key(key); - TIVA_element& el = (exists ? (TIVA_element&)_righe_iva[key] : el_tmp); - - // Casistica sulle righe omaggio: - // quelle che non hanno addebito IVA devono venire scartate, quelle che hanno - // addebito IVA vengono aggiunte normalmente ed in piu' viene aggiunta - // una riga IVA con lo stesso imponibile ma di segno opposto, con un cod. IVA - // speciale per lo storno, proveniente da configurazione - if (tipo_r == 'O') - { - if (_ivasto.empty()) - { - _error = ivasto_error; - return _error; - } - - real imp_om = r.imponibile_omaggio() * p; - imp_om.round(ndec); - - // Aggiunge la riga "normale" - - el.imp() += imp_om; - el.iva() += tiva.imposta(imp_om, ndec);// imposta calcolata sullo sconto - el.ali() = tiva.percentuale(); - el.cod_iva() = tiva.codice(); - _righe_iva.add(key,el,exists); - - // Aggiunge la riga di "compensazione" imponibile (segno meno) - TCodiceIVA tiva_sto(_ivasto); - key.format("%d|%-4s|%c|%3d|%3d|%6ld",ord,(const char*)_ivasto,tipo,gr,co,so); - exists = _righe_iva.is_key(key); - el_tmp.zero(); - TIVA_element& el_om = (exists ? (TIVA_element&)_righe_iva[key] : el_tmp); - - el_om.cod_iva() = _ivasto; - el_om.imp() += -imp_om; // Note negative sign on the left... - - real iva_om = tiva_sto.imposta(imp_om, ndec);// imposta: dovrebbe essere sempre ZERO; in caso contrario si avra' un movimento NON quadrato - el_om.iva() += iva_om; // Could of Been Should of Been Would of Been - el_om.ali() = tiva_sto.percentuale(); - - _righe_iva.add(key,el_om,exists); - } - else // Any other kind of row... - { - //el.add(r,sconto_lordo,ndec); // Inserisce la riga IVA al netto o al lordo dello sconto - real iimmpp, iivvaa; - if (!sconto_lordo) // Al netto dello sconto - iimmpp = r.imponibile() * p; - else - iimmpp = r.importo(FALSE,FALSE,ndec) * p; // Imponibile della riga al lordo dello sconto - iimmpp.round(ndec); - iivvaa = tiva.imposta(iimmpp,ndec); - - if (!iimmpp.is_zero() || !iivvaa.is_zero()) - { - el.imp() += iimmpp; - el.iva() += iivvaa; - el.ali() = tiva.percentuale(); - el.cod_iva() = tiva.codice(); - _righe_iva.add(key,el,exists); // Le righe di sconto le aggiorna dopo - } - - if (r.doc().tipo().calcolo_lordo()) // Si ricorda che calcolo_lordo() e fattura_commerciale() sono esclusivi. - { - // Totalizza per ogni codice iva il lordo - if (!_totali_lordi.is_key(cod)) - _totali_lordi.add(cod, new real); - real& rl = (real&) _totali_lordi[cod]; - rl += r.imponibile(TRUE); - } - if (tipo_r == 'S' && !_caus->intra()) - { - const char tipo_rit = r.spesa().tipo_ritenuta(); - - if (tipo_rit != '\0') - { - ((TSpesa_prest &)r.spesa()).zero("S9"); - ((TRiga_documento &)r).dirty_fields(); - TCurrency_documento c(r.imponibile(TRUE)); - ((TRiga_documento &)r).dirty_fields(); - ((TSpesa_prest &)r.spesa()).put("S9", (char) tipo_rit); - TRectype & h = _movimento->lfile().curr(); - real val; - if (r.doc().in_valuta()) - { - val = h.get_real(MOV_TOTDOCVAL) - c.get_num(); - h.put(MOV_TOTDOCVAL, val); - } - c.change_to_firm_val(); - val = h.get_real(MOV_TOTDOC) - c.get_num(); - h.put(MOV_TOTDOC, val); - - if (tipo_rit == 'F') - { - val = h.get_real(MOV_RITFIS) + c.get_num(); - h.put(MOV_RITFIS, val); - } - else - if (tipo_rit == 'S') - { - val = h.get_real(MOV_RITSOC) + c.get_num(); - h.put(MOV_RITSOC, val); - } - } - - } - } - } - - if (sconto_lordo) // Se e' settato il flag di contabilizzare anche gli sconti merce - { - real sconto, ivasc; - - sconto = - (r.sconto() * p); // Imponibile dello sconto (positivo, quindi si cambia di segno) - sconto.round(ndec); - - if (sconto != ZERO) // Le righe Omaggio con Addebito IVA hanno comunque sconto ZERO! - { - key.format("6|%-4s|%c|%3d|%3d|%6ld", - (const char*)cod, - _sco_perc_bill.tipo(), - _sco_perc_bill.gruppo(), - _sco_perc_bill.conto(), - _sco_perc_bill.sottoconto()); - - el_tmp.zero(); - exists = _righe_iva.is_key(key); - TIVA_element& el_sc = (exists ? (TIVA_element&)_righe_iva[key] : el_tmp); - el_sc.ali() = tiva.percentuale(); - el_sc.cod_iva() = tiva.codice(); - el_sc.imp() += sconto; - el_sc.iva() += ivasc; - _righe_iva.add(key,el_sc,exists); // Sostituisce od aggiunge la riga relativa allo sconto - } - } - - return no_error; -} void TContabilizzazione::calculate_spese(real& spese, real& sp_iva, int ndec, bool is_incasso, bool is_cli, const TString & codiva_es, const TDocumento & doc) { - char tipo; - int gr,co; - long so; const TBill& zio = is_incasso ? (is_cli ? _spin_billv : _spin_billa) : (is_cli ? _spbo_billv : _spbo_billa); - TCodiceIVA sp_cod((is_incasso ? (codiva_es.not_empty() ? codiva_es : (const TString &) _spin_cod) : (const TString &) _spbo_cod)); - TIVA_element el_tmp; - TString80 key; if (zio.ok()) { - sp_iva = sp_cod.imposta(spese, ndec); - tipo = zio.tipo(); - gr = zio.gruppo(); - co = zio.conto(); - so = zio.sottoconto(); - key.format("5|%-4s|%c|%3d|%3d|%6ld",(const char*)sp_cod.codice(),tipo,gr,co,so); - const bool exists = _righe_iva.is_key(key); - TIVA_element& el = (exists ? (TIVA_element&)_righe_iva[key] : el_tmp); - el.imp() += spese; - el.iva() += sp_iva; - el.ali() = sp_cod.percentuale(); - _righe_iva.add(key,el,exists); + TRiga_documento r((TDocumento *) &doc, "02"); // il tipo riga 02 spese a valore + r.put(RDOC_QTA, "1.00"); + r.put(RDOC_PREZZO, spese); + r.put(RDOC_CODIVA, codiva_es); + _righe_iva->add(r, zio, ndec); if (doc.tipo().calcolo_lordo()) // Si ricorda che calcolo_lordo() e fattura_commerciale sono esclusivi. { // Totalizza per ogni codice iva il lordo - const TString16 codiva(sp_cod.codice()); - if (!_totali_lordi.is_key(codiva)) - _totali_lordi.add(codiva, new real); - real& rl = (real&) _totali_lordi[codiva]; - rl += spese + sp_iva; + if (!_totali_lordi.is_key(codiva_es)) + _totali_lordi.add(codiva_es, new real); + real& rl = (real&) _totali_lordi[codiva_es]; + rl += spese + r.imposta(ndec); } } else @@ -1409,12 +1397,10 @@ error_type TContabilizzazione::add_spese_inbo(TDocumento& doc, const int ndec) // Aggiorna le righe di sconto (importo o a percentuale) error_type TContabilizzazione::adjust_sconto_rows(TDocumento& doc) { - TIVA_element el_tmp; TAssoc_array& aa = doc.tabella_iva(); TRiepilogo_iva * riep; TString16 cod; // Codice IVA corrente - TString80 key; - real sconto,iva; + real sconto; const int ndec = doc.decimals(); if (!_sco_imp_bill.ok() || !_sco_perc_bill.ok()) @@ -1426,8 +1412,7 @@ error_type TContabilizzazione::adjust_sconto_rows(TDocumento& doc) // Scorre tutti gli elementi della tabella IVA del documento (elementi per codice iva) for (riep = (TRiepilogo_iva*) aa.first_item(); riep != NULL; riep = (TRiepilogo_iva*) aa.succ_item()) { - const TCodiceIVA& codiva = riep->cod_iva(); - cod = codiva.codice(); // Codice IVA + cod = riep->cod_iva().codice(); // Codice IVA for (int i = 0; i < 2; i++) // Ciclo per sconto a percentuale (i == 0) e ad importo (i == 1) { //Importo sconto (sconto_perc() o sconto_imp()) @@ -1436,31 +1421,21 @@ error_type TContabilizzazione::adjust_sconto_rows(TDocumento& doc) //I conti per aggiustare l'iva vengono fatti in adjust_iva_rows() const bool perc = i == 0; TBill& conto = perc ? _sco_perc_bill : _sco_imp_bill; - sconto = perc ? riep->sconto_perc() : riep->sconto_imp(); - iva = codiva.imposta(sconto, ndec); + sconto = perc ? -riep->sconto_perc() : -riep->sconto_imp(); if (sconto != ZERO) { - key.format("6|%-4s|%c|%3d|%3d|%6ld",(const char*)cod, - conto.tipo(), - conto.gruppo(), - conto.conto(), - conto.sottoconto()); - const bool exists = _righe_iva.is_key(key); - // Aggiorna imponibile ed imposta all'elemento relativo - el_tmp.zero(); - TIVA_element& el = exists ? (TIVA_element&)_righe_iva[key] : el_tmp; - el.imp() += sconto; - el.iva() += iva; - el.ali() = codiva.percentuale(); - el.cod_iva() = cod; - _righe_iva.add(key,el,exists); + TRiga_documento r(&doc, "07"); // il tipo riga 02 spese a valore + r.put(RDOC_QTA, "1.00"); + r.put(RDOC_PREZZO, sconto); + r.put(RDOC_CODIVA, cod); + _righe_iva->add(r, conto, ndec); if (doc.tipo().calcolo_lordo()) // Si ricorda che calcolo_lordo() e fattura_commerciale() sono esclusivi. { // Totalizza per ogni codice iva il lordo if (!_totali_lordi.is_key(cod)) _totali_lordi.add(cod, new real); real& rl = (real&) _totali_lordi[cod]; - rl += sconto + iva; + rl += sconto + r.imposta(ndec); } } } @@ -1603,54 +1578,55 @@ error_type TContabilizzazione::adjust_iva_rows(TDocumento& doc) error_type TContabilizzazione::create_iva_rows(TDocumento& doc) { - const int items = _righe_iva.items(); + const int items = _righe_iva->items(); const bool in_valuta = doc.in_valuta(); TRectype& head = _movimento->curr(); - int gr,co; - long so; - char tipo; TToken_string key; TString_array key_arr; TString16 codiva; - TBill conto; - + TBill cur_conto; + char tipo; + int gruppo; + int conto; + long sottoconto; const int annoes = head.get_int(MOV_ANNOES); const long numreg = head.get_long(MOV_NUMREG); real cambio = head.get_real(MOV_CAMBIO); real imponibile,imposta; + TString16 valuta(doc.valuta()); - _righe_iva.get_keys(key_arr); + _righe_iva->get_keys(key_arr); key_arr.sort(); - TIVA_element cur; - TString16 valuta(doc.valuta()); + TRectype & cur = (TRectype &) (*_righe_iva)[key_arr.row(0)]; for (int i = 0, nr = 0; i < items; i++) { key = key_arr.row(i); - cur = (TIVA_element&) _righe_iva[key]; - codiva = key.get(1); - tipo = key.get_char(2); - gr = key.get_int(3); - co = key.get_int(4); - so = atol(key.get(5)); - conto.set(gr,co,so,tipo); - conto.find(); - imponibile = cur.imp(); + cur = (TRectype &) (*_righe_iva)[key]; + codiva = cur.get(RMI_CODIVA); + tipo = cur.get_char(RMI_TIPOC); + gruppo = cur.get_int(RMI_GRUPPO); + conto = cur.get_int(RMI_CONTO); + sottoconto = cur.get_long(RMI_SOTTOCONTO); + cur_conto.set(gruppo, conto, sottoconto, tipo); + cur_conto.find(); + + imponibile = cur.get_real(RMI_IMPONIBILE); + imposta = cur.get_real(RMI_IMPOSTA); + if (in_valuta) // I documenti vanno sempre contabilizzati in lire { - TCurrency_documento imponval(cur.imp(), doc); + TCurrency_documento imponval(imponibile, doc); imponval.change_to_firm_val(); imponibile = imponval.get_num(); // imponibile in lire - TCurrency_documento impval(cur.iva(), doc); + TCurrency_documento impval(imposta, doc); impval.change_to_firm_val(); imposta = impval.get_num(); // questa e' l'imposta ricalcolata } - else - imposta = cur.iva(); if (imponibile != ZERO && codiva.not_empty()) - { + { TRectype& rec_iva = _movimento->iva(nr); rec_iva.put(RMI_ANNOES,annoes); rec_iva.put(RMI_NUMREG,numreg); @@ -1658,13 +1634,16 @@ error_type TContabilizzazione::create_iva_rows(TDocumento& doc) rec_iva.put(RMI_CODIVA,codiva); rec_iva.put(RMI_IMPONIBILE,imponibile); rec_iva.put(RMI_IMPOSTA,imposta); - rec_iva.put(RMI_TIPOCR,conto.tipo_cr()); - rec_iva.put(RMI_INTRA,_caus->intra()); - rec_iva.put(RMI_TIPOC,conto.tipo()); - rec_iva.put(RMI_GRUPPO,conto.gruppo()); - rec_iva.put(RMI_CONTO,conto.conto()); - rec_iva.put(RMI_SOTTOCONTO,conto.sottoconto()); - nr++; + rec_iva.put(RMI_TIPOCR,cur_conto.tipo_cr()); + rec_iva.put(RMI_INTRA, _caus->intra()); + rec_iva.put(RMI_TIPOC, tipo); + rec_iva.put(RMI_GRUPPO, gruppo); + rec_iva.put(RMI_CONTO, conto); + rec_iva.put(RMI_SOTTOCONTO, sottoconto); + rec_iva.put(RMI_CODCMS, cur.get(RMI_CODCMS)); + rec_iva.put(RMI_FASCMS, cur.get(RMI_FASCMS)); + rec_iva.put(RMI_TIPODET, cur.get(RMI_TIPODET)); + nr++; } } return _error; @@ -1748,11 +1727,11 @@ error_type TContabilizzazione::compile_rows_mov(TDocumento& doc) } } - _righe_iva.destroy(); // resetta l'assoc_array delle righe di iva + _righe_iva->destroy(); // resetta l'assoc_array delle righe di iva _totali_lordi.destroy();// resetta l'assoc_array dei totali lordi for (int i=1; good() && i<=rows; i++) // browse all this fucked document rows { - TRiga_documento& r = doc[i]; + TRiga_documento & r = doc[i]; tiporiga = r.get(RDOC_TIPORIGA); _tri->put("CODTAB",tiporiga); if (_tri->read() == NOERR) // controlla l'esistenza della riga @@ -1779,12 +1758,59 @@ error_type TContabilizzazione::compile_rows_mov(TDocumento& doc) continue; r.put(RDOC_CODIVA, codiva1); - add_iva_row(conto, r, ALL_DECIMALS, perc); + _righe_iva->add(r, conto, ALL_DECIMALS, perc); } r.put(RDOC_CODIVA, codiva2); //Restore } else - add_iva_row(conto, r, ALL_DECIMALS, 1.0); + { + _righe_iva->add(r, conto); + const TString16 cod(r.get(RDOC_CODIVA)); + + if (r.doc().tipo().calcolo_lordo()) // Si ricorda che calcolo_lordo() e fattura_commerciale() sono esclusivi. + { + // Totalizza per ogni codice iva il lordo + if (!_totali_lordi.is_key(cod)) + _totali_lordi.add(cod, new real); + real& rl = (real&) _totali_lordi[cod]; + rl += r.imponibile(TRUE); + } + } + if (r.tipo().tipo() == RIGA_SPESEDOC && !_caus->intra()) + { + const char tipo_rit = r.spesa().tipo_ritenuta(); + + if (tipo_rit != '\0') + { + ((TSpesa_prest &)r.spesa()).zero("S9"); + ((TRiga_documento &)r).dirty_fields(); + TCurrency_documento c(r.imponibile()); + ((TRiga_documento &)r).dirty_fields(); + ((TSpesa_prest &)r.spesa()).put("S9", (char) tipo_rit); + TRectype & h = _movimento->lfile().curr(); + real val; + if (r.doc().in_valuta()) + { + val = h.get_real(MOV_TOTDOCVAL) - c.get_num(); + h.put(MOV_TOTDOCVAL, val); + } + c.change_to_firm_val(); + val = h.get_real(MOV_TOTDOC) - c.get_num(); + h.put(MOV_TOTDOC, val); + + if (tipo_rit == 'F') + { + val = h.get_real(MOV_RITFIS) + c.get_num(); + h.put(MOV_RITFIS, val); + } + else + if (tipo_rit == 'S') + { + val = h.get_real(MOV_RITSOC) + c.get_num(); + h.put(MOV_RITSOC, val); + } + } + } } } } @@ -1792,7 +1818,7 @@ error_type TContabilizzazione::compile_rows_mov(TDocumento& doc) _error = row_type_error; } - if (good() && _righe_iva.items() == 0) + if (good() && _righe_iva->items() == 0) _error = no_rows_error; // Crea le righe per le spese d'incasso e bolli @@ -1819,7 +1845,7 @@ error_type TContabilizzazione::compile_rows_mov(TDocumento& doc) { const TString descr_cr(doc.clifor().get(CLI_RAGSOC)); - switch (_movimento->recalc_cg_rows(descr_cr, _caus)) + switch (_movimento->recalc_cg_rows(descr_cr, *_caus)) { case 1 : _error = movement_error; @@ -2543,7 +2569,7 @@ error_type TContabilizzazione::write_pagamento_anticipo(TDocumento& doc) if (abb != ZERO) { // Reperisce il conto di contropartita per gli abbuoni dalla causale: 9 passivi 10 attivi - const int nrigc = new_ap == 'A' ? 10 : 9; + const int nrigc = new_ap == 'A' ? RIGA_ABBUONI_ATTIVI : RIGA_ABBUONI_PASSIVI; _caus->bill(nrigc, abb_bill); if (abb_bill.ok()) { @@ -2707,18 +2733,21 @@ error_type TContabilizzazione::write_intra(TDocumento& doc) ammvaluta += is_val ? imp_val.get_num() : ZERO; massakg += qta * rec_anamag.get_real(ANAMAG_MASSANUN); massaums += qta * rec_anamag.get_real(ANAMAG_UNSUPPUN); + if (rr.exist("VALSTAT")) - valstat += rr.get_real("VALSTAT"); + { + TCurrency_documento vstat(rr.get_real("VALSTAT"), doc); + vstat.change_to_firm_val(); + valstat += vstat.get_num(); + } else valstat += qta * rec_anamag.get_real(ANAMAG_VALSTATUN); - TCurrency_documento vstat(valstat, doc); - vstat.change_value(codvali, cambioi); rc->put("AMMLIRE", ammlire); rc->put("AMMVALUTA", ammvaluta); rc->put("MASSAKG", massakg); rc->put("MASSAUMS", massaums); - rc->put("VALSTAT", vstat.get_num()); + rc->put("VALSTAT", valstat); totale_righe += is_val ? imp_val.get_num() : imp.get_num(); } @@ -3047,6 +3076,7 @@ bool TContabilizzazione::elabora(TLista_documenti& doc_in, TLista_documenti& /* const long txt_pos = _viswin->lines(); TDocumento& doc = doc_in[i]; + msg = "Elaborazione documento "; msg << doc.anno() << ' '; msg << doc.numerazione() << '/'; @@ -3076,6 +3106,7 @@ bool TContabilizzazione::elabora(TLista_documenti& doc_in, TLista_documenti& /* if (good()) { compile_head_mov(doc); + if (good()) compile_rows_mov(doc); } @@ -3144,4 +3175,3 @@ bool TContabilizzazione::elabora(TLista_documenti& doc_in, TLista_documenti& /* return _can_write; // Se non ha riscontrato errori per nessun documento, _can_write = TRUE } - diff --git a/ve/velib04d.uml b/ve/velib04d.uml index 772a6cb80..d0cb31f50 100755 --- a/ve/velib04d.uml +++ b/ve/velib04d.uml @@ -14,7 +14,6 @@ END ENDPAGE - PAGE "Consegna Ordini" 11 60 14 GROUPBOX -1 78 6 diff --git a/ve/velib06a.cpp b/ve/velib06a.cpp index b20a92e8f..8c10aeedd 100755 --- a/ve/velib06a.cpp +++ b/ve/velib06a.cpp @@ -1051,14 +1051,17 @@ bool causmag_handler( TMask_field& f, KEY key ) if (c.empty()) { cache().discard("%CAU", causmag); - } else { + } + else + { if (c.has_default_mag() && row_mask.get(FR_CODMAG).empty()) { row_mask.set(FR_CODMAG, c.default_mag(), TRUE); row_mask.set(FR_CODDEPC, "", TRUE); } if (c.has_default_dep() && row_mask.get(FR_CODDEP).empty()) - row_mask.set(FR_CODDEP, c.default_dep(), TRUE); + row_mask.set(FR_CODDEP, c.default_dep(), TRUE); + if (!c.caus_collegata().empty()) { c = cache().get("%CAU", c.caus_collegata()); @@ -1068,7 +1071,23 @@ bool causmag_handler( TMask_field& f, KEY key ) row_mask.set(FR_CODDEPC, "", TRUE); } if (c.has_default_dep() && row_mask.get(FR_CODDEPC).empty()) - row_mask.set(FR_CODDEPC, c.default_dep(), TRUE); + row_mask.set(FR_CODDEPC, c.default_dep(), TRUE); + + static int copy_defmagc = -883; + if (copy_defmagc < 0) + { + TFilename fname = mask.doc().tipo().profile_name(); + fname.ext("ini"); + TConfig c_tipo_documento(fname,"MAIN"); + copy_defmagc = c_tipo_documento.get_bool("DEFMAGXCOLL"); + } + if (copy_defmagc!=0) + { + if (row_mask.get(FR_CODMAGC).empty()) + row_mask.set(FR_CODMAGC, mask.stdmag(), TRUE); + if (row_mask.get(FR_CODDEPC).empty()) + row_mask.set(FR_CODDEPC, mask.stddep(), TRUE); + } } } }