diff --git a/src/cg/cg2100.cpp b/src/cg/cg2100.cpp index 6533921d3..8216cff0b 100755 --- a/src/cg/cg2100.cpp +++ b/src/cg/cg2100.cpp @@ -1876,8 +1876,11 @@ void TPrimanota_application::genera_automatico(int tipo, const char* causimm) _automatico->_iva_originale = caus.iva(); if (tipo != 3) { - _automatico->_datadoc = m.get(F_DATADOC); - _automatico->_numdoc = m.get(F_NUMDOC); + if (tipo != 2) + { + _automatico->_datadoc = m.get(F_DATADOC); + _automatico->_numdoc = m.get(F_NUMDOC); + } _automatico->_clifo.get(_rel->cg(0)); _automatico->_totale = m.get_real(F_TOTALE); } @@ -1887,7 +1890,21 @@ void TPrimanota_application::genera_automatico(int tipo, const char* causimm) { TSheet_field & iva = app().ivas(); const int items = iva.items(); - + const TCausale & causreg = cached_causale(causimm); + const TString8 tipo_doc_sdi = causreg.tipodocsdi(); + const int tipo_doc = atoi(tipo_doc_sdi.mid(2)); + + if (tipo_doc_sdi.starts_with("TD") && (tipo_doc > 15 && tipo_doc < 20)) + { + _automatico->_datadoc = m.get(F_DATAREG); + _automatico->_numdoc.cut(0); + _automatico->_numdoc << cached_registro(causreg.codice_registro()).protocol() + 1; + } + else + { + _automatico->_datadoc = m.get(F_DATADOC); + _automatico->_numdoc = m.get(F_NUMDOC); + } _automatico->_movcoll = m.get_long(F_NUMREG); _automatico->_iva.destroy(); _automatico->_totale = ZERO; diff --git a/src/cg/cg2100.h b/src/cg/cg2100.h index 7af7d924f..b486d123f 100755 --- a/src/cg/cg2100.h +++ b/src/cg/cg2100.h @@ -18,6 +18,7 @@ #define F_ANNOES 115 #define F_DATACOMP 116 #define F_ANNOIVA 117 + #define F_NUMDOCEXT 130 #define F_RITFATT 231 #define F_PROKEY 232 @@ -93,6 +94,8 @@ #define F_GOCOLL 186 #define F_IDDOCSDI 187 #define F_DATADOCSDI 188 +#define F_PREFISSO 192 +#define F_SLASH 193 #define F_SHEETCG 190 #define F_SHEETIVA 191 diff --git a/src/cg/cg2100c.uml b/src/cg/cg2100c.uml index 3eb90c8c0..5cc9b5965 100755 --- a/src/cg/cg2100c.uml +++ b/src/cg/cg2100c.uml @@ -153,6 +153,18 @@ BEGIN WARNING "La causale o il saldaconto richiedono il numero documento" END +TEXT F_SLASH +BEGIN + PROMPT 16 6 "/" + FLAGS "H" +END + +STRING F_PREFISSO 2 +BEGIN + PROMPT 13 6 "" + FLAGS "HD" +END + DATE F_DATADOC BEGIN PROMPT 27 6 "Data documento " diff --git a/src/cg/cg2102.cpp b/src/cg/cg2102.cpp index e334045ca..95efd4e7b 100755 --- a/src/cg/cg2102.cpp +++ b/src/cg/cg2102.cpp @@ -2285,7 +2285,7 @@ bool TPrimanota_application::caus_modify_handler(TMask_field& f, KEY key) TMask& m = f.mask(); const int ann = m.get_int(F_ANNOIVA); const TString& cau = f.get(); - const TCausale c(cau, ann); + const TCausale & c = cached_causale(cau, ann); if (c.ok()) { @@ -2327,6 +2327,21 @@ bool TPrimanota_application::caus_modify_handler(TMask_field& f, KEY key) new_mask->set(F_PROTIVA, protocol); new_mask->set(F_RITFATT, app().causale().fattura_in_ritardo() ? "X" : " "); + + const TString & prefisso = c.reg().prefisso(); + + if (c.is_reg_autof() && prefisso.full()) + { + m.show(F_PREFISSO); + m.show(F_SLASH); + m.set(F_PREFISSO, prefisso); + } + else + { + m.hide(F_PREFISSO); + m.hide(F_SLASH); + m.reset(F_PREFISSO); + } } check_fppro_fields(*new_mask); } @@ -2336,6 +2351,36 @@ bool TPrimanota_application::caus_modify_handler(TMask_field& f, KEY key) else return false; } + else + if (f.initial_check(key)) + { + TMask& m = f.mask(); + const int ann = m.get_int(F_ANNOIVA); + const TString& cau = f.get(); + + if (cau.full()) + { + const TCausale & c = cached_causale(cau, ann); + + if (c.iva() != nessuna_iva) + { + const TString & prefisso = c.reg().prefisso(); + + if (c.is_reg_autof() && prefisso.full()) + { + m.show(F_PREFISSO); + m.show(F_SLASH); + m.set(F_PREFISSO, prefisso); + } + else + { + m.hide(F_PREFISSO); + m.hide(F_SLASH); + m.reset(F_PREFISSO); + } + } + } + } return true; } diff --git a/src/cg/cg4400.cpp b/src/cg/cg4400.cpp index ce9bcf9de..9e3a1417d 100755 --- a/src/cg/cg4400.cpp +++ b/src/cg/cg4400.cpp @@ -980,7 +980,7 @@ void TStampa_registri_app::calcola_progressivi() codreg.rpad(3); select << codreg << format("%02d", i) << "\")"; - keyf <<_annoIVA << _codatt << 1 << codreg << format("%02d", i); + keyf << _annoIVA << _codatt << 1 << codreg << format("%02d", i); keyt << _annoIVA << _codatt << 2 << codreg << format("%02d", i); from.put("CODTAB", keyf); to.put("CODTAB", keyt); @@ -2406,7 +2406,7 @@ bool TStampa_registri_app::preprocess_page(int file, int counter) const long numreg = mov.get_long(MOV_NUMREG); const long protiva = mov.get_long(MOV_PROTIVA); const long uprotiva = mov.get_long(MOV_UPROTIVA); - const TString16 numdoc = mov.get(MOV_NUMDOC); + TString16 numdoc = mov.get(MOV_NUMDOC); const int meseliq = mov.get_int(MOV_MESELIQ); const char tipocf = mov.get(MOV_TIPO)[0]; TString16 ocfpi = mov.get(MOV_OCFPI); @@ -2523,9 +2523,29 @@ bool TStampa_registri_app::preprocess_page(int file, int counter) set_row(_r, "@9g%5ld", protiva); if (datadoc.ok()) set_row(_r, "@15g%s", (const char*) app); - set_row(_r, "@24g%s", (const char*) numdoc); - if (codcf != 0l) - set_row(_r, "@31g%6ld", codcf); + if (codcf != 0l) + set_row(_r, "@31g%6ld", codcf); + if (cached_causale(mov.curr()).reverse_charge_pubb()) + { + const TRectype movcoll = cache().get(LF_MOV, mov.get_long(MOV_MOVCOLL)); + const TCausale & caus = cached_causale(movcoll); + + if (caus.is_reg_autof() && tipomov == acquisto) + { + app = movcoll.get_date(MOV_DATADOC).string(brief, '/'); + set_row(_r + 1, "@15g%s", (const char*)app); + + TString numdoccoll = movcoll.get(MOV_NUMDOC); + const TString & prefisso = caus.reg().prefisso(); + + if (prefisso.full()) + { + numdoccoll.insert("/"); + numdoccoll.insert(prefisso); + } + set_row(_r + 1, "@24g%s", (const char*)numdoccoll); + } + } if (meseliq > 0) set_row(_r, "@62g%02d", meseliq); set_row(_r, "@67g%2s", (const char*) _tipodoc); @@ -2563,6 +2583,32 @@ bool TStampa_registri_app::preprocess_page(int file, int counter) const char* r; int i = 1; + + if (cached_causale(mov.curr()).reverse_charge_pubb()) + { + const TRectype movcoll = cache().get(LF_MOV, mov.get_long(MOV_MOVCOLL)); + + if (cached_causale(movcoll).is_reg_autof() && tipomov == vendita) + { + TParagraph_string desc(cache().get(LF_NDITTE, get_firm()).get(NDT_RAGSOC), 23); + + while ((r = desc.get()) != NULL) + { + set_row(i, "@38g%s", r); + i++; + } + const TString & prefisso = cached_causale(mov.curr()).reg().prefisso(); + + if (prefisso.full()) + { + numdoc.insert("/"); + numdoc.insert(prefisso); + } + } + } + set_row(_r, "@24g%s", (const char*)numdoc); + if (codcf != 0l) + set_row(i, "@31g%6ld", codcf); TParagraph_string desc(ragsoc, 23); while ((r = desc.get()) != NULL) @@ -2686,9 +2732,9 @@ bool TStampa_registri_app::preprocess_page(int file, int counter) { if (_stampa_width == 132) { - set_row(_r, "@126g%5ld", numreg); + set_row(_r, "@126g%6ld", numreg); if (stampato) - set_row(_r, "@131g*"); //solo in stampa di prova! + set_row(_r, "@132g*"); //solo in stampa di prova! } else //198 { @@ -3022,18 +3068,17 @@ void TStampa_registri_app::preprocess_header() { if (_stampa_width == 132) { - set_header(r,FR("@10gNum.@19gDocumento@61gMese@65gT Tipo@102gCod %c@123gT %c@128gNum"), nd1, tipo); - r++; - set_header(r, FR("Data reg. prot.@17gData@24gNumero Codice Ragione sociale/descr. liq.@65gO Doc.@74gTotale doc.@90gImponibile IVA %c@115gImposta@123g%c %c@128gReg"), nd2, cor, type); - r++; + set_header(r++,FR("@10gNum.@19gDocumento@61gMese@65gT Tipo@102gCod %c@123gT %c@128gNum"), nd1, tipo); + set_header(r++, FR("Data reg. prot.@17gData@24gNumero Codice Ragione sociale/descr. liq.@65gO Doc.@74gTotale doc.@90gImponibile IVA %c@115gImposta@123g%c %c@128gReg"), nd2, cor, type); } else //stampa a 198 { - set_header(r,FR("Registrazione Documento@61gMese@65gT Tipo@110gCod %c@132g%c T@139gNum."), nd1, tipo, cor); - r++; - set_header(r, FR("Data Protocollo Data@24gNumero Codice Ragione sociale/descr. liq.@65gO Documento@80gTot.Documento@98gImponibile IVA %c@124gImposta@132g%c %c@139gReg."), nd2, type, cor); - r++; + set_header(r++,FR("Registrazione Documento@61gMese@65gT Tipo@110gCod %c@132g%c T@139gNum."), nd1, tipo, cor); + set_header(r++, FR("Data Protocollo Data@24gNumero Codice Ragione sociale/descr. liq.@65gO Documento@80gTot.Documento@98gImponibile IVA %c@124gImposta@132g%c %c@139gReg."), nd2, type, cor); } + if (cached_registro(_codreg).tipo() == iva_acquisti) + set_header(r++, FR("Integr./Autofatt.Data@24gNumero")); + } } else if (!_intesta_vidi) @@ -3064,6 +3109,8 @@ void TStampa_registri_app::preprocess_header() if (_tipo_stampa == rif_giornale) set_header(r, FR("@139gop. @144gCodice conto @159gDescrizione sottoconto")); r++; + if (cached_registro(_codreg).tipo() == iva_acquisti) + set_header(r++, FR("Integr./Autofatt.Data@24gNumero")); } } } diff --git a/src/cg/cglib.h b/src/cg/cglib.h index e58bd8b4b..f86e21f32 100644 --- a/src/cg/cglib.h +++ b/src/cg/cglib.h @@ -250,7 +250,9 @@ public: TDate last_print() const { return _rec.get_date("D3"); } long mese_stampa_ultima_liq() const { return _rec.get_long("I4"); } long protocol() const { return _rec.get_long("I5"); } - const TString& attivita() const { return _rec.get("S8"); } + const TString& attivita() const { return _rec.get("S8"); } + const TString& prefisso() const { return _rec.get("S5"); } + bool agenzia_viaggi() const; const TString& tipo_attivita() const; @@ -341,6 +343,7 @@ public: tipo_movimento tipomov() const; const TString& tipodoc() const; const TString& tipodocsdi() const; + const bool is_reg_autof() const; bool saldaconto(const TDate& datareg) const; int link_m770() const; char link_cespiti() const; @@ -364,7 +367,8 @@ public: }; const TCausale & cached_causale(const char * codcaus, const int year = 0); -inline const TCausale & cached_causale(const TRectype & caus, const int year = 0) { return cached_causale(caus.get(CAU_CODCAUS), year); } +inline const TCausale & cached_causale(const TRectype & caus, const int year) { return cached_causale(caus.get(CAU_CODCAUS), year); } // causale da record +inline const TCausale & cached_causale(const TRectype & mov) { return cached_causale(mov.get(MOV_CODCAUS), mov.get_int(MOV_ANNOIVA)); } // causale da movimento class TCodiceIVA : public TRectype