diff --git a/cg/cg3200.cpp b/cg/cg3200.cpp index 00c39579f..2bb2bd2bc 100755 --- a/cg/cg3200.cpp +++ b/cg/cg3200.cpp @@ -2812,7 +2812,7 @@ void TMastrini_application::crea_intestazione() sep1 =""; set_header(11,"@1g%s",(const char*) sep1); } - if (_pagina != np) + if (_pagina != np && _nummast == 3) _pagina = np; } diff --git a/cg/cg3400.cpp b/cg/cg3400.cpp index aed29ffba..155f2a78f 100755 --- a/cg/cg3400.cpp +++ b/cg/cg3400.cpp @@ -217,6 +217,7 @@ public: const char* get_descr_caus (const char * codcaus); TRectype& look_com (const char * cod); + TRectype& look_com (const TString& stato, const TString& cod); const char* get_codiva_des(const char* codiva); void get_date_aep(int aep, TDate* in, TDate* fin); void update_totals (char sezione, real& importo); @@ -284,6 +285,17 @@ HIDDEN bool libro_cronologico() return conf.get_bool("GsLbCn"); } +TRectype& TStampa_giornale::look_com (const TString& stato, const TString& cod) +{ + _com->zero(); + _com->put(COM_COM, cod); + _com->put(COM_STATO, stato); + if (_com->read() != NOERR) + _com->zero(); + + return _com->curr(); +} + TRectype& TStampa_giornale::look_com (const char * cod) { _com->zero(); @@ -1440,7 +1452,7 @@ int TStampa_giornale::setta_righe_indirizzo(char tipocf, long codcf,int rdes) codanagr = _clifo->get_long(CLI_CODANAGPER); } - TRectype rec = look_com (comcf); + TRectype rec = look_com (statocf, comcf); comune = rec.get(COM_DENCOM); prov = rec.get(COM_PROVCOM); if (comcf.empty()) comune = _clifo->get(CLI_LOCCF); @@ -1477,14 +1489,13 @@ int TStampa_giornale::setta_righe_indirizzo(char tipocf, long codcf,int rdes) if (datana.not_empty()) { codcomna = _clifo->get("COMNASC"); - TRectype dep = look_com (codcomna); + statona = _clifo->get("STATONASC"); + TRectype dep = look_com (statona,codcomna); comna = dep.get(COM_DENCOM); provna = dep.get(COM_PROVCOM); capna = dep.get(COM_CAPCOM); - statona = dep.get("STATO"); - sprintf (riga, "@%dg%s %s %s %s", POSCONTO, (const char*)datana, (const char*)comna, diff --git a/cg/cg4301.cpp b/cg/cg4301.cpp index dcef1da0c..7dc5896d1 100755 --- a/cg/cg4301.cpp +++ b/cg/cg4301.cpp @@ -737,7 +737,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) vssp_imp += vsimp_imp; vssp_iva += vsimp_iva; } - else if (fattrit && month != 13) + else if (fattrit) { rit_imp = imponibile; rit_iva = imposta; @@ -1075,7 +1075,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) vendite += imponibile; vendite_iva += imposta; } - else if (liq && tipomov == acquisto) + else if ((liq || fattrit && month == 13) && tipomov == acquisto) { // totale acquisti acquisti += imponibile; diff --git a/cg/cg4304.cpp b/cg/cg4304.cpp index 64d86f0d8..6e4574871 100755 --- a/cg/cg4304.cpp +++ b/cg/cg4304.cpp @@ -499,6 +499,10 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt) int tipodet = atoi(*_pim_tipodet); TString codiva((const char*)(*_pim_codiva)); TString other = _pim->get("S4"); + TToken_string s1(_pim->get("S1"),'!'); // Imponibile/iva fatture in ritardo + real rit_imp(s1.get(0)); + real rit_iva(s1.get(1)); + const bool is_rit= tipodet != 0 && month == 13 && rit_imp != 0.0; //Se fattura in ritardo con tipo detr. != 0 e si sta calcolando l'annuale // ACHTUNG! Corrispettivi da ventileer possono ventilare // ad un altro codiva; in tal caso si scrive quello @@ -517,7 +521,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt) // questi non vanno in liquidazione, i totali sono // gia' calcolati altrove - if (tipodet == 1 || tipodet == 3 || tipodet == 9) + if ((tipodet == 1 || tipodet == 3 || tipodet == 9) && !is_rit) continue; // se ha tutti gli importi nulli viene da un annullamento di @@ -573,10 +577,11 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt) if (tipomov == acquisto) { - d->_r4 += _pim->get_real("R0"); - d->_r5 += _pim->get_real("R1"); - t4 += _pim->get_real("R0"); - t5 += _pim->get_real("R1"); + // Ci sono anche le fatture in ritardo (solo in annuale)! Con tipo detraibilita' 1,3,9 + d->_r4 += is_rit ? rit_imp : _pim->get_real("R0"); + d->_r5 += is_rit ? rit_iva : _pim->get_real("R1"); + t4 += is_rit ? rit_imp : _pim->get_real("R0"); + t5 += is_rit ? rit_iva : _pim->get_real("R1"); } else // vendita { @@ -673,7 +678,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt) real impc,ivac; // Aggiunge lo scorporo dei corrispettivi const int ditems = _descr_arr.items(); - for (int i=0;izero(); + _com->put(COM_STATO, stato); + _com->put(COM_COM, cod); + _com->read(); + if (_com->bad()) + _com->zero(); + + return _com->curr(); +} + +TRectype& CG4400_application::look_comuni (const char* cod) { _com->zero(); _com->put(COM_COM, cod); @@ -2038,7 +2050,7 @@ bool CG4400_application::preprocess_page(int file, int counter) reset_print(); int rr = 0, riga = 0; bool intra; - TString80 comune, prov, comcf, capcf, civcf; + TString80 comune, prov, comcf, capcf, civcf, stacf; TString80 viacf; TString ragsoc; TString tipo_op = ""; @@ -2152,6 +2164,7 @@ bool CG4400_application::preprocess_page(int file, int counter) capcf = dep.get (CLI_CAPCF); comcf = dep.get (CLI_COMCF); comune = dep.get (CLI_LOCCF); + stacf = dep.get (CLI_STATOCF); char tipoa = dep.get_char(CLI_TIPOAPER); if (tipoa == 'F') { @@ -2171,8 +2184,9 @@ bool CG4400_application::preprocess_page(int file, int counter) civcf = dep.get (OCC_CIV); capcf = dep.get (OCC_CAP); comcf = dep.get (OCC_COM); + stacf = dep.get (OCC_STATO); } - TRectype com = look_comuni(comcf); + TRectype com = look_comuni(stacf,comcf); if (!com.empty()) { comune = com.get(COM_DENCOM); diff --git a/cg/cg4400.h b/cg/cg4400.h index c5202465d..0a7d57162 100755 --- a/cg/cg4400.h +++ b/cg/cg4400.h @@ -95,7 +95,8 @@ public: const char* descr_iva (const char*); TRectype& ricerca_occ(const char*); TRectype& ricerca_cf (char, long); - TRectype& look_comuni(const char*); + TRectype& look_comuni(const TString& stato, const TString& cod); + TRectype& look_comuni(const char* cod); TArray_sheet* get_ditte_sheet() { return _ditte; } int setta_riga (int, const TRigaiva&, real&, real&, real&, real&); int riga_rmoviva(); diff --git a/cg/cg6902.cpp b/cg/cg6902.cpp index f6f6e1bf0..1ed2ea137 100755 --- a/cg/cg6902.cpp +++ b/cg/cg6902.cpp @@ -1106,7 +1106,7 @@ void TInv_cont::sola_iva(TString& record, long nreg) bool TInv_cont::invio_mov_PN() { int size = 256; - TString record(size); + TString record(size),head_descr; bool almeno_una_riga = FALSE; long cicli = _tmov->items(); @@ -1123,6 +1123,8 @@ bool TInv_cont::invio_mov_PN() record.spaces(); long nreg = _tmov->get_long(RMV_NUMREG); + head_descr = _tmov->get(MOV_DESCR); // Descrizione di testata + testata_mov_PN(); @@ -1146,6 +1148,8 @@ bool TInv_cont::invio_mov_PN() testata_trasfer(nreg,nrig,record); TString descr = _trmov->get(RMV_DESCR); + if (descr.empty()) + descr = head_descr; // Se non esiste la descrizione della riga ci mette quella della testata str.format("%-.30s", (const char*) descr); record.overwrite(str,44); //Descrizione riga di movimento