Patch level : 12.0 964
Files correlati : cg5.exe cg5300a.msk Commento : Modificata la gestione dei parametri liquidazione per aggiungere e togliere attività da un anno
This commit is contained in:
parent
57eee7a34c
commit
fb73bcab4b
@ -51,8 +51,8 @@ protected: // Relapp
|
||||
virtual int read(TMask& m);
|
||||
|
||||
protected:
|
||||
void check_registers(int year);
|
||||
void init_array(TMask& m, bool update);
|
||||
void check_registers(int year, bool verbose = true);
|
||||
void init_array(TSheet_field& sf);
|
||||
static bool sheet_action(TSheet_field& s, int r, KEY k);
|
||||
|
||||
public:
|
||||
@ -148,7 +148,7 @@ bool TParaliq_app::credpreccost_handler(TMask_field& f, KEY k)
|
||||
return true;
|
||||
}
|
||||
|
||||
void TParaliq_app::check_registers(int year)
|
||||
void TParaliq_app::check_registers(int year, bool verbose)
|
||||
{
|
||||
// controlla che per ogni data attività esistano almeno un registro
|
||||
// acquisti, vendite e giornale; warning appropriato in caso negativo
|
||||
@ -185,7 +185,7 @@ void TParaliq_app::check_registers(int year)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flags < R_ALL)
|
||||
if (verbose && flags < R_ALL)
|
||||
{
|
||||
TString wrn(TR("I seguenti registri non esistono per l'attività "));
|
||||
wrn << att << "(" << year << "):";
|
||||
@ -193,38 +193,41 @@ void TParaliq_app::check_registers(int year)
|
||||
if ((flags & R_ACQ) == 0x00) wrn << TR("\n\tregistro acquisti");
|
||||
warning_box(wrn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TParaliq_app::init_array(TMask& m, bool update)
|
||||
void TParaliq_app::init_array(TSheet_field& sf)
|
||||
{
|
||||
TSheet_field& sf = m.sfield(F_SHEET_PLA);
|
||||
const long newditta = m.get_long(F_CODDITTA);
|
||||
TRelation att(LF_ATTIV);
|
||||
TRectype & r = att.curr();
|
||||
TRectype r(LF_ATTIV);
|
||||
|
||||
r.put(ATT_CODDITTA, newditta);
|
||||
r.put(ATT_CODDITTA, sf.mask().get_long(F_CODDITTA));
|
||||
|
||||
TCursor cur(&att, "", 1, &r, &r);
|
||||
TCursor cur(new TRelation(LF_ATTIV), "", 1, &r, &r);
|
||||
const TRecnotype items = cur.items();
|
||||
int i = 0;
|
||||
|
||||
cur.freeze();
|
||||
for (cur = 0L; cur.pos() < items; ++cur, i++)
|
||||
{
|
||||
TToken_string& tt = sf.row(i);
|
||||
|
||||
// istanzia array _atts on le attività della ditta corrente
|
||||
tt = r.get(ATT_CODATT);
|
||||
tt.add(r.get(ATT_TIPOATT));
|
||||
}
|
||||
|
||||
if (update)
|
||||
for (cur = 0L; cur.pos() < items; ++cur)
|
||||
{
|
||||
sf.force_update();
|
||||
const TString& freq = cache().get(LF_NDITTE,newditta,NDT_FREQVIVA);
|
||||
m.set(F_FREQ_VERS, freq);
|
||||
}
|
||||
const TString8 codatt = cur.curr().get(ATT_CODATT);
|
||||
bool found = false;
|
||||
int j = -1;
|
||||
|
||||
for (int i = 0; j < 0 && !found && i < sf.items(); i++) // Cerca riga corrispondente sullo sheet
|
||||
{
|
||||
const TString & row_codatt = sf.row(i).get(0);
|
||||
|
||||
if (codatt == row_codatt)
|
||||
found = true;
|
||||
else
|
||||
if (codatt < row_codatt)
|
||||
j = i;
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
j = sf.insert(j);
|
||||
sf.set_row_cell(F_CODATT, cur.curr().get(ATT_CODATT), j);
|
||||
sf.set_row_cell(F_TIPOATT, cur.curr().get(ATT_TIPOATT), j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TParaliq_app::on_config_change()
|
||||
@ -257,10 +260,41 @@ bool TParaliq_app::user_destroy()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool exist_reg(const char * att, int year)
|
||||
{
|
||||
TRelation reg("REG");
|
||||
TRectype & r = reg.curr();
|
||||
TString filter;
|
||||
|
||||
filter.format("(S8==\"\")||(S8==\"%s\")", (const char *)att);
|
||||
r.put("CODTAB", year);
|
||||
|
||||
TCursor cur(& reg, filter, 1, &r, &r);
|
||||
|
||||
return cur.items() > 0;
|
||||
}
|
||||
|
||||
bool TParaliq_app::sheet_action(TSheet_field& s, int r, KEY k)
|
||||
{
|
||||
// non si possono cancellare o aggiungere righe in PLA
|
||||
return (k != K_DEL && k != K_INS);
|
||||
switch (k)
|
||||
{
|
||||
case K_DEL :
|
||||
{
|
||||
const int year = s.mask().get_int(F_YEAR);
|
||||
const TString & att = s.row(s.selected()).get(F_CODATT);
|
||||
|
||||
if (exist_reg(att, year))
|
||||
return error_box(TR("Esiste almeno un registro su questa attività"));
|
||||
}
|
||||
break;
|
||||
case K_SHIFT + K_INS:
|
||||
app().init_array(s);
|
||||
s.force_update();
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void TParaliq_app::init_query_mode(TMask& m)
|
||||
@ -271,8 +305,8 @@ void TParaliq_app::init_query_mode(TMask& m)
|
||||
|
||||
void TParaliq_app::init_insert_mode(TMask& m)
|
||||
{
|
||||
// Inizializza array delle attività
|
||||
init_array(m, true);
|
||||
// Inizializza array delle attività
|
||||
init_array(m.sfield(F_SHEET_PLA));
|
||||
m.set(F_ROUNDLIQ, TCurrency::get_firm_dec());
|
||||
}
|
||||
|
||||
@ -292,9 +326,8 @@ int TParaliq_app::rewrite(const TMask& m)
|
||||
|
||||
for (int i = 0; err == NOERR && i < sf.items(); i++)
|
||||
{
|
||||
TToken_string& tt = sf.row(i);
|
||||
const TString16 att = tt.get(0);
|
||||
const TString16 tips = tt.get(1);
|
||||
const TString16 att = sf.get_str_row_cell(i, F_CODATT);
|
||||
const TString16 tips = sf.get_str_row_cell(i, F_TIPOATT);
|
||||
|
||||
TString16 codtab;
|
||||
codtab.format("%05ld%4d%s", firm, year, (const char*)att);
|
||||
@ -313,15 +346,13 @@ int TParaliq_app::rewrite(const TMask& m)
|
||||
real es_a9 = pla.get_real("R7");
|
||||
|
||||
pla.put("CODTAB", codtab);
|
||||
// scrive i campi (vedi a read() per i nomi)
|
||||
// in base alla riga sheet
|
||||
pla.put("S7", tips); // tipo attività
|
||||
pla.put("R8", tt.get()); // prorata
|
||||
pla.put("R5", tt.get()); // plafond art. 8
|
||||
pla.put("R6", tt.get()); // plafond art. 8bis
|
||||
pla.put("R7", tt.get()); // plafond art. 9
|
||||
pla.put("R8", sf.get_str_row_cell(i, F_PRORATA)); // prorata
|
||||
pla.put("R5", sf.get_str_row_cell(i, F_P8)); // plafond art. 8
|
||||
pla.put("R6", sf.get_str_row_cell(i, F_P8B)); // plafond art. 8bis
|
||||
pla.put("R7", sf.get_str_row_cell(i, F_P9)); // plafond art. 9
|
||||
|
||||
err = (was ? pla.rewrite() : pla.write());
|
||||
err = pla.rewrite_write();
|
||||
|
||||
// se si e' cambiato qualcosa..
|
||||
if ((prorata != pla.get_real("R8")) ||
|
||||
@ -339,24 +370,40 @@ int TParaliq_app::rewrite(const TMask& m)
|
||||
TCursor cur(&rellim, "", 1, &lim, &lim);
|
||||
const TRecnotype items = cur.items();
|
||||
|
||||
cur.freeze();
|
||||
for (cur = 0L; cur.pos() < items; ++cur)
|
||||
{
|
||||
// const int mese = atoi(lim.get("CODTAB").mid(4,2)); chiedere a cinzia
|
||||
// if (freq == 'M' || (freq == 'T' && mese == 3))
|
||||
// {
|
||||
rellim.lfile().reread(_lock);
|
||||
lim.zero("B0");
|
||||
rellim.rewrite();
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TTable& lia = (TTable&)_rel->lfile();
|
||||
TString16 ct; ct.format("%05ld%04d", firm, year);
|
||||
lia.put("CODTAB", ct);
|
||||
|
||||
TRelation relpla(TAB_PLA);
|
||||
TRectype & pla = relpla.curr();
|
||||
TArray rec_to_delete;
|
||||
|
||||
pla.put("CODTAB", format("%05ld%4d", firm, year));
|
||||
|
||||
TCursor cur(&relpla, "", 1, &pla, &pla);
|
||||
const TRecnotype items = cur.items();
|
||||
|
||||
for (cur = 0L; cur.pos() < items; ++cur)
|
||||
{
|
||||
const TString8 codatt = cur.curr().get("CODTAB").mid(9, 5);
|
||||
bool found = false;
|
||||
|
||||
for (int i = 0; !found && i < sf.items(); i++)
|
||||
found = codatt == sf.get_str_row_cell(i, F_CODATT);
|
||||
if (!found)
|
||||
rec_to_delete.add(cur.curr());
|
||||
}
|
||||
FOR_EACH_ARRAY_ITEM(rec_to_delete, r, obj)
|
||||
((TRectype *)obj)->remove(cur.file());
|
||||
|
||||
TTable& lia = (TTable&)_rel->lfile();
|
||||
|
||||
lia.put("CODTAB", format("%05ld%04d", firm, year));
|
||||
was = lia.read() == NOERR;
|
||||
if (!was) lia.zero();
|
||||
m.autosave(*_rel);
|
||||
@ -392,34 +439,29 @@ int TParaliq_app::read(TMask& m)
|
||||
const long firm = m.get_long(F_CODDITTA);
|
||||
const int year = m.get_int(F_YEAR);
|
||||
TSheet_field& sf = m.sfield(F_SHEET_PLA);
|
||||
TString16 ctab;
|
||||
TToken_string tt(80);
|
||||
TRelation relpla(TAB_PLA);
|
||||
TRectype & pla = relpla.curr();
|
||||
|
||||
ctab.format("%05ld%4d", firm, year);
|
||||
pla.put("CODTAB", ctab);
|
||||
pla.put("CODTAB", format("%05ld%4d", firm, year));
|
||||
|
||||
TCursor cur(&relpla, "", 1, &pla, &pla);
|
||||
const TRecnotype items = cur.items();
|
||||
|
||||
init_array(m, false); // Carica tutti i codici attività
|
||||
cur.freeze();
|
||||
for (cur = 0L; cur.pos() < items; ++cur)
|
||||
{
|
||||
tt = pla.get("CODTAB").mid(9,5); // codice attività
|
||||
int i;
|
||||
for (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 attività
|
||||
tt.add(pla.get("R8")); // prorata
|
||||
tt.add(pla.get("R5")); // plafond art. 8
|
||||
tt.add(pla.get("R6")); // plafond art. 8bis
|
||||
tt.add(pla.get("R7")); // plafond art. 9
|
||||
sf.row(i) = tt;
|
||||
}
|
||||
|
||||
sf.destroy();
|
||||
if (items == 0)
|
||||
init_array(sf); // Carica tutti i codici attività
|
||||
else
|
||||
for (cur = 0L; cur.pos() < items; ++cur)
|
||||
{
|
||||
const int nrow = sf.set_row_cell(F_CODATT, pla.get("CODTAB").mid(9,5)); // codice attività
|
||||
|
||||
sf.set_row_cell(F_TIPOATT, pla.get("S7"), nrow); // tipo attività
|
||||
sf.set_row_cell(F_PRORATA, pla.get("R8"), nrow); // prorata
|
||||
sf.set_row_cell(F_P8, pla.get("R5"), nrow); // plafond art. 8
|
||||
sf.set_row_cell(F_P8B, pla.get("R6"), nrow); // plafond art. 8bis
|
||||
sf.set_row_cell(F_P9, pla.get("R7"), nrow); // plafond art. 9
|
||||
}
|
||||
return NOERR;
|
||||
}
|
||||
|
||||
@ -430,20 +472,3 @@ int cg5300(int argc, char* argv[])
|
||||
a.run(argc, argv, TR("Parametri liquidazione"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -310,18 +310,24 @@ TOOLBAR "topbar" 0 0 0 2
|
||||
|
||||
BUTTON DLG_OK 9 2
|
||||
BEGIN
|
||||
PROMPT -13 -1 ""
|
||||
PROMPT -14 -1 ""
|
||||
END
|
||||
|
||||
BUTTON DLG_NULL 9 2
|
||||
BEGIN
|
||||
PROMPT -23 -1 "Azzera"
|
||||
PROMPT -24 -1 "Azzera"
|
||||
MESSAGE RESET,1@
|
||||
END
|
||||
|
||||
BUTTON DLG_DELREC 9 2
|
||||
BEGIN
|
||||
PROMPT -34 -1 "Elimina"
|
||||
MESSAGE EXIT,K_DEL
|
||||
END
|
||||
|
||||
BUTTON DLG_CANCEL 9 2
|
||||
BEGIN
|
||||
PROMPT -33 -1 ""
|
||||
PROMPT -34 -1 ""
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
Loading…
x
Reference in New Issue
Block a user