Corretto salvataggio righe %PLA ed eliminato controllo sul giornale
git-svn-id: svn://10.65.10.50/trunk@1034 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
b8db9bcfae
commit
ca0cd6f769
122
cg/cg5300.cpp
122
cg/cg5300.cpp
@ -25,11 +25,6 @@ class TParaliq_app : public TRelation_application
|
|||||||
TLocalisamfile * _ditte;
|
TLocalisamfile * _ditte;
|
||||||
int _yearliq;
|
int _yearliq;
|
||||||
TTable * _pla;
|
TTable * _pla;
|
||||||
TString_array _atts; // array di stringhe con i codici attivita'
|
|
||||||
TString_array _tips; // array di stringhe con i tipi attivita'
|
|
||||||
long _lastditta;
|
|
||||||
|
|
||||||
void check_registers(int year);
|
|
||||||
|
|
||||||
protected: // Applicat
|
protected: // Applicat
|
||||||
virtual void on_config_change();
|
virtual void on_config_change();
|
||||||
@ -54,12 +49,13 @@ protected: // Relapp
|
|||||||
virtual int read(TMask& m);
|
virtual int read(TMask& m);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void init_array(TMask& m);
|
void check_registers(int year);
|
||||||
static bool sheet_action(int r, KEY k);
|
void init_array(TMask& m, bool update);
|
||||||
|
static bool sheet_action(int r, KEY k);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TParaliq_app() { _lastditta = 0L; }
|
TParaliq_app() {}
|
||||||
virtual ~TParaliq_app() {}
|
virtual ~TParaliq_app() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -68,6 +64,7 @@ void TParaliq_app::check_registers(int year)
|
|||||||
{
|
{
|
||||||
// controlla che per ogni data attivita' esistano almeno un registro
|
// controlla che per ogni data attivita' esistano almeno un registro
|
||||||
// acquisti, vendite e giornale; warning appropriato in caso negativo
|
// acquisti, vendite e giornale; warning appropriato in caso negativo
|
||||||
|
TSheet_field& sf = (TSheet_field&)_msk->field(F_SHEET_PLA);
|
||||||
TTable reg("REG");
|
TTable reg("REG");
|
||||||
TRecfield reg_year(reg.curr(), "CODTAB", 0,3);
|
TRecfield reg_year(reg.curr(), "CODTAB", 0,3);
|
||||||
|
|
||||||
@ -75,19 +72,13 @@ void TParaliq_app::check_registers(int year)
|
|||||||
const byte R_VEN = 0x02;
|
const byte R_VEN = 0x02;
|
||||||
const byte R_ALL = R_ACQ | R_VEN;
|
const byte R_ALL = R_ACQ | R_VEN;
|
||||||
|
|
||||||
bool is_giornale = FALSE;
|
|
||||||
byte flags = 0x00;
|
byte flags = 0x00;
|
||||||
|
|
||||||
for (int i = 0; i < _atts.items(); i++)
|
for (int i = 0; i < sf.items(); i++)
|
||||||
{
|
{
|
||||||
TString& att = (TString&)_atts[i];
|
const TString16 att(sf.row(i).get(0));
|
||||||
for (reg.first(); !reg.eof(); reg.next())
|
for (reg.first(); !reg.eof(); reg.next())
|
||||||
{
|
{
|
||||||
if (atoi(reg_year) == year && reg.get_int("I0") == 5)
|
|
||||||
{
|
|
||||||
is_giornale = TRUE;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (atoi(reg_year) != year || att != reg.get("S8"))
|
if (atoi(reg_year) != year || att != reg.get("S8"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -99,8 +90,10 @@ void TParaliq_app::check_registers(int year)
|
|||||||
case 2: // acquisti
|
case 2: // acquisti
|
||||||
flags |= R_ACQ;
|
flags |= R_ACQ;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (flags == R_ALL && is_giornale) break;
|
if (flags == R_ALL) break;
|
||||||
}
|
}
|
||||||
if (flags < R_ALL)
|
if (flags < R_ALL)
|
||||||
{
|
{
|
||||||
@ -111,43 +104,46 @@ void TParaliq_app::check_registers(int year)
|
|||||||
warning_box(wrn);
|
warning_box(wrn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// libro giornale non si controlla per attivita'
|
|
||||||
if(!is_giornale)
|
|
||||||
warning_box("Non esiste probabilmente nessun "
|
|
||||||
"libro giornale per l'anno %d", year);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TParaliq_app::init_array(TMask& m)
|
void TParaliq_app::init_array(TMask& m, bool update)
|
||||||
{
|
{
|
||||||
|
TSheet_field& sf = (TSheet_field&)m.field(F_SHEET_PLA);
|
||||||
|
|
||||||
const long newditta = m.get_long(F_CODDITTA);
|
const long newditta = m.get_long(F_CODDITTA);
|
||||||
|
|
||||||
if (newditta != _lastditta)
|
_attiv->zero();
|
||||||
{
|
_attiv->put(ATT_CODDITTA, newditta);
|
||||||
_lastditta = newditta;
|
TRectype r(_attiv->curr());
|
||||||
_atts.destroy();
|
|
||||||
_tips.destroy();
|
int i = 0;
|
||||||
|
for(_attiv->read(_isgteq);
|
||||||
|
_attiv->good() && _attiv->curr() == r;
|
||||||
|
_attiv->next(), i++)
|
||||||
|
{
|
||||||
|
TToken_string& tt = sf.row(i);
|
||||||
|
|
||||||
_attiv->zero();
|
// istanzia array _atts on le attivita' della ditta corrente
|
||||||
_attiv->put(ATT_CODDITTA, newditta);
|
tt = "";
|
||||||
TRectype r(_attiv->curr());
|
tt.add(_attiv->get(ATT_CODATT));
|
||||||
|
tt.add(_attiv->get(ATT_TIPOATT));
|
||||||
for(_attiv->read(_isgteq);
|
tt.add("");
|
||||||
_attiv->status() == NOERR && _attiv->curr() == r;
|
tt.add("");
|
||||||
_attiv->next())
|
tt.add("");
|
||||||
{
|
tt.add("");
|
||||||
// istanzia array _atts on le attivita' della ditta corrente
|
}
|
||||||
_atts.add(_attiv->get(ATT_CODATT));
|
|
||||||
_tips.add(_attiv->get(ATT_TIPOATT));
|
if (update)
|
||||||
}
|
{
|
||||||
|
sf.force_update();
|
||||||
|
|
||||||
TString16 freq;
|
TString16 freq;
|
||||||
_ditte->put(NDT_CODDITTA, newditta);
|
_ditte->put(NDT_CODDITTA, newditta);
|
||||||
if (_ditte->read() == NOERR)
|
if (_ditte->read() == NOERR)
|
||||||
freq = _ditte->get(NDT_FREQVIVA);
|
freq = _ditte->get(NDT_FREQVIVA);
|
||||||
m.set(F_FREQ_VERS, freq);
|
m.set(F_FREQ_VERS, freq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -194,25 +190,8 @@ void TParaliq_app::init_query_mode(TMask& m)
|
|||||||
|
|
||||||
void TParaliq_app::init_insert_mode(TMask& m)
|
void TParaliq_app::init_insert_mode(TMask& m)
|
||||||
{
|
{
|
||||||
TSheet_field& sf = (TSheet_field&)m.field(F_SHEET_PLA);
|
|
||||||
TToken_string tt(60);
|
|
||||||
|
|
||||||
// Inizializza array delle attivita'
|
// Inizializza array delle attivita'
|
||||||
init_array(m);
|
init_array(m, TRUE);
|
||||||
|
|
||||||
// Inizializza array delle attivita'
|
|
||||||
for (int i = 0; i < _atts.items(); i++)
|
|
||||||
{
|
|
||||||
const TString& tips = _tips.row(i);
|
|
||||||
tt = _atts.row(i);
|
|
||||||
tt.add(tips);
|
|
||||||
tt.add("");
|
|
||||||
tt.add("");
|
|
||||||
tt.add("");
|
|
||||||
tt.add("");
|
|
||||||
sf.row(i) = tt;
|
|
||||||
}
|
|
||||||
sf.force_update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -229,12 +208,12 @@ int TParaliq_app::rewrite(const TMask& m)
|
|||||||
int err = NOERR;
|
int err = NOERR;
|
||||||
bool was = FALSE;
|
bool was = FALSE;
|
||||||
|
|
||||||
for (int i = 0; err == NOERR && i < _atts.items(); i++)
|
for (int i = 0; err == NOERR && i < sf.items(); i++)
|
||||||
{
|
{
|
||||||
TToken_string& tt = sf.row(i);
|
TToken_string& tt = sf.row(i);
|
||||||
const TString& att = _atts.row(i);
|
const TString16 att = tt.get(0);
|
||||||
const TString16 tips(tt.get(1));
|
const TString16 tips(tt.get(1));
|
||||||
const TString16 codtab(format("%05ld%4d%s1", firm, year, (const char *)att));
|
const TString16 codtab(format("%05ld%4d%s1", firm, year, (const char*)att));
|
||||||
|
|
||||||
_pla->zero();
|
_pla->zero();
|
||||||
_pla->put("CODTAB", codtab);
|
_pla->put("CODTAB", codtab);
|
||||||
@ -319,22 +298,27 @@ int TParaliq_app::read(TMask& m)
|
|||||||
TSheet_field& sf = (TSheet_field&)m.field(F_SHEET_PLA);
|
TSheet_field& sf = (TSheet_field&)m.field(F_SHEET_PLA);
|
||||||
sf.reset();
|
sf.reset();
|
||||||
|
|
||||||
const TString16 ctab = format("%05ld%d", firm, year);
|
const TString16 ctab = format("%05ld%4d", firm, year);
|
||||||
_pla->put("CODTAB", ctab);
|
_pla->put("CODTAB", ctab);
|
||||||
TToken_string tt(60);
|
TToken_string tt(80);
|
||||||
|
|
||||||
|
init_array(m, FALSE); // Carica tutti i codici attivita'
|
||||||
|
|
||||||
for (_pla->read(_isgteq); _pla->good(); _pla->next())
|
for (_pla->read(_isgteq); _pla->good(); _pla->next())
|
||||||
{
|
{
|
||||||
if (strncmp(ctab, _pla->get("CODTAB"), 9) == 0)
|
if (strncmp(ctab, _pla->get("CODTAB"), 9) == 0)
|
||||||
{
|
{
|
||||||
tt = "";
|
tt = _pla->get("CODTAB").mid(9,5); // codice attivita'
|
||||||
tt.add(_pla->get("CODTAB").mid(9,5)); // codice attivita'
|
|
||||||
|
for (int i = 0; i < sf.items(); i++) // Cerca riga corrispondente sullo sheet
|
||||||
|
if (tt == sf.row(i).get(0)) break;
|
||||||
|
|
||||||
tt.add(_pla->get("S7")); // tipo attivita'
|
tt.add(_pla->get("S7")); // tipo attivita'
|
||||||
tt.add(_pla->get("R8")); // prorata
|
tt.add(_pla->get("R8")); // prorata
|
||||||
tt.add(_pla->get("R5")); // plafond art. 8
|
tt.add(_pla->get("R5")); // plafond art. 8
|
||||||
tt.add(_pla->get("R6")); // plafond art. 8bis
|
tt.add(_pla->get("R6")); // plafond art. 8bis
|
||||||
tt.add(_pla->get("R7")); // plafond art. 9
|
tt.add(_pla->get("R7")); // plafond art. 9
|
||||||
sf.row(-1) = tt;
|
sf.row(i) = tt;
|
||||||
}
|
}
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user