Files correlati : cg1.exe Commento : Corretta la stampa del bilancio di verifica dei conti movimentati per data limite.
3749 lines
113 KiB
C++
Executable File
3749 lines
113 KiB
C++
Executable File
// Stampa bilanci
|
|
|
|
// W96SALDI e' la sigla di tutte le modifiche effettuate riguardo il cambiamento dell' archivio
|
|
// SALDI. L' archivio e' cambiato nel seguente modo:
|
|
// - Non esistono piu' i progressivi dei movimenti scaricati PDARESCA e PAVERESCA;
|
|
// - Ora esistono un record per i movimenti normali e un record per i movimenti scaricati; la
|
|
// distinzione e' resa possibile dall' introduzione in chiave di un flag FLSCA (vedi tracciato)
|
|
// che e' un booleano. Il record con FLSCA = false contiene la somma dei saldi dei movimenti
|
|
// normali e dei movimenti scaricati, mentre il record con FLSCA = true, contiene solo i saldi
|
|
// dei movimenti scaricati.
|
|
// Tutti i progressivi che nel programma venivano memorizzati nei campi PDARESCA e PAVERESCA dei
|
|
// file temporanei ora sono memorizzati in PDAREPRO e PAVEREPRO.
|
|
// Le funzioni che sono state modificate sono:
|
|
// - bil_verifica();
|
|
// - ricerca_cf(...);
|
|
// - scrivi_record_gruppo();
|
|
// - scrivi_record_conto();
|
|
// - leggi_clifo();
|
|
// - leggi_file_tmp();
|
|
// - UltimaData();
|
|
|
|
#include <currency.h>
|
|
#include <mask.h>
|
|
#include <modaut.h>
|
|
#include <progind.h>
|
|
#include <printapp.h>
|
|
#include <sort.h>
|
|
#include <utility.h>
|
|
|
|
#include <mov.h>
|
|
#include <rmov.h>
|
|
#include <rmoviva.h>
|
|
#include <pconti.h>
|
|
#include <comuni.h>
|
|
#include <clifo.h>
|
|
#include <attiv.h>
|
|
#include <causali.h>
|
|
#include <saldi.h>
|
|
#include <nditte.h>
|
|
#include <anagr.h>
|
|
|
|
#include "cg1.h"
|
|
#include "cg1500.h"
|
|
#include "cglib.h"
|
|
|
|
|
|
class TStampa_bilanci : public TPrintapp
|
|
{
|
|
static bool mask_anno (TMask_field& f, KEY k);
|
|
static bool mask_datalim (TMask_field& f, KEY k);
|
|
static bool verifica_handler(TMask_field& f, KEY k);
|
|
static bool mask_dataini (TMask_field& f, KEY k);
|
|
static bool mask_bilancio(TMask_field& f, KEY k);
|
|
static bool mask_tipost (TMask_field& f, KEY k);
|
|
|
|
struct cli_for
|
|
{
|
|
char tipocf;
|
|
char gruppo[4];
|
|
char conto[4];
|
|
char codcf[7];
|
|
char ragsoc[52]; // ci può essere uno spazio aggiuntivo
|
|
real saldodare;
|
|
real saldoavere;
|
|
real movdare;
|
|
real movavere;
|
|
real saldofinale;
|
|
TDate udata;
|
|
};
|
|
|
|
TSort * _sort;
|
|
|
|
TRelation* _rel;
|
|
TCursor * _cur;
|
|
TSaldi_list* _listacf, * _lista;
|
|
TLocalisamfile* _com, * _pcn, * _mov, * _rmov, * _clifo, * _saldi, * _nditte,* _anag,* _caus;
|
|
TIsamtempfile * _tmp_saldi_att, * _tmp_saldi_pass, * _tmp_saldi_conti_uno;
|
|
TIsamtempfile * _tmp_saldi_costi, * _tmp_saldi_ricavi,* _tmp_saldi_conti_due;
|
|
TParagraph_string* _d;
|
|
const char* _buff;
|
|
bool _noseparator; // Usa separatore delle migliaia o no?
|
|
|
|
TString _cofi,_cap,_paiva,_ragsoc,_comunefis,_provfis,_viafis;
|
|
TString _descr_dare, _descr_avere, _gc_corr_dare, _gc_corr_avere, _descr;
|
|
TString _gc_prec_dare, _gc_prec_avere, _situazione, _descr_succ;
|
|
#ifdef CONT_SEP
|
|
TString _cont_sep;
|
|
#endif
|
|
char _tipo_conto, _tipoc_succ;
|
|
|
|
int _annoes, _bilancio, _tipo_stampa,_stampa_width,_gp,_cp,_i;
|
|
int _eof1, _eof2, _gruppo_dare, _gruppo_avere, _conto_dare, _conto_avere;
|
|
int _add_file_da, _add_file_a, _indbil_dare, _indbil_avere, _indbil;
|
|
int _eof3, _eof4, _eof5, _eof6, _verifica, _stampac, _stampav, _ordinamento, _print_full_code;
|
|
int _gruppo, _conto, _gruppo_succ, _conto_succ, _annoapp;
|
|
long _sottoconto_dare, _sottoconto_avere, _sottoconto, _sottoconto_succ;
|
|
|
|
real _saldo_dare, _saldo_avere, _gruppo_a, _gruppo_da, _conto_a;
|
|
real _conto_da, _tot_dare, _tot_avere, _mov_periodo_dare, _saldo_ini_dare;
|
|
real _mov_periodo_avere, _saldo_ini_avere, _prg_prec_dare, _prg_prec_avere;
|
|
real _saldo_ini_conto_dare, _saldo_ini_conto_avere, _saldoini_dare;
|
|
real _saldoini_avere, _mov_dare, _mov_avere, _saldofinale;
|
|
real _saldoini_dare_succ, _saldoini_avere_succ, _mov_dare_succ;
|
|
real _mov_avere_succ, _saldofinale_succ;
|
|
real _saldo_dare_tot, _saldo_avere_tot, _mov_dare_tot, _mov_avere_tot;
|
|
real _saldo_finale_tot, _saldo_ini_gruppo_dare, _saldo_ini_gruppo_avere;
|
|
real _gruppo_da_ordine, _gruppo_a_ordine;
|
|
real _prg_saldoini_dare, _prg_saldoini_avere, _prg_inidare_ord, _prg_iniavere_ord;
|
|
real _nuovo_tot_saldo_d, _nuovo_tot_saldo_a;
|
|
|
|
TDate _data, _dal, _al, _dataini, _ultima_data, _u_max;
|
|
bool _cambiato_conto_1, _cambiato_conto_2, _add_file_avere;
|
|
bool _add_file_dare, _prima_volta, _seconda_volta, _totali, _codici, _saldo;
|
|
bool _add_dare, _add_avere, _controlla, _salto_pagina, _flag, _stampato;
|
|
bool _sottoc_dare, _sottoc_avere, _salto_pagina1, _livello_conto;
|
|
bool _mov_ap,_quadratura;
|
|
bool _print_exercise, _hide_clifo;
|
|
TTipo_data _tipo_data;
|
|
int _stampa_mov_prov;
|
|
TBill _bill_from, _bill_to;
|
|
TArray _clienti, _fornitori;
|
|
|
|
#ifdef CONT_SEP
|
|
virtual const char * extra_modules() const { return "CG"; }
|
|
#endif
|
|
|
|
public:
|
|
bool menu (MENU_TAG m) { return TPrintapp::menu(m) ; }
|
|
virtual bool user_create() ;
|
|
virtual bool user_destroy();
|
|
bool set_print(int);
|
|
|
|
void next_c();
|
|
|
|
virtual bool preprocess_print(int,int);
|
|
virtual void preprocess_header();
|
|
virtual bool preprocess_page(int,int);
|
|
virtual print_action postprocess_page(int,int);
|
|
virtual void postclose_print();
|
|
virtual void set_page(int,int);
|
|
real compensazione(bool compensa, int indbil_conto, real& saldo);
|
|
bool bil_sez_contr();
|
|
bool bil_verifica();
|
|
bool ricerca_sottoc_clifo(int,int,bool,int,real&);
|
|
bool ricerca_cf(int,int,char,int,real&,real&,real&,real&,real&,real&,real&);
|
|
bool calcola(int,int,long);
|
|
void leggi_pcon(); // Inizializza i TArray C/F
|
|
void crea_sort_clifo();
|
|
void leggi_clifo(const TArray&);
|
|
void init_sort();
|
|
void leggi_sort();
|
|
void riempi_record(char,int,int,long,const char*,const real&,
|
|
const real&,const real&,const real&,const real&);
|
|
void get_dati_ditta();
|
|
void scrivi_record_conto(const real&,const real&,const real&,
|
|
const real&, const real&);
|
|
void scrivi_record_gruppo(const real&,const real&,const real&,
|
|
const real&, const real&);
|
|
int stampa_record_conto(int,int,const TString&,const real&,const real&,
|
|
const real&,const real&,const real&,const char);
|
|
int stampa_intestazione_ditta();
|
|
int cerca_indbil(int,int);
|
|
void scrivig_file_temp();
|
|
void scrivic_file_temp();
|
|
void scrivis_file_temp(int,int,long,const real&);
|
|
void leggi_files_dare (TIsamtempfile*);
|
|
void leggi_files_avere(TIsamtempfile*);
|
|
void leggi_file_tmp();
|
|
void stampa_riga_totali(int);
|
|
void stampa_prima_colonna(int,int,long,const char*,const real&);
|
|
void stampa_seconda_colonna(int,int,long,const char*,const real&);
|
|
void stampa_totali();
|
|
void stampa_totali_uno(const real&, const real&);
|
|
void controlla_conto(int,int);
|
|
TDate UltimaData(int,int,long,int);
|
|
void stampa_un_bilancio(const TMask& m);
|
|
|
|
TStampa_bilanci() {}
|
|
};
|
|
|
|
HIDDEN inline TStampa_bilanci& app() { return (TStampa_bilanci&)main_app(); }
|
|
|
|
bool TStampa_bilanci::mask_anno(TMask_field& f, KEY k)
|
|
{
|
|
TMask& m = f.mask();
|
|
|
|
if (k == K_ENTER)
|
|
{
|
|
const int tipo_stampa = m.get_int(F_STAMPA);
|
|
const int anno = m.get_int(F_ANNO);
|
|
|
|
if (tipo_stampa == 2 && anno == 0)
|
|
return f.error_box(TR("Indicare l'anno di esercizio"));
|
|
}
|
|
if (f.running_check(k))
|
|
{
|
|
const int tipo_stampa = m.get_int(F_STAMPA);
|
|
const int anno = m.get_int(F_ANNO);
|
|
const int bilancio = m.get_int(F_BILANCIO);
|
|
const TDate datalim = m.get_date(F_DATALIM);
|
|
TDate data;
|
|
|
|
if (esercizi().exist(datalim))
|
|
data = esercizio(datalim).fine();
|
|
m.enable_page(1, bilancio != 1);
|
|
m.show(F_DATAINI, bilancio == 2 && tipo_stampa == 1);
|
|
m.show(F_QUADRATURA, bilancio == 2 && tipo_stampa == 1 && data == datalim);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool TStampa_bilanci::mask_bilancio(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_SPACE)
|
|
{
|
|
TMask& m = f.mask();
|
|
const int anno = m.get_int(F_ANNO);
|
|
const int bilancio = m.get_int(F_BILANCIO);
|
|
const int tipo_stampa = m.get_int(F_STAMPA);
|
|
const TDate datalim = m.get_date(F_DATALIM);
|
|
TDate data;
|
|
|
|
m.enable_page(1, bilancio != 1);
|
|
if (esercizi().exist(datalim))
|
|
data = esercizio(datalim).fine();
|
|
m.show(F_DATAINI, bilancio == 2 && tipo_stampa == 1);
|
|
m.show(F_QUADRATURA, bilancio == 2 && tipo_stampa == 1 && data == datalim);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool TStampa_bilanci::mask_datalim (TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_ENTER)
|
|
{
|
|
TMask& m = f.mask();
|
|
const int anno = m.get_int(F_ANNO);
|
|
const int bilancio = m.get_int(F_BILANCIO);
|
|
const TDate data = m.get_date(F_DATALIM);
|
|
|
|
if (anno != 0)
|
|
{
|
|
if (data.ok())
|
|
{
|
|
if (!esercizi().exist(data) || (esercizio(data).codice() != anno))
|
|
return f.error_box (TR("La data limite deve appartenere all'esercizio indicato"));
|
|
}
|
|
// else
|
|
// m.field(F_DATALIM).set(esercizio(anno).fine());
|
|
app()._annoapp = anno;
|
|
}
|
|
else //anno == 0
|
|
{
|
|
if (!data.ok())
|
|
return f.error_box (TR("La data limite e' obbligatoria"));
|
|
if (!esercizi().exist(data))
|
|
return f.error_box (TR("La data limite deve appartenere ad un esercizio attivo della ditta"));
|
|
}
|
|
if (m.get_date(F_DATALIM) < m.get_date(F_DATAINI))
|
|
return f.error_box(TR("La data limite deve essere maggiore o uguale alla data iniziale"));
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool TStampa_bilanci::mask_dataini(TMask_field& f, KEY k)
|
|
{
|
|
TMask& m = f.mask();
|
|
const short id = f.dlg();
|
|
|
|
if (k == K_ENTER)
|
|
{
|
|
const int anno = m.get_int(F_ANNO);
|
|
int bilancio = m.get_int(F_BILANCIO);
|
|
TDate data = f.get_date();
|
|
|
|
if (anno != 0)
|
|
{
|
|
if (data.ok())
|
|
{
|
|
if (!esercizi().exist(data) || (esercizio(data).codice() != anno))
|
|
return f.error_box(TR("La data iniziale deve appartenere all'esercizio indicato"));
|
|
}
|
|
// else
|
|
// m.field(F_DATAINI).set(esercizio(anno).inizio());
|
|
app()._annoapp = anno;
|
|
}
|
|
else //anno == 0
|
|
{
|
|
const TDate datalim = m.get_date(F_DATALIM);
|
|
|
|
if (!data.ok() && datalim.ok() && esercizi().exist(datalim))
|
|
m.field(F_DATAINI).set(data = esercizio(datalim).inizio());
|
|
if (!data.ok())
|
|
return f.error_box(TR("La data limite e' obbligatoria"));
|
|
if (!esercizi().exist(data))
|
|
return f.error_box(TR("La data limite deve appartenere ad un esercizio attivo della ditta"));
|
|
app()._annoapp = esercizio(data).codice();
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool TStampa_bilanci::verifica_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_SPACE)
|
|
{
|
|
TMask& m = f.mask();
|
|
const int verifica = m.get_int(F_VERIFICA);
|
|
|
|
m.show(F_SITUAZIONE, verifica == 3);
|
|
m.show(F_STAMPAC, verifica == 3);
|
|
m.show(F_ORDINAMENTO, verifica == 3);
|
|
m.show(F_STAMPAV, verifica != 3);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void TStampa_bilanci::scrivig_file_temp()
|
|
{
|
|
TIsamtempfile* tmp = NULL;
|
|
TString nome_campo(12);
|
|
real valore;
|
|
|
|
if (!_totali)
|
|
{
|
|
if (_add_dare)
|
|
{
|
|
nome_campo = SLD_PDARE;
|
|
valore = _gruppo_da;
|
|
switch (_indbil)
|
|
{
|
|
case 1:
|
|
case 2:
|
|
tmp = _tmp_saldi_att;
|
|
break;
|
|
case 3:
|
|
case 4:
|
|
tmp = _tmp_saldi_costi;
|
|
break;
|
|
case 5:
|
|
tmp = _tmp_saldi_conti_uno;
|
|
valore = _gruppo_da_ordine;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
tmp->zero();
|
|
tmp->put(SLD_GRUPPO,_gp);
|
|
tmp->put(SLD_CONTO,0);
|
|
tmp->put(SLD_SOTTOCONTO,0L);
|
|
tmp->put(SLD_ANNOES,0); // W96SALDI del 07-06-96
|
|
tmp->put(SLD_FLSCA,false);
|
|
if (tmp->read() == NOERR)
|
|
{
|
|
tmp->put(SLD_CONTO,0);
|
|
tmp->put(SLD_SOTTOCONTO,0L);
|
|
tmp->put(nome_campo, valore);
|
|
tmp->rewrite();
|
|
}
|
|
else
|
|
{
|
|
tmp->put(SLD_GRUPPO,_gp);
|
|
tmp->put(SLD_CONTO,0);
|
|
tmp->put(SLD_SOTTOCONTO,0L);
|
|
tmp->put(SLD_ANNOES,0); // W96SALDI del 07-06-96
|
|
tmp->put(SLD_FLSCA,false);
|
|
tmp->put(nome_campo, valore);
|
|
tmp->write();
|
|
}
|
|
}
|
|
if (_add_avere)
|
|
{
|
|
nome_campo = SLD_PAVERE;
|
|
valore = _gruppo_a;
|
|
switch (_indbil)
|
|
{
|
|
case 1:
|
|
case 2:
|
|
tmp = _tmp_saldi_pass;
|
|
break;
|
|
case 3:
|
|
case 4:
|
|
tmp = _tmp_saldi_ricavi;
|
|
break;
|
|
case 5:
|
|
tmp = _tmp_saldi_conti_due;
|
|
valore = _gruppo_a_ordine;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
tmp->zero();
|
|
tmp->put(SLD_GRUPPO,_gp);
|
|
tmp->put(SLD_CONTO,0);
|
|
tmp->put(SLD_SOTTOCONTO,0L);
|
|
tmp->put(SLD_ANNOES,0); // W96SALDI del 07-06-96
|
|
tmp->put(SLD_FLSCA,false);
|
|
if (tmp->read() == NOERR)
|
|
{
|
|
tmp->put(SLD_CONTO,0);
|
|
tmp->put(SLD_SOTTOCONTO,0L);
|
|
tmp->put(nome_campo, valore);
|
|
tmp->rewrite();
|
|
}
|
|
else
|
|
{
|
|
tmp->put(SLD_GRUPPO,_gp);
|
|
tmp->put(SLD_CONTO,0);
|
|
tmp->put(SLD_SOTTOCONTO,0L);
|
|
tmp->put(SLD_ANNOES,0); // W96SALDI del 07-06-96
|
|
tmp->put(SLD_FLSCA,false);
|
|
tmp->put(nome_campo, valore);
|
|
tmp->write();
|
|
}
|
|
}
|
|
}
|
|
_add_dare = _add_avere = false;
|
|
}
|
|
|
|
void TStampa_bilanci::scrivic_file_temp()
|
|
{
|
|
TIsamtempfile* tmp = NULL;
|
|
TString nome_campo(12);
|
|
real valore;
|
|
|
|
if (_add_file_dare)
|
|
{
|
|
_add_dare = true;
|
|
nome_campo = SLD_PDARE;
|
|
valore = _conto_da;
|
|
if (_indbil == 1 || _indbil==2) tmp = _tmp_saldi_att; // da stampare a sx
|
|
else
|
|
if (_indbil==3 || _indbil==4) tmp = _tmp_saldi_costi; //da stampare a sx
|
|
else
|
|
if (_indbil==5) tmp = _tmp_saldi_conti_uno;
|
|
else return;
|
|
tmp->zero();
|
|
tmp->put(SLD_GRUPPO,_gp);
|
|
tmp->put(SLD_CONTO,_cp);
|
|
tmp->put(SLD_SOTTOCONTO,0L);
|
|
tmp->put(nome_campo, valore);
|
|
tmp->write();
|
|
}
|
|
if (_add_file_avere)
|
|
{
|
|
_add_avere = true;
|
|
nome_campo = SLD_PAVERE;
|
|
valore = _conto_a;
|
|
if (_indbil==2 || _indbil==1) tmp = _tmp_saldi_pass; //da stampare a dx
|
|
else
|
|
if (_indbil==4 || _indbil==3) tmp = _tmp_saldi_ricavi;//da stampare a dx
|
|
else
|
|
if (_indbil==5) tmp = _tmp_saldi_conti_due;
|
|
else return;
|
|
tmp->zero();
|
|
tmp->put(SLD_GRUPPO,_gp);
|
|
tmp->put(SLD_CONTO,_cp);
|
|
tmp->put(SLD_SOTTOCONTO,0L);
|
|
tmp->put(nome_campo, valore);
|
|
tmp->write();
|
|
}
|
|
}
|
|
|
|
void TStampa_bilanci::scrivis_file_temp(int g, int c, long s, const real& saldo)
|
|
{
|
|
TIsamtempfile* tmp = NULL;
|
|
TString16 nome_campo;
|
|
|
|
if (_indbil==1)
|
|
{
|
|
tmp = _tmp_saldi_att;
|
|
nome_campo = SLD_PDARE;
|
|
}
|
|
else
|
|
if (_indbil==2)
|
|
{
|
|
tmp = _tmp_saldi_pass;
|
|
nome_campo = SLD_PAVERE;
|
|
}
|
|
else
|
|
if (_indbil==3)
|
|
{
|
|
tmp = _tmp_saldi_costi;
|
|
nome_campo = SLD_PDARE;
|
|
}
|
|
else
|
|
if (_indbil==4)
|
|
{
|
|
tmp = _tmp_saldi_ricavi;
|
|
nome_campo = SLD_PAVERE;
|
|
}
|
|
else
|
|
if (_sottoc_dare)
|
|
{
|
|
tmp = _tmp_saldi_conti_uno;
|
|
nome_campo = SLD_PDARE;
|
|
}
|
|
else
|
|
if (_sottoc_avere)
|
|
{
|
|
tmp = _tmp_saldi_conti_due;
|
|
nome_campo = SLD_PAVERE;
|
|
}
|
|
CHECKD(tmp, "Null tmp file: indbil = ", _indbil);
|
|
tmp->zero();
|
|
tmp->put(SLD_GRUPPO,g);
|
|
tmp->put(SLD_CONTO,c);
|
|
tmp->put(SLD_SOTTOCONTO,s);
|
|
tmp->put(nome_campo, saldo);
|
|
tmp->write();
|
|
}
|
|
|
|
real TStampa_bilanci::compensazione(bool compensa, int indbil_conto, real& sld)
|
|
{
|
|
real saldo = sld;
|
|
|
|
if (!compensa)
|
|
{
|
|
switch (indbil_conto)
|
|
{
|
|
case 1:
|
|
if (saldo > ZERO)
|
|
_indbil = indbil_conto;
|
|
else
|
|
{
|
|
_indbil = 2;
|
|
saldo = -saldo;
|
|
}
|
|
break;
|
|
|
|
case 3:
|
|
if (saldo > ZERO)
|
|
_indbil = indbil_conto;
|
|
else
|
|
{
|
|
_indbil = 4;
|
|
saldo = -saldo;
|
|
}
|
|
break;
|
|
|
|
case 2:
|
|
if (saldo < ZERO)
|
|
{
|
|
_indbil = indbil_conto;
|
|
saldo = -saldo;
|
|
}
|
|
else
|
|
_indbil = 1;
|
|
break;
|
|
|
|
case 4:
|
|
if (saldo < ZERO)
|
|
{
|
|
_indbil = indbil_conto;
|
|
saldo = -saldo;
|
|
}
|
|
else
|
|
_indbil = 3;
|
|
break;
|
|
case 5:
|
|
default: break;
|
|
}
|
|
}
|
|
else //e' richiesta la compensazione
|
|
if ( indbil_conto==2 || indbil_conto==4)
|
|
saldo = -saldo;
|
|
|
|
return saldo;
|
|
}
|
|
|
|
void TStampa_bilanci::next_c()
|
|
{
|
|
TRecnotype recnum = _pcn->recno();
|
|
_pcn->next();
|
|
if (_pcn->eof())
|
|
{
|
|
scrivic_file_temp();
|
|
scrivig_file_temp();
|
|
}
|
|
_pcn->readat(recnum);
|
|
}
|
|
|
|
bool TStampa_bilanci::bil_sez_contr()
|
|
{
|
|
TSaldo sld;
|
|
int indbil_conto=0;
|
|
int g, c;
|
|
long s;
|
|
char tipo_conto = ' ';
|
|
real saldo;
|
|
bool compensa = false, dettaglio = false, cambiato = false;
|
|
bool esiste_conto = false, esiste_sc = false;
|
|
bool movimentato = false;
|
|
TProgress_monitor p(_pcn->eod(), TR("Elaborazione conti"));
|
|
|
|
CHECK(_tmp_saldi_att == NULL, "Non posso riaprire cg01");
|
|
_tmp_saldi_att = new TIsamtempfile(LF_SALDI, "cg01", true, true);
|
|
_tmp_saldi_pass = new TIsamtempfile(LF_SALDI, "cg02", true, true);
|
|
_tmp_saldi_costi = new TIsamtempfile(LF_SALDI, "cg03", true, true);
|
|
_tmp_saldi_ricavi = new TIsamtempfile(LF_SALDI, "cg04", true, true);
|
|
_tmp_saldi_conti_uno = new TIsamtempfile(LF_SALDI, "cg05", true, true);
|
|
_tmp_saldi_conti_due = new TIsamtempfile(LF_SALDI, "cg06", true, true);
|
|
_gp=-1;
|
|
_cp=-1;
|
|
_gruppo_a = ZERO;
|
|
_gruppo_da = ZERO;
|
|
_gruppo_da_ordine = ZERO;
|
|
_gruppo_a_ordine = ZERO;
|
|
_prg_saldoini_dare = ZERO;
|
|
_prg_saldoini_avere = ZERO;
|
|
_prg_inidare_ord = ZERO;
|
|
_prg_iniavere_ord = ZERO;
|
|
_conto_a = ZERO;
|
|
_conto_da = ZERO;
|
|
_add_dare = false;
|
|
_add_avere = false;
|
|
|
|
sld.set_annoes(_annoes);
|
|
for (_pcn->first(); !_pcn->eof() && p.addstatus(1L); _pcn->next())
|
|
{
|
|
g = _pcn->get_int (PCN_GRUPPO);
|
|
c = _pcn->get_int (PCN_CONTO);
|
|
s = _pcn->get_long(PCN_SOTTOCONTO);
|
|
|
|
if (c != _cp)
|
|
cambiato = true;
|
|
|
|
if ( (((_cp != -1) && (c != _cp)) || ((_gp != -1) && (g != _gp))) &&
|
|
esiste_sc )
|
|
{
|
|
scrivic_file_temp();
|
|
scrivig_file_temp();
|
|
_cp = c;
|
|
esiste_conto = true;
|
|
_conto_da = ZERO;
|
|
_conto_a = ZERO;
|
|
}
|
|
|
|
if ( ((_gp != -1) && (g != _gp)) && esiste_conto )
|
|
{
|
|
scrivig_file_temp();
|
|
esiste_conto = false;
|
|
_gp = g;
|
|
_gruppo_da = ZERO;
|
|
_gruppo_a = ZERO;
|
|
_gruppo_da_ordine = ZERO;
|
|
_gruppo_a_ordine = ZERO;
|
|
}
|
|
|
|
if (cambiato)
|
|
{
|
|
_add_file_avere = false;
|
|
_add_file_dare = false;
|
|
cambiato = false;
|
|
}
|
|
|
|
if ( (s == 0) && (c != 0) ) //si tratta di un conto
|
|
{
|
|
compensa = _pcn->get_bool(PCN_COMPENS);
|
|
dettaglio = !_pcn->get_bool(PCN_STSOTTBIL);
|
|
tipo_conto = _pcn->get_char(PCN_TMCF);
|
|
indbil_conto = _pcn->get_int(PCN_INDBIL);
|
|
|
|
if (indbil_conto <= 0) // Warning per Roberto!
|
|
{
|
|
yesnofatal_box(FR("Indicatore di bilancio %d nel conto %03d %03d"), indbil_conto,
|
|
_pcn->get_int (PCN_GRUPPO), _pcn->get_int (PCN_CONTO));
|
|
indbil_conto = 1;
|
|
}
|
|
|
|
if ( (tipo_conto == 'C') || (tipo_conto == 'F') )
|
|
{
|
|
saldo = ZERO;
|
|
esiste_sc = ricerca_sottoc_clifo(g, c, compensa, indbil_conto, saldo);
|
|
if (esiste_sc)
|
|
{
|
|
_gp = g;
|
|
_cp = c;
|
|
}
|
|
TRecnotype recnum = _pcn->recno();
|
|
_pcn->next();
|
|
if (_pcn->eof())
|
|
{
|
|
if (esiste_sc)
|
|
{
|
|
scrivic_file_temp();
|
|
scrivig_file_temp();
|
|
}
|
|
else
|
|
if (esiste_conto)
|
|
scrivig_file_temp();
|
|
}
|
|
_pcn->readat(recnum);
|
|
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if ( (c == 0) || (s == 0) ) //si tratta di un conto o di un gruppo
|
|
{
|
|
esiste_sc = false;
|
|
continue;
|
|
}
|
|
|
|
if (_tipo_stampa == 1) //bil. a sez. contrapposte per data limite
|
|
{
|
|
#ifdef CONT_SEP
|
|
movimentato = sld.saldo_cont_sep(_tipo_data,g, c, s, _annoes, _al, indbil_conto, _cont_sep, _stampa_mov_prov) ;
|
|
#else
|
|
movimentato = sld.data_limite_bilancio(_tipo_data, g, c, s, _dataini, _al, indbil_conto, _stampa_mov_prov);
|
|
#endif
|
|
}
|
|
else
|
|
{
|
|
if (_tipo_stampa == 2) //bil. a sez. contrapposte all'ultima immissione es. in corso
|
|
movimentato = sld.ultima_immissione_bilancio(_annoes,g,c,s,indbil_conto,_stampa_mov_prov);
|
|
}
|
|
|
|
if (!movimentato)
|
|
if (!sld.esiste_saldo() || !sld.significativo())
|
|
{
|
|
next_c();
|
|
continue;
|
|
}
|
|
|
|
saldo = sld.saldo();
|
|
|
|
real app = sld.saldoini();
|
|
bool flag = sld.flagprec();
|
|
|
|
if (_saldo) //se richiesto di NON stampare i conti con saldo a zero
|
|
if (saldo == ZERO)
|
|
{
|
|
//modifica del 06/07/1995
|
|
if (indbil_conto == 1 || indbil_conto == 2 || indbil_conto == 5)
|
|
{
|
|
if (flag)
|
|
{
|
|
if (app > ZERO)
|
|
{
|
|
if (indbil_conto == 5)
|
|
_prg_inidare_ord += app;
|
|
else _prg_saldoini_dare += app;
|
|
}
|
|
else
|
|
if (app < ZERO)
|
|
{
|
|
app = -app;
|
|
if (indbil_conto == 5)
|
|
_prg_iniavere_ord += app;
|
|
else _prg_saldoini_avere += app;
|
|
}
|
|
}
|
|
}
|
|
//fine
|
|
next_c();
|
|
continue;
|
|
}
|
|
|
|
esiste_sc = true;
|
|
_indbil = indbil_conto;
|
|
|
|
//i due flag seguenti servono solo per i conti d'ordine
|
|
_sottoc_dare = false;
|
|
_sottoc_avere = false;
|
|
|
|
if (saldo != ZERO)
|
|
saldo = compensazione(compensa, indbil_conto, saldo);
|
|
|
|
if (_indbil == 1 || _indbil == 2)
|
|
{
|
|
if (flag)
|
|
{
|
|
if (app > ZERO)
|
|
_prg_saldoini_dare += app;
|
|
else
|
|
if (app < ZERO)
|
|
{
|
|
app = -app;
|
|
_prg_saldoini_avere += app;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (_indbil == 5)
|
|
{
|
|
if (flag)
|
|
{
|
|
if (app > ZERO)
|
|
_prg_inidare_ord += app;
|
|
else
|
|
if (app < ZERO)
|
|
{
|
|
app = -app;
|
|
_prg_iniavere_ord += app;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( _indbil==1 || _indbil==3 )
|
|
{
|
|
_gruppo_da += saldo;
|
|
_conto_da += saldo;
|
|
_add_file_dare = true;
|
|
}
|
|
|
|
if ( _indbil==2 || _indbil==4 )
|
|
{
|
|
_gruppo_a += saldo;
|
|
_conto_a += saldo;
|
|
_add_file_avere = true;
|
|
}
|
|
|
|
if (_indbil==5)
|
|
{
|
|
if ( saldo >= ZERO || compensa )
|
|
{
|
|
_gruppo_da_ordine += saldo;
|
|
_conto_da += saldo;
|
|
_add_file_dare = true;
|
|
_sottoc_dare = true;
|
|
}
|
|
else
|
|
{
|
|
saldo = -saldo;
|
|
_gruppo_a_ordine += saldo;
|
|
_conto_a += saldo;
|
|
_add_file_avere = true;
|
|
_sottoc_avere = true;
|
|
}
|
|
scrivig_file_temp();
|
|
}
|
|
if ( (dettaglio) && ( (tipo_conto != 'C') && (tipo_conto != 'F') ) )
|
|
scrivis_file_temp(g, c, s, saldo);
|
|
|
|
_gp = g;
|
|
_cp = c;
|
|
// } // da_considerare
|
|
|
|
TRecnotype recnum = _pcn->recno();
|
|
_pcn->next();
|
|
if (_pcn->eof())
|
|
{
|
|
scrivic_file_temp();
|
|
scrivig_file_temp();
|
|
}
|
|
_pcn->readat(recnum);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
bool TStampa_bilanci::ricerca_sottoc_clifo(int g,int c, bool compensa, int indbil_conto,real& saldo)
|
|
{
|
|
TSaldo sld;
|
|
int aep=0;
|
|
long s, items;
|
|
bool esiste_sc = false;
|
|
bool movimentato = false;
|
|
|
|
if (_annoes)
|
|
{
|
|
TEsercizi_contabili ese;
|
|
aep = ese.pred(_annoes);
|
|
}
|
|
sld.set_annoes(_annoes);
|
|
_listacf = new TSaldi_list(g, c, _annoes, aep);
|
|
|
|
items = _listacf->items();
|
|
|
|
for (int i = 0; i < items; i++)
|
|
{
|
|
const TRectype* r = _listacf->saldi();
|
|
|
|
if (r == NULL) break;
|
|
|
|
s = r->get_long(SLD_SOTTOCONTO);
|
|
|
|
if (_tipo_stampa == 1) //bil. a sez. contrapposte per data limite
|
|
{
|
|
#ifdef CONT_SEP
|
|
movimentato = sld.saldo_cont_sep(_tipo_data, g, c, s, _annoes, _al, indbil_conto, _cont_sep, _stampa_mov_prov);
|
|
#else
|
|
movimentato = sld.data_limite_bilancio(_tipo_data ,g,c,s,_dataini,_al,indbil_conto,_stampa_mov_prov);
|
|
#endif
|
|
}
|
|
else
|
|
if (_tipo_stampa == 2) //bil. a sez. contrapposte all'ultima immissione es. in corso
|
|
movimentato = sld.ultima_immissione_bilancio(_annoes, g, c, s, indbil_conto, _stampa_mov_prov);
|
|
|
|
if (!movimentato)
|
|
if (!sld.esiste_saldo() || !sld.significativo())
|
|
continue;
|
|
|
|
saldo = sld.saldo();
|
|
real app = sld.saldoini();
|
|
bool flag = sld.flagprec();
|
|
|
|
if (_saldo) //se richiesto di non stampare i conti con saldo a zero
|
|
if (saldo == ZERO)
|
|
{
|
|
//modifica del 06/07/1995
|
|
if (indbil_conto == 1 || indbil_conto == 2 || indbil_conto == 5)
|
|
{
|
|
if (flag)
|
|
{
|
|
if (app > ZERO)
|
|
{
|
|
if (indbil_conto == 5)
|
|
_prg_inidare_ord += app;
|
|
else _prg_saldoini_dare += app;
|
|
}
|
|
else
|
|
if (app < ZERO)
|
|
{
|
|
app = -app;
|
|
if (indbil_conto == 5)
|
|
_prg_iniavere_ord += app;
|
|
else _prg_saldoini_avere += app;
|
|
}
|
|
}
|
|
}
|
|
//fine
|
|
continue;
|
|
}
|
|
|
|
esiste_sc = true;
|
|
_indbil = indbil_conto;
|
|
|
|
//i due flag seguenti servono solo per i conti d'ordine
|
|
_sottoc_dare = false;
|
|
_sottoc_avere = false;
|
|
|
|
if (saldo != ZERO)
|
|
saldo = compensazione(compensa, indbil_conto, saldo);
|
|
|
|
if (_indbil == 1 || _indbil == 2)
|
|
{
|
|
if (flag)
|
|
{
|
|
if (app > ZERO)
|
|
_prg_saldoini_dare += app;
|
|
else
|
|
if (app < ZERO)
|
|
{
|
|
app = -app;
|
|
_prg_saldoini_avere += app;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (_indbil == 5)
|
|
{
|
|
if (flag)
|
|
{
|
|
if (app > ZERO)
|
|
_prg_inidare_ord += app;
|
|
else
|
|
if (app < ZERO)
|
|
{
|
|
app = -app;
|
|
_prg_iniavere_ord += app;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( (_indbil==1) || (_indbil==3) )
|
|
{
|
|
_gruppo_da += saldo;
|
|
_conto_da += saldo;
|
|
_add_file_dare = true;
|
|
}
|
|
|
|
if ( (_indbil==2) || (_indbil==4) )
|
|
{
|
|
_gruppo_a += saldo;
|
|
_conto_a += saldo;
|
|
_add_file_avere = true;
|
|
}
|
|
|
|
if (_indbil==5)
|
|
{
|
|
if ( (saldo >= ZERO) || (compensa) ) // il sottoconto ha saldo in dare
|
|
{
|
|
_gruppo_da_ordine += saldo;
|
|
_conto_da += saldo;
|
|
_add_file_dare = true;
|
|
_sottoc_dare = true;
|
|
}
|
|
else //il sottoconto ha saldo in avere
|
|
{
|
|
saldo = -saldo;
|
|
_gruppo_a_ordine += saldo;
|
|
_conto_a += saldo;
|
|
_add_file_avere = true;
|
|
_sottoc_avere = true;
|
|
}
|
|
scrivig_file_temp();
|
|
}
|
|
}
|
|
delete _listacf;
|
|
return esiste_sc;
|
|
}
|
|
|
|
bool TStampa_bilanci::bil_verifica()
|
|
{
|
|
TSaldo sld;
|
|
int g, c, indbil_conto = 0;
|
|
long s;
|
|
char tipo_conto = ' ';
|
|
real saldo_finale, saldo_conto, saldo_gruppo, saldo_iniziale;
|
|
real mov_conto_dare, mov_conto_avere, prg_conto_dare, prg_conto_avere;
|
|
real mov_gruppo_dare, mov_gruppo_avere, prg_gruppo_dare, prg_gruppo_avere;
|
|
bool esiste_conto = false, esiste_sc = false, movimentato = false;
|
|
TProgress_monitor p(_pcn->eod(), "Elaborazione saldi");
|
|
|
|
CHECK(_tmp_saldi_att == NULL, "Non posso riaprire cg01");
|
|
_tmp_saldi_att = new TIsamtempfile(LF_SALDI, "cg01", true, true);
|
|
|
|
_gp=-1;
|
|
_cp=-1;
|
|
|
|
_saldo_ini_conto_dare = ZERO;
|
|
_saldo_ini_conto_avere = ZERO;
|
|
_saldo_ini_gruppo_dare = ZERO;
|
|
_saldo_ini_gruppo_avere = ZERO;
|
|
_nuovo_tot_saldo_d = ZERO;
|
|
_nuovo_tot_saldo_a = ZERO;
|
|
saldo_conto = ZERO;
|
|
mov_conto_dare = ZERO;
|
|
mov_conto_avere = ZERO;
|
|
prg_conto_dare = ZERO;
|
|
prg_conto_avere = ZERO;
|
|
saldo_gruppo = ZERO;
|
|
mov_gruppo_dare = ZERO;
|
|
mov_gruppo_avere = ZERO;
|
|
prg_gruppo_dare = ZERO;
|
|
prg_gruppo_avere = ZERO;
|
|
_u_max = 0l;
|
|
|
|
//controllo sui gr/co/sc selezionati
|
|
if (_bill_from.gruppo() > 0) //se ho un gruppo iniziale valido...
|
|
{
|
|
if (_bill_from.sottoconto() > 0L)
|
|
{
|
|
_pcn->zero();
|
|
_pcn->put(PCN_GRUPPO,_bill_from.gruppo()); //lo metto nel file del pianodeiconticorrente..
|
|
_pcn->put(PCN_CONTO,_bill_from.conto()); //un valore alla volta
|
|
if (_pcn->read(_isequal) == NOERR)
|
|
{
|
|
indbil_conto = _pcn->get_int(PCN_INDBIL);
|
|
tipo_conto = _pcn->get_char(PCN_TMCF);
|
|
}
|
|
}
|
|
|
|
_pcn->zero();
|
|
_pcn->put(PCN_GRUPPO,_bill_from.gruppo()); //lo metto nel file del pianodeiconticorrente..
|
|
_pcn->put(PCN_CONTO,_bill_from.conto()); //un valore alla volta
|
|
_pcn->put(PCN_SOTTOCONTO,_bill_from.sottoconto());
|
|
_pcn->read(_isgteq); //..e la scansione del file _pcn parte da questo
|
|
}
|
|
else
|
|
_pcn->first(); //..se non e' stato selezionato nessun gruppo parto dal primo
|
|
|
|
for ( ; !_pcn->eof() && p.addstatus(1L); _pcn->next())
|
|
{
|
|
g = _pcn->get_int (PCN_GRUPPO);
|
|
c = _pcn->get_int (PCN_CONTO);
|
|
s = _pcn->get_long(PCN_SOTTOCONTO);
|
|
|
|
if ( (((_cp != -1) && (c != _cp)) || ((_gp != -1) && (g != _gp))) && esiste_sc )
|
|
{
|
|
if (_verifica == 2)
|
|
if (!((_stampav == 2) && (saldo_conto == 0)))
|
|
{
|
|
//modifica del 21/11/1995
|
|
if (_tipo_stampa == 1 && _dal == _dataini)
|
|
{
|
|
_saldo_ini_gruppo_dare += _saldo_ini_conto_dare;
|
|
_saldo_ini_gruppo_avere += _saldo_ini_conto_avere;
|
|
}
|
|
else
|
|
//fine
|
|
{
|
|
const real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere;
|
|
|
|
if (app < ZERO)
|
|
_saldo_ini_gruppo_avere += app;
|
|
else
|
|
_saldo_ini_gruppo_dare += app;
|
|
}
|
|
mov_gruppo_dare += mov_conto_dare;
|
|
mov_gruppo_avere += mov_conto_avere;
|
|
prg_gruppo_dare += prg_conto_dare;
|
|
prg_gruppo_avere += prg_conto_avere;
|
|
saldo_gruppo += saldo_conto;
|
|
}
|
|
//scrivo il record del conto;
|
|
if ( (_verifica == 1)||( (_verifica == 2)&&
|
|
(!((_stampav == 2)&&(saldo_conto == 0))) ) )
|
|
{
|
|
scrivi_record_conto(prg_conto_dare,prg_conto_avere,mov_conto_dare,
|
|
mov_conto_avere,saldo_conto);
|
|
esiste_conto = true;
|
|
}
|
|
_cp = c;
|
|
_saldo_ini_conto_dare = ZERO;
|
|
_saldo_ini_conto_avere = ZERO;
|
|
saldo_conto = ZERO;
|
|
mov_conto_dare = ZERO;
|
|
mov_conto_avere = ZERO;
|
|
prg_conto_dare = ZERO;
|
|
prg_conto_avere = ZERO;
|
|
}
|
|
if (_verifica == 2)
|
|
if ( ((_gp != -1) && (g != _gp)) && (!esiste_conto) )
|
|
{
|
|
_gp = g;
|
|
_saldo_ini_gruppo_dare = ZERO;
|
|
_saldo_ini_gruppo_avere = ZERO;
|
|
saldo_gruppo = ZERO;
|
|
mov_gruppo_dare = ZERO;
|
|
mov_gruppo_avere = ZERO;
|
|
prg_gruppo_dare = ZERO;
|
|
prg_gruppo_avere = ZERO;
|
|
}
|
|
if (_verifica == 2)
|
|
if ( ((_gp != -1) && (g != _gp)) && esiste_conto )
|
|
{
|
|
//scrivo il record del gruppo
|
|
scrivi_record_gruppo(prg_gruppo_dare,prg_gruppo_avere,mov_gruppo_dare,
|
|
mov_gruppo_avere,saldo_gruppo);
|
|
_gp = g;
|
|
esiste_conto = false;
|
|
_saldo_ini_gruppo_dare = ZERO;
|
|
_saldo_ini_gruppo_avere = ZERO;
|
|
saldo_gruppo = ZERO;
|
|
mov_gruppo_dare = ZERO;
|
|
mov_gruppo_avere = ZERO;
|
|
prg_gruppo_dare = ZERO;
|
|
prg_gruppo_avere = ZERO;
|
|
}
|
|
if ( (s == 0) && (c != 0) ) //si tratta di un conto
|
|
{
|
|
tipo_conto = _pcn->get_char(PCN_TMCF);
|
|
indbil_conto = _pcn->get_int(PCN_INDBIL);
|
|
if ( (tipo_conto == 'C') || (tipo_conto == 'F') )
|
|
{
|
|
esiste_sc = ricerca_cf(g,c,tipo_conto,indbil_conto,saldo_finale,saldo_iniziale,
|
|
mov_conto_dare,mov_conto_avere,prg_conto_dare,prg_conto_avere,
|
|
saldo_conto);
|
|
if (_verifica == 2 && _stampav == 2 && saldo_conto.is_zero())
|
|
continue;
|
|
if (esiste_sc)
|
|
{
|
|
_gp = g;
|
|
_cp = c;
|
|
const TRecnotype recnum = _pcn->recno();
|
|
_pcn->next();
|
|
if (_pcn->eof())
|
|
{
|
|
if (_verifica == 2)
|
|
{
|
|
//modifica del 21/11/1995
|
|
if (_tipo_stampa == 1 && _dal == _dataini)
|
|
{
|
|
_saldo_ini_gruppo_dare += _saldo_ini_conto_dare;
|
|
_saldo_ini_gruppo_avere += _saldo_ini_conto_avere;
|
|
}
|
|
else
|
|
//fine
|
|
{
|
|
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere;
|
|
|
|
if (app < ZERO)
|
|
_saldo_ini_gruppo_avere += app;
|
|
else
|
|
_saldo_ini_gruppo_dare += app;
|
|
}
|
|
mov_gruppo_dare += mov_conto_dare;
|
|
mov_gruppo_avere += mov_conto_avere;
|
|
prg_gruppo_dare += prg_conto_dare;
|
|
prg_gruppo_avere += prg_conto_avere;
|
|
saldo_gruppo += saldo_conto;
|
|
|
|
scrivi_record_gruppo(prg_gruppo_dare,prg_gruppo_avere,
|
|
mov_gruppo_dare,mov_gruppo_avere,saldo_gruppo);
|
|
}
|
|
scrivi_record_conto(prg_conto_dare,prg_conto_avere,mov_conto_dare,
|
|
mov_conto_avere,saldo_conto);
|
|
}
|
|
_pcn->readat(recnum);
|
|
}
|
|
continue;
|
|
}
|
|
}
|
|
|
|
//controlla se e' arrivato all'ultimo gruppo/conto/sottoconto selezionato
|
|
const TBill curr_bill(g,c,s);
|
|
if (curr_bill > _bill_to)
|
|
break;
|
|
|
|
if ( (c == 0) || (s == 0) )
|
|
{
|
|
esiste_sc = false;
|
|
continue;
|
|
}
|
|
|
|
saldo_finale = saldo_iniziale = ZERO; //saldi relativi a ciascun sottoconto
|
|
_indbil = indbil_conto;
|
|
if (_tipo_stampa == 1) //bil. di verifica per data limite
|
|
{
|
|
|
|
_mov_ap = false;
|
|
//modifica del 19/06/95
|
|
movimentato = calcola(g,c,s);
|
|
if (_stampa_mov_prov & 0x1)
|
|
{
|
|
if (movimentato)
|
|
{
|
|
//modifica del 21/11/95
|
|
if (_mov_ap)
|
|
saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere;
|
|
else //discorso flag "movimentato" (video)
|
|
{
|
|
sld.ultima_immissione_verifica(_annoes, g, c, s, _indbil, _stampa_mov_prov);
|
|
saldo_iniziale = sld.saldoini();
|
|
if (saldo_iniziale > ZERO)
|
|
_saldo_ini_dare = saldo_iniziale;
|
|
else
|
|
_saldo_ini_avere = -saldo_iniziale;
|
|
}
|
|
}
|
|
else // !movimentato -> _mov_ap e' di sicuro false
|
|
{
|
|
if (_annoes != 0 && (indbil_conto == 1 || indbil_conto == 2 || indbil_conto == 5))
|
|
{
|
|
sld.ultima_immissione_verifica(g, c, s, _indbil, _stampa_mov_prov);
|
|
saldo_iniziale = sld.saldoini();
|
|
if (saldo_iniziale > ZERO)
|
|
_saldo_ini_dare = saldo_iniziale;
|
|
else
|
|
_saldo_ini_avere = -saldo_iniziale;
|
|
if (_stampav == 1 && sld.significativo())
|
|
movimentato = true;
|
|
}
|
|
}
|
|
}
|
|
if (movimentato || _stampav != 1)
|
|
{
|
|
_nuovo_tot_saldo_d += _mov_periodo_dare;
|
|
_nuovo_tot_saldo_a += _mov_periodo_avere;
|
|
_nuovo_tot_saldo_d += _saldo_ini_dare;
|
|
_nuovo_tot_saldo_a += _saldo_ini_avere;
|
|
|
|
if (_dal == _dataini)
|
|
saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere;
|
|
else
|
|
if (_dal > _dataini)
|
|
{
|
|
if (saldo_iniziale > 0)
|
|
_prg_prec_dare += saldo_iniziale;
|
|
else
|
|
_prg_prec_avere -= saldo_iniziale;
|
|
saldo_finale = _prg_prec_dare-_prg_prec_avere+_mov_periodo_dare-_mov_periodo_avere;
|
|
}
|
|
}
|
|
//se saldo_finale < 0 verra' stampato con una A, se no con una D
|
|
}
|
|
else
|
|
{
|
|
movimentato = sld.ultima_immissione_verifica(_annoes,g,c,s,indbil_conto,_stampa_mov_prov);
|
|
|
|
if (_stampa_mov_prov & 0x1)
|
|
{
|
|
if (movimentato)
|
|
saldo_iniziale = sld.saldoini();
|
|
if (!movimentato)
|
|
{
|
|
if (indbil_conto == 1 || indbil_conto == 2 || indbil_conto == 5)
|
|
{
|
|
saldo_iniziale = sld.saldofin_esprec(_annoes,g,c,s,false,_stampa_mov_prov);
|
|
if (_stampav == 1 && sld.significativo())
|
|
movimentato = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (movimentato || _stampav != 1)
|
|
{
|
|
_mov_periodo_dare = sld.prgdare();
|
|
_mov_periodo_avere = sld.prgavere();
|
|
_prg_prec_dare = ZERO;
|
|
_prg_prec_avere = ZERO;
|
|
|
|
if (sld.sezsf() == 'A')
|
|
_mov_periodo_avere -= sld.saldofin();
|
|
else
|
|
_mov_periodo_dare += sld.saldofin();
|
|
|
|
saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere;
|
|
}
|
|
}
|
|
|
|
if ((movimentato || _stampav != 1) && !(saldo_finale.is_zero() && _stampav == 2))
|
|
{
|
|
esiste_sc = true;
|
|
esiste_conto = true;
|
|
|
|
if (_tipo_stampa == 2)
|
|
{
|
|
_nuovo_tot_saldo_d += _mov_periodo_dare;
|
|
_nuovo_tot_saldo_a += _mov_periodo_avere;
|
|
|
|
real nuovo = sld.saldoinisusaldi();
|
|
|
|
if (nuovo > ZERO)
|
|
_nuovo_tot_saldo_d += nuovo;
|
|
else
|
|
{
|
|
nuovo = -nuovo;
|
|
_nuovo_tot_saldo_a += nuovo;
|
|
}
|
|
}
|
|
//modifica del 21/11/1995
|
|
if (_tipo_stampa == 1 && _dal == _dataini)
|
|
{
|
|
_saldo_ini_conto_dare += _saldo_ini_dare;
|
|
_saldo_ini_conto_avere += _saldo_ini_avere;
|
|
}
|
|
else //_tipo_stampa1 == 1 || _tipo_stampa1 == 2
|
|
{
|
|
if (saldo_iniziale < ZERO)
|
|
_saldo_ini_conto_avere += saldo_iniziale;
|
|
else
|
|
_saldo_ini_conto_dare += saldo_iniziale;
|
|
}
|
|
|
|
mov_conto_dare += _mov_periodo_dare;
|
|
mov_conto_avere += _mov_periodo_avere;
|
|
prg_conto_dare += _prg_prec_dare;
|
|
prg_conto_avere += _prg_prec_avere;
|
|
saldo_conto += saldo_finale; // somma pitagorica
|
|
|
|
//scrivo il record relat. al sottoconto se non e' richiesto saldi di mastro
|
|
if (_verifica != 2)
|
|
{
|
|
_tmp_saldi_att->zero();
|
|
_tmp_saldi_att->put(SLD_GRUPPO,g);
|
|
_tmp_saldi_att->put(SLD_CONTO,c);
|
|
_tmp_saldi_att->put(SLD_SOTTOCONTO,s);
|
|
_tmp_saldi_att->put(SLD_FLAGSALINI,tipo_conto);
|
|
|
|
if ((_dal == _dataini) || (_tipo_stampa != 1))
|
|
{
|
|
//modifica del 21/11/1995
|
|
if (_dal == _dataini && _tipo_stampa == 1)
|
|
{
|
|
_tmp_saldi_att->put(SLD_PDAREPRO,_saldo_ini_dare); // W96SALDI del 05-06-96
|
|
_tmp_saldi_att->put(SLD_PAVEREPRO,_saldo_ini_avere);
|
|
}
|
|
else
|
|
{
|
|
if (saldo_iniziale > ZERO) //va stampato in Dare
|
|
_tmp_saldi_att->put(SLD_PDAREPRO,saldo_iniziale); // W96SALDI del 05-06-96
|
|
else
|
|
if (saldo_iniziale < ZERO)
|
|
{
|
|
saldo_iniziale = -saldo_iniziale;
|
|
_tmp_saldi_att->put(SLD_PAVEREPRO,saldo_iniziale); // W96SALDI del 05-06-96
|
|
}
|
|
}
|
|
}
|
|
else
|
|
if (_dal > _dataini)
|
|
{
|
|
_tmp_saldi_att->put(SLD_PDAREPRO,_prg_prec_dare); // W96SALDI del 05-06-96
|
|
_tmp_saldi_att->put(SLD_PAVEREPRO,_prg_prec_avere);
|
|
}
|
|
_tmp_saldi_att->put(SLD_PDARE,_mov_periodo_dare);
|
|
_tmp_saldi_att->put(SLD_PAVERE,_mov_periodo_avere);
|
|
_tmp_saldi_att->put(SLD_SALDO,saldo_finale);
|
|
_tmp_saldi_att->put(SLD_DATAULMOV,_u_max);
|
|
_tmp_saldi_att->write();
|
|
}
|
|
_gp = g;
|
|
_cp = c;
|
|
}
|
|
|
|
TRecnotype recnum = _pcn->recno();
|
|
_pcn->next();
|
|
if (_pcn->eof())
|
|
{
|
|
if ( (_verifica == 2) && esiste_conto )
|
|
{
|
|
//modifica del 21/11/1995
|
|
if (_tipo_stampa == 1 && _dal == _dataini)
|
|
{
|
|
_saldo_ini_gruppo_dare += _saldo_ini_conto_dare;
|
|
_saldo_ini_gruppo_avere += _saldo_ini_conto_avere;
|
|
}
|
|
else
|
|
//fine
|
|
{
|
|
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere;
|
|
|
|
if (app < ZERO)
|
|
_saldo_ini_gruppo_avere += app;
|
|
else
|
|
_saldo_ini_gruppo_dare += app;
|
|
}
|
|
mov_gruppo_dare += mov_conto_dare;
|
|
mov_gruppo_avere += mov_conto_avere;
|
|
prg_gruppo_dare += prg_conto_dare;
|
|
prg_gruppo_avere += prg_conto_avere;
|
|
saldo_gruppo += saldo_conto;
|
|
|
|
scrivi_record_gruppo(prg_gruppo_dare,prg_gruppo_avere,
|
|
mov_gruppo_dare,mov_gruppo_avere,saldo_gruppo);
|
|
}
|
|
if (esiste_sc)
|
|
if ( (_verifica == 1)||( (_verifica == 2)&&
|
|
(!((_stampav == 2)&&(saldo_conto == 0))) ) )
|
|
scrivi_record_conto(prg_conto_dare,prg_conto_avere,mov_conto_dare,
|
|
mov_conto_avere,saldo_conto);
|
|
}
|
|
_pcn->readat(recnum);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
// bilancio di verifica per data limite
|
|
// Calcola totali delle righe relative al g,c,s
|
|
bool TStampa_bilanci::calcola(int g, int c, long s)
|
|
{
|
|
int annoe;
|
|
bool conto_mov = false;
|
|
TDecoder causali(LF_CAUSALI, CAU_MOVAP);
|
|
|
|
|
|
_mov_periodo_dare = ZERO;
|
|
_mov_periodo_avere = ZERO;
|
|
_prg_prec_dare = ZERO;
|
|
_prg_prec_avere = ZERO;
|
|
_saldo_ini_dare = ZERO;
|
|
_saldo_ini_avere = ZERO;
|
|
_u_max = 0l;
|
|
|
|
// TDate data_start = _dataini;
|
|
// Calcolo progressivi precedenti:
|
|
// e non è indicato l'anno esercizio, prende il primo giorno dell'anno indicato da _datada
|
|
if (_annoes == 0)
|
|
{
|
|
_dataini = _dal;
|
|
_dataini.set_day(1);
|
|
_dataini.set_month(1);
|
|
}
|
|
else
|
|
_dataini = esercizi().esercizio(_annoes).inizio();
|
|
|
|
TCursor cur(new TRelation(LF_RMOV), "", 2);
|
|
TRectype& rmov = cur.file().curr();
|
|
|
|
rmov.zero();
|
|
rmov.put(RMV_GRUPPO, g);
|
|
if (c != 0)
|
|
{
|
|
rmov.put(RMV_CONTO, c);
|
|
if (s != 0)
|
|
rmov.put(RMV_SOTTOCONTO, s);
|
|
}
|
|
cur.setregion(rmov, rmov);
|
|
|
|
const long items = cur.items();
|
|
|
|
cur.freeze();
|
|
for (cur = 0L; cur.pos() < items; ++cur)
|
|
{
|
|
annoe = rmov.get_int(RMV_ANNOES);
|
|
const long numreg = rmov.get_long(RMV_NUMREG);
|
|
const TRectype& mov = cache().get(LF_MOV, numreg);
|
|
const TDate data = get_date_mov(mov, _tipo_data);
|
|
const TString4 provvis = mov.get(MOV_PROVVIS);
|
|
const TString& codcaus = mov.get(MOV_CODCAUS);
|
|
const TCausale & caus = cached_causale(codcaus);
|
|
const char causap = causali.decode(codcaus)[0];
|
|
|
|
if (_quadratura || !caus.chiusura())
|
|
{
|
|
const char sezione = rmov.get_char(RMV_SEZIONE);
|
|
const real importo = rmov.get_real(RMV_IMPORTO);
|
|
|
|
if (importo != ZERO)
|
|
{
|
|
//calcolo i movimenti del periodo
|
|
if (check_mov(_stampa_mov_prov, provvis))
|
|
{
|
|
if (data.ok() && esercizi().esercizio(data).codice() == _annoes)
|
|
_u_max = fnc_max(_u_max, data);
|
|
if ((data >= _dataini) && (data < _dal)) //calcolo i progressivi precedenti
|
|
{
|
|
conto_mov = true;
|
|
_mov_ap |= caus.apertura();
|
|
if (sezione == 'D')
|
|
_prg_prec_dare += importo;
|
|
else
|
|
_prg_prec_avere += importo;
|
|
}
|
|
else
|
|
if (data >= _dal && data <= _al && !caus.apertura())
|
|
{
|
|
conto_mov = true;
|
|
if (sezione == 'D')
|
|
_mov_periodo_dare += importo;
|
|
else
|
|
_mov_periodo_avere += importo;
|
|
}
|
|
}
|
|
//il saldo inizio es. e' dato dall'importo dare - importo avere di quei movimenti che hanno causale == apertura e data reg >= data inizio es. e <= data limite sup.
|
|
if (_dal == _dataini) //calcolo il saldo iniziale
|
|
{
|
|
if ((_stampa_mov_prov & 0x1) && caus.apertura() &&
|
|
(data >= _dataini) && (data <= _al))
|
|
{
|
|
_mov_ap = true;
|
|
conto_mov = true;
|
|
_u_max = fnc_max(_u_max, data);
|
|
if (sezione == 'D')
|
|
_saldo_ini_dare += importo;
|
|
else
|
|
_saldo_ini_avere += importo;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return conto_mov;
|
|
}
|
|
|
|
bool TStampa_bilanci::ricerca_cf(int g,int c,char tipocf,int ib, real& saldo_finale,real& saldo_iniziale,
|
|
real& mov_conto_dare,real& mov_conto_avere,real& prg_conto_dare,real& prg_conto_avere,real& saldo_conto)
|
|
{
|
|
TSaldo sld;
|
|
bool esiste_sc = false;
|
|
const int anno = _tipo_stampa == 1 ? _annoapp : _annoes;
|
|
|
|
_lista = new TSaldi_list(g, c, anno);
|
|
const TRecnotype items = _lista->items();
|
|
|
|
for (TRecnotype i = 0; i < items; i++)
|
|
{
|
|
const TRectype* r = _lista->saldi();
|
|
if (r == NULL) break;
|
|
|
|
const long s = r->get_long(SLD_SOTTOCONTO);
|
|
|
|
saldo_finale = saldo_iniziale = ZERO; //saldi relativi a ciascun sottoconto
|
|
|
|
if (_tipo_stampa == 1) //bil. di verifica per data limite
|
|
{
|
|
|
|
_mov_ap = false;
|
|
bool movimentato = calcola(g,c,s);
|
|
|
|
if (_stampa_mov_prov & 0x1)
|
|
{
|
|
if (movimentato)
|
|
{
|
|
if (_mov_ap)
|
|
saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere;
|
|
else
|
|
{
|
|
sld.ultima_immissione_verifica(_annoes, g, c, s, _indbil, _stampa_mov_prov);
|
|
saldo_iniziale = sld.saldoini();
|
|
if (saldo_iniziale > ZERO)
|
|
_saldo_ini_dare = saldo_iniziale;
|
|
else
|
|
_saldo_ini_avere = -saldo_iniziale;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (_annoes != 0 && (ib == 1 || ib == 2 || ib == 5))
|
|
{
|
|
sld.ultima_immissione_verifica(g, c, s, _indbil, _stampa_mov_prov);
|
|
saldo_iniziale = sld.saldoini();
|
|
if (saldo_iniziale > ZERO)
|
|
_saldo_ini_dare = saldo_iniziale;
|
|
else
|
|
_saldo_ini_avere = -saldo_iniziale;
|
|
movimentato = sld.significativo();
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!movimentato)
|
|
continue;
|
|
//fine modifica
|
|
|
|
_nuovo_tot_saldo_d += _mov_periodo_dare;
|
|
_nuovo_tot_saldo_a += _mov_periodo_avere;
|
|
//modifica del 21/11/1995
|
|
_nuovo_tot_saldo_d += _saldo_ini_dare;
|
|
_nuovo_tot_saldo_a += _saldo_ini_avere;
|
|
//fine
|
|
|
|
if (_dal == _dataini)
|
|
saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere;
|
|
else
|
|
if (_dal > _dataini)
|
|
{
|
|
if (saldo_iniziale > 0)
|
|
_prg_prec_dare += saldo_iniziale;
|
|
else
|
|
_prg_prec_avere -= saldo_iniziale;
|
|
saldo_finale = _prg_prec_dare-_prg_prec_avere+_mov_periodo_dare-
|
|
_mov_periodo_avere;
|
|
}
|
|
if (saldo_finale == ZERO)
|
|
if (_stampav == 2)
|
|
continue;
|
|
|
|
//se saldo_finale < 0 verra' stampato con una A, se no con una D
|
|
}
|
|
else // Bilancio di verifica all'ultima immissione
|
|
{
|
|
//Attenzione! Nel caso di "tutti i conti" devono scendere solo i cli/for movimentati!!!
|
|
|
|
//modifica del 31/03/1995
|
|
bool movimentato = sld.ultima_immissione_verifica(_annoes,g,c,s,ib,_stampa_mov_prov);
|
|
|
|
if (_stampa_mov_prov & 0x1)
|
|
{
|
|
saldo_iniziale = sld.saldoini();
|
|
if (!movimentato)
|
|
{
|
|
//vado sui saldi con l'anno precedente e calcolo saldo_finale es.prec
|
|
//se esiste tale record e almeno un valore e' significativo (indipendentemente dal valore
|
|
//del saldo iniziale calcolato, allora metto a true il flag movimentato
|
|
//solo se e' un conto patrimoniale
|
|
if (ib == 1 || ib == 2 || ib == 5)
|
|
{
|
|
saldo_iniziale = sld.saldofin_esprec(_annoes,g,c,s,false,_stampa_mov_prov);
|
|
movimentato = sld.significativo();
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!movimentato)
|
|
continue;
|
|
//fine modifica 31/03/1995
|
|
|
|
_mov_periodo_dare = sld.prgdare();
|
|
_mov_periodo_avere = sld.prgavere();
|
|
_prg_prec_dare = ZERO;
|
|
_prg_prec_avere = ZERO;
|
|
|
|
if (sld.sezsf() == 'A')
|
|
_mov_periodo_avere -= sld.saldofin();
|
|
else
|
|
_mov_periodo_dare += sld.saldofin();
|
|
|
|
saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere;
|
|
if (saldo_finale.is_zero() && _stampav == 2)
|
|
continue;
|
|
|
|
_nuovo_tot_saldo_d += _mov_periodo_dare;
|
|
_nuovo_tot_saldo_a += _mov_periodo_avere;
|
|
|
|
real nuovo = sld.saldoinisusaldi();
|
|
|
|
if (nuovo > ZERO)
|
|
_nuovo_tot_saldo_d += nuovo;
|
|
else
|
|
{
|
|
nuovo = -nuovo;
|
|
_nuovo_tot_saldo_a += nuovo;
|
|
}
|
|
}
|
|
|
|
esiste_sc = true;
|
|
|
|
//modifica del 21/11/1995
|
|
if (_tipo_stampa == 1 && _dal == _dataini)
|
|
{
|
|
_saldo_ini_conto_dare += _saldo_ini_dare;
|
|
_saldo_ini_conto_avere += _saldo_ini_avere;
|
|
}
|
|
else
|
|
//fine
|
|
{
|
|
if (saldo_iniziale < ZERO)
|
|
_saldo_ini_conto_avere += saldo_iniziale;
|
|
else
|
|
_saldo_ini_conto_dare += saldo_iniziale;
|
|
}
|
|
|
|
mov_conto_dare += _mov_periodo_dare;
|
|
mov_conto_avere += _mov_periodo_avere;
|
|
prg_conto_dare += _prg_prec_dare;
|
|
prg_conto_avere += _prg_prec_avere;
|
|
saldo_conto += saldo_finale; // somma algebrica!!!
|
|
|
|
//scrivo il record relat. al sottoconto se non e' richiesto saldi di mastro
|
|
if (_verifica != 2 && !_hide_clifo)
|
|
{
|
|
_tmp_saldi_att->zero();
|
|
_tmp_saldi_att->put(SLD_GRUPPO,g);
|
|
_tmp_saldi_att->put(SLD_CONTO,c);
|
|
_tmp_saldi_att->put(SLD_SOTTOCONTO,s);
|
|
_tmp_saldi_att->put(SLD_FLAGSALINI,tipocf);
|
|
if ( (_dal == _dataini) || (_tipo_stampa != 1) )
|
|
{
|
|
//modifica del 21/11/1995
|
|
if (_tipo_stampa == 1 && _dal == _dataini)
|
|
{
|
|
_tmp_saldi_att->put(SLD_PDAREPRO,_saldo_ini_dare); // W96SALDI del 05-06-96
|
|
_tmp_saldi_att->put(SLD_PAVEREPRO,_saldo_ini_avere);
|
|
}
|
|
else
|
|
{
|
|
if (saldo_iniziale > ZERO) //va stampato in Dare
|
|
_tmp_saldi_att->put(SLD_PDAREPRO,saldo_iniziale); // W96SALDI del 05-06-96
|
|
else
|
|
if (saldo_iniziale < ZERO)
|
|
{
|
|
saldo_iniziale = -saldo_iniziale;
|
|
_tmp_saldi_att->put(SLD_PAVEREPRO,saldo_iniziale); // W96SALDI del 05-06-96
|
|
}
|
|
}
|
|
}
|
|
else
|
|
if (_dal > _dataini)
|
|
{
|
|
_tmp_saldi_att->put(SLD_PDAREPRO,_prg_prec_dare); // W96SALDI del 05-06-96
|
|
_tmp_saldi_att->put(SLD_PAVEREPRO,_prg_prec_avere);
|
|
}
|
|
_tmp_saldi_att->put(SLD_PDARE,_mov_periodo_dare);
|
|
_tmp_saldi_att->put(SLD_PAVERE,_mov_periodo_avere);
|
|
_tmp_saldi_att->put(SLD_SALDO,saldo_finale);
|
|
_tmp_saldi_att->put(SLD_DATAULMOV, _u_max);
|
|
|
|
_tmp_saldi_att->write();
|
|
}
|
|
}
|
|
delete _lista;
|
|
return esiste_sc;
|
|
}
|
|
|
|
void TStampa_bilanci::scrivi_record_gruppo(const real& prg_da, const real& prg_a,
|
|
const real& mov_da, const real& mov_a,
|
|
const real& s)
|
|
{
|
|
_tmp_saldi_att->zero();
|
|
_tmp_saldi_att->put(SLD_GRUPPO,_gp);
|
|
_tmp_saldi_att->put(SLD_CONTO,0);
|
|
_tmp_saldi_att->put(SLD_SOTTOCONTO,0L);
|
|
if ( (_dal == _dataini) || (_tipo_stampa != 1) )
|
|
{
|
|
//modifica del 21/11/1995
|
|
if (_dal == _dataini && _tipo_stampa == 1)
|
|
{
|
|
_tmp_saldi_att->put(SLD_PDAREPRO,_saldo_ini_gruppo_dare); // W96SALDI del 05-06-96
|
|
_tmp_saldi_att->put(SLD_PAVEREPRO,_saldo_ini_gruppo_avere);
|
|
}
|
|
else
|
|
{
|
|
real app = _saldo_ini_gruppo_dare + _saldo_ini_gruppo_avere;
|
|
|
|
if (app > ZERO) //va stampato in Dare
|
|
_tmp_saldi_att->put(SLD_PDAREPRO,app); // W96SALDI del 05-06-96
|
|
else
|
|
if (app < ZERO)
|
|
{
|
|
app = -app;
|
|
_tmp_saldi_att->put(SLD_PAVEREPRO,app); // W96SALDI del 05-06-96
|
|
}
|
|
}
|
|
}
|
|
else
|
|
if (_dal > _dataini)
|
|
{
|
|
_tmp_saldi_att->put(SLD_PDAREPRO,prg_da); // W96SALDI del 05-06-96
|
|
_tmp_saldi_att->put(SLD_PAVEREPRO,prg_a);
|
|
}
|
|
_tmp_saldi_att->put(SLD_PDARE,mov_da);
|
|
_tmp_saldi_att->put(SLD_PAVERE,mov_a);
|
|
_tmp_saldi_att->put(SLD_SALDO,s);
|
|
_tmp_saldi_att->write();
|
|
}
|
|
|
|
void TStampa_bilanci::scrivi_record_conto(const real& prg_da, const real& prg_a,
|
|
const real& mov_da,const real& mov_a, const real& s)
|
|
{
|
|
_tmp_saldi_att->zero();
|
|
_tmp_saldi_att->put(SLD_GRUPPO,_gp);
|
|
_tmp_saldi_att->put(SLD_CONTO,_cp);
|
|
_tmp_saldi_att->put(SLD_SOTTOCONTO,0L);
|
|
if ( (_dal == _dataini) || (_tipo_stampa != 1) )
|
|
{
|
|
//modifica del 21/11/1995
|
|
if (_dal == _dataini && _tipo_stampa == 1)
|
|
{
|
|
_tmp_saldi_att->put(SLD_PDAREPRO,_saldo_ini_conto_dare); // W96SALDI del 05-06-96
|
|
_tmp_saldi_att->put(SLD_PAVEREPRO,_saldo_ini_conto_avere);
|
|
}
|
|
else
|
|
{
|
|
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere;
|
|
|
|
if (app > ZERO) //va stampato in Dare
|
|
_tmp_saldi_att->put(SLD_PDAREPRO,app); // W96SALDI del 05-06-96
|
|
else
|
|
if (app < ZERO)
|
|
{
|
|
app = -app;
|
|
_tmp_saldi_att->put(SLD_PAVEREPRO,app); // W96SALDI del 05-06-96
|
|
}
|
|
}
|
|
}
|
|
else
|
|
if (_dal > _dataini)
|
|
{
|
|
_tmp_saldi_att->put(SLD_PDAREPRO,prg_da); // W96SALDI del 05-06-96
|
|
_tmp_saldi_att->put(SLD_PAVEREPRO,prg_a);
|
|
}
|
|
_tmp_saldi_att->put(SLD_PDARE,mov_da);
|
|
_tmp_saldi_att->put(SLD_PAVERE,mov_a);
|
|
_tmp_saldi_att->put(SLD_SALDO,s);
|
|
_tmp_saldi_att->write();
|
|
}
|
|
|
|
void TStampa_bilanci::init_sort()
|
|
{
|
|
cli_for cf;
|
|
|
|
_sort = new TSort(sizeof(cli_for));
|
|
_sort->addsortkey ((char*)&(cf.tipocf)-(char*)&(cf.tipocf),1);
|
|
_sort->addsortkey ((char*)&(cf.gruppo)-(char*)&(cf.tipocf),3);
|
|
_sort->addsortkey ((char*)&(cf.conto)-(char*)&(cf.tipocf),3);
|
|
if (_ordinamento == 1)
|
|
_sort->addsortkey ((char*)&(cf.codcf)-(char*)&(cf.tipocf),6);
|
|
else
|
|
if (_ordinamento == 2)
|
|
_sort->addsortkey ((char*)&(cf.ragsoc)-(char*)&(cf.tipocf),50);
|
|
|
|
_sort->init();
|
|
}
|
|
|
|
void TStampa_bilanci::riempi_record(char t,int g,int c,long s,
|
|
const char* rs,const real& sd,const real& sa,
|
|
const real& md,const real& ma,const real& sf)
|
|
{
|
|
cli_for cf;
|
|
cf.tipocf = t;
|
|
sprintf_s(cf.gruppo, "%03d", g);
|
|
sprintf_s(cf.conto, "%03d", c);
|
|
sprintf_s(cf.codcf, "%06ld", s);
|
|
sprintf_s(cf.ragsoc, "%s", rs);
|
|
if ( s == 999999L )
|
|
{
|
|
if ((_dal == _dataini) || (_tipo_stampa != 1))
|
|
{
|
|
//modifica del 21/11/1995
|
|
if (_tipo_stampa == 1 && _dal == _dataini)
|
|
{
|
|
cf.saldodare = _saldo_ini_conto_dare;
|
|
cf.saldoavere = _saldo_ini_conto_avere;
|
|
}
|
|
else
|
|
//fine
|
|
{
|
|
real app = _saldo_ini_conto_dare + _saldo_ini_conto_avere;
|
|
|
|
if (app > ZERO) //va stampato in Dare
|
|
{
|
|
cf.saldoavere = ZERO;
|
|
cf.saldodare = app;
|
|
}
|
|
else
|
|
if (app < ZERO)
|
|
{
|
|
app = -app;
|
|
cf.saldodare = ZERO;
|
|
cf.saldoavere = app;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
if (_dal > _dataini)
|
|
{
|
|
cf.saldodare = sd;
|
|
cf.saldoavere = sa;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
cf.saldodare = sd;
|
|
cf.saldoavere = sa;
|
|
}
|
|
cf.movdare = md;
|
|
cf.movavere = ma;
|
|
cf.saldofinale = sf;
|
|
cf.udata = _u_max;
|
|
_sort->sort((const char*)&cf);
|
|
}
|
|
|
|
void TStampa_bilanci::leggi_clifo(const TArray& gccf)
|
|
{
|
|
TEsercizi_contabili ese;
|
|
|
|
TSaldo sld;
|
|
TLocalisamfile saldi(LF_SALDI);
|
|
// int g = 0, c=0;
|
|
long codcf=0l;
|
|
TString80 ragsoc;
|
|
char tipocf,tipocfp,tipoa;
|
|
real saldo_finale, saldo_conto, saldo_iniziale, saldodare, saldoavere,
|
|
movdare, movavere;
|
|
real mov_conto_dare, mov_conto_avere, prg_conto_dare, prg_conto_avere;
|
|
bool esiste_sc = false, movimentato = false;
|
|
TRecnotype items = _cur->items();
|
|
TProgress_monitor p(_pcn->eod(), "Elaborazione saldi clienti/fornitori");
|
|
|
|
_gp=-1;
|
|
_cp=-1;
|
|
tipocfp = ' ';
|
|
_saldo_ini_conto_dare = ZERO;
|
|
_saldo_ini_conto_avere = ZERO;
|
|
/* saldo_conto = ZERO;
|
|
mov_conto_dare = ZERO;
|
|
mov_conto_avere = ZERO;
|
|
prg_conto_dare = ZERO;
|
|
prg_conto_avere = ZERO;*/
|
|
_u_max = 0l;
|
|
|
|
const int anno = _tipo_stampa == 1 ? _annoapp : _annoes;
|
|
|
|
for (int i=0; i < gccf.items(); i++)
|
|
{
|
|
int g = ((TToken_string&)gccf[i]).get_int(0);
|
|
int c = ((TToken_string&)gccf[i]).get_int(1);
|
|
|
|
*_cur = 0l;
|
|
for (int i = 0; i < items && p.addstatus(1L); i++,++(*_cur))
|
|
{
|
|
codcf = _cur->curr().get_long(CLI_CODCF);
|
|
tipocf = _cur->curr().get(CLI_TIPOCF)[0];
|
|
ragsoc = _cur->curr().get(CLI_RAGSOC);
|
|
tipoa = _cur->curr().get_char(CLI_TIPOAPER);
|
|
if (tipoa == 'F') //persona fisica
|
|
{
|
|
TString80 cognome, nome;
|
|
cognome = ragsoc.mid(0,30);
|
|
nome = ragsoc.mid(30,20);
|
|
cognome.trim(); nome.trim();
|
|
ragsoc = cognome;
|
|
ragsoc << ' ' << nome;
|
|
}
|
|
|
|
int aprec = ese.pred(anno);
|
|
|
|
saldi.zero();
|
|
saldi.put(SLD_ANNOES, anno); // W96SALDI del 05-06-96
|
|
saldi.put(SLD_FLSCA, false);
|
|
saldi.put(SLD_GRUPPO, g);
|
|
saldi.put(SLD_CONTO, c);
|
|
saldi.put(SLD_SOTTOCONTO, codcf);
|
|
if (saldi.read() != NOERR)
|
|
{
|
|
//if (_tipo_stampa1 == 1) //bilancio per data limite
|
|
// continue;
|
|
//else
|
|
if (_stampac == 2) //se sono richiesti i conti movimentati
|
|
{ //esco, se no...
|
|
_indbil = cerca_indbil(g,c);
|
|
if (_indbil == 1 || _indbil == 2 || _indbil == 5)
|
|
{
|
|
saldi.zero();
|
|
saldi.put(SLD_ANNOES, aprec); // W96SALDI del 05-06-96
|
|
saldi.put(SLD_FLSCA, false);
|
|
saldi.put(SLD_GRUPPO, g);
|
|
saldi.put(SLD_CONTO, c);
|
|
saldi.put(SLD_SOTTOCONTO, codcf);
|
|
if (saldi.read() != NOERR)
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
if ( (((_cp != -1) && (c != _cp)) || ((_gp != -1) && (g != _gp))) &&
|
|
esiste_sc )
|
|
{
|
|
//scrivo il record del conto;
|
|
riempi_record(tipocfp,_gp,_cp,999999L,"zzzz",prg_conto_dare,
|
|
prg_conto_avere,mov_conto_dare,mov_conto_avere,saldo_conto);
|
|
tipocfp = tipocf;
|
|
_cp = c;
|
|
esiste_sc = false;
|
|
_saldo_ini_conto_dare = ZERO;
|
|
_saldo_ini_conto_avere = ZERO;
|
|
saldo_conto = ZERO;
|
|
mov_conto_dare = ZERO;
|
|
mov_conto_avere = ZERO;
|
|
prg_conto_dare = ZERO;
|
|
prg_conto_avere = ZERO;
|
|
}
|
|
|
|
saldo_finale = ZERO;
|
|
saldodare = ZERO;
|
|
saldoavere = ZERO;
|
|
movdare = ZERO;
|
|
movavere = ZERO;
|
|
saldo_iniziale = ZERO;
|
|
|
|
if (_tipo_stampa == 1) //bilancio di verifica per data limite
|
|
{
|
|
|
|
_mov_ap = false;
|
|
//modifica del 19/06/95
|
|
_indbil = cerca_indbil(g,c);
|
|
movimentato = calcola(g,c,codcf);
|
|
if (_stampa_mov_prov & 0x1)
|
|
if (!movimentato)
|
|
if (_indbil == 1 || _indbil == 2 || _indbil == 5)
|
|
if (_annoes != 0) //cioe' se sto ragionando per competenza
|
|
{
|
|
sld.ultima_immissione_verifica(_annoes, g, c, codcf, _indbil, _stampa_mov_prov);
|
|
saldo_iniziale = sld.saldoini();
|
|
if (saldo_iniziale > ZERO)
|
|
_saldo_ini_dare = saldo_iniziale;
|
|
else
|
|
_saldo_ini_avere = -saldo_iniziale;
|
|
}
|
|
if (movimentato)
|
|
{
|
|
//modifica del 21/11/1995
|
|
if (_mov_ap)
|
|
saldo_iniziale = _saldo_ini_dare - _saldo_ini_avere;
|
|
else
|
|
{
|
|
sld.ultima_immissione_verifica(anno, g, c, codcf, _indbil, _stampa_mov_prov);
|
|
saldo_iniziale = sld.saldoini();
|
|
if (saldo_iniziale > ZERO)
|
|
_saldo_ini_dare = saldo_iniziale;
|
|
else
|
|
_saldo_ini_avere = -saldo_iniziale;
|
|
}
|
|
}
|
|
if (movimentato || _stampac != 1 || saldo_iniziale != ZERO)
|
|
{
|
|
if (_dal == _dataini)
|
|
saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere;
|
|
else
|
|
if (_dal > _dataini)
|
|
{
|
|
//modifica del 19/06
|
|
if (saldo_iniziale > 0)
|
|
_prg_prec_dare += saldo_iniziale;
|
|
else _prg_prec_avere -= saldo_iniziale;
|
|
//fine modifica
|
|
saldo_finale = _prg_prec_dare-_prg_prec_avere+_mov_periodo_dare
|
|
-_mov_periodo_avere;
|
|
}
|
|
}
|
|
|
|
//se saldo_finale < 0 verra' stampato con una A, se no con una D
|
|
}
|
|
else //bilancio di verifica all'ultima immissione
|
|
{
|
|
_indbil = cerca_indbil(g,c);
|
|
movimentato = sld.ultima_immissione_verifica(anno,g,c,codcf,_indbil,_stampa_mov_prov);
|
|
|
|
if (_stampa_mov_prov & 0x1)
|
|
if (!movimentato /* && _stampac!=1 */ )
|
|
if (_indbil == 1 || _indbil == 2 || _indbil == 5)
|
|
saldo_iniziale = sld.saldofin_esprec(anno,g,c,codcf,false,_stampa_mov_prov);
|
|
|
|
if (movimentato)
|
|
saldo_iniziale = sld.saldoini();
|
|
|
|
if (movimentato || _stampac != 1 || saldo_iniziale != ZERO)
|
|
{
|
|
_mov_periodo_dare = sld.prgdare();
|
|
_mov_periodo_avere = sld.prgavere();
|
|
_prg_prec_dare = ZERO;
|
|
_prg_prec_avere = ZERO;
|
|
|
|
if (sld.sezsf() == 'A')
|
|
_mov_periodo_avere -= sld.saldofin();
|
|
else
|
|
_mov_periodo_dare += sld.saldofin();
|
|
|
|
saldo_finale = saldo_iniziale+_mov_periodo_dare-_mov_periodo_avere;
|
|
}
|
|
}
|
|
if (movimentato || _stampac != 1 || saldo_iniziale != ZERO)
|
|
if (!(saldo_finale.is_zero() && _stampac == 2))
|
|
{
|
|
esiste_sc = true;
|
|
|
|
//modifica del 21/11/1995
|
|
if (_tipo_stampa == 1 && _dal == _dataini)
|
|
{
|
|
_saldo_ini_conto_dare += _saldo_ini_dare;
|
|
_saldo_ini_conto_avere += _saldo_ini_avere;
|
|
}
|
|
else
|
|
{
|
|
if (saldo_iniziale < ZERO)
|
|
_saldo_ini_conto_avere += saldo_iniziale;
|
|
else
|
|
_saldo_ini_conto_dare += saldo_iniziale;
|
|
}
|
|
//fine
|
|
|
|
mov_conto_dare += _mov_periodo_dare;
|
|
mov_conto_avere += _mov_periodo_avere;
|
|
prg_conto_dare += _prg_prec_dare;
|
|
prg_conto_avere += _prg_prec_avere;
|
|
saldo_conto += saldo_finale; // somma algebrica!!!
|
|
|
|
if ((_dal == _dataini) || (_tipo_stampa != 1))
|
|
{
|
|
//modifica del 21/11/1995
|
|
if (_tipo_stampa == 1 && _dal == _dataini)
|
|
{
|
|
saldodare = _saldo_ini_dare;
|
|
saldoavere = _saldo_ini_avere;
|
|
}
|
|
else
|
|
//
|
|
{
|
|
if (saldo_iniziale > ZERO) //va stampato in Dare
|
|
saldodare = saldo_iniziale;
|
|
else
|
|
if (saldo_iniziale < ZERO)
|
|
{
|
|
saldo_iniziale = -saldo_iniziale;
|
|
saldoavere = saldo_iniziale;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
if (_dal > _dataini)
|
|
{
|
|
saldodare = _prg_prec_dare;
|
|
saldoavere = _prg_prec_avere;
|
|
}
|
|
|
|
movdare = _mov_periodo_dare;
|
|
movavere = _mov_periodo_avere;
|
|
|
|
riempi_record(tipocf,g,c,codcf,ragsoc,saldodare,saldoavere,movdare,
|
|
movavere,saldo_finale);
|
|
tipocfp = tipocf;
|
|
_gp = g;
|
|
_cp = c;
|
|
}
|
|
}
|
|
}
|
|
if (esiste_sc)
|
|
riempi_record(tipocfp,_gp,_cp,999999L,"zzzz",prg_conto_dare,prg_conto_avere,
|
|
mov_conto_dare,mov_conto_avere,saldo_conto);
|
|
}
|
|
|
|
void TStampa_bilanci::crea_sort_clifo()
|
|
{
|
|
long ncur = _cur->items();
|
|
//serve solo per la progind: stima alla meno peggio
|
|
if (_situazione.empty()) ncur /= 2;
|
|
long nitems = ncur*(_clienti.items()+_fornitori.items());
|
|
|
|
init_sort();
|
|
if (_situazione == "C") leggi_clifo(_clienti);
|
|
else
|
|
if (_situazione == "F")
|
|
leggi_clifo(_fornitori);
|
|
else
|
|
{
|
|
_cur->setfilter("TIPOCF = \"C\"");
|
|
leggi_clifo(_clienti);
|
|
_cur->setfilter("TIPOCF = \"F\"");
|
|
leggi_clifo(_fornitori);
|
|
}
|
|
}
|
|
|
|
int TStampa_bilanci::cerca_indbil(int g, int c)
|
|
{
|
|
/*
|
|
TLocalisamfile pconti(LF_PCON);
|
|
pconti.zero();
|
|
pconti.put(PCN_GRUPPO,g);
|
|
if (c != 0)
|
|
pconti.put(PCN_CONTO,c);
|
|
pconti.put(PCN_SOTTOCONTO,0l);
|
|
|
|
pconti.read();
|
|
return pconti.get_int(PCN_INDBIL);
|
|
*/
|
|
TString8 key; key.format("%d|%d", g, c);
|
|
const int indbil = atoi(cache().get(LF_PCON, key, PCN_INDBIL));
|
|
CHECKD(indbil > 0, "Indicatore di bilancio strano: ", indbil);
|
|
return indbil;
|
|
|
|
}
|
|
|
|
void TStampa_bilanci::leggi_files_dare(TIsamtempfile* file)
|
|
{
|
|
_gruppo_dare = file->get_int(SLD_GRUPPO);
|
|
_conto_dare = file->get_int(SLD_CONTO);
|
|
_sottoconto_dare = file->get_long(SLD_SOTTOCONTO);
|
|
_saldo_dare = file->get_real(SLD_PDARE);
|
|
_descr_dare = TBill(_gruppo_dare, _conto_dare, _sottoconto_dare, ' ').descrizione();
|
|
|
|
_gc_corr_dare = format("%3d%3d", _gruppo_dare, _conto_dare);
|
|
|
|
if (_gc_corr_dare != _gc_prec_dare)
|
|
{
|
|
_cambiato_conto_1 = true;
|
|
_gc_prec_dare = _gc_corr_dare;
|
|
}
|
|
else
|
|
if (_sottoconto_dare != 0l)
|
|
_cambiato_conto_1 = false;
|
|
}
|
|
|
|
void TStampa_bilanci::leggi_files_avere(TIsamtempfile* file)
|
|
{
|
|
_gruppo_avere = file->get_int(SLD_GRUPPO);
|
|
_conto_avere = file->get_int(SLD_CONTO);
|
|
_sottoconto_avere = file->get_long(SLD_SOTTOCONTO);
|
|
_saldo_avere = file->get_real(SLD_PAVERE);
|
|
_descr_avere = TBill(_gruppo_avere, _conto_avere, _sottoconto_avere, ' ').descrizione();
|
|
_gc_corr_avere = format("%3d%3d", _gruppo_avere, _conto_avere);
|
|
|
|
if (_gc_corr_avere != _gc_prec_avere)
|
|
{
|
|
_cambiato_conto_2 = true;
|
|
_gc_prec_avere = _gc_corr_avere;
|
|
}
|
|
else
|
|
if (_sottoconto_avere != 0l)
|
|
_cambiato_conto_2 = false;
|
|
}
|
|
|
|
#define TOTAL_PICTURE "###.###.###.###.###"
|
|
|
|
HIDDEN void total2string(const real& tot, TString& str)
|
|
{
|
|
TCurrency cur(tot);
|
|
str = cur.string(true);
|
|
str.right_just(strlen(TOTAL_PICTURE));
|
|
}
|
|
|
|
bool TStampa_bilanci::preprocess_print(int file, int counter)
|
|
{
|
|
if (_bilancio == 1)
|
|
{
|
|
set_real_picture ("##.###.###.###.###");
|
|
set_print_zero();
|
|
_tmp_saldi_att->setkey(2);
|
|
_tmp_saldi_pass->setkey(2);
|
|
_tmp_saldi_costi->setkey(2);
|
|
_tmp_saldi_ricavi->setkey(2);
|
|
_tmp_saldi_conti_uno->setkey(2);
|
|
_tmp_saldi_conti_due->setkey(2);
|
|
_gc_prec_avere = "";
|
|
_prima_volta = _seconda_volta = true;
|
|
_flag = _controlla = false;
|
|
_salto_pagina = _salto_pagina1 = _stampato = false;
|
|
_cambiato_conto_1 = true;
|
|
_cambiato_conto_2 = true;
|
|
_tot_dare = ZERO;
|
|
_tot_avere = ZERO;
|
|
}
|
|
else
|
|
{
|
|
if (_noseparator)
|
|
set_real_picture ("################");
|
|
else
|
|
set_real_picture ("####.###.###.###");
|
|
|
|
set_print_zero(false);
|
|
_cambiato_conto_1 = false;
|
|
_livello_conto = true;
|
|
_saldo_dare_tot = ZERO;
|
|
_saldo_avere_tot = ZERO;
|
|
_mov_dare_tot = ZERO;
|
|
_mov_avere_tot = ZERO;
|
|
_saldo_finale_tot = ZERO;
|
|
}
|
|
set_magic_currency(true);
|
|
return true;
|
|
}
|
|
|
|
void TStampa_bilanci::leggi_file_tmp()
|
|
{
|
|
if (_livello_conto) // era meglio chiamarla _livello_conto_oppure_gruppo, perche' nel caso dei saldi di mastro _livello_conto==true <=> si tratta di un gruppo, mentre nel caso del bilancio _livello_conto==true <=> si tratta di un conto
|
|
{
|
|
_gruppo = _tmp_saldi_att->get_int(SLD_GRUPPO);
|
|
_conto = _tmp_saldi_att->get_int(SLD_CONTO);
|
|
_sottoconto = _tmp_saldi_att->get_long(SLD_SOTTOCONTO);
|
|
_tipo_conto = _tmp_saldi_att->get_char(SLD_FLAGSALINI);
|
|
_descr = TBill(_gruppo,_conto,_sottoconto,_tipo_conto).descrizione();
|
|
_saldoini_dare = _tmp_saldi_att->get_real(SLD_PDAREPRO); // W96SALDI del 05-06-96
|
|
_saldoini_avere = _tmp_saldi_att->get_real(SLD_PAVEREPRO);
|
|
_mov_dare = _tmp_saldi_att->get_real(SLD_PDARE);
|
|
_mov_avere = _tmp_saldi_att->get_real(SLD_PAVERE);
|
|
_saldofinale = _tmp_saldi_att->get_real(SLD_SALDO);
|
|
}
|
|
_eof1 = _tmp_saldi_att->next();
|
|
if (!_eof1)
|
|
{
|
|
_gruppo_succ = _tmp_saldi_att->get_int(SLD_GRUPPO);
|
|
_conto_succ = _tmp_saldi_att->get_int(SLD_CONTO);
|
|
_sottoconto_succ = _tmp_saldi_att->get_long(SLD_SOTTOCONTO);
|
|
_tipoc_succ = _tmp_saldi_att->get_char(SLD_FLAGSALINI);
|
|
if ( (_verifica != 2) && (_sottoconto_succ != 0) )
|
|
{
|
|
if (_tipo_stampa == 2)
|
|
_ultima_data = UltimaData(_gruppo_succ,_conto_succ, _sottoconto_succ,_annoes);
|
|
else
|
|
_ultima_data = _tmp_saldi_att->get_date(SLD_DATAULMOV);
|
|
}
|
|
_descr_succ = TBill(_gruppo_succ,_conto_succ, _sottoconto_succ,_tipoc_succ).descrizione();
|
|
_saldoini_dare_succ = _tmp_saldi_att->get_real(SLD_PDAREPRO); // W96SALDI del 05-06-96
|
|
_saldoini_avere_succ = _tmp_saldi_att->get_real(SLD_PAVEREPRO);
|
|
_mov_dare_succ = _tmp_saldi_att->get_real(SLD_PDARE);
|
|
_mov_avere_succ = _tmp_saldi_att->get_real(SLD_PAVERE);
|
|
_saldofinale_succ = _tmp_saldi_att->get_real(SLD_SALDO);
|
|
_livello_conto = false;
|
|
if ( ((_verifica != 2)&&(_sottoconto_succ == 0)) ||
|
|
((_verifica == 2)&&(_conto_succ == 0)) )
|
|
{
|
|
_livello_conto = true;
|
|
_gruppo_succ = _gruppo;
|
|
_conto_succ = _conto;
|
|
_sottoconto_succ = _sottoconto;
|
|
_descr_succ = _descr;
|
|
_saldoini_dare_succ = _saldoini_dare;
|
|
_saldoini_avere_succ = _saldoini_avere;
|
|
_mov_dare_succ = _mov_dare;
|
|
_mov_avere_succ = _mov_avere;
|
|
_saldofinale_succ = _saldofinale;
|
|
}
|
|
}
|
|
}
|
|
|
|
bool TStampa_bilanci::preprocess_page(int file, int counter)
|
|
{
|
|
reset_print();
|
|
|
|
if (_bilancio == 1) //stampa bilancio a sez. contrapposte
|
|
{
|
|
if (counter)
|
|
{
|
|
if ( (!_eof1) && (_cambiato_conto_1) )
|
|
_eof1 = _tmp_saldi_att->next();
|
|
|
|
if ( (!_eof2) && (_cambiato_conto_2) )
|
|
_eof2 = _tmp_saldi_pass->next();
|
|
|
|
if (_eof1 && _eof2)
|
|
{
|
|
if (_prima_volta)
|
|
{
|
|
stampa_totali_uno(_prg_saldoini_dare,_prg_saldoini_avere);
|
|
_eof3 = _tmp_saldi_costi->first();
|
|
_eof4 = _tmp_saldi_ricavi->first();
|
|
}
|
|
else
|
|
{
|
|
_controlla = true;
|
|
|
|
if (_salto_pagina)
|
|
{
|
|
if ( (!_eof3) && (_cambiato_conto_1) )
|
|
_eof3 = _tmp_saldi_costi->next();
|
|
|
|
if ( (!_eof4) && (_cambiato_conto_2) )
|
|
_eof4 = _tmp_saldi_ricavi->next();
|
|
}
|
|
}
|
|
|
|
if ( (!_eof3) && (_cambiato_conto_1) )
|
|
leggi_files_dare(_tmp_saldi_costi);
|
|
|
|
if ( (!_eof4) && (_cambiato_conto_2) )
|
|
leggi_files_avere(_tmp_saldi_ricavi);
|
|
|
|
if (_eof3 && _eof4 && _salto_pagina)
|
|
{
|
|
if (_seconda_volta)
|
|
{
|
|
stampa_totali();
|
|
_eof5 = _tmp_saldi_conti_uno->first();
|
|
_eof6 = _tmp_saldi_conti_due->first();
|
|
}
|
|
else
|
|
{
|
|
_flag = true;
|
|
|
|
if (_salto_pagina1)
|
|
{
|
|
if ( (!_eof5) && (_cambiato_conto_1) )
|
|
_eof5 = _tmp_saldi_conti_uno->next();
|
|
|
|
if ( (!_eof6) && (_cambiato_conto_2) )
|
|
_eof6 = _tmp_saldi_conti_due->next();
|
|
}
|
|
}
|
|
|
|
if ( (!_eof5) && (_cambiato_conto_1) )
|
|
leggi_files_dare(_tmp_saldi_conti_uno);
|
|
|
|
if ( (!_eof6) && (_cambiato_conto_2) )
|
|
leggi_files_avere(_tmp_saldi_conti_due);
|
|
}
|
|
}
|
|
}
|
|
else //counter = 0
|
|
{
|
|
_gc_prec_dare = _gc_corr_avere = "";
|
|
_eof1 = _tmp_saldi_att->first();
|
|
_eof2 = _tmp_saldi_pass->first();
|
|
}
|
|
|
|
if ( (!_eof1) && (_cambiato_conto_1) )
|
|
leggi_files_dare(_tmp_saldi_att);
|
|
|
|
if ( (!_eof2) && (_cambiato_conto_2) )
|
|
leggi_files_avere(_tmp_saldi_pass);
|
|
}
|
|
else //stampa bilancio di verifica
|
|
{
|
|
if (_verifica == 3)
|
|
leggi_sort();
|
|
else
|
|
{
|
|
if (counter)
|
|
{
|
|
if (!_eof1)
|
|
leggi_file_tmp();
|
|
}
|
|
else
|
|
{
|
|
_eof1 = _tmp_saldi_att->first();
|
|
if (_eof1)
|
|
return false;
|
|
else
|
|
leggi_file_tmp();
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void TStampa_bilanci::leggi_sort()
|
|
{
|
|
_buff = _sort->retrieve();
|
|
if (_buff != NULL)
|
|
{
|
|
struct cli_for* cf = (struct cli_for*)_buff;
|
|
_tipo_conto = cf->tipocf;
|
|
_gruppo = atoi(cf->gruppo);
|
|
_conto = atoi(cf->conto);
|
|
_sottoconto = atol(cf->codcf);
|
|
_descr = cf->ragsoc;
|
|
if ( (_ordinamento == 2 && _descr != "zzzz") || (_ordinamento == 1 && _sottoconto != 999999L) )
|
|
{
|
|
if (_tipo_stampa == 2)
|
|
_ultima_data = UltimaData(_gruppo,_conto,_sottoconto,_annoes);
|
|
else
|
|
_ultima_data = cf->udata;
|
|
}
|
|
_saldo_dare = cf->saldodare;
|
|
_saldo_avere = cf->saldoavere;
|
|
_mov_dare = cf->movdare;
|
|
_mov_avere = cf->movavere;
|
|
_saldofinale = cf->saldofinale;
|
|
}
|
|
}
|
|
|
|
void TStampa_bilanci::controlla_conto(int file1,int file2)
|
|
{
|
|
if (!file1)
|
|
if (_cambiato_conto_1)
|
|
{
|
|
set_row(_i,"@67g*");
|
|
_cambiato_conto_1 = false;
|
|
}
|
|
else
|
|
{
|
|
stampa_prima_colonna(_gruppo_dare, _conto_dare, _sottoconto_dare,
|
|
_descr_dare,_saldo_dare);
|
|
_cambiato_conto_1 = true;
|
|
if (!_totali)
|
|
if ( (_conto_dare == 0) && (_sottoconto_dare == 0) )
|
|
_tot_dare += _saldo_dare;
|
|
if (_totali)
|
|
if (_sottoconto_dare == 0)
|
|
_tot_dare += _saldo_dare;
|
|
}
|
|
|
|
if (!file2)
|
|
if (_cambiato_conto_2)
|
|
{
|
|
set_row(_i,"@67g*");
|
|
_cambiato_conto_2 = false;
|
|
}
|
|
else
|
|
{
|
|
stampa_seconda_colonna(_gruppo_avere, _conto_avere, _sottoconto_avere,
|
|
_descr_avere, _saldo_avere);
|
|
_cambiato_conto_2 = true;
|
|
if (!_totali)
|
|
if ( (_conto_avere == 0) && (_sottoconto_avere == 0) )
|
|
_tot_avere += _saldo_avere;
|
|
if (_totali)
|
|
if (_sottoconto_avere == 0)
|
|
_tot_avere += _saldo_avere;
|
|
}
|
|
}
|
|
|
|
void TStampa_bilanci::postclose_print()
|
|
{
|
|
if (_bilancio == 1)
|
|
{
|
|
delete _tmp_saldi_att; _tmp_saldi_att = NULL;
|
|
delete _tmp_saldi_pass; _tmp_saldi_pass = NULL;
|
|
delete _tmp_saldi_costi; _tmp_saldi_costi = NULL;
|
|
delete _tmp_saldi_ricavi; _tmp_saldi_ricavi = NULL;
|
|
delete _tmp_saldi_conti_uno; _tmp_saldi_conti_uno = NULL;
|
|
delete _tmp_saldi_conti_due; _tmp_saldi_conti_due = NULL;
|
|
}
|
|
else
|
|
{
|
|
if (_verifica == 3)
|
|
{
|
|
delete _sort; _sort = NULL;
|
|
}
|
|
else
|
|
{
|
|
delete _tmp_saldi_att; _tmp_saldi_att = NULL;
|
|
}
|
|
}
|
|
}
|
|
|
|
void TStampa_bilanci::set_page(int file, int counter)
|
|
{
|
|
const TString16 dep;
|
|
|
|
if (_bilancio == 1) //stampa bilancio a sezioni contrapposte
|
|
{
|
|
_i = 1;
|
|
|
|
if (!counter)
|
|
{
|
|
set_row(_i++,FR("@29gATTIVITA'@98gPASSIVITA'"));
|
|
set_row(_i++,"@29g---------@98g----------");
|
|
set_row(_i++, dep);
|
|
}
|
|
|
|
controlla_conto(_eof1,_eof2); //stampo una riga vuota tra un gruppo e un conto altrimenti no
|
|
|
|
if ( _eof1 && _eof2 && (!_prima_volta) && _controlla )
|
|
if (!_salto_pagina)
|
|
{
|
|
printer().formfeed();
|
|
set_row(_i++,FR("@29gCOSTI@98gRICAVI"));
|
|
set_row(_i++,"@29g-----@98g------");
|
|
set_row(_i++, dep);
|
|
_salto_pagina = true;
|
|
|
|
}
|
|
|
|
if (_eof1 && _eof2 && _controlla)
|
|
{
|
|
controlla_conto(_eof3,_eof4);
|
|
|
|
if ( _eof3 && _eof4 && (!_seconda_volta) && _flag )
|
|
if (!_salto_pagina1)
|
|
{
|
|
if (!_tmp_saldi_conti_uno->empty() || !_tmp_saldi_conti_due->empty())
|
|
{
|
|
printer().formfeed();
|
|
set_row(_i++,FR("@59gCONTI D'ORDINE"));
|
|
set_row(_i++,"@59g--------------");
|
|
set_row(_i++, dep);
|
|
if (_eof5 && _eof6)
|
|
{
|
|
_stampato = true;
|
|
stampa_totali_uno(_prg_inidare_ord,_prg_iniavere_ord);
|
|
}
|
|
}
|
|
_salto_pagina1 = true;
|
|
}
|
|
|
|
if (_eof3 && _eof4 && _flag)
|
|
{
|
|
if (!_tmp_saldi_conti_uno->empty() || !_tmp_saldi_conti_due->empty())
|
|
{
|
|
controlla_conto(_eof5,_eof6);
|
|
if (_eof5 && _eof6)
|
|
if (!_stampato)
|
|
stampa_totali_uno(_prg_inidare_ord,_prg_iniavere_ord);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else //stampa bilancio di verifica
|
|
{
|
|
const TString16 udata = _ultima_data.string(brief,'/');
|
|
char app;
|
|
int r = 1;
|
|
|
|
if (_verifica == 3)
|
|
{
|
|
if (_buff != NULL)
|
|
{
|
|
*_d = (const char*) _descr;
|
|
if (_saldofinale > 0)
|
|
app = 'D';
|
|
else
|
|
if (_saldofinale < 0)
|
|
{
|
|
_saldofinale = -_saldofinale;
|
|
app = 'A';
|
|
}
|
|
if ( (_ordinamento == 2 && _descr == "zzzz") ||
|
|
(_ordinamento == 1 && _sottoconto == 999999L) ) //devo stampare il conto
|
|
{
|
|
_descr = TBill(_gruppo, _conto, 0L, ' ').descrizione();
|
|
stampa_record_conto(_gruppo,_conto,_descr,_saldo_dare,_saldo_avere,
|
|
_mov_dare,_mov_avere,_saldofinale,app);
|
|
}
|
|
else
|
|
{
|
|
if (_stampa_width == 132)
|
|
{
|
|
set_row(r,"@1g%6ld", _sottoconto);
|
|
if ((_saldo_dare != ZERO) || (_saldo_avere != ZERO) || (_mov_dare != ZERO) ||
|
|
(_mov_avere != ZERO) || (_saldofinale != ZERO))
|
|
set_row(r," %s",(const char*)udata);
|
|
set_row(r,"@17g#a@46g!%r@64g%r@80g!%r@98g%r@114g!@115g%r",_d,&_saldo_dare,
|
|
&_saldo_avere,&_mov_dare,&_mov_avere,&_saldofinale);
|
|
if (_saldofinale != ZERO)
|
|
set_row(r,"@131g%c", app);
|
|
if (_descr.len() > 30)
|
|
set_row(++r, "@46g!@80g!@114g!");
|
|
}
|
|
else
|
|
if (app == 'D')
|
|
{
|
|
set_row(r,"@1g%6ld", _sottoconto);
|
|
if ((_saldo_dare != ZERO) || (_saldo_avere != ZERO) || (_mov_dare != ZERO) ||
|
|
(_mov_avere != ZERO) || (_saldofinale != ZERO))
|
|
set_row(r," %s",(const char*)udata);
|
|
set_row(r,"@17g#a@46g!%r@64g%r@80g!%r@98g%r@114g!%r@148g!",_d,
|
|
&_saldo_dare,&_saldo_avere,&_mov_dare,&_mov_avere,&_saldofinale);
|
|
if (_descr.len() > 30)
|
|
set_row(++r, "@46g!@80g!@114g!@148g!");
|
|
}
|
|
else
|
|
{
|
|
set_row(r,"@1g%6ld", _sottoconto);
|
|
if ((_saldo_dare != ZERO) || (_saldo_avere != ZERO) || (_mov_dare != ZERO) ||
|
|
(_mov_avere != ZERO) || (_saldofinale != ZERO))
|
|
set_row(r," %s",(const char*)udata);
|
|
set_row(r,"@17g#a@46g!%r@64g%r@80g!%r@100g%r@114g!@132g%r@148g!",
|
|
_d,&_saldo_dare,&_saldo_avere,&_mov_dare,&_mov_avere,&_saldofinale);
|
|
if (_descr.len() > 30)
|
|
set_row(++r, "@46g!@80g!@114g!@148g!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else //_verifica != 3
|
|
{
|
|
if (!_eof1)
|
|
{
|
|
if (_saldofinale_succ >= ZERO)
|
|
app = 'D';
|
|
else
|
|
{
|
|
_saldofinale_succ = -_saldofinale_succ;
|
|
app = 'A';
|
|
}
|
|
|
|
if (_livello_conto) //sto stampando un conto/gruppo
|
|
r = stampa_record_conto(_gruppo_succ,_conto_succ,_descr_succ,
|
|
_saldoini_dare_succ,_saldoini_avere_succ,_mov_dare_succ,
|
|
_mov_avere_succ,_saldofinale_succ,app);
|
|
|
|
else //sto stampando un sottoconto/conto
|
|
{
|
|
if (_verifica == 2)
|
|
{
|
|
if (_stampa_width == 132)
|
|
{
|
|
set_row(r,"%3d",_conto_succ);
|
|
set_row(r," @8g%-.40s@46g!%r@64g%r@80g!%r@98g%r@114g!@115g%r",
|
|
(const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ,
|
|
&_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ);
|
|
if (_saldofinale_succ != ZERO)
|
|
set_row(r,"@131g%c", app);
|
|
}
|
|
else
|
|
if (app == 'D')
|
|
{
|
|
set_row(r,"%3d",_conto_succ);
|
|
set_row(r," @8g%-.40s@46g!%r@64g%r@80g!%r@98g%r@114g!%r@148g!",
|
|
(const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ,
|
|
&_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ);
|
|
}
|
|
else
|
|
{
|
|
set_row(r,"%3d",_conto_succ);
|
|
set_row(r," @8g%-.40s@46g!%r@64g%r@80g!%r@98g%r@114g!@132g%r@148g!",
|
|
(const char*)_descr_succ,&_saldoini_dare_succ,&_saldoini_avere_succ,
|
|
&_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ);
|
|
}
|
|
} // _verifica != 2
|
|
else
|
|
{
|
|
*_d = (const char*) _descr_succ;
|
|
if (_print_full_code)
|
|
set_row(r,"@1g%3d %3d %6ld", _gruppo_succ, _conto_succ, _sottoconto_succ);
|
|
else
|
|
{
|
|
set_row(r,"@1g%6ld", _sottoconto_succ);
|
|
if ((_saldoini_dare_succ != ZERO) || (_saldoini_avere_succ != ZERO) ||
|
|
(_mov_dare_succ != ZERO) || (_mov_avere_succ != ZERO) ||
|
|
(_saldofinale_succ != ZERO))
|
|
set_row(r," %s",(const char*)udata);
|
|
}
|
|
|
|
if (_stampa_width == 132)
|
|
{
|
|
// set_row(r,"@1g%6ld",(const char*)_sottoconto_succ);
|
|
// if ((_saldoini_dare_succ != ZERO) || (_saldoini_avere_succ != ZERO) ||
|
|
// (_mov_dare_succ != ZERO) || (_mov_avere_succ != ZERO) ||
|
|
// (_saldofinale_succ != ZERO))
|
|
// set_row(r," %s",(const char*)udata);
|
|
set_row(r,"@17g#a@46g!%r@64g%r@80g!%r@98g%r@114g!@115g%r",
|
|
_d,&_saldoini_dare_succ,&_saldoini_avere_succ,
|
|
&_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ);
|
|
if (_saldofinale_succ != ZERO)
|
|
set_row(r,"@131g%c", app);
|
|
if (_descr_succ.len() > 30)
|
|
set_row(++r, "@46g!@80g!@114g!");
|
|
}
|
|
else // Stampa estesa
|
|
{
|
|
// set_row(r,"@1g%6ld",(const char*)_sottoconto_succ);
|
|
// if ((_saldoini_dare_succ != ZERO) || (_saldoini_avere_succ != ZERO) ||
|
|
// (_mov_dare_succ != ZERO) || (_mov_avere_succ != ZERO) ||
|
|
// (_saldofinale_succ != ZERO))
|
|
// set_row(r," %s",(const char*)udata);
|
|
if (app == 'D')
|
|
{
|
|
set_row(r,"@17g#a@46g!%r@64g%r@80g!%r@98g%r@114g!%r@148g!",
|
|
_d,&_saldoini_dare_succ,&_saldoini_avere_succ,
|
|
&_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ);
|
|
}
|
|
else
|
|
{
|
|
set_row(r,"@17g#a@46g!%r@64g%r@80g!%r@98g%r@114g!@132g%r@148g!",
|
|
_d,&_saldoini_dare_succ,&_saldoini_avere_succ,
|
|
&_mov_dare_succ,&_mov_avere_succ,&_saldofinale_succ);
|
|
}
|
|
if (_descr_succ.len() > 30)
|
|
set_row(++r, "@46g!@80g!@114g!@148g!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (_saldofinale >= ZERO)
|
|
app = 'D';
|
|
else
|
|
{
|
|
app = 'A';
|
|
_saldofinale = -_saldofinale;
|
|
}
|
|
r = stampa_record_conto(_gruppo,_conto,_descr,_saldoini_dare,
|
|
_saldoini_avere,_mov_dare,_mov_avere,_saldofinale,app);//per stampare l'ultimo conto
|
|
|
|
stampa_riga_totali(r);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
int TStampa_bilanci::stampa_record_conto(int g,int c,const TString& d,
|
|
const real& r1,const real& r2,const real& r3,const real& r4,const real& r5,
|
|
const char app)
|
|
{
|
|
int r = 1;
|
|
|
|
if (_stampa_width != 132)
|
|
set_row(r,"@46g!@80g!@114g!@148g!"); //stampo una riga vuota
|
|
else
|
|
set_row(r,"@46g!@80g!@114g!"); //stampo una riga vuota
|
|
r++;
|
|
if (_verifica == 2)
|
|
{
|
|
if (_stampa_width == 132)
|
|
{
|
|
set_row(r,"%3d-",g);
|
|
set_row(r,"@8g%-.40s",(const char*)d);
|
|
set_row(r,"@46g!%r@64g%r@80g!%r@98g%r@114g!@115g%r",&r1,&r2,&r3,&r4,&r5);
|
|
if (r5 != ZERO)
|
|
set_row(r,"@131g%c", app);
|
|
r++;
|
|
}
|
|
else
|
|
if (app == 'D')
|
|
{
|
|
set_row(r,"%3d-",g);
|
|
set_row(r,"@8g%-.40s",(const char*)d);
|
|
set_row(r++,"@46g!%r@64g%r@80g!%r@98g%r@114g!%r@148g!",&r1,&r2,&r3,&r4,&r5);
|
|
}
|
|
else
|
|
{
|
|
set_row(r,"%3d-",g);
|
|
set_row(r,"@8g%-.40s",(const char*)d);
|
|
set_row(r++,"@46g!%r@64g%r@80g!%r@98g%r@114g!@132g%r@148g!",&r1,&r2,&r3,&r4,&r5);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
*_d = (const char*) d;
|
|
|
|
if (_stampa_width == 132)
|
|
{
|
|
set_row(r,"%3d-",g);
|
|
set_row(r,"%3d ********",c);
|
|
set_row(r,"@17g#a",_d);
|
|
set_row(r,"@46g!%r@64g%r@80g!%r@98g%r@114g!@115g%r",&r1,&r2,&r3,&r4,&r5);
|
|
if (r5 != ZERO)
|
|
set_row(r,"@131g%c", app);
|
|
r++;
|
|
if (d.len() > 30)
|
|
set_row(r+1, "@46g!@80g!@114g!");
|
|
}
|
|
else
|
|
if (app == 'D')
|
|
{
|
|
set_row(r,"%3d-",g);
|
|
set_row(r,"%3d ********",c);
|
|
set_row(r,"@17g#a",_d);
|
|
set_row(r++,"@46g!%r@64g%r@80g!%r@98g%r@114g!%r@148g!",&r1,&r2,&r3,&r4,&r5);
|
|
if (d.len() > 30)
|
|
set_row(r+1, "@46g!@80g!@114g!@148g!");
|
|
}
|
|
else
|
|
{
|
|
set_row(r,"%3d-",g);
|
|
set_row(r,"%3d ********",c);
|
|
set_row(r,"@17g#a",_d);
|
|
set_row(r++,"@46g!%r@64g%r@80g!%r@98g%r@114g!@132g%r@148g!",&r1,&r2,&r3,&r4,&r5);
|
|
if (d.len() > 30)
|
|
set_row(r+1, "@46g!@80g!@114g!@148g!");
|
|
}
|
|
}
|
|
|
|
set_row(r,"@46g!@80g!@114g!");
|
|
if (_stampa_width != 132)
|
|
set_row(r,"@148g!");
|
|
r++;
|
|
|
|
set_row(r,"@46g!@80g!@114g!");
|
|
if (_stampa_width != 132)
|
|
set_row(r,"@148g!");
|
|
r++;
|
|
|
|
if (app == 'D')
|
|
_saldo_finale_tot += r5;
|
|
else _saldo_finale_tot -= r5;
|
|
|
|
_saldo_dare_tot += r1;
|
|
_saldo_avere_tot += r2;
|
|
_mov_dare_tot += r3;
|
|
_mov_avere_tot += r4;
|
|
|
|
return r;
|
|
}
|
|
|
|
void TStampa_bilanci::stampa_riga_totali(int r)
|
|
{
|
|
const TString16 dep;
|
|
char app = ' ';
|
|
|
|
if (_saldo_finale_tot > 0)
|
|
app = 'D';
|
|
else
|
|
if (_saldo_finale_tot < 0)
|
|
{
|
|
_saldo_finale_tot = -_saldo_finale_tot;
|
|
app = 'A';
|
|
}
|
|
|
|
//modifica del 21/11/1995
|
|
if (_tipo_stampa == 2)
|
|
{
|
|
real r = _saldo_dare_tot - _saldo_avere_tot;
|
|
|
|
if (r > ZERO)
|
|
{
|
|
_saldo_dare_tot = r;
|
|
_saldo_avere_tot = ZERO;
|
|
}
|
|
else
|
|
{
|
|
_saldo_avere_tot = -r;
|
|
_saldo_dare_tot = ZERO;
|
|
}
|
|
}
|
|
|
|
set_row(r, "@46g!@80g!@114g!");
|
|
if (_stampa_width != 132)
|
|
set_row(r, "@148g!");
|
|
r++;
|
|
|
|
if (_verifica == 2)
|
|
{
|
|
if (_stampa_width == 132)
|
|
{
|
|
set_row(r,FR("***@8gTOTALE GENERALE@46g!%r@64g%r@80g!%r@98g%r@114g!@115g%r"),&_saldo_dare_tot,&_saldo_avere_tot,&_mov_dare_tot,
|
|
&_mov_avere_tot,&_saldo_finale_tot);
|
|
if (_saldo_finale_tot != ZERO)
|
|
set_row(r,"@131g%c", app);
|
|
}
|
|
else
|
|
{
|
|
if (app == 'D')
|
|
set_row(r,FR("***@8gTOTALE GENERALE@46g!%r@64g%r@80g!%r@98g%r@114g!%r@148g!"),&_saldo_dare_tot,&_saldo_avere_tot,
|
|
&_mov_dare_tot,&_mov_avere_tot,&_saldo_finale_tot);
|
|
else
|
|
set_row(r,FR("***@8gTOTALE GENERALE@46g!%r@64g%r@80g!%r@98g%r@114g!@132g%r@148g!"),&_saldo_dare_tot,&_saldo_avere_tot,
|
|
&_mov_dare_tot,&_mov_avere_tot,&_saldo_finale_tot);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (_stampa_width == 132)
|
|
{
|
|
set_row(r,FR("@1g****** ********@17gTOTALE GENERALE@46g!%r@64g%r@80g!%r@98g%r@114g!@115g%r"),&_saldo_dare_tot,&_saldo_avere_tot,
|
|
&_mov_dare_tot,&_mov_avere_tot,&_saldo_finale_tot);
|
|
if (_saldo_finale_tot != ZERO)
|
|
set_row(r,"@131g%c", app);
|
|
r++;
|
|
|
|
if ((_tipo_stampa == 1 && _dal == _dataini) || _tipo_stampa == 2)
|
|
{
|
|
//modifica del 21/11/1995
|
|
if (_tipo_stampa == 2)
|
|
set_row(r,FR("@1g****** ********@17gTOTALE CON SALDI INIZIALI@46g!@80g!%r@98g%r@114g!"),&_nuovo_tot_saldo_d,&_nuovo_tot_saldo_a);
|
|
else
|
|
set_row(r,FR("@1g****** ********@17gTOTALE CON MOVIM. DI APERTURA@46g!@80g!%r@98g%r@114g!"),&_nuovo_tot_saldo_d,&_nuovo_tot_saldo_a);
|
|
//fine
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (app == 'D')
|
|
{
|
|
set_row(r++,FR("@1g****** ********@17gTOTALE GENERALE@46g!%r@64g%r@80g!%r@98g%r@114g!%r@148g!"),&_saldo_dare_tot,
|
|
&_saldo_avere_tot,&_mov_dare_tot,&_mov_avere_tot, &_saldo_finale_tot);
|
|
}
|
|
else
|
|
{
|
|
set_row(r++,FR("@1g****** ********@17gTOTALE GENERALE@46g!%r@64g%r@80g!%r@98g%r@114g!@132g%r@148g!"),&_saldo_dare_tot,
|
|
&_saldo_avere_tot,&_mov_dare_tot,&_mov_avere_tot, &_saldo_finale_tot);
|
|
}
|
|
|
|
if ((_tipo_stampa == 1 && _dal == _dataini) || _tipo_stampa == 2)
|
|
{
|
|
if (_tipo_stampa == 2)
|
|
set_row(r,FR("@1g****** ********@17gTOTALE CON SALDI INIZIALI@46g!@80g!%r@98g%r@114g!@148g!"),&_nuovo_tot_saldo_d,&_nuovo_tot_saldo_a);
|
|
else
|
|
set_row(r,FR("@1g****** ********@17gTOTALE CON MOVIM. DI APERTURA@46g!@80g!%r@98g%r@114g!@148g!"),&_nuovo_tot_saldo_d,&_nuovo_tot_saldo_a);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void TStampa_bilanci::stampa_totali()
|
|
{
|
|
const TString16 dep = "";
|
|
real pareggio;
|
|
real sbilancio = _tot_dare - _tot_avere;
|
|
|
|
if (sbilancio > ZERO) //_tot_dare > _tot_avere
|
|
pareggio = _tot_avere + sbilancio;
|
|
else
|
|
{
|
|
sbilancio = -sbilancio;
|
|
pareggio = _tot_dare + sbilancio;
|
|
}
|
|
if (_prima_volta) //ho finito di stampare le attivita'/passivita'
|
|
_prima_volta = false;
|
|
else
|
|
_seconda_volta = false;
|
|
const bool stato_patrimoniale = _seconda_volta; // cosa mi tocca fare
|
|
_gc_prec_dare = _gc_corr_avere = "";
|
|
_cambiato_conto_1 = true;
|
|
_cambiato_conto_2 = true;
|
|
|
|
set_row(_i++, (const char*)dep);
|
|
set_row(_i++, (const char*)dep);
|
|
set_row(_i++, (const char*)dep);
|
|
set_row(_i++, (const char*)dep);
|
|
TString pal; total2string(_tot_dare, pal);
|
|
TString bal; total2string(_tot_avere, bal);
|
|
set_row(_i++, FR("@39gTOTALE@48g%s@102gTOTALE@113g%s"),
|
|
(const char*)pal, (const char*)bal);
|
|
TString sb; total2string(sbilancio, sb);
|
|
TString pa; total2string(pareggio, pa);
|
|
if (_tot_dare > _tot_avere)
|
|
{
|
|
if (stato_patrimoniale)
|
|
set_row(_i++, FR("@79gUTILE DELL'ESERCIZIO IN CORSO@113g%s"), (const char*)sb);
|
|
else
|
|
set_row(_i++, FR("@77gPERDITA DELL'ESERCIZIO IN CORSO@113g%s"), (const char*)sb);
|
|
set_row(_i++, FR("@91gTOTALE A PAREGGIO@113g%s"),(const char*)pa);
|
|
}
|
|
if (_tot_dare < _tot_avere)
|
|
{
|
|
if (stato_patrimoniale)
|
|
set_row(_i++, FR("@14gPERDITA DELL'ESERCIZIO IN CORSO@48g%s"), (const char*)sb);
|
|
else
|
|
set_row(_i++, FR("@16gUTILE DELL'ESERCIZIO IN CORSO@48g%s"), (const char*)sb);
|
|
set_row(_i++, FR("@28gTOTALE A PAREGGIO@48g%s"),(const char*)pa);
|
|
}
|
|
_tot_dare = ZERO;
|
|
_tot_avere = ZERO;
|
|
}
|
|
|
|
//per i conti patrimoniali stampo anche lo sbilancio es. precedente
|
|
void TStampa_bilanci::stampa_totali_uno(const real& r1,const real& r2)
|
|
{
|
|
real pareggio;
|
|
real sbilancio = _tot_dare - r1 - (_tot_avere - r2);
|
|
real sbilprec = r2 - r1;
|
|
|
|
if (_prima_volta) //ho finito di stampare le attivita'/passivita'
|
|
_prima_volta = false;
|
|
else
|
|
_seconda_volta = false;
|
|
const bool stato_patrimoniale = _seconda_volta; // cosa mi tocca fare
|
|
_gc_prec_dare = _gc_corr_avere = "";
|
|
_cambiato_conto_1 = true;
|
|
_cambiato_conto_2 = true;
|
|
|
|
const char* dep = "";
|
|
set_row(_i++, (const char*)dep);
|
|
set_row(_i++, (const char*)dep);
|
|
set_row(_i++, (const char*)dep);
|
|
set_row(_i++, (const char*)dep);
|
|
TString pal; total2string(_tot_dare, pal);
|
|
TString bal; total2string(_tot_avere, bal);
|
|
set_row(_i++, FR("@39gTOTALE@48g%s@102gTOTALE@113g%s"),
|
|
(const char*)pal, (const char*)bal);
|
|
if (sbilancio > ZERO) //ho un utile => va stampato tra le passivita'
|
|
{
|
|
sbilprec = -sbilprec;
|
|
pareggio = _tot_avere + sbilancio + sbilprec;
|
|
if (sbilprec != ZERO)
|
|
{
|
|
TString sb; total2string(sbilprec, sb);
|
|
set_row(_i++, FR("@83gSBILANCIO ESERCIZIO PRECEDENTE@113g%s"),
|
|
(const char*)sb);
|
|
}
|
|
TString pal; total2string(sbilancio, pal);
|
|
TString bal; total2string(pareggio, bal);
|
|
if (stato_patrimoniale)
|
|
set_row(_i++, FR("@79gUTILE DELL'ESERCIZIO IN CORSO@113g%s"), (const char*)pal);
|
|
else
|
|
set_row(_i++, FR("@77gPERDITA DELL'ESERCIZIO IN CORSO@113g%s"), (const char*)pal);
|
|
set_row(_i++, FR("@91gTOTALE A PAREGGIO@113g%s"),(const char*)bal);
|
|
}
|
|
else
|
|
if (sbilancio < ZERO) //ho una perdita => va stampato tra le attivita'
|
|
{
|
|
sbilancio = -sbilancio;
|
|
pareggio = _tot_dare + sbilancio + sbilprec;
|
|
if (sbilprec != ZERO)
|
|
{
|
|
TString sb; total2string(sbilprec, sb);
|
|
set_row(_i++, FR("@15gSBILANCIO ESERCIZIO PRECEDENTE@48g%s"),
|
|
(const char*)sb);
|
|
}
|
|
|
|
TString pal; total2string(sbilancio, pal);
|
|
TString bal; total2string(pareggio, bal);
|
|
if (stato_patrimoniale)
|
|
set_row(_i++, FR("@14gPERDITA DELL'ESERCIZIO IN CORSO@48g%s"), (const char*)pal);
|
|
else
|
|
set_row(_i++, FR("@16gUTILE DELL'ESERCIZIO IN CORSO@48g%s"), (const char*)pal);
|
|
set_row(_i++, FR("@28gTOTALE A PAREGGIO@48g%s"),(const char*)bal);
|
|
}
|
|
else //sbilancio es. in corso == 0
|
|
{
|
|
sbilprec = -sbilprec;
|
|
if (sbilprec > ZERO) //va stampato sotto le passivita'
|
|
{
|
|
TString pal; total2string(sbilprec, pal);
|
|
pareggio = _tot_avere + sbilprec;
|
|
TString bal; total2string(pareggio, bal);
|
|
set_row(_i++, FR("@83gSBILANCIO ESERCIZIO PRECEDENTE@113g%s"),
|
|
(const char*)pal);
|
|
set_row(_i++, FR("@96gTOTALE A PAREGGIO@113g%s"), (const char*)bal);
|
|
}
|
|
else
|
|
if (sbilprec < ZERO)
|
|
{
|
|
sbilprec = -sbilprec;
|
|
pareggio = _tot_dare + sbilprec;
|
|
TString pal; total2string(sbilprec, pal);
|
|
TString bal; total2string(pareggio, bal);
|
|
set_row(_i++, FR("@15gSBILANCIO ESERCIZIO PRECEDENTE@48g%s"), (const char*)pal);
|
|
set_row(_i++, FR("@28gTOTALE A PAREGGIO@48g%s"), (const char*)bal);
|
|
}
|
|
}
|
|
_tot_dare = ZERO;
|
|
_tot_avere = ZERO;
|
|
}
|
|
|
|
// Guy: stampa la prima colonna del bilancio di raffronto
|
|
void TStampa_bilanci::stampa_prima_colonna(int g, int c, long s,
|
|
const char* desc, const real& saldo)
|
|
{
|
|
if (_codici) //sono stampate solo le descrizioni dei conti
|
|
{
|
|
if (!_totali)
|
|
{
|
|
if (c != 0 && s == 0)
|
|
set_row(_i, "%-.44s @44g @48g%r", desc, &saldo);
|
|
else
|
|
set_row(_i, "%-.48s @48g%r", desc, &saldo);
|
|
}
|
|
else
|
|
if ( !(c == 0 && s == 0) ) //se cioe' non e' un gruppo
|
|
{
|
|
if (s == 0) //se e' un conto
|
|
set_row(_i, "%-.44s @44g @48g%r", desc, &saldo);
|
|
else
|
|
set_row(_i, "%-.48s @48g%r", desc, &saldo);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (_totali && c == 0 && s == 0l)
|
|
return;
|
|
|
|
set_row(_i, "@0g%3d", g);
|
|
if (c > 0)
|
|
{
|
|
set_row(_i, "@4g%3d", c);
|
|
if (s > 0)
|
|
set_row(_i, "@8g%6ld", s);
|
|
}
|
|
set_row(_i, "@15g%-.31s @48g%r", desc, &saldo);
|
|
}
|
|
set_row(_i, "@67g*");
|
|
}
|
|
|
|
|
|
// Guy: stampa la seconda colonna del bilancio di raffronto
|
|
void TStampa_bilanci::stampa_seconda_colonna(int g, int c, long s, const char* desc, const real& saldo)
|
|
{
|
|
if (_codici) //sono stampate solo le descrizioni dei conti
|
|
{
|
|
if (!_totali)
|
|
{
|
|
set_row(_i, "@67g*@69g%-.47s @114g%r", desc, &saldo);
|
|
}
|
|
else
|
|
{
|
|
if ( !(c == 0 && s == 0) )
|
|
set_row(_i, "@67g*@69g%-.47s @114g%r", desc, &saldo);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (_totali && c == 0 && s == 0l)
|
|
return;
|
|
|
|
set_row(_i, "@67g*@69g%3d ", g);
|
|
if (c > 0)
|
|
{
|
|
set_row(_i, "@73g%3d", c);
|
|
if (s > 0)
|
|
set_row(_i, "@77g%6ld", s);
|
|
}
|
|
set_row(_i, "@84g%-.30s @114g%r", desc, &saldo);
|
|
}
|
|
}
|
|
|
|
print_action TStampa_bilanci::postprocess_page(int file, int counter)
|
|
{
|
|
if (_bilancio == 1)
|
|
{
|
|
if ( _eof1 && _eof2 && _eof3 && _eof4 && _eof5 && _eof6 && _salto_pagina1 )
|
|
return NEXT_PAGE;
|
|
}
|
|
else //bilancio di verifica
|
|
{
|
|
if (_verifica == 3)
|
|
{
|
|
if (_buff == NULL)
|
|
return NEXT_PAGE;
|
|
}
|
|
else
|
|
if (_eof1)
|
|
return NEXT_PAGE;
|
|
}
|
|
return REPEAT_PAGE;
|
|
}
|
|
|
|
TDate TStampa_bilanci::UltimaData(int g, int c, long s, int anno)
|
|
{
|
|
TDate uldata;
|
|
TLocalisamfile saldi(LF_SALDI);
|
|
|
|
saldi.zero();
|
|
if (_annoes != 0)
|
|
saldi.put(SLD_ANNOES, anno);
|
|
saldi.put(SLD_FLSCA, false); // W96SALDI del 05-06-96
|
|
saldi.put(SLD_GRUPPO,g);
|
|
if (c != 0)
|
|
saldi.put(SLD_CONTO, c);
|
|
if (s != 0)
|
|
saldi.put(SLD_SOTTOCONTO, s);
|
|
saldi.read();
|
|
if (saldi.bad())
|
|
saldi.zero();
|
|
uldata = saldi.get(SLD_DATAULMOV);
|
|
|
|
return uldata;
|
|
}
|
|
|
|
bool TStampa_bilanci::user_create()
|
|
{
|
|
open_files(LF_TAB, 0);
|
|
|
|
_stampa_width = 132;
|
|
_rel = new TRelation(LF_CLIFO);
|
|
_cur = new TCursor (_rel,"",3);
|
|
_mov = new TLocalisamfile(LF_MOV);
|
|
_rmov = new TLocalisamfile(LF_RMOV);
|
|
_clifo = new TLocalisamfile(LF_CLIFO);
|
|
_com = new TLocalisamfile(LF_COMUNI);
|
|
_pcn = new TLocalisamfile(LF_PCON);
|
|
_saldi = new TLocalisamfile(LF_SALDI);
|
|
_nditte = new TLocalisamfile(LF_NDITTE);
|
|
_anag = new TLocalisamfile(LF_ANAG);
|
|
_caus = new TLocalisamfile(LF_CAUSALI);
|
|
_d = new TParagraph_string("",29);
|
|
_sort = NULL;
|
|
_tmp_saldi_att = NULL;
|
|
_tmp_saldi_pass = NULL;
|
|
_tmp_saldi_costi = NULL;
|
|
_tmp_saldi_ricavi = NULL;
|
|
_tmp_saldi_conti_uno = NULL;
|
|
_tmp_saldi_conti_due = NULL;
|
|
return true;
|
|
}
|
|
|
|
bool TStampa_bilanci::user_destroy()
|
|
{
|
|
delete _rel;
|
|
delete _cur;
|
|
delete _com;
|
|
delete _pcn;
|
|
delete _mov;
|
|
delete _rmov;
|
|
delete _clifo;
|
|
delete _saldi;
|
|
delete _nditte;
|
|
delete _anag;
|
|
delete _caus;
|
|
delete _d;
|
|
|
|
if (_tmp_saldi_att) delete _tmp_saldi_att;
|
|
if (_tmp_saldi_pass) delete _tmp_saldi_pass;
|
|
if (_tmp_saldi_costi) delete _tmp_saldi_costi;
|
|
if (_tmp_saldi_ricavi) delete _tmp_saldi_ricavi;
|
|
if (_tmp_saldi_conti_uno) delete _tmp_saldi_conti_uno;
|
|
if (_tmp_saldi_conti_due) delete _tmp_saldi_conti_due;
|
|
return true;
|
|
}
|
|
|
|
void TStampa_bilanci::leggi_pcon()
|
|
{
|
|
TRelation rel(LF_PCON);
|
|
TCursor cur(&rel);
|
|
const TRectype& pconti = rel.curr();
|
|
|
|
const long items = cur.items();
|
|
cur.freeze();
|
|
|
|
TToken_string gc(10);
|
|
for (cur = 0L; cur.pos() < items; ++cur)
|
|
{
|
|
const int gruppo = pconti.get_int(PCN_GRUPPO);
|
|
const int conto = pconti.get_int(PCN_CONTO);
|
|
const long sottoconto = pconti.get_long(PCN_SOTTOCONTO);
|
|
if ( (sottoconto == 0l) && (conto != 0) ) //si tratta di un conto
|
|
{
|
|
const char tipocf = pconti.get_char(PCN_TMCF);
|
|
if ( tipocf == 'C' && (_situazione.empty() || _situazione == "C"))
|
|
{
|
|
gc.add(gruppo,0);
|
|
gc.add(conto,1);
|
|
_clienti.add(gc);
|
|
}
|
|
else
|
|
if ( tipocf == 'F' && (_situazione.empty() || _situazione == "F"))
|
|
{
|
|
gc.add(gruppo,0);
|
|
gc.add(conto,1);
|
|
_fornitori.add(gc);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void TStampa_bilanci::stampa_un_bilancio(const TMask& m)
|
|
{
|
|
if (_bilancio == 1) //bilancio a sezioni contrapposte
|
|
{
|
|
printer().footerlen(3);
|
|
_totali = m.get_bool(F_TOTALI);
|
|
_codici = m.get_bool(F_CODICI);
|
|
_saldo = m.get_bool(F_SALDO);
|
|
_tipo_stampa = m.get_int(F_STAMPA);
|
|
_annoes = m.get_int(F_ANNO);
|
|
_al = m.get(F_DATALIM);
|
|
if (_annoes == 0)
|
|
_annoes = esercizi().exist(_al) ? esercizio(_al).codice() : esercizio(TDate(TODAY)).codice();
|
|
_dataini = esercizio(_annoes).inizio();
|
|
if (!_al.ok())
|
|
_al = esercizio(_annoes).fine();
|
|
_print_exercise = (_tipo_stampa == 1);
|
|
bil_sez_contr();
|
|
}
|
|
else //bilancio di verifica (tipo 1,2,3)
|
|
{
|
|
printer().footerlen(5);
|
|
_stampa_width = (m.get_int(F_MODULO) == 1) ? 132 : 148; //perche' questo e' in realta' il margine dx (vedi es. di stampa AS/400)
|
|
|
|
_verifica = m.get_int(F_VERIFICA); //tipo di bilancio di verifica da stampare
|
|
_print_full_code = _verifica == 1 && m.get_bool(F_PRINT_FULL_CODE);
|
|
_tipo_stampa = m.get_int(F_STAMPA);
|
|
|
|
if ((_verifica == 1) || (_verifica == 2)) //bilancio di verifica:1bilancio,2saldi mastro
|
|
{
|
|
_stampav = atoi(m.get(F_STAMPAV));
|
|
bil_verifica();
|
|
}
|
|
else
|
|
{
|
|
_situazione = m.get(F_SITUAZIONE);
|
|
_stampac = atoi(m.get(F_STAMPAC));
|
|
_ordinamento = atoi(m.get(F_ORDINAMENTO));
|
|
|
|
if (_situazione.not_empty())
|
|
_cur->setfilter(format("TIPOCF=\"%s\"",(const char*)_situazione));
|
|
else
|
|
_cur->setfilter("");
|
|
|
|
_clienti.destroy();
|
|
_fornitori.destroy();
|
|
leggi_pcon();
|
|
crea_sort_clifo(); // Crea la sua _prog
|
|
_sort->endsort();
|
|
}
|
|
}
|
|
print();
|
|
}
|
|
|
|
bool TStampa_bilanci::set_print(int)
|
|
{
|
|
#ifdef CONT_SEP
|
|
TMask m ("np0300a");
|
|
#else
|
|
TMask m ("cg1500a");
|
|
#endif
|
|
|
|
m.set_handler (F_VERIFICA, verifica_handler);
|
|
m.set_handler (F_BILANCIO, mask_bilancio);
|
|
m.set_handler (F_STAMPA, mask_bilancio);
|
|
m.set_handler (F_DATALIM, mask_datalim);
|
|
m.set_handler (F_DATAINI, mask_dataini);
|
|
m.set_handler (F_ANNO, mask_anno);
|
|
m.set(F_NORMALI, "X");
|
|
|
|
while (m.run() == K_ENTER)
|
|
{
|
|
_annoes = m.get_int(F_ANNO);
|
|
_bilancio = m.get_int(F_BILANCIO);
|
|
_data = m.get(F_DATASTAMPA);
|
|
_stampa_mov_prov = m.get_bool(F_NORMALI) ? 0x1 : 0; // qui
|
|
_stampa_mov_prov |= m.get_bool(F_PROVVM) ? 0x2 : 0; // qui
|
|
_stampa_mov_prov |= m.get_bool(F_PROVVB) ? 0x4 : 0; // qui
|
|
_stampa_mov_prov |= m.get_bool(F_PROVVC) ? 0x8 : 0; // qui
|
|
_quadratura = m.get_bool(F_QUADRATURA);
|
|
_hide_clifo = m.get_bool(F_HIDE_CLIFO);
|
|
_noseparator = m.get_bool(F_SEPARATOR);
|
|
_dal = m.get_date(F_DATAINI);
|
|
_al = m.get_date(F_DATALIM);
|
|
if (_annoes != 0)
|
|
{
|
|
if (!_dal.ok())
|
|
_dal = esercizi().esercizio(_annoes).inizio();
|
|
if (!_al.ok())
|
|
_al = esercizi().esercizio(_annoes).fine();
|
|
}
|
|
|
|
_tipo_data = (_annoes == 0 ? Registrazione : (m.get_bool(F_COMPCR) ? CostiRicavi : Competenza));
|
|
#ifdef CONT_SEP
|
|
_cont_sep = m.get(F_CONTSEP);
|
|
#endif
|
|
|
|
//qui getti le terne dei 2 conti da mettere in bill_from e bill_to con un metodo dei TBill
|
|
_bill_from.get(m, F_DA_GRUPPO, F_DA_CONTO, F_DA_SOTTOCONTO);
|
|
_bill_to.get(m, F_A_GRUPPO, F_A_CONTO, F_A_SOTTOCONTO);
|
|
|
|
//se non e' stato riempito il gruppo TO, si mette di default il max del gr/co/so
|
|
if (_bill_to.gruppo() == 0)
|
|
_bill_to.set(999, 999, 999999L);
|
|
else
|
|
{ //se invece il gruppo c'e' ma il conto no...
|
|
if (_bill_to.conto() == 0)
|
|
_bill_to.set(_bill_to.gruppo(), 999, 999999L); //il gruppo e' quello selezionato
|
|
else
|
|
{
|
|
if (_bill_to.sottoconto() == 0) //se mancasse solo il sottoconto..
|
|
_bill_to.set(_bill_to.gruppo(), _bill_to.conto(), 999999L);
|
|
}
|
|
}
|
|
|
|
stampa_un_bilancio(m);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
TRectype& look_com (const char* cod, TLocalisamfile *comuni)
|
|
{
|
|
comuni->zero();
|
|
comuni->put(COM_COM, cod);
|
|
comuni->read();
|
|
if (comuni->bad())
|
|
comuni->zero();
|
|
|
|
return comuni->curr();
|
|
}
|
|
|
|
void TStampa_bilanci::get_dati_ditta()
|
|
{
|
|
TLocalisamfile nditte(LF_NDITTE);
|
|
TLocalisamfile anag(LF_ANAG);
|
|
TString codanagr;
|
|
TString tipoa;
|
|
|
|
nditte.zero();
|
|
nditte.put(NDT_CODDITTA, get_firm());
|
|
nditte.read();
|
|
|
|
if (nditte.bad()) nditte.zero();
|
|
|
|
codanagr = nditte.get(NDT_CODANAGR);
|
|
tipoa = nditte.get(NDT_TIPOA);
|
|
_ragsoc = nditte.get(NDT_RAGSOC);
|
|
|
|
anag.setkey(1);
|
|
anag.zero();
|
|
anag.put (ANA_TIPOA, tipoa);
|
|
anag.put (ANA_CODANAGR, codanagr);
|
|
anag.read();
|
|
if (anag.bad()) anag.zero();
|
|
|
|
_cofi = anag.get(ANA_COFI);
|
|
_paiva = anag.get(ANA_PAIV);
|
|
_comunefis = anag.get(ANA_COMRF);
|
|
|
|
if (_comunefis.empty())
|
|
_comunefis = anag.get(ANA_COMRES);
|
|
|
|
TRectype dep = look_com (_comunefis, _com);
|
|
|
|
_comunefis = dep.get(COM_DENCOM);
|
|
_provfis = dep.get(COM_PROVCOM);
|
|
_cap = dep.get(COM_CAPCOM);
|
|
if (_comunefis.empty())
|
|
{
|
|
_viafis = anag.get(ANA_INDRF);
|
|
_viafis.rtrim();
|
|
_viafis << " " << anag.get (ANA_CIVRF);
|
|
}
|
|
else
|
|
{
|
|
_viafis = anag.get(ANA_INDRES);
|
|
_viafis.rtrim();
|
|
_viafis << " " << anag.get (ANA_CIVRES);
|
|
}
|
|
}
|
|
|
|
int TStampa_bilanci::stampa_intestazione_ditta()
|
|
{
|
|
int r = 1;
|
|
TString codice_ditta;
|
|
TString riga(_stampa_width);
|
|
|
|
get_dati_ditta();
|
|
codice_ditta << get_firm();
|
|
|
|
set_header (r++, "%s %s %s %s %s %s %s", TR("Ditta"), (const char*)codice_ditta,
|
|
(const char*)_ragsoc, (const char*)_viafis,
|
|
(const char*)_cap, (const char*)_comunefis,
|
|
(const char*)_provfis);
|
|
printer().setdate(_data);
|
|
riga = TR("Data") ; riga << " @> " << TR("Pag.") << " @#";
|
|
riga.right_just(_stampa_width-10);
|
|
|
|
//_stampa_mov_provv(1=normale,2=globale,3=solo provvisori)
|
|
//l'uso della overwrite e' una vera vaccata!
|
|
riga.overwrite (format("%s %s %s %s", TR("Partita iva"), (const char*)_paiva, TR("Codice fiscale"), (const char*)_cofi));
|
|
|
|
set_header (r++, "%s", (const char*) riga);
|
|
|
|
if (_stampa_mov_prov > 0x1)
|
|
{
|
|
TString tipoprovv;
|
|
|
|
if ((_stampa_mov_prov & 0x1))
|
|
tipoprovv << TR("Movimenti : Normali");
|
|
if (_stampa_mov_prov > 0x1)
|
|
tipoprovv << TR(" Provvisori :");
|
|
if (_stampa_mov_prov & 0x2)
|
|
tipoprovv << TR(" Manuali");
|
|
if (_stampa_mov_prov & 0x4)
|
|
tipoprovv << TR(" Competenza costi/ricavi");
|
|
if (_stampa_mov_prov & 0x8)
|
|
tipoprovv << TR(" Cespiti");
|
|
|
|
riga.cut(0);
|
|
riga.overwrite(tipoprovv, (_stampa_width - tipoprovv.len()) /2);
|
|
|
|
set_header(r++, "%s", (const char*)riga);
|
|
}
|
|
|
|
return r;
|
|
}
|
|
|
|
void TStampa_bilanci::preprocess_header()
|
|
{
|
|
int r;
|
|
|
|
reset_header();
|
|
r = stampa_intestazione_ditta();
|
|
|
|
if (_bilancio == 1) //bilancio a sezioni contrapposte
|
|
{
|
|
TString riga (132);
|
|
TString intestazione(TR("STAMPA BILANCIO A SEZIONI CONTRAPPOSTE"));
|
|
|
|
if (_tipo_data == Registrazione)
|
|
intestazione << ' ' << TR("PER CASSA");
|
|
else
|
|
if (_tipo_data == CostiRicavi)
|
|
intestazione << ' ' << TR("PER COMPETENZA COSTI/RICAVI");
|
|
set_header(r, intestazione);
|
|
if (_tipo_stampa == 1)
|
|
set_header(r,"@90g%s %s %s %s", TR("dalla data"), (const char*) _dataini.string(), TR("alla data"),
|
|
(const char*) _al.string());
|
|
else
|
|
if (_tipo_stampa == 2)
|
|
set_header(r,FR("@102gall'ultima immissione Es. %d"), _annoes);
|
|
//modifica del 20/04/1995
|
|
if (_print_exercise)
|
|
{
|
|
const TEsercizio & es = esercizio(_annoes);
|
|
|
|
set_header(++r, "@101g%s %s %s", TR("Esercizio"), (const char*)es.inizio().string(), (const char*)es.fine().string()); /**/
|
|
}
|
|
riga.fill('_');
|
|
set_header(++r, (const char*)riga);
|
|
riga = "";
|
|
set_header(++r, (const char*)riga);
|
|
}
|
|
else // bilancio di verifica
|
|
{
|
|
TString riga (_stampa_width);
|
|
TString intestazione;
|
|
|
|
if (_verifica == 1)
|
|
intestazione = TR("STAMPA BILANCIO DI VERIFICA");
|
|
else
|
|
if (_verifica == 2)
|
|
intestazione = TR("STAMPA SALDI DI MASTRO");
|
|
else
|
|
{
|
|
if (_situazione == "C")
|
|
intestazione = TR("SITUAZIONE CONTABILE CLIENTI");
|
|
else
|
|
if (_situazione == "F")
|
|
intestazione = TR("SITUAZIONE CONTABILE FORNITORI");
|
|
else
|
|
intestazione = TR("SITUAZIONE CLIENTI/FORNITORI");
|
|
}
|
|
if (_tipo_data == Registrazione)
|
|
intestazione << ' ' << TR("PER CASSA");
|
|
else
|
|
if (_tipo_data == CostiRicavi)
|
|
intestazione << ' ' << TR("PER COMPETENZA COSTI/RICAVI");
|
|
set_header(r, intestazione);
|
|
if (_tipo_stampa == 1)
|
|
{
|
|
set_header(r,"@90g%s %s %s %s", TR("dalla data"), (const char*) _dal.string(), TR("alla data"),
|
|
(const char*) _al.string());
|
|
//modifica del 20/04/1995
|
|
if (_annoes != 0) //se l'anno e' 0 non si considera la competenza
|
|
{
|
|
const TEsercizio & es = esercizio(_annoes);
|
|
|
|
set_header(++r, "@101g%s %s %s", TR("Esercizio"), (const char*)es.inizio().string(), (const char*)es.fine().string()); /**/
|
|
}
|
|
}
|
|
else
|
|
if (_tipo_stampa == 2)
|
|
{
|
|
const TEsercizio & es = esercizio(_annoes);
|
|
|
|
set_header(r,FR("@102gall'ultima immissione Es. %d"), _annoes);
|
|
set_header(++r, "@101g%s %s %s", TR("Esercizio"), (const char*)es.inizio().string(), (const char*)es.fine().string()); /**/
|
|
}
|
|
|
|
if ((_verifica == 1) || (_verifica == 2))
|
|
{
|
|
if (_stampav == 1)
|
|
set_header(++r, "@107g%s", TR("Tutti i conti movimentati"));
|
|
else
|
|
if (_stampav == 2)
|
|
set_header(++r, "@112g%s", TR("Conti con saldo <> 0"));
|
|
else
|
|
set_header(++r, "@119g%s", TR("Tutti i conti"));
|
|
}
|
|
else
|
|
{
|
|
if (_stampac == 1)
|
|
set_header(++r, "@107g%s", TR("Tutti i conti movimentati"));
|
|
else
|
|
set_header(++r, "@112g%s", TR("Conti con saldo <> 0"));
|
|
}
|
|
riga.fill('_');
|
|
set_header(++r, (const char*)riga);
|
|
r++;
|
|
|
|
TString h;
|
|
|
|
if (_print_full_code)
|
|
h << "@46g!@55g";
|
|
else
|
|
h << "@7g!@46g!@55g";
|
|
|
|
if ( ((_dal == _dataini) && (_tipo_stampa == 1)) || (_tipo_stampa != 1))
|
|
{
|
|
if (_tipo_stampa == 1 && _dal == _dataini)
|
|
h << TR("MOVIMENTI DI APERTURA");
|
|
else
|
|
h << TR(" SALDO INIZIALE");
|
|
}
|
|
else
|
|
if (_tipo_stampa == 1)
|
|
h << TR("PROGRESSIVI PRECEDENTI");
|
|
h << "@80g!@88g";
|
|
h << TR("MOVIMENTI DEL PERIODO");
|
|
set_header(r, h);
|
|
if ( (_verifica == 1)||(_verifica == 3) )
|
|
set_header(r,"@16g!");
|
|
|
|
set_header(r,"@114g!");
|
|
if (_stampa_width != 132)
|
|
{
|
|
h = "@129g" ;
|
|
h << TR("SALDO");
|
|
h << "@148g!";
|
|
set_header(r, h);
|
|
}
|
|
r++;
|
|
|
|
if ( (_verifica == 1)||(_verifica == 3))
|
|
{
|
|
if (_print_full_code)
|
|
set_header(r,FR("@2gcodice conto !@46g!@47g%.67s@80g!@83g@114g!"),(const char*)riga);
|
|
else
|
|
set_header(r,FR("@2gcod. ! ultima !@46g!@47g%.67s@80g!@83g@114g!"),(const char*)riga);
|
|
if (_stampa_width == 132)
|
|
set_header(r,FR("@121gSALDO"));
|
|
else
|
|
set_header(r,"%.33s@148g!",(const char*)riga);
|
|
r++;
|
|
|
|
if (_print_full_code)
|
|
set_header(r,FR("@2g ! denominazione@46g!@53gDare@63g!@69gAvere@80g!@87gDare@97g!@103gAvere@114g!"));
|
|
else
|
|
set_header(r,FR("@2gconto! data ! denominazione@46g!@53gDare@63g!@69gAvere@80g!@87gDare@97g!@103gAvere@114g!"));
|
|
if (_stampa_width != 132)
|
|
set_header(r,FR("@121gDare@131g!@137gAvere@148g!"));
|
|
r++;
|
|
}
|
|
else
|
|
{
|
|
set_header(r,FR("@2gcod. !@46g!@47g%.67s@80g!@83g@114g!"),(const char*)riga);
|
|
if (_stampa_width == 132)
|
|
set_header(r,FR("@121gSALDO"));
|
|
else
|
|
set_header(r,"%.33s@148g!",(const char*)riga);
|
|
r++;
|
|
|
|
set_header(r,FR("@1gmastro!descrizione@46g!@53gDare@63g!@69gAvere@80g!@87gDare@97g!@103gAvere@114g!"));
|
|
if (_stampa_width != 132)
|
|
set_header(r, FR("@121gDare@131g!@137gAvere@148g!"));
|
|
r++;
|
|
}
|
|
set_header(r, (const char*)riga);
|
|
if (_stampa_width != 132)
|
|
set_header(r,"@148g!");
|
|
}
|
|
}
|
|
|
|
#ifdef CONT_SEP
|
|
int np0300(int argc, char* argv[])
|
|
#else
|
|
int cg1500(int argc, char* argv[])
|
|
#endif
|
|
{
|
|
TStampa_bilanci a;
|
|
a.run(argc, argv, TR("Stampa bilanci"));
|
|
return 0;
|
|
}
|