Files correlati :cg1.exe Ricompilazione Demo : [ ] Commento :eliminate stringhe statiche; i prog non partivano git-svn-id: svn://10.65.10.50/trunk@11262 c028cbd2-c16b-5b4b-a496-9718f37d4682
2619 lines
75 KiB
C++
Executable File
2619 lines
75 KiB
C++
Executable File
//
|
|
//Lista movimenti
|
|
//
|
|
#include <currency.h>
|
|
#include <mask.h>
|
|
#include <modaut.h>
|
|
#include <printapp.h>
|
|
#include <recarray.h>
|
|
#include <tabutil.h>
|
|
|
|
#include "cg3.h"
|
|
#include "cg3100.h"
|
|
|
|
#include <attiv.h>
|
|
#include <causali.h>
|
|
#include <clifo.h>
|
|
#include <comuni.h>
|
|
#include <mov.h>
|
|
#include <nditte.h>
|
|
#include <pconti.h>
|
|
#include <rmov.h>
|
|
#include <rmoviva.h>
|
|
#include <saldi.h>
|
|
|
|
#include "cglib01.h"
|
|
#include "cglib03.h"
|
|
|
|
enum liste {
|
|
movimenti=1,
|
|
fatture=2,
|
|
};
|
|
|
|
bool filter_func (const TRelation *);
|
|
bool filter_func_fatture (const TRelation *);
|
|
bool annoes_handler(TMask_field&, KEY);
|
|
bool data_inizio (TMask_field&, KEY);
|
|
bool data_fine (TMask_field&, KEY);
|
|
|
|
class TListaMov_application : public TPrintapp
|
|
{
|
|
friend bool filter_func (const TRelation *);
|
|
friend bool filter_func_fatture (const TRelation *);
|
|
friend bool annoes_handler(TMask_field&, KEY);
|
|
friend bool data_inizio (TMask_field&, KEY);
|
|
friend bool data_fine (TMask_field&, KEY);
|
|
|
|
static bool cdc_handler (TMask_field& f, KEY k);
|
|
|
|
TRigaiva_array _c;
|
|
TTable * _tabiva, * _tabtpd, * _tabreg, * _tabes;
|
|
TRelation * _relmov1,* _relmov2,* _relmov3;
|
|
TCursor * _curr1, * _curr2, * _curr3;
|
|
TBit_array _err;
|
|
TDate _data_ini, _data_fin, _datareg, _data_prec, _datacomp;
|
|
TString _descr, _descr_doc, _descr_causale;
|
|
TString _tipo_ini, _causale, _app;
|
|
TString _causale_ini, _causale_fin, _registro,_registro_ini, _registro_fin;
|
|
TString _tipoatt, _tipo_elenco,_tipo_clifo_prec,_cod,_tipoelsucc;
|
|
char _appoggio;
|
|
TString16 _tipodoc, _tipodocumento;
|
|
TString _ragsoc, _indcf, _civcf, _paiv, _codcaus, _dencom, _provcom, _cofi;
|
|
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, _numero;
|
|
int _ae, _anno, _annoes, _annoeser;
|
|
bool _noseparator;
|
|
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 _intra, _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;
|
|
int _ricser;
|
|
bool _settata_prima_riga, _causale_gia_stampata,_mov_di_sola_iva;
|
|
int _cur1,_cur2,_cur2b,_cur3,_cur4,_decidi,_tipod,_controllo_mov_errati;
|
|
int _numero_riga, _alleg, _tiporegistro, _tipocr, _scelta_stampa, _nr, _n;
|
|
int _provvis;
|
|
liste _tipo_lista;
|
|
word _flags;
|
|
char _tipoc;
|
|
TString _cdc, _fsc;
|
|
bool _cdc_only, _print_cdc;
|
|
TDecoder _simbval, _descdoc;
|
|
|
|
protected:
|
|
virtual void preprocess_header();
|
|
virtual bool preprocess_page(int,int);
|
|
virtual print_action postprocess_page(int,int);
|
|
virtual print_action postprocess_print(int,int);
|
|
virtual void set_page(int,int);
|
|
virtual bool set_print(int m);
|
|
void init_print(const TMask& m);
|
|
|
|
void print_intra(int& rr);
|
|
|
|
void imposta_parametri_stampa(const TMask& msk);
|
|
void set_cdc_header(int& soh);
|
|
|
|
public:
|
|
|
|
bool user_create();
|
|
bool user_destroy();
|
|
bool segnala_errori_primariga();
|
|
bool segnala_errori_ogniriga();
|
|
bool segnala_errori_iva();
|
|
bool contropartita(int, int, long, char);
|
|
void stampa_errori_rmov();
|
|
void stampa_errori_mov();
|
|
void stampa_errori_iva(int*,const char*,const int,const int);
|
|
void stampa_errori_contropartita(int, int, long, char);
|
|
void stampa_intestazione();
|
|
void incrementa_totali();
|
|
void compila_clifo();
|
|
void compila_comuni();
|
|
const char * get_error(int error);
|
|
|
|
bool RicercaDoc(const char*);
|
|
const TString& SimboloValuta (const char* cod);
|
|
const TString& DescrDoc(const char* cod);
|
|
|
|
const TString& cdc() const { return _cdc; }
|
|
const TString& fsc() const { return _fsc; }
|
|
|
|
TListaMov_application(char tipost);
|
|
virtual ~TListaMov_application() {}
|
|
};
|
|
|
|
|
|
HIDDEN inline TListaMov_application & app()
|
|
{ return (TListaMov_application&)main_app();}
|
|
|
|
bool annoes_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_TAB && f.focusdirty())
|
|
{
|
|
const int anno = atoi(f.get());
|
|
TEsercizi_contabili esc;
|
|
if (esc.exist(anno))
|
|
{
|
|
f.mask().set(F_DATAINI, esc[anno].inizio());
|
|
const int prossimo = esc.next(anno);
|
|
const TDate fine = esc[prossimo > 0 ? prossimo : anno].fine();
|
|
f.mask().set(F_DATAFIN, fine);
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool data_inizio(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_ENTER)
|
|
{
|
|
int decidi;
|
|
int anno = f.mask().get_int (F_ANNO);
|
|
TDate data = f.mask().get(F_DATAINI);
|
|
if (app()._tipo_lista == movimenti)
|
|
decidi = f.mask().get_int (F_DECIDI);
|
|
|
|
TEsercizi_contabili esc;
|
|
if (esc.exist(anno) && ( (app()._tipo_lista == fatture) ||
|
|
((app()._tipo_lista == movimenti ) && (decidi == 2)) ) )
|
|
{
|
|
const TDate inizio = esc[anno].inizio();
|
|
if (data.ok())
|
|
{
|
|
if (data < inizio)
|
|
{
|
|
f.error_box(TR("La data indicata non deve essere inferiore alla data di inizio esercizio"));
|
|
return FALSE;
|
|
}
|
|
}
|
|
else //se la data e' vuota
|
|
f.mask().field(F_DATAINI).set(inizio);
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool data_fine(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_ENTER)
|
|
{
|
|
int decidi;
|
|
int anno = f.mask().get_int (F_ANNO);
|
|
TDate dataini = f.mask().get(F_DATAINI);
|
|
TDate datafin = f.mask().get(F_DATAFIN);
|
|
if (app()._tipo_lista == movimenti)
|
|
decidi = f.mask().get_int (F_DECIDI);
|
|
if ( (app()._tipo_lista == fatture) ||
|
|
((app()._tipo_lista == movimenti) && (decidi == 2)) )
|
|
if ( dataini.ok() && datafin.ok() )
|
|
if (dataini > datafin)
|
|
{
|
|
f.error_box(TR("La data iniziale non deve essere superiore alla data finale"));
|
|
return FALSE;
|
|
}
|
|
|
|
TEsercizi_contabili esc;
|
|
if (esc.exist(anno) && ( (app()._tipo_lista == fatture) || ((app()._tipo_lista == movimenti) && (decidi == 2)) ) )
|
|
{
|
|
const int prossimo = esc.next(anno);
|
|
const TDate fine = esc[prossimo > 0 ? prossimo : anno].fine();
|
|
if (datafin.ok())
|
|
{
|
|
if (datafin > fine)
|
|
{
|
|
f.error_box(TR("La data indicata non deve essere superiore alla data di fine esercizio successivo, oppure, in caso questo non esista, dell'esercizio indicato"));
|
|
return FALSE;
|
|
}
|
|
}
|
|
else //se la data e' vuota
|
|
f.mask().set(F_DATAFIN, fine);
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TListaMov_application::cdc_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_TAB)
|
|
{
|
|
TMask& m = f.mask();
|
|
const bool on = !(m.field(F_DACDC).empty() && m.field(F_ACDC).empty());
|
|
if (!on)
|
|
{
|
|
m.reset(F_DAFASE);
|
|
m.reset(F_AFASE);
|
|
m.reset(F_CDC_ONLY);
|
|
}
|
|
m.enable(F_DAFASE, on);
|
|
m.enable(F_AFASE, on);
|
|
m.enable(F_CDC_ONLY, on);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TListaMov_application::RicercaDoc(const char * tipo)
|
|
{
|
|
TTable tab_tpd(TAB_TPD);
|
|
TString16 codtab; codtab.format ("%-2s", tipo);
|
|
tab_tpd.zero();
|
|
tab_tpd.put("CODTAB", codtab);
|
|
tab_tpd.read();
|
|
if (tab_tpd.good())
|
|
return TRUE;
|
|
else
|
|
return FALSE;
|
|
}
|
|
|
|
void TListaMov_application::compila_clifo()
|
|
{
|
|
TToken_string key;
|
|
key.add(_tipo_elenco);
|
|
key.add(_codcf);
|
|
const TRectype & clifo = cache().get(LF_CLIFO, key);
|
|
|
|
char tipoa = clifo.get_char("TIPOAPER");
|
|
_alleg = clifo.get_int(CLI_ALLEG);
|
|
_statocf = clifo.get(CLI_STATOCF);
|
|
_comcf = clifo.get(CLI_COMCF);
|
|
_ragsoc = clifo.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.get(CLI_INDCF);
|
|
_civcf = clifo.get(CLI_CIVCF);
|
|
_paiv = clifo.get(CLI_PAIV);
|
|
_capcf = clifo.get(CLI_CAPCF);
|
|
_dencom = clifo.get(CLI_LOCCF);
|
|
_cofi = clifo.get(CLI_COFI);
|
|
_codalleg = clifo.get_long(CLI_CODALLEG);
|
|
}
|
|
|
|
void TListaMov_application::compila_comuni()
|
|
{
|
|
TToken_string key;
|
|
key.add(_statocf);
|
|
key.add(_comcf);
|
|
const TRectype & comuni = cache().get(LF_COMUNI, key);
|
|
//modifica del 26/04/1995
|
|
_dencom = comuni.get(COM_DENCOM);
|
|
if (!_dencom.empty())
|
|
_app = "Com";
|
|
else _app = "Loc";
|
|
//fine modifica
|
|
_provcom = comuni.get(COM_PROVCOM);
|
|
}
|
|
|
|
const char * TListaMov_application::get_error(int err)
|
|
{
|
|
switch (err)
|
|
{
|
|
case 0:
|
|
return TR("La data operazione non appartiene a nessun esercizio");
|
|
break;
|
|
case 1:
|
|
return TR("Anno IVA non compatibile con data operazione");
|
|
break;
|
|
case 2:
|
|
return TR("Data operazione successiva all'esercizio di competenza");
|
|
break;
|
|
case 3:
|
|
return TR("Movimento con competenza anno precedente");
|
|
break;
|
|
case 4:
|
|
return TR("La data di competenza non appartiene a nessun esercizio");
|
|
break;
|
|
case 5:
|
|
return TR("Data competenza incompatibile con data operazione");
|
|
break;
|
|
case 6:
|
|
return TR("Esercizio incompatibile con data competenza");
|
|
break;
|
|
case 7:
|
|
return TR("Codice causale non presente in tabella");
|
|
break;
|
|
case 8:
|
|
return TR("Codice causale sospeso");
|
|
break;
|
|
case 9:
|
|
return TR("Nella causale e' stato attivato il segnale non va in allegato");
|
|
break;
|
|
case 10:
|
|
return TR("Tipo documento non corrisponde a quello indicato in causale");
|
|
break;
|
|
case 11:
|
|
return TR("Tipo documento non presente in tabella");
|
|
break;
|
|
case 12:
|
|
return TR("Codice registro non corrisponde a quello indicato in causale");
|
|
break;
|
|
case 13:
|
|
return TR("Codice registro non presente in tabella");
|
|
break;
|
|
case 14:
|
|
return TR("Codice registro sospeso");
|
|
break;
|
|
case 15:
|
|
return TR("Tipo registro incompatibile con tipo documento");
|
|
break;
|
|
case 16:
|
|
return TR("Non indicato codice cliente/fornitore");
|
|
break;
|
|
case 17:
|
|
return TR("Tipo cliente/fornitore non compatibile con tipo registro");
|
|
break;
|
|
case 18:
|
|
return TR("Codice cliente/fornitore sospeso");
|
|
break;
|
|
case 19:
|
|
return TR("Nel cliente/fornitore e' stato attivato il segnale: non va in allegato");
|
|
break;
|
|
case 20:
|
|
return TR("Indicato codice C/F per allegato che richiama se stesso");
|
|
break;
|
|
case 21:
|
|
return TR("Indicato codice C/F per allegato sospeso");
|
|
break;
|
|
case 22:
|
|
return TR("C/F per allegato riporta un altro C/F per allegato");
|
|
break;
|
|
case 23:
|
|
return TR("Indicato codice C/F per allegato con segnale: non va in allegato");
|
|
break;
|
|
case 24:
|
|
return TR("Indicato codice C/F per allegato non presente in anagrafica");
|
|
break;
|
|
case 25:
|
|
return TR("Codice cliente/fornitore non presente in anagrafica");
|
|
break;
|
|
case 26:
|
|
return TR("Movimento con data competenza diversa da data operazione");
|
|
break;
|
|
default:
|
|
return "";
|
|
break;
|
|
}
|
|
}
|
|
|
|
const int AllegClifo (int gruppo, int conto, long sottoconto)
|
|
{
|
|
TLocalisamfile clifo(LF_CLIFO);
|
|
int alleg;
|
|
|
|
clifo.setkey(3);
|
|
clifo.zero();
|
|
clifo.put(CLI_GRUPPO, gruppo);
|
|
clifo.put(CLI_CONTO, conto);
|
|
clifo.put(CLI_CODCF, sottoconto);
|
|
clifo.read();
|
|
if (clifo.good())
|
|
alleg = clifo.curr().get_int(CLI_ALLEG);
|
|
else
|
|
alleg = 0;
|
|
|
|
return alleg;
|
|
}
|
|
|
|
const char * DescrConto (long gruppo, long conto, long sottoconto,
|
|
const char* tipocf)
|
|
{
|
|
TString key(30);
|
|
TString & tmp = get_tmp_string(50);
|
|
|
|
key << gruppo;
|
|
if (conto != 0)
|
|
key << '|' << conto;
|
|
if (sottoconto != 0)
|
|
key << '|' << sottoconto;
|
|
tmp = cache().get(LF_PCON, key, PCN_DESCR);
|
|
|
|
if (tmp.empty())
|
|
{
|
|
key.format("%s|%ld",tipocf , sottoconto);
|
|
|
|
const TRectype & clifo = cache().get(LF_CLIFO, key);
|
|
if (!clifo.empty())
|
|
{
|
|
char tipoa = clifo.get_char("TIPOAPER");
|
|
if (tipoa == 'F') //persona fisica
|
|
{
|
|
const TString & ragsoc = clifo.get("RAGSOC");
|
|
|
|
tmp = ragsoc.mid(0,30);
|
|
tmp.trim();
|
|
tmp << ' ' << ragsoc.mid(30);
|
|
}
|
|
else
|
|
tmp = clifo.get("RAGSOC");
|
|
}
|
|
}
|
|
return tmp;
|
|
}
|
|
|
|
bool CausAlleg (const char * cod)
|
|
{
|
|
const TRectype & caus = cache().get(LF_CAUSALI, cod);
|
|
const bool allegb = caus.get_bool(CAU_ALLEG);
|
|
|
|
return allegb;
|
|
}
|
|
|
|
const char * TipoAttivita (const char * attreg, long codice_ditta)
|
|
{
|
|
TToken_string key;
|
|
key.add(codice_ditta);
|
|
key.add(attreg);
|
|
const TRectype & attiv = cache().get(LF_ATTIV, key);
|
|
|
|
return attiv.get(ATT_TIPOATT);
|
|
}
|
|
|
|
const TString& TListaMov_application::SimboloValuta(const char* cod)
|
|
{
|
|
return _simbval.decode(cod);
|
|
}
|
|
|
|
const TString& TListaMov_application::DescrDoc(const char* tipo)
|
|
{
|
|
return _descdoc.decode(tipo);
|
|
}
|
|
|
|
const char * AttivitaRegistro (const char * cod, int anno)
|
|
{
|
|
TString16 key;
|
|
|
|
key.format ("%04d%-3s", anno, cod);
|
|
|
|
return cache().get("REG", key, "S8");
|
|
}
|
|
|
|
int CodiceRegistro (const char* cod, int anno)
|
|
{
|
|
TString16 codtab; codtab.format("%4d%-3s", anno, cod);
|
|
const TString& tipo_reg = cache().get("REG", codtab, "I0");
|
|
|
|
return atoi(tipo_reg);
|
|
}
|
|
|
|
// Controlla che il movimento abbia almeno una riga con la commessa voluta
|
|
bool cdc_filter(const TRelation* rel)
|
|
{
|
|
bool ok = FALSE;
|
|
TLocalisamfile& rmov = rel->lfile(LF_RMOV);
|
|
const TRecnotype oldpos = rmov.recno();
|
|
const long numreg = rel->curr(LF_MOV).get_long(MOV_NUMREG);
|
|
const TString& cdc = app().cdc();
|
|
const TString& fsc = app().fsc();
|
|
rmov.zero();
|
|
rmov.put(RMV_NUMREG, numreg);
|
|
rmov.put(RMV_NUMRIG, 1);
|
|
for (int err = rmov.read(_isgteq); err == NOERR; err = rmov.next())
|
|
{
|
|
if (rmov.get_long(RMV_NUMREG) != numreg)
|
|
break;
|
|
if (rmov.get(RMV_CODCMS) == cdc)
|
|
{
|
|
if (fsc.not_empty())
|
|
ok = (rmov.get(RMV_FASCMS) == fsc);
|
|
else
|
|
ok = TRUE;
|
|
if (ok)
|
|
break;
|
|
}
|
|
}
|
|
rmov.readat(oldpos);
|
|
return ok;
|
|
}
|
|
|
|
bool filter_func_fatture (const TRelation* rel)
|
|
{
|
|
const TRectype& mov = rel->curr(LF_MOV);
|
|
|
|
// Altrimenti stampa anche i corrispettivi! Pseudo errore MI2396
|
|
long codcf = mov.get_long(MOV_CODCF);
|
|
if (codcf <= 0)
|
|
return FALSE;
|
|
|
|
const int ann_reg = mov.get_int(MOV_ANNOIVA);
|
|
const TString16 cod_reg = mov.get(MOV_REG);
|
|
const int tipo_reg = CodiceRegistro (cod_reg, ann_reg);
|
|
|
|
// Considera solo iva acquisti o vendite
|
|
if (tipo_reg != 1 && tipo_reg != 2)
|
|
return FALSE;
|
|
|
|
TRectype from (LF_MOV), to (LF_MOV);
|
|
if (app()._annoes != 0) //anno esercizio specificato nella maschera
|
|
{
|
|
from.put(MOV_ANNOES, app()._annoes);
|
|
to.put(MOV_ANNOES, app()._annoes);
|
|
}
|
|
if (app()._data_ini.ok())
|
|
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_TIPO, app()._tipo_fin);
|
|
if (app()._codice_fin != 0)
|
|
to.put(MOV_CODCF, app()._codice_fin);
|
|
|
|
bool ok = mov >= from && mov <= to;
|
|
if (ok && app().cdc().not_empty())
|
|
ok = cdc_filter(rel);
|
|
|
|
return ok;
|
|
}
|
|
|
|
bool filter_func (const TRelation * rel)
|
|
{
|
|
bool ok = FALSE;
|
|
int tipo_reg, ann_reg;
|
|
TString cod_reg, causale;
|
|
TLocalisamfile* mov = &(rel->lfile(LF_MOV));
|
|
TRectype from (mov->curr());
|
|
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) )
|
|
{
|
|
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);
|
|
ok = (mov->curr() >= from) && (mov->curr() <= to);
|
|
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);
|
|
|
|
ok = ((mov->curr() >= from) && (mov->curr() <= to)) &&
|
|
((tipo_reg != 1) && (tipo_reg != 2));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if (ok && app().cdc().not_empty())
|
|
ok = cdc_filter(rel);
|
|
|
|
return ok;
|
|
}
|
|
|
|
void TListaMov_application::stampa_errori_rmov()
|
|
{
|
|
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);
|
|
TDate datareg = rec.get_date(RMV_DATAREG);
|
|
char sez = rec.get_char(RMV_SEZIONE);
|
|
char tipo = rec.get_char(RMV_TIPOC);
|
|
int gruppoc = rec.get_int(RMV_GRUPPOC);
|
|
int contoc = rec.get_int(RMV_CONTOC);
|
|
long sottocontoc = rec.get_long(RMV_SOTTOCONTOC);
|
|
char tipoc = rec.get_char(RMV_TIPOCC);
|
|
|
|
bool g = FALSE;
|
|
char t;
|
|
|
|
TBill tc (gruppo,conto,sottoconto);
|
|
|
|
_nr++;
|
|
|
|
if (anno != _annoeser || datareg != _datareg)
|
|
set_row(_nr++, FR("@11gUno o piu' campi non sono costanti nella riga dell' operazione"));
|
|
if (sez != 'D' && sez != 'A')
|
|
set_row(_nr++, FR("@11gIndicato tipo movimento Dare/Avere errato"));
|
|
if (tc.empty())
|
|
set_row(_nr++, FR("@11gNon presente codice gruppo/conto/sottoconto"));
|
|
if (!tc.ok())
|
|
set_row(_nr++, FR("@11gCodice gruppo/conto/sottoconto non corrisponde ad un sottoconto"));
|
|
|
|
TRectype pc (LF_PCON);
|
|
tc.set(gruppo,0,0l);
|
|
if (!tc.read(pc))
|
|
g = TRUE;
|
|
tc.set(gruppo,conto,0l);
|
|
if (!tc.read(pc))
|
|
set_row(_nr++, FR("@11gCodice gruppo/conto/sottoconto non presente in Piano dei Conti"));
|
|
else
|
|
{
|
|
t = pc.get_char(PCN_TMCF);
|
|
if (t != tipo)
|
|
set_row(_nr++, FR("@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++, FR("@11gCodice gruppo/conto/sottoconto non presente in Piano dei Conti"));
|
|
else
|
|
{
|
|
bool sosp = tc.sospeso();
|
|
if (sosp)
|
|
set_row(_nr++, FR("@11gCodice gruppo/conto/sottoconto sospeso in Piano dei Conti"));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TToken_string key;
|
|
key.add(t);
|
|
key.add(sottoconto);
|
|
const TRectype & clifo = cache().get(LF_CLIFO, key);
|
|
|
|
if (!clifo.empty())
|
|
{
|
|
bool sosp = clifo.get_bool(CLI_SOSPESO);
|
|
if (sosp)
|
|
set_row(_nr++, FR("@11gCodice C/F sospeso in Anagrafica"));
|
|
}
|
|
else set_row(_nr++, FR("@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++, FR("@11gTipo C/F non compatibile con tipo registro"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
TString key(30);
|
|
|
|
key.format("%d||%d|%d|%ld", anno, gruppo, conto, sottoconto);
|
|
|
|
const TRectype & saldi = cache().get(LF_SALDI, key);
|
|
|
|
if (saldi.empty())
|
|
set_row(_nr++, FR("@11gCodice gruppo/conto/sottoconto non presente in Saldi p.d.c."));
|
|
|
|
if (gruppoc != 0 || contoc != 0 || sottocontoc != 0l)
|
|
stampa_errori_contropartita(gruppoc, contoc, sottocontoc, tipoc);
|
|
}
|
|
|
|
void TListaMov_application::stampa_errori_contropartita(int gruppo, int conto, long sottoconto, char t)
|
|
{
|
|
bool g = FALSE;
|
|
|
|
TBill tc;
|
|
TRectype pc (LF_PCON);
|
|
tc.set(gruppo,0,0l);
|
|
if (!tc.read(pc))
|
|
g = TRUE;
|
|
tc.set(gruppo,conto,0l);
|
|
if (!tc.read(pc))
|
|
set_row(_nr++, FR("@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++, FR("@11gCodice gruppo/conto/sottoconto di contropartita non presente in Piano dei Conti"));
|
|
else
|
|
{
|
|
bool sosp = tc.sospeso();
|
|
if (sosp)
|
|
set_row(_nr++, FR("@11gCodice gruppo/conto/sottoconto di contropartita sospeso in Piano dei Conti"));
|
|
}
|
|
}
|
|
else if (sottoconto != 0l)
|
|
{
|
|
TToken_string key;
|
|
key.add(t);
|
|
key.add(sottoconto);
|
|
const TRectype & clifo = cache().get(LF_CLIFO, key);
|
|
|
|
if (!clifo.empty())
|
|
{
|
|
bool sosp = clifo.get_bool(CLI_SOSPESO);
|
|
if (sosp)
|
|
set_row(_nr++, FR("@11gCodice C/F di contropartita sospeso in Anagrafica"));
|
|
}
|
|
else set_row(_nr++, FR("@11gCodice C/F di contropartita non presente in Anagrafica"));
|
|
}
|
|
}
|
|
}
|
|
|
|
void TListaMov_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), FR("@11gCodice IVA sospeso"));
|
|
if (_stampa_mess_alleg_iva)
|
|
if (allc == 0 || allf == 0)
|
|
set_row(++(*nr), FR("@11gSul Codice IVA non e' stato indicato un valore per allegato"));
|
|
}
|
|
else
|
|
set_row(++(*nr), FR("@11gCodice IVA non presente in tabella"));
|
|
|
|
if (tipodet == 1 || tipodet == 3 || tipodet == 5 || tipodet == 9)
|
|
if (_tiporegistro != 2)
|
|
set_row(++(*nr), FR("@11gCodice di indetraibilita' errato"));
|
|
|
|
if (_tiporegistro == 1)
|
|
if (tipocr != 0 && tipocr != 1 && tipocr != 4 && tipocr != 9)
|
|
set_row(++(*nr), FR("@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), FR("@11gTipo costo/ricavo non valido"));
|
|
}
|
|
|
|
void TListaMov_application::stampa_errori_mov()
|
|
{
|
|
long i = _err.first_one();
|
|
if (i != -1)
|
|
{
|
|
for (; i <= _err.last_one(); i++)
|
|
if (_err[i])
|
|
set_row(++_n, "@11g%s", (const char*) get_error(i));
|
|
}
|
|
}
|
|
|
|
void TListaMov_application::set_page(int file, int count)
|
|
{
|
|
switch (_tipo_lista)
|
|
{
|
|
case movimenti:
|
|
if (file == LF_RMOVIVA)
|
|
break;
|
|
if (file == LF_RMOV)
|
|
{
|
|
_nr = 1;
|
|
const TRectype& rec = current_cursor()->curr(LF_RMOV);
|
|
if (_cdc.not_empty())
|
|
{
|
|
if (rec.get(RMV_CODCMS) == _cdc)
|
|
{
|
|
if (_fsc.not_empty())
|
|
{
|
|
if (rec.get(RMV_FASCMS) == _fsc)
|
|
{
|
|
if (!_cdc_only)
|
|
set_row(_nr,"@0g@b"); // Grassettiamo le righe interessate
|
|
}
|
|
else
|
|
{
|
|
if (_cdc_only)
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
if (!_cdc_only)
|
|
set_row(_nr,"@0g@b"); // Grassettiamo le righe interessate
|
|
}
|
|
else
|
|
{
|
|
if (_cdc_only)
|
|
return;
|
|
}
|
|
}
|
|
set_row(_nr,"@3n",FLD(LF_RMOV,RMV_NUMRIG));
|
|
set_row(_nr,"@30g@22s",FLD(LF_RMOV,RMV_DESCR));
|
|
set_row(_nr,"@54g@3,rn",FLD(LF_RMOV,RMV_GRUPPO));
|
|
set_row(_nr,"@58g@3,rn",FLD(LF_RMOV,RMV_CONTO));
|
|
set_row(_nr,"@62g@6,rn",FLD(LF_RMOV,RMV_SOTTOCONTO));
|
|
set_row(_nr,"@69g#.20t",&_descr);
|
|
_appoggio = toupper(current_cursor()->curr(LF_RMOV).get_char(RMV_SEZIONE));
|
|
if (_appoggio=='D')
|
|
set_row(_nr,"@90g@n",FLD(LF_RMOV,RMV_IMPORTO));
|
|
else
|
|
set_row(_nr,"@110g@n",FLD(LF_RMOV,RMV_IMPORTO));
|
|
if (_print_cdc)
|
|
{
|
|
TString80 cms = rec.get(RMV_CODCMS);
|
|
if (cms.not_empty())
|
|
{
|
|
TString riga_commessa(132);
|
|
riga_commessa << "@0g@b" << cms;
|
|
riga_commessa << "@21g" << cache().get("CMS", cms, "S0");
|
|
cms = rec.get(RMV_FASCMS);
|
|
if (cms.not_empty())
|
|
{
|
|
riga_commessa << "@72g" << cms;
|
|
riga_commessa << "@83g" << cache().get("FSC", cms, "S0");
|
|
}
|
|
set_row (_nr+1, riga_commessa);
|
|
}
|
|
}
|
|
}
|
|
else if (file == LF_MOV)
|
|
{
|
|
_n = 1;
|
|
set_row (_n++,"");
|
|
set_row (_n, FR("Operazione n. @14g@7n"), FLD(LF_MOV,MOV_NUMREG));
|
|
set_row (_n, FR("@22gdel@26g@d"),FLD(LF_MOV,MOV_DATAREG));
|
|
set_row (_n, "@37g@36s",FLD(LF_MOV,MOV_DESCR));
|
|
set_row (_n, FR("@75gdoc. @7s"),FLD(LF_MOV,MOV_NUMDOC));
|
|
set_row (_n, FR("@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);
|
|
TDate dcomp = current_cursor()->curr(LF_MOV).get_date(MOV_DATACOMP);
|
|
TString16 reg = current_cursor()->curr(LF_MOV).get(MOV_REG);
|
|
int anno = current_cursor()->curr(LF_MOV).get_int(MOV_ANNOIVA);
|
|
char prov = current_cursor()->curr(LF_MOV).get_char(MOV_PROVVIS);
|
|
int tipo = CodiceRegistro(reg, anno);
|
|
|
|
TEsercizi_contabili esc;
|
|
int ae = esc.date2esc(data);
|
|
if ( (tipo == 1) || (tipo == 2) )
|
|
{
|
|
set_row (_n, FR("@103greg @3s"),FLD(LF_MOV,MOV_REG));
|
|
set_row (_n, FR("@111gpr @5n"),FLD(LF_MOV,MOV_PROTIVA));
|
|
}
|
|
else if (_provvis == 2 && prov >= ' ')
|
|
set_row (_n, FR("@103gMov.Provvisorio"));
|
|
if (data != dcomp)
|
|
set_row (_n, "@119gc.%s", (const char*)dcomp.string(brief, '-'));
|
|
//fine
|
|
set_row (_n, "@130g@f", FLD(LF_MOV,MOV_STAMPATO));
|
|
}
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void TListaMov_application::stampa_intestazione()
|
|
{
|
|
set_row (1,"");
|
|
if (_tipo_elenco == "C")
|
|
set_row (2, FR("@bCliente@8g@6n"), FLD(LF_MOV,MOV_CODCF));
|
|
else
|
|
set_row (2, FR("@bFornitore@10g@6n"), FLD(LF_MOV,MOV_CODCF));
|
|
set_row (2, "@b@18g#.35t", &_ragsoc);
|
|
set_row (2, FR("@b@54gInd #-.29t #-.10t"), &_indcf, &_civcf);
|
|
set_row (2, FR("@b@98gP.I. #11t"), &_paiv);
|
|
if (_alleg == 0)
|
|
set_row (2, FR("@b@121gAllegato SI"));
|
|
else
|
|
set_row (2, FR("@b@121gAllegato NO"));
|
|
set_row (3, FR("@b@54gCap #5t"), &_capcf);
|
|
set_row (3,"@b@64g%s #-.20t Pr #-.5t",
|
|
(const char*)_app, &_dencom, &_provcom);
|
|
set_row (3, FR("@b@98gC.F. #-16t"), &_cofi);
|
|
if (_alleg == 0)
|
|
set_row (3, FR("@b@120gRifer@126g#6d"), &_codalleg);
|
|
}
|
|
|
|
bool TListaMov_application::preprocess_page(int file,int counter)
|
|
{
|
|
TCursor* cur = current_cursor();
|
|
|
|
if (counter) return TRUE;
|
|
|
|
switch (_tipo_lista)
|
|
{
|
|
case movimenti:
|
|
if (_scelta_stampa == 0)
|
|
{
|
|
if (file == LF_MOV)
|
|
{
|
|
_tot_avere = 0;
|
|
_tot_dare = 0;
|
|
_c.destroy();
|
|
_no_preprocess_page = FALSE;
|
|
_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);
|
|
_tipo_elenco = current_cursor()->file(LF_MOV).get(MOV_TIPO);
|
|
_codcf = current_cursor()->file(LF_MOV).get_long(MOV_CODCF);
|
|
_numero = current_cursor()->file(LF_MOV).get_long(MOV_NUMREG);
|
|
_codval = cur->curr(LF_MOV).get(MOV_CODVALI);
|
|
_tiporegistro = CodiceRegistro(_registro, _anno);
|
|
|
|
_causale_gia_stampata = FALSE;
|
|
TEsercizi_contabili esc;
|
|
_ae = esc.date2esc(_datareg);
|
|
|
|
if (_registro.not_empty()) //si tratta di fattura
|
|
if (current_cursor()->is_first_match(LF_RMOV))
|
|
_mov_di_sola_iva = FALSE;
|
|
else _mov_di_sola_iva = TRUE;
|
|
|
|
_descr_doc = DescrDoc(_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);
|
|
da.put(MOV_REG, _registro_ini);
|
|
a.put(MOV_CODCAUS, _causale_fin);
|
|
a.put(MOV_REG, _registro_fin);
|
|
|
|
if ((fl.curr() >= da) && (fl.curr() <= a))
|
|
{
|
|
const TRectype & caus = cache().get(LF_CAUSALI, _causale);
|
|
|
|
_reg_causale = caus.get(CAU_REG);
|
|
_descr_causale = caus.get(CAU_DESCR);
|
|
_alleg_causale = caus.get_bool(CAU_ALLEG);
|
|
_tipodocumento = caus.get(CAU_TIPODOC);
|
|
|
|
if (_controllo_mov_errati == 1 || _controllo_mov_errati == 2)
|
|
{
|
|
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 return TRUE;
|
|
}
|
|
}
|
|
else if (file == LF_RMOV)
|
|
{
|
|
if (!_causale_gia_stampata)
|
|
{
|
|
set_row(_nr,"@4g%3s", (const char*) _causale);
|
|
set_row(_nr,"@8g%-.20s", (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);
|
|
TString tipoc = current_cursor()->curr(LF_RMOV).get(RMV_TIPOC);
|
|
_descr = DescrConto(gruppo, conto, sottoconto, tipoc);
|
|
_alleg = AllegClifo(gruppo, conto, sottoconto);
|
|
_importo = current_cursor()->file(LF_RMOV).get_real(RMV_IMPORTO);
|
|
_appoggio = toupper(current_cursor()->curr(LF_RMOV).get_char(RMV_SEZIONE));
|
|
if (!_no_preprocess_page)
|
|
{
|
|
if (_appoggio=='D')
|
|
{
|
|
_tot_dare_generale += _importo;
|
|
_tot_dare += _importo;
|
|
}
|
|
else
|
|
{
|
|
_tot_avere += _importo;
|
|
_tot_avere_generale += _importo;
|
|
}
|
|
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);
|
|
_intra = iva.get_bool(RMI_INTRA);
|
|
|
|
_c.add_riga(_impo,_impos,ZERO,ZERO,_cod,_tipod,_tipocr,_intra);
|
|
|
|
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);
|
|
|
|
_causale_gia_stampata = FALSE;
|
|
|
|
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))
|
|
{
|
|
const TRectype & caus = cache().get(LF_CAUSALI, _causale);
|
|
|
|
_descr_causale = caus.get(CAU_DESCR);
|
|
_alleg_causale = caus.get_bool(CAU_ALLEG);
|
|
_tipodocumento = caus.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)
|
|
{
|
|
if (!_causale_gia_stampata)
|
|
{
|
|
set_row(_nr,"@4g%3s", (const char*) _causale);
|
|
set_row(_nr,"@8g%-.20s", (const char*) _descr_causale);
|
|
_causale_gia_stampata = TRUE;
|
|
}
|
|
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 = toupper(current_cursor()->curr(LF_RMOV).get_char(RMV_SEZIONE));
|
|
if (!_no_preprocess_page)
|
|
{
|
|
if (_appoggio=='D')
|
|
{
|
|
_tot_dare_generale += _importo;
|
|
_tot_dare += _importo;
|
|
}
|
|
else
|
|
{
|
|
_tot_avere += _importo;
|
|
_tot_avere_generale += _importo;
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
}
|
|
break;
|
|
|
|
case fatture:
|
|
{
|
|
if (file == LF_MOV)
|
|
{
|
|
int anno = cur->curr(LF_MOV).get_int(MOV_ANNOIVA);
|
|
TString codreg = cur->curr(LF_MOV).get(MOV_REG);
|
|
_numr = current_cursor()->curr(LF_MOV).get_long(MOV_NUMREG);
|
|
_tipo_elenco = current_cursor()->curr(LF_MOV).get(MOV_TIPO);
|
|
_codcf = current_cursor()->curr(LF_MOV).get_long(MOV_CODCF);
|
|
int tiporeg = CodiceRegistro (codreg, anno);
|
|
TString attreg = AttivitaRegistro (codreg, anno);
|
|
|
|
if (tiporeg == 1 || tiporeg == 2)//se si tratta di un movimento iva
|
|
{
|
|
_tipoatt = TipoAttivita(attreg, get_firm());
|
|
_tipo_elenco = cur->curr(LF_MOV).get(MOV_TIPO);
|
|
_codcf = cur->curr(LF_MOV).get_long(MOV_CODCF);
|
|
_codcaus = cur->curr(LF_MOV).get(MOV_CODCAUS);
|
|
_tipodoc = cur->curr(LF_MOV).get(MOV_TIPODOC);
|
|
_codval = cur->curr(LF_MOV).get(MOV_CODVALI);
|
|
_totdoc = cur->curr(LF_MOV).get_real(MOV_TOTDOC);
|
|
|
|
if (_tipo_elenco != _tipo_clifo_prec && _tipo_clifo_prec != "")
|
|
printer().formfeed();
|
|
|
|
TLocalisamfile& file = cur->file(LF_MOV);
|
|
TRectype da (file.curr());
|
|
TRectype a (file.curr());
|
|
da.zero();
|
|
a.zero();
|
|
|
|
if (_annoes != 0) //anno specificato nella maschera
|
|
{
|
|
da.put(MOV_ANNOES, _annoes);
|
|
a.put(MOV_ANNOES, _annoes);
|
|
}
|
|
|
|
da.put(MOV_CODCAUS, _causale_ini);
|
|
a.put(MOV_CODCAUS, _causale_fin);
|
|
|
|
if (_data_ini.ok())
|
|
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_TIPO, _tipo_fin);
|
|
if (_codice_fin != 0)
|
|
a.put(MOV_CODCF, _codice_fin);
|
|
|
|
if ((file.curr() >= da) && (file.curr() <= a))
|
|
{
|
|
compila_clifo();
|
|
compila_comuni();
|
|
|
|
if ((_tipo_clifo_prec == "")&&(_codcf_prec == 0l))
|
|
{
|
|
_tipo_clifo_prec = _tipo_elenco;
|
|
_codcf_prec = _codcf;
|
|
stampa_intestazione();
|
|
}
|
|
else
|
|
if (_tipo_clifo_prec == _tipo_elenco && _codcf_prec == _codcf)
|
|
_settata_prima_riga = FALSE;
|
|
else
|
|
{
|
|
if ( _salto_pagina && _tipo_clifo_prec == _tipo_elenco )
|
|
printer().formfeed();
|
|
stampa_intestazione();
|
|
_tipo_clifo_prec = _tipo_elenco;
|
|
_codcf_prec = _codcf;
|
|
_settata_prima_riga = FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
else if (file == LF_RMOVIVA)
|
|
{
|
|
int gruppo = current_cursor()->curr(LF_RMOV).get_int(RMV_GRUPPO);
|
|
int conto = current_cursor()->curr(LF_RMOV).get_int(RMV_CONTO);
|
|
|
|
TToken_string key;
|
|
key.add(gruppo);
|
|
key.add(conto);
|
|
key.add("");
|
|
const TRectype & pcon = cache().get(LF_PCON, key);
|
|
|
|
_ricser = pcon.get_int("RICSER");
|
|
|
|
_simbolo = SimboloValuta(_codval);
|
|
_allegb = CausAlleg(_codcaus);
|
|
_descr_doc = DescrDoc(_tipodoc);
|
|
_intra = cur->curr(LF_RMOVIVA).get_bool(RMI_INTRA);
|
|
|
|
if (!_settata_prima_riga)
|
|
{
|
|
reset_print();
|
|
set_row(1, "");
|
|
set_row(2,"@7,rn",FLD(LF_MOV,MOV_NUMREG));
|
|
set_row(2,"@8g@d",FLD(LF_MOV,MOV_DATAREG));
|
|
set_row(2,"@17g@3,rs",FLD(LF_MOV,MOV_REG));
|
|
set_row(2,"@20g@5,rn",FLD(LF_MOV,MOV_PROTIVA));
|
|
set_row(2,"@26g@2,rn",FLD(LF_MOV,MOV_MESELIQ));
|
|
|
|
TString protiva = cur->curr(LF_MOV).get(MOV_PROTIVA);
|
|
TString uprotiva = cur->curr(LF_MOV).get(MOV_UPROTIVA);
|
|
|
|
if (uprotiva.not_empty())
|
|
{
|
|
for (int i = 0; protiva[i] && (protiva[i] == uprotiva[i]); i++);
|
|
uprotiva = uprotiva.mid(i);
|
|
set_row(2, "@24g/@25g%s", (const char*) uprotiva);
|
|
}
|
|
set_row(2, "@32g@d", FLD(LF_MOV,MOV_DATADOC));
|
|
set_row(2,"@41g@6,rs",FLD(LF_MOV,MOV_NUMDOC));
|
|
set_row(2,"@48g@3s",FLD(LF_MOV,MOV_CODCAUS));
|
|
set_row(2,"@52g@2s",FLD(LF_MOV,MOV_TIPODOC));
|
|
set_row(2,"@55g%-.12s", (const char *)_descr_doc);
|
|
set_row(2,"@67g@n",FLD(LF_MOV,MOV_TOTDOC));
|
|
set_row(2,"@84g@n",FLD(LF_RMOVIVA,RMI_IMPONIBILE));
|
|
set_row(2,"@101g@4s",FLD(LF_RMOVIVA,RMI_CODIVA));
|
|
set_row(2,"@105g@1n",FLD(LF_RMOVIVA,RMI_TIPODET));
|
|
if (_tipoatt == "E")
|
|
{
|
|
if (_ricser == 1)
|
|
set_row(2,"@109g1");
|
|
else if (_ricser == 2)
|
|
set_row(2,"@109g2");
|
|
}
|
|
set_row(2,"@111g@f",FLD(LF_RMOVIVA,RMI_INTRA));
|
|
set_row(2,"@114g@n",FLD(LF_RMOVIVA,RMI_IMPOSTA));
|
|
if (_allegb)
|
|
set_row(2,"@131g*");
|
|
|
|
incrementa_totali();
|
|
_settata_prima_riga = TRUE;
|
|
++_documenti;
|
|
}
|
|
else if (_settata_prima_riga)
|
|
{
|
|
reset_print();
|
|
set_row(1,"@84g@n", FLD(LF_RMOVIVA,RMI_IMPONIBILE));
|
|
set_row(1,"@101g@4s", FLD(LF_RMOVIVA,RMI_CODIVA));
|
|
set_row(1,"@105g@1n",FLD(LF_RMOVIVA,RMI_TIPODET));
|
|
set_row(1,"@114g@n", FLD(LF_RMOVIVA,RMI_IMPOSTA));
|
|
incrementa_totali();
|
|
}
|
|
return TRUE;
|
|
}
|
|
}
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
void TListaMov_application::print_intra(int& rr)
|
|
{
|
|
const TRectype& mov = current_cursor()->curr(LF_MOV);
|
|
const real corrval = mov.get(MOV_CORRVALUTA);
|
|
if (corrval != ZERO)
|
|
{
|
|
const TString16 codval = mov.get(MOV_CODVALI);
|
|
TString80 str;
|
|
|
|
rr++;
|
|
|
|
const TCurrency cl(mov.get_real(MOV_CORRLIRE));
|
|
str = cl.string(TRUE); str.right_just(19);
|
|
set_row(rr,FR("Corrispettivo@14g%s"), (const char*)str);
|
|
|
|
const TCurrency cv(corrval, codval);
|
|
str = cv.string(TRUE); str.right_just(19);
|
|
set_row(rr,FR("@34gCorr.in valuta@49g%s"), (const char*)str);
|
|
|
|
set_row(rr,"@70g%-3s", (const char*)codval);
|
|
}
|
|
}
|
|
|
|
print_action TListaMov_application::postprocess_page(int file,int count)
|
|
{
|
|
if (count)
|
|
{
|
|
reset_print();
|
|
return NEXT_PAGE;
|
|
}
|
|
switch (_tipo_lista)
|
|
{
|
|
case movimenti:
|
|
if (file == LF_RMOV)
|
|
{
|
|
force_setpage();
|
|
break;
|
|
}
|
|
if (file == LF_MOV)
|
|
{
|
|
reset_print();
|
|
_err.reset();
|
|
int n = 1;
|
|
int r = 0;
|
|
if (_scelta_stampa == 0)
|
|
if (_registro.not_empty() && _mov_di_sola_iva)
|
|
{
|
|
compila_clifo();
|
|
set_row(++r, "@1g%3s %-50s %6ld %-50s", (const char*)_causale, (const char*)_descr_causale, _codcf, (const char*)_ragsoc);
|
|
}
|
|
if ( _scelta_stampa == 0 && _stampa_parte_iva )
|
|
{
|
|
for (int j = 0; j < _c.items(); j++)
|
|
{
|
|
TRigaiva& riga = (TRigaiva&)_c[j];
|
|
//r = j+1;
|
|
r++;
|
|
set_row(r, FR("Imponibile@11g%r"), &riga._imponibile);
|
|
set_row(r, FR("@31gImposta@38g%r"), &riga._imposta);
|
|
set_row(r, FR("@58gCodice Iva@69g%3s"), (const char*)riga._codiva);
|
|
switch (riga._tipodet)
|
|
{
|
|
case 0 : set_row(r, FR("@76gDetraibile"));
|
|
break;
|
|
case 1 : set_row(r, FR("@76gIndetraibile su op.es."));
|
|
break;
|
|
case 3 : set_row(r, FR("@76gPassaggi interni"));
|
|
break;
|
|
case 9 : set_row(r, FR("@76gIndetraibile art.19"));
|
|
break;
|
|
default: break;
|
|
}
|
|
|
|
if (j == 0) // Se e' la prima riga che stampa
|
|
{
|
|
const int meseliq = current_cursor()->file(LF_MOV).get_int(MOV_MESELIQ);
|
|
if (meseliq > 0) // Stampa il mese liquidazione
|
|
set_row(r,FR(" Mese liq. %2d"), meseliq);
|
|
}
|
|
if (riga._intra)
|
|
set_row(r, FR("@111gOper.intrac."));
|
|
if (_controllo_mov_errati != 3)
|
|
if (!_esiste_riga_iva && ! _nonesiste_riga_iva)
|
|
stampa_errori_iva(&r, riga._codiva, riga._tipodet, riga._tipocr);
|
|
}
|
|
print_intra(r);
|
|
if (_esiste_riga_iva)
|
|
set_row(++r, FR("@11gPresenti righe IVA in una registrazione senza IVA"));
|
|
if (_nonesiste_riga_iva)
|
|
set_row(++r, FR("@11gNon presente alcuna riga IVA in una registrazione con IVA"));
|
|
_c.destroy();
|
|
}
|
|
if (r > 0)
|
|
n = ++r;
|
|
TRecnotype pos, items;
|
|
bool FINITO = FALSE;
|
|
if ((_scelta_stampa == 0)&&(_controllo_mov_errati != 3)&&(_tot_dare != _tot_avere))
|
|
set_row(n++, FR("@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);
|
|
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 (!_cdc_only)
|
|
{
|
|
if ( FINITO ||
|
|
(_datareg != datarec)||(_numreg == _numreg_fin))
|
|
{
|
|
if (( _scelta_stampa == 0 && _controllo_mov_errati != 1 && _decidi == 2) || (_scelta_stampa == 1 && _decidi == 2))
|
|
{
|
|
set_row(n, FR("@b@60gTotali del giorno %s"), _datareg.string());
|
|
set_row(n++, "@b@90g%r %r", &_tot_dare_giornaliero, &_tot_avere_giornaliero);
|
|
_tot_avere_giornaliero = 0;
|
|
_tot_dare_giornaliero = 0;
|
|
}
|
|
if ((_scelta_stampa == 0 && _controllo_mov_errati != 1 && FINITO) || (_scelta_stampa == 1 && FINITO))
|
|
{
|
|
set_row(n++,"");
|
|
set_row(n, FR("@b@60gTotale generale"));
|
|
set_row(n++, "@b@90g%r %r", &_tot_dare_generale, &_tot_avere_generale);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (n == 1)
|
|
{
|
|
force_setpage(); //probabilmente e' inutile
|
|
return NEXT_PAGE;
|
|
}
|
|
else
|
|
{
|
|
_no_preprocess_page = TRUE;
|
|
force_setpage(FALSE);
|
|
return REPEAT_PAGE;
|
|
}
|
|
}
|
|
break;
|
|
|
|
case fatture:
|
|
if (file == LF_MOV)
|
|
{
|
|
reset_print();
|
|
TCursor* cur = current_cursor();
|
|
int rr = 1;
|
|
print_intra(rr);
|
|
_totdocumenti += _totdoc;
|
|
TRecnotype pos, items;
|
|
bool FINITO = FALSE;
|
|
|
|
pos = current_cursor()->pos();
|
|
items = current_cursor()->items();
|
|
|
|
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))
|
|
{
|
|
TString blank = "";
|
|
set_row(rr++,(const char*)blank);
|
|
if ((_tipo_elenco == "C")||(_tipo_elenco == "c"))
|
|
set_row(rr++, FR("@bTotali Cliente@18gDocumenti Totale documenti@47gAllegati:@63gImponibile@82gImposta@95gop. esenti@110gop. non imp."));
|
|
else
|
|
set_row(rr++, FR("@bTotali Fornitore@18gDocumenti Totale documenti@49gAllegati:@63gImponibile@82gImposta@95gop. esenti@110gop. non imp."));
|
|
set_row(rr, "@b@18g%9d", _documenti);
|
|
set_row(rr, "@b@28g%r", &_totdocumenti);
|
|
set_row(rr, "@b@57g%r", &_totimponibile);
|
|
set_row(rr, "@b@73g%r", &_totimposta);
|
|
set_row(rr, "@b@92g%r", &_op_esenti);
|
|
set_row(rr, "@b@110g%r", &_op_non_imp);
|
|
_totimposta = 0;
|
|
_totimponibile = 0;
|
|
_op_esenti = 0;
|
|
_op_non_imp = 0;
|
|
_documenti = 0;
|
|
_totdocumenti = 0;
|
|
//return REPEAT_PAGE;
|
|
}
|
|
if (rr > 1)
|
|
return REPEAT_PAGE;
|
|
}
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return NEXT_PAGE;
|
|
}
|
|
|
|
print_action TListaMov_application::postprocess_print(int file,int count)
|
|
{
|
|
if (count)
|
|
{
|
|
reset_print();
|
|
return NEXT_PAGE;
|
|
}
|
|
|
|
switch (_tipo_lista)
|
|
{
|
|
case movimenti:
|
|
break;
|
|
|
|
case fatture:
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
return NEXT_PAGE;
|
|
}
|
|
|
|
//cerca errori sulla testata (MOV)
|
|
bool TListaMov_application::segnala_errori_primariga()
|
|
{
|
|
TEsercizi_contabili esc;
|
|
const int ae = esc.date2esc(_datacomp);
|
|
|
|
if (_ae == 0)
|
|
_err.set(0l);
|
|
|
|
if (_registro.not_empty()) //si tratta di fattura
|
|
if (_datareg.year() != _anno)
|
|
_err.set(1);
|
|
|
|
if ( _scelta_stampa == 0 && _stampa_anno_comp )
|
|
if (_ae != _annoeser)
|
|
{
|
|
if (_annoes) //specificato l'anno nella maschera
|
|
_err.set(2);
|
|
else _err.set(3);
|
|
}
|
|
else
|
|
if (_datacomp != _datareg) // altrimenti se gli esercizi corrispondono controlla datacomp e dataop
|
|
_err.set(26);
|
|
|
|
if (ae)
|
|
{
|
|
const int ar = esc.date2esc(_datareg); // Esercizio in corso
|
|
const int pr = esc.pred(ar); // Esercizio precedente
|
|
if (ae != ar && ae != pr)
|
|
_err.set(4);
|
|
}
|
|
else
|
|
_err.set(5);
|
|
|
|
if (_annoeser != ae)
|
|
_err.set(6);
|
|
|
|
if (_tipodoc != "")
|
|
if (!RicercaDoc(_tipodoc))
|
|
_err.set(11);
|
|
|
|
if (_causale.not_empty()) //se indicata la causale
|
|
{
|
|
const TRectype & caus = cache().get(LF_CAUSALI, _causale);
|
|
if (caus.empty())
|
|
_err.set(7);
|
|
else
|
|
{
|
|
bool sos = caus.get_bool(CAU_SOSPESO);
|
|
if (sos)
|
|
_err.set(8);
|
|
if (_stampa_mess_alleg_iva && _alleg_causale)
|
|
_err.set(9);
|
|
}
|
|
if (_tipodoc != _tipodocumento)
|
|
_err.set(10);
|
|
if (_registro != _reg_causale)
|
|
_err.set(12);
|
|
|
|
if (_registro.not_empty()) //movimento iva (fatture)
|
|
{
|
|
TRegistro rg (_registro, _datareg.year());
|
|
if (rg.name().empty())
|
|
_err.set(13);
|
|
else
|
|
{
|
|
const int tipo = rg.tipo();
|
|
TipoIVA i = nessuna_iva;
|
|
TTable tabtpd("%TPD");
|
|
tabtpd.put("CODTAB", _tipodoc);
|
|
if (tabtpd.read() == NOERR)
|
|
{
|
|
bool cor = tabtpd.get_bool("B0");
|
|
|
|
int i = tabtpd.get_int("I0");
|
|
if (i == 1 && tipo != 1)
|
|
_err.set(15);
|
|
if (i == 2 && tipo != 2)
|
|
_err.set(15);
|
|
if (i == 9 && (tipo != 1 && tipo != 2))
|
|
_err.set(15);
|
|
if (cor && !rg.corrispettivi())
|
|
_err.set(15);
|
|
if (!cor)
|
|
if (_codcf == 0l)
|
|
_err.set(16);
|
|
}
|
|
if (_codcf != 0l)
|
|
{
|
|
if ((tipo == 1 && _tipo_elenco != "C") || (tipo == 2 && _tipo_elenco != "F"))
|
|
_err.set(17);
|
|
|
|
TToken_string key;
|
|
key.add(_tipo_elenco);
|
|
key.add(_codcf);
|
|
const TRectype & clifo = cache().get(LF_CLIFO, key);
|
|
|
|
if (!clifo.empty())
|
|
{
|
|
bool sosp = clifo.get_bool(CLI_SOSPESO);
|
|
if (sosp)
|
|
_err.set(18);
|
|
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(19);
|
|
if (calleg != 0l)
|
|
{
|
|
if (calleg == _codcf)
|
|
_err.set(20);
|
|
TToken_string key;
|
|
key.add(_tipo_elenco);
|
|
key.add(calleg);
|
|
const TRectype & clifo = cache().get(LF_CLIFO, key);
|
|
if (!clifo.empty())
|
|
{
|
|
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(21);
|
|
if (codall != 0l)
|
|
_err.set(22);
|
|
if (_stampa_mess_alleg_iva && alleg == '1')
|
|
_err.set(23);
|
|
}
|
|
else _err.set(24);
|
|
}
|
|
}
|
|
}
|
|
else _err.set(25);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (_err.ones())
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
//controlli sulla contropartita
|
|
bool TListaMov_application::contropartita(int gruppo, int conto, long sottoconto, char t)
|
|
{
|
|
TBill tc;
|
|
TRectype pc (LF_PCON);
|
|
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 if (sottoconto != 0l)
|
|
{
|
|
TToken_string key;
|
|
key.add(t);
|
|
key.add(sottoconto);
|
|
const TRectype & clifo = cache().get(LF_CLIFO, key);
|
|
|
|
if (!clifo.empty())
|
|
{
|
|
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 TListaMov_application::segnala_errori_ogniriga()
|
|
{
|
|
TLocalisamfile& rmov = current_cursor()->file(LF_RMOV);
|
|
int gruppo, conto, anno, gruppoc, contoc;
|
|
long sottoconto, sottocontoc;
|
|
TDate datareg;
|
|
char sez, tipo, t, tipoc;
|
|
real importo;
|
|
real dare, avere;
|
|
|
|
if (current_cursor()->is_first_match(LF_RMOV))
|
|
{
|
|
dare = avere = ZERO;
|
|
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())
|
|
{
|
|
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);
|
|
gruppoc = rec.get_int(RMV_GRUPPOC);
|
|
contoc = rec.get_int(RMV_CONTOC);
|
|
sottocontoc = rec.get_long(RMV_SOTTOCONTOC);
|
|
tipoc = rec.get_char(RMV_TIPOCC);
|
|
anno = rec.get_int(RMV_ANNOES);
|
|
datareg = rec.get_date(RMV_DATAREG);
|
|
sez = rec.get_char(RMV_SEZIONE);
|
|
tipo = rec.get_char(RMV_TIPOC);
|
|
importo = rec.get_real(RMV_IMPORTO);
|
|
|
|
if (sez == 'D')
|
|
dare += importo;
|
|
if (sez == 'A')
|
|
avere += importo;
|
|
|
|
TBill tc (gruppo,conto,sottoconto);
|
|
|
|
if (gruppoc != 0 || contoc != 0 || sottocontoc != 0l)
|
|
if (contropartita(gruppoc, contoc, sottocontoc, tipoc))
|
|
{
|
|
rmov.readat(nrec);
|
|
return TRUE;
|
|
}
|
|
|
|
if (anno != _annoeser || datareg != _datareg)
|
|
{
|
|
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 (LF_PCON);
|
|
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))
|
|
{
|
|
rmov.readat(nrec);
|
|
return TRUE;
|
|
}
|
|
else
|
|
{
|
|
bool sosp = tc.sospeso();
|
|
if (sosp)
|
|
{
|
|
rmov.readat(nrec);
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TToken_string key;
|
|
key.add(t);
|
|
key.add(sottoconto);
|
|
const TRectype & clifo = cache().get(LF_CLIFO, key);
|
|
|
|
if (!clifo.empty())
|
|
{
|
|
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);
|
|
saldi.put(SLD_FLSCA, "");
|
|
|
|
if (saldi.read() != NOERR)
|
|
{
|
|
rmov.readat(nrec);
|
|
return TRUE;
|
|
}
|
|
} //for
|
|
if (dare != avere)
|
|
{
|
|
rmov.readat(nrec);
|
|
return TRUE;
|
|
}
|
|
rmov.readat(nrec);
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
bool TListaMov_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 FALSE;
|
|
}
|
|
|
|
void TListaMov_application::incrementa_totali()
|
|
{
|
|
TString dep1;
|
|
real imponibile, imposta;
|
|
|
|
imponibile = current_cursor()->file(LF_RMOVIVA).get_real(RMI_IMPONIBILE);
|
|
imposta = current_cursor()->file(LF_RMOVIVA).get_real(RMI_IMPOSTA);
|
|
TString codiva = current_cursor()->file(LF_RMOVIVA).get(RMI_CODIVA);
|
|
_tabiva->zero();
|
|
dep1.format("%-4s",(const char*) codiva);
|
|
_tabiva->put("CODTAB", (const char*)dep1);
|
|
_tabiva->read();
|
|
if (_tabiva->bad())
|
|
_tabiva->zero();
|
|
if ((_tipo_elenco == "C")||(_tipo_elenco == "c"))
|
|
{
|
|
const int colonna = _tabiva->get_int("S7");
|
|
if ((colonna == 1)||(colonna == 3))
|
|
_totimposta += imposta;
|
|
if (colonna == 1)
|
|
_totimponibile += imponibile;
|
|
else
|
|
if (colonna == 3)
|
|
_op_esenti += imponibile;
|
|
}
|
|
else
|
|
{
|
|
const int colonna = _tabiva->get_int("S8");
|
|
if ((colonna == 1)||(colonna == 3)||(colonna == 4))
|
|
_totimposta += imposta;
|
|
if (colonna == 1)
|
|
_totimponibile += imponibile;
|
|
else
|
|
if (colonna == 3)
|
|
_op_esenti += imponibile;
|
|
else
|
|
if (colonna == 4)
|
|
_op_non_imp += imponibile;
|
|
}
|
|
}
|
|
|
|
void TListaMov_application::imposta_parametri_stampa(const TMask& msk)
|
|
{
|
|
set_magic_currency(TRUE);
|
|
|
|
reset_files();
|
|
_curr1->set_filterfunction (filter_func);
|
|
_curr2->set_filterfunction (filter_func);
|
|
_curr3->set_filterfunction (filter_func_fatture);
|
|
switch (_tipo_lista)
|
|
{
|
|
case movimenti:
|
|
{
|
|
_scelta_stampa = atoi(msk.get(F_MOVIMENTI));
|
|
_annoes = msk.get_int (F_ANNO);
|
|
_decidi = msk.get_int(F_DECIDI);
|
|
_causale_ini = msk.get(F_CAUSALEINI);
|
|
_causale_fin = msk.get(F_CAUSALEFIN);
|
|
if (_scelta_stampa == 0)
|
|
{
|
|
_registro_ini = msk.get(F_REGISTROINI);
|
|
_registro_fin = msk.get(F_REGISTROFIN);
|
|
}
|
|
_numreg_ini = msk.get_long(F_NUMEROINI);
|
|
_numreg_fin = msk.get_long(F_NUMEROFIN);
|
|
_data_ini = msk.get(F_DATAINI);
|
|
_data_fin = msk.get(F_DATAFIN);
|
|
_provvis = msk.get_int(F_STAMPAMOVP);
|
|
if (_decidi == 1)
|
|
{
|
|
select_cursor(_cur1);
|
|
if (_provvis == 1) //normale
|
|
_curr1->setfilter("(PROVVIS=\"\")");
|
|
else if (_provvis == 2) //globale
|
|
_curr1->setfilter("");
|
|
else _curr1->setfilter("(PROVVIS!=\"\")"); //solo provvisori
|
|
|
|
TRectype da(LF_MOV), a(LF_MOV);
|
|
da.put(MOV_NUMREG, _numreg_ini);
|
|
a.put(MOV_NUMREG, _numreg_fin);
|
|
current_cursor()->setregion(da,a);
|
|
|
|
add_file(LF_MOV);
|
|
add_file(LF_RMOV,LF_MOV);
|
|
add_file(LF_RMOVIVA,LF_MOV);
|
|
}
|
|
else
|
|
{
|
|
select_cursor(_cur2);
|
|
if (_provvis == 1) //normale
|
|
_curr2->setfilter("(PROVVIS=\"\")");
|
|
else if (_provvis == 2) //globale
|
|
_curr2->setfilter("");
|
|
else
|
|
_curr2->setfilter("(PROVVIS!=\"\")"); //solo provvisori
|
|
TRectype da (LF_MOV), a(LF_MOV);
|
|
if (_data_ini.ok())
|
|
da.put(MOV_DATAREG, _data_ini);
|
|
if (_data_fin.ok())
|
|
a.put(MOV_DATAREG, _data_fin);
|
|
current_cursor()->setregion(da,a);
|
|
add_file(LF_MOV);
|
|
add_file(LF_RMOV,LF_MOV);
|
|
add_file(LF_RMOVIVA,LF_MOV);
|
|
}
|
|
}
|
|
break;
|
|
|
|
case fatture:
|
|
{
|
|
_noseparator = msk.get_bool(F_SEPARATOR);
|
|
TString tipo = msk.get(F_TIPOELENCO);
|
|
|
|
_data_ini = msk.get(F_DATAINI);
|
|
_data_fin = msk.get(F_DATAFIN);
|
|
_annoes = msk.get_int(F_ANNO);
|
|
_causale_ini = msk.get(F_DACODCAUS);
|
|
_causale_fin = msk.get(F_ACODCAUS);
|
|
|
|
if (tipo=="C" || tipo=="F")
|
|
{
|
|
_codice_ini = atol(msk.get(F_CODICEINI));
|
|
_codice_fin = atol(msk.get(F_CODICEFIN));
|
|
}
|
|
else
|
|
{
|
|
_codice_ini = atol(msk.get(F_CODICEINI1));
|
|
_codice_fin = atol(msk.get(F_CODICEFIN1));
|
|
}
|
|
|
|
if (tipo == "E")
|
|
{
|
|
_tipo_ini = "C";
|
|
_tipo_fin = "F";
|
|
}
|
|
else
|
|
{
|
|
_tipo_ini = tipo;
|
|
_tipo_fin = tipo;
|
|
}
|
|
select_cursor(_cur3);
|
|
_curr3->setfilter("");
|
|
TRectype da(LF_MOV), a(LF_MOV);
|
|
if (_codice_ini != 0)
|
|
da.put(MOV_CODCF, _codice_ini);
|
|
a.put(MOV_TIPO, _tipo_fin);
|
|
if (_codice_fin != 0)
|
|
a.put(MOV_CODCF, _codice_fin);
|
|
da.put(MOV_TIPO, _tipo_ini);
|
|
current_cursor()->setregion(da,a);
|
|
add_file(LF_MOV);
|
|
add_file(LF_RMOVIVA,LF_MOV);
|
|
}
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
init_print(msk);
|
|
}
|
|
|
|
bool TListaMov_application::set_print(int)
|
|
{
|
|
const char* masc;
|
|
switch(toupper(_tipoc))
|
|
{
|
|
case 'C':
|
|
masc = "cg3100b";
|
|
_tipo_lista = fatture;
|
|
break;
|
|
case 'M':
|
|
default :
|
|
masc = "cg3100a";
|
|
_tipo_lista = movimenti;
|
|
break;
|
|
}
|
|
|
|
TMask msk(masc);
|
|
if (main_app().has_module(CMAUT))
|
|
msk.show(-4);
|
|
else
|
|
{
|
|
msk.hide(-4);
|
|
msk.reset(-4);
|
|
}
|
|
msk.set_handler(F_ANNO, annoes_handler);
|
|
msk.set_handler(F_DATAINI, data_inizio);
|
|
msk.set_handler(F_DATAFIN, data_fine);
|
|
msk.set_handler(F_DACDC, cdc_handler);
|
|
msk.set_handler(F_ACDC, cdc_handler);
|
|
|
|
while (msk.run() == K_ENTER)
|
|
{
|
|
_print_cdc = msk.get_bool(F_PRINTCDC);
|
|
if (msk.get(F_DACDC).not_empty() || msk.get(F_ACDC).not_empty())
|
|
{
|
|
_cdc_only = msk.get_bool(F_CDC_ONLY);
|
|
TRelation rel("CMS");
|
|
TRectype darec(rel.curr()), arec(rel.curr());
|
|
darec.put("CODTAB", msk.get(F_DACDC));
|
|
arec.put("CODTAB", msk.get(F_ACDC));
|
|
TCursor cur(&rel, "", 1, &darec, &arec);
|
|
const long items = cur.items();
|
|
cur.freeze();
|
|
|
|
TRelation fscrel("FSC");
|
|
TRectype da_fsc(fscrel.curr()), a_fsc(fscrel.curr());
|
|
da_fsc.put("CODTAB", msk.get(F_DAFASE));
|
|
a_fsc.put("CODTAB", msk.get(F_AFASE));
|
|
TCursor fsccur(&fscrel, "", 1, &da_fsc, &a_fsc);
|
|
const TRecnotype fsc_items = fsccur.items();
|
|
fsccur.freeze();
|
|
|
|
for (cur = 0L; cur.pos() < items; ++cur)
|
|
{
|
|
_cdc = rel.curr().get("CODTAB");
|
|
if (!da_fsc.empty() || !a_fsc.empty())
|
|
{
|
|
for (fsccur = 0L; fsccur.pos() < fsc_items; ++fsccur)
|
|
{
|
|
_fsc = fsccur.curr().get("CODTAB");
|
|
imposta_parametri_stampa(msk);
|
|
print();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_fsc.cut(0);
|
|
imposta_parametri_stampa(msk);
|
|
print();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_cdc_only = FALSE;
|
|
_cdc.cut(0); _fsc.cut(0);
|
|
imposta_parametri_stampa(msk);
|
|
print();
|
|
}
|
|
msk.reset(-5);
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
bool TListaMov_application::user_create()
|
|
{
|
|
_relmov1 = new TRelation (LF_MOV);
|
|
_relmov1->add(LF_RMOV, "NUMREG=NUMREG",1);
|
|
_relmov1->add(LF_RMOVIVA, "NUMREG=NUMREG",1);
|
|
_curr1 = new TCursor (_relmov1, "", 1);
|
|
_cur1 = add_cursor (_curr1);
|
|
|
|
_relmov2 = new TRelation (LF_MOV);
|
|
_relmov2->add(LF_RMOV, "NUMREG=NUMREG",1);
|
|
_relmov2->add(LF_RMOVIVA, "NUMREG=NUMREG",1);
|
|
_curr2 = new TCursor (_relmov2, "", 2);
|
|
_cur2 = add_cursor (_curr2);
|
|
|
|
_relmov3 = new TRelation (LF_MOV);
|
|
_relmov3->add(LF_RMOVIVA, "NUMREG==NUMREG",1);
|
|
_relmov3->add(LF_RMOV, "NUMREG==NUMREG",1);
|
|
_curr3 = new TCursor (_relmov3, "", 3);
|
|
_cur3 = add_cursor (_curr3);
|
|
|
|
open_files(LF_TAB, LF_TABCOM, LF_CAUSALI, LF_CLIFO, LF_COMUNI, LF_ATTIV,
|
|
LF_PCON, LF_SALDI, LF_RMOVIVA, LF_NDITTE, 0);
|
|
_tabiva = new TTable(TAB_IVA);
|
|
_tabtpd = new TTable(TAB_TPD);
|
|
_tabreg = new TTable("REG");
|
|
_tabes = new TTable("ESC");
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TListaMov_application::user_destroy() // releasev e arrmask
|
|
{
|
|
delete _relmov1;
|
|
delete _relmov2;
|
|
delete _relmov3;
|
|
delete _tabiva;
|
|
delete _tabreg;
|
|
delete _tabtpd;
|
|
delete _tabes;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
void TListaMov_application::init_print(const TMask& msk)
|
|
{
|
|
const TDate data (msk.get(F_DATASTAMPA));
|
|
printer().setdate(data);
|
|
printer().footerlen(5);
|
|
|
|
set_magic_currency(TRUE);
|
|
|
|
switch (_tipo_lista)
|
|
{
|
|
case movimenti:
|
|
{
|
|
set_real_picture("###.###.###.###.###");
|
|
reset_print();
|
|
_flags = 0;
|
|
_err.reset();
|
|
_tot_dare_giornaliero = 0;
|
|
_tot_avere_giornaliero = 0;
|
|
_tot_dare_generale = 0;
|
|
_tot_avere_generale = 0;
|
|
if (_scelta_stampa == 0)
|
|
{
|
|
_annoes = msk.get_int(F_ANNO);
|
|
_stampa_parte_iva = msk.get_bool(F_STAMPA);
|
|
if (_stampa_parte_iva)
|
|
_flags |= ST_DATI_IVA;
|
|
_stampa_mess_alleg_iva = msk.get_bool(F_ALLEGATO);
|
|
if (_stampa_mess_alleg_iva)
|
|
_flags |= ST_MESS_ALLEG;
|
|
_stampa_anno_comp = msk.get_bool(F_ANNOC);
|
|
if (_stampa_anno_comp)
|
|
_flags |= ST_ANNO_COMP;
|
|
_controllo_mov_errati = msk.get_int(F_CONTROLLO);
|
|
if (_controllo_mov_errati == 1)
|
|
_flags |= ST_SOLO_MOVERR;
|
|
else if (_controllo_mov_errati == 2)
|
|
_flags |= ST_CONTROLLO;
|
|
else _flags |= ST_SENZA_CONTR;
|
|
if ((_numreg_ini != 0)&&(_decidi == 1))
|
|
_flags |= ST_NUMERO;
|
|
if ((_data_ini.ok())&&(_decidi == 2))
|
|
_flags |= ST_DATA;
|
|
_causale_ini = msk.get(F_CAUSALEINI);
|
|
if (_causale_ini != "")
|
|
_flags |= ST_CAUSALE;
|
|
_registro_ini = msk.get(F_REGISTROINI);
|
|
if (_registro_ini != "")
|
|
_flags |= ST_REGISTRO;
|
|
if ((_data_fin.ok())&&(_decidi == 2))
|
|
_flags |= ST_DATA;
|
|
if ((_numreg_fin != 0)&&(_decidi == 2))
|
|
_flags |= ST_NUMERO;
|
|
_causale_fin = msk.get(F_CAUSALEFIN);
|
|
if (_causale_fin != "")
|
|
_flags |= ST_CAUSALE;
|
|
_registro_fin = msk.get(F_REGISTROFIN);
|
|
if (_registro_fin != "")
|
|
_flags |= ST_REGISTRO;
|
|
}
|
|
else //_scelta_stampa == 1
|
|
{
|
|
_annoes = msk.get_int(F_ANNO);
|
|
if (_numreg_ini != 0)
|
|
_flags |= ST_NUMERO;
|
|
if (_data_ini.ok())
|
|
_flags |= ST_DATA;
|
|
_causale_ini = msk.get(F_CAUSALEINI);
|
|
if (_causale_ini != "")
|
|
_flags |= ST_CAUSALE;
|
|
if (_data_fin.ok())
|
|
_flags |= ST_DATA;
|
|
if (_numreg_fin != 0)
|
|
_flags |= ST_NUMERO;
|
|
_causale_fin = msk.get(F_CAUSALEFIN);
|
|
if (_causale_fin != "")
|
|
_flags |= ST_CAUSALE;
|
|
}
|
|
}
|
|
break;
|
|
case fatture:
|
|
{
|
|
if (_noseparator)
|
|
set_real_picture("################");
|
|
else
|
|
set_real_picture("####.###.###.###");
|
|
|
|
_flags = 0;
|
|
|
|
reset_print();
|
|
_settata_prima_riga = FALSE;
|
|
_tipo_clifo_prec = "";
|
|
_codcf_prec = 0l;
|
|
_numeroregp = 0;
|
|
_documenti = 0;
|
|
_totdocumenti = 0;
|
|
_totimponibile = 0;
|
|
_totimposta = 0;
|
|
_op_esenti = 0;
|
|
_op_non_imp = 0;
|
|
_annoes = msk.get_int(F_ANNO);
|
|
_salto_pagina = (bool)(msk.get(F_CAMBIO)=="X");
|
|
_data_ini = msk.get(F_DATAINI);
|
|
if (_data_ini.ok())
|
|
_flags |= ST_DATA;
|
|
_data_fin = msk.get(F_DATAFIN);
|
|
_causale_ini = msk.get(F_DACODCAUS);
|
|
if (_causale_ini != "")
|
|
_flags |= ST_CAUSALE;
|
|
if (_data_fin.ok())
|
|
_flags |= ST_DATA;
|
|
_causale_fin = msk.get(F_ACODCAUS);
|
|
if (_causale_fin != "")
|
|
_flags |= ST_CAUSALE;
|
|
TString tipo = msk.get(F_TIPOELENCO);
|
|
if ((tipo=="C")||(tipo=="F"))
|
|
{
|
|
_codice_ini = msk.get_long(F_CODICEINI);
|
|
_codice_fin = msk.get_long(F_CODICEFIN);
|
|
}
|
|
else
|
|
{
|
|
_codice_ini = msk.get_long(F_CODICEINI1);
|
|
_codice_fin = msk.get_long(F_CODICEFIN1);
|
|
}
|
|
if (_codice_ini != 0)
|
|
_flags |= ST_CODICE;
|
|
if (_codice_fin != 0)
|
|
_flags |= ST_CODICE;
|
|
if (tipo == "E")
|
|
{
|
|
_tipo_ini = "C";
|
|
_tipo_fin = "F";
|
|
}
|
|
else
|
|
{
|
|
_tipo_ini = tipo;
|
|
_tipo_fin = tipo;
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void TListaMov_application::set_cdc_header(int& soh)
|
|
{
|
|
if (_cdc.not_empty())
|
|
{
|
|
const TString& desc_cdc = cache().get("CMS", _cdc, "S0");
|
|
if (_fsc.not_empty())
|
|
{
|
|
const TString& desc_fsc = cache().get("FSC", _fsc, "S0");
|
|
set_header(++soh, FR("@bCommessa %s %s - Fase %s %s"),
|
|
(const char*)_cdc, (const char*)desc_cdc,
|
|
(const char*)_fsc, (const char*)desc_fsc);
|
|
}
|
|
else
|
|
set_header(++soh, FR("@bCommessa %s %s"), (const char*)_cdc, (const char*)desc_cdc);
|
|
}
|
|
}
|
|
|
|
void TListaMov_application::preprocess_header()
|
|
{
|
|
int soh; // riga d'inizio dell'intestazione
|
|
|
|
TString sep(132);
|
|
TString key; key.format("%d", get_firm());
|
|
const TString & ragsoc = cache().get(LF_NDITTE, key, NDT_RAGSOC);
|
|
|
|
reset_header();
|
|
soh=1;
|
|
sep << TR("Ditta ") << get_firm();
|
|
sep << " " << ragsoc;
|
|
sep.left_just(132);
|
|
|
|
set_header (soh++, (const char*) sep);
|
|
|
|
sep.cut(0) << FR("Data @> Pag. @#");
|
|
sep.right_just(122);
|
|
|
|
switch (_tipo_lista)
|
|
{
|
|
case movimenti:
|
|
if (_scelta_stampa == 0)
|
|
{
|
|
sep.overwrite (TR("Lista movimenti"));
|
|
set_header (soh++, (const char*)sep);
|
|
if (_decidi == 2) // se _decidi e' 1 _annoes e' sempre uguale a zero
|
|
{
|
|
if (_annoes != 0)
|
|
{
|
|
set_header (soh, FR("Cod. eserc.%d"), _annoes);
|
|
if (_flags & ST_DATA)
|
|
{
|
|
set_header (soh, FR("@16gda@19g%s"),_data_ini.string());
|
|
set_header (soh, FR("@30ga@32g%s"),_data_fin.string());
|
|
}
|
|
}
|
|
else // _annoes == 0
|
|
if (_flags & ST_DATA)
|
|
{
|
|
set_header (soh, FR("Dalla data@11g%s"),_data_ini.string());
|
|
if (_data_fin.ok())
|
|
set_header (soh, FR("@23galla data@33g%s"),_data_fin.string());
|
|
}
|
|
else
|
|
set_header (soh, TR("Completa in ordine di data"));
|
|
}
|
|
else
|
|
if (_flags & ST_NUMERO)
|
|
{
|
|
set_header (soh, FR("dal numero@12g%ld"), _numreg_ini);
|
|
if (_numreg_fin != 0)
|
|
set_header (soh, FR("@20gal numero@30g%ld"), _numreg_fin);
|
|
}
|
|
else
|
|
set_header (soh, TR("Completa in ordine di numero"));
|
|
if (_flags & ST_CAUSALE)
|
|
{
|
|
set_header (soh, FR("@46gdalla causale@60g%s"),(const char*)_causale_ini);
|
|
set_header (soh++, FR("@64galla causale@77g%s"),(const char*)_causale_fin);
|
|
}
|
|
else
|
|
set_header (soh++, TR(" tutte le causali"));
|
|
if (_flags & ST_REGISTRO)
|
|
{
|
|
set_header (soh, FR("dal registro %s"),(const char*)_registro_ini);
|
|
set_header (soh, FR("@17gal registro %s"),(const char*)_registro_fin);
|
|
}
|
|
else
|
|
set_header (soh, TR("tutti i registri"));
|
|
if (_flags & ST_DATI_IVA)
|
|
set_header (soh, FR("@34gstampa dati iva"));
|
|
if (_flags & ST_CONTROLLO)
|
|
set_header (soh, FR("@50g(controllo movimenti)"));
|
|
else if (_flags & ST_SOLO_MOVERR)
|
|
set_header (soh, FR("@50g(solo movimenti errati)"));
|
|
else set_header (soh, FR("@50g(senza controllo movimenti)"));
|
|
if (_flags & ST_MESS_ALLEG)
|
|
{
|
|
if (_flags & ST_ANNO_COMP)
|
|
set_header (soh, FR("@78gcon messaggi: data competenza, allegato iva"));
|
|
else
|
|
set_header (soh, FR("@78gcon messaggio: allegato iva"));
|
|
}
|
|
else if (_flags & ST_ANNO_COMP)
|
|
{
|
|
if (_flags & ST_MESS_ALLEG)
|
|
set_header (soh, FR("@78gcon messaggi: data competenza, allegato iva"));
|
|
else
|
|
set_header (soh, FR("@78gcon messaggio: data competenza"));
|
|
}
|
|
set_cdc_header(soh);
|
|
sep.fill('_');
|
|
set_header (++soh, (const char *) sep);
|
|
set_header (++soh, FR("Rg Cod Causale@30gDescrizione@56gCodice conto@71gDescrizione conto@103gDare@120gAvere@130gSB"));
|
|
}
|
|
else
|
|
{
|
|
sep.overwrite (TR("Lista movimenti di sola prima nota"));
|
|
set_header (soh++, (const char*)sep);
|
|
if (_decidi == 2)
|
|
{
|
|
if (_annoes != 0)
|
|
{
|
|
set_header (soh, FR("Cod. comp. %d"), _annoes);
|
|
if (_flags & ST_DATA)
|
|
{
|
|
set_header (soh, FR("@16gda@19g%s"), (const char*)_data_ini.string());
|
|
set_header (soh, FR("@30ga@32g%s"), (const char*)_data_fin.string());
|
|
}
|
|
}
|
|
else
|
|
if (_flags & ST_DATA)
|
|
{
|
|
set_header (soh, FR("Dalla data@11g%s"), (const char*)_data_ini.string());
|
|
set_header (soh, FR("@23galla data@33g%s"), (const char*)_data_fin.string());
|
|
}
|
|
else
|
|
set_header (soh, TR("Completa in ordine di data"));
|
|
}
|
|
else
|
|
if (_flags & ST_NUMERO)
|
|
{
|
|
set_header (soh, FR("@46gdal numero@57g%ld"), _numreg_ini);
|
|
set_header (soh, FR("@65gal numero@75g%ld"), _numreg_fin);
|
|
}
|
|
else
|
|
set_header (soh, FR("@46gCompleta in ordine di numero"));
|
|
if (_flags & ST_CAUSALE)
|
|
{
|
|
set_header(soh, FR("@86gdalla causale@100g%3s"),(const char*)_causale_ini);
|
|
set_header(soh++,FR("@104galla causale@117g%3s"),(const char*)_causale_fin);
|
|
}
|
|
else
|
|
set_header (soh++, TR("@86gtutte le causali"));
|
|
set_cdc_header(soh);
|
|
soh++;
|
|
sep.fill('_');
|
|
set_header (soh++, (const char *) sep);
|
|
set_header (soh, FR("Rg Cod Causale@30gDescrizione@56gCodice conto@71gDescrizione conto@103gDare@120gAvere@130gSB"));
|
|
}
|
|
break;
|
|
|
|
case fatture:
|
|
sep.overwrite (TR("Lista fatture"));
|
|
set_header (soh, (const char*)sep);
|
|
if (_annoes != 0)
|
|
{
|
|
set_header (soh, FR("@15gCod. comp %d"), _annoes);
|
|
if (_flags & ST_DATA)
|
|
{
|
|
set_header (soh, FR("@30gdalla data@41g%s"), (const char*)_data_ini.string());
|
|
set_header (soh, FR("@52galla data@62g%s"), (const char*)_data_fin.string());
|
|
}
|
|
}
|
|
else
|
|
if (_flags & ST_DATA)
|
|
{
|
|
set_header (soh, FR("@15gdalla data %s"), (const char*)_data_ini.string());
|
|
set_header (soh, FR("@37galla data %s"), (const char*)_data_fin.string());
|
|
}
|
|
else
|
|
set_header (soh, TR("@15gcompleta in ordine di data"));
|
|
if (_flags & ST_CODICE)
|
|
{
|
|
set_header (soh, FR("@74gdal codice %ld"), _codice_ini);
|
|
set_header (soh, FR("@92gal codice %ld"), _codice_fin);
|
|
}
|
|
set_cdc_header(soh);
|
|
sep.fill('_');
|
|
set_header (++soh, (const char *) sep);
|
|
set_header (++soh, FR("Numero Data Cod Prot. M Documento@48gCod Tp @75gTotale@101gCd Tp T O@129gNo"));
|
|
set_header (++soh, FR("Regis. Operaz. Reg Num. L Data@41gNumero@48gCau Dc @55gDescrizione@75gDocumento@90gImponibile@101gIv Det A I@121gImposta@129gAll"));
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
set_header (++soh,(const char*)sep);
|
|
}
|
|
|
|
TListaMov_application::TListaMov_application(char tipost)
|
|
: _tipoc(tipost), _err(80),
|
|
_simbval(TAB_VAL, "S7"), _descdoc(TAB_TPD, "S0")
|
|
{ }
|
|
|
|
|
|
int cg3100(int argc, char* argv[])
|
|
{
|
|
const char tipo = argc > 2 ? *argv[2] : 'M';
|
|
TListaMov_application a(tipo);
|
|
|
|
const char* title;
|
|
switch (tipo)
|
|
{
|
|
case 'C':
|
|
title = TR("Lista fatture clienti/fornitori");
|
|
break;
|
|
default:
|
|
title = TR("Lista movimenti");
|
|
break;
|
|
}
|
|
a.run(argc, argv, title);
|
|
return TRUE;
|
|
}
|
|
|
|
|