Correzioni al programma causali (cg05*) stampa registri (cg44*) e chiusura

conti (cg46*).


git-svn-id: svn://10.65.10.50/trunk@185 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
nik 1994-09-08 10:11:19 +00:00
parent c48cfadb7d
commit c4c3f7bae3
11 changed files with 2147 additions and 2227 deletions

View File

@ -185,6 +185,8 @@ typedef enum { acquisto, vendita, incasso_pagamento,
int _mode; // Modo maschera corrente
int _items;
// Bitarray delle righe lette da file all'inizio.
// Quando leggo dal file la riga n setto il bit n.
TBit_array _righe_gia_presenti;
void togli_dal_file(const TString&);
@ -833,19 +835,19 @@ bool CG0500_application::descr2array(TMask& m, bool fromHandler)
void CG0500_application::togli_dal_file(const TString& cau)
{
long i;
TLocalisamfile *rcaus = _rel->lfile(LF_RCAUSALI);
const long start = _righe_gia_presenti.first_one();
const long last = _righe_gia_presenti.last_one();
long last = _righe_gia_presenti.last_one();
long start = _righe_gia_presenti.first_one();
if (start > 0L)
for (long i=start; i<=last; i++)
for (i=start; i<=last; i++)
{
if (_righe_gia_presenti[i])
{
rcaus->zero();
rcaus->put(RCA_CODCAUS,cau);
rcaus->put(RCA_NRIGA, i);
if (rcaus->read() == NOERR)
// if (rcaus->read() == NOERR)
rcaus->remove();
_righe_gia_presenti.reset(i);
}
@ -867,6 +869,7 @@ int CG0500_application::re_write(const TMask& m,bool rewrite)
const TString16 cau(m.get(F_COD_CAUS));
TString80 desc;
TString16 coddesc;
TLocalisamfile *caus = _rel->lfile(LF_CAUSALI);
TLocalisamfile *rcaus = _rel->lfile(LF_RCAUSALI);
m.autosave(_rel);
@ -878,8 +881,7 @@ int CG0500_application::re_write(const TMask& m,bool rewrite)
for (int i = 0; i < _items; i++)
{
TToken_string &riga = cs.row(i);
if (riga.empty_items())
continue;
if (riga.empty_items()) continue;
desc = riga.get(0);
const char tipo_cf = riga.get_char();
@ -903,10 +905,8 @@ int CG0500_application::re_write(const TMask& m,bool rewrite)
rcaus->put (RCA_DESC , (const char *)desc);
rcaus->put (RCA_CODDESC, (const char *)coddesc);
rcaus->put (RCA_TIPOCF, tipo_cf);
if (rewrite)
{
if (_righe_gia_presenti[i+1]) // bitarray delle righe lette da file all'inizio
{
if (rewrite) {
if (_righe_gia_presenti[i+1]) {
rcaus->rewrite();
_righe_gia_presenti.reset(i+1);
}
@ -921,10 +921,11 @@ else
if (rewrite)
{
togli_dal_file(cau); // Elimina dal file le righe rimaste nel bitarray
return _rel->rewrite();
// return _rel->rewrite();
return caus->rewrite();
}
else
return _rel->write();
return caus->write();
}

View File

@ -141,11 +141,31 @@ BEGIN
FLAGS "U"
END
// Descrizione normale
STRING 107 50
BEGIN
PROMPT 1 5 "Descrizione "
USE LF_PCON KEY 2
FIELD LF_RCAUSALI->DESC
GROUP 1
END
// Descrizione CLIENTE
STRING 207 50
BEGIN
PROMPT 1 5 "Descrizione "
FIELD LF_RCAUSALI->DESC
GROUP 1
FLAGS "H"
END
// Descrizione FORNITORE
STRING 307 50
BEGIN
PROMPT 1 5 "Descrizione "
FIELD LF_RCAUSALI->DESC
GROUP 1
FLAGS "H"
END
STRING 108 3

View File

@ -2,7 +2,6 @@
#include <tabutil.h>
#include "cg0501.h"
#include "cg0500.h"
#include <causali.h>
@ -15,6 +14,7 @@ const char* iva2name(TipoIVA iva)
case nessuna_iva : i = "Nessuna IVA"; break;
case iva_acquisti: i = "IVA Acquisti"; break;
case iva_vendite : i = "IVA Vendite"; break;
case iva_generica: i = "IVA Generica"; break;
default : i = "IVA ERRATA!"; break;
}
@ -41,25 +41,29 @@ bool TRegistro::read(const char* cod, int year)
int err = ~NOERR;
TTable reg("REG");
if (cod && *cod > ' ')
{
TTable reg("REG");
TString16 chiave;
chiave << year << cod;
reg.put("CODTAB", chiave);
err = reg.read();
if (err == NOERR)
_rec = reg.curr();
}
_rec = reg.curr();
if (_att.ok())
_att.zero();
if (err != NOERR && _rec.ok())
if (err != NOERR)
_rec.zero();
return err == NOERR;
}
int TRegistro::year() const
{ return ok() ? atoi(_rec.get("CODTAB")) : 0; }
TRegistro& TRegistro::operator =(const TRegistro& r)
{
_rec = r._rec;
@ -68,16 +72,17 @@ TRegistro& TRegistro::operator =(const TRegistro& r)
}
bool TRegistro::corrisp() const
int TRegistro::tipo() const
{
const bool t = _rec.ok() ? _rec.get_bool("B0") : FALSE;
const int t = ok() ? _rec.get_int("I0") : 0;
return t;
}
int TRegistro::tipo() const
bool TRegistro::corrispettivi() const
{
const int t = _rec.ok() ? _rec.get_int("I0") : 0;
return t;
const bool c = ok() ? _rec.get_bool("B0") : FALSE;
return c;
}
@ -86,8 +91,8 @@ TipoIVA TRegistro::iva() const
TipoIVA i = (TipoIVA)tipo();
if (i != nessuna_iva && i != iva_vendite && i != iva_acquisti)
{
error_box("Il registro '%s' non e' un registro iva, tipo: %d",
(const char*)_rec.get("CODTAB"), i);
error_box("Il registro '%s' non e' un registro IVA o contabile: tipo %d",
(const char*)name(), i);
i = nessuna_iva;
}
return i;
@ -98,12 +103,11 @@ bool TRegistro::read_att()
if (!_att.empty())
return TRUE;
TLocalisamfile attivita(LF_ATTIV);
attivita.put("CODDITTA", MainApp()->get_firm());
const char* a = _rec.get("S8");
attivita.put("CODATT", a);
const int err = attivita.read();
_att = attivita.curr();
TLocalisamfile attiv(LF_ATTIV);
attiv.put("CODDITTA", MainApp()->get_firm());
attiv.put("CODATT", attivita());
const int err = attiv.read();
_att = attiv.curr();
if (err != NOERR)
_att.zero();
@ -143,7 +147,6 @@ bool TRegistro::update(long protiva, const TDate& datareg)
_rec.put("D2", datareg);
updated = FALSE;
}
if (!updated)
{
TTable reg("REG");
@ -166,12 +169,12 @@ bool TLibro_giornale::read(int y)
y = oggi.year();
}
if (ok() && y == year()) return TRUE; // Gia' letto!
TTable reg("REG");
bool found = FALSE;
char anno[8]; sprintf(anno, "%4d", y);
TString16 anno; anno.format("%-4d", y);
reg.setkey(1);
reg.put("CODTAB", anno); // Cerca il primo registro dell'anno y
for (int err = reg.read(_isgteq); err == NOERR; err = reg.next())
@ -205,6 +208,7 @@ TCausale::TCausale(const char* cod, int year)
if (*cod) read(cod, year);
}
// Legge le righe della causale attualmente selezionata sulla maschera
bool TCausale::read(const char* cod, int year)
{
@ -242,8 +246,11 @@ bool TCausale::read(const char* cod, int year)
for (int riga = 1; riga < size(); riga++) // Fill gaps
if (objptr(riga) == NULL) add(rcaus.curr(), riga);
if (year > 0)
_reg.read(caus.get("REG"), year); // Read register
TString16 codreg(caus.get("REG"));
const bool ok = _reg.read(codreg, year); // Read register
if (!ok && codreg.not_empty())
return error_box("Non esiste il registro '%s' per l'anno %d",
(const char*)codreg, year);
}
else
{
@ -251,12 +258,9 @@ bool TCausale::read(const char* cod, int year)
_reg.read("", year);
}
return TRUE;
}
const TRectype& TCausale::row(int num) const
{
const TRectype* rec = (const TRectype*)objptr(num);
@ -294,6 +298,11 @@ bool TCausale::intra() const
bool TCausale::corrval() const
{ return _rec.ok() ? _rec.get_bool("VALINTRA") : FALSE; }
int TCausale::tipo_mov() const
{ return _rec.ok() ? _rec.get_int("TIPOMOV") : -1; }
const char* TCausale::cod_reg() const
{ return _rec.ok() ? _rec.get("REG") : ""; }
const char* TCausale::causale_inc_imm() const
{ return _rec.ok() ? _rec.get("CODCAUSIM") : ""; }
@ -302,6 +311,12 @@ const char* TCausale::tipo_doc() const
{ return _rec.ok() ? _rec.get("TIPODOC") : ""; }
bool TCausale::puramentecontabile() const
{
const char * codreg = cod_reg();
return ((codreg == NULL || *codreg == '\0') && tipo_mov() == 0);
}
TipoIVA TCausale::iva() const
{
if (_iva == iva_errata)
@ -318,7 +333,7 @@ TipoIVA TCausale::iva() const
if (tpd.read() == NOERR)
{
i = (TipoIVA)tpd.get_int("I0"); // IVA acquisti, vendite, generica
if (i != iva_vendite && i != iva_acquisti)
if (i == iva_generica)
i = _reg.iva();
}
}
@ -336,3 +351,27 @@ bool TCausale::similar(const TCausale& c) const
valuta() == c.valuta() &&
intra() == c.intra();
}
///////////////////////////////////////////////////////////
// Codice IVA
///////////////////////////////////////////////////////////
TCodiceIVA::TCodiceIVA(const char* cod) : TRectype(LF_TABCOM)
{
read(cod);
}
bool TCodiceIVA::read(const char* cod)
{
int err = ~NOERR;
TTable iva("%IVA");
if (cod && *cod)
{
iva.setkey(1);
iva.put("CODTAB", cod);
err = iva.read();
}
TRectype::operator=(iva.curr());
if (err != NOERR) zero();
return err == NOERR;
}

View File

@ -34,12 +34,15 @@ public:
virtual bool ok() const { return !_rec.empty(); }
bool corrisp() const;
int tipo() const;
TipoIVA iva() const;
const char* name() const { return _rec.get("CODTAB").mid(4); }
int year() const { return _rec.get_int("CODTAB"); }
bool corrispettivi() const;
const TString& name() const { return _rec.get("CODTAB").mid(4); }
int year() const;
TDate last_reg() const { return _rec.get_date("D2"); }
TDate last_print() const { return _rec.get_date("D3"); }
long protocol() const { return _rec.get_long("I5"); }
const TString& attivita() const { return _rec.get("S8"); }
bool agenzia_viaggi();
const TString& tipo_attivita();
@ -79,8 +82,11 @@ public:
bool valuta() const;
bool intra() const;
bool corrval() const;
bool puramentecontabile() const;
const char* causale_inc_imm() const;
const char* tipo_doc() const;
const char* cod_reg() const;
int tipo_mov() const;
TRegistro& reg() { return _reg; }
TipoIVA iva() const;
@ -88,10 +94,21 @@ public:
virtual bool ok() const { return !_rec.empty(); }
bool similar(const TCausale& c) const;
bool read(const char* code, int year);
bool read(const char* cod, int year);
TCausale(const char* code = "", int year = 0);
virtual ~TCausale() {}
};
class TCodiceIVA : public TRectype
{
public:
TCodiceIVA(const char* codice = NULL);
bool read(const char* codice);
bool ok() const { return !empty(); }
const TString& codice() const { return get("CODTAB"); }
real percentuale() const { return get_real("R0"); }
const TString& tipo() const { return get("S1"); }
};
#endif

View File

@ -6,22 +6,21 @@
static TString256 TMP;
CG4400_application * app() { return (CG4400_application*) MainApp(); }
HIDDEN CG4400_application * app() { return (CG4400_application*) MainApp(); }
bool filter_func (const TRelation * r)
{
TLocalisamfile * mov = r->lfile(LF_MOV);
TString codreg = mov->get(MOV_REG);
long annoes = mov->get_long(MOV_ANNOES);
TDate datareg = mov->get_date(MOV_DATAREG);
int annoiva = mov->get_int(MOV_ANNOIVA);
if (codreg != app()->_codreg || annoes != app()->_annoes)
if (codreg != (app()->_codreg) || annoiva != (app()->_annoes))
return FALSE;
//Non puo' essere che _tipo_reg sia diverso da 1 o 2, nel caso di stampa tutti i registri !
//if (app()->_stampa_tutti_i_registri)
// if ( (app()->_tipo_reg != 1) && (app()->_tipo_reg != 2) )
// return FALSE;
if (app()->_data_da.string() != "" && app()->_data_a.string() != "")
if ( (datareg < app()->_data_da || datareg > app()->_data_a ) || (!datareg.ok()) )
return FALSE;
return TRUE;
}
@ -154,7 +153,8 @@ bool mask_cod (TMask_field& f, KEY k)
TString codtab;
int anno;
if ( (k == K_TAB) && f.mask().is_running() )
//if ( (k == K_TAB) && f.mask().is_running() )
if ( (k == K_SPACE)||(k == K_TAB) )
{
TString codlib = f.mask().get(CODICE_LIB_UN);
anno = f.mask().get_int(ANNO);
@ -173,9 +173,27 @@ bool mask_cod (TMask_field& f, KEY k)
return TRUE;
}
bool mask_data (TMask_field& f, KEY k)
{
const short id = f.dlg();
if (k == K_ENTER)
{
int anno = f.mask().get_int(ANNO);
TDate data = f.mask().get(id);
if (data.ok())
if (data.year() != anno)
{
f.warning_box("L'anno delle date limite deve essere uguale all'anno iva specificato");
return FALSE;
}
}
return TRUE;
}
/*
bool mask_fino_a_mese (TMask_field& f, KEY k)
{
//if ( (k == K_TAB) && f.mask().is_running() )
if (k == K_ENTER)
{
TTable TabReg ("REG");
@ -241,6 +259,7 @@ bool mask_fino_a_mese (TMask_field& f, KEY k)
}
return TRUE;
}
*/
//da una SHEET non e' possibile mandare messaggi nella maschera!!!
HIDDEN bool my_handler (TMask_field& f, KEY k)
@ -387,6 +406,8 @@ void CG4400_application::user_create()
_tabreg = new TTable("REG");
_tablbu = new TTable("%LBU");
_tabinl = new TTable("%INL");
_tablim = new TTable("LIM");
_tabpim = new TTable("PIM");
_clifo = new TLocalisamfile(LF_CLIFO);
_occas = new TLocalisamfile(LF_OCCAS);
_rel = new TRelation (LF_MOV);
@ -518,8 +539,9 @@ bool CG4400_application::controlla_liquidazione()
{
TTable lim ("LIM");
TTable pim ("PIM");
TString mesi_ric, mesi_cal;
TString chiave;
TString16 mesi_ric = "";
TString16 mesi_cal = "";
TString16 chiave = "";
int i;
if (lim.empty())
@ -846,50 +868,41 @@ void CG4400_application::set_page_tot_reg()
}
}
bool CG4400_application::compila_reg()
bool CG4400_application::compila_reg(const TMask& m)
{
byte tipo;
int anno;
long codditta = _nditte->get_long("CODDITTA");
_codtab = "";
TString16 codtab = "";
_tipo_stampa = m.get_int(TIPO_STAMPA);
if (_tipo_stampa == 2) //stampa su libro unico di studio
_codreg = m.get(CODICE_LIBRO_IVA);
else if (_tipo_stampa == 3) //stampa di prova
_codreg = m.get(CODICE_LIBRO_PROVA);
else _codreg = m.get(CODICE_LIBRO);
if (_codreg.trim().empty())
{
_stampa_tutti_i_registri = TRUE;
for (_tabreg->first(); !_tabreg->eof(); _tabreg->next())
_tabreg->first();
if (!_tabreg->eof())
{
_codtab = _tabreg->get("CODTAB");
tipo = _tabreg->get_int("I0");
anno = atoi(_codtab.mid(0,4));
codtab = _tabreg->get("CODTAB");
anno = atoi(codtab.mid(0,4));
if (anno > _annoes)
{
warning_box("Non esistono registri IVA della Ditta %ld per l'anno %d",
codditta, _annoes);
return FALSE;
}
if (anno == _annoes)
{
if ( tipo == 1 || tipo == 2 ) //registro iva
{
_codreg = _codtab.mid(4,3);
_tipo_reg = _tabreg->get_int("I0");
_pagine_stampate = _tabreg->get_int("I1");
_data_da = _tabreg->get_date ("D3");
_codatt = _tabreg->get("S8");
_attivita = desc_attivita(_codatt);
_desc_lib = _tabreg->get ("S0");
break;
}
else continue;
}
}
}
else // stampa un solo registro
{
_stampa_tutti_i_registri = FALSE;
_codtab << _annoes << _codreg;
codtab << _annoes << _codreg;
_tabreg->zero();
_tabreg->put("CODTAB", _codtab);
_tabreg->put("CODTAB", codtab);
if (_tabreg->read() == NOERR)
{
_tipo_reg = _tabreg->get_int("I0");
@ -899,21 +912,54 @@ bool CG4400_application::compila_reg()
//_nprog_da = tab_reg.get_long ("I6");
//_tot_dare = tab_reg.get_real ("R1")
//_tot_avere = tab_reg.get_real ("R2");
if (_tipo_stampa != 3)
_data_da = _tabreg->get_date ("D3");
if ( _tipo_stampa == 1 || _tipo_stampa == 4 )
if ( _data_a < _data_da)
{
TString16 datas = format("%02d/%4d", _data_da.month(), _data_da.year());
warning_box ("La data specificata non deve essere inferiore al %s (ultima data di stampa specificata sul registro)", (const char*)datas);
return FALSE;
}
//_stampa_intesta = _tabreg->get_bool ("B9");
_codatt = _tabreg->get("S8");
_attivita = desc_attivita(_codatt);
_desc_lib = _tabreg->get ("S0");
return TRUE;
}
else
{
warning_box("Il registro IVA specificato non esiste nella \n Ditta %ld", codditta, _annoes);
warning_box("Il registro IVA specificato non esiste nella \n Ditta %ld", codditta);
return FALSE;
}
}
return TRUE;;
if (_tipo_stampa == 4)
{
TString app(4);
_tabreg->zero();
app = format("%04d", _annoes);
_tabreg->put ("CODTAB", app);
TRectype r (_tabreg->curr());
_tabreg->read(_isgteq);
for (; !_tabreg->eof(); _tabreg->next())
{
if (_tabreg->curr() != r) break;
int tiporeg = _tabreg->get_int("I0");
if (tiporeg == 5) //libro giornale
{
TDate data = _tabreg->get_date("D3");
if (_data_a > data)
{
TString16 datas = format("%02d/%4d", data.month(), data.year());
warning_box ("La data specificata non deve essere superiore al %s (ultima data di stampa del libro giornale)", (const char*)datas);
return FALSE;
}
}
}
}
return TRUE;
}
bool CG4400_application::compila_lib()
@ -943,7 +989,7 @@ bool CG4400_application::preprocess_print(int file, int counter)
_doc_array.destroy();
_dataregp = "";
_mov_empty = TRUE;
_primast = get_page_number();
//_primast = get_page_number();
set_print_zero();
}
return TRUE;
@ -961,22 +1007,26 @@ bool CG4400_application::preprocess_page(int file, int counter)
TLocalisamfile* mov = _cur->file(LF_MOV);
TLocalisamfile* caus = _cur->file(LF_CAUSALI);
long annoes = mov->get_long(MOV_ANNOES);
TString16 codreg = mov->get(MOV_REG);
//long annoes = mov->get_long(MOV_ANNOES);
//TString16 codreg = mov->get(MOV_REG);
_datareg = mov->get_date(MOV_DATAREG);
if (codreg != _codreg || annoes != _annoes)
return FALSE;
//if (codreg != _codreg || annoes != _annoes)
// return FALSE;
if (_data_da.string() != "" && _data_a.string() != "")
if ( (_datareg < _data_da || _datareg > _data_a) || (!_datareg.ok()) )
return FALSE;
//if (_data_da.string() != "" && _data_a.string() != "")
// if ( (_datareg < _data_da || _datareg > _data_a) || (!_datareg.ok()) )
// return FALSE;
_mov_empty = FALSE;
if ( (_tipo_stampa == 1) || (_tipo_stampa == 4) )
//if ( (_tipo_stampa == 1) || (_tipo_stampa == 4) )
if ( (_datareg.month() != _dataregp.month()) && (_dataregp.ok()) )
{
if (_tipo_stampa == 2)
++ _u_stampata;
printer().formfeed();
}
_dataregp = _datareg;
@ -1070,7 +1120,8 @@ void CG4400_application::aggiorna_reg()
TString16 codtab;
TTable Tabreg ("REG");
TTable TabInl ("%INL");
long stampate, pag;
long pag;
//long stampate;
const word ultimast = get_page_number();
@ -1079,10 +1130,10 @@ void CG4400_application::aggiorna_reg()
Tabreg.put("CODTAB", codtab);
if (Tabreg.read() == NOERR)
{
stampate = ultimast - _primast + 1;
//stampate = ultimast + 1;
if (!_mov_empty) //cioe' se e' stata stampata almeno una pagina
{
pag = _pagine_stampate + stampate;
pag = _pagine_stampate + ultimast;
Tabreg.put("I1", pag);
}
Tabreg.put("D3", _data_a);
@ -1109,47 +1160,54 @@ void CG4400_application::aggiorna_reg()
recprec = TabInl.curr();
}
TString16 cod;
TString cod = "";
if (trovato)
{
TString16 cod_inl = recprec.get("CODTAB");
long numero_riga = atol(cod_inl.mid(7,6));
long numero_riga = atol(cod_inl.mid(7,6)) + 1;
TString16 num_riga (format("%6d", numero_riga));
cod_inl = cod_inl.mid(0,7);
nuovo = recprec;
cod << cod_inl << numero_riga + 1;
cod << cod_inl << num_riga;
}
else
cod << codtab << 1L;
{
TString16 num_riga ( format("%6d", 1L) );
cod << codtab << num_riga;
}
long numini = _pagine_stampate + 1;
nuovo.put("CODTAB", cod);
nuovo.put("I0", _annoes);
nuovo.put("I1", _fino_a_mese);
nuovo.put("I2", _primast);
nuovo.put("I3", ultimast);
nuovo.put("I0", (long)_annoes);
nuovo.put("I1", (long)_fino_a_mese);
nuovo.put("I2", (long)_u_stampata + 1);
nuovo.put("I3", (long)(_u_stampata + ultimast));
nuovo.put("I4", get_firm());
nuovo.put("S0", _codreg);
nuovo.put("I5", numini);
nuovo.put("I6", pag);
nuovo.put("I5", (long)numini);
nuovo.put("I6", (long)(numini + ultimast));
if (trovato)
TabInl.rewrite(nuovo);
else
TabInl.write(nuovo);
_u_stampata += ultimast;
}
}
void CG4400_application::aggiorna_lib()
{
TString16 cod;
TString16 cod = "";
TTable lbu ("%LBU");
const word stampate = get_page_number();
cod << _annoes << _codlib;
lbu.zero();
lbu.put("CODTAB", cod);
if (lbu.read() == NOERR)
{
lbu.put("I0", _fino_a_mese);
lbu.put("I1", stampate);
lbu.put("I0", (long) _fino_a_mese);
lbu.put("I1", (long) _u_stampata - 1);
lbu.rewrite();
}
}
@ -1157,6 +1215,20 @@ void CG4400_application::aggiorna_lib()
print_action CG4400_application::postprocess_page (int file, int counter)
{
if (file == LF_MOV)
if (!counter)
{
bool FINITO = FALSE;
TRecnotype pos = _cur->pos();
long items = _cur->items();
FINITO = (pos == items-1);
if ( FINITO )
{
set_page_tot_reg();
return REPEAT_PAGE;
}
else //if ( (_tipo_stampa == 1) || (_tipo_stampa == 4) )
{
TLocalisamfile* mov = _cur->file(LF_MOV);
_cur->save_status();
@ -1171,6 +1243,7 @@ print_action CG4400_application::postprocess_page (int file, int counter)
return REPEAT_PAGE;
}
}
}
return NEXT_PAGE;
}
@ -1179,8 +1252,16 @@ print_action CG4400_application::postprocess_print(int file, int counter)
if (file == LF_MOV)
{
//aggiorna registri solo se non e' stampa di prova
if (_tipo_stampa != 3)
if ( (_tipo_stampa != 3) && (!_stampa_tutti_i_registri) )
aggiorna_reg();
if (_stampa_tutti_i_registri)
if (!_mov_empty )
{
if (_tipo_stampa == 2)
++ _u_stampata;
printer().formfeed();
}
/*
if (_stampa_tutti_i_registri)
{
TString16 codtab;
@ -1215,51 +1296,13 @@ print_action CG4400_application::postprocess_print(int file, int counter)
printer().formfeed();
_cur->set_filterfunction(NULL);
_cur->set_filterfunction(filter_func);
// (*_cur) = 0L;
_mov_empty = TRUE;
return REPEAT_PAGE;
}
}
}
if (file == LF_RMOVIVA)
if (!counter)
{
bool FINITO = FALSE;
TRecnotype pos = _cur->pos();
long items = _cur->items();
FINITO = (pos == items-1);
if ( FINITO )
{
set_page_tot_reg();
return REPEAT_PAGE;
}
else if ( (_tipo_stampa == 1) || (_tipo_stampa == 4) )
{
TLocalisamfile* mov = _cur->file(LF_MOV);
/*
TDate dataregp = mov->get_date(MOV_DATAREG);
_cur->save_status();
++(*_cur);
TDate datareg = mov->get_date(MOV_DATAREG);
--(*_cur);
_cur->restore_status();
if (datareg.month() != dataregp.month())
{
set_page_tot_reg();
return REPEAT_PAGE;
}
if (_dataregp.month() != _dataregs.month())
{
set_page_tot_reg();
return REPEAT_PAGE;
}
*/
}
}
return NEXT_PAGE;
}
@ -1271,27 +1314,8 @@ bool CG4400_application::set_print(int n)
if (set_ditte(m))
if (_selected.ones() > 0l)
{
_tipo_stampa = m.get_int(TIPO_STAMPA);
_annoes = m.get_int(ANNO);
if (_tipo_stampa == 2) //stampa su libro unico di studio
_codreg = m.get(CODICE_LIBRO_IVA);
else if (_tipo_stampa == 3) //stampa di prova
_codreg = m.get(CODICE_LIBRO_PROVA);
else _codreg = m.get(CODICE_LIBRO);
/*
if (_codreg.trim().empty())
{
_tabreg->first();
_codtab = _tabreg->get("CODTAB");
_codreg = _codtab.mid(4,3);
_stampa_tutti_i_registri = TRUE;
}
else
{
_codtab << _annoes << _codreg;
_stampa_tutti_i_registri = FALSE;
}
**/
_tipo_stampa = m.get_int(TIPO_STAMPA);
//Se stampa di prova l'utente indica data_da e data_a
if (_tipo_stampa == 3)
{
@ -1313,7 +1337,8 @@ bool CG4400_application::set_print(int n)
{
_codlib = m.get(CODICE_LIB_UN);
_fino_a_mese = m.get_int(MESE);
set_page_number(m.get_int(ULTIMA_PAGINA) + 1);
_u_stampata = m.get_int(ULTIMA_PAGINA);
//set_page_number(_u_stampata + 1);
}
if (_fino_a_mese == 12)
giorni_del_mese = 31;
@ -1326,16 +1351,15 @@ bool CG4400_application::set_print(int n)
_data_a=format("%02d/%02d/%4d",giorni_del_mese,_fino_a_mese,_annoes);
// NB data_da viene letta nella preprocess_page
}
// compila_reg();
if (_tipo_stampa == 2)
compila_lib();
stampa_registri_IVA();
stampa_registri_IVA(m);
}
else warning_box("Nessuna ditta selezionata!");
return FALSE;
}
void CG4400_application::stampa_registri_IVA()
void CG4400_application::stampa_registri_IVA(const TMask& m)
{
long l;
long firm = TApplication::get_firm();
@ -1346,15 +1370,56 @@ void CG4400_application::stampa_registri_IVA()
if (_selected[l])
{
TApplication::set_firm(_nditte->get_long("CODDITTA"));
ok = compila_reg(); // cerca il primo registro valido (nel caso di stampa tutti i registri), senno' legge i dati del registro specificato
ok = compila_reg(m); // cerca il primo registro valido (nel caso di stampa tutti i registri), senno' legge i dati del registro specificato
if (!ok) continue;
if (!_stampa_tutti_i_registri)
_cur->set_filterfunction(filter_func);
_frequiva = _nditte->get("FREQVIVA")[0];
if (_tipo_stampa != 3) //stampa definitiva
ok = controlla_liquidazione() && controlla_mov();
if (ok) print();
if (!ok) continue;
if (!_stampa_tutti_i_registri)
print();
else
{
TString16 codtab;
int anno, tipo;
for (_tabreg->first(); !_tabreg->eof(); _tabreg->next())
{
tipo = _tabreg->get_int("I0");
codtab = _tabreg->get("CODTAB");
anno = atoi(codtab.mid(0,4));
if (anno > _annoes)
break;
if ( (tipo == 1) || (tipo == 2) ) //registro iva
{
_tipo_reg = _tabreg->get_int("I0");
_desc_lib = _tabreg->get("S0");
if (_tipo_stampa != 3)
_data_da = _tabreg->get_date("D3");
_pagine_stampate = _tabreg->get_int("I1");
_codreg = codtab.mid(4,3);
_codatt = _tabreg->get("S8");
_attivita = desc_attivita(_codatt);
_desc_lib = _tabreg->get ("S0");
//_primast = get_page_number();
//if (!_mov_empty )
// printer().formfeed();
_cur->set_filterfunction(NULL);
_cur->set_filterfunction(filter_func);
//set_page_number(_u_stampata + 1);
print();
if (_tipo_stampa != 3) aggiorna_reg();
}
}
}
if (_tipo_stampa == 2)
aggiorna_lib();
}
}
TApplication::set_firm(firm);
}
@ -1368,8 +1433,10 @@ bool CG4400_application::set_ditte(TMask& m)
m.field(TIPO_STAMPA).set("1");
m.set_handler (TIPO_STAMPA, my_handler);
m.set_handler (DA_DATA, mask_data);
m.set_handler (A_DATA, mask_data);
m.set_handler (MESE, mask_mese);
m.set_handler (FINO_A_MESE, mask_fino_a_mese);
//m.set_handler (FINO_A_MESE, mask_fino_a_mese);
m.set_handler (CODICE_LIB_UN, mask_cod);
m.set_handler (DLG_SELECT, mask_select);
m.set_handler (F_ANNULLA, mask_annulla);
@ -1423,8 +1490,15 @@ else
reset_header();
if (_tipo_stampa == 2)
{
if (_stampa_ind_ditta)
r = stampa_intestazione_ditta();
long num = _u_stampata + 1;
set_header(r++, "@94gProgr.Studio %ld@114gProgr.Utente @#", num);
}
else
r = stampa_intestazione_ditta();
set_header(r, "Registro IVA: %s %s %s Attivita\' %s %s",
(const char *) _codreg, (const char *) _desc_lib,
(const char *) data, (const char *) _codatt,
@ -1457,12 +1531,12 @@ else
{
set_header(r,"@10gNum.@19gDocumento@68gT Tipo@103gCod %s@121g@124gT", (const char*) nd1);
if (_tipo_stampa == 4) //stampa definitiva con rif. al libro giornale
set_header(r, "@127gNumero");
set_header(r, "@128gNum.");
r++;
set_header(r, "Data reg. prot.@17gData@25gNumero Codice Ragione sociale/descrizione@68gO Doc.@76gTotale doc.@91gImponibile Iva %s@112gImposta@124g%s",
(const char*) nd2, (const char*) cor);
if (_tipo_stampa == 4)
set_header(r, "@127goperaz");
set_header(r, "@128gop.");
r++;
}
riga.fill('-');

View File

@ -24,12 +24,19 @@
#include "cglib03.h"
<<<<<<< cg4400.h
const int MAXSTR = 255;
static char __tmp[MAXSTR];
=======
>>>>>>> 1.6
//enum STAMPA { bollati=1, unici=2 };
const int TABREG = (int)TTable::name2log("REG");
bool filter_func (const TRelation*);
bool my_handler (TMask_field&, KEY);
bool mask_cod (TMask_field&, KEY);
bool mask_data (TMask_field&, KEY);
bool mask_mese (TMask_field&, KEY);
bool mask_fino_a_mese (TMask_field&, KEY);
bool mask_select (TMask_field&, KEY);
@ -58,7 +65,7 @@ class CG4400_application : public TPrintapp
friend bool filter_func (const TRelation *r);
friend bool mask_cod (TMask_field&, KEY);
friend bool mask_mese (TMask_field&, KEY);
friend bool mask_fino_a_mese (TMask_field&, KEY);
//friend bool mask_fino_a_mese (TMask_field&, KEY);
friend bool my_handler (TMask_field&, KEY);
friend bool mask_select (TMask_field&, KEY);
friend bool mask_verifica (TMask_field&, KEY);
@ -67,7 +74,7 @@ class CG4400_application : public TPrintapp
TCursor * _cur;
TRelation *_rel;
TLocalisamfile *_clifo, *_nditte, *_occas, *_tab, *_tabcom;
TTable *_tabreg, *_tablbu, *_tabinl;
TTable *_tabreg, *_tablbu, *_tabinl, *_tablim, *_tabpim;
TRigaiva_array _iva_array, _riga_rmi;
TTipodoc_array _doc_array;
TRiga_array _tot_iva_array;
@ -77,13 +84,12 @@ class CG4400_application : public TPrintapp
bool _mov_empty, _stampa_ind_ditta, _stampa_tutti_i_registri;
char _frequiva;
TDate _data_da, _data_a, _data_stampa, _dataregp, _dataregs, _datareg;
long _annoes, _n_ditte;
word _primast;
int _riepil, _tipo_reg, _fino_a_mese, _tipo_stampa, _pagine_stampate;
int _r, _stampa_width; // riga corrente di stampa
long _n_ditte, _u_stampata;
int _fino_a_mese, _tipo_reg, _tipo_stampa, _pagine_stampate;
int _annoes, _r, _stampa_width; // riga corrente di stampa
real _totale_doc;
TString _codreg, _desc_lib, _codatt, _attivita;
TString _codtab, _tipodoc, _descr_doc, _codlib;
TString _tipodoc, _descr_doc, _codlib;
public:
const char* desc_attivita (const char * codatt);
@ -95,13 +101,13 @@ public:
int riga_rmoviva();
bool set_print(int);
bool set_ditte(TMask&);
bool compila_reg();
bool compila_reg(const TMask&);
bool compila_lib();
bool controlla_liquidazione();
bool controlla_mov();
void cerca_reg(const TString&, byte&, TDate&);
//void leggi_movimenti(const TDate&, const TString&, bool&);
void stampa_registri_IVA();
void stampa_registri_IVA(const TMask&);
void set_page_tot_reg();
void aggiorna_reg();
void aggiorna_lib();

View File

@ -1,4 +1,3 @@
<<<<<<< cg4400a.uml
// cg4400a.uml
// Stampa tabella registri
@ -96,6 +95,7 @@ NUMBER ANNO 4
BEGIN
PROMPT 2 7 "Anno "
FLAGS "A"
CHECKTYPE REQUIRED
END
STRING CODICE_LIBRO 3
@ -121,12 +121,12 @@ BEGIN
HELP "Specificare il codice libro di cui si chiede la stampa; nel caso in cui non si indichi nessun codice verranno stampati tutti i libri delle ditte selezionate"
USE REG SELECT (I0<"3") && (CODTAB[1,4]==#111)
INPUT CODTAB[1,4] ANNO
INPUT CODTAB[5,7] CODICE_LIBRO
INPUT CODTAB[5,7] CODICE_LIBRO_PROVA
DISPLAY "Anno " CODTAB[1,4]
DISPLAY "Codice " CODTAB[5,7]
DISPLAY "Descrizione @40" S0
OUTPUT ANNO CODTAB[1,4]
OUTPUT CODICE_LIBRO CODTAB[5,7]
OUTPUT CODICE_LIBRO_PROVA CODTAB[5,7]
//CHECKTYPE NORMAL
FLAGS "UR"
GROUP 1
@ -234,240 +234,3 @@ ENDPAGE
ENDMASK
=======
// cg4400a.uml
// Stampa tabella registri
#include "cg4400a.h"
PAGE "Stampa registri IVA" -1 -1 56 19
/*
LISTBOX TIPO_STAMPA 2 27
BEGIN
PROMPT 2 1 "Tipo stampa "
ITEM "1|Libri bollati della ditta"
MESSAGE SHOW,1@|HIDE,2@|HIDE,3@
ITEM "2|Libri unici dello studio"
MESSAGE SHOW,2@|HIDE,1@|HIDE,3@
ITEM "3|Stampa di prova"
MESSAGE SHOW,3@|HIDE,1@|HIDE,2@|SHOW,CODICE_LIBRO
ITEM "4|Stampa libri con riferimenti al libro giornale"
MESSAGE SHOW,1@|HIDE,2@|HIDE,3@
END
*/
NUMBER TIPO_STAMPA 1
BEGIN
PROMPT 2 1 "Tipo stampa "
SHEET "Cod|Descrizione@50"
INPUT TIPO_STAMPA
OUTPUT TIPO_STAMPA
ITEM "1|Libri bollati della ditta"
ITEM "2|Libri unici dello studio"
ITEM "3|Stampa di prova"
ITEM "4|Stampa libri con riferimenti al libro giornale"
END
GROUPBOX DLG_NULL 35 5
BEGIN
PROMPT 20 1 "Scelta ditte"
END
NUMBER DA_CODICE 6
BEGIN
PROMPT 21 2 "Da codice "
HELP "Immettere codice ditta di partenza per la selezione"
USE LF_NDITTE KEY 1
CHECKTYPE NORMAL
INPUT CODDITTA DA_CODICE
DISPLAY "Codice" CODDITTA
DISPLAY "Ragione sociale@50" RAGSOC
OUTPUT DA_CODICE CODDITTA
END
NUMBER A_CODICE 6
BEGIN
PROMPT 21 3 "A codice "
HELP "Immettere codice ditta di fine selezione"
COPY USE DA_CODICE
CHECKTYPE NORMAL
INPUT CODDITTA A_CODICE
COPY DISPLAY DA_CODICE
OUTPUT A_CODICE CODDITTA
END
STRING F_SELECT 6
BEGIN
PROMPT 21 4 "Scelte n. "
FLAGS "D"
END
BUTTON DLG_SELECT 9
BEGIN
PROMPT 42 2 "Selezione"
//MESSAGE EXIT,DLG_SELECT
END
BUTTON F_ANNULLA 9
BEGIN
PROMPT 42 3 "Annulla"
//MESSAGE EXIT,F_ANNULLA
END
BUTTON F_VERIFICA 9
BEGIN
PROMPT 42 4 "Verifica"
//MESSAGE EXIT,F_VERIFICA
END
DATE DATA_STAMPA
BEGIN
PROMPT 2 6 "Data stampa "
FLAG "AH"
GROUP 3
END
NUMBER ANNO 4
BEGIN
PROMPT 2 7 "Anno "
FLAGS "A"
END
STRING CODICE_LIBRO 3
BEGIN
PROMPT 20 7 "Codice libro "
HELP "Specificare il codice libro di cui si chiede la stampa; nel caso in cui non si indichi nessun codice verranno stampati tutti i libri delle ditte selezionate"
USE REG SELECT (I0<"3") && (S6=="") && (CODTAB[1,4]==#111)
INPUT CODTAB[1,4] ANNO
INPUT CODTAB[5,7] CODICE_LIBRO
DISPLAY "Anno " CODTAB[1,4]
DISPLAY "Codice " CODTAB[5,7]
DISPLAY "Descrizione @40" S0
OUTPUT ANNO CODTAB[1,4]
OUTPUT CODICE_LIBRO CODTAB[5,7]
//CHECKTYPE NORMAL
FLAGS "UR"
GROUP 1
END
STRING CODICE_LIBRO_PROVA 3
BEGIN
PROMPT 20 7 "Codice libro "
HELP "Specificare il codice libro di cui si chiede la stampa; nel caso in cui non si indichi nessun codice verranno stampati tutti i libri delle ditte selezionate"
USE REG SELECT (I0<"3") && (CODTAB[1,4]==#111)
INPUT CODTAB[1,4] ANNO
INPUT CODTAB[5,7] CODICE_LIBRO
DISPLAY "Anno " CODTAB[1,4]
DISPLAY "Codice " CODTAB[5,7]
DISPLAY "Descrizione @40" S0
OUTPUT ANNO CODTAB[1,4]
OUTPUT CODICE_LIBRO CODTAB[5,7]
//CHECKTYPE NORMAL
FLAGS "UR"
GROUP 1
END
STRING CODICE_LIB_UN 3
BEGIN
PROMPT 20 7 "Cod.libro unico "
HELP "Specificare il codice del libro unico su cui deve essere effettuata la stampa"
USE %LBU SELECT CODTAB[1,4]==#111
INPUT CODTAB[1,4] ANNO
INPUT CODTAB[5,7] CODICE_LIB_UN
DISPLAY "Anno " CODTAB[1,4]
DISPLAY "Codice " CODTAB[5,7]
DISPLAY "Descrizione @40" S0
OUTPUT ANNO CODTAB[1,4]
OUTPUT CODICE_LIB_UN CODTAB[5,7]
FLAGS "UR"
CHECKTYPE REQUIRED
GROUP 2
END
GROUPBOX DLG_NULL 52 3
BEGIN
PROMPT 2 9 "Stampa movimenti"
END
DATE DA_DATA
BEGIN
PROMPT 5 10 "Dalla data "
GROUP 3
END
DATE A_DATA
BEGIN
PROMPT 30 10 "Alla data "
GROUP 3
END
LISTBOX FINO_A_MESE 10
BEGIN
PROMPT 5 10 "Fino al mese "
FLAGS "M"
GROUP 1
END
LISTBOX MESE 10
BEGIN
PROMPT 5 10 "Mese "
FLAGS "M"
GROUP 2
END
LISTBOX TIPO_RIEPILOGATIVO 11
BEGIN
PROMPT 2 12 "Tipo riepilogativo "
HELP "Selezionare Del periodo/Annuale a seconda che si desideri la stampa della liquidazione periodica/annuale"
ITEM "P|Del periodo"
ITEM "A|Annuale"
GROUP 1
END
LISTBOX ULTIMO_MESE 10
BEGIN
PROMPT 2 13 "Ultimo mese stampa su libro unico "
FLAGS "MD"
GROUP 2
END
NUMBER ULTIMA_PAGINA 4
BEGIN
PROMPT 2 14 "Ultimo numero di pagina stampata libro unico "
FLAGS "R"
GROUP 2
END
STRING CODICE_LIBRO_IVA 3
BEGIN
PROMPT 2 15 "Eventuale codice libro IVA "
HELP "Se non viene indicato nessun cod. libro IVA, vengono stampati tutti i registri delle ditte selezionate"
USE REG SELECT (I0<"3") && (S6=="") && (CODTAB[1,4]==#111)
INPUT CODTAB[1,4] ANNO
INPUT CODTAB[5,7] CODICE_LIBRO_IVA
DISPLAY "Anno " CODTAB[1,4]
DISPLAY "Codice " CODTAB[5,7]
DISPLAY "Descrizione @40" S0
OUTPUT ANNO CODTAB[1,4]
OUTPUT CODICE_LIBRO_IVA CODTAB[5,7]
//CHECKTYPE NORMAL
FLAGS "UR"
GROUP 2
END
BUTTON DLG_OK 9 2
BEGIN
PROMPT -12 -1 ""
END
BUTTON DLG_CANCEL 9 2
BEGIN
PROMPT -22 -1 ""
END
ENDPAGE
ENDMASK
>>>>>>> 1.3

View File

@ -86,27 +86,24 @@ void TDati_ditta::get_dati_ditta ()
}
}
const char * TDati_ditta::prima_riga()
{
get_dati_ditta();
/*
tmp.format("Ditta %d %s Via %s %s %s %s", _codditta,
(const char *)_ragsoc,(const char *)_viafis, (const char *)_cap,
(const char *)_comunefis, (const char *)_provfis);
*/
tmp << "Ditta " << _codditta << ' ' << _ragsoc << " Via " << _viafis << ' '
<< _cap << ' ' << _comunefis << ' ' << _provfis;
return tmp;
}
const char * TDati_ditta::seconda_riga()
{
tmp = "Data @<";
tmp.right_just(_stampa_width-15);
tmp.overwrite (format ("Partita iva %s @26gCodice fiscale %s",
TString riga(_stampa_width);
tmp = "";
riga = "Data @<";
riga.right_just(_stampa_width-15);
riga.overwrite (format ("Partita iva %s @26gCodice fiscale %s",
(const char*)_paiva, (const char*)_cofi));
return tmp;
tmp = riga;
return __tmp;
}

View File

@ -101,6 +101,7 @@ BEGIN
PROMPT 51 9 ""
COPY ALL F_BILCHG
CHECKTYPE REQUIRED
END
NUMBER F_PROPERG 3
@ -122,6 +123,7 @@ BEGIN
PROMPT 44 10 ""
COPY USE F_BILCHG
CHECKTYPE REQUIRED
COPY DISPLAY F_BILCHG
COPY OUTPUT F_PROPERG
COPY INPUT F_PROPERG
@ -270,6 +272,7 @@ BEGIN
INPUT GRUPPO F_PERDEG
INPUT CONTO F_PERDEC
INPUT SOTTOCONTO F_PERDES
END
NUMBER F_PERDEC 3
@ -294,7 +297,7 @@ BEGIN
PROMPT -12 -1 ""
END
BUTTON DLG_CANCEL 9 2
BUTTON DLG_QUIT 9 2
BEGIN
PROMPT -22 -1 ""
END