Prima implementazione dell'oggetto sconto. Il motore adesso si accorge se sono
state modificate le impostazioni e chiede di rigenerare le maschere git-svn-id: svn://10.65.10.50/trunk@1832 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
d3eaeb214b
commit
2749cef346
110
ve/sconti.cpp
Executable file
110
ve/sconti.cpp
Executable file
@ -0,0 +1,110 @@
|
||||
#ifndef __SCONTI_H
|
||||
#include "sconti.h"
|
||||
#endif
|
||||
|
||||
const real TSconto::cento( "100" );
|
||||
|
||||
void TSconto::set( const TString& exp, bool signal )
|
||||
{
|
||||
TString work( exp );
|
||||
TString goodexp;
|
||||
TString num;
|
||||
|
||||
// Elimina gli spazi molesti
|
||||
work.strip_spaces( );
|
||||
// Per ora nessun errore
|
||||
_errorpos = -1;
|
||||
|
||||
int i = 0;
|
||||
_part = 1.0;
|
||||
const int wlen = work.len( );
|
||||
// Flag che indica se sono nella parte decimale di un numero
|
||||
bool dec = FALSE;
|
||||
// Flag che indica se si attende l'inizio di un numero
|
||||
bool startnum = TRUE;
|
||||
// Flag che indica se siamo all'inizio di un numero
|
||||
while ( i < wlen && _errorpos < 0 )
|
||||
{
|
||||
char c = work[ i++ ];
|
||||
switch( c )
|
||||
{
|
||||
case '+':
|
||||
case '-':
|
||||
// Se ero in in numero ...
|
||||
if( !startnum )
|
||||
{
|
||||
// Aggiunge il numero alla sequenza
|
||||
real newval( num );
|
||||
_part = _part * ( cento + newval ) / cento;
|
||||
if( newval >= 0 )
|
||||
goodexp << '+';
|
||||
goodexp << num;
|
||||
}
|
||||
// Inizia il nuovo numero
|
||||
num = ( c == '-' )?"-":"";
|
||||
startnum = TRUE;
|
||||
dec = FALSE;
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
num << c;
|
||||
startnum = FALSE;
|
||||
break;
|
||||
case '.':
|
||||
case ',':
|
||||
// Se siamo già nella parte decimale ...
|
||||
if( dec )
|
||||
{
|
||||
// Segnala un errore
|
||||
_errorpos = i;
|
||||
break;
|
||||
}
|
||||
// Se occorrenva un numero ci metto lo 0
|
||||
if( startnum )
|
||||
num << '0';
|
||||
// Interpreto la virgola come punto
|
||||
num << '.';
|
||||
dec = TRUE;
|
||||
startnum = TRUE;
|
||||
break;
|
||||
default:
|
||||
_errorpos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Controlla la validità
|
||||
_valid = ( _errorpos < 0 );
|
||||
// Se richiesto segnala l'errore
|
||||
if( !_valid && signal )
|
||||
warning_box( "Espressione di sconto non valida. Errore sul carattere %d.", _errorpos + 1 );
|
||||
if( _valid )
|
||||
{
|
||||
// Aggiunge l'ultimo numero preso
|
||||
real lastval( num );
|
||||
_part = _part * ( cento + lastval ) / cento;
|
||||
if( lastval >= 0 )
|
||||
goodexp << '+';
|
||||
goodexp << num;
|
||||
// Assegna la nuova espressione formattata bene
|
||||
_exp = goodexp;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Azzera la sequenza di percentuali
|
||||
_part = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
real TSconto::sconto( )
|
||||
{
|
||||
CHECK(is_valid( ),"tentativo di usare uno sconto non valido!" );
|
||||
return ( ( _part * cento ) - cento );
|
||||
}
|
31
ve/sconti.h
Executable file
31
ve/sconti.h
Executable file
@ -0,0 +1,31 @@
|
||||
#ifndef __SCONTI_H
|
||||
#define __SCONTI_H
|
||||
|
||||
#ifndef __REAL_H
|
||||
#include <real.h>
|
||||
#endif
|
||||
|
||||
#define CHKVALID CHECK( _valid, "Tentativo di usare uno sconto non valido!" )
|
||||
|
||||
class TSconto : public TObject
|
||||
{
|
||||
private:
|
||||
|
||||
TString _exp;
|
||||
bool _valid;
|
||||
int _errorpos;
|
||||
real _part;
|
||||
static const real cento;
|
||||
|
||||
public:
|
||||
|
||||
TString& get( void ){ CHKVALID; return _exp; }
|
||||
void set( const TString& exp, bool signal = FALSE );
|
||||
bool is_valid( ){ return _valid; }
|
||||
real sconto( );
|
||||
char * scontostr( int len = 0, int dec = UNDEFINED, char pad = ' ' ){ CHKVALID; real p(sconto()); return p.stringa( len, dec, pad ); }
|
||||
|
||||
};
|
||||
|
||||
#undef CHKVALID
|
||||
#endif
|
@ -72,6 +72,17 @@
|
||||
#include "tmaskven.h"
|
||||
#endif
|
||||
|
||||
#ifndef __EXECP_H
|
||||
#include "execp.h"
|
||||
#endif
|
||||
|
||||
#ifndef __SCONTI_H
|
||||
#include "sconti.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define CHANGE_MESSAGE "Sono state effettuate modifiche alla configurazione.\nPrima di eseguire la gestione documenti occorrerà rigenerare le maschere.\nDesideri farlo ora ?"
|
||||
|
||||
|
||||
|
||||
// Numero di colonne presenti sullo sheet totale
|
||||
@ -1046,6 +1057,28 @@ void TMotore_application::calcola_riga( TRectype& r, bool temp )
|
||||
|
||||
bool TMotore_application::user_create( )
|
||||
{
|
||||
TSconto s;
|
||||
s.set( "12 - 23 + 12.2 +.5 ", TRUE );
|
||||
if( s.is_valid( ) )
|
||||
warning_box( "Sconto: %s( %s )", (const char *)s.get( ), (const char *)s.scontostr( ) );
|
||||
s.set( ".5-.5", TRUE );
|
||||
if( s.is_valid( ) )
|
||||
warning_box( "Sconto: %s( %s )", (const char *)s.get( ), (const char *)s.scontostr( ) );
|
||||
s.set( "12 - 2.3 + 12.2.1 +.5 ", TRUE );
|
||||
if( s.is_valid( ) )
|
||||
warning_box( "Sconto: %s( %s )", (const char *)s.get( ), (const char *)s.scontostr( ) );
|
||||
|
||||
TConfig ditta( CONFIG_DITTA );
|
||||
|
||||
// Controllo se sono cambiate le impostazioni delle vendite.
|
||||
if( ditta.get_bool( "CHANGED", "ve" ) )
|
||||
{ // Se sono cambiate, rigenero tutte le maschere
|
||||
if ( !yesno_box( CHANGE_MESSAGE ) )
|
||||
return FALSE;
|
||||
TExternal_app motore2( "VE0 -3 -all" );
|
||||
motore2.run( );
|
||||
ditta.set( "CHANGED", "", "ve" );
|
||||
}
|
||||
_clifor = new TCliForVendite( );
|
||||
azzera_piedi( );
|
||||
_msk = new TMask("VE1000A");
|
||||
|
@ -14,7 +14,9 @@
|
||||
|
||||
#ifndef __TABUTIL_H
|
||||
#include <tabutil.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define SINTASSI "Sintassi: VE0 -2 [a|b|c|d|e]"
|
||||
|
||||
class TConf_vendite : public TConfig_application
|
||||
{
|
||||
@ -23,6 +25,7 @@ class TConf_vendite : public TConfig_application
|
||||
bool _changed;
|
||||
|
||||
public:
|
||||
|
||||
virtual bool preprocess_config (TMask& mask, TConfig& config);
|
||||
virtual bool postprocess_config_changed (const char* par, const char* var,
|
||||
const char* oldv, const char* newv);
|
||||
@ -33,7 +36,7 @@ class TConf_vendite : public TConfig_application
|
||||
TConf_vendite() : TConfig_application( CONFIG_DITTA ){ }
|
||||
virtual ~TConf_vendite( ){ }
|
||||
};
|
||||
|
||||
|
||||
bool TConf_vendite::preprocess_config (TMask& mask, TConfig& config)
|
||||
{
|
||||
disable_menu_item(M_FILE_NEW);
|
||||
@ -43,7 +46,6 @@ bool TConf_vendite::preprocess_config (TMask& mask, TConfig& config)
|
||||
|
||||
bool TConf_vendite::postprocess_config (TMask& mask, TConfig& config)
|
||||
{
|
||||
_changed = FALSE;
|
||||
enable_menu_item(M_FILE_NEW);
|
||||
enable_menu_item(M_FILE_REVERT);
|
||||
return TRUE;
|
||||
@ -60,33 +62,36 @@ bool TConf_vendite::postprocess_config_changed (const char* par, const char* var
|
||||
|
||||
bool TConf_vendite::user_create( )
|
||||
{
|
||||
char msk = argv(2)[0];
|
||||
TString16 arg( argv(2) );
|
||||
_changed = FALSE;
|
||||
// Il fottuto meno serve per evitare fottutamente che la fottuta confapp
|
||||
// si fotta il fottuto parametro
|
||||
if( arg[ 0 ] != '-' )
|
||||
fatal_box( SINTASSI );
|
||||
char msk = arg[1];
|
||||
// Devo usare un puntatore così deletandolo si registra
|
||||
TConfig confditta( CONFIG_DITTA );
|
||||
// Prima usavo le lettere ma la fottuta confapp si fotte il fottuto -c per i suoi fottuti
|
||||
// motivi, così uso i fottuti numeri
|
||||
switch( msk )
|
||||
{
|
||||
case 'a':
|
||||
case 'A':
|
||||
confditta.set( "EdMask", "ve0200a" "ve" );
|
||||
case '1':
|
||||
confditta.set( "EdMask", "ve0200a", "ve" );
|
||||
break;
|
||||
case 'b':
|
||||
case 'B':
|
||||
confditta.set( "EdMask", "ve0200b" "ve" );
|
||||
case '2':
|
||||
confditta.set( "EdMask", "ve0200b", "ve" );
|
||||
break;
|
||||
case 'c':
|
||||
case 'C':
|
||||
confditta.set( "EdMask", "ve0200c" "ve" );
|
||||
case '3':
|
||||
confditta.set( "EdMask", "ve0200c", "ve" );
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
confditta.set( "EdMask", "ve0200d" "ve" );
|
||||
case '4':
|
||||
confditta.set( "EdMask", "ve0200d", "ve" );
|
||||
break;
|
||||
case 'e':
|
||||
case 'E':
|
||||
confditta.set( "EdMask", "ve0200e" "ve" );
|
||||
case '5':
|
||||
confditta.set( "EdMask", "ve0200e", "ve" );
|
||||
break;
|
||||
default:
|
||||
fatal_box( "Sintassi: VE0 -2 [a|b|c|d|e]" );
|
||||
fatal_box( SINTASSI );
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
@ -97,7 +102,7 @@ bool TConf_vendite::user_destroy( )
|
||||
{
|
||||
if( _changed )
|
||||
{
|
||||
TConfig confditta( CONFIG_DITTA );
|
||||
TConfig confditta( CONFIG_DITTA );
|
||||
confditta.set( "EdMask", "", "ve" );
|
||||
confditta.set( "CHANGED", "X", "ve" );
|
||||
}
|
||||
@ -109,7 +114,7 @@ int ve0200(int argc, char** argv)
|
||||
TConf_vendite appc;
|
||||
|
||||
if( argc < 3 )
|
||||
fatal_box( "Sintassi: VE0 -2 [a|b|c|d|e]" );
|
||||
fatal_box( SINTASSI );
|
||||
appc.run(argc, argv, "Parametri gestione vendite");
|
||||
return 0;
|
||||
}
|
||||
|
119
ve/ve0300.cpp
119
ve/ve0300.cpp
@ -35,10 +35,22 @@
|
||||
#include <utility.h>
|
||||
#endif
|
||||
|
||||
#ifndef __PROGIND_H
|
||||
#include <progind.h>
|
||||
#endif
|
||||
|
||||
#ifndef __TABUTIL_H
|
||||
#include <tabutil.h>
|
||||
#endif
|
||||
|
||||
#ifndef __DEFMASK_H
|
||||
#include <defmask.h>
|
||||
#endif
|
||||
|
||||
#ifndef __RELATION_H
|
||||
#include <relation.h>
|
||||
#endif
|
||||
|
||||
#ifndef __VE0100_H
|
||||
#include "ve0100.h"
|
||||
#endif
|
||||
@ -530,6 +542,8 @@ private:
|
||||
|
||||
// Campi dello sheet
|
||||
TString_array _tab0300b;
|
||||
|
||||
TArray _campi;
|
||||
|
||||
protected:
|
||||
|
||||
@ -584,7 +598,7 @@ public:
|
||||
TMask_generator( const TString& profilo );
|
||||
|
||||
// Attiva la generazione della maschera
|
||||
void genera( );
|
||||
void genera( const TString& );
|
||||
|
||||
// Distruttore
|
||||
virtual ~TMask_generator( );
|
||||
@ -594,37 +608,35 @@ public:
|
||||
// Definizione dei metodi di TMask_generator
|
||||
// -----------------------------------------
|
||||
|
||||
TMask_generator::TMask_generator( const TString& profilo ) : _proname( profilo ), _fieldsini( "ve0300a.ini" ), _groupsini( "ve0300c.ini" ), _ditta( CONFIG_DITTA )
|
||||
TMask_generator::TMask_generator( const TString& profilo ) : _fieldsini( "ve0300a.ini" ), _groupsini( "ve0300c.ini" ), _ditta( CONFIG_DITTA )
|
||||
{
|
||||
// All'inizio il gruppo è 'chiuso'
|
||||
_groupopen = FALSE;
|
||||
|
||||
// Forza l'estensione al profilo
|
||||
_proname.ext( "ini" );
|
||||
|
||||
// Se il file di profilo non esiste, esci con un errore fatale
|
||||
if ( !fexist( _proname ) )
|
||||
fatal_box( "Il file %s non esiste!", ( const char * )_proname );
|
||||
|
||||
CHECK( fexist( "ve0300a.ini" ), "Il file ve0300a.ini non esiste!" );
|
||||
_fieldsini.list_paragraphs( _fields );
|
||||
CHECK( fexist( "ve0300b.dat" ), "Il file ve0300b.dat non esiste!" );
|
||||
carica_tabella( "ve0300b.dat", _tab0300b );
|
||||
|
||||
_pro = new TConfig( _proname );
|
||||
|
||||
TFilename _mskname( _pro->get( "MSKFILE", "MAIN") );
|
||||
_mskname.ext( "msk" );
|
||||
|
||||
|
||||
_m = new TMaschera( _mskname );
|
||||
|
||||
};
|
||||
carica_dati_campi( "ve0300a.ini", _campi );
|
||||
TString16 param( profilo );
|
||||
param.lower( );
|
||||
if( param == "-all" )
|
||||
{
|
||||
TRelation rel("TIP");
|
||||
TCursor t( &rel );
|
||||
long count = t.items();
|
||||
TProgind bar( count, "Generazione delle maschere", FALSE, TRUE);
|
||||
t = 0;
|
||||
while( t.ok() )
|
||||
{
|
||||
genera( t.curr().get( "S4" ) );
|
||||
++t;
|
||||
bar.addstatus(1);
|
||||
}
|
||||
}
|
||||
else genera( profilo );
|
||||
}
|
||||
|
||||
TMask_generator::~TMask_generator( )
|
||||
{
|
||||
delete _m;
|
||||
delete _pro;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -871,15 +883,30 @@ void TMask_generator::intestazione_pagina( )
|
||||
|
||||
}
|
||||
|
||||
void TMask_generator::genera( )
|
||||
void TMask_generator::genera( const TString& profilo )
|
||||
{
|
||||
int i;
|
||||
TString temp_s;
|
||||
TFilename proname( profilo ),
|
||||
// All'inizio il gruppo è 'chiuso'
|
||||
_groupopen = FALSE;
|
||||
|
||||
// Forza l'estensione al profilo
|
||||
proname.ext( "ini" );
|
||||
|
||||
// Se il file di profilo non esiste, esci con un errore fatale
|
||||
if ( !fexist( proname ) )
|
||||
fatal_box( "Il file %s non esiste!", ( const char * )proname );
|
||||
|
||||
_pro = new TConfig( proname );
|
||||
|
||||
TFilename _mskname( _pro->get( "MSKFILE", "MAIN") );
|
||||
_mskname.ext( "msk" );
|
||||
|
||||
|
||||
_m = new TMaschera( _mskname );
|
||||
|
||||
// Definizione della toolbar
|
||||
|
||||
|
||||
_m->outline( "TOOLBAR \"\" 0 20 0 2" );
|
||||
|
||||
_m->control( T_BOTTONE, 18, 802 );
|
||||
@ -1061,30 +1088,29 @@ void TMask_generator::genera( )
|
||||
|
||||
// Scorro l'array dei campi, per vedere gli stati ed i gruppi
|
||||
|
||||
TArray campi;
|
||||
TAssoc_array gruppi;
|
||||
|
||||
carica_dati_campi( "ve0300a.ini", campi );
|
||||
int last = campi.items( );
|
||||
int last = _campi.items( );
|
||||
for( i = 0; i < last; i ++ )
|
||||
{
|
||||
TString nome = (( TField & )campi[ i ]).nome( );
|
||||
TString nome = (( TField & )_campi[ i ]).nome( );
|
||||
int stato = stato_del_campo( nome );
|
||||
if( stato != S_NASCOSTO )
|
||||
{
|
||||
const int addgruppo = (( TField & )campi[ i ]).gruppo( );
|
||||
const int addgruppo = (( TField & )_campi[ i ]).gruppo( );
|
||||
TString16 chiave;
|
||||
chiave.format( "%5d", addgruppo );
|
||||
if ( !gruppi.is_key( chiave ) )
|
||||
gruppi.add( chiave, new TGruppo( addgruppo, _groupsini ) );
|
||||
}
|
||||
(( TField & )campi[ i ]).stato( stato );
|
||||
(( TField & )_campi[ i ]).stato( stato );
|
||||
};
|
||||
campi.sort( sort_by_group );
|
||||
// Si ordinano a mano nel .INI per velocizzare il processo di generazione
|
||||
// campi.sort( sort_by_group );
|
||||
|
||||
// Generazione vera e propria
|
||||
_m->_pageopen = TRUE;
|
||||
last = campi.items( );
|
||||
last = _campi.items( );
|
||||
int curgruppo = 0;
|
||||
for( i = 0; i < last; i ++ )
|
||||
{
|
||||
@ -1093,7 +1119,7 @@ void TMask_generator::genera( )
|
||||
intestazione_pagina( );
|
||||
_m->_pageopen = TRUE;
|
||||
}
|
||||
TField& campo = ( TField& ) campi[ i ];
|
||||
TField& campo = ( TField& ) _campi[ i ];
|
||||
if ( campo.gruppo( ) != curgruppo )
|
||||
{
|
||||
TString16 chiave;
|
||||
@ -1116,9 +1142,9 @@ void TMask_generator::genera( )
|
||||
_m->line( _m->line( ) + ( ( TGruppo& ) gruppi[ vecchiachiave ]).height( ) );
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
curgruppo = campo.gruppo( );
|
||||
};
|
||||
}
|
||||
campo.configura( *_pro );
|
||||
campo.genera( *_m );
|
||||
}
|
||||
@ -1127,27 +1153,27 @@ void TMask_generator::genera( )
|
||||
|
||||
// Generazione del listbox per i tipi di riga da aggiungere nello sheet
|
||||
_m->control ( T_LISTA, F_LBTIPORIGA, 30 );
|
||||
_m->begin();
|
||||
_m->begin( );
|
||||
_m->prompt( 2, 7, "Tipo riga da aggiungere " );
|
||||
_m->end( );
|
||||
|
||||
// Generazione dello sheet : vedi il profilo
|
||||
TScanner sheet_in( "ve0300b.dat" );
|
||||
_m->_out << "SPREADSHEET " << F_SHEET << " 76 6 \n";
|
||||
_m->begin();
|
||||
_m->begin( );
|
||||
_m->prompt( 2, 8 );
|
||||
for( i = 0; i < _tab0300b.items( ); i ++ )
|
||||
genera_item_sheet( _tab0300b.row( i ) );
|
||||
_m->end();
|
||||
|
||||
_m->control( T_MEMO, F_MEMORIGA, 7604 );
|
||||
_m->begin();
|
||||
_m->begin( );
|
||||
_m->prompt( 2, 15, " " );
|
||||
_m->field( "34->DESCEST" );
|
||||
_m->end( );
|
||||
|
||||
|
||||
_m->end();
|
||||
_m->end( );
|
||||
|
||||
// Generazione pagina dei piedi
|
||||
TToken_string s(_pro->get( "PROGPIEDE", "MAIN" ) );
|
||||
@ -1182,9 +1208,11 @@ void TMask_generator::genera( )
|
||||
id( 101 );
|
||||
for( i = 0; i < _tab0300b.items( ); i ++ )
|
||||
genera_campo_sheet( _tab0300b.row( i ) );
|
||||
_m->end();
|
||||
_m->end();
|
||||
_m->end( );
|
||||
_m->end( );
|
||||
_m->endmask( );
|
||||
delete _m;
|
||||
delete _pro;
|
||||
}
|
||||
|
||||
|
||||
@ -1203,8 +1231,7 @@ protected:
|
||||
|
||||
bool TGenMask_application::menu(MENU_TAG _m)
|
||||
{
|
||||
TMask_generator a( argv( 2 ) );
|
||||
a.genera( );
|
||||
TMask_generator a( argv( 2 ) );
|
||||
return( TRUE );
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user