cg0600.cpp Tolto file principale _saldi e usato uno temporaneo

cg2.url       Aggiunto menu colori
cg2100.cpp    Aggiunta gestione menu colori
cg2100b.uml   Accorciata colonna tipo
cg2100c.uml   Accorciata colonna tipo
cg2102.cpp    Gestione righe colorate
cg2102.h      Aggiunte funzioni gestione righe colorate
cg3.cpp       Aggiunti mastrini a video
cg3.url       Aggiunto menu dei mastrini a video
conto.cpp     MEGAFIGATA, velocizzato TBill
conto.h       Sembra che funzioni bene!


git-svn-id: svn://10.65.10.50/trunk@3892 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-11-12 15:18:10 +00:00
parent 49a5aec854
commit 8d5d6540be
12 changed files with 155 additions and 72 deletions

View File

@ -12,21 +12,20 @@
class CGTab_application : public Tab_application
{
// ------------- specifiche tabella esercizi ----
TLocalisamfile* _saldi;
static bool dataini_handler(TMask_field& f, KEY k);
static bool checkbut_handler(TMask_field& f, KEY k);
void check_sheet();
bool check_esercizio(TString& cod, TDate s1, TDate f1);
// --------------------------------------------
protected:
protected:
virtual bool protected_record(TRectype & rec);
virtual bool user_create();
virtual bool user_destroy();
public:
public:
static CGTab_application& app() { return (CGTab_application&)main_app(); }
@ -39,11 +38,11 @@ bool CGTab_application::protected_record(TRectype &rec)
if (get_tabname() == "ESC")
{
// cerca saldo con questo esercizio
TString cod(rec.get("CODTAB"));
_saldi->zero();
_saldi->put(SLD_ANNOES, cod);
const TString16 cod(rec.get("CODTAB"));
TLocalisamfile saldi(LF_SALDI);
saldi.put(SLD_ANNOES, cod);
// se ce n'e' uno non si puo' cancellare
if (_saldi->read(_isgteq) == NOERR && cod == rec.get("CODTAB"))
if (saldi.read(_isgteq) == NOERR && cod == rec.get("CODTAB"))
return TRUE;
}
return Tab_application::protected_record(rec);
@ -51,21 +50,20 @@ bool CGTab_application::protected_record(TRectype &rec)
bool CGTab_application::user_create()
{
Tab_application::user_create();
if (get_tabname() == "ESC")
bool ok = Tab_application::user_create();
if (ok)
{
_saldi = new TLocalisamfile(LF_SALDI);
get_mask()->set_handler(F_DATAINI, dataini_handler);
get_mask()->set_handler(BUT_CHECK, checkbut_handler);
}
return TRUE;
if (get_tabname() == "ESC")
{
get_mask()->set_handler(F_DATAINI, dataini_handler);
get_mask()->set_handler(BUT_CHECK, checkbut_handler);
}
}
return ok;
}
bool CGTab_application::user_destroy()
{
if (get_tabname() == "ESC")
delete _saldi;
return Tab_application::user_destroy();
}

View File

@ -1,7 +1,15 @@
#include <default.url>
// Prima nota
MENU TASK_MENUBAR
SUBMENU MENU_FILE "~File"
SUBMENU M_FONT "~Opzioni"
MENU M_FONT
ITEM MENU_ITEM(1) "~Colori righe"
// Gestione movimenti provvisori
MENUBAR MENU_BAR(1)

View File

@ -173,11 +173,12 @@ bool TPrimanota_application::user_create()
set_search_field(F_NUMREG); // Set field for default search
_pag = NULL;
// _pag_rows = NULL; // Kriminal!
_is_saldaconto = FALSE;
load_mask(0);
load_colors();
return TRUE;
}
@ -342,6 +343,16 @@ void TPrimanota_application::print()
stampa.run();
}
bool TPrimanota_application::menu(MENU_TAG mt)
{
bool ok = TRUE;
if (mt == MENU_ITEM(1))
set_colors();
else
ok = TRelation_application::menu(mt);
return ok;
}
bool TPrimanota_application::changing_mask(int mode)
{
@ -421,6 +432,7 @@ void TPrimanota_application::on_config_change()
void TPrimanota_application::init_mask(TMask& m)
{
disable_menu_item(M_FILE_PRINT);
disable_menu_item(M_FONT);
read_caus(NULL, 0); // Setta campi obbligatori
fill_sheet(m);
@ -481,7 +493,8 @@ void TPrimanota_application::init_mask(TMask& m)
void TPrimanota_application::init_query_mode(TMask& m)
{
enable_menu_item(M_FILE_PRINT);
enable_menu_item(M_FONT);
if (lnflag())
{
m.field(F_NUMREG).on_hit(); // Aggiorna opportunamente le date
@ -495,17 +508,18 @@ void TPrimanota_application::init_query_mode(TMask& m)
void TPrimanota_application::fill_sheet(TMask& m) const
{
{
const int filler = 16;
if (_iva != nessuna_iva || !is_saldaconto())
{
TSheet_field& cgs = (TSheet_field&)m.field(F_SHEETCG);
for (int r = cgs.items(); r < 16; r++) cgs.row(r);
for (int r = cgs.items(); r < filler; r++) cgs.row(r);
}
if (_iva != nessuna_iva)
{
TSheet_field& ivas = (TSheet_field&)m.field(F_SHEETIVA);
for (int r = ivas.items(); r < 16; r++) ivas.row(r);
for (int r = ivas.items(); r < filler; r++) ivas.row(r);
ivas.enable_column(2, _iva == iva_acquisti); // Tipo detrazione
ivas.enable_column(4, !m.insert_mode()); // Tipo costo ricavo
}

View File

@ -352,7 +352,7 @@ BEGIN
ITEM "Sott./c@6"
ITEM "Descrizione contropartita@30"
ITEM "Giornale"
ITEM "Tipo"
ITEM "Tipo@4"
END
NUMBER F_DARE 15

View File

@ -631,7 +631,7 @@ BEGIN
ITEM "Sott./c@6"
ITEM "Descrizione contropartita@30"
ITEM "Giornale"
ITEM "Tipo"
ITEM "Tipo@4"
END
NUMBER F_DARE 15

View File

@ -1,3 +1,4 @@
#include <colors.h>
#include <progind.h>
#include <tabutil.h>
#include <urldefid.h>
@ -145,7 +146,8 @@ int TPrimanota_application::type2pos(char tipo)
int TPrimanota_application::bill2pos(const TBill& conto, char tipo)
{
TString_array& cg = app().cgs().rows_array();
for (int i = 0; i < cg.items(); i++)
const int num_rows = cg.items();
for (int i = 0; i < num_rows; i++)
{
TToken_string& s = cg.row(i);
const char t = row_type(s);
@ -164,14 +166,16 @@ int TPrimanota_application::bill2pos(const TBill& conto, char tipo)
int TPrimanota_application::bill2contr(const TBill& conto, char sezione) const
{
TString_array& rows = cgs().rows_array();
for (int i = 0; i < rows.items(); i++)
const int num_rows = rows.items();
TBill c; // Conto corrente (Buona questa!)
for (int i = 0; i < num_rows; i++)
{
TToken_string& r = rows.row(i);
const real dare(r.get(0));
const char sez = dare.is_zero() ? 'A' : 'D';
if (sez == sezione) // Devo cercare sezione contraria
continue;
const TBill c(r, 3, 0x0);
c.get(r, 3, 0x0);
if (conto == c)
return i;
}
@ -182,19 +186,19 @@ int TPrimanota_application::bill2contr(const TBill& conto, char sezione) const
// Controlla se un conto e' usato nelle righe IVA
int TPrimanota_application::bill_used(const TBill& conto) const
{
TString_array& rows = ivas().rows_array();
TBill c; // Conto corrente
int users = 0;
const TArray& rows = ivas().rows_array();
for (int i = 0; i < rows.items(); i++)
for (int i = rows.items(); i >= 0 ; i--)
{
TToken_string& row = (TToken_string&)rows[i];
TToken_string& row = rows.row(i);
if (!row.empty_items())
{
const TBill c(row, 6, 0x0);
if (conto == c) users++;
c.get(row, 6, 0x0);
if (conto == c)
users++;
}
}
return users;
}
@ -324,8 +328,16 @@ void TPrimanota_application::disable_cgs_cells(int n, char tipo)
break;
}
for (int i = first; i < last; i++)
cg.disable_cell(n, i);
if (last)
{
for (int i = first; i < last; i++)
cg.disable_cell(n, i);
COLOR back_color, fore_color;
type2colors(tipo, back_color, fore_color);
cg.set_back_and_fore_color(back_color, fore_color, n);
cg.force_update(n);
}
}
void TPrimanota_application::reset_sheet_row(TSheet_field& s, int n)
@ -346,7 +358,7 @@ int TPrimanota_application::set_cgs_row(int n, const TImporto& imp,
row.add(conto.string(0x3));
row.add(""); // Codice decrizione
row.add(desc); // Descrizione aggiuntiva
if (tipo == 'T') // Calcolo contropartita
{
TToken_string& irow = ivas().row(0);
@ -367,7 +379,6 @@ int TPrimanota_application::set_cgs_row(int n, const TImporto& imp,
row << "| |" << tipo;
disable_cgs_cells(n, tipo);
cg.force_update(n);
return n;
}
@ -1226,7 +1237,7 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k)
if (oldposiva < 0 && !oldiva.is_zero())
{
const int ri = tipod == 'D' ? 3 : 4; // Calcola riga causale per l'IVA
const int ri = tipod == 'D' ? RIGA_IVA_DETRAIBILE : RIGA_IVA_NON_DETRAIBILE;
TBill c; cau.bill(ri, c);
if (c.ok())
{
@ -1297,7 +1308,7 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k)
const int ri = detrarre ? RIGA_IVA_DETRAIBILE : RIGA_IVA_NON_DETRAIBILE;
TBill contoiva; cau.bill(ri, contoiva);
if (ri == 4 && !contoiva.ok()) // Se non c'e' il conto IVA indetraibile ...
if (!detrarre && !contoiva.ok()) // Se non c'e' il conto IVA indetraibile ...
{ // ... somma imponibile e imposta
imponibile += imposta;
imposta = 0.0;

View File

@ -68,6 +68,8 @@ class TPrimanota_application : public TRelation_application
TEsercizi_contabili _esercizi; // Tabella degli esercizi contabili
TAssoc_array _colori; // Colori delle righe
static bool showpartite_handler(TMask_field& f, KEY k);
static bool speserimb_handler(TMask_field& f, KEY k);
static bool altrespese_handler(TMask_field& f, KEY k);
@ -138,6 +140,7 @@ protected: // TApplication
virtual void on_firm_change();
virtual void on_config_change();
virtual void print();
virtual bool menu(MENU_TAG m);
protected: // TRelation_application
virtual bool user_create();
@ -161,7 +164,7 @@ protected:
void check_saldi();
void genera_incasso(const char* causimm);
void gioca_cambi(int force = 0x00);
TMask* load_mask(int n);
TMask& occas_mask() { return *load_mask(3); }
void open_files(int logicnum, ...);
@ -196,6 +199,12 @@ protected:
int bill2contr(const TBill& c, char sezione) const;
int bill_used(const TBill& conto) const;
TBill& ivas_bill(TBill& tc);
void load_colors();
void save_colors();
COLOR type2color(char tipor, char tipoc);
void set_type_color(char tipor, char tipoc, COLOR col);
void set_colors();
bool read_caus(const char* cod, int year);
TLibro_giornale& giornale() { return *_giornale; }
@ -249,6 +258,10 @@ protected:
public:
static char row_type(const TToken_string& s);
void type2colors(char tipor, COLOR& back, COLOR& fore);
void set_type_colors(char tipor, COLOR back, COLOR fore);
TCausale& causale() const { return *_causale; }
TPartite_array& partite() { return _partite; } // Partite editate
bool edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp);

View File

@ -8,18 +8,19 @@
int main(int argc,char** argv)
{
int rt = 0 ;
int rt = 0 ;
int s = atoi(argv[1]+1) ;
switch (s)
{
case 0: rt = cg3100(argc,argv) ; break;
case 1: rt = cg3200(argc,argv) ; break;
case 2: rt = cg3300(argc,argv) ; break;
case 3: rt = cg3400(argc,argv) ; break;
case 4: rt = cg3500(argc,argv) ; break;
default: error_box(usage, argv[0]) ; break;
}
case 1: rt = cg3200(argc,argv) ; break;
case 2: rt = cg3300(argc,argv) ; break;
case 3: rt = cg3400(argc,argv) ; break;
case 4: rt = cg3500(argc,argv) ; break;
case 5: rt = cg3600(argc,argv) ; break;
default: error_box(usage, argv[0]) ; break;
}
return rt;
}

View File

@ -20,6 +20,7 @@ int cg3200(int argc, char* argv[]);
int cg3300(int argc, char* argv[]);
int cg3400(int argc, char* argv[]);
int cg3500(int argc, char* argv[]);
int cg3600(int argc, char* argv[]);
#endif // __CG3_H

View File

@ -46,3 +46,10 @@ MENUBAR MENU_BAR(4)
MENU MENU_BAR(4)
SUBMENU MENU_FILE "~File"
/* ----------------------------------------------------
* cg3 -5
* ---------------------------------------------------- */
MENUBAR MENU_BAR(5)
MENU MENU_BAR(5)
SUBMENU MENU_FILE "~File"

View File

@ -7,6 +7,23 @@
#include "conto.h"
TBill::~TBill()
{
if (_descrizione)
delete _descrizione;
}
void TBill::set_description(const char* d)
{
if (_descrizione || (d && *d))
{
if (_descrizione)
*_descrizione = d;
else
_descrizione = new TString(d);
}
}
// Certified 90%
const TBill& TBill::get(TToken_string& s, int from, int mode)
{
@ -29,7 +46,7 @@ const TBill& TBill::get(TToken_string& s, int from, int mode)
_conto = s.get_int();
_sottoconto = s.get_long();
if (mode & 0x2)
_descrizione = s.get();
set_description(s.get());
_tipo_cr = -1;
_sezione = ' ';
@ -37,14 +54,13 @@ const TBill& TBill::get(TToken_string& s, int from, int mode)
return *this;
}
const TBill& TBill::copy(const TBill& bill)
{
_tipo = bill._tipo;
_gruppo = bill._gruppo;
_conto = bill._conto;
_sottoconto = bill._sottoconto;
_descrizione = bill._descrizione;
set_description(bill.descrizione());
_tipo_cr = bill._tipo_cr;
_sospeso = bill._sospeso;
_sezione = bill._sezione;
@ -59,7 +75,7 @@ const TBill& TBill::set(int g, int c, long s, char t, const char* d, int r)
_gruppo = g;
_conto = c;
_sottoconto = s;
_descrizione = d;
set_description(d);
_tipo_cr = r;
return *this;
}
@ -129,7 +145,7 @@ bool TBill::get(const TRectype& r, bool c)
r.get_long(field_name(2, c)),
r.get_char(field_name(3, c)));
_descrizione.cut(0);
set_description(NULL);
_tipo_cr = -1;
_sezione = ' ';
@ -150,7 +166,7 @@ void TBill::set(TMask& m, short g, short c, short s, short t, short d) const
m.set(t, typ);
}
if (d)
m.set(d, ((TBill*)this)->descrizione());
m.set(d, descrizione());
}
void TBill::get(const TMask& m, short g, short c, short s, short t, short d)
@ -214,7 +230,7 @@ bool TBill::find()
ok = clifo.read() == NOERR;
if (ok)
{
_descrizione = clifo.get("RAGSOC");
set_description(clifo.get("RAGSOC"));
if (_tipo_cr < 0)
{
_tipo_cr = 0;
@ -225,12 +241,12 @@ bool TBill::find()
const char tipoa = clifo.get_char("TIPOAPER");
if (tipoa == 'F') // Se persona fisica allora aggiusta la ragione sociale
{
TString nome(_descrizione.mid(30));
TString nome(descrizione().mid(30));
if (nome.not_empty())
{
_descrizione.cut(30);
_descrizione.trim(); nome.trim();
_descrizione << ' ' << nome;
_descrizione->cut(30);
_descrizione->trim(); nome.trim();
*_descrizione << ' ' << nome;
}
}
if (_gruppo == 0 || _conto == 0)
@ -258,7 +274,7 @@ bool TBill::read(TRectype &r)
r = pcon.curr();
_tipo_cr = r.get_int("TIPOSPRIC");
_sezione = r.get_char("SEZSALDI");
_descrizione = r.get("DESCR");
set_description(r.get("DESCR"));
_sospeso = r.get_bool("SOSPESO");
}
else
@ -287,14 +303,18 @@ int TBill::tipo_att()
// Certified 99%
const TString& TBill::descrizione() const
{
if (_descrizione.empty() && !empty())
{
TBill& myself = (TBill&)*this;
// Se il conto e valido (c'e' almeno il gruppo) cerca la sua descrizione su file
if ((_descrizione == NULL || _descrizione->blank()) && gruppo() != 0)
{
TBill& myself = (TBill&)*this;
if (!myself.find())
myself._descrizione = "Sconosciuto";
myself.set_description("Sconosciuto");
}
return _descrizione;
if (_descrizione == NULL)
myself._descrizione = new TString;
return *_descrizione;
}
int TBill::tipo_cr() const

View File

@ -19,7 +19,7 @@ class TBill : public TSortable
char _tipo; // ' ' = Conto, 'C' = Cliente, 'F' = 'Fornitore'
int _gruppo, _conto;
long _sottoconto; // Sottoconto, codice cliente o fornitore
TString _descrizione; // Vuota fino alla chiamata di describe
TString* _descrizione; // Vuota fino alla chiamata di describe
int _tipo_cr; // Tipo costo/ricavo
bool _sospeso;
char _sezione;
@ -28,6 +28,7 @@ protected:
virtual int compare(const TSortable& s) const;
virtual const char* class_name() const { return "Conto"; }
void set_description(const char* d);
const TBill& copy(const TBill& b);
const char* field_name(int n, bool contro) const;
@ -36,14 +37,23 @@ public: // TObject
public:
TBill(int g = 0, int c = 0, long s = 0L, char t = ' ', const char* d = NULL, int r = -1)
: _tipo(t), _gruppo(g), _conto(c), _sottoconto(s), _descrizione(d),
: _tipo(t), _gruppo(g), _conto(c), _sottoconto(s), _descrizione(NULL),
_sezione(' '), _sospeso(FALSE)
{ set(g,c,s,t,d,r);}
TBill(TToken_string& tgcsd, int from, int mode = 0) { get(tgcsd, from, mode); }
TBill(const TRectype& rec, bool contro = FALSE) { get(rec, contro); }
TBill(const TBill& b) { copy(b); }
virtual ~TBill() {}
TBill(TToken_string& tgcsd, int from, int mode = 0)
: _descrizione(NULL)
{ get(tgcsd, from, mode); }
TBill(const TRectype& rec, bool contro = FALSE)
: _descrizione(NULL)
{ get(rec, contro); }
TBill(const TBill& b)
: _descrizione(NULL)
{ copy(b); }
virtual ~TBill();
const TBill& set(int g = 0, int c = 0, long s = 0L, char t = ' ',
const char* d = NULL, int r = -1);