From b8d3d63b6cbda00945c477a6e888a2bec7ea0339 Mon Sep 17 00:00:00 2001 From: nik Date: Thu, 10 Nov 1994 11:43:40 +0000 Subject: [PATCH] Corretti da Parma lista movimenti , mastrini, stampa clienti/fornitori , giornale git-svn-id: svn://10.65.10.50/trunk@584 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg1200.cpp | 426 ++++++++-- cg/cg1200a.h | 7 +- cg/cg1200a.uml | 100 ++- cg/cg3100.cpp | 1923 +++++++++++++++++++++++++++------------------ cg/cg3100a.uml | 4 +- cg/cg3100c.uml | 14 +- cg/cg3200.cpp | 574 +++++++++----- cg/cg3200.h | 13 +- cg/cg3200a.uml | 291 ++++--- cg/cg3400.cpp | 60 +- include/causali.h | 1 + 11 files changed, 2196 insertions(+), 1217 deletions(-) diff --git a/cg/cg1200.cpp b/cg/cg1200.cpp index 252a3bbb9..1da5a87ba 100755 --- a/cg/cg1200.cpp +++ b/cg/cg1200.cpp @@ -11,9 +11,12 @@ #include #include #include -#include +#include + +#include "cg1.h" #include "cg1200a.h" -#include "cg1200b.h" +#include "cg1200b.h" +#include #define COMRF_ALIAS 50 #define COMNASC_ALIAS 51 @@ -23,6 +26,9 @@ enum pw { clienti = 1, fornitori = 2, both = 3 }; bool mask2_reset_fields(TMask_field& mf, KEY k); +extern char __tmp [MAXSTR]; +static TFixed_string tmp(__tmp, MAXSTR); + class CG1200_App : public TPrintapp { friend bool mask2_reset_fields(TMask_field& mf, KEY k); @@ -38,18 +44,22 @@ class CG1200_App : public TPrintapp TLocalisamfile* _comuni; // etichette - int _startrow, _rows_et, _cols_et, _startcol; + int _startrow, _rows_et, _cols_et, _startcol; // variable field slots - TString _piva, _cpercip, _fax, _telex, _name, _telefono, _indir, - _localita; - + TString _piva,_cpercip,_fax,_telex,_name,_telefono,_indir,_localita; + TString _cod_from,_cod_to,_data_stampa,_cofi,_d_c_ric,_d_alleg; + TString _datanas; + long _codice; + char _tipocf,_tipoaper; + bool _gia_iniziati_fornitori; public: virtual bool preprocess_page(int file, int counter); virtual bool preprocess_print(int file, int counter); virtual print_action postprocess_print(int file, int counter); + virtual void preprocess_header(); virtual void user_create(); virtual bool destroy(); virtual bool set_print(int); @@ -66,7 +76,13 @@ public: void set_rubriche(); void set_etichette(); void set_vendite(int f, int c) ; - void process_link(int id, const char* txt); + void process_link(int id, const char* txt); + void ultimo_codice(char tipo); + const char* compatta_ragsoc(TString& ragsoc,char tipoaper); + void header_elenco(); + void header_rubriche(); + const char* descrizione_conto_ric(int,int,long); + const char* descrizione_allegato(char,long); CG1200_App() : TPrintapp(),_piva(18), _cpercip(10), _fax(50), _telex(50), _name(60), _telefono(90), _indir(70), _localita(90) @@ -106,9 +122,46 @@ const char* CG1200_App::look_tab(const char* tabname, TString& cod, return tab.curr().get(fld); } +const char* CG1200_App::descrizione_conto_ric(int gruppo, int conto, long sottoc) +{ + TLocalisamfile pconti(LF_PCON, FALSE); + + pconti.setkey(1); + pconti.zero(); + pconti.put(PCN_GRUPPO, gruppo); + pconti.put(PCN_CONTO, conto); + pconti.put(PCN_SOTTOCONTO, sottoc); + pconti.read(); + if (pconti.bad()) + pconti.zero(); + tmp = pconti.get(PCN_DESCR); + + return (__tmp); +} + +const char* CG1200_App::descrizione_allegato(char tipocf,long cod) +{ + TLocalisamfile clifo(LF_CLIFO, FALSE); + + clifo.setkey(1); + clifo.zero(); + clifo.put(CLI_TIPOCF, tipocf); + clifo.put(CLI_CODCF , cod); + clifo.read(); + if (clifo.bad()) + clifo.zero(); + _tipoaper = clifo.get_char(CLI_TIPOAPER); + tmp = clifo.get(CLI_RAGSOC); + + return (__tmp); +} + bool CG1200_App::preprocess_page(int file, int counter) { TString s; + int g_ric,c_ric; + long s_ric,codall; + switch (file) { case LF_CLIFO: @@ -127,9 +180,13 @@ bool CG1200_App::preprocess_page(int file, int counter) return FALSE; } + _tipocf = current_cursor()->curr(LF_CLIFO).get_char(CLI_TIPOCF); + // set variable fields - _piva = get_field(LF_CLIFO, CLI_COFI); - if (_piva.empty()) _piva = get_field(LF_CLIFO, CLI_PAIV); + _cofi = get_field(LF_CLIFO, CLI_COFI); + //_piva = get_field(LF_CLIFO, CLI_COFI); + //if (_piva.empty()) _piva = get_field(LF_CLIFO, CLI_PAIV); + _piva = get_field(LF_CLIFO, CLI_PAIV); _telefono = get_field(LF_CLIFO, CLI_PTEL); if (!_telefono.empty()) _telefono << "/"; _telefono << get_field(LF_CLIFO, CLI_TEL) << " "; @@ -145,8 +202,31 @@ bool CG1200_App::preprocess_page(int file, int counter) _telex = get_field(LF_CLIFO, CLI_PTELEX); if (!_telex.empty()) _telex << "/"; _telex << get_field(LF_CLIFO, CLI_TELEX); - _indir = get_field(LF_CLIFO, CLI_INDCF); + _indir = get_field(LF_CLIFO, CLI_INDCF); + g_ric = atoi(get_field(LF_CLIFO, CLI_GRUPPORIC)); + c_ric = atoi(get_field(LF_CLIFO, CLI_CONTORIC)); + s_ric = atol(get_field(LF_CLIFO, CLI_SOTTOCRIC)); + codall = atol(get_field(LF_CLIFO, CLI_CODALLEG)); + _datanas = get_field(LF_CLIFO, CLI_DATANASC); + const TString16 tipoaper(get_field(LF_CLIFO, CLI_TIPOAPER)); + + _d_alleg = ""; + if (codall != 0) + { + _d_alleg = descrizione_allegato(_tipocf,codall); + if (_tipoaper == 'F') + { + TString surname = _d_alleg.mid(30,50); surname.trim(); + _d_alleg = _d_alleg.mid(0,30); _d_alleg.trim(); + _d_alleg << " " << surname; + } + } + _d_c_ric = descrizione_conto_ric(g_ric,c_ric,s_ric); + + _d_c_ric = _d_c_ric.mid(0,31); + _d_alleg = _d_alleg.mid(0,26); + if (!_indir.empty()) _indir << " "; _indir << get_field(LF_CLIFO, CLI_CIVCF); @@ -157,7 +237,7 @@ bool CG1200_App::preprocess_page(int file, int counter) _name = get_field(LF_CLIFO, CLI_RAGSOC); s = get_field(LF_CLIFO, CLI_CODANAGPER); _cpercip = ""; - const TString16 tipoaper(get_field(LF_CLIFO, CLI_TIPOAPER)); + if (s.not_empty()) _cpercip << tipoaper << " " << s; @@ -166,6 +246,21 @@ bool CG1200_App::preprocess_page(int file, int counter) TString surname = _name.mid(30,50); surname.trim(); _name = _name.mid(0,30); _name.trim(); _name << " " << surname; + } + + switch(_pr_type) + { + case elenco: + case rubriche: + if (_pr_what == both) + if (_tipocf == 'F' && !_gia_iniziati_fornitori) + { + _gia_iniziati_fornitori = TRUE; + printer().formfeed(); + } + break; + default: + break; } } break; @@ -198,22 +293,24 @@ default: print_action CG1200_App::postprocess_print(int file, int counter) { - static bool more = FALSE; - if (_pr_what == both) - { - if (more) - { - more = FALSE; - select_cursor(ccur()); - return NEXT_PAGE; - } - else - { - more = TRUE; - select_cursor(ccur()); - return REPEAT_PAGE; - } - } + /* + static bool more = FALSE; + if (_pr_what == both) + { + if (more) + { + more = FALSE; + select_cursor(ccur()); + return NEXT_PAGE; + } + else + { + more = TRUE; + select_cursor(ccur()); + return REPEAT_PAGE; + } + } + */ return NEXT_PAGE; } @@ -270,38 +367,223 @@ void CG1200_App::set_page(int file, int counter) } } -void CG1200_App::set_elenco() +void CG1200_App::ultimo_codice(char tipocf) +{ + TLocalisamfile clifo(LF_CLIFO,FALSE); + + char tipopr = tipocf; + + clifo.setkey(1); + clifo.zero(); + clifo.put(CLI_TIPOCF,tipocf); + + for (clifo.read();!clifo.eof();clifo.next()) + { + char tipo = clifo.get_char(CLI_TIPOCF); + + if (tipo != tipopr) break; + + _codice = clifo.get_long(CLI_CODCF); + } +} + +const char* CG1200_App::compatta_ragsoc(TString& ragsoc,char tipoa) +{ + if (tipoa == 'F') + { + TString80 cognome, nome; + cognome = ragsoc.mid(0,30); + nome = ragsoc.mid(30,20); + cognome.trim(); nome.trim(); + + ragsoc = cognome; + ragsoc << " " << nome; + } + + tmp = ragsoc; + + return (__tmp); +} + +void CG1200_App::preprocess_header() +{ + switch(_pr_type) + { + case elenco: + header_elenco(); + break; + case rubriche: + header_rubriche(); + break; + default: + break; + } +} + +void CG1200_App::header_elenco() { reset_header(); // intestazione - const long firm = get_firm(); + const long firm = get_firm(); + TString var; + int j = 1; + char tipocf; TLocalisamfile ditte(LF_NDITTE); ditte.zero(); ditte.put(NDT_CODDITTA, firm); ditte.read(); if (ditte.bad()) ditte.zero(); TString s(ditte.get(NDT_RAGSOC)); - set_header(1, "Ditta %ld %s @102gData @<@125gPag @#", firm, (const char*) s); - set_header(2, "Elenco %s",(_pr_what == both ? "Clienti+Fornitori" : - (_pr_what == clienti ? "Clienti" : "Fornitori"))); - set_header(3, (const char *)(TString(132).fill('-'))); - set_header(4, " Codice Ragione sociale"); - set_header(5, "@9gIndirizzo@59gC.A.P.@66gLocalita'"); - set_header(6, "@9gTelefoni@91gFAX @115gTelex"); - set_header(7, "@9gLuogo di nascita@46gData" - "@56gPartita IVA Codice fiscale@93gConto di costo/ricavo@115gC.allegato@126gPerc.770"); - set_header(8, (const char *)(TString(132).fill('-'))); + + set_header(j, "Ditta %ld %s@125gPag @#", firm, (const char*) s); + set_header(j++, "@102gData %s", (const char*) _data_stampa); + /* + if (_pr_what == both) + { + current_cursor()->save_status(); + ++(*current_cursor()); + tipocf = current_cursor()->curr(LF_CLIFO).get_char(CLI_TIPOCF); + --(*current_cursor()); + current_cursor()->restore_status(); + } + else + */ + tipocf = current_cursor()->curr(LF_CLIFO).get_char(CLI_TIPOCF); + + if (tipocf == 'C') + var = "Clienti"; + else + if (tipocf == 'F') + var = "Fornitori"; + + set_header(j, "Elenco %s",(const char*) var); + + if (_sort == 1) + var = "Ordine di codice"; + else + var = "Ordine alfabetico"; + + set_header(j, "@30g%s", (const char*) var); + + if (_mov_only) + set_header(j, "@55gSolo i movimentati"); + + ultimo_codice(_tipocf); + + set_header(j++, "@102gUltimo cod.utilizzato %ld" , _codice); + + if (_pr_what != both) + { + if (_cod_from.not_empty() || _cod_to.not_empty()) + { + set_header(j, "Estremi selezione"); + if (_cod_from.not_empty()) + set_header(j, " da %s", (const char*) _cod_from); + if (_cod_to.not_empty()) + if (_sort == 1) + set_header(j, " a %s", (const char*) _cod_to); + else + set_header(j, " a %s", (const char*) _cod_to); + j++; + } + } + + set_header(j++, (const char *)(TString(132).fill('-'))); + set_header(j++, " Codice Ragione sociale"); + set_header(j++, "@9gIndirizzo@56gC.A.P.@63gLocalita'"); + set_header(j++, "@9gTelefoni@90gFAX @115gTelex"); + set_header(j++, "@9gLuogo di nascita@45gData@56gPartita IVA Codice fiscale"); + set_header(j++, "@9gConto di costo/ricavo@56gCodice allegato@90gPercipiente 770"); + set_header(j, (const char *)(TString(132).fill('-'))); +} + +void CG1200_App::header_rubriche() +{ + reset_header(); + // intestazione + const long firm = get_firm(); + TString var; + int j = 1; + char tipocf; + TLocalisamfile ditte(LF_NDITTE); + ditte.zero(); + ditte.put(NDT_CODDITTA, firm); + ditte.read(); + if (ditte.bad()) ditte.zero(); + TString s(ditte.get(NDT_RAGSOC)); + set_header(j, "Ditta %ld %s@125gPag @#", firm, (const char*) s); + set_header(j++, "@102gData %s", (const char*) _data_stampa); + /* + if (_pr_what == both) + { + current_cursor()->save_status(); + ++(*current_cursor()); + tipocf = current_cursor()->curr(LF_CLIFO).get_char(CLI_TIPOCF); + --(*current_cursor()); + current_cursor()->restore_status(); + } + else + */ + tipocf = current_cursor()->curr(LF_CLIFO).get_char(CLI_TIPOCF); + + if (tipocf == 'C') + var = "Clienti"; + else + if (tipocf == 'F') + var = "Fornitori"; + + set_header(j, "Rubrica %s",(const char*) var); + + if (_sort == 1) + var = "Ordine di codice"; + else + var = "Ordine alfabetico"; + + set_header(j, "@30g%s", (const char*) var); + + if (_mov_only) + set_header(j, "@55gSolo i movimentati"); + + ultimo_codice(_tipocf); + + set_header(j++, "@102gUltimo cod.utilizzato %ld" , _codice); + + if (_pr_what != both) + { + if (_cod_from.not_empty() || _cod_to.not_empty()) + { + set_header(j, "Estremi selezione"); + if (_cod_from.not_empty()) + set_header(j, " da %s", (const char*) _cod_from); + if (_cod_to.not_empty()) + if (_sort == 1) + set_header(j, " a %s", (const char*) _cod_to); + else + set_header(j, " a %s", (const char*) _cod_to); + j++; + } + } + + set_header(j++, (const char *)(TString(132).fill('-'))); + set_header(j++, " Codice Ragione sociale@60gIndirizzo@100gC.A.P.@106gLocalita'@127gProv."); + set_header(j++, "@9gPartita iva@25gTelefoni"); + set_header(j++, (const char *)(TString(132).fill('-'))); +} + +void CG1200_App::set_elenco() +{ // body set_row(1,"$[r]@1s$[n] $[r]@pn$[n] #t", FLD(LF_CLIFO, CLI_TIPOCF), FLD(LF_CLIFO, CLI_CODCF,"@@@@@@"), &_name); - set_row(2,"@9g#t@59g@s@66g#t@s @s", &_indir, FLD(LF_CLIFO, CLI_CAPCF), + set_row(2,"@9g#t@56g@s@63g#t @s @s", &_indir, FLD(LF_CLIFO, CLI_CAPCF), &_localita, FLD(-COMRF_ALIAS,COM_DENCOM), FLD(-COMRF_ALIAS,COM_PROVCOM)); set_row(3,"@9g#t@90g#t@115g#t", &_telefono, &_fax, &_telex); - set_row(4,"@9g@s @s@46g@ld@56g#t@92g@3n @3n @6n@115g@n@126g#t", - FLD(-COMNASC_ALIAS, COM_DENCOM), FLD(-COMNASC_ALIAS, COM_PROVCOM), - FLD(LF_CLIFO, CLI_DATANASC), &_piva, FLD(LF_CLIFO,CLI_GRUPPORIC), - FLD(LF_CLIFO,CLI_CONTORIC), FLD(LF_CLIFO, CLI_SOTTOCRIC), - FLD(LF_CLIFO, CLI_CODALLEG), &_cpercip); + set_row(4,"@9g@s @s@45g#t@56g#t@69g#t",FLD(-COMNASC_ALIAS, COM_DENCOM), + FLD(-COMNASC_ALIAS, COM_PROVCOM), &_datanas, &_piva,&_cofi); + + set_row(5,"@9g@3n @3n @6n #t@56g@n #t@90g#t",FLD(LF_CLIFO,CLI_GRUPPORIC), + FLD(LF_CLIFO,CLI_CONTORIC), FLD(LF_CLIFO, CLI_SOTTOCRIC),&_d_c_ric, + FLD(LF_CLIFO, CLI_CODALLEG), &_d_alleg, &_cpercip); for(int i = 0; i < _interline; i++) set_row(i+5,""); @@ -309,29 +591,12 @@ void CG1200_App::set_elenco() void CG1200_App::set_rubriche() { - reset_header(); - // intestazione - const long firm = get_firm(); - TLocalisamfile ditte(LF_NDITTE); - ditte.zero(); - ditte.put(NDT_CODDITTA, firm); - ditte.read(); - if (ditte.bad()) ditte.zero(); - TString s(ditte.get(NDT_RAGSOC)); - set_header(1, "Ditta %ld %s @102gData @<@125gPag @#", firm, (const char*) s); - set_header(2, "Rubrica %s",(_pr_what == both ? "Clienti+Fornitori" : - (_pr_what == clienti ? "Clienti" : "Fornitori"))); - set_header(3, (const char *)(TString(132).fill('-'))); - set_header(4, " Codice Ragione sociale"); - set_header(5, "@9gIndirizzo@59gC.A.P.@66gLocalita'"); - set_header(6, "@9gTelefoni@91gFAX @115gTelex"); - set_header(7, (const char *)(TString(132).fill('-'))); // body set_row(1,"$[r]@1s$[n] $[r]@pn$[n] #t", FLD(LF_CLIFO,CLI_TIPOCF), FLD(LF_CLIFO,CLI_CODCF,"@@@@@@"), &_name); - set_row(2,"@9g#t@59g@s@66g#t@s @s", &_indir, FLD(LF_CLIFO, CLI_CAPCF), - &_localita, FLD(-COMRF_ALIAS,COM_DENCOM), FLD(-COMRF_ALIAS,COM_PROVCOM)); - set_row(3,"@9g#t@90g#t@115g#t", &_telefono, &_fax, &_telex); + set_row(1,"@60g#t@100g@s@106g#t @127g@s", &_indir, FLD(LF_CLIFO, CLI_CAPCF), + &_localita, FLD(-COMRF_ALIAS,COM_PROVCOM)); + set_row(2,"@9g#t@25g#t", &_piva,&_telefono); for(int i = 0; i < _interline; i++) set_row(i+4,""); @@ -569,10 +834,16 @@ bool CG1200_App::set_print(int) enable_link("Collegamento clienti e fornitori : ", 'r'); } - _sort = mask.get_int(RDB_CG12_SORT); - _pr_what = (pw) mask.get_int(RDB_CG12_TYPE); - _interline = mask.get_int(LST_CG12_INTERLINE); - _mov_only = mask.get_bool(CHK_CG12_MOVIM); + _sort = mask.get_int(RDB_CG12_SORT); + _pr_what = (pw) mask.get_int(RDB_CG12_TYPE); + _interline = mask.get_int(LST_CG12_INTERLINE); + _mov_only = mask.get_bool(CHK_CG12_MOVIM); + char tipoafr = mask.get(F_TIPOAPERFR)[0]; + char tipoato = mask.get(F_TIPOAPERTO)[0]; + TDate data_stampa (mask.get(F_DATA_STAMPA)); + _data_stampa = data_stampa.string(); + _codice = 0; + _gia_iniziati_fornitori = FALSE; select_cursor(ccur()); @@ -600,11 +871,22 @@ bool CG1200_App::set_print(int) toid = (_pr_what == clienti) ? FLD_CLI_RAGSOCTO : FLD_FOR_RAGSOCTO; nome_campo = CLI_RAGSOC; } - const TString16 cod_from(mask.get(fromid)); - const TString16 cod_to(mask.get(toid)); - + TString cod_from(mask.get(fromid)); + TString cod_to(mask.get(toid)); + if (cod_from.not_empty()) tr1.put(nome_campo, cod_from); if (cod_to.not_empty()) tr2.put(nome_campo, cod_to); + + if (_sort == 1) + { + _cod_from = cod_from; + _cod_to = cod_to; + } + else + { + _cod_from = compatta_ragsoc(cod_from,tipoafr); + _cod_to = compatta_ragsoc(cod_to,tipoato); + } } current_cursor()->setregion(tr1, tr2); diff --git a/cg/cg1200a.h b/cg/cg1200a.h index 3d413afc3..131c58521 100755 --- a/cg/cg1200a.h +++ b/cg/cg1200a.h @@ -14,5 +14,10 @@ #define BUT_CG12_ELENCO 115 #define BUT_CG12_RUBRICHE 116 #define BUT_CG12_ETICHETTE 117 -#define BUT_CG12_VENDITE 118 +#define BUT_CG12_VENDITE 118 +#define F_CODDITTA 119 +#define F_RAGSOC 120 +#define F_DATA_STAMPA 121 +#define F_TIPOAPERFR 122 +#define F_TIPOAPERTO 123 diff --git a/cg/cg1200a.uml b/cg/cg1200a.uml index 5e185ea07..1c47aada7 100755 --- a/cg/cg1200a.uml +++ b/cg/cg1200a.uml @@ -1,10 +1,36 @@ #include "cg1200a.h" #include -PAGE "Selezione" -1 -1 70 17 +PAGE "Selezione" -1 -1 70 20 + +NUMBER F_CODDITTA 5 +BEGIN + PROMPT 2 1 "Ditta " + FLAGS "FRD" + USE LF_NDITTE KEY 1 + CHECKTYPE REQUIRED + INPUT CODDITTA F_CODDITTA + DISPLAY "Codice" CODDITTA + DISPLAY "Ragione sociale @50" RAGSOC + OUTPUT F_CODDITTA CODDITTA + OUTPUT F_RAGSOC RAGSOC +END + +STRING F_RAGSOC 50 +BEGIN + PROMPT 2 2 "Ragione sociale " + FLAGS "D" +END + +DATE F_DATA_STAMPA +BEGIN + PROMPT 42 1 "Data di stampa " + FLAGS "A" +END + RADIOBUTTON RDB_CG12_TYPE 22 BEGIN - PROMPT 4 1 "Oggetto" + PROMPT 4 4 "Oggetto" HELP "Selezionare l'archivio che si desidera stampare" ITEM "1|Clienti" MESSAGE RESET,2@|SHOW,1@|HIDE,2@ ITEM "2|Fornitori" MESSAGE RESET,1@|SHOW,2@|HIDE,1@ @@ -13,7 +39,7 @@ END RADIOBUTTON RDB_CG12_SORT 22 BEGIN - PROMPT 4 6 "Ordinamento" + PROMPT 4 9 "Ordinamento" HELP "Selezionare il tipo di ordinamento dei record stampati" ITEM "1|per Codice" MESSAGE CLEAR,4@|ENABLE,3@ ITEM "2|per Ragione Sociale" MESSAGE CLEAR,3@|ENABLE,4@ @@ -21,32 +47,32 @@ END GROUPBOX DLG_NULL 35 10 BEGIN - PROMPT 32 1 "Selezione " + PROMPT 32 4 "Selezione " END TEXT DLG_NULL BEGIN - PROMPT 34 5 "da Ragione Sociale/Nominativo" + PROMPT 34 8 "da Ragione Sociale/Nominativo" END TEXT DLG_NULL BEGIN - PROMPT 34 7 "a Ragione Sociale/Nominativo" + PROMPT 34 10 "a Ragione Sociale/Nominativo" END TEXT DLG_NULL BEGIN - PROMPT 34 2 "da Codice" + PROMPT 34 5 "da Codice" END TEXT DLG_NULL BEGIN - PROMPT 48 2 "a Codice" + PROMPT 48 5 "a Codice" END STRING FLD_CLI_CODFR 5 BEGIN - PROMPT 34 3 "" + PROMPT 34 6 "" USE LF_CLIFO KEY 1 INPUT TIPOCF "C" INPUT CODCF FLD_CLI_CODFR @@ -60,7 +86,7 @@ END STRING FLD_CLI_CODTO 5 BEGIN - PROMPT 48 3 "" + PROMPT 48 6 "" COPY USE FLD_CLI_CODFR INPUT TIPOCF "C" INPUT CODCF FLD_CLI_CODTO @@ -74,7 +100,7 @@ END STRING FLD_CLI_RAGSOCFR 50 29 BEGIN - PROMPT 34 6 "" + PROMPT 34 9 "" USE LF_CLIFO KEY 2 INPUT TIPOCF "C" INPUT RAGSOC FLD_CLI_RAGSOCFR @@ -82,17 +108,20 @@ BEGIN DISPLAY "Codice" CODCF DISPLAY "Codice Fiscale@16" COFI OUTPUT FLD_CLI_RAGSOCFR RAGSOC + OUTPUT F_TIPOAPERFR TIPOAPER GROUP 1 4 HELP "Introdurre rag. soc. di inizio stampa: vuoto = inizio archivio" END STRING FLD_CLI_RAGSOCTO 50 29 BEGIN - PROMPT 34 8 "" - COPY USE FLD_CLI_RAGSOCFR + PROMPT 34 11 "" + COPY USE FLD_CLI_RAGSOCFR + INPUT TIPOCF "C" INPUT RAGSOC FLD_CLI_RAGSOCTO COPY DISPLAY FLD_CLI_RAGSOCFR - OUTPUT FLD_CLI_RAGSOCTO RAGSOC + OUTPUT FLD_CLI_RAGSOCTO RAGSOC + OUTPUT F_TIPOAPERTO TIPOAPER GROUP 1 4 HELP "Introdurre ragione soc. di fine stampa: vuoto = fine archivio" STR_EXPR {(#THIS_FIELD == "") || (#THIS_FIELD >= #FLD_CLI_RAGSOCFR)} @@ -101,7 +130,7 @@ END STRING FLD_FOR_CODFR 5 BEGIN - PROMPT 34 3 "" + PROMPT 34 6 "" COPY USE FLD_CLI_CODFR INPUT TIPOCF "F" INPUT CODCF FLD_FOR_CODFR @@ -113,7 +142,7 @@ END STRING FLD_FOR_CODTO 5 BEGIN - PROMPT 48 3 "" + PROMPT 48 6 "" COPY USE FLD_FOR_CODFR INPUT TIPOCF "F" INPUT CODCF FLD_FOR_CODTO @@ -127,38 +156,53 @@ END STRING FLD_FOR_RAGSOCFR 50 29 BEGIN - PROMPT 34 6 "" + PROMPT 34 9 "" USE LF_CLIFO KEY 2 INPUT TIPOCF "F" INPUT RAGSOC FLD_FOR_RAGSOCFR COPY DISPLAY FLD_CLI_RAGSOCFR OUTPUT FLD_FOR_RAGSOCFR RAGSOC + OUTPUT F_TIPOAPERFR TIPOAPER GROUP 2 4 HELP "Introdurre rag. soc. di inizio stampa: vuoto = inizio archivio" END STRING FLD_FOR_RAGSOCTO 50 29 BEGIN - PROMPT 34 8 "" - COPY USE FLD_FOR_RAGSOCFR + PROMPT 34 11 "" + COPY USE FLD_FOR_RAGSOCFR + INPUT TIPOCF "F" INPUT RAGSOC FLD_FOR_RAGSOCTO COPY DISPLAY FLD_CLI_RAGSOCFR - OUTPUT FLD_FOR_RAGSOCTO RAGSOC + OUTPUT FLD_FOR_RAGSOCTO RAGSOC + OUTPUT F_TIPOAPERTO TIPOAPER GROUP 2 4 HELP "Introdurre ragione soc. di fine stampa: vuoto = fine archivio" STR_EXPR {(#THIS_FIELD == "") || (#THIS_FIELD >= #FLD_FOR_RAGSOCFR)} WARNING "Limite superiore errato" END + +STRING F_TIPOAPERFR 1 +BEGIN + PROMPT 1 1 "" + FLAGS "HD" +END + +STRING F_TIPOAPERTO 1 +BEGIN + PROMPT 2 2 "" + FLAGS "HD" +END BOOLEAN CHK_CG12_MOVIM BEGIN - PROMPT 4 10 "Solo movimentati" + PROMPT 4 13 "Solo movimentati" HELP "Selezionare per stampare solo inclusi archivio movimenti" END LIST LST_CG12_INTERLINE 1 BEGIN - PROMPT 4 11 "Righe interlinea " + PROMPT 4 14 "Righe interlinea " ITEM "0|0" ITEM "1|1" ITEM "2|2" @@ -167,36 +211,36 @@ END GROUPBOX DLG_NULL 51 4 BEGIN - PROMPT 2 13 "Stampa" + PROMPT 2 16 "Stampa" END BUTTON BUT_CG12_ELENCO 9 2 BEGIN - PROMPT 4 14 "~Elenco" + PROMPT 4 17 "~Elenco" MESSAGE EXIT,BUT_CG12_ELENCO END BUTTON BUT_CG12_RUBRICHE 9 2 BEGIN - PROMPT 16 14 "~Rubriche" + PROMPT 16 17 "~Rubriche" MESSAGE EXIT,BUT_CG12_RUBRICHE END BUTTON BUT_CG12_ETICHETTE 9 2 BEGIN - PROMPT 28 14 "E~tichette" + PROMPT 28 17 "E~tichette" MESSAGE EXIT,BUT_CG12_ETICHETTE END BUTTON BUT_CG12_VENDITE 9 2 BEGIN - PROMPT 40 14 "~Vendite" + PROMPT 40 17 "~Vendite" MESSAGE EXIT,BUT_CG12_VENDITE END BUTTON DLG_QUIT 9 2 BEGIN - PROMPT 55 14 "" + PROMPT 55 17 "" END ENDPAGE diff --git a/cg/cg3100.cpp b/cg/cg3100.cpp index 1254312b0..9b27bcc4e 100755 --- a/cg/cg3100.cpp +++ b/cg/cg3100.cpp @@ -6,7 +6,7 @@ #include #include #include - +#include #include #include @@ -15,14 +15,15 @@ #include #include #include +#include #include #include #include -#include #include "cg3.h" #include "cg3100.h" #include "cglib03.h" +#include "cg2103.h" static TString256 TMP; @@ -38,6 +39,36 @@ bool annoes (TMask_field&, KEY); bool data_inizio (TMask_field&, KEY); bool data_fine (TMask_field&, KEY); +HIDDEN int date2esc(const TDate& d, int* prevesc = NULL); + +HIDDEN const char* err_msg[] = {"La data operazione non appartiene a nessun esercizio", + "Anno IVA non compatibile con data operazione", + "Data operazione successiva all'anno di competenza", + "Movimento con competenza anno precedente", + "La data di competenza non appartiene a nessun esercizio", + "Data competenza incompatibile con data operazione", + "Anno esercizio incompatibile con data competenza", + "Codice causale non presente in tabella", + "Codice causale sospeso" + "Nella causale e' stato attivato il segnale non va in allegato", + "Tipo documento non presente in tabella", + "Tipo documento non corrisponde a quello indicato in causale", + "Codice registro non corrisponde a quello indicato in causale", + "Codice registro non presente in tabella", + "Codice registro sospeso" + "Tipo registro incompatibile con tipo documento", + "Non indicato codice cliente/fornitore", + "Tipo cliente/fornitore non compatibile con tipo registro", + "Codice cliente/fornitore sospeso", + "Nel cliente/fornitore e' stato attivato il segnale: non va in allegato", + "Indicato codice C/F per allegato che richiama se stesso", + "Indicato codice C/F per allegato sospeso", + "C/F per allegato riporta un altro C/F per allegato", + "Indicato codice C/F per allegato con segnale: non va in allegato", + "Indicato codice C/F per allegato non presente in anagrafica", + "Codice cliente/fornitore non presente in anagrafica"}; + + class CG3100_application : public TPrintapp { friend bool filter_func (const TRelation *); @@ -48,27 +79,28 @@ class CG3100_application : public TPrintapp TRigaiva_array _c; TTable * _tabiva, * _tabtpd, * _tabreg, * _tabes; - TLocalisamfile * _caus,* _comuni,* _rmoviva, * _clifo, * _pcon, * _attiv, *_nditte; + TLocalisamfile * _caus,* _comuni,* _rmoviva, * _clifo, * _pcon, * _attiv, *_nditte, *_saldi; TRelation * _relmov,* _relmov1,* _relmov2,* _relmov3; TCursor * _curr1, * _curr2, * _curr3; - TDate _data_ini, _data_fin, _datareg, _data_prec; - TString _descr, _descr_doc, _descr_causale, _totali_a, _totali_d; - TString _totalegen_dare, _totalegen_avere, _tipo_ini, _masc, _causale; + TBit_array _err; + TDate _data_ini, _data_fin, _datareg, _data_prec, _datacomp; + TString _descr, _descr_doc, _descr_causale; + TString _tipo_ini, _masc, _causale; TString _causale_ini, _causale_fin, _registro,_registro_ini, _registro_fin; TString _tipoatt, _tipo_elenco,_tipo_clifo_prec,_cod,_tipoelsucc; - TString _appoggio, _tipodoc, _tipodocumento, _err1, _msg, _err, _err2, _err3; + TString _appoggio, _tipodoc, _tipodocumento; TString _ragsoc, _indcf, _civcf, _paiv, _codcaus, _dencom, _provcom, _cofi; - TString _capcf, _codval, _simbolo, _statocf, _comcf, _tipo_fin; - TString _reg_causale; - long _documenti, _codice_ini, _codice_fin, _numero_reg,_codcf; + TString _capcf, _codval, _simbolo, _statocf, _comcf, _tipo_fin, _reg_causale; + long _documenti, _codice_ini, _codice_fin, _numero_reg, _codcf; long _numreg, _numreg_fin, _numreg_ini, _codalleg, _numeroregp,_codclifosucc; - long _codcf_prec, _numr; - int _anno, _annoes; + long _codcf_prec, _numr, _numero; + int _ae, _anno, _annoes, _annoeser; + char _tipo; real _totdocumenti, _totdoc, _totimponibile, _totimposta, _importo; real _op_esenti, _op_non_imp, _impo, _impos; real _tot_dare, _tot_avere, _tot_avere_giornaliero; real _tot_dare_giornaliero, _tot_dare_generale, _tot_avere_generale; - bool _intracom, _no_preprocess_page, _salto_pagina, _stampa_anno_comp; + bool _intracom, _no_preprocess_page, _salto_pagina, _stampa_anno_comp,_esiste_riga_iva,_nonesiste_riga_iva; bool _stampa_parte_iva,_alleg_causale,_stampa_mess_alleg_iva,_allegb,_ricser; bool _settata_prima_riga, _causale_gia_stampata; int _cur1,_cur2,_cur2b,_cur3,_cur4,_decidi,_tipod,_controllo_mov_errati; @@ -91,17 +123,38 @@ public: void user_destroy(); bool segnala_errori_primariga(); bool segnala_errori_ogniriga(); + bool segnala_errori_iva(); + bool contropartita(int); void stampa_errori_rmov(); - void stampa_errori_mov(); + void stampa_errori_mov(); + void stampa_errori_iva(int*,const char*,const int,const int); + void stampa_errori_contropartita(int); void stampa_intestazione(); void incrementa_totali(); void compila_clifo(); void compila_comuni(); -// int my_next (TLocalisamfile&); - - CG3100_application() {} + bool RicercaDoc(const char*); + + CG3100_application(): _err(80) {} + virtual ~CG3100_application() {} }; +HIDDEN int date2esc(const TDate& d, int* prevesc) +{ + if (prevesc) *prevesc = 0; + TTable esc("ESC"); + for (int err = esc.first(); err == NOERR; err = esc.next()) + { + const TDate ia(esc.get("D0")); // Data inizio esercizio + const TDate fa(esc.get("D1")); // Data fine esercizio + const anno = esc.get_int("CODTAB"); + if (d >= ia && d <= fa) + return anno; + if (prevesc) *prevesc = anno; + } + return 0; +} + TDate InizioEsercizio(int anno) { TTable TabEs ("ESC"); @@ -113,7 +166,7 @@ TDate InizioEsercizio(int anno) TabEs.put ("CODTAB", codtab); TabEs.read(); if (TabEs.good()) - inizio_es= TabEs.get_date ("D0"); + inizio_es= TabEs.get_date ("D0"); return inizio_es; } @@ -129,7 +182,7 @@ TDate FineEsercizio(int anno) TabEs.put ("CODTAB", codtab); TabEs.read(); if (TabEs.good()) - fine_es = TabEs.get_date ("D1"); + fine_es = TabEs.get_date ("D1"); else fine_es = botime; return fine_es; @@ -145,7 +198,7 @@ bool annoes(TMask_field& f, KEY k) f.mask().field(F_DATAINI).set(InizioEsercizio(anno)); TDate fine = FineEsercizio(anno + 1); if (fine == botime) - fine = FineEsercizio(anno); + fine = FineEsercizio(anno); f.mask().field(F_DATAFIN).set(fine); } } @@ -162,18 +215,18 @@ bool data_inizio(TMask_field& f, KEY k) int anno = f.mask().get_int (F_ANNO); TDate data = f.mask().get(F_DATAINI); if (app->_masc == "cg3100a") - decidi = f.mask().get_int (F_DECIDI); + decidi = f.mask().get_int (F_DECIDI); if ( anno != 0 && ( (app->_masc == "cg3100b") || - ((app->_masc == "cg3100a" ) && (decidi == 2)) ) ) + ((app->_masc == "cg3100a" ) && (decidi == 2)) ) ) { if (!data.ok()) //se la data e' vuota - f.mask().field(F_DATAINI).set(InizioEsercizio(anno)); - else - if (data < InizioEsercizio(anno)) - { - f.error_box("La data indicata non deve essere inferiore alla data di inizio esercizio"); - return FALSE; - } + f.mask().field(F_DATAINI).set(InizioEsercizio(anno)); +else + if (data < InizioEsercizio(anno)) + { + f.error_box("La data indicata non deve essere inferiore alla data di inizio esercizio"); + return FALSE; + } } } return TRUE; @@ -190,34 +243,49 @@ bool data_fine(TMask_field& f, KEY k) TDate dataini = f.mask().get(F_DATAINI); TDate datafin = f.mask().get(F_DATAFIN); if (app->_masc == "cg3100a") - decidi = f.mask().get_int (F_DECIDI); + decidi = f.mask().get_int (F_DECIDI); if ( (app->_masc == "cg3100b") || - ((app->_masc == "cg3100a" ) && (decidi == 2)) ) - if ( dataini.ok() && datafin.ok() ) - if (dataini > datafin) - { - f.error_box("La data iniziale non deve essere superiore alla data finale"); - return FALSE; - } + ((app->_masc == "cg3100a" ) && (decidi == 2)) ) + if ( dataini.ok() && datafin.ok() ) + if (dataini > datafin) + { + f.error_box("La data iniziale non deve essere superiore alla data finale"); + return FALSE; + } if ( anno != 0 && ( (app->_masc == "cg3100b") || - ((app->_masc == "cg3100a" ) && (decidi == 2)) ) ) + ((app->_masc == "cg3100a" ) && (decidi == 2)) ) ) { TDate fine = FineEsercizio(anno + 1); if (fine == botime) - fine = FineEsercizio(anno); + fine = FineEsercizio(anno); if (!datafin.ok()) //se la data e' vuota - f.mask().field(F_DATAFIN).set(fine); - else - if (datafin > fine) - { - f.error_box("La data indicata non deve essere superiore alla data di fine esercizio successivo, oppure, in caso questo non esista, dell'esercizio indicato"); - return FALSE; - } + f.mask().field(F_DATAFIN).set(fine); +else + if (datafin > fine) + { + f.error_box("La data indicata non deve essere superiore alla data di fine esercizio successivo, oppure, in caso questo non esista, dell'esercizio indicato"); + return FALSE; + } } } return TRUE; } +bool CG3100_application::RicercaDoc(const char * tipo) +{ + TTable tab_tpd(TAB_TPD); + TString codtab = format ("%-2s", tipo); + + tab_tpd.zero(); + + tab_tpd.put("CODTAB", codtab); + tab_tpd.read(); + if (tab_tpd.good()) + return TRUE; + else + return FALSE; +} + void CG3100_application::compila_clifo() { _clifo->setkey(1); @@ -227,16 +295,29 @@ void CG3100_application::compila_clifo() _clifo->read(); if (_clifo->bad()) _clifo->zero(); - _alleg = _clifo->curr().get_int(CLI_ALLEG); - _statocf = _clifo->curr().get(CLI_STATOCF); - _comcf = _clifo->curr().get(CLI_COMCF); - _ragsoc = _clifo->curr().get(CLI_RAGSOC); - _indcf = _clifo->curr().get(CLI_INDCF); - _civcf = _clifo->curr().get(CLI_CIVCF); - _paiv = _clifo->curr().get(CLI_PAIV); - _capcf = _clifo->curr().get(CLI_CAPCF); - _cofi = _clifo->curr().get(CLI_COFI); - _codalleg = _clifo->curr().get_long(CLI_CODALLEG); + else + { + char tipoa = _clifo->curr().get_char("TIPOAPER"); + _alleg = _clifo->curr().get_int(CLI_ALLEG); + _statocf = _clifo->curr().get(CLI_STATOCF); + _comcf = _clifo->curr().get(CLI_COMCF); + _ragsoc = _clifo->curr().get(CLI_RAGSOC); + if (tipoa == 'F') + { + TString80 cognome, nome; + cognome = _ragsoc.mid(0,30); + nome = _ragsoc.mid(30,20); + cognome.trim(); nome.trim(); + _ragsoc = cognome; + _ragsoc << " " << nome; + } + _indcf = _clifo->curr().get(CLI_INDCF); + _civcf = _clifo->curr().get(CLI_CIVCF); + _paiv = _clifo->curr().get(CLI_PAIV); + _capcf = _clifo->curr().get(CLI_CAPCF); + _cofi = _clifo->curr().get(CLI_COFI); + _codalleg = _clifo->curr().get_long(CLI_CODALLEG); + } } void CG3100_application::compila_comuni() @@ -274,9 +355,11 @@ const int AllegClifo (int gruppo, int conto, long sottoconto) const char * DescrConto (long gruppo, long conto, long sottoconto, const char* tipocf) { - TLocalisamfile pcon(LF_PCON); + TString80 ragsoc; + const char* desc = NULL; + TLocalisamfile pcon (LF_PCON); TLocalisamfile clifo(LF_CLIFO); - + pcon.setkey(1); pcon.zero(); pcon.put(PCN_GRUPPO, gruppo); @@ -289,13 +372,30 @@ const char * DescrConto (long gruppo, long conto, long sottoconto, TMP = pcon.curr().get(PCN_DESCR); else { - clifo.setkey(1); + clifo.setkey(1); clifo.zero(); clifo.put(CLI_CODCF, sottoconto); clifo.put(CLI_TIPOCF,tipocf); - clifo.read(); - if (clifo.good()) - TMP = clifo.get(CLI_RAGSOC); + if (clifo.read() == NOERR) + { + char tipoa = clifo.get_char("TIPOAPER"); + if (tipoa == 'F') //persona fisica + { + TString80 cognome, nome; + ragsoc = clifo.get("RAGSOC"); + cognome = ragsoc.mid(0,30); + nome = ragsoc.mid(30,20); + cognome.trim(); nome.trim(); + ragsoc = cognome; + ragsoc << " " << nome; + desc = ragsoc; + } + else + desc = clifo.get("RAGSOC"); + TMP = desc; + } + else + TMP = ""; } return TMP; } @@ -428,12 +528,12 @@ bool filter_func_fatture (const TRelation * rel) to.put(MOV_ANNOES, app->_annoes); } if (app->_data_ini.ok()) - from.put(MOV_DATAREG, app->_data_ini); + from.put(MOV_DATAREG, app->_data_ini); from.put(MOV_TIPO, app->_tipo_ini); if (app->_codice_ini != 0) from.put(MOV_CODCF, app->_codice_ini); if (app->_data_fin.ok()) - to.put(MOV_DATAREG, app->_data_fin); + to.put(MOV_DATAREG, app->_data_fin); to.put(MOV_TIPO, app->_tipo_fin); if (app->_codice_fin != 0) to.put(MOV_CODCF, app->_codice_fin); @@ -455,144 +555,240 @@ bool filter_func (const TRelation * rel) TRectype to (mov->curr()); switch (app->_scelta_stampa) { - case 0: - ann_reg = mov->get_int(MOV_ANNOIVA); - causale = mov->get (MOV_CODCAUS); - from.zero(); - to.zero(); - if ( (app->_decidi == 2) && (app->_annoes != 0) ) - { + case 0: + ann_reg = mov->get_int(MOV_ANNOIVA); + causale = mov->get (MOV_CODCAUS); + from.zero(); + to.zero(); + if ( (app->_decidi == 2) && (app->_annoes != 0) ) + { from.put(MOV_ANNOES, app->_annoes); to.put(MOV_ANNOES, app->_annoes); - } - from.put(MOV_CODCAUS, app->_causale_ini); - 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; - break; - case 1: - cod_reg = mov->get (MOV_REG); - ann_reg = mov->get_int (MOV_ANNOIVA); - tipo_reg = CodiceRegistro(cod_reg, ann_reg); - causale = mov->get (MOV_CODCAUS); - from.zero(); - to.zero(); - if ( (app->_decidi == 2) && (app->_annoes != 0) ) - { + } + from.put(MOV_CODCAUS, app->_causale_ini); + 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; + break; + case 1: + cod_reg = mov->get (MOV_REG); + ann_reg = mov->get_int (MOV_ANNOIVA); + tipo_reg = CodiceRegistro(cod_reg, ann_reg); + causale = mov->get (MOV_CODCAUS); + from.zero(); + to.zero(); + if ( (app->_decidi == 2) && (app->_annoes != 0) ) + { from.put(MOV_ANNOES, app->_annoes); to.put(MOV_ANNOES, app->_annoes); - } - from.put(MOV_CODCAUS, app->_causale_ini); - to.put(MOV_CODCAUS, app->_causale_fin); + } + from.put(MOV_CODCAUS, app->_causale_ini); + to.put(MOV_CODCAUS, app->_causale_fin); - if (((mov->curr() >= from) && (mov->curr() <= to)) && + if (((mov->curr() >= from) && (mov->curr() <= to)) && ((tipo_reg != 1) && (tipo_reg != 2))) - return TRUE; + return TRUE; - break; + break; - default: - break; - } - return FALSE; + default: + break; + } + return FALSE; } void CG3100_application::stampa_errori_rmov() { - if (_controllo_mov_errati != 3) - { - _nr = 2; - if ( _tiporegistro != 1 && _tiporegistro != 2 ) - { - if (_err == ERR_64) - { - reset_row(_nr); - set_row(_nr++, "@11g%s", ERR_64); - } - if (_err1 == ERR_66) - { - reset_row(_nr); - set_row(_nr++, "@11g%s", ERR_66); - } - if (_err2 == ERR_75) - { - reset_row(_nr); - set_row(_nr++, "@11g%s", ERR_75); - } - } - if ((_tiporegistro == 1)||(_tiporegistro == 2)) - { - if ((_alleg == 1)||(_alleg == 2)) + TRectype rec (current_cursor()->file(LF_RMOV).curr()); + int gruppo = rec.get_int(RMV_GRUPPO); + int conto = rec.get_int(RMV_CONTO); + long sottoconto = rec.get_long(RMV_SOTTOCONTO); + int anno = rec.get_int(RMV_ANNOES); + int rcontr = rec.get_int(RMV_RCONTR); + TDate datareg = rec.get_date(RMV_DATAREG); + char sez = rec.get_char(RMV_SEZIONE); + char tipo = rec.get_char(RMV_TIPOC); + + bool g = FALSE; + char t; + + TConto tc (gruppo,conto,sottoconto); + + _nr++; + + if (anno != _annoeser || datareg != _datareg) + set_row(_nr++, "@11gUno o piu' campi non sono costanti nella riga dell' operazione"); + if (sez != 'D' && sez != 'A') + set_row(_nr++, "@11gIndicato tipo movimento Dare/Avere errato"); + if (tc.empty()) + set_row(_nr++, "@11gNon presente codice gruppo/conto/sottoconto"); + if (!tc.ok()) + set_row(_nr++, "@11gCodice gruppo/conto/sottoconto non corrisponde ad un sottoconto"); + + TRectype pc (_pcon->curr()); + tc.set(gruppo,0,0l); + if (!tc.read(pc)) + g = TRUE; + tc.set(gruppo,conto,0l); + if (!tc.read(pc)) + set_row(_nr++, "@11gCodice gruppo/conto/sottoconto non presente in Piano dei Conti"); + else + { + t = pc.get_char(PCN_TMCF); + if (t != tipo) + set_row(_nr++, "@11gIl tipo C/F indicato non corrisponde a quello presente su Piano dei Conti"); + else + { + tc.set(gruppo,conto,sottoconto); + if (t != 'C' && t != 'F') + { + if (!tc.read(pc) || g ) + set_row(_nr++, "@11gCodice gruppo/conto/sottoconto non presente in Piano dei Conti"); + else + { + bool sosp = tc.sospeso(); + if (sosp) + set_row(_nr++, "@11gCodice gruppo/conto/sottoconto sospeso in Piano dei Conti"); + } + } + else + { + TLocalisamfile clifo(LF_CLIFO); + clifo.setkey(1); + clifo.zero(); + clifo.put(CLI_CODCF, sottoconto); + clifo.put(CLI_TIPOCF,t); + if (clifo.read() == NOERR) { - reset_row(_nr); - set_row(_nr++, "@11g%s", MSG_31); - } - if (_err2 == ERR_1) - { - reset_row(_nr); - set_row(_nr++, "@11g%s",ERR_1); - } - if (_err == ERR_2) - { - reset_row(_nr); - set_row(_nr++, "@11g%s",ERR_2); - } - if (_err3 == ERR_4) - { - reset_row(_nr); - set_row(_nr++, "@11g%s",ERR_4); - } - if (_msg == MSG_54) - { - reset_row(_nr); - set_row(_nr++, "@11g%s",MSG_54); - } - if (_err1 == ERR_09) - { - reset_row(_nr); - set_row(_nr, "@11g%s",ERR_09); + bool sosp = clifo.get_bool(CLI_SOSPESO); + if (sosp) + set_row(_nr++, "@11gCodice C/F sospeso in Anagrafica"); } - } + else set_row(_nr++, "@11gCodice C/F non presente in Anagrafica"); + if (_registro.not_empty()) //se su mov e' indicato il codice registro + { + TRegistro rg (_registro, _ae); + const int tiporeg = rg.tipo(); + if ((tiporeg == 1 && t != 'C') || (tiporeg == 2 && t != 'F')) + set_row(_nr++, "@11gTipo C/F non compatibile con tipo registro"); + } + } } + } + TLocalisamfile saldi(LF_SALDI); + saldi.setkey(1); + saldi.zero(); + saldi.put(SLD_ANNOES,anno); + saldi.put(SLD_GRUPPO,gruppo); + saldi.put(SLD_CONTO, conto); + saldi.put(SLD_SOTTOCONTO,sottoconto); + + if (saldi.read() != NOERR) + set_row(_nr++, "@11gCodice gruppo/conto/sottoconto non presente in Saldi p.d.c."); + + TRecnotype numrec = current_cursor()->file(LF_RMOV).recno(); + stampa_errori_contropartita(rcontr); + current_cursor()->file(LF_RMOV).readat(numrec); +} + +void CG3100_application::stampa_errori_contropartita(int riga) +{ + TLocalisamfile& rmov = current_cursor()->file(LF_RMOV); + char t; + rmov.zero(); + rmov.put(RMV_NUMREG, _numero); + rmov.put(RMV_NUMRIG, riga); + if (rmov.read(_isequal) == NOERR) // se esiste la contropartita + { + int gruppo = rmov.get_int (RMV_GRUPPO); + int conto = rmov.get_int (RMV_CONTO); + long sottoconto = rmov.get_long(RMV_SOTTOCONTO); + + bool g = FALSE; + TConto tc; + TRectype pc (_pcon->curr()); + tc.set(gruppo,0,0l); + if (!tc.read(pc)) + g = TRUE; + tc.set(gruppo,conto,0l); + if (!tc.read(pc)) + set_row(_nr++, "@11gCodice gruppo/conto/sottoconto di contropartita non presente in Piano dei Conti"); + else + { + t = pc.get_char(PCN_TMCF); + tc.set(gruppo,conto,sottoconto); + if (t != 'C' && t != 'F') + { + if (!tc.read(pc) || g ) + set_row(_nr++, "@11gCodice gruppo/conto/sottoconto di contropartita non presente in Piano dei Conti"); + else + { + bool sosp = tc.sospeso(); + if (sosp) + set_row(_nr++, "@11gCodice gruppo/conto/sottoconto di contropartita sospeso in Piano dei Conti"); + } + } + else + { + TLocalisamfile clifo(LF_CLIFO); + clifo.setkey(1); + clifo.zero(); + clifo.put(CLI_CODCF, sottoconto); + clifo.put(CLI_TIPOCF,t); + if (clifo.read() == NOERR) + { + bool sosp = clifo.get_bool(CLI_SOSPESO); + if (sosp) + set_row(_nr++, "@11gCodice C/F di contropartita sospeso in Anagrafica"); + } + else set_row(_nr++, "@11gCodice C/F di contropartita non presente in Anagrafica"); + } + } + } +} + +void CG3100_application::stampa_errori_iva(int* nr, const char* cod, const int tipodet, const int tipocr) +{ + TTable tab_iva ("%IVA"); + tab_iva.zero(); + tab_iva.put("CODTAB", cod); + if (tab_iva.read()==NOERR) + { + int allc = tab_iva.get_int("S7"); + int allf = tab_iva.get_int("S8"); + bool s = tab_iva.get_bool("B2"); + if (s) + set_row(++(*nr), "@11gCodice IVA sospeso"); + if (_stampa_mess_alleg_iva) + if (allc == 0 && allf == 0) + set_row(++(*nr), "@11gSul Codice IVA non e' stato attivato l'indicatore per allegato"); + } + else + set_row(++(*nr), "@11gCodice IVA non presente in tabella"); + + if (tipodet == 1 || tipodet == 3 || tipodet == 5 || tipodet == 9) + if (_tiporegistro != 2) + set_row(++(*nr), "@11gCodice di indetraibilita' errato"); + + if (_tiporegistro == 1) + if (tipocr != 0 && tipocr != 1 && tipocr != 4 && tipocr != 9) + set_row(++(*nr), "@11gTipo costo/ricavo non valido"); + + if (_tiporegistro == 2) + if (tipocr != 0 && tipocr != 1 && tipocr != 2 && tipocr != 3 && tipocr != 5 && tipocr != 8 && tipocr != 9) + set_row(++(*nr), "@11gTipo costo/ricavo non valido"); } void CG3100_application::stampa_errori_mov() { - if (_controllo_mov_errati != 3) - { - //aggiungere il controllo anno di competenza - - if ( _tiporegistro == 1 || _tiporegistro == 2 ) //controlli su mov. iva - { - if (_caus->empty()) - set_row(++_n, "@11g%s", ERR_16); - - if (_tipodocumento != _tipodoc) - set_row(++_n, "@11g%s", MSG_19); - - if ((_stampa_mess_alleg_iva)&&(!_alleg_causale)) - set_row(++_n, "@11g%s", MSG_20); - - if (_registro == "") - set_row(++_n, "@11g%s", ERR_21); - } - if ( _tiporegistro != 1 && _tiporegistro != 2 ) //controlli su mov. di prima nota - { - if (_registro.not_empty()) - if (CodiceRegistro(_registro,_anno) == 0) - set_row(++_n, "@11g%s", ERR_62); - if (_causale.not_empty()) - { - if (_caus->empty()) - set_row(++_n, "@11g%s", ERR_16); - else - if ( _reg_causale != _registro && _registro.not_empty() ) - set_row(++_n, "@11g%s", ERR_59); - } - } - } + long i = _err.first_one(); + if (i != -1) + { + for (; i <= _err.last_one(); i++) + set_row(++_n, "@11g%s", (const char*) err_msg[i-1]); + } } void CG3100_application::set_page(int file, int count) @@ -608,17 +804,17 @@ void CG3100_application::set_page(int file, int count) set_row(_nr,"@3n",FLD(LF_RMOV,RMV_NUMRIG)); // set_row(_nr,"@5g@3s",FLD(LF_MOV,MOV_CODCAUS)); // set_row(_nr,"@9g#.20t", &_descr_causale); - set_row(_nr,"@30g@24s@r",FLD(LF_RMOV,RMV_DESCR)); - set_row(_nr,"@56g@4n",FLD(LF_RMOV,RMV_GRUPPO)); - set_row(_nr,"@61g@3n",FLD(LF_RMOV,RMV_CONTO)); - set_row(_nr,"@65g@6n",FLD(LF_RMOV,RMV_SOTTOCONTO)); - set_row(_nr,"@72g#.20t@r",&_descr); + set_row(_nr,"@30g@24s",FLD(LF_RMOV,RMV_DESCR)); + set_row(_nr,"@56g@3n",FLD(LF_RMOV,RMV_GRUPPO)); + set_row(_nr,"@60g@3n",FLD(LF_RMOV,RMV_CONTO)); + set_row(_nr,"@64g@6n",FLD(LF_RMOV,RMV_SOTTOCONTO)); + set_row(_nr,"@71g#.21t",&_descr); _appoggio = current_cursor()->curr(LF_RMOV).get(RMV_SEZIONE); if ((_appoggio=="D")||(_appoggio=="d")) set_row(_nr,"@93g@pN",FLD(LF_RMOV,RMV_IMPORTO,"###.###.###.###")); else set_row(_nr,"@111g@pN",FLD(LF_RMOV,RMV_IMPORTO,"###.###.###.###")); - set_row(_nr,"@130g@f",FLD(LF_MOV,MOV_STAMPATO)); + //set_row(_nr,"@130g@f",FLD(LF_MOV,MOV_STAMPATO)); } else if (file == LF_MOV) { @@ -626,24 +822,38 @@ void CG3100_application::set_page(int file, int count) dep = ""; _n = 1; set_row (_n++,(const char*)dep); - set_row (_n, "Operazione n. @18g@7n", FLD(LF_MOV,MOV_NUMREG)); - //set_row (_n, "@23g@3s",FLD(LF_MOV,MOV_CODCAUS)); - set_row (_n, "@26gdel@30g@d",FLD(LF_MOV,MOV_DATAREG)); - set_row (_n, "@41g@40s@r",FLD(LF_MOV,MOV_DESCR)); - set_row (_n, "@82gdoc. @87g@7s",FLD(LF_MOV,MOV_NUMDOC)); - set_row (_n, "@95gdel@99g@d", FLD(LF_MOV,MOV_DATADOC)); + /* + set_row (_n, "Operazione n. @18g@7n", FLD(LF_MOV,MOV_NUMREG)); + set_row (_n, "@26gdel@30g@d",FLD(LF_MOV,MOV_DATAREG)); + set_row (_n, "@41g@40s@r",FLD(LF_MOV,MOV_DESCR)); + set_row (_n, "@82gdoc. @87g@7s",FLD(LF_MOV,MOV_NUMDOC)); + set_row (_n, "@95gdel@99g@d", FLD(LF_MOV,MOV_DATADOC)); + */ + set_row (_n, "Operazione n. @14g@7n", FLD(LF_MOV,MOV_NUMREG)); + set_row (_n, "@22gdel@26g@d",FLD(LF_MOV,MOV_DATAREG)); + set_row (_n, "@37g@36s",FLD(LF_MOV,MOV_DESCR)); + set_row (_n, "@75gdoc. @7s",FLD(LF_MOV,MOV_NUMDOC)); + set_row (_n, "@88gdel@92g@d", FLD(LF_MOV,MOV_DATADOC)); + int annoese = current_cursor()->curr(LF_MOV).get_int(MOV_ANNOES); + TDate data = current_cursor()->curr(LF_MOV).get_date(MOV_DATAREG); TString16 reg = current_cursor()->curr(LF_MOV).get(MOV_REG); int anno = current_cursor()->curr(LF_MOV).get_int(MOV_ANNOIVA); int tipo = CodiceRegistro(reg, anno); + int ae = date2esc(data); if ( (tipo == 1) || (tipo == 2) ) { - set_row (_n, "@110greg @3s",FLD(LF_MOV,MOV_REG)); - set_row (_n, "@118gpr @5n",FLD(LF_MOV,MOV_PROTIVA)); + set_row (_n, "@103greg @3s",FLD(LF_MOV,MOV_REG)); + set_row (_n, "@111gpr @5n",FLD(LF_MOV,MOV_PROTIVA)); } - if (_scelta_stampa == 0) + if (ae != annoese) + if (_annoes == 0) //se non indicato l'anno nella maschera + set_row (_n, "@120gcomp @4n", FLD(LF_MOV,MOV_ANNOES)); + /* + if (_scelta_stampa == 0) if (_stampa_anno_comp) - set_row (_n, "@127g@4n", FLD(LF_MOV,MOV_ANNOES)); - //set_row (_n, "@130g@f", FLD(LF_MOV,MOV_STAMPATO)); + set_row (_n, "@127g@4n", FLD(LF_MOV,MOV_ANNOES)); + */ + set_row (_n, "@130g@f", FLD(LF_MOV,MOV_STAMPATO)); } break; @@ -701,19 +911,26 @@ bool CG3100_application::preprocess_page(int file,int counter) _tot_dare = 0; _c.destroy(); _no_preprocess_page = FALSE; - _causale = current_cursor()->curr(LF_MOV).get(MOV_CODCAUS); + _esiste_riga_iva = FALSE; + _nonesiste_riga_iva = FALSE; + _annoeser = current_cursor()->curr(LF_MOV).get_int(MOV_ANNOES); + _datacomp = current_cursor()->curr(LF_MOV).get_date(MOV_DATACOMP); + _causale = current_cursor()->curr(LF_MOV).get(MOV_CODCAUS); _registro = current_cursor()->curr(LF_MOV).get(MOV_REG); _anno = current_cursor()->curr(LF_MOV).get_int(MOV_ANNOIVA); _tipodoc = current_cursor()->curr(LF_MOV).get(MOV_TIPODOC); _datareg = current_cursor()->file(LF_MOV).get_date(MOV_DATAREG); - _causale_gia_stampata = FALSE; - - //TDate data_corrente (current_cursor()->file(LF_MOV)->get_date(MOV_DATAREG)); + _tipo = current_cursor()->file(LF_MOV).get_char(MOV_TIPO); + _codcf = current_cursor()->file(LF_MOV).get_long(MOV_CODCF); + _numero = current_cursor()->file(LF_MOV).get_long(MOV_NUMREG); _tiporegistro = CodiceRegistro(_registro, _anno); - TLocalisamfile* fl = &(current_cursor()->file(LF_MOV)); - TRectype da (fl->curr()); - TRectype a (fl->curr()); + _causale_gia_stampata = FALSE; + _ae = date2esc(_datareg); + + TLocalisamfile& fl = current_cursor()->file(LF_MOV); + TRectype da (fl.curr()); + TRectype a (fl.curr()); da.zero(); a.zero(); if (_annoes != 0) @@ -726,8 +943,7 @@ bool CG3100_application::preprocess_page(int file,int counter) a.put(MOV_CODCAUS, _causale_fin); a.put(MOV_REG, _registro_fin); - if ((fl->curr() >= da) && (fl->curr() <= a)) - //&&((_tiporegistro == 1)||(_tiporegistro == 2))) + if ((fl.curr() >= da) && (fl.curr() <= a)) { _caus->setkey(1); _caus->curr().put(CAU_CODCAUS,_causale); @@ -739,33 +955,32 @@ bool CG3100_application::preprocess_page(int file,int counter) _alleg_causale = _caus->curr().get_bool(CAU_ALLEG); _tipodocumento = _caus->curr().get(CAU_TIPODOC); - bool controlla = segnala_errori_primariga(); - - if ( (_controllo_mov_errati == 1 && controlla) - || _controllo_mov_errati == 2 ) + if (_controllo_mov_errati == 1 || _controllo_mov_errati == 2) { - stampa_errori_mov(); - return TRUE; + bool controlla = segnala_errori_primariga(); + bool verifica = (_stampa_parte_iva && segnala_errori_iva()) || segnala_errori_ogniriga(); + + if ((_controllo_mov_errati == 1 && controlla) + || _controllo_mov_errati == 2 ) + { + stampa_errori_mov(); + return TRUE; + } + else if (_controllo_mov_errati == 1 && !verifica) + return FALSE; + else return TRUE; } - else if ((_controllo_mov_errati == 1)&&(!controlla)) - return FALSE; - else if (_controllo_mov_errati == 3) - return TRUE; + else return TRUE; } } - else if (file == LF_RMOV) - { - if (!_causale_gia_stampata) - { - set_row(_nr,"@4g%3s", (const char*) _causale); - set_row(_nr,"@8g%.20s@r", (const char*) _descr_causale); - _causale_gia_stampata = TRUE; - } - - bool verifica = segnala_errori_ogniriga(); - - if (((_controllo_mov_errati == 1)&&(verifica))||(_controllo_mov_errati == 2)||(_controllo_mov_errati == 3)) + else if (file == LF_RMOV) { + if (!_causale_gia_stampata) + { + set_row(_nr,"@4g%3s", (const char*) _causale); + set_row(_nr,"@8g%.20s@r", (const char*) _descr_causale); + _causale_gia_stampata = TRUE; + } int gruppo = current_cursor()->curr(LF_RMOV).get_int(RMV_GRUPPO); int conto = current_cursor()->curr(LF_RMOV).get_int(RMV_CONTO); long sottoconto = current_cursor()->curr(LF_RMOV).get_long(RMV_SOTTOCONTO); @@ -786,95 +1001,90 @@ bool CG3100_application::preprocess_page(int file,int counter) _tot_avere += _importo; _tot_avere_generale += _importo; } - stampa_errori_rmov(); + if (_controllo_mov_errati != 3) stampa_errori_rmov(); } return TRUE; } - } - else if ((_stampa_parte_iva)&&(file == LF_RMOVIVA)) - { - TRectype iva(current_cursor()->file(LF_RMOVIVA).curr()); - _impo = iva.get_real(RMI_IMPONIBILE); - _impos = iva.get_real(RMI_IMPOSTA); - _tipocr = iva.get_int(RMI_TIPOCR); - _tipod = iva.get_int(RMI_TIPODET); - _cod = iva.get(RMI_CODIVA); - if (_stampa_parte_iva) - _c.add_riga(_impo,_impos,_cod,_tipod,_tipocr, ZERO, ZERO); - - return TRUE; - } - } - else //_scelta_stampa == 1 - { - if (file == LF_MOV) - { - _tot_avere = 0; - _tot_dare = 0; - _no_preprocess_page = FALSE; - _causale = current_cursor()->curr(LF_MOV).get(MOV_CODCAUS); - _registro = current_cursor()->curr(LF_MOV).get(MOV_REG); - _anno = current_cursor()->curr(LF_MOV).get_int(MOV_ANNOES); - _tipodoc = current_cursor()->curr(LF_MOV).get(MOV_TIPODOC); - - TLocalisamfile* fl = &(current_cursor()->file(LF_MOV)); - TRectype da (fl->curr()); - TRectype a (fl->curr()); - da.zero(); - a.zero(); - if (_annoes != 0) - { - da.put(MOV_ANNOES, _annoes); - a.put(MOV_ANNOES, _annoes); - } - da.put(MOV_CODCAUS, _causale_ini); - a.put(MOV_CODCAUS, _causale_fin); - - if ((fl->curr() >= da) && (fl->curr() <= a)) - /* - if ((_annoes == _anno) || (_annoes == 0)) - if ((_causale >= _causale_ini) && (_causale <= _causale_fin)) - */ + else if ((_stampa_parte_iva)&&(file == LF_RMOVIVA)) { - _caus->setkey(1); - _caus->curr().put(CAU_CODCAUS,_causale); - _caus->read(); - _descr_causale = _caus->curr().get(CAU_DESCR); - _alleg_causale = _caus->curr().get_bool(CAU_ALLEG); - _tipodocumento = _caus->curr().get(CAU_TIPODOC); + TRectype iva(current_cursor()->file(LF_RMOVIVA).curr()); + _impo = iva.get_real(RMI_IMPONIBILE); + _impos = iva.get_real(RMI_IMPOSTA); + _tipocr = iva.get_int(RMI_TIPOCR); + _tipod = iva.get_int(RMI_TIPODET); + _cod = iva.get(RMI_CODIVA); + + _c.add_riga(_impo,_impos,_cod,_tipod,0,0.00,0.00); - _tiporegistro = CodiceRegistro (_registro, _anno); - - if ((_tiporegistro != 1)&&(_tiporegistro != 2))//se si tratta di un movimento di sola prima nota - return TRUE; - } - } - else if (file == LF_RMOV) - { - long gruppo = atol(current_cursor()->curr(LF_RMOV).get(RMV_GRUPPO)); - long conto = atol(current_cursor()->curr(LF_RMOV).get(RMV_CONTO)); - long sottoconto = atol(current_cursor()->curr(LF_RMOV).get(RMV_SOTTOCONTO)); - TString tipoc = current_cursor()->curr(LF_RMOV).get(RMV_TIPOC); - _descr = DescrConto(gruppo, conto, sottoconto, tipoc); - _importo = current_cursor()->file(LF_RMOV).get_real(RMV_IMPORTO); - _appoggio = current_cursor()->curr(LF_RMOV).get(RMV_SEZIONE); - if (!_no_preprocess_page) - { - if ((_appoggio=="D")||(_appoggio=="d")) - { - _tot_dare_generale += _importo; - _tot_dare += _importo; - } - else if ((_appoggio=="A")||(_appoggio=="a")) - { - _tot_avere += _importo; - _tot_avere_generale += _importo; - } + return TRUE; } - return TRUE; } - } - break; + else //_scelta_stampa == 1 + { + if (file == LF_MOV) + { + _tot_avere = 0; + _tot_dare = 0; + _no_preprocess_page = FALSE; + _causale = current_cursor()->curr(LF_MOV).get(MOV_CODCAUS); + _registro = current_cursor()->curr(LF_MOV).get(MOV_REG); + _anno = current_cursor()->curr(LF_MOV).get_int(MOV_ANNOES); + _tipodoc = current_cursor()->curr(LF_MOV).get(MOV_TIPODOC); + + TLocalisamfile* fl = &(current_cursor()->file(LF_MOV)); + TRectype da (fl->curr()); + TRectype a (fl->curr()); + da.zero(); + a.zero(); + if (_annoes != 0) + { + da.put(MOV_ANNOES, _annoes); + a.put(MOV_ANNOES, _annoes); + } + da.put(MOV_CODCAUS, _causale_ini); + a.put(MOV_CODCAUS, _causale_fin); + + if ((fl->curr() >= da) && (fl->curr() <= a)) + { + _caus->setkey(1); + _caus->curr().put(CAU_CODCAUS,_causale); + _caus->read(); + _descr_causale = _caus->curr().get(CAU_DESCR); + _alleg_causale = _caus->curr().get_bool(CAU_ALLEG); + _tipodocumento = _caus->curr().get(CAU_TIPODOC); + + _tiporegistro = CodiceRegistro (_registro, _anno); + + if ((_tiporegistro != 1)&&(_tiporegistro != 2))//se si tratta di un movimento di sola prima nota + return TRUE; + } + } + else if (file == LF_RMOV) + { + long gruppo = atol(current_cursor()->curr(LF_RMOV).get(RMV_GRUPPO)); + long conto = atol(current_cursor()->curr(LF_RMOV).get(RMV_CONTO)); + long sottoconto = atol(current_cursor()->curr(LF_RMOV).get(RMV_SOTTOCONTO)); + TString tipoc = current_cursor()->curr(LF_RMOV).get(RMV_TIPOC); + _descr = DescrConto(gruppo, conto, sottoconto, tipoc); + _importo = current_cursor()->file(LF_RMOV).get_real(RMV_IMPORTO); + _appoggio = current_cursor()->curr(LF_RMOV).get(RMV_SEZIONE); + if (!_no_preprocess_page) + { + if ((_appoggio=="D")||(_appoggio=="d")) + { + _tot_dare_generale += _importo; + _tot_dare += _importo; + } + else if ((_appoggio=="A")||(_appoggio=="a")) + { + _tot_avere += _importo; + _tot_avere_generale += _importo; + } + } + return TRUE; + } + } + break; case fatture: { @@ -900,7 +1110,7 @@ bool CG3100_application::preprocess_page(int file,int counter) if ((_tipo_elenco != _tipo_clifo_prec) && (_tipo_clifo_prec != "") && _salto_pagina) - printer().formfeed(); + printer().formfeed(); TLocalisamfile & file = cur->file(LF_MOV); TRectype da (file.curr()); @@ -914,12 +1124,12 @@ bool CG3100_application::preprocess_page(int file,int counter) a.put(MOV_ANNOES, _annoes); } if (_data_ini.ok()) - da.put(MOV_DATAREG, _data_ini); + da.put(MOV_DATAREG, _data_ini); da.put(MOV_TIPO, _tipo_ini); if (_codice_ini != 0) da.put(MOV_CODCF, _codice_ini); if (_data_fin.ok()) - a.put(MOV_DATAREG, _data_fin); + a.put(MOV_DATAREG, _data_fin); a.put(MOV_TIPO, _tipo_fin); if (_codice_fin != 0) a.put(MOV_CODCF, _codice_fin); @@ -937,13 +1147,13 @@ bool CG3100_application::preprocess_page(int file,int counter) } else if (_tipo_clifo_prec == _tipo_elenco && _codcf_prec == _codcf) - _settata_prima_riga = FALSE; + _settata_prima_riga = FALSE; else { - stampa_intestazione(); - _tipo_clifo_prec = _tipo_elenco; - _codcf_prec = _codcf; - _settata_prima_riga = FALSE; + stampa_intestazione(); + _tipo_clifo_prec = _tipo_elenco; + _codcf_prec = _codcf; + _settata_prima_riga = FALSE; } return TRUE; } @@ -1058,174 +1268,173 @@ print_action CG3100_application::postprocess_page(int file,int count) } if (file == LF_MOV) { - reset_print(); - int n = 1; - if ( _scelta_stampa == 0 && _stampa_parte_iva ) - { - int r = 0; - for (int j = 0; j < _c.items(); j++) - { - TRigaiva& riga = (TRigaiva&)_c[j]; - r = j+1; - set_row(r, "Imponibile@12g%15.0r", &riga._imponibile); - set_row(r, "@31gImposta@39g%15.0r", &riga._imposta); - set_row(r, "@58gCodice Iva@68g%3s", (const char*)riga._codiva); - switch (riga._tipodet) - { - case 0 : set_row(r, "@73gDetraibile"); - break; - case 1 : set_row(r, "@73gIndetraibile su op.es."); - break; - case 3 : set_row(r, "@73gPassaggi interni"); - break; - case 9 : set_row(r, "@73gIndetraibile art.19"); - break; - default: break; - } - } - _c.destroy(); - if (r > 0) - { - n = ++r; - //return REPEAT_PAGE; - } - //else - // return NEXT_PAGE; - } - //} - TRecnotype pos, items; - bool FINITO = FALSE; - //reset_print(); - //int n = 1; - if ((_scelta_stampa == 0)&&(_controllo_mov_errati != 3)&&(_tot_dare != _tot_avere)) - set_row(n++, "@11g%s", ERR_77); - - // TLocalisamfile & mov = current_cursor()->file(LF_MOV); - pos = current_cursor()->pos(); - items = current_cursor()->items(); - - FINITO = (pos == items-1); - - _datareg = current_cursor()->file(LF_MOV).get_date(MOV_DATAREG); - _numreg = current_cursor()->file(LF_MOV).get_long(MOV_NUMREG); - - TDate datarec (_datareg); - if (!FINITO) - { - TCursor * cur = current_cursor(); - cur->save_status(); - ++(*cur); - datarec = cur->file(LF_MOV).get_date(MOV_DATAREG); - --(*cur); - cur->restore_status(); - } - - _tot_avere_giornaliero += _tot_avere; - _tot_dare_giornaliero += _tot_dare; - - //stampa i totali giornalieri - if ( FINITO || - (_datareg != datarec)||(_numreg == _numreg_fin)) - { - if (( (_scelta_stampa == 0) && (_controllo_mov_errati != 1) && (_decidi == 2)) || ((_scelta_stampa == 1)&&(_decidi == 2))) - { - TString data = _datareg.string(); - set_row(n, "@b@50gTotali del"); - set_row(n, "@b@61ggiorno %s", (const char *)data); - set_row(n, "@b@93g%r", &_tot_dare_giornaliero); - set_row(n++, "@b@111g%r", &_tot_avere_giornaliero); - _tot_avere_giornaliero = 0; - _tot_dare_giornaliero = 0; - } - else if (((_scelta_stampa == 0)&&(_controllo_mov_errati != 1)&&(_decidi == 1)&&(FINITO)) || ((_scelta_stampa == 1)&&(_decidi == 1)&&(FINITO))) - { - TString sep; - sep = ""; - set_row (n,(const char*)sep); - set_row(++n, "@b@60gTotale generale"); - set_row(n, "@b@93g%r", &_tot_dare_generale); - set_row(n++, "@b@111g%r", &_tot_avere_generale); - } - } - - if (n == 1) - { - force_setpage(); - return NEXT_PAGE; - } - else + reset_print(); + _err.reset(); + int n = 1; + if ( _scelta_stampa == 0 && _stampa_parte_iva ) { - _no_preprocess_page = TRUE; - force_setpage(FALSE); - return REPEAT_PAGE; + int r = 0; + for (int j = 0; j < _c.items(); j++) + { + TRigaiva& riga = (TRigaiva&)_c[j]; + //r = j+1; + r++; + set_row(r, "Imponibile@12g%15.0r", &riga._imponibile); + set_row(r, "@31gImposta@39g%15.0r", &riga._imposta); + set_row(r, "@58gCodice Iva@68g%3s", (const char*)riga._codiva); + switch (riga._tipodet) + { + case 0 : set_row(r, "@73gDetraibile"); + break; + case 1 : set_row(r, "@73gIndetraibile su op.es."); + break; + case 3 : set_row(r, "@73gPassaggi interni"); + break; + case 9 : set_row(r, "@73gIndetraibile art.19"); + break; + default: break; + } + if (_controllo_mov_errati != 3) + if (!_esiste_riga_iva && ! _nonesiste_riga_iva) + stampa_errori_iva(&r, riga._codiva, riga._tipodet, riga._tipocr); + } + if (_esiste_riga_iva) + set_row(++r, "@11gPresenti righe IVA in una registrazione senza IVA"); + if (_nonesiste_riga_iva) + set_row(++r, "@11gNon presente alcuna riga IVA in una registrazione con IVA"); + _c.destroy(); + if (r > 0) + n = ++r; } - } - break; - - case fatture: - if (file == LF_MOV) - { - _totdocumenti += _totdoc; TRecnotype pos, items; bool FINITO = FALSE; - TCursor* cur = current_cursor(); - // TLocalisamfile & mov = cur->file(LF_MOV); - + if ((_scelta_stampa == 0)&&(_controllo_mov_errati != 3)&&(_tot_dare != _tot_avere)) + set_row(n++, "@11gIl movimento risulta sbilanciato"); + pos = current_cursor()->pos(); items = current_cursor()->items(); FINITO = (pos == items-1); + _datareg = current_cursor()->file(LF_MOV).get_date(MOV_DATAREG); + _numreg = current_cursor()->file(LF_MOV).get_long(MOV_NUMREG); + + TDate datarec (_datareg); if (!FINITO) { + TCursor * cur = current_cursor(); cur->save_status(); ++(*cur); - // long numrsucc = cur->file(LF_MOV).get_long(MOV_NUMREG); - _tipoelsucc = cur->file(LF_MOV).get(MOV_TIPO); - _codclifosucc = cur->file(LF_MOV).get_long(MOV_CODCF); + datarec = cur->file(LF_MOV).get_date(MOV_DATAREG); --(*cur); cur->restore_status(); } + + _tot_avere_giornaliero += _tot_avere; + _tot_dare_giornaliero += _tot_dare; - if (FINITO || (_tipo_elenco != _tipoelsucc)||(_codcf != _codclifosucc)) + //stampa i totali giornalieri + if ( FINITO || + (_datareg != datarec)||(_numreg == _numreg_fin)) { - reset_print(); - TString blank = ""; - set_row(1,(const char*)blank); - if ((_tipo_elenco == "C")||(_tipo_elenco == "c")) - set_row(2, "@bTotali Cliente@18gDocumenti Totale documenti@45gAllegati:@56gImponibile@75gImposta@94gop. esenti@112gop. non imp."); - else - set_row(2, "@bTotali Fornitore@18gDocumenti Totale documenti@47gAllegati:@56gImponibile@75gImposta@94gop. esenti@112gop. non imp."); - set_row(3, "@b@18g%9d", _documenti); - set_row(3, "@b@28g%r", &_totdocumenti); - set_row(3, "@b@56g%r", &_totimponibile); - set_row(3, "@b@75g%r", &_totimposta); - set_row(3, "@b@94g%r", &_op_esenti); - set_row(3, "@b@112g%r", &_op_non_imp); - _totimposta = 0; - _totimponibile = 0; - _op_esenti = 0; - _op_non_imp = 0; - _documenti = 0; - _totdocumenti = 0; - return REPEAT_PAGE; + if (( _scelta_stampa == 0 && _controllo_mov_errati != 1 && _decidi == 2) || (_scelta_stampa == 1 && _decidi == 2)) + { + TString data = _datareg.string(); + set_row(n, "@b@60gTotali del"); + set_row(n, "@b@71ggiorno %s", (const char *)data); + set_row(n, "@b@93g%r", &_tot_dare_giornaliero); + set_row(n++, "@b@111g%r", &_tot_avere_giornaliero); + _tot_avere_giornaliero = 0; + _tot_dare_giornaliero = 0; + } + if ((_scelta_stampa == 0 && _controllo_mov_errati != 1 && FINITO) || (_scelta_stampa == 1 && FINITO)) + { + TString sep; + sep = ""; + set_row (n,(const char*)sep); + set_row(++n, "@b@60gTotale generale"); + set_row(n, "@b@93g%r", &_tot_dare_generale); + set_row(n++, "@b@111g%r", &_tot_avere_generale); + } + } + + if (n == 1) + { + force_setpage(); //probabilmente e' inutile + return NEXT_PAGE; } - } - break; +else +{ + _no_preprocess_page = TRUE; + force_setpage(FALSE); + return REPEAT_PAGE; +} +} +break; - case movimenti_sezionale: - break; + case fatture: + if (file == LF_MOV) +{ + _totdocumenti += _totdoc; + TRecnotype pos, items; + bool FINITO = FALSE; + TCursor* cur = current_cursor(); - default: - break; - } + pos = current_cursor()->pos(); + items = current_cursor()->items(); - return NEXT_PAGE; + FINITO = (pos == items-1); + + if (!FINITO) + { + cur->save_status(); + ++(*cur); + // long numrsucc = cur->file(LF_MOV).get_long(MOV_NUMREG); + _tipoelsucc = cur->file(LF_MOV).get(MOV_TIPO); + _codclifosucc = cur->file(LF_MOV).get_long(MOV_CODCF); + --(*cur); + cur->restore_status(); + } + + if (FINITO || (_tipo_elenco != _tipoelsucc)||(_codcf != _codclifosucc)) + { + reset_print(); + TString blank = ""; + set_row(1,(const char*)blank); + if ((_tipo_elenco == "C")||(_tipo_elenco == "c")) + set_row(2, "@bTotali Cliente@18gDocumenti Totale documenti@45gAllegati:@56gImponibile@75gImposta@94gop. esenti@112gop. non imp."); + else + set_row(2, "@bTotali Fornitore@18gDocumenti Totale documenti@47gAllegati:@56gImponibile@75gImposta@94gop. esenti@112gop. non imp."); + set_row(3, "@b@18g%9d", _documenti); + set_row(3, "@b@28g%r", &_totdocumenti); + set_row(3, "@b@56g%r", &_totimponibile); + set_row(3, "@b@75g%r", &_totimposta); + set_row(3, "@b@94g%r", &_op_esenti); + set_row(3, "@b@112g%r", &_op_non_imp); + _totimposta = 0; + _totimponibile = 0; + _op_esenti = 0; + _op_non_imp = 0; + _documenti = 0; + _totdocumenti = 0; + return REPEAT_PAGE; + } +} +break; + + case movimenti_sezionale: + break; + +default: +break; +} + +return NEXT_PAGE; } /************ -int CG3100_application::my_next(TLocalisamfile & mov) -{ + int CG3100_application::my_next(TLocalisamfile & mov) + { int esito; TString cod_reg, causale; int tipo_reg; @@ -1236,34 +1445,34 @@ int CG3100_application::my_next(TLocalisamfile & mov) switch (_scelta_stampa) { case 0: - return esito; + return esito; case 1: - while (!mov.eof()) - { - cod_reg = mov.get (MOV_REG); - ann_reg = mov.get_int (MOV_ANNOIVA); - causale = mov.get (MOV_CODCAUS); + while (!mov.eof()) + { + cod_reg = mov.get (MOV_REG); + ann_reg = mov.get_int (MOV_ANNOIVA); + causale = mov.get (MOV_CODCAUS); - if ( ( _annoes != 0l) - || ( (causale < (const char*)_causale_ini) || (causale > (const char*)_causale_fin)) ) - { - esito = mov.next(); - continue; - } - tipo_reg = CodiceRegistro (cod_reg, ann_reg); - if ( (tipo_reg != 1) && (tipo_reg != 2) ) - return esito; + if ( ( _annoes != 0l) + || ( (causale < (const char*)_causale_ini) || (causale > (const char*)_causale_fin)) ) + { + esito = mov.next(); + continue; + } + tipo_reg = CodiceRegistro (cod_reg, ann_reg); + if ( (tipo_reg != 1) && (tipo_reg != 2) ) + return esito; - esito=mov.next(); - } - break; - + esito=mov.next(); + } + break; + default: - break; + break; } return esito; -} -********/ + } + ********/ print_action CG3100_application::postprocess_print(int file,int count) { @@ -1276,89 +1485,6 @@ print_action CG3100_application::postprocess_print(int file,int count) switch (_tipo_lista) { case movimenti: - /* - if (file == LF_RMOV) - { - TRecnotype pos, items; - bool FINITO = FALSE; - - reset_print(); - int n = 1; - if ((_scelta_stampa == 0)&&(_controllo_mov_errati != 3)&&(_tot_dare != _tot_avere)) - set_row(n++, "@11g%s", ERR_77); - - TLocalisamfile* mov; - mov=current_cursor()->file(LF_MOV); - // nrec = mov->recno(); - - pos = current_cursor()->pos(); - items = current_cursor()->items(); - - FINITO = (pos == items-1); - - _datareg = current_cursor()->file(LF_MOV)->get_date(MOV_DATAREG); - _numreg = current_cursor()->file(LF_MOV)->get_long(MOV_NUMREG); - - TDate datarec (_datareg); - if (!FINITO) - { - TCursor * cur = current_cursor(); - cur->save_status(); - ++(*cur); - datarec = cur->file(LF_MOV)->get_date(MOV_DATAREG); - --(*cur); - cur->restore_status(); - } - // esito = my_next(mov); - // if (esito == NOERR) - // { - // long numrec = mov->get_long(MOV_NUMREG); - // datarec = mov->get_date(MOV_DATAREG); - // } - // mov->readat(nrec); - - _tot_avere_giornaliero += _tot_avere; - _tot_dare_giornaliero += _tot_dare; - - //stampa i totali giornalieri - if ( FINITO || - (_datareg != datarec)||(_numreg == _numreg_fin)) - { - if (( (_scelta_stampa == 0) && (_controllo_mov_errati != 1) && (_decidi == 2)) || ((_scelta_stampa == 1)&&(_decidi == 2))) - { - TString data = _datareg.string(); - set_row(n, "@b@50gTotali del"); - set_row(n, "@b@61ggiorno %s", (const char *)data); - set_row(n, "@b@93g%r", &_tot_dare_giornaliero); - set_row(n++, "@b@111g%r", &_tot_avere_giornaliero); - _tot_avere_giornaliero = 0; - _tot_dare_giornaliero = 0; - - } - else if (((_scelta_stampa == 0)&&(_controllo_mov_errati != 1)&&(_decidi == 1)&&(FINITO)) || ((_scelta_stampa == 1)&&(_decidi == 1)&&(FINITO))) - { - TString sep; - sep = ""; - set_row (n,(const char*)sep); - set_row(++n, "@b@60gTotale generale"); - set_row(n, "@b@93g%r", &_tot_dare_generale); - set_row(n++, "@b@111g%r", &_tot_avere_generale); - } - } - - if (n == 1) - { - force_setpage(); - return NEXT_PAGE; - } - else - { - _no_preprocess_page = TRUE; - force_setpage(FALSE); - return REPEAT_PAGE; - } - } - */ break; case fatture: @@ -1373,149 +1499,424 @@ print_action CG3100_application::postprocess_print(int file,int count) return NEXT_PAGE; } +//cerca errori sulla testata (MOV) bool CG3100_application::segnala_errori_primariga() { - int tiporeg; - tiporeg = CodiceRegistro (_registro, _anno); + const int ae = date2esc(_datacomp); - if ((_tiporegistro == 1)||(_tiporegistro == 2)) //movimento iva + if (_ae == 0) + _err.set(1); + + if (_registro.not_empty()) //si tratta di fattura + if (_datareg.year() != _anno) + _err.set(2); + + if ( _scelta_stampa == 0 && _stampa_anno_comp ) + if (_ae != _annoeser) + if (_annoes) //specificato l'anno nella maschera + _err.set(3); +else _err.set(4); + + if (ae) + { + int pr; // Esercizio precedente + const int ar = date2esc(_datareg, &pr); // Esercizio in corso + if (ae != ar && ae != pr) + _err.set(5); + } + else _err.set(6); + + if (_annoeser != ae) + _err.set(7); + + if (_causale.not_empty()) //se indicata la causale { - if ( tiporeg == 0 || - _caus->empty() || - _tipodocumento != _tipodoc || - (_stampa_mess_alleg_iva && !_alleg_causale) ) - return TRUE; - } - if ((_tiporegistro != 1)&&(_tiporegistro != 2)) //mov. di prima nota - { - if (_registro.not_empty()) - if (tiporeg == 0) return TRUE; - if (_causale.not_empty()) - if ( _caus->empty() || - (_reg_causale != _registro && _registro.not_empty()) ) - return TRUE; + if (_caus->curr().empty()) + _err.set(8); + else + { + bool sos = _caus->curr().get_bool(CAU_SOSPESO); + if (sos) + _err.set(9); + if (_stampa_mess_alleg_iva && _alleg_causale) + _err.set(10); + } + if (_tipodoc == "" || _tipodoc != _tipodocumento) + _err.set(11); + if (_tipodoc != "") + if (!RicercaDoc(_tipodoc)) + _err.set(12); + if (_registro == "" || _registro != _reg_causale) + _err.set(13); + + if (_registro.not_empty()) //movimento iva (fatture) + { + TRegistro rg (_registro, _datareg.year()); + if (rg.name().empty()) + _err.set(14); + else + { + bool so = rg.sospeso(); + if (so) + _err.set(15); + TipoIVA i = nessuna_iva; + TTable tabtpd("%TPD"); + tabtpd.put("CODTAB", _tipodoc); + if (tabtpd.read() == NOERR) + { + bool cor = tabtpd.get_bool("B0"); + i = (TipoIVA)tabtpd.get_int("I0"); // IVA acquisti, vendite, generica + const TipoIVA ri = rg.iva(); + if (i == iva_generica) i = ri; + if (i != ri || ( cor && !rg.corrispettivi() )) + _err.set(16); + if (!cor) + if (_codcf == 0l) + _err.set(17); + } + const int tipo = rg.tipo(); + if ((tipo == 1 && _tipo != 'C') || (tipo == 2 && _tipo != 'F')) + _err.set(18); + + TLocalisamfile clifo(LF_CLIFO); + clifo.setkey(1); + clifo.zero(); + clifo.put(CLI_CODCF, _codcf); + clifo.put(CLI_TIPOCF,_tipo); + if (clifo.read() == NOERR) + { + bool sosp = clifo.get_bool(CLI_SOSPESO); + if (sosp) + _err.set(19); + bool occ = clifo.get_bool(CLI_OCCAS); + char alleg = clifo.get_char(CLI_ALLEG); + long calleg = clifo.get_long(CLI_CODALLEG); + if (!occ) + { + if (_stampa_mess_alleg_iva && alleg == 1) + _err.set(20); + if (calleg != 0l) + if (calleg == _codcf) + _err.set(21); + clifo.zero(); + clifo.put(CLI_CODCF, calleg); + clifo.put(CLI_TIPOCF,_tipo); + if (clifo.read == NOERR) + { + bool sospall = clifo.get_bool(CLI_SOSPESO); + long codall = clifo.get_long(CLI_CODALLEG); + char alleg = clifo.get_char(CLI_ALLEG); + if (sospall) + _err.set(22); + if (codall != 0l) + _err.set(23); + if (_stampa_mess_alleg_iva && alleg == 1) + _err.set(24); + } + else _err.set(25); + } + } + else _err.set(26); + } + } } + if (_err.ones()) + return TRUE; + return FALSE; } +//controlli sulla contropartita +bool CG3100_application::contropartita(int riga) +{ + char t; + TLocalisamfile rmov(LF_RMOV,FALSE); + rmov.setkey(1); + rmov.zero(); + rmov.put(RMV_NUMREG, _numero); + rmov.put(RMV_NUMRIG, riga); + if (rmov.read(_isequal) == NOERR) // se esiste la contropartita + { + int gruppo = rmov.get_int (RMV_GRUPPO); + int conto = rmov.get_int (RMV_CONTO); + long sottoconto = rmov.get_long(RMV_SOTTOCONTO); + TConto tc; + TRectype pc (_pcon->curr()); + tc.set(gruppo,0,0l); + if (!tc.read(pc)) + return TRUE; + tc.set(gruppo,conto,0l); + if (!tc.read(pc)) + return TRUE; + else t = pc.get_char(PCN_TMCF); + tc.set(gruppo,conto,sottoconto); + if (t != 'C' && t != 'F') + { + if (!tc.read(pc)) + return TRUE; + else + { + bool sosp = tc.sospeso(); + if (sosp) + return TRUE; + } + } + else + { + TLocalisamfile clifo(LF_CLIFO); + clifo.setkey(1); + clifo.zero(); + clifo.put(CLI_CODCF, sottoconto); + clifo.put(CLI_TIPOCF,t); + if (clifo.read() == NOERR) + { + bool sosp = clifo.get_bool(CLI_SOSPESO); + if (sosp) + return TRUE; + } + else + return TRUE; + } + } + return FALSE; +} + +//guarda se c'e' almeno un errore su almeno una riga (rmov) bool CG3100_application::segnala_errori_ogniriga() { - bool trovato = FALSE; - TString dep1; - _err = _err1 = _err2 = _err3 = ""; + TLocalisamfile& rmov = current_cursor()->file(LF_RMOV); + int gruppo, conto, anno, rcontr; + long sottoconto; + TDate datareg; + char sez, tipo, t; - if ((_tiporegistro != 1)&&(_tiporegistro != 2)) + if (current_cursor()->is_first_match(LF_RMOV)) { - int gruppo = current_cursor()->curr(LF_RMOV).get_int(RMV_GRUPPO); - int conto = current_cursor()->curr(LF_RMOV).get_int(RMV_CONTO); - long sottoconto = current_cursor()->curr(LF_RMOV).get_long(RMV_SOTTOCONTO); - if (gruppo == 0 || conto == 0 || sottoconto == 0L) + TRecnotype nrec = rmov.recno(); + rmov.zero(); + rmov.setkey(1); + rmov.put(RMV_NUMREG, _numero); + TRectype recc (rmov.curr()); + for (rmov.read(_isgteq); !rmov.eof() ;rmov.next()) { - _err = ERR_64; - trovato = TRUE; - } - TString tipoc = current_cursor()->curr(LF_RMOV).get(RMV_TIPOC); - _descr = DescrConto(gruppo, conto, sottoconto, tipoc); - if (_descr.empty()) - { - _err1 = ERR_66; - trovato = TRUE; - } - _alleg = AllegClifo(gruppo, conto, sottoconto); - _importo = current_cursor()->file(LF_RMOV).get_real(RMV_IMPORTO); - _appoggio = current_cursor()->curr(LF_RMOV).get(RMV_SEZIONE); - if (_appoggio != "D" && _appoggio != "A") - { - _err2 = ERR_75; - trovato = TRUE; - } - } - - if ((_tiporegistro == 1)||(_tiporegistro == 2)) //movimento iva - { - long record, numreg; - TLocalisamfile& rmoviva = current_cursor()->file(LF_RMOVIVA); - _numreg = current_cursor()->file(LF_MOV).get_long(MOV_NUMREG); - - if (current_cursor()->is_first_match(LF_RMOVIVA)) - { - record = rmoviva.recno(); - rmoviva.zero(); - rmoviva.put(RMI_NUMREG, _numreg); - for (rmoviva.read(); !rmoviva.eof() ;rmoviva.next()) + TRectype rec (rmov.curr()); + if (rec > recc) break; + gruppo = rec.get_int(RMV_GRUPPO); + conto = rec.get_int(RMV_CONTO); + sottoconto = rec.get_long(RMV_SOTTOCONTO); + anno = rec.get_int(RMV_ANNOES); + datareg = rec.get_date(RMV_DATAREG); + sez = rec.get_char(RMV_SEZIONE); + tipo = rec.get_char(RMV_TIPOC); + rcontr = rec.get_int(RMV_RCONTR); + + TConto tc (gruppo,conto,sottoconto); + + TRecnotype numerorec = rmov.recno(); + if (contropartita(rcontr)) + { + rmov.readat(nrec); + return TRUE; + } + rmov.readat(numerorec); + + if (anno != _annoeser || datareg != _datareg) { - _cod = rmoviva.get(RMI_CODIVA); - _tipod = rmoviva.get_int(RMI_TIPODET); - _impo = rmoviva.get_real(RMI_IMPONIBILE); - _impos = rmoviva.get_real(RMI_IMPOSTA); - _tipocr = rmoviva.get_int(RMI_TIPOCR); - numreg = rmoviva.get_long(RMI_NUMREG); - if (numreg != _numreg) - break; - else + rmov.readat(nrec); + return TRUE; + } + if (sez != 'D' && sez != 'A') + { + rmov.readat(nrec); + return TRUE; + } + if (tc.empty()) + { + rmov.readat(nrec); + return TRUE; + } + if (!tc.ok()) + { + rmov.readat(nrec); + return TRUE; + } + TRectype pc (_pcon->curr()); + tc.set(gruppo,0,0l); + + if (!tc.read(pc)) + { + rmov.readat(nrec); + return TRUE; + } + tc.set(gruppo,conto,0l); + if (!tc.read(pc)) + { + rmov.readat(nrec); + return TRUE; + } + else t = pc.get_char(PCN_TMCF); + if (t != tipo) + { + rmov.readat(nrec); + return TRUE; + } + tc.set(gruppo,conto,sottoconto); + if (t != 'C' && t != 'F') + { + if (!tc.read(pc)) { - if (_tiporegistro == 1) - switch (_tipocr) - { - case 2 : case 3: case 5: case 8: case 9: _err1 = ERR_09; - trovato = TRUE; - break; - default: break; - } - else - if (_tiporegistro == 2) - { - switch (_tipocr) - { - case 4: case 9: _err1 = ERR_09; - trovato = TRUE; - break; - default: break; - } - if ( _tipod!=0 && _tipod!=1 && _tipod!=3 && _tipod!=9 ) - { - _err3 = ERR_4; - trovato = TRUE; - } - } - if (_tipodoc != "AN") - { - _tabiva->setkey(1); - _tabiva->zero(); - dep1.format("%-4s",(const char*) _cod); - _tabiva->put("CODTAB", (const char*)dep1); - _tabiva->read(); - if (_tabiva->good()) - { - TString colonnac = _tabiva->get("S7"); - TString colonnaf = _tabiva->get("S8"); - bool sospeso = _tabiva->get_bool("B2"); - if (sospeso) - { - _err = ERR_2; - trovato = TRUE; - } - else if ((_stampa_mess_alleg_iva)&&((colonnac==" ") - ||(colonnaf==" "))) - { - _msg = MSG_54; - trovato = TRUE; - } - // break; - } - else - { - _err2 = ERR_1; - trovato = TRUE; - } - } + rmov.readat(nrec); + return TRUE; } - } //for - rmoviva.readat (record); + else + { + bool sosp = tc.sospeso(); + if (sosp) + { + rmov.readat(nrec); + return TRUE; + } + } + } + else + { + TLocalisamfile clifo(LF_CLIFO); + clifo.setkey(1); + clifo.zero(); + clifo.put(CLI_CODCF, sottoconto); + clifo.put(CLI_TIPOCF,t); + if (clifo.read() == NOERR) + { + bool sosp = clifo.get_bool(CLI_SOSPESO); + if (sosp) + { + rmov.readat(nrec); + return TRUE; + } + } + else + { + rmov.readat(nrec); + return TRUE; + } + if (_registro.not_empty()) //se su mov e' indicato il codice registro + { + TRegistro rg (_registro, _ae); + const int tiporeg = rg.tipo(); + if ((tiporeg == 1 && t != 'C') || (tiporeg == 2 && t != 'F')) + { + rmov.readat(nrec); + return TRUE; + } + } + } + TLocalisamfile saldi(LF_SALDI); + saldi.setkey(1); + saldi.zero(); + saldi.put(SLD_ANNOES,anno); + saldi.put(SLD_GRUPPO,gruppo); + saldi.put(SLD_CONTO, conto); + saldi.put(SLD_SOTTOCONTO,sottoconto); + + if (saldi.read() != NOERR) + { + rmov.readat(nrec); + return TRUE; + } + /* + TRecnotype numerorec = rmov.recno(); + if (contropartita(rmov,rcontr)) + { + rmov.readat(nrec); + return TRUE; + } + rmov.readat(numerorec); + */ } + rmov.readat(nrec); + } + return FALSE; +} + +bool CG3100_application::segnala_errori_iva() +{ + TLocalisamfile& rmoviva = current_cursor()->file(LF_RMOVIVA); + TTable tab_iva("%IVA"); + TString16 cod; + int tipodet, tipocr; + + if (current_cursor()->is_first_match(LF_RMOVIVA)) + { + TRecnotype nrec = rmoviva.recno(); + rmoviva.setkey(1); + rmoviva.zero(); + rmoviva.put(RMI_NUMREG, _numero); + TRectype recc (rmoviva.curr()); + for (rmoviva.read(_isgteq); !rmoviva.eof() ;rmoviva.next()) + { + TRectype rec (rmoviva.curr()); + if (rec > recc) break; + if (_registro.empty()) + { + rmoviva.readat(nrec); + _esiste_riga_iva = TRUE; + return TRUE; + } + cod = rec.get(RMI_CODIVA); + tipodet = rec.get_int(RMI_TIPODET); + tipocr = rec.get_int(RMI_TIPOCR); + tab_iva.zero(); + tab_iva.put("CODTAB", cod); + if (tab_iva.read()==NOERR) + { + int allc = tab_iva.get_int("S7"); + int allf = tab_iva.get_int("S8"); + bool s = tab_iva.get_bool("B2"); + if (s) + { + rmoviva.readat(nrec); + return TRUE; + } + if (_stampa_mess_alleg_iva) + if (allc == 0 && allf == 0) + { + rmoviva.readat(nrec); + return TRUE; + } + } + else + { + rmoviva.readat(nrec); + return TRUE; + } + if (tipodet == 1 || tipodet == 3 || tipodet == 5 || tipodet == 9) + if (_tiporegistro != 2) + { + rmoviva.readat(nrec); + return TRUE; + } + if (_tiporegistro == 1) + if (tipocr != 0 && tipocr != 1 && tipocr != 4 && tipocr != 9) + { + rmoviva.readat(nrec); + return TRUE; + } + if (_tiporegistro == 2) + if (tipocr != 0 && tipocr != 1 && tipocr != 2 && tipocr != 3 && tipocr != 5 && tipocr != 8 && tipocr != 9) + { + rmoviva.readat(nrec); + return TRUE; + } + } + rmoviva.readat(nrec); + } + else if (_registro.not_empty()) //cioe' si tratta di fattura + { + _nonesiste_riga_iva = TRUE; + return TRUE; } - return trovato; + return FALSE; } void CG3100_application::incrementa_totali() @@ -1596,8 +1997,8 @@ bool CG3100_application::set_print(int m) _curr3->set_filterfunction (filter_func_fatture); switch (_tipo_lista) { - case movimenti: - { + case movimenti: + { _scelta_stampa = atoi(msk.get(F_MOVIMENTI)); _annoes = msk.get_int (F_ANNO); _decidi = msk.get_int(F_DECIDI); @@ -1644,9 +2045,9 @@ bool CG3100_application::set_print(int m) da.zero(); a.zero(); if (_data_ini.ok()) - da.put(MOV_DATAREG, _data_ini); + da.put(MOV_DATAREG, _data_ini); if (_data_fin.ok()) - a.put(MOV_DATAREG, _data_fin); + a.put(MOV_DATAREG, _data_fin); current_cursor()->setregion(da,a); add_file(LF_MOV); add_file(LF_RMOV,LF_MOV); @@ -1698,12 +2099,6 @@ bool CG3100_application::set_print(int m) a.put(MOV_TIPO, _tipo_fin); if (_codice_fin != 0) a.put(MOV_CODCF, _codice_fin); - /* - if (_data_ini.ok()) - da.put(MOV_DATAREG, _data_ini); - if (_data_fin.ok()) - a.put(MOV_DATAREG, _data_fin); - */ da.put(MOV_TIPO, _tipo_ini); current_cursor()->setregion(da,a); add_file(LF_MOV); @@ -1716,8 +2111,8 @@ break; case movimenti_sezionale: break; - default: - break; +default: +break; } init_print(msk); @@ -1749,15 +2144,12 @@ void CG3100_application::user_create() _cur2 = add_cursor (_curr2); _cur3 = add_cursor (_curr3); - //_curr1->set_filterfunction (filter_func); - //_curr2->set_filterfunction (filter_func); - //_curr3->set_filterfunction (filter_func_fatture); - _caus = new TLocalisamfile(LF_CAUSALI); _clifo = new TLocalisamfile(LF_CLIFO); _comuni = new TLocalisamfile(LF_COMUNI); _attiv = new TLocalisamfile(LF_ATTIV); _pcon = new TLocalisamfile(LF_PCON); + _saldi = new TLocalisamfile(LF_SALDI); _rmoviva = new TLocalisamfile(LF_RMOVIVA); _nditte = new TLocalisamfile(LF_NDITTE); _tabiva = new TTable(TAB_IVA); @@ -1779,6 +2171,8 @@ void CG3100_application::user_destroy() // releasev e arrmask delete _tabreg; delete _tabtpd; delete _rmoviva; + delete _saldi; + } void CG3100_application::init_print(const TMask& msk) @@ -1794,6 +2188,7 @@ void CG3100_application::init_print(const TMask& msk) { reset_print(); _flags = 0; + _err.reset(); _tot_dare_giornaliero = 0; _tot_avere_giornaliero = 0; _tot_dare_generale = 0; @@ -1809,7 +2204,7 @@ void CG3100_application::init_print(const TMask& msk) _flags |= ST_MESS_ALLEG; _stampa_anno_comp = (bool)(msk.get(F_ANNOC)=="X"); if (_stampa_anno_comp) - _flags |= ST_ANNO_COMP; + _flags |= ST_ANNO_COMP; _controllo_mov_errati = atoi(msk.get(F_CONTROLLO)); if (_controllo_mov_errati == 1) _flags |= ST_SOLO_MOVERR; @@ -1939,7 +2334,8 @@ void CG3100_application::preprocess_header() set_header (soh++, (const char*) sep); - sep = "Studio "; + //sep = "Studio "; + sep = ""; sep << "Data @< Pag. @#"; sep.right_just(127); @@ -1951,31 +2347,33 @@ void CG3100_application::preprocess_header() { sep.overwrite ("Lista movimenti"); set_header (soh++, (const char*)sep); - if (_decidi == 2) + if (_decidi == 2) // se _decidi e' 1 _annoes e' sempre uguale a zero { if (_annoes != 0) { - set_header (soh, "Anno %d", _annoes); - if (_flags & ST_DATA) - { - set_header (soh, "@10gda@13g%s",_data_ini.string()); - set_header (soh, "@24ga@26g%s",_data_fin.string()); - } + set_header (soh, "Anno comp. %d", _annoes); + if (_flags & ST_DATA) + { + set_header (soh, "@16gda@19g%s",_data_ini.string()); + set_header (soh, "@30ga@32g%s",_data_fin.string()); + } } - else - if (_flags & ST_DATA) - { - set_header (soh, "Dalla data@12g%s",_data_ini.string()); - set_header (soh, "@24galla data@34g%s",_data_fin.string()); - } - else - set_header (soh, "Completa in ordine di data"); + else // _annoes == 0 + if (_flags & ST_DATA) + { + set_header (soh, "Dalla data@12g%s",_data_ini.string()); + if (_data_fin.ok()) + set_header (soh, "@24galla data@34g%s",_data_fin.string()); + } + else + set_header (soh, "Completa in ordine di data"); } else if (_flags & ST_NUMERO) { set_header (soh, "dal numero@12g%d", _numreg_ini); - set_header (soh, "@20gal numero@30g%d", _numreg_fin); + if (_numreg_fin != 0) + set_header (soh, "@20gal numero@30g%d", _numreg_fin); } else set_header (soh, "Completa in ordine di numero"); @@ -2000,15 +2398,23 @@ void CG3100_application::preprocess_header() else if (_flags & ST_SOLO_MOVERR) set_header (soh, "@50g(solo movimenti errati)"); else set_header (soh, "@50g(senza controllo movimenti)"); - if ((_flags & (ST_ANNO_COMP|ST_MESS_ALLEG)) == 1) - set_header (soh, "@78gcon messaggi: anno di competenza, allegato iva"); + if (_flags & ST_MESS_ALLEG) + { + if (_flags & ST_ANNO_COMP) + set_header (soh, "@78gcon messaggi: anno di competenza, allegato iva"); + else + set_header (soh, "@78gcon messaggio: allegato iva"); + } else if (_flags & ST_ANNO_COMP) - set_header (soh, "@78gcon messaggio: anno di competenza"); - else if (_flags & ST_MESS_ALLEG) - set_header (soh, "@78gcon messaggio: allegato iva"); + { + if (_flags & ST_MESS_ALLEG) + set_header (soh, "@78gcon messaggi: anno di competenza, allegato iva"); + else + set_header (soh, "@78gcon messaggio: anno di competenza"); + } sep.fill('-'); set_header (++soh, (const char *) sep); - set_header (++soh, "Rg Cod Causale@30gDescrizione@56gCodice conto@72gDescrizione conto@98gDare@116gAvere@130gSB"); + set_header (++soh, "Rg Cod Causale@30gDescrizione@56gCodice conto@71gDescrizione conto@98gDare@116gAvere@130gSB"); } else { @@ -2016,29 +2422,29 @@ void CG3100_application::preprocess_header() set_header (soh++, (const char*)sep); if (_decidi == 2) { - if (_annoes != 0) - { - set_header (soh, "Anno %d", (const char*)_annoes); - if (_flags & ST_DATA) - { - set_header (soh, "@10gda@13g%s",_data_ini.string()); - set_header (soh, "@24ga@26g%s",_data_fin.string()); - } - } - else - if (_flags & ST_DATA) - { - set_header (soh, "Dalla data@12g%s",_data_ini.string()); - set_header (soh, "@24galla data@34g%s",_data_fin.string()); - } - else - set_header (soh, "Completa in ordine di data"); + if (_annoes != 0) + { + set_header (soh, "Anno comp. %d", (const char*)_annoes); + if (_flags & ST_DATA) + { + set_header (soh, "@16gda@19g%s",_data_ini.string()); + set_header (soh, "@30ga@32g%s",_data_fin.string()); + } + } + else + if (_flags & ST_DATA) + { + set_header (soh, "Dalla data@12g%s",_data_ini.string()); + set_header (soh, "@24galla data@34g%s",_data_fin.string()); + } + else + set_header (soh, "Completa in ordine di data"); } else if (_flags & ST_NUMERO) { - set_header (soh, "@46gdal numero@57g%d", (const char*)_numreg_ini); - set_header (soh, "@65gal numero@75g%d",(const char*)_numreg_fin); + set_header (soh, "@46gdal numero@57g%d", (const char*)_numreg_ini); + set_header (soh, "@65gal numero@75g%d",(const char*)_numreg_fin); } else set_header (soh, "@46gCompleta in ordine di numero"); @@ -2051,7 +2457,7 @@ void CG3100_application::preprocess_header() set_header (soh++, "@86gtutte le causali"); sep.fill('-'); set_header (soh++, (const char *) sep); - set_header (soh++, "Rg Cod Causale@30gDescrizione@56gCodice conto@72gDescrizione conto@98gDare@116gAvere@130gSB"); + set_header (soh++, "Rg Cod Causale@30gDescrizione@56gCodice conto@71gDescrizione conto@98gDare@116gAvere@130gSB"); } break; @@ -2060,11 +2466,11 @@ void CG3100_application::preprocess_header() set_header (soh, (const char*)sep); if (_annoes != 0) { - set_header (soh, "@15gAnno %d", (const char*)_annoes); + set_header (soh, "@15gAnno comp. %d", (const char*)_annoes); if (_flags & ST_DATA) { - set_header (soh, "@25gdalla data@36g%s",_data_ini.string()); - set_header (soh, "@47galla data@57g%s",_data_fin.string()); + set_header (soh, "@31gdalla data@42g%s",_data_ini.string()); + set_header (soh, "@53galla data@63g%s",_data_fin.string()); } } else @@ -2098,11 +2504,6 @@ void CG3100_application::preprocess_header() break; } set_header (++soh,(const char*)sep); - //if (_tipo_lista != fatture) - //{ - // sep = ""; - // set_header (++soh,(const char*)sep); - //} } int cg3100(int argc, char* argv[]) diff --git a/cg/cg3100a.uml b/cg/cg3100a.uml index 452ea7199..49155b5ad 100755 --- a/cg/cg3100a.uml +++ b/cg/cg3100a.uml @@ -55,7 +55,7 @@ END LIST F_CONTROLLO 21 BEGIN PROMPT 2 7 "Controllo movimenti errati " - HELP "La scelta 1 stampa solo le registrazioni non errate; la scelta 2 permette di listare tutte le registrazioni inserite, segnalando quelle errate; la scelta 3 stampa solo le registrazioni errate" + HELP "La scelta 1 stampa tutte le registrazioni senza la segnalazione di quelle errate; la scelta 2 permette di listare tutte le registrazioni inserite, segnalando quelle errate; la scelta 3 stampa solo le registrazioni errate" ITEM "3|No" MESSAGE HIDE,1@|RESET,1@ ITEM "2|Si" MESSAGE SHOW,1@ ITEM "1|Stampa movimenti errati" MESSAGE SHOW,1@ @@ -126,6 +126,8 @@ BEGIN OUTPUT F_NUMEROFIN NUMREG CHECKTYPE NORMAL FLAGS "R" + NUM_EXPR {(#F_NUMEROFIN==0)||(#F_NUMEROFIN>=#F_NUMEROINI)} + WARNING "Limite superiore errato" GROUP 2 END diff --git a/cg/cg3100c.uml b/cg/cg3100c.uml index d7e888fa1..37491b76d 100755 --- a/cg/cg3100c.uml +++ b/cg/cg3100c.uml @@ -6,14 +6,14 @@ PAGE "" -1 -1 76 19 NUMBER F_CODDITTA 5 BEGIN - PROMPT 2 2 "Ditta " + PROMPT 2 2 "Ditta " FLAGS "FRD" USE LF_NDITTE KEY 1 CHECKTYPE REQUIRED INPUT CODDITTA F_CODDITTA DISPLAY "Codice" CODDITTA - DISPLAY "Ragione sociale @50" RAGSOC - OUTPUT F_CODDITTA CODDITTA + DISPLAY "Ragione sociale @50" RAGSOC + OUTPUT F_CODDITTA CODDITTA OUTPUT F_RAGSOC RAGSOC END @@ -26,12 +26,14 @@ END NUMBER F_ANNO 4 BEGIN PROMPT 2 5 "Anno esercizio " - HELP "Se non indicato nessun anno esercizio significa che si richiede la stampa come specificato nei campi: dalla data, alla data" - USE ESC KEY 1 + USE ESC CHECKTYPE NORMAL INPUT CODTAB F_ANNO - DISPLAY "Anno esercizio@50" CODTAB + DISPLAY "Anno" CODTAB + DISPLAY "Data inizio esercizio" D0 + DISPLAY "Data fine esercizio" D1 OUTPUT F_ANNO CODTAB + FLAGS "RZ" END DATE F_DATASTAMPA diff --git a/cg/cg3200.cpp b/cg/cg3200.cpp index 87553e188..7d8b6a1f9 100755 --- a/cg/cg3200.cpp +++ b/cg/cg3200.cpp @@ -25,12 +25,16 @@ static TString256 tmp; -int date2esc(const TDate& d, int* prevesc = NULL); +int date2esc(const TDate& d, int* prevesc = NULL); +bool sottoc_handler_ini (TMask_field& f, KEY k); +bool sottoc_handler_fine (TMask_field& f, KEY k); class CG3200_application : public TPrintapp { static bool data_inizio (TMask_field& f, KEY k); static bool data_fine (TMask_field& f, KEY k); + friend bool sottoc_handler_ini (TMask_field& f, KEY k); + friend bool sottoc_handler_fine (TMask_field& f, KEY k); TDociva_array _b; TRelation* _rel; @@ -45,8 +49,8 @@ class CG3200_application : public TPrintapp Saldo _sld; TDate _data_ini,_data_fine,_data_finese,_data_finesesucc,_ultima_data_reg; - TDate _datareg,_datadoc,_data_inizioese,_datareg_stampa; - int _cur1,_gruppo,_conto,_numcarat,_stampanum,_numivd; + TDate _datareg,_datadoc,_data_inizioese,_datareg_stampa,_inizioes; + int _cur1,_gruppo,_conto,_numcarat,_stampanum,_numivd,_annoiva; int _numrig,_natdoc,_tipo,_tipostampa,_g_prec,_c_prec,_numrivd_int; real _progredare,_progreavere,_totprogre_dare_al,_totprogre_avere_al; real _totprogre_dare,_totprogre_avere,_importo; @@ -56,10 +60,12 @@ class CG3200_application : public TPrintapp real _saldo_movimenti,_saldo_progressivi,_totale_saldo; TString _ragsoc,_indulc,_civulc,_capulc,_com,_prov,_comulc; long _codice_ditta,_s_prec; - TString _tipodoc,_codcaus,_descrcaus,_descrdociva,_regiva; + TString _tipodoc,_codcaus,_descrcaus,_descrdociva,_regiva,_g_contr,_c_contr,_s_contr; char _sezivd,_lettivd; TString _descrizione,_sezione,_numdoc,_descrizionemov,_numrivd,_descr; - TString _dataregs, _datadocs,_gruppocontr,_contocontr,_sottocontocontr; + TString _dataregs, _datadocs; + int _gruppocontr,_contocontr; + long _sottocontocontr; bool _stampaprogre,_stampatotiva,_stampatot,_prima_volta,_stampa_mov_prov; @@ -67,7 +73,7 @@ class CG3200_application : public TPrintapp int _anno_corrente,_anno_precedente,_indbil; long _sottoc,_numreg,_numgio,_protiva; bool _stampa_progressivi_si,_competenza,_inizio_stampa,_puoi_stampare; - char _tipocf,_tmcf; + char _tmcf,_tipo_contr; TDate _dataregrmov; int _gruppof,_contof; @@ -108,12 +114,10 @@ public: void data_fine_esercizio(int); const char* descrizione_gruppo(); const char* descrizione_conto(); - const char* descrizione_gruppo_clifo(); - const char* descrizione_conto_clifo(); const char* descrizione_classe(char,char,int,int); bool almeno_un_record(); void ricerca_dati_ditta(); - void conto(); + void conto(int,int,bool); CG3200_application() {} }; @@ -132,7 +136,204 @@ void CG3200_application::process_link(int id, const char* txt) TExternal_app pn(app); pn.run(); -} +} + +bool sottoc_handler_ini(TMask_field& f, KEY key) +{ + const short id = f.dlg(); + const int gruppo = f.mask().get_int(F_GRUPPOINI); + const int conto = f.mask().get_int(F_CONTOINI_CONTO); + const long sottoconto = f.mask().get_long(id); + TString ds; + TString80 rs; + TLocalisamfile pconti (LF_PCON); + + if ( key == K_ENTER ) + { + if (sottoconto != 0 && conto == 0) + return f.warning_box("Manca il CONTO"); + + if (conto != 0 && gruppo == 0) + return f.warning_box("Manca il GRUPPO"); + } + + if ( key == K_TAB ) + { + if (id == F_SOTTOCINI_CONTO) + { + pconti.zero(); + pconti.put(PCN_GRUPPO, gruppo) ; + pconti.put(PCN_CONTO, conto); + pconti.put(PCN_SOTTOCONTO, sottoconto); + pconti.setkey(1); + pconti.read(_isequal, _nolock); + if (pconti.good()) + ds = pconti.get(PCN_DESCR); + else + ds = ""; + + f.mask().set(F_DESCRINI_CONTO, ds); + f.mask().set(F_DESCRINI_CLIENTE, ds); + f.mask().set(F_DESCRINI_FORN, ds); + } + if (id == F_SOTTOCINI_CLIENTE || id == F_SOTTOCINI_FORN) + { + char tipo = id == F_SOTTOCINI_CLIENTE ? 'C' : 'F'; + TLocalisamfile clifo (LF_CLIFO); + if (sottoconto != 0) + { + clifo.zero(); + clifo.put(CLI_TIPOCF,tipo); + clifo.put(CLI_CODCF, sottoconto) ; + clifo.setkey(1); + if (clifo.read(_isequal, _nolock) == NOERR) + { + rs = clifo.get(CLI_RAGSOC); + char tipoa = clifo.get_char("TIPOAPER"); + + if (tipoa == 'F') + { + TString80 cognome, nome; + cognome = rs.mid(0,30); + nome = rs.mid(30,20); + cognome.trim(); nome.trim(); + + rs = cognome; + rs << " " << nome; + } + } + else + rs = ""; + + f.mask().set(F_DESCRINI_CLIENTE, rs); + f.mask().set(F_DESCRINI_FORN, rs); + } + else + if (gruppo != 0 && conto != 0) + { + pconti.zero(); + pconti.put(PCN_GRUPPO, gruppo) ; + pconti.put(PCN_CONTO, conto); + pconti.setkey(1); + pconti.read(_isequal, _nolock); + if (pconti.good()) + ds = pconti.get(PCN_DESCR); + else + ds = ""; + + f.mask().set(F_DESCRINI_CLIENTE, ds); + f.mask().set(F_DESCRINI_FORN, ds); + f.mask().set(F_DESCRINI_CONTO, ds); + } + } + } + return TRUE; +} + +bool sottoc_handler_fine(TMask_field& f, KEY key) +{ + const short id = f.dlg(); + const int gruppo = f.mask().get_int(F_GRUPPOFINE); + const int conto = f.mask().get_int(F_CONTOFINE_CONTO); + const long sottoconto = f.mask().get_long(id); + TString ds; + TString80 rs; + TLocalisamfile pconti (LF_PCON); + + if ( key == K_ENTER ) + { + if (sottoconto != 0 && conto == 0) + return f.warning_box("Manca il CONTO"); + + if (conto != 0 && gruppo == 0) + return f.warning_box("Manca il GRUPPO"); + } + + if ( key == K_TAB ) + { +// if (!f.focusdirty() && gruppo == 0 && conto == 0) return TRUE; +/* + if (sottoconto != 0 && conto == 0) + { + f.warning_box("Manca il CONTO"); + return FALSE; + } + if (conto != 0 && gruppo == 0) + { + f.warning_box("Manca il GRUPPO"); + return FALSE; + } +*/ + if (id == F_SOTTOCFINE_CONTO) + { + pconti.zero(); + pconti.put(PCN_GRUPPO, gruppo) ; + pconti.put(PCN_CONTO, conto); + pconti.put(PCN_SOTTOCONTO, sottoconto); + pconti.setkey(1); + pconti.read(_isequal, _nolock); + if (pconti.good()) + ds = pconti.get(PCN_DESCR); + else + ds = ""; + + f.mask().set(F_DESCRFINE_CONTO, ds); + f.mask().set(F_DESCRFINE_CLIENTE, ds); + f.mask().set(F_DESCRFINE_FORN, ds); + } + if (id == F_SOTTOCFINE_CLIENTE || id == F_SOTTOCFINE_FORN) + { + char tipo = id == F_SOTTOCFINE_CLIENTE ? 'C' : 'F'; + TLocalisamfile clifo (LF_CLIFO); + if (sottoconto != 0) + { + clifo.zero(); + clifo.put(CLI_TIPOCF,tipo); + clifo.put(CLI_CODCF, sottoconto) ; + clifo.setkey(1); + if (clifo.read(_isequal, _nolock) == NOERR) + { + rs = clifo.get(CLI_RAGSOC); + char tipoa = clifo.get_char("TIPOAPER"); + + if (tipoa == 'F') + { + TString80 cognome, nome; + cognome = rs.mid(0,30); + nome = rs.mid(30,20); + cognome.trim(); nome.trim(); + + rs = cognome; + rs << " " << nome; + } + } + else + rs = ""; + + f.mask().set(F_DESCRFINE_CLIENTE, rs); + f.mask().set(F_DESCRFINE_FORN, rs); + } + else + if (gruppo != 0 && conto != 0) + { + pconti.zero(); + pconti.put(PCN_GRUPPO, gruppo) ; + pconti.put(PCN_CONTO, conto); + pconti.setkey(1); + pconti.read(_isequal, _nolock); + if (pconti.good()) + ds = pconti.get(PCN_DESCR); + else + ds = ""; + + f.mask().set(F_DESCRFINE_CLIENTE, ds); + f.mask().set(F_DESCRFINE_FORN, ds); + f.mask().set(F_DESCRFINE_CONTO, ds); + } + } + } + return TRUE; +} int date2esc(const TDate& d, int* prevesc) { @@ -285,7 +486,9 @@ bool CG3200_application::data_fine(TMask_field& f, KEY k) return FALSE; } - app()._anno_ghost = date2esc(data_ini); + app()._anno_ghost = date2esc(data_ini); + + app()._inizioes = app()._inizioEs; if (data < app()._inizioEs || data > app()._fineEs) { @@ -357,20 +560,13 @@ void CG3200_application::fai_stampa132() set_row (1,"@30g#7t", &_numdoc); set_row (1,"@38g#3t", &_codcaus); - set_row (1,"@117g#3t", &_gruppocontr); - set_row (1,"@120g#3t", &_contocontr); - set_row (1,"@123g#6t", &_sottocontocontr); + set_row (1,"@117g#3t", &_g_contr); + set_row (1,"@120g#3t", &_c_contr); + set_row (1,"@123g#6t", &_s_contr); } void CG3200_application::fai_stampa198() -{ - TLocalisamfile & rmov = current_cursor()->file(LF_RMOV); - long rec; - TDate datasucc; - TString datasuccstring,dataregrmovstring; - int gruppof,contof; - long sottocf; - +{ set_row (1,"@0g#t", &_dataregs); if (_stampanum == 1) set_row (1,"@11g$[r]#7d$[n]", &_numreg); @@ -384,30 +580,9 @@ void CG3200_application::fai_stampa198() set_row (1,"@153g#t", &_saldo_movimenti_str); - set_row (1,"@169g#3t", &_gruppocontr); - set_row (1,"@172g#3t", &_contocontr); - set_row (1,"@175g#6t", &_sottocontocontr); - - if (_tipo < 3) - set_row (1,"@185g#t" , &_regiva); - set_row (1,"@194g#5d", &_protiva); - _dataregrmov = current_cursor()->curr(LF_RMOV).get_date(RMV_DATAREG); - dataregrmovstring=_dataregrmov.string(); - -//Gestire la stampa di saldo_progressivi nella postprocess_page di RMOV - - rec = rmov.recno(); - rmov.next(); - gruppof = rmov.get_int(RMV_GRUPPO); - contof = rmov.get_int(RMV_CONTO); - sottocf = rmov.get_int(RMV_SOTTOCONTO); - datasucc = rmov.get_date(RMV_DATAREG); - datasuccstring=datasucc.string(); - if (((gruppof!=_gruppo)||(contof!=_conto)||(sottocf!=_sottoc))||(rmov.eof())) - datasucc = (""); - if (datasucc != _dataregrmov) - set_row (1,"@136g#t", &_saldo_progressivi_str); - rmov.readat(rec); + set_row (1,"@169g#3t", &_g_contr); + set_row (1,"@172g#3t", &_c_contr); + set_row (1,"@175g#6t", &_s_contr); } void CG3200_application::stampa_totali132() @@ -450,19 +625,25 @@ void CG3200_application::stampa_totali198() set_row (3,"@119g%15.0r", &_totale_periodo_avere); set_row (3,"@153g%15.0r", &_saldo_movimenti); set_row (4,"@32gTOTALI PROGRESSIVI@102g%15.0r", &_totprogre_dare); - set_row (4,"@119g%15.0r", &_totprogre_avere); + set_row (4,"@119g%15.0r", &_totprogre_avere); set_row (4,"@136g%15.0r", &_saldo_progressivi); if (_stampaprogre) //Progressivi attuali { set_row(5,"@32gTOTALI PROGRESSIVI AL@55g%s",(const char*)_ultima_data_reg.string()); set_row (5,"@102g%15.0r", &_totprogre_dare_al); - set_row (5,"@119g%15.0r", &_totprogre_avere_al); + set_row (5,"@119g%15.0r", &_totprogre_avere_al); set_row (5,"@136g%15.0r", &_saldo_progressivi); } } bool CG3200_application::preprocess_page(int file, int counter) -{ +{ + TLocalisamfile & rmov = current_cursor()->file(LF_RMOV); + long rec; + TDate datasucc; + TString datasuccstring,dataregrmovstring; + int gruppof,contof; + long sottocf; long record; TString provvis = ""; int annoes; @@ -480,13 +661,13 @@ bool CG3200_application::preprocess_page(int file, int counter) _conto = atoi(current_cursor()->curr(LF_SALDI).get(SLD_CONTO)); _sottoc = atol(current_cursor()->curr(LF_SALDI).get(SLD_SOTTOCONTO)); annoes = atoi(current_cursor()->curr(LF_SALDI).get(SLD_ANNOES)); - conto(); + conto(_gruppo,_conto,TRUE); if (annoes != _anno_corrente && annoes != _anno_precedente) - return FALSE; + return FALSE; if (_g_prec == _gruppo && _c_prec == _conto && _s_prec == _sottoc) - return FALSE; + return FALSE; _g_prec = _gruppo; _c_prec = _conto; @@ -519,12 +700,13 @@ bool CG3200_application::preprocess_page(int file, int counter) { _puoi_stampare = TRUE; calcola_progressivi(); + _saldo_progressivi += _saldo_progre_prec; stampa_progre_riporto(); } else { - _puoi_stampare = FALSE; - return FALSE; + _puoi_stampare = FALSE; + return FALSE; } } else @@ -538,14 +720,15 @@ bool CG3200_application::preprocess_page(int file, int counter) } else { - _puoi_stampare = TRUE; + _puoi_stampare = TRUE; + _saldo_progressivi += _saldo_progre_prec; stampa_progre_riporto(); } } break; case LF_RMOV: - { + { // Ricerca la contropartita di quel movimento TLocalisamfile& rmov = current_cursor()->file(LF_RMOV); @@ -560,9 +743,12 @@ bool CG3200_application::preprocess_page(int file, int counter) rmov.read(); if (rmov.bad()) rmov.curr().zero(); - _gruppocontr = rmov.curr().get(RMV_GRUPPO); - _contocontr = rmov.curr().get(RMV_CONTO); - _sottocontocontr = rmov.curr().get(RMV_SOTTOCONTO); + _gruppocontr = rmov.curr().get_int (RMV_GRUPPO); + _contocontr = rmov.curr().get_int (RMV_CONTO); + _sottocontocontr = rmov.curr().get_long(RMV_SOTTOCONTO); + _g_contr = rmov.get(RMV_GRUPPO); + _c_contr = rmov.get(RMV_CONTO); + _s_contr = rmov.get(RMV_SOTTOCONTO); rmov.setkey(2); rmov.readat(record); @@ -577,8 +763,9 @@ bool CG3200_application::preprocess_page(int file, int counter) _mov->read(); if (_mov->bad()) _mov->zero(); - _annoes = _mov->get_int(MOV_ANNOES); - _regiva = _mov->curr().get(MOV_REG); + _annoes = _mov->get_int(MOV_ANNOES); + _regiva = _mov->curr().get(MOV_REG); + _annoiva = _mov->curr().get_int(MOV_ANNOIVA); // Controlla se saldo e' diverso da 0 @@ -586,43 +773,56 @@ bool CG3200_application::preprocess_page(int file, int counter) { _sezione = current_cursor()->curr(LF_RMOV).get(RMV_SEZIONE); - if (_annomsk == 0) + if (_annomsk == 0) { - _datareg = (_mov->curr().get(MOV_DATAREG)); + _datareg = (_mov->curr().get(MOV_DATAREG)); _datareg_stampa = _datareg; } - else - if (_annomsk != 0) + else + if (_annomsk != 0) { - _datareg = _mov->curr().get(MOV_DATACOMP); + _datareg = _mov->curr().get(MOV_DATACOMP); _datareg_stampa = _mov->curr().get(MOV_DATAREG); - } + } provvis = _mov->curr().get(MOV_PROVVIS); - + _dataregs = _datareg_stampa.string(); if ((_stampa_mov_prov)||((!_stampa_mov_prov)&&(provvis.trim().empty()))) - { - if ((_datareg >= _data_ini) && (_datareg <= _data_fine)) { + if ((_datareg >= _data_ini) && (_datareg <= _data_fine)) + { + // Determino l' anno di competenza dell' operazione in esame + + int anno = date2esc(_datareg_stampa); + if (anno != _annoes) + if (_numcarat == 1) + set_row (1, "@131g*"); + else + if (_numcarat == 2) + set_row (1, "@197g*"); + _codcaus = _mov->curr().get(MOV_CODCAUS); _tipodoc = _mov->curr().get(MOV_TIPODOC); if (_stampatotiva && (_tmcf == 'C' || _tmcf == 'F')) - { - documenti_iva(); - _b.add_riga(_descrdociva,_importo, _natdoc); - } + { + if (_tipodoc != "") + { + documenti_iva(); + _b.add_riga(_descrdociva,_importo, _natdoc); + } + } _datadoc = (_mov->curr().get(MOV_DATADOC)); _datadocs = _datadoc.string(); _numdoc = _mov->curr().get(MOV_NUMDOC); - descrizione_causale(); + descrizione_causale(); _descrizionemov = _mov->curr().get(MOV_DESCR); - _numgio = atol(_mov->curr().get(MOV_NUMGIO)); + _numgio = atol(_mov->curr().get(MOV_NUMGIO)); - _descrizione = current_cursor()->curr(LF_RMOV).get(RMV_DESCR); + _descrizione = current_cursor()->curr(LF_RMOV).get(RMV_DESCR); - if (_numcarat == 1) // Stampa 132 caratteri + if (_numcarat == 1) // Stampa 132 caratteri { if (_descrizione != "") { @@ -638,15 +838,25 @@ bool CG3200_application::preprocess_page(int file, int counter) } } else if (_descrizione == "") - { - set_row (1,"@42g%.18s", (const char*) _descrcaus); - set_row (1,"@61g%.23s", (const char*) _descrizionemov); - } + if (_descrizionemov != "") + { + set_row (1,"@42g%.18s", (const char*) _descrcaus); + set_row (1,"@61g%.23s", (const char*) _descrizionemov); + } + else + if (_descrizionemov == "") + { + conto(_gruppocontr,_contocontr,FALSE); + TConto tc (_gruppocontr,_contocontr,_sottocontocontr,_tipo_contr); + TString descr_contr = tc.descrizione(); + set_row (1,"@42g%.18s", (const char*) _descrcaus); + set_row (1,"@61g%.23s", (const char*) descr_contr); + } } - else - if (_numcarat == 2) // Stampa 198 caratteri - { - if (_descrizione != "") + else + if (_numcarat == 2) // Stampa 198 caratteri + { + if (_descrizione != "") { if (_descrizionemov != "") { @@ -659,11 +869,21 @@ bool CG3200_application::preprocess_page(int file, int counter) set_row (1,"@68g%.32s", (const char*) _descrizione); } } - else if (_descrizione == "") - { - set_row (1,"@42g%.25s", (const char*) _descrcaus); - set_row (1,"@68g%.32s", (const char*) _descrizionemov); - } + else if (_descrizione == "") + if (_descrizionemov != "") + { + set_row (1,"@42g%.25s", (const char*) _descrcaus); + set_row (1,"@68g%.32s", (const char*) _descrizionemov); + } + else + if (_descrizionemov == "") + { + conto(_gruppocontr,_contocontr,FALSE); + TConto tc (_gruppocontr,_contocontr,_sottocontocontr,_tipo_contr); + TString descr_contr = tc.descrizione(); + set_row (1,"@42g%.25s", (const char*) _descrcaus); + set_row (1,"@68g%.32s", (const char*) descr_contr); + } } if (_sezione == "D") @@ -671,31 +891,31 @@ bool CG3200_application::preprocess_page(int file, int counter) _totale_periodo_dare += _importo; _riporto_parziale_dare += _importo; - if (_numcarat == 1) // Stampa 132 caratteri - set_row (1,"@85g%s", (const char*) _importo_str); + if (_numcarat == 1) // Stampa 132 caratteri + set_row (1,"@85g%s", (const char*) _importo_str); else - if (_numcarat == 2) // Stampa 198 caratteri + if (_numcarat == 2) // Stampa 198 caratteri { _saldo_progressivi += _importo; _saldo_movimenti += _importo; - set_row (1,"@102g%s", (const char*) _importo_str); - } + set_row (1,"@102g%s", (const char*) _importo_str); + } } else if (_sezione == "A") { _totale_periodo_avere += _importo; - _riporto_parziale_avere += _importo; + _riporto_parziale_avere += _importo; - if (_numcarat == 1) // Stampa 132 caratteri - set_row (1,"@101g%s", (const char*) _importo_str); + if (_numcarat == 1) // Stampa 132 caratteri + set_row (1,"@101g%s", (const char*) _importo_str); else if (_numcarat == 2) // Stampa 198 caratteri { _saldo_progressivi -= _importo; _saldo_movimenti -= _importo; - set_row (1,"@119g%s", (const char*) _importo_str); - } - } + set_row (1,"@119g%s", (const char*) _importo_str); + } + } _saldo_progressivi_str=_saldo_progressivi.string("###############"); _saldo_movimenti_str=_saldo_movimenti.string("###############"); @@ -703,17 +923,40 @@ bool CG3200_application::preprocess_page(int file, int counter) { ricerca_regiva(); _protiva = atol(_mov->curr().get(MOV_PROTIVA)); + if (_protiva != 0) + set_row (1,"@191g%5d", _protiva); + + if (_tipo < 3) + set_row (1,"@182g#t" , &_regiva); + _dataregrmov = current_cursor()->curr(LF_RMOV).get_date(RMV_DATAREG); + dataregrmovstring=_dataregrmov.string(); + +//Gestire la stampa di saldo_progressivi nella postprocess_page di RMOV + + rec = rmov.recno(); + rmov.next(); + gruppof = rmov.get_int(RMV_GRUPPO); + contof = rmov.get_int(RMV_CONTO); + sottocf = rmov.get_int(RMV_SOTTOCONTO); + datasucc = rmov.get_date(RMV_DATAREG); + datasuccstring=datasucc.string(); + if (((gruppof!=_gruppo)||(contof!=_conto)||(sottocf!=_sottoc))||(rmov.eof())) + datasucc = (""); + if (datasucc != _dataregrmov) + set_row (1,"@136g#t", &_saldo_progressivi_str); + rmov.readat(rec); } + return TRUE; } else - return FALSE; - } + return FALSE; + } } else - return FALSE; - break; - } + return FALSE; + break; + } default: break; } @@ -833,7 +1076,6 @@ void CG3200_application::descrizione_causale() void CG3200_application::documenti_iva() { TString dep; -// _tipodoc = _mov->curr().get(MOV_TIPODOC); _tabtpd->curr().zero(); dep << format ("%2s",(const char*) _tipodoc); @@ -848,7 +1090,7 @@ void CG3200_application::ricerca_regiva() TString16 dep; _tabreg->curr().zero(); - dep << format("%04d", _annoes); + dep << format("%04d", _annoiva); dep << format("%3s" , (const char*) _regiva); _tabreg->curr().put("CODTAB", (const char*) dep); _tabreg->read(); @@ -891,16 +1133,15 @@ bool CG3200_application::set_print(int) _stampanum = atoi(_msk->get(F_STAMPANUM)); _stampa_mov_prov = (bool)(_msk->get(F_STAMPAMOVPROV) == "X"); int gruppoini = atoi(_msk->get(F_GRUPPOINI)); - int contoini = atoi(_msk->get(F_CONTOINI)); + int contoini = atoi(_msk->get(F_CONTOINI_CONTO)); long sottocontoini = atol(_msk->get(F_SOTTOCINI_CONTO)); int gruppofine = atoi(_msk->get(F_GRUPPOFINE)); - int contofine = atoi(_msk->get(F_CONTOFINE)); + int contofine = atoi(_msk->get(F_CONTOFINE_CONTO)); long sottocontofine = atol(_msk->get(F_SOTTOCFINE_CONTO)); _tipostampa = atoi(_msk->get(F_TIPOSTAMPA)); _numcarat = atoi(_msk->get(F_NUMCARAT)); int formato = atoi(_msk->get(F_FORMATO)); int nummast = atoi(_msk->get(F_NUMMAST)); - _tipocf = _msk->get(F_TIPOCF)[0]; _codice_ditta = get_firm(); ricerca_dati_ditta(); @@ -929,6 +1170,7 @@ bool CG3200_application::set_print(int) _saldo_movimenti = ZERO; _saldo_progressivi = ZERO; _saldo_progre_prec = ZERO; + _protiva = 0; // Scelta del formato e del numero di mastrini per pagina 1 o 2 @@ -1015,22 +1257,27 @@ void CG3200_application::preprocess_header() else if (_tipostampa == 1) if (_puoi_stampare) crea_intestazione(); -} +} -void CG3200_application::conto() +void CG3200_application::conto(int gruppo, int conto, bool no_contropartita) { TLocalisamfile pconti(LF_PCON); pconti.setkey(1); pconti.zero(); - pconti.put(PCN_GRUPPO, _gruppo); - pconti.put(PCN_CONTO , _conto); + pconti.put(PCN_GRUPPO, gruppo); + pconti.put(PCN_CONTO , conto); pconti.read(); if (pconti.bad()) pconti.zero(); - - _indbil = pconti.get_int(PCN_INDBIL); - _tmcf = pconti.get_char(PCN_TMCF); + + if (no_contropartita) + { + _indbil = pconti.get_int(PCN_INDBIL); + _tmcf = pconti.get_char(PCN_TMCF); + } + else + _tipo_contr = pconti.get_char(PCN_TMCF); } void CG3200_application::ricerca_dati_ditta() @@ -1099,8 +1346,6 @@ void CG3200_application::crea_intestazione() set_header (3, "@16g%d", _conto); set_header (3, "@20g%ld", _sottoc); -// conto(); - if (_tmcf == 'C') _tipo_mask = 1; else if (_tmcf == 'F') @@ -1122,11 +1367,11 @@ void CG3200_application::crea_intestazione() { sep.fill('-'); //Stampa 132 - (sep(132)) set_header (6, (const char *) sep); - set_header (7,"Operazione@19gDocumento@117gContro"); + set_header (7,"Operazione@19gDocumento@117gContro@131gA"); set_header (8,"Data"); if (_stampanum < 3) set_header (8,"@11gnumero"); - set_header (8,"@19gData@30gNumero@38gCod.Causale@61gDescrizione@90gDare@106gAvere@117gPartita"); + set_header (8,"@19gData@30gNumero@38gCod.Causale@61gDescrizione@96gDare@111gAvere@117gPartita@131gC"); sep.fill('-'); set_header (9, (const char *) sep); } @@ -1134,54 +1379,14 @@ void CG3200_application::crea_intestazione() { sep1.fill('-'); //Stampa 198 - (sep1(198)) set_header (6,"@1g%s", (const char *) sep1); - set_header (7,"Operazione@19gData@30gNumero@172gContro@185gReg@193gNumero"); + set_header (7,"Operazione@19gData@30gNumero@172gContro@182gReg@190gNumero@197gA"); set_header (8,"Data"); if (_stampanum < 3) set_header (8,"@11gnumero"); - set_header (8,"@19gDocumento@38gCod.Causale@68gDescrizione@108gDare@124gAvere@136gSaldo progress.@154gSaldo movim.@172gPartita@185gIva@189gProtocollo"); + set_header (8,"@19gDocumento@38gCod.Causale@68gDescrizione@113gDare@129gAvere@136gSaldo progress.@156gSaldo movim.@172gPartita@182gIva@186gProtocollo@197gC"); sep1.fill('-'); set_header (9,"@1g%s", (const char *) sep1); } -/* - if (_stampa_progressivi_si) - { - stampa_progressivi(); - _riporto_dare = _progredare; - _riporto_avere = _progreavere; - _stampa_progressivi_si = FALSE; - } - else - { - _riporto_dare += _riporto_parziale_dare; - _riporto_avere += _riporto_parziale_avere; - if (_numcarat == 1) - { - TString string = _riporto_dare.string("###############"); - set_header (10,"@32gA RIPORTO@85g%15s",(const char*) string); - string = _riporto_avere.string("###############"); - set_header (10,"@101g%15s",(const char*) string); - } - if (_numcarat == 2) - { - TString string = _riporto_dare.string("###############"); - set_header (10,"@32gA RIPORTO@102g%15s",(const char*) string); - string = _riporto_avere.string("###############"); - set_header (10,"@119g%15s",(const char*) string); - } - _riporto_parziale_dare = 0; - _riporto_parziale_avere = 0; - } - if (_numcarat == 1) - { - sep =""; - set_header(11,"@1g%s",(const char*) sep); - } - else if (_numcarat == 2) - { - sep1 =""; - set_header(11,"@1g%s",(const char*) sep1); - } -*/ } void CG3200_application::stampa_progre_riporto() @@ -1262,15 +1467,15 @@ void CG3200_application::calcola_progressivi_al() if (_annomsk == 0) { - datareg = rmov.get_date(RMV_DATAREG); - data = _inizioEs; + datareg = rmov.get_date(RMV_DATAREG); + data = _inizioes; } else - if (_annomsk != 0) - { - datareg = datacomp; - data = _data_inizioese; - } + if (_annomsk != 0) + { + datareg = datacomp; + data = _data_inizioese; + } gruppo = rmov.get_int(RMV_GRUPPO); conto = rmov.get_int(RMV_CONTO); @@ -1281,20 +1486,18 @@ void CG3200_application::calcola_progressivi_al() if (sezione == 'D') _totale_prima_dare += importo; else if (sezione == 'A') - _totale_prima_avere += importo; + _totale_prima_avere += importo; } rmov.readat(record); } void CG3200_application::calcola_progressivi() { -// TLocalisamfile* saldi; TLocalisamfile saldi(LF_SALDI, FALSE); real pdaresca,paveresca,pdarescap,paverescap; real progdare_attuale,progavere_attuale,progdare_prec,progavere_prec; real saldo,progredare_eseprec,progreavere_eseprec,pdarep,paverep; char salini; - // TRectype record(saldi.curr()); saldo = ZERO; pdarep = ZERO; @@ -1307,9 +1510,6 @@ void CG3200_application::calcola_progressivi() // Ricerca sull'archivio saldi dei record con gruppo,conto,sottoconto // uguali a quelli di rmov per il calcolo dei progressivi precedenti -// saldi = current_cursor()->file(LF_SALDI); -// rec = saldi->recno(); - TRectype record(saldi.curr()); record.zero(); @@ -1369,11 +1569,9 @@ void CG3200_application::calcola_progressivi() { progredare_eseprec = saldo;// + pdarescap + pdarep; progdare_prec = saldo; - // progreavere_eseprec = paverescap;// + paverep; } else if (salini == 'A') { - // progredare_eseprec = pdarescap;// + pdarep; progreavere_eseprec = saldo;// + paverescap + paverep; progavere_prec = saldo; } @@ -1396,11 +1594,9 @@ void CG3200_application::calcola_progressivi() { progredare_eseprec = saldo;// + pdarescap + pdarep; progdare_prec = saldo; - // progreavere_eseprec = paverescap + paverep; } else if (saldo < ZERO) { - // progredare_eseprec = pdarescap + pdarep; saldo = -saldo; progreavere_eseprec = saldo;// + paverescap + paverep; progavere_prec = saldo; @@ -1408,8 +1604,6 @@ void CG3200_application::calcola_progressivi() } } -// saldi->readat(rec); - calcola_progressivi_al(); //Calcolo dei progressivi precedenti: somma di tutti quei movimenti di rmov @@ -1457,8 +1651,11 @@ void CG3200_application::stampa_progressivi() set_row (1,"@32gPROGRESSIVI PRECEDENTI@102g%15s",(const char*)string); string = _progreavere.string("###############"); set_row (1,"@119g%15s",(const char*) string); + string = _saldo_progre_prec.string("###############"); + set_row (1,"@136g%15s",(const char*) string); } } + // Se la ricerca selezionata nella maschera e' per clienti, oppure fornitori, // allora ricerco su CLIFO i relativi dati, e su PCON il relativo gruppo,conto,// sottoconto e IV direttiva CEE void CG3200_application::ricerca_clifo() @@ -1501,9 +1698,7 @@ void CG3200_application::ricerca_clifo() pconti.zero(); pconti.put(PCN_GRUPPO, _gruppo); pconti.put(PCN_CONTO, _conto); - //pconti.put(PCN_SOTTOCONTO, _sottoc); pconti.read(); - //_sezivd = pconti.get_char(PCN_SEZIVD); _sezivd = pconti.get_char(PCN_SEZIVD); _lettivd = pconti.get_char(PCN_LETTIVD); numrivd = pconti.get_int(PCN_NUMRIVD); @@ -1582,7 +1777,6 @@ void CG3200_application::ricerca_classe_IV(bool scelta) if (scelta) pconti.put(PCN_SOTTOCONTO, _sottoc); pconti.read(); - //_sezivd = pconti.get_char(PCN_SEZIVD); _sezivd = pconti.get_char(PCN_SEZIVD); _lettivd = pconti.get_char(PCN_LETTIVD); _numrivd_int = pconti.get_int (PCN_NUMRIVD); @@ -1732,6 +1926,12 @@ void CG3200_application::user_create() _tabesc = new TTable (TAB_ESC); _msk = new TMask("cg3200a"); + _msk->set_handler(F_SOTTOCINI_CONTO, sottoc_handler_ini); + _msk->set_handler(F_SOTTOCINI_CLIENTE, sottoc_handler_ini); + _msk->set_handler(F_SOTTOCINI_FORN, sottoc_handler_ini); + _msk->set_handler(F_SOTTOCFINE_CONTO, sottoc_handler_fine); + _msk->set_handler(F_SOTTOCFINE_CLIENTE, sottoc_handler_fine); + _msk->set_handler(F_SOTTOCFINE_FORN, sottoc_handler_fine); _inizio_stampa = TRUE; } diff --git a/cg/cg3200.h b/cg/cg3200.h index 8fc77ea4b..139caa6ef 100755 --- a/cg/cg3200.h +++ b/cg/cg3200.h @@ -8,11 +8,11 @@ #define F_CODDITTA 101 #define F_RAGSOC 102 -#define F_TIPOCF 103 +#define F_TIPOCF_INI 103 #define F_GRUPPOINI 104 #define F_GRUPPOFINE 105 -#define F_CONTOINI 106 -#define F_CONTOFINE 107 +#define F_CONTOINI_CONTO 106 +#define F_CONTOFINE_CONTO 107 #define F_SOTTOCINI_CONTO 108 #define F_SOTTOCFINE_CONTO 109 #define F_SOTTOCINI_CLIENTE 110 @@ -36,7 +36,12 @@ #define F_NUMCARAT 128 #define F_NUMMAST 129 #define F_ANNO 130 -#define F_FORMATO 131 +#define F_FORMATO 131 +#define F_CONTOINI_CLIENTE 132 +#define F_CONTOINI_FORN 133 +#define F_CONTOFINE_CLIENTE 134 +#define F_CONTOFINE_FORN 135 +#define F_TIPOCF_FINE 136 #endif // __CG3200_H diff --git a/cg/cg3200a.uml b/cg/cg3200a.uml index 9ccb7ec14..016925cca 100755 --- a/cg/cg3200a.uml +++ b/cg/cg3200a.uml @@ -24,22 +24,22 @@ END TEXT 96 BEGIN - PROMPT 4 10 "Dalla data competenza" + PROMPT 4 11 "Dalla data competenza" END TEXT 97 BEGIN - PROMPT 40 10 "Alla data competenza " + PROMPT 40 11 "Alla data competenza " END TEXT 98 BEGIN - PROMPT 4 10 "Dalla data operazione " + PROMPT 4 11 "Dalla data operazione " END TEXT 99 BEGIN - PROMPT 40 10 "Alla data operazione " + PROMPT 40 11 "Alla data operazione " END NUMBER F_ANNO 4 @@ -58,7 +58,7 @@ BEGIN FLAGS "RZ" END -LIST F_TIPOCF 25 +LIST F_TIPOCF_INI 25 BEGIN PROMPT 4 4 "Ricerca " ITEM " |Gruppo/conto/sottoconto" @@ -74,40 +74,88 @@ BEGIN PROMPT 4 5 "Da Gruppo - Conto - Sottoconto " END -NUMBER F_CONTOINI 3 +NUMBER F_CONTOINI_CONTO 3 BEGIN PROMPT 41 5 "" - USE LF_PCON SELECT SOTTOCONTO="" + USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="") && (TMCF="") INPUT GRUPPO F_GRUPPOINI - INPUT CONTO F_CONTOINI + INPUT CONTO F_CONTOINI_CONTO DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO DISPLAY "Descrizione@50" DESCR - OUTPUT F_TIPOCF TMCF + //OUTPUT F_TIPOCF TMCF OUTPUT F_GRUPPOINI GRUPPO - OUTPUT F_CONTOINI CONTO - OUTPUT F_DESCRINI_CONTO DESCR - FLAGS "R" - WARNING "Conto inesistente o mancante" - MESSAGE DIRTY,F_SOTTOCINI_CONTO|DIRTY,F_SOTTOCINI_CLIENTE|DIRTY,F_SOTTOCINI_FORN + OUTPUT F_CONTOINI_CONTO CONTO + //OUTPUT F_SOTTOCINI_CONTO SOTTOCONTO + //OUTPUT F_DESCRINI_CONTO DESCR + FLAGS "R" + //CHECKTYPE NORMAL + //WARNING "Conto inesistente o mancante" + //MESSAGE DIRTY,F_SOTTOCINI_CONTO|DIRTY,F_SOTTOCINI_CLIENTE|DIRTY,F_SOTTOCINI_FORN + GROUP 1 +END + +NUMBER F_CONTOINI_CLIENTE 3 +BEGIN + PROMPT 41 5 "" + USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="") && (TMCF="C") + INPUT GRUPPO F_GRUPPOINI + INPUT CONTO F_CONTOINI_CLIENTE + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Descrizione@50" DESCR + //OUTPUT F_TIPOCF TMCF + OUTPUT F_GRUPPOINI GRUPPO + OUTPUT F_CONTOINI_CLIENTE CONTO + //OUTPUT F_SOTTOCINI_CLIENTE SOTTOCONTO + //OUTPUT F_DESCRINI_CLIENTE DESCR + FLAGS "R" + //CHECKTYPE NORMAL + //WARNING "Conto inesistente o mancante" + //MESSAGE DIRTY,F_SOTTOCINI_CONTO|DIRTY,F_SOTTOCINI_CLIENTE|DIRTY,F_SOTTOCINI_FORN + GROUP 2 + MESSAGE COPY,F_CONTOINI_CONTO +END + +NUMBER F_CONTOINI_FORN 3 +BEGIN + PROMPT 41 5 "" + USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="") && (TMCF="F") + INPUT GRUPPO F_GRUPPOINI + INPUT CONTO F_CONTOINI_FORN + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Descrizione@50" DESCR + //OUTPUT F_TIPOCF TMCF + OUTPUT F_GRUPPOINI GRUPPO + OUTPUT F_CONTOINI_FORN CONTO + //OUTPUT F_SOTTOCINI_FORN SOTTOCONTO + //OUTPUT F_DESCRINI_FORN DESCR + FLAGS "R" + //CHECKTYPE NORMAL + //WARNING "Conto inesistente o mancante" + //MESSAGE DIRTY,F_SOTTOCINI_CONTO|DIRTY,F_SOTTOCINI_CLIENTE|DIRTY,F_SOTTOCINI_FORN + GROUP 3 + MESSAGE COPY,F_CONTOINI_CONTO END NUMBER F_SOTTOCINI_CONTO 6 BEGIN PROMPT 48 5 "" - USE LF_PCON SELECT SOTTOCONTO!="" + USE LF_PCON //SELECT SOTTOCONTO!="" INPUT GRUPPO F_GRUPPOINI - INPUT CONTO F_CONTOINI + INPUT CONTO F_CONTOINI_CONTO INPUT SOTTOCONTO F_SOTTOCINI_CONTO DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO DISPLAY "Sottoconto" SOTTOCONTO DISPLAY "Descrizione@50" DESCR OUTPUT F_GRUPPOINI GRUPPO - OUTPUT F_CONTOINI CONTO + OUTPUT F_CONTOINI_CONTO CONTO OUTPUT F_SOTTOCINI_CONTO SOTTOCONTO - OUTPUT F_DESCRINI_CONTO DESCR - FLAGS "R" + //OUTPUT F_DESCRINI_CONTO DESCR + FLAGS "R" + //CHECKTYPE NORMAL GROUP 1 END @@ -122,7 +170,6 @@ BEGIN DISPLAY "Conto" CONTO DISPLAY "Sottoconto" SOTTOCONTO COPY OUTPUT F_SOTTOCINI_CONTO - CHECKTYPE NORMAL GROUP 1 END @@ -130,7 +177,7 @@ NUMBER F_SOTTOCINI_CLIENTE 6 BEGIN PROMPT 48 5 "" USE LF_CLIFO - CHECKTYPE NORMAL + //CHECKTYPE NORMAL INPUT TIPOCF "C" INPUT CODCF F_SOTTOCINI_CLIENTE DISPLAY "Codice" CODCF @@ -138,7 +185,7 @@ BEGIN DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO OUTPUT F_SOTTOCINI_CLIENTE CODCF - OUTPUT F_DESCRINI_CLIENTE RAGSOC + //OUTPUT F_DESCRINI_CLIENTE RAGSOC MESSAGE COPY,F_SOTTOCINI_CONTO FLAGS "R" GROUP 2 @@ -165,7 +212,7 @@ NUMBER F_SOTTOCINI_FORN 6 BEGIN PROMPT 48 5 "" USE LF_CLIFO - CHECKTYPE NORMAL + //CHECKTYPE NORMAL INPUT TIPOCF "F" INPUT CODCF F_SOTTOCINI_FORN DISPLAY "Codice" CODCF @@ -173,7 +220,7 @@ BEGIN DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO OUTPUT F_SOTTOCINI_FORN CODCF - OUTPUT F_DESCRINI_FORN RAGSOC + //OUTPUT F_DESCRINI_FORN RAGSOC FLAGS "R" GROUP 3 MESSAGE COPY,F_SOTTOCINI_CONTO @@ -194,52 +241,108 @@ BEGIN CHECKTYPE NORMAL GROUP 3 END - + +LIST F_TIPOCF_FINE 25 +BEGIN + PROMPT 4 7 "Ricerca " + ITEM " |Gruppo/conto/sottoconto" + MESSAGE HIDE,5@|HIDE,6@|RESET,5@|RESET,6@|SHOW,4@ + ITEM "C|Clienti" + MESSAGE HIDE,4@|HIDE,6@|RESET,4@|RESET,6@|SHOW,5@ + ITEM "F|Fornitori" + MESSAGE HIDE,4@|HIDE,5@|RESET,4@|RESET,5@|SHOW,6@ +END + NUMBER F_GRUPPOFINE 3 BEGIN - PROMPT 4 7 "A Gruppo - Conto - Sottoconto " + PROMPT 4 8 "A Gruppo - Conto - Sottoconto " END -NUMBER F_CONTOFINE 3 +NUMBER F_CONTOFINE_CONTO 3 BEGIN - PROMPT 41 7 "" - USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="") + PROMPT 41 8 "" + USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="") && (TMCF="") INPUT GRUPPO F_GRUPPOFINE - INPUT CONTO F_CONTOFINE + INPUT CONTO F_CONTOFINE_CONTO DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO DISPLAY "Descrizione@50" DESCR - OUTPUT F_TIPOCF TMCF + //OUTPUT F_TIPOCF TMCF OUTPUT F_GRUPPOFINE GRUPPO - OUTPUT F_CONTOFINE CONTO - OUTPUT F_DESCRFINE_CONTO DESCR - FLAGS "R" - WARNING "Conto inesistente o mancante" - MESSAGE DIRTY,F_SOTTOCFINE_CONTO|DIRTY,F_SOTTOCFINE_CLIENTE|DIRTY,F_SOTTOCFINE_FORN + OUTPUT F_CONTOFINE_CONTO CONTO + //OUTPUT F_DESCRFINE_CONTO DESCR + FLAGS "R" + //CHECKTYPE NORMAL + //WARNING "Conto inesistente o mancante" + //MESSAGE DIRTY,F_SOTTOCFINE_CONTO|DIRTY,F_SOTTOCFINE_CLIENTE|DIRTY,F_SOTTOCFINE_FORN + GROUP 4 +END + +NUMBER F_CONTOFINE_CLIENTE 3 +BEGIN + PROMPT 41 8 "" + USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="") && (TMCF="C") + INPUT GRUPPO F_GRUPPOFINE + INPUT CONTO F_CONTOFINE_CLIENTE + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Descrizione@50" DESCR + //OUTPUT F_TIPOCF TMCF + OUTPUT F_GRUPPOFINE GRUPPO + OUTPUT F_CONTOFINE_CLIENTE CONTO + //OUTPUT F_DESCRFINE_CLIENTE DESCR + FLAGS "R" + //CHECKTYPE NORMAL + //WARNING "Conto inesistente o mancante" + //MESSAGE DIRTY,F_SOTTOCFINE_CONTO|DIRTY,F_SOTTOCFINE_CLIENTE|DIRTY,F_SOTTOCFINE_FORN + MESSAGE COPY,F_CONTOFINE_CONTO + GROUP 5 +END + +NUMBER F_CONTOFINE_FORN 3 +BEGIN + PROMPT 41 8 "" + USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="") && (TMCF="F") + INPUT GRUPPO F_GRUPPOFINE + INPUT CONTO F_CONTOFINE_FORN + DISPLAY "Gruppo" GRUPPO + DISPLAY "Conto" CONTO + DISPLAY "Descrizione@50" DESCR + //OUTPUT F_TIPOCF TMCF + OUTPUT F_GRUPPOFINE GRUPPO + OUTPUT F_CONTOFINE_FORN CONTO + //OUTPUT F_DESCRFINE_FORN DESCR + FLAGS "R" + //CHECKTYPE NORMAL + //WARNING "Conto inesistente o mancante" + //MESSAGE DIRTY,F_SOTTOCFINE_CONTO|DIRTY,F_SOTTOCFINE_CLIENTE|DIRTY,F_SOTTOCFINE_FORN + MESSAGE COPY,F_CONTOFINE_CONTO + GROUP 6 END NUMBER F_SOTTOCFINE_CONTO 6 BEGIN - PROMPT 48 7 "" + PROMPT 48 8 "" USE LF_PCON SELECT SOTTOCONTO!="" INPUT GRUPPO F_GRUPPOFINE - INPUT CONTO F_CONTOFINE + INPUT CONTO F_CONTOFINE_CONTO INPUT SOTTOCONTO F_SOTTOCFINE_CONTO DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO DISPLAY "Sottoconto" SOTTOCONTO DISPLAY "Descrizione@50" DESCR OUTPUT F_GRUPPOFINE GRUPPO - OUTPUT F_CONTOFINE CONTO + OUTPUT F_CONTOFINE_CONTO CONTO OUTPUT F_SOTTOCFINE_CONTO SOTTOCONTO - OUTPUT F_DESCRFINE_CONTO DESCR - FLAGS "R" - GROUP 1 + //OUTPUT F_DESCRFINE_CONTO DESCR + FLAGS "R" + //CHECKTYPE NORMAL + GROUP 4 END STRING F_DESCRFINE_CONTO 50 BEGIN - PROMPT 4 8 "Descrizione " + PROMPT 4 9 "Descrizione " USE LF_PCON KEY 2 CHECKTYPE NORMAL INPUT DESCR F_DESCRINI_CONTO @@ -248,49 +351,14 @@ BEGIN DISPLAY "Conto" CONTO DISPLAY "Sottoconto" SOTTOCONTO COPY OUTPUT F_SOTTOCFINE_CONTO - CHECKTYPE NORMAL - GROUP 1 -END - -NUMBER F_SOTTOCINI_CLIENTE 6 -BEGIN - PROMPT 48 5 "" - USE LF_CLIFO - INPUT TIPOCF "C" - INPUT CODCF F_SOTTOCINI_CLIENTE - DISPLAY "Codice" CODCF - DISPLAY "Ragione Sociale@50" RAGSOC - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - OUTPUT F_SOTTOCINI_CLIENTE CODCF - OUTPUT F_DESCRINI_CLIENTE RAGSOC - MESSAGE COPY,F_SOTTOCINI_CONTO - FLAGS "R" - GROUP 2 -END - -STRING F_DESCRINI_CLIENTE 50 -BEGIN - PROMPT 4 6 "Ragione sociale " - FIELD LF_CLIFO->RAGSOC - USE LF_CLIFO KEY 2 - CHECKTYPE NORMAL - INPUT TIPOCF "C" - INPUT RAGSOC F_DESCRINI_CLIENTE - DISPLAY "Ragione Sociale Cliente@50" RAGSOC - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Codice" CODCF - COPY OUTPUT F_SOTTOCINI_CLIENTE - MESSAGE COPY,F_DESCRINI_CONTO - GROUP 2 + GROUP 4 END NUMBER F_SOTTOCFINE_CLIENTE 6 BEGIN - PROMPT 48 7 "" + PROMPT 48 8 "" USE LF_CLIFO - CHECKTYPE NORMAL + //CHECKTYPE NORMAL INPUT TIPOCF "C" INPUT CODCF F_SOTTOCFINE_CLIENTE DISPLAY "Codice" CODCF @@ -298,15 +366,15 @@ BEGIN DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO OUTPUT F_SOTTOCFINE_CLIENTE CODCF - OUTPUT F_DESCRFINE_CLIENTE RAGSOC + //OUTPUT F_DESCRFINE_CLIENTE RAGSOC MESSAGE COPY,F_SOTTOCFINE_CONTO FLAGS "R" - GROUP 2 + GROUP 5 END STRING F_DESCRFINE_CLIENTE 50 BEGIN - PROMPT 4 8 "Ragione sociale " + PROMPT 4 9 "Ragione sociale " FIELD LF_CLIFO->RAGSOC CHECKTYPE NORMAL USE LF_CLIFO KEY 2 @@ -318,50 +386,14 @@ BEGIN DISPLAY "Codice" CODCF COPY OUTPUT F_SOTTOCFINE_CLIENTE MESSAGE COPY,F_DESCRFINE_CONTO - CHECKTYPE NORMAL - GROUP 2 + GROUP 5 END -NUMBER F_SOTTOCINI_FORN 6 -BEGIN - PROMPT 48 5 "" - USE LF_CLIFO - CHECKTYPE NORMAL - INPUT TIPOCF "F" - INPUT CODCF F_SOTTOCINI_FORN - DISPLAY "Codice" CODCF - DISPLAY "Ragione Sociale@50" RAGSOC - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - OUTPUT F_SOTTOCINI_FORN CODCF - OUTPUT F_DESCRINI_FORN RAGSOC - FLAGS "R" - GROUP 3 - MESSAGE COPY,F_SOTTOCINI_CONTO -END - -STRING F_DESCRINI_FORN 50 -BEGIN - PROMPT 4 6 "Ragione Sociale " - USE LF_CLIFO KEY 2 - CHECKTYPE NORMAL - INPUT TIPOCF "F" - INPUT RAGSOC F_DESCRINI_FORN - DISPLAY "Ragione Sociale Fornitore@50" RAGSOC - DISPLAY "Gruppo" GRUPPO - DISPLAY "Conto" CONTO - DISPLAY "Codice" CODCF - COPY OUTPUT F_DESCRINI_CONTO - MESSAGE COPY,F_DESCRINI_CONTO - CHECKTYPE NORMAL - GROUP 3 -END - NUMBER F_SOTTOCFINE_FORN 6 BEGIN - PROMPT 48 7 "" + PROMPT 48 8 "" USE LF_CLIFO - CHECKTYPE NORMAL + //CHECKTYPE NORMAL INPUT TIPOCF "F" INPUT CODCF F_SOTTOCFINE_FORN DISPLAY "Codice" CODCF @@ -369,15 +401,15 @@ BEGIN DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO OUTPUT F_SOTTOCFINE_FORN CODCF - OUTPUT F_DESCRFINE_FORN RAGSOC + //OUTPUT F_DESCRFINE_FORN RAGSOC FLAGS "R" - GROUP 3 + GROUP 6 MESSAGE COPY,F_SOTTOCFINE_CONTO END STRING F_DESCRFINE_FORN 50 BEGIN - PROMPT 4 8 "Ragione Sociale " + PROMPT 4 9 "Ragione Sociale " USE LF_CLIFO KEY 2 CHECKTYPE NORMAL INPUT TIPOCF "F" @@ -388,18 +420,17 @@ BEGIN DISPLAY "Codice" CODCF COPY OUTPUT F_DESCRFINE_CONTO MESSAGE COPY,F_DESCRFINE_CONTO - CHECKTYPE NORMAL - GROUP 3 + GROUP 6 END DATE F_DATAINI BEGIN - PROMPT 26 10 "" + PROMPT 26 11 "" END DATE F_DATAFINE BEGIN - PROMPT 62 10 "" + PROMPT 62 11 "" END BOOLEAN F_STAMPATOTIVA diff --git a/cg/cg3400.cpp b/cg/cg3400.cpp index 2fc5216c1..50e7f9f55 100755 --- a/cg/cg3400.cpp +++ b/cg/cg3400.cpp @@ -610,9 +610,9 @@ int CG3400_application::stampa_intestazione_ditta() (const char *)_viafis, (const char *)_cap, (const char *)_comunefis, (const char *)_provfis); - _intes = "Data @>"; - _intes.right_just(_stampa_width-15); // perche' il codice viene espanso nella data con l'anno in 4 caratteri - _intes.overwrite (format ("Partita iva %s @24gCodice fiscale %s %s", (const char*)_paiva, (const char*)_cofi, _stampa_definitiva ? "" : "STAMPA DI PROVA")); + _intes = format ("Partita iva %s @24gCodice fiscale %s %s @117gData @>", + (const char*)_paiva, (const char*)_cofi, + _stampa_definitiva ? "" : "STAMPA DI PROVA"); set_header (++r, "%s", (const char*) _intes); @@ -631,7 +631,8 @@ int CG3400_application::set_header_198() TString16 data_da = _data_da.string(); TString16 data_a = _data_a.string(); - if (_stampa_intesta) r = stampa_intestazione_ditta(); + if (_stampa_intesta || !_stampa_definitiva) + r = stampa_intestazione_ditta(); // set_header(r, "@bCodice libro:@r %s %s @bdalla data:@r %s @balla data:@r %s @bEsercizio:@r %04d", set_header(r, "Codice libro: %s %s dalla data: %s alla data: %s Esercizio: %04d", @@ -682,14 +683,15 @@ int CG3400_application::set_header_132() TString16 data_da = _data_da.string(); TString16 data_a = _data_a.string(); - if (_stampa_intesta) r = stampa_intestazione_ditta(); + if (_stampa_intesta || !_stampa_definitiva) + r = stampa_intestazione_ditta(); #if XVT_OS != XVT_OS_SCOUNIX - if (_stampa_intesta) - set_background("W4l{1 1 132 1}W4l{1 4 132 4}W1l{1 8 132 8}"); + if (_stampa_intesta || !_stampa_definitiva) + set_background("W4l{1 1 133 1}W4l{1 4 133 4}W1l{1 8 133 8}"); else { - set_background("W4l{1 1 132 1}W1l{1 5 132 5}"); + set_background("W4l{1 1 133 1}W1l{1 5 133 5}"); r++; } #else @@ -698,7 +700,7 @@ int CG3400_application::set_header_132() #endif // set_header(r++, "@bCodice libro:@r %s %s @bdalla data:@r %s @balla data:@r %s @bEsercizio:@r %04d", - set_header(r++, "Codice libro: %s %s @69gdalla data: %s alla data: %s Esercizio: %04d", + set_header(r++, "Codice libro: %s %s @69gdalla data: %s alla data: %s @117gEsercizio: %04d", (const char *) _reg_cod, (const char *) _reg_descr, (const char *) data_da, (const char *) data_a, _ae); @@ -1245,8 +1247,8 @@ int CG3400_application::ultimo_esercizio() TTable ese("ESC"); ese.zero(); - ese.last(); -// ese.first(); +// ese.last(); // Sembra che non vadi ?!? + ese.first(); sanno = ese.get("CODTAB"); sanno.cut(4); const int anno = atoi(sanno); @@ -1268,21 +1270,21 @@ bool CG3400_application::leggi_tabreg(const char * reg_cod, _tabreg->zero(); _tabreg->put("CODTAB", codtab); - _tabreg->read(); + const bool ok = (_tabreg->read() == NOERR); + + if (!ok) _tabreg->zero(); + + _pagine_stampate = _tabreg->get_int("I1"); + _pagine_numerate = _tabreg->get_int("I2"); + _stampa_ok = _tabreg->get_int("I7"); + _nprog_da = _tabreg->get_long ("I6"); + _tot_dare = _tabreg->get_real ("R1"); + _tot_avere = _tabreg->get_real ("R2"); + _last_data = _tabreg->get_date ("D3"); + _stampa_intesta = _tabreg->get_bool ("B9"); + _reg_descr = _tabreg->get ("S0"); - if (_tabreg->good()) - { - _pagine_stampate = _tabreg->get_int("I1"); - _pagine_numerate = _tabreg->get_int("I2"); - _stampa_ok = _tabreg->get_int("I7"); - _nprog_da = _tabreg->get_long ("I6"); - _tot_dare = _tabreg->get_real ("R1"); - _tot_avere = _tabreg->get_real ("R2"); - _last_data = _tabreg->get_date ("D3"); - _stampa_intesta = _tabreg->get_bool ("B9"); - _reg_descr = _tabreg->get ("S0"); - } - return TRUE; + return ok; } // Calcola l'anno di esercizio di una data @@ -1411,13 +1413,17 @@ bool CG3400_application::mask_a_cod_reg (TMask_field& f, KEY k) TString16 reg_cod(f.get()); if (reg_cod.empty()) return TRUE; - - a.leggi_tabreg(reg_cod, a._ae); + + bool reg_ok = a.leggi_tabreg(reg_cod, a._ae); // Output da qui della descrizione del registro e dell'anno m.set(REG_DESC, a._reg_descr); m.set(ANNO_ESER, a._ae); +// CHECKTYPE NORMAL abolito! (nella maschera non ho l'anno... + if (!reg_ok) + return f.warning_box("Registro inesistente"); + if (definitiva) { if (a._stampa_ok == -1) // stampa precedente andata bene diff --git a/include/causali.h b/include/causali.h index 41acfe757..2bbc0e63d 100755 --- a/include/causali.h +++ b/include/causali.h @@ -19,5 +19,6 @@ #define CAU_COLLCESP "COLLCESP" #define CAU_M770 "M770" #define CAU_CODCAUSIM "CODCAUSIM" +#define CAU_SOSPESO "SOSPESO" #endif