2003-05-05 14:32:23 +00:00
|
|
|
#include <config.h>
|
|
|
|
#include <currency.h>
|
|
|
|
#include <printapp.h>
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
|
|
#include "../cg/cgsaldac.h"
|
|
|
|
#include "../cg/cglib02.h"
|
|
|
|
#include "sc2.h"
|
|
|
|
#include "sc2201.h"
|
|
|
|
#include "sc2600.h"
|
|
|
|
|
|
|
|
#include <clifo.h>
|
|
|
|
#include <nditte.h>
|
|
|
|
#include <pconti.h>
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Stampa prospetto scadenze
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define NUMERO_FASCE 5
|
|
|
|
#define LIMITI {30,60,90,120,150,30,60,90,120,150}
|
|
|
|
|
2006-01-09 01:15:53 +00:00
|
|
|
enum tipo_st {clienti=0, fornitori=1};
|
2003-05-05 14:32:23 +00:00
|
|
|
|
|
|
|
class TLineTotal : public TObject //Oggetto di base per i TAssoc_array dei totali
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
real _s1;// Scaglione 1 scaduto
|
|
|
|
real _s2;// Scaglione 2 scaduto
|
|
|
|
real _s3;// Scaglione 3 scaduto
|
|
|
|
real _s4;// Scaglione 4 scaduto
|
|
|
|
real _s5;// Scaglione 5 scaduto
|
|
|
|
real _s6;// Scaglione 6 scaduto
|
|
|
|
real _ns1;// Scaglione 1 non scaduto
|
|
|
|
real _ns2;// Scaglione 2 non scaduto
|
|
|
|
real _ns3;// Scaglione 3 non scaduto
|
|
|
|
real _ns4;// Scaglione 4 non scaduto
|
|
|
|
real _ns5;// Scaglione 5 non scaduto
|
|
|
|
real _ns6;// Scaglione 6 non scaduto
|
|
|
|
real _es; // esposto
|
|
|
|
real _sl; // saldo
|
|
|
|
|
|
|
|
virtual TObject* dup() const { return new TLineTotal(*this); }
|
|
|
|
virtual TLineTotal & copy(const TLineTotal & l);
|
|
|
|
TLineTotal(const TLineTotal* l) { copy(*l); }
|
|
|
|
TLineTotal();
|
|
|
|
};
|
|
|
|
|
|
|
|
TLineTotal & TLineTotal::copy(const TLineTotal & l)
|
|
|
|
{
|
|
|
|
_s1=l._s1;
|
|
|
|
_s2=l._s2;
|
|
|
|
_s3=l._s3;
|
|
|
|
_s4=l._s4;
|
|
|
|
_s5=l._s5;
|
|
|
|
_s6=l._s6;
|
|
|
|
_ns1=l._ns1;
|
|
|
|
_ns2=l._ns2;
|
|
|
|
_ns3=l._ns3;
|
|
|
|
_ns4=l._ns4;
|
|
|
|
_ns5=l._ns5;
|
|
|
|
_ns6=l._ns6;
|
|
|
|
_es=l._es;
|
|
|
|
_sl=l._sl;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
TLineTotal::TLineTotal()
|
|
|
|
{
|
|
|
|
_s1=ZERO;
|
|
|
|
_s2=ZERO;
|
|
|
|
_s3=ZERO;
|
|
|
|
_s4=ZERO;
|
|
|
|
_s5=ZERO;
|
|
|
|
_s6=ZERO;
|
|
|
|
_ns1=ZERO;
|
|
|
|
_ns2=ZERO;
|
|
|
|
_ns3=ZERO;
|
|
|
|
_ns4=ZERO;
|
|
|
|
_ns5=ZERO;
|
|
|
|
_ns6=ZERO;
|
|
|
|
_es=ZERO;
|
|
|
|
_sl=ZERO;
|
|
|
|
}
|
|
|
|
|
|
|
|
class TProspettoScadenze : public TPrintapp
|
|
|
|
{
|
|
|
|
TRelation *_rel1, *_rel2; // Relazioni di lavoro...
|
|
|
|
int _cur1, _cur2, // Identificatori dei cursori di lavoro...
|
|
|
|
_cur3, _cur4;
|
|
|
|
TSelection_ext_mask *_m;
|
|
|
|
TLocalisamfile *_scad,*_pagsca;
|
|
|
|
tipo_st _tipost; // Tipo di stampa impostato
|
|
|
|
bool _end_printed,
|
|
|
|
_stvaluta,
|
|
|
|
_ordcod, // VERO=ordine per codice, FALSO=ordine per ragione sociale
|
|
|
|
_sinfasce,
|
|
|
|
_nsinfasce;
|
|
|
|
TString _anno,_numdoc,_protiva,_datadoc,_codval,
|
|
|
|
_cod, _cod_pre, _des, _des_pre;
|
|
|
|
TDate _limop, _limscad, _datas, _limbf; // Data limite operazione, data limite scaduto e data di stampa
|
|
|
|
int _gcr, // Giorni per Calcolo Rischio (valido solo per stampa clienti)
|
|
|
|
_sfasce,
|
|
|
|
_nsfasce;
|
|
|
|
real _unsnc,_uns; // Unassigned per partita.
|
|
|
|
TArray _conti_cf, // array per conti mastro
|
|
|
|
_t, // Array per i totali
|
|
|
|
_ns_date, // Date per non scaduto
|
|
|
|
_s_date; // Date per lo scaduto
|
|
|
|
|
|
|
|
static TString _last_game;
|
|
|
|
static bool fil_function(const TRelation *);
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual bool preprocess_page(int file, int counter);
|
|
|
|
virtual bool preprocess_print(int file, int counter);
|
|
|
|
virtual print_action postprocess_print(int file, int counter);
|
|
|
|
virtual print_action postprocess_page(int file, int counter);
|
|
|
|
virtual void preprocess_header() {};
|
|
|
|
virtual bool user_create();
|
|
|
|
virtual bool user_destroy();
|
|
|
|
virtual bool set_print(int);
|
|
|
|
virtual void set_page (int file, int counter);
|
2006-01-09 01:15:53 +00:00
|
|
|
void print_totali_rows(int nriga, bool what);
|
2003-05-05 14:32:23 +00:00
|
|
|
void print_totali(int& nriga);
|
|
|
|
void print_header();
|
2006-01-09 01:15:53 +00:00
|
|
|
int calc_last_column();
|
|
|
|
void update_totals(bool what, real& esp,
|
2003-05-05 14:32:23 +00:00
|
|
|
real& s1,real& s2,real& s3,real& s4,real& s5, real& s6,
|
|
|
|
real& ns1,real& ns2,real& ns3,real& ns4,real& ns5, real& ns6);
|
|
|
|
void compute_unassigned(TPartita& p);
|
|
|
|
void compute_all(TPartita& p, TBill& bill);
|
|
|
|
void print_real(TString& dest, const real& num);
|
|
|
|
void riempi_conti_mastro(const char cf);
|
|
|
|
void calcola_saldo();
|
|
|
|
TProspettoScadenze();
|
|
|
|
};
|
|
|
|
|
|
|
|
TString TProspettoScadenze::_last_game;
|
|
|
|
|
|
|
|
inline TProspettoScadenze& app() {return (TProspettoScadenze&)main_app();}
|
|
|
|
|
|
|
|
void TProspettoScadenze::print_real(TString& dest, const real& num)
|
|
|
|
{
|
|
|
|
const bool stampa_in_valuta = _stvaluta && !_codval.blank();
|
|
|
|
const TString& val = stampa_in_valuta ? _codval : EMPTY_STRING;
|
|
|
|
const TCurrency cur(num, val);
|
|
|
|
dest = cur.string(TRUE);
|
2006-01-09 01:15:53 +00:00
|
|
|
dest.right_just(10);
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TProspettoScadenze::fil_function(const TRelation *r)
|
|
|
|
{
|
|
|
|
TRectype& part = r->curr(LF_PARTITE);
|
|
|
|
|
|
|
|
TString80 key;
|
|
|
|
key.format("%03d%03d%06ld%4d",
|
|
|
|
part.get_int(PART_GRUPPO), part.get_int(PART_CONTO),
|
|
|
|
part.get_long(PART_SOTTOCONTO), part.get_int(PART_ANNO));
|
|
|
|
key << part.get(PART_NUMPART);
|
|
|
|
|
|
|
|
const bool rt = key != _last_game;
|
|
|
|
if (rt)
|
|
|
|
_last_game = key;
|
|
|
|
return rt;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TProspettoScadenze::update_totals(bool what, real& esp,
|
|
|
|
real& s1, real& s2, real& s3, real& s4, real& s5, real& s6,
|
|
|
|
real& ns1, real& ns2, real& ns3, real& ns4, real& ns5, real& ns6)
|
|
|
|
{
|
|
|
|
TAssoc_array& a = (TAssoc_array&) _t[what];
|
|
|
|
TLineTotal *ll = (TLineTotal *) a.objptr(_codval);
|
|
|
|
if (ll == NULL)
|
|
|
|
{
|
|
|
|
ll = new TLineTotal;
|
|
|
|
a.add(_codval, ll);
|
|
|
|
}
|
|
|
|
ll->_s1 += s1;
|
|
|
|
ll->_s2 += s2;
|
|
|
|
ll->_s3 += s3;
|
|
|
|
ll->_s4 += s4;
|
|
|
|
ll->_s5 += s5;
|
|
|
|
ll->_s6 += s6;
|
|
|
|
ll->_ns1 += ns1;
|
|
|
|
ll->_ns2 += ns2;
|
|
|
|
ll->_ns3 += ns3;
|
|
|
|
ll->_ns4 += ns4;
|
|
|
|
ll->_ns5 += ns5;
|
|
|
|
ll->_ns6 += ns6;
|
|
|
|
ll->_es += esp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TProspettoScadenze::compute_unassigned(TPartita& p)
|
|
|
|
{
|
|
|
|
TRecord_array& ra = p.unassigned();
|
|
|
|
|
|
|
|
_uns = ZERO; _unsnc = ZERO;
|
|
|
|
for (int r = ra.last_row(); r > 0; r = ra.pred_row(r))
|
|
|
|
{
|
|
|
|
const TRectype& rec = ra.row(r);
|
|
|
|
const TRiga_partite& sum = p.riga(rec.get_int(PAGSCA_NRIGP));
|
|
|
|
const char * field = (_stvaluta && sum.in_valuta() ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO);
|
|
|
|
if (sum.get_int(PART_TIPOMOV) == 2) // Is it a credit note ?
|
|
|
|
_unsnc += rec.get_real(field);
|
|
|
|
else
|
|
|
|
_uns += rec.get_real(field);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TProspettoScadenze::compute_all(TPartita& p, TBill& bill)
|
|
|
|
{
|
|
|
|
real residuo, s1,s2,s3,s4,s5,s6,ns1,ns2,ns3,ns4,ns5,ns6,res_pagati,esposto;
|
|
|
|
compute_unassigned(p);
|
|
|
|
for (int r = p.last(); r > 0; r = p.pred(r)) // Browse all rows (partite)
|
|
|
|
{
|
|
|
|
const TRiga_partite& rp = p.riga(r);
|
|
|
|
// se la data di registrazione della partita ' > di _limop (data lim operazione)
|
|
|
|
// non deve scorrere le scadenze
|
|
|
|
const TDate data_reg(rp.get_date(PART_DATAREG));
|
|
|
|
if (data_reg > _limop) continue;
|
|
|
|
for (int n=rp.rate(); n > 0; n--) // Browse all rows (scadenze)
|
|
|
|
{
|
|
|
|
const TRiga_scadenze& rs = rp.rata(n);
|
|
|
|
const TDate d(rs.get_date(SCAD_DATASCAD));
|
|
|
|
const char* field = (_stvaluta && rs.in_valuta()) ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO;
|
|
|
|
const char* sfield = (_stvaluta && rs.in_valuta()) ? SCAD_IMPORTOVAL : SCAD_IMPORTO;
|
|
|
|
const char ssez = rp.sezione();
|
|
|
|
|
|
|
|
TImporto scd,pag,bf,work_imp;
|
|
|
|
scd += TImporto(ssez,rs.get_real(sfield)); // Importo in scadenza...
|
|
|
|
pag += rs.importo_pagato(_stvaluta); // Quanto e' stato pagato per questa scadenza?
|
|
|
|
|
|
|
|
// Scorre le righe di pagamento per trovare la riga corripondente alla prima data pagamento
|
|
|
|
// di questa rata. Motivo: il primo pagamento delle rata corrente, effettuato tramite effetto
|
|
|
|
// (ai fini del calcolo B.F.) deve essere considerato con la data scadenza
|
|
|
|
const int lst = rs.last();
|
|
|
|
int prima_riga_pagamento = -1;
|
|
|
|
TDate first_date;// data relativa alla prima riga di pagamento
|
|
|
|
for (int pp = rs.first(); pp <= lst; pp = rs.succ(pp))
|
|
|
|
{
|
|
|
|
const TRiga_partite& sum = p.riga(pp);
|
|
|
|
TDate current_date(sum.get_date(PART_DATAPAG));
|
|
|
|
int tipo_pag = rs.get_int(SCAD_TIPOPAG);
|
|
|
|
if (tipo_pag>=2 && tipo_pag<=7) //Incasso tramite effetto
|
|
|
|
if (prima_riga_pagamento==-1 || first_date > current_date)
|
|
|
|
{
|
|
|
|
first_date = current_date;
|
|
|
|
prima_riga_pagamento = pp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (pp = rs.first(); pp <= lst; pp = rs.succ(pp)) // Browse all rows (pagamenti)
|
|
|
|
{
|
|
|
|
const TRectype pg = rs.row(pp);
|
|
|
|
const TRiga_partite& sum = p.riga(pp);
|
|
|
|
const char sez = sum.sezione();
|
|
|
|
const int tipomov = sum.get_int(PART_TIPOMOV);
|
|
|
|
// se tipomov e' 2 (Nota di credito assegnata)
|
|
|
|
// storna da scdz. In entrambi i casi si ha l'operatore +=, perche' nel TImporto e' gia'
|
|
|
|
// compresa la sezione opposta
|
|
|
|
if (tipomov==2)
|
|
|
|
{
|
|
|
|
work_imp = TImporto(sez,pg.get_real(field));
|
|
|
|
scd += work_imp;
|
|
|
|
pag -= work_imp;
|
|
|
|
}
|
|
|
|
if ((tipomov==3 || tipomov==5) && _tipost==clienti && _gcr!=0)
|
|
|
|
{
|
|
|
|
TDate data_pag(sum.get_date(PART_DATAPAG));
|
|
|
|
int tipo_pag = rs.get_int(SCAD_TIPOPAG);
|
|
|
|
if (tipo_pag>=2 && tipo_pag<=7 && data_pag.ok()) //Incasso tramite effetto
|
|
|
|
{
|
|
|
|
if (prima_riga_pagamento > -1 && prima_riga_pagamento == pp)
|
|
|
|
data_pag = d; // Se e' il primo pagamento(in ordine di data) di questa rata
|
|
|
|
// prende la data di scadenza relativa.
|
|
|
|
if (data_pag >= _limbf) // && data_pag <= _limscad)
|
|
|
|
bf += TImporto(sez,pg.get_real(field));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
char norm='D';
|
|
|
|
if (_tipost == fornitori)
|
|
|
|
norm = 'A';
|
|
|
|
pag.normalize((norm=='D') ? 'A' : 'D'); scd.normalize(norm); bf.normalize((norm=='D') ? 'A' : 'D');
|
|
|
|
real res,a,b; a = pag.valore(); b = scd.valore(); //buonf += bf.valore();
|
|
|
|
res = b - a;
|
|
|
|
if (_uns > ZERO) // Rettifica i pagamenti con i non assegnati (calcolo sul residuo: scadenza-pagamento)
|
|
|
|
{
|
|
|
|
real gap = (_uns > res ? res : _uns); // questo e' quanto manca per completare questa scadenza
|
|
|
|
a += gap;
|
|
|
|
_uns -= gap; // aggiorna la cache..
|
|
|
|
}
|
|
|
|
if (_unsnc > ZERO) // Rettifica le scadenze con le N.C non assegnate.
|
|
|
|
{
|
|
|
|
real gap = (_unsnc > b ? b : _unsnc);
|
|
|
|
b -= gap;
|
|
|
|
_unsnc -= gap;
|
|
|
|
}
|
|
|
|
res = b - a; // Scadenze - pagati = scaduto per questo gruppo di rate
|
|
|
|
if (b == ZERO) // Se le scadenze sono a zero, vuol dire che sono state stornate
|
|
|
|
res = ZERO; // da qualche nota di credito o non assegnato percio' non si ha residuo
|
|
|
|
|
2005-09-19 12:45:16 +00:00
|
|
|
//if (res < ZERO) // Significa che l'importo pagato e' maggiore dell'importo in scadenza
|
|
|
|
//{ // c'e' un residuo positivo, e quindi va memorizzato
|
|
|
|
// res *= -1.0; // cambia il segno
|
|
|
|
// res_pagati+= res; // Residui pagati in piu'
|
|
|
|
// res = ZERO;
|
|
|
|
// res *= -1.0;
|
|
|
|
//}
|
2003-05-05 14:32:23 +00:00
|
|
|
|
|
|
|
if (d > _limscad)
|
|
|
|
{
|
|
|
|
if (d > _limscad && d <= (TDate&)_ns_date[0])
|
|
|
|
ns1 += res;
|
|
|
|
if (d > (TDate&)_ns_date[0] && d <= (TDate&)_ns_date[1])
|
|
|
|
ns2 += res;
|
|
|
|
if (d > (TDate&)_ns_date[1] && d <= (TDate&)_ns_date[2])
|
|
|
|
ns3 += res;
|
|
|
|
if (d > (TDate&)_ns_date[2] && d <= (TDate&)_ns_date[3])
|
|
|
|
ns4 += res;
|
|
|
|
if (d > (TDate&)_ns_date[3] && d <= (TDate&)_ns_date[4])
|
|
|
|
ns5 += res;
|
|
|
|
if (d > (TDate&)_ns_date[4])
|
2005-09-19 12:45:16 +00:00
|
|
|
{
|
|
|
|
TDate data = (TDate&) _ns_date[4];
|
|
|
|
if (data.year() != 0)
|
|
|
|
ns6 += res;
|
|
|
|
}
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Detrae dal residuo scaduto eventuali pagamenti in piu' effettuati
|
2005-09-19 12:45:16 +00:00
|
|
|
//real gap = (res_pagati > res ? res : res_pagati);
|
|
|
|
//res -= gap;
|
|
|
|
//res_pagati -= gap;
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
2005-09-19 12:45:16 +00:00
|
|
|
if (d <= _limscad && d > (TDate&)_s_date[0])
|
2003-05-05 14:32:23 +00:00
|
|
|
s1 += res;
|
2005-09-19 12:45:16 +00:00
|
|
|
if (d <= (TDate&)_s_date[0] && d > (TDate&)_s_date[1])
|
2003-05-05 14:32:23 +00:00
|
|
|
s2 += res;
|
2005-09-19 12:45:16 +00:00
|
|
|
if (d <= (TDate&)_s_date[1] && d > (TDate&)_s_date[2])
|
2003-05-05 14:32:23 +00:00
|
|
|
s3 += res;
|
2005-09-19 12:45:16 +00:00
|
|
|
if (d <= (TDate&)_s_date[2] && d > (TDate&)_s_date[3])
|
2003-05-05 14:32:23 +00:00
|
|
|
s4 += res;
|
2005-09-19 12:45:16 +00:00
|
|
|
if (d <= (TDate&)_s_date[3] && d > (TDate&)_s_date[4])
|
2003-05-05 14:32:23 +00:00
|
|
|
s5 += res;
|
2005-09-19 12:45:16 +00:00
|
|
|
if (d <= (TDate&)_s_date[4])
|
2003-05-05 14:32:23 +00:00
|
|
|
s6 += res;
|
|
|
|
residuo += res;
|
2006-01-09 01:15:53 +00:00
|
|
|
bool sbf;
|
|
|
|
TImporto esp = rs.esposto(_stvaluta, _limscad, _limbf, sbf);
|
|
|
|
esposto += esp.valore();
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Aggiorna i totali...
|
|
|
|
if (s1!=ZERO || s2!=ZERO || s3!=ZERO || s4!= ZERO || s5!= ZERO || s6!=ZERO ||
|
|
|
|
ns1!=ZERO || ns2!=ZERO || ns3!=ZERO || ns4!= ZERO || ns5!= ZERO || ns6!=ZERO || esposto!=ZERO)
|
|
|
|
{
|
|
|
|
update_totals(0, esposto, s1, s2, s3, s4, s5, s6, ns1, ns2, ns3, ns4, ns5, ns6); // Singolo...
|
|
|
|
update_totals(1, esposto, s1, s2, s3, s4, s5, s6, ns1, ns2, ns3, ns4, ns5, ns6); // ...Generale
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TProspettoScadenze::calcola_saldo()
|
|
|
|
{
|
|
|
|
TAssoc_array& a = (TAssoc_array&) _t[0];
|
|
|
|
TLineTotal *ll = (TLineTotal *) a.objptr(_codval);
|
|
|
|
TSaldo saldo;
|
|
|
|
int g,c;
|
2006-01-09 01:15:53 +00:00
|
|
|
const long s = atol(_cod_pre);
|
|
|
|
|
|
|
|
for (int i = 0; i < _conti_cf.items(); i++)
|
|
|
|
{
|
|
|
|
TToken_string& cf = (TToken_string&)_conti_cf[i];
|
|
|
|
g = cf.get_int(0);
|
|
|
|
c = cf.get_int(1);
|
|
|
|
TToken_string key;
|
|
|
|
key.add(g); key.add(c); key.add(s);
|
|
|
|
const TRectype& pc = cache().get(LF_PCON, key);
|
|
|
|
int indbil_conto = pc.get_int (PCN_INDBIL);
|
|
|
|
TDate dataini = TDate(1, 1, _limop.year());
|
|
|
|
saldo.data_limite_bilancio( 1, g, c, s, dataini, _limop, indbil_conto, FALSE);
|
|
|
|
ll->_sl += saldo.saldo();
|
|
|
|
}
|
|
|
|
// aggiorno il totale generale
|
|
|
|
TAssoc_array& at = (TAssoc_array&) _t[1];
|
|
|
|
TLineTotal *lt = (TLineTotal *) at.objptr(_codval);
|
|
|
|
if (lt == NULL)
|
2003-05-05 14:32:23 +00:00
|
|
|
{
|
2006-01-09 01:15:53 +00:00
|
|
|
lt = new TLineTotal;
|
|
|
|
at.add(_codval, lt);
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
2006-01-09 01:15:53 +00:00
|
|
|
lt->_sl += ll->_sl;
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TProspettoScadenze::preprocess_page(int file, int counter)
|
|
|
|
{
|
|
|
|
if (file == LF_PARTITE)
|
|
|
|
{
|
|
|
|
const TRectype& curr = current_cursor()->curr(file);
|
|
|
|
|
|
|
|
TBill bill(curr);
|
|
|
|
const bool checked = _m->selected(bill);
|
|
|
|
|
|
|
|
if (!checked && !_end_printed) // Se non e' stato selezionato salta al prossimo record
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
int nriga = 1;
|
|
|
|
if (_tipost == clienti || _tipost == fornitori)
|
|
|
|
{
|
|
|
|
const TRectype& clifo = current_cursor()->curr(LF_CLIFO);
|
|
|
|
_des = clifo.get(CLI_RAGSOC);
|
|
|
|
_cod = clifo.get(CLI_CODCF);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const TRectype& pcon = current_cursor()->curr(LF_PCON);
|
|
|
|
_des = pcon.get(PCN_DESCR);
|
|
|
|
_cod = pcon.get(PCN_GRUPPO);
|
|
|
|
_cod << " " << pcon.get(PCN_CONTO);
|
|
|
|
_cod << " " << pcon.get(PCN_SOTTOCONTO);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_cod != _cod_pre || _end_printed) // Controlla se e' cambiato il codice cli/fo/conto
|
|
|
|
{
|
|
|
|
reset_print();
|
|
|
|
if (_cod_pre != "") // stampa i totali del precedente solo se non e' la prima
|
|
|
|
{
|
|
|
|
//calcola_saldo();
|
|
|
|
TAssoc_array& sin_tot = (TAssoc_array&) _t[0];
|
|
|
|
if (sin_tot.items() > 0)
|
2005-09-19 12:45:16 +00:00
|
|
|
{
|
2003-05-05 14:32:23 +00:00
|
|
|
print_totali(nriga);
|
2006-01-09 01:15:53 +00:00
|
|
|
return true;
|
2005-09-19 12:45:16 +00:00
|
|
|
}
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
|
|
|
_des.trim();
|
|
|
|
_cod_pre = _cod;
|
|
|
|
_des_pre = _des;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (curr.empty()) // Attenzione: Possono succedere anche queste cose!
|
|
|
|
return FALSE;
|
|
|
|
TPartita p(curr);
|
|
|
|
|
|
|
|
//Pesca gli estremi dalla prima riga di fattura, che non e' necessariamente la riga #1
|
|
|
|
const int r = p.prima_fattura();
|
|
|
|
if (r <= 0)
|
|
|
|
return TRUE; // se non ci sono fatture ... salta al prossimo
|
|
|
|
|
|
|
|
if (r > 0) //Skip next partita if no fatture!
|
|
|
|
{
|
|
|
|
TRiga_partite& rp = p.riga(r);
|
|
|
|
_anno = rp.get(PART_ANNO);
|
|
|
|
_anno.ltrim(2);
|
|
|
|
_numdoc = rp.get(PART_NUMDOC);
|
|
|
|
_protiva = rp.get(PART_PROTIVA);
|
|
|
|
_datadoc = (const char*) rp.get_date(PART_DATADOC);
|
|
|
|
_codval = (_stvaluta ? rp.get(PART_CODVAL): "");
|
|
|
|
if (_codval.empty()) _codval = " ";
|
|
|
|
// Now performing fulkrum...
|
|
|
|
compute_all(p, bill);
|
|
|
|
}
|
|
|
|
current_cursor()->repos(); // Very, very necessary...
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TProspettoScadenze::preprocess_print(int file, int counter)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
print_action TProspettoScadenze::postprocess_print(int file, int counter)
|
|
|
|
{
|
|
|
|
print_action rt = NEXT_PAGE;
|
|
|
|
if (!_end_printed)
|
2006-01-09 01:15:53 +00:00
|
|
|
{
|
2003-05-05 14:32:23 +00:00
|
|
|
if ((file == LF_PARTITE))
|
|
|
|
{
|
|
|
|
rt = REPEAT_PAGE;
|
2006-01-09 01:15:53 +00:00
|
|
|
_end_printed = true;
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
2005-09-19 12:45:16 +00:00
|
|
|
if (_end_printed)
|
|
|
|
{
|
|
|
|
TAssoc_array& gen_tot = (TAssoc_array&) _t[1];
|
2006-01-09 01:15:53 +00:00
|
|
|
|
2005-09-19 12:45:16 +00:00
|
|
|
if (gen_tot.items() > 0)
|
2006-01-09 01:15:53 +00:00
|
|
|
{
|
|
|
|
print_totali_rows(1,1);
|
|
|
|
print_one(0);
|
2005-09-19 12:45:16 +00:00
|
|
|
}
|
|
|
|
}
|
2006-01-09 01:15:53 +00:00
|
|
|
}
|
2003-05-05 14:32:23 +00:00
|
|
|
return rt;
|
|
|
|
}
|
|
|
|
|
|
|
|
print_action TProspettoScadenze::postprocess_page(int file, int counter)
|
|
|
|
{
|
|
|
|
return NEXT_PAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TProspettoScadenze::user_create()
|
|
|
|
{
|
|
|
|
_rel1 = new TRelation(LF_PARTITE);
|
|
|
|
_rel1->add(LF_CLIFO,"TIPOCF=TIPOC|CODCF=SOTTOCONTO",1);
|
|
|
|
_cur1 = add_cursor(new TCursor(_rel1));
|
|
|
|
_cur2 = add_cursor(new TSorted_cursor(_rel1,"UPPER(20->RAGSOC)||NUMPART","",1));
|
|
|
|
|
|
|
|
_rel2 = new TRelation(LF_PARTITE);
|
|
|
|
_rel2->add(LF_PCON,"GRUPPO=GRUPPO|CONTO=CONTO|SOTTOCONTO=SOTTOCONTO",1);
|
|
|
|
_cur3 = add_cursor(new TCursor(_rel2));
|
|
|
|
_cur4 = add_cursor(new TSorted_cursor(_rel2,"UPPER(19->DESCR)|ANNO|NUMPART","",1));
|
|
|
|
|
|
|
|
_scad = new TLocalisamfile(LF_SCADENZE);
|
|
|
|
_pagsca = new TLocalisamfile(LF_PAGSCA);
|
|
|
|
_t.add(new TAssoc_array);_t.add(new TAssoc_array);
|
|
|
|
|
|
|
|
for (int i = 0; i < NUMERO_FASCE; i++)
|
|
|
|
{
|
|
|
|
_s_date.add(new TDate);
|
|
|
|
_ns_date.add(new TDate);
|
|
|
|
}
|
|
|
|
|
|
|
|
TConfig conf (CONFIG_DITTA,"cg");
|
|
|
|
_m = new TSelection_ext_mask("sc2600a");
|
|
|
|
_m->enable(F_VALUTA,conf.get_bool("GesVal"));
|
|
|
|
|
|
|
|
enable_print_menu();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TProspettoScadenze::user_destroy()
|
|
|
|
{
|
|
|
|
if (_rel1) delete _rel1;
|
|
|
|
if (_rel2) delete _rel2;
|
|
|
|
if (_scad) delete _scad;
|
|
|
|
if (_pagsca) delete _pagsca;
|
|
|
|
if (_m) delete _m;
|
|
|
|
_t.destroy();
|
|
|
|
_s_date.destroy();
|
|
|
|
_ns_date.destroy();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TProspettoScadenze::riempi_conti_mastro(const char cf)
|
|
|
|
{
|
|
|
|
_conti_cf.destroy();
|
|
|
|
TRelation rel = TRelation(LF_PCON);
|
|
|
|
TString80 filtro;
|
|
|
|
filtro.format("TMCF==\'%c\'", cf);
|
|
|
|
TCursor cur(&rel, filtro);
|
|
|
|
TToken_string gc(10);
|
|
|
|
for (cur=0; cur.pos() < cur.items(); ++cur)
|
|
|
|
{
|
|
|
|
const int g = cur.curr().get_int(PCN_GRUPPO);
|
|
|
|
const int c = cur.curr().get_int(PCN_CONTO);
|
|
|
|
gc.add(g,0);
|
|
|
|
gc.add(c,1);
|
|
|
|
_conti_cf.add(gc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TProspettoScadenze::set_print(int)
|
|
|
|
{
|
|
|
|
const bool rt = _m->run() == K_ENTER;
|
|
|
|
if (rt)
|
|
|
|
{
|
|
|
|
reset_files();
|
|
|
|
reset_print();
|
2006-01-09 01:15:53 +00:00
|
|
|
if (_m->get_who() == 'C')
|
|
|
|
_tipost = clienti;
|
|
|
|
else
|
|
|
|
_tipost = fornitori;
|
|
|
|
riempi_conti_mastro(_m->get_who());
|
2003-05-05 14:32:23 +00:00
|
|
|
if (_m->get_key() == 1)
|
|
|
|
_ordcod = TRUE;
|
|
|
|
else
|
|
|
|
_ordcod = FALSE;
|
|
|
|
_end_printed = FALSE;
|
|
|
|
_gcr = _m->get_int(F_GIORNI);
|
|
|
|
_stvaluta = _m->get_bool(F_VALUTA);
|
|
|
|
_datas = (const char *)(_m->get(F_DATASTAMPA));
|
|
|
|
_limop = (const char *)(_m->get(F_DATAOPERAZIONE));
|
|
|
|
_limscad = (const char *)(_m->get(F_DATASCADUTO));
|
|
|
|
_limbf = _limscad - (long)_gcr; // Limite inferiore per le scadenze a Buon Fine.
|
|
|
|
_sinfasce = _m->get_bool(F_SCADINFASCE);
|
|
|
|
_sfasce = _m->get_int(F_SCADFASCE);
|
|
|
|
_nsinfasce = _m->get_bool(F_ASCADINFASCE);
|
|
|
|
_nsfasce = _m->get_int(F_ASCADFASCE);
|
|
|
|
_anno.cut(0);_numdoc.cut(0);_protiva.cut(0);_datadoc.cut(0);
|
|
|
|
_codval.cut(0);_cod.cut(0); _des.cut(0); _cod_pre.cut(0);
|
|
|
|
for (int it=0; it < _t.items(); it++)
|
|
|
|
{
|
|
|
|
TAssoc_array& aa = (TAssoc_array&) _t[it];
|
|
|
|
aa.destroy(); // Totali lineari (singolo e generale)
|
|
|
|
}
|
|
|
|
|
|
|
|
get_cursor(_cur1)->set_filterfunction(fil_function,TRUE);
|
|
|
|
get_cursor(_cur2)->set_filterfunction(fil_function,TRUE);
|
|
|
|
get_cursor(_cur3)->set_filterfunction(fil_function,TRUE);
|
|
|
|
get_cursor(_cur4)->set_filterfunction(fil_function,TRUE);
|
|
|
|
_last_game.cut(0);
|
|
|
|
|
|
|
|
TRectype filter_from(LF_PARTITE), filter_to(LF_PARTITE);
|
|
|
|
|
|
|
|
switch (_tipost)
|
|
|
|
{
|
|
|
|
case clienti:
|
|
|
|
case fornitori:
|
|
|
|
filter_from.put("TIPOC", _tipost == clienti ? "C" : "F");
|
|
|
|
filter_to = filter_from;
|
|
|
|
if (_ordcod) // Per codice...
|
|
|
|
{
|
|
|
|
select_cursor(_cur1);
|
|
|
|
get_cursor(_cur1)->setregion(filter_from, filter_to);
|
|
|
|
}
|
|
|
|
else // ... e ragione sociale
|
|
|
|
{
|
|
|
|
select_cursor(_cur2);
|
|
|
|
get_cursor(_cur2)->setregion(filter_from, filter_to);
|
|
|
|
}
|
|
|
|
add_file(LF_PARTITE);
|
|
|
|
add_file(LF_CLIFO,LF_PARTITE);
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
} // End of inner switch
|
|
|
|
|
|
|
|
int limiti[2][NUMERO_FASCE] = LIMITI;
|
|
|
|
int row = 0;
|
|
|
|
if (_tipost == fornitori)
|
|
|
|
row = 1;
|
|
|
|
for (int j = 0; j < NUMERO_FASCE; j++)
|
|
|
|
{
|
|
|
|
long inc = (long) limiti[row][j];
|
|
|
|
TDate* d = (TDate *)_s_date.objptr(j);
|
|
|
|
|
|
|
|
if (j < _sfasce)
|
|
|
|
*d = _limscad - inc;
|
|
|
|
else
|
|
|
|
*d = NULLDATE;
|
|
|
|
TDate* dns = (TDate *)_ns_date.objptr(j);
|
|
|
|
if (j < _nsfasce)
|
|
|
|
*dns = _limscad + inc;
|
|
|
|
else
|
|
|
|
*dns = NULLDATE;
|
|
|
|
}
|
|
|
|
} // End if
|
|
|
|
return rt;
|
|
|
|
}
|
|
|
|
|
2006-01-09 01:15:53 +00:00
|
|
|
void TProspettoScadenze::print_totali_rows(int nriga, bool what)
|
2003-05-05 14:32:23 +00:00
|
|
|
// If what is 0 prints single total... else prints also general total
|
|
|
|
{
|
|
|
|
reset_print();
|
|
|
|
TAssoc_array& xassoc = (TAssoc_array&) _t[what];
|
|
|
|
TString_array as;
|
|
|
|
const int items = xassoc.items();
|
|
|
|
xassoc.get_keys(as);
|
|
|
|
as.sort();
|
|
|
|
for (int i=0; i < items; i++)
|
|
|
|
{
|
|
|
|
if (!what)
|
|
|
|
calcola_saldo();
|
|
|
|
TString k(as.row(i)); // Chiave di ordinamento(valuta)
|
|
|
|
TString value;
|
|
|
|
TLineTotal& v = (TLineTotal&)xassoc[k];
|
|
|
|
|
2006-01-09 01:15:53 +00:00
|
|
|
int pos = 40;
|
2003-05-05 14:32:23 +00:00
|
|
|
TString rw(255);
|
|
|
|
rw = "";
|
|
|
|
|
|
|
|
if (_sinfasce)
|
|
|
|
{
|
2005-05-16 23:44:23 +00:00
|
|
|
if (v._s6 != ZERO)
|
2003-05-05 14:32:23 +00:00
|
|
|
{
|
2005-05-16 23:44:23 +00:00
|
|
|
print_real(value, v._s6);
|
2006-01-09 01:15:53 +00:00
|
|
|
rw << format("@%dg%10s", pos, (const char*) value);
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
2005-05-16 23:44:23 +00:00
|
|
|
if (_sfasce >= 5)
|
2006-01-09 01:15:53 +00:00
|
|
|
pos = pos + 11;
|
2003-05-05 14:32:23 +00:00
|
|
|
|
2005-05-16 23:44:23 +00:00
|
|
|
if (v._s5 != ZERO)
|
2003-05-05 14:32:23 +00:00
|
|
|
{
|
2005-05-16 23:44:23 +00:00
|
|
|
print_real(value, v._s5);
|
2006-01-09 01:15:53 +00:00
|
|
|
rw << format("@%dg%10s", pos, (const char*) value);
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
2005-05-16 23:44:23 +00:00
|
|
|
if (_sfasce >= 4)
|
2006-01-09 01:15:53 +00:00
|
|
|
pos = pos + 11;
|
2003-05-05 14:32:23 +00:00
|
|
|
|
2005-05-16 23:44:23 +00:00
|
|
|
if (v._s4 != ZERO)
|
2003-05-05 14:32:23 +00:00
|
|
|
{
|
2005-05-16 23:44:23 +00:00
|
|
|
print_real(value, v._s4);
|
2006-01-09 01:15:53 +00:00
|
|
|
rw << format("@%dg%10s", pos, (const char*) value);
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
|
|
|
if (_sfasce >= 3)
|
2006-01-09 01:15:53 +00:00
|
|
|
pos = pos + 11;
|
2003-05-05 14:32:23 +00:00
|
|
|
|
2005-05-16 23:44:23 +00:00
|
|
|
if (v._s3 != ZERO)
|
2003-05-05 14:32:23 +00:00
|
|
|
{
|
2005-05-16 23:44:23 +00:00
|
|
|
print_real(value, v._s3);
|
2006-01-09 01:15:53 +00:00
|
|
|
rw << format("@%dg%10s", pos, (const char*) value);
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
2005-05-16 23:44:23 +00:00
|
|
|
if (_sfasce >= 2)
|
2006-01-09 01:15:53 +00:00
|
|
|
pos = pos + 11;
|
2003-05-05 14:32:23 +00:00
|
|
|
|
2005-05-16 23:44:23 +00:00
|
|
|
if (v._s2 != ZERO)
|
2003-05-05 14:32:23 +00:00
|
|
|
{
|
2005-05-16 23:44:23 +00:00
|
|
|
print_real(value, v._s2);
|
2006-01-09 01:15:53 +00:00
|
|
|
rw << format("@%dg%10s", pos, (const char*) value);
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
2005-05-16 23:44:23 +00:00
|
|
|
if (_sfasce >= 1)
|
2006-01-09 01:15:53 +00:00
|
|
|
pos = pos + 11;
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
2005-05-16 23:44:23 +00:00
|
|
|
if (v._s1 != ZERO)
|
2003-05-05 14:32:23 +00:00
|
|
|
{
|
2005-05-16 23:44:23 +00:00
|
|
|
print_real(value, v._s1);
|
2006-01-09 01:15:53 +00:00
|
|
|
rw << format("@%dg%10s", pos, (const char*) value);
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
2006-01-09 01:15:53 +00:00
|
|
|
pos = pos + 11;
|
2003-05-05 14:32:23 +00:00
|
|
|
|
|
|
|
if (_nsinfasce)
|
|
|
|
{
|
|
|
|
if (v._ns1 != ZERO)
|
|
|
|
{
|
|
|
|
print_real(value, v._ns1);
|
2006-01-09 01:15:53 +00:00
|
|
|
rw << format("@%dg%10s", pos, (const char*) value);
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
|
|
|
if (_nsfasce >= 1)
|
2006-01-09 01:15:53 +00:00
|
|
|
pos = pos + 11;
|
2003-05-05 14:32:23 +00:00
|
|
|
|
|
|
|
if (v._ns2 != ZERO)
|
|
|
|
{
|
|
|
|
print_real(value, v._ns2);
|
2006-01-09 01:15:53 +00:00
|
|
|
rw << format("@%dg%10s", pos, (const char*) value);
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
|
|
|
if (_nsfasce >= 2)
|
2006-01-09 01:15:53 +00:00
|
|
|
pos = pos + 11;
|
2003-05-05 14:32:23 +00:00
|
|
|
|
|
|
|
if (v._ns3 != ZERO)
|
|
|
|
{
|
|
|
|
print_real(value, v._ns3);
|
2006-01-09 01:15:53 +00:00
|
|
|
rw << format("@%dg%10s", pos, (const char*) value);
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
|
|
|
if (_nsfasce >= 3)
|
2006-01-09 01:15:53 +00:00
|
|
|
pos = pos + 11;
|
2003-05-05 14:32:23 +00:00
|
|
|
|
|
|
|
if (v._ns4 != ZERO)
|
|
|
|
{
|
|
|
|
print_real(value, v._ns4);
|
2006-01-09 01:15:53 +00:00
|
|
|
rw << format("@%dg%10s", pos, (const char*) value);
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
|
|
|
if (_nsfasce >= 4)
|
2006-01-09 01:15:53 +00:00
|
|
|
pos = pos + 11;
|
2003-05-05 14:32:23 +00:00
|
|
|
|
|
|
|
if (v._ns5 != ZERO)
|
|
|
|
{
|
|
|
|
print_real(value, v._ns5);
|
2006-01-09 01:15:53 +00:00
|
|
|
rw << format("@%dg%10s", pos, (const char*) value);
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
|
|
|
if (_nsfasce >= 5)
|
2006-01-09 01:15:53 +00:00
|
|
|
pos = pos + 11;
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
|
|
|
if (v._ns6 != ZERO)
|
|
|
|
{
|
|
|
|
print_real(value, v._ns6);
|
2006-01-09 01:15:53 +00:00
|
|
|
rw << format("@%dg%10s", pos, (const char*) value);
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
2006-01-09 01:15:53 +00:00
|
|
|
pos = pos + 11;
|
2003-05-05 14:32:23 +00:00
|
|
|
const real tot = v._s1+v._s2+v._s3+v._s4+v._s5+v._s6+v._ns1+v._ns2+v._ns3+v._ns4+v._ns5+v._ns6;
|
|
|
|
if (tot != ZERO)
|
|
|
|
{
|
|
|
|
print_real(value, tot);
|
2006-01-09 01:15:53 +00:00
|
|
|
rw << format("@%dg%10s", pos, (const char*) value);
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
2006-01-09 01:15:53 +00:00
|
|
|
pos = pos + 11;
|
|
|
|
if (v._es != ZERO)
|
|
|
|
{
|
|
|
|
print_real(value, v._es);
|
|
|
|
rw << format("@%dg%10s", pos, (const char*) value);
|
|
|
|
}
|
|
|
|
pos = pos + 11;
|
2003-05-05 14:32:23 +00:00
|
|
|
if (v._sl != ZERO)
|
|
|
|
{
|
|
|
|
print_real(value, v._sl);
|
2006-01-09 01:15:53 +00:00
|
|
|
rw << format("@%dg%10s", pos, (const char*) value);
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
2006-01-09 01:15:53 +00:00
|
|
|
pos = pos + 13;
|
2003-05-05 14:32:23 +00:00
|
|
|
|
2006-01-09 01:15:53 +00:00
|
|
|
const real diff = v._sl + v._es - tot;
|
|
|
|
if (diff != ZERO)
|
|
|
|
{
|
|
|
|
print_real(value, diff);
|
|
|
|
rw << format("@%dg%10s", pos, (const char*) value);
|
|
|
|
}
|
2003-05-05 14:32:23 +00:00
|
|
|
|
|
|
|
if (rw.not_empty())
|
|
|
|
{
|
|
|
|
if (!what)
|
2006-01-09 01:15:53 +00:00
|
|
|
{
|
|
|
|
TString s = _des_pre.left(25);
|
|
|
|
rw.insert(format("%6s@8g%-25s", (const char*) _cod_pre, (const char*) s));
|
|
|
|
}
|
2003-05-05 14:32:23 +00:00
|
|
|
else
|
2006-01-09 01:15:53 +00:00
|
|
|
{
|
|
|
|
TString meno;
|
|
|
|
const int last_column = calc_last_column();
|
|
|
|
|
|
|
|
meno.fill('-', last_column);
|
|
|
|
set_row(nriga++, meno);
|
|
|
|
rw.insert("@8gTOTALE GENERALE");
|
|
|
|
}
|
2003-05-05 14:32:23 +00:00
|
|
|
set_row(nriga, rw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xassoc.destroy(); // Distrugge il totale appena stampato
|
|
|
|
}
|
|
|
|
|
|
|
|
void TProspettoScadenze::print_totali(int& nriga)
|
|
|
|
{
|
|
|
|
reset_row(nriga);
|
|
|
|
print_totali_rows(nriga,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TProspettoScadenze::print_header()
|
|
|
|
// Setta le righe dell'intestazione
|
|
|
|
{
|
|
|
|
int soh = 1;
|
2006-01-09 01:15:53 +00:00
|
|
|
const int last_column = calc_last_column();
|
2003-05-05 14:32:23 +00:00
|
|
|
const long firm = get_firm();
|
2006-01-09 01:15:53 +00:00
|
|
|
TString rw(last_column);
|
|
|
|
TString meno(last_column);
|
2003-05-05 14:32:23 +00:00
|
|
|
|
|
|
|
reset_header ();
|
|
|
|
TLocalisamfile ditte(LF_NDITTE);
|
|
|
|
ditte.zero();
|
|
|
|
ditte.put(NDT_CODDITTA, firm);
|
|
|
|
ditte.read();
|
|
|
|
if (ditte.bad()) ditte.zero();
|
|
|
|
|
|
|
|
TString s;
|
|
|
|
s = ditte.get(NDT_RAGSOC);
|
|
|
|
TString datas = _datas.string();
|
|
|
|
TString limop = _limop.string();
|
|
|
|
TString limscad = _limscad.string();
|
|
|
|
|
2006-01-09 01:15:53 +00:00
|
|
|
set_header (soh++, "Ditta : %ld %s@%ldgData %s @%ldgPag. @#",
|
|
|
|
firm, (const char *)s, last_column - 30, (const char *)datas, last_column - 10);
|
2003-05-05 14:32:23 +00:00
|
|
|
|
|
|
|
switch (_tipost)
|
|
|
|
{
|
|
|
|
case fornitori:
|
|
|
|
case clienti:
|
|
|
|
{
|
|
|
|
TString s1,s2, s3;
|
|
|
|
int o = 0; // Offset per scaglioni.
|
2006-01-09 01:15:53 +00:00
|
|
|
|
|
|
|
|
2003-05-05 14:32:23 +00:00
|
|
|
if (_tipost==fornitori)
|
2006-01-09 01:15:53 +00:00
|
|
|
set_header(soh++,"@%ldg** PROSPETTO SCADENZE FORNITORI **", (last_column - 35) / 2);
|
2003-05-05 14:32:23 +00:00
|
|
|
else
|
2006-01-09 01:15:53 +00:00
|
|
|
set_header(soh++,"@%ldg** PROSPETTO SCADENZE CLIENTI **", (last_column - 34) / 2);
|
|
|
|
set_header (soh++,"@%ldgAl %s - Operazioni al %s", (last_column - 40) / 2, (const char*)limscad, (const char*)limop);
|
|
|
|
meno.fill('-', last_column);
|
|
|
|
set_header(soh++,(const char *)meno);
|
2003-05-05 14:32:23 +00:00
|
|
|
set_header(soh,"CODICE@8gC O G N O M E E N O M E ");
|
|
|
|
int limiti[2][NUMERO_FASCE] = LIMITI;
|
|
|
|
int row = 0;
|
|
|
|
if (_tipost==fornitori)
|
|
|
|
row = 1;
|
2006-01-09 01:15:53 +00:00
|
|
|
int pos = 40;
|
|
|
|
|
|
|
|
rw.cut(0);
|
2003-05-05 14:32:23 +00:00
|
|
|
if (_sinfasce)
|
|
|
|
{
|
2005-05-16 23:44:23 +00:00
|
|
|
for (int i = _sfasce-1; i >= 0; i--)
|
2003-05-05 14:32:23 +00:00
|
|
|
{
|
2006-01-09 01:15:53 +00:00
|
|
|
rw << format("@%dg%7d gg", pos, limiti[row][i] + 30);
|
|
|
|
pos = pos + 11;
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
2006-01-09 01:15:53 +00:00
|
|
|
rw << format("@%dg%10s", pos, "30 gg");
|
|
|
|
set_header(soh, format("@%dg%10s", 40+((pos-40)/2), "SCADUTO"));
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
|
|
|
else
|
2006-01-09 01:15:53 +00:00
|
|
|
set_header(soh, format("@%dg%10s", pos, "SCADUTO"));
|
|
|
|
pos = pos + 11;
|
2003-05-05 14:32:23 +00:00
|
|
|
const int pos_ascad = pos;
|
|
|
|
if (_nsinfasce)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < _nsfasce; i++)
|
|
|
|
{
|
2006-01-09 01:15:53 +00:00
|
|
|
rw << format("@%dg%7d gg", pos, limiti[row][i]);
|
|
|
|
pos = pos + 11;
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
2006-01-09 01:15:53 +00:00
|
|
|
set_header(soh, format("@%dg%11s", pos_ascad+((pos-pos_ascad)/2)-5, " A SCADERE"));
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
|
|
|
else
|
2006-01-09 01:15:53 +00:00
|
|
|
set_header(soh, format("@%dg%11s", pos, " A SCADERE"));
|
|
|
|
pos = pos + 11;
|
|
|
|
set_header(soh, format("@%dg%11s", pos, " TOTALE"));
|
|
|
|
pos = pos + 11;
|
|
|
|
set_header(soh, format("@%dg%11s", pos, " ESPOSTO"));
|
|
|
|
pos = pos + 11;
|
|
|
|
set_header(soh, format("@%dg%11s", pos, " SALDO"));
|
|
|
|
pos = pos + 13;
|
|
|
|
set_header(soh, format("@%dg%11s", pos, "DIFFERENZA"));
|
2003-05-05 14:32:23 +00:00
|
|
|
set_header(++soh,(const char *)rw);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-01-09 01:15:53 +00:00
|
|
|
set_header(++soh, (const char *) meno);
|
|
|
|
}
|
|
|
|
|
|
|
|
int TProspettoScadenze::calc_last_column()
|
|
|
|
// Setta le righe dell'intestazione
|
|
|
|
{
|
|
|
|
int pos = 110;
|
|
|
|
|
|
|
|
if (_sinfasce)
|
|
|
|
for (int i = _sfasce-1; i >= 0; i--)
|
|
|
|
pos = pos + 11;
|
|
|
|
if (_nsinfasce)
|
|
|
|
for (int i = 0; i < _nsfasce; i++)
|
|
|
|
pos = pos + 11;
|
|
|
|
return pos;
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TProspettoScadenze::set_page(int file, int counter)
|
|
|
|
{
|
|
|
|
print_header();
|
|
|
|
}
|
|
|
|
|
|
|
|
TProspettoScadenze::TProspettoScadenze()
|
|
|
|
{
|
2006-01-09 01:15:53 +00:00
|
|
|
_rel1 = _rel2 = NULL;
|
2003-05-05 14:32:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int sc2600(int argc, char** argv)
|
|
|
|
{
|
|
|
|
TProspettoScadenze app;
|
|
|
|
app.run(argc, argv, "Stampa Prospetto Scadenze");
|
|
|
|
return 0;
|
|
|
|
}
|