Patch level : 2.2
Files correlati : ca2 Ricompilazione Demo : [ ] Commento : Migliorata rigenerazione righe analitiche a partire da quelle contabili nel caso di conti privi di ripartizione. Se possibile vengono anche preservate commessa e fase. git-svn-id: svn://10.65.10.50/trunk@13689 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
b841ba91d7
commit
30350733cb
139
ca/ca2100.cpp
139
ca/ca2100.cpp
@ -21,6 +21,7 @@
|
|||||||
class TMovanal_msk : public TAutomask
|
class TMovanal_msk : public TAutomask
|
||||||
{
|
{
|
||||||
TAssoc_array _saldi;
|
TAssoc_array _saldi;
|
||||||
|
bool _use_pdc;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool on_field_event(TOperable_field& o, TField_event fe, long jolly);
|
virtual bool on_field_event(TOperable_field& o, TField_event fe, long jolly);
|
||||||
@ -39,6 +40,7 @@ protected:
|
|||||||
|
|
||||||
int create_sheet_fields(int lf, int& y, short& dlg, bool required);
|
int create_sheet_fields(int lf, int& y, short& dlg, bool required);
|
||||||
void create_sheet();
|
void create_sheet();
|
||||||
|
int get_constant_columns(TToken_string& tok) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void reset_saldi();
|
void reset_saldi();
|
||||||
@ -188,39 +190,48 @@ void TMovanal_msk::split_cg_row(const TRectype& row, const TRecord_array& rrip)
|
|||||||
|
|
||||||
bool TMovanal_msk::is_ripartible_movcg()
|
bool TMovanal_msk::is_ripartible_movcg()
|
||||||
{
|
{
|
||||||
const TString& numregcg = get(F_NUMREGCG);
|
bool ok = true;
|
||||||
TRecord_array cg(numregcg, LF_RMOV);
|
if (!_use_pdc)
|
||||||
|
|
||||||
TString80 query;
|
|
||||||
for (int r = cg.last_row(); r > 0; r--)
|
|
||||||
{
|
{
|
||||||
const TRectype& row = cg.row(r);
|
const TString& numregcg = get(F_NUMREGCG);
|
||||||
for (int i = 3; i > 0; i--)
|
TRecord_array cg(numregcg, LF_RMOV);
|
||||||
{
|
|
||||||
query = "USE RIP SELECT";
|
|
||||||
query << " (GRUPPO=" << row.get(RMV_GRUPPO) << ')'; // Il gruppo c'e' sempre
|
|
||||||
const int conto = i > 1 ? row.get_int(RMV_CONTO) : 0; // Il conto c'e' per i = 2 o 3
|
|
||||||
query << "&&(CONTO=" << conto << ')';
|
|
||||||
if (conto > 0)
|
|
||||||
{
|
|
||||||
const long sotto = i > 2 ? row.get_long(RMV_SOTTOCONTO) : 0; // Il sottoconto c'e' per i = 3
|
|
||||||
query << "&&(SOTTOCONTO=" << sotto << ')';
|
|
||||||
}
|
|
||||||
query << "\nFROM TIPO='I'\nTO TIPO='I'";
|
|
||||||
|
|
||||||
TISAM_recordset rs(query);
|
TString80 query;
|
||||||
if (rs.items() > 0) // Ho trovato la ripartizione!
|
for (int r = cg.last_row(); r > 0; r--)
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i <= 0) // Non trovato la ripartizione
|
|
||||||
{
|
{
|
||||||
return error_box("Non esiste una ripartizione del conto %d.%d.%ld\n"
|
const TRectype& row = cg.row(r);
|
||||||
"presente sulla riga %d del movimento %ld",
|
const TBill zio(row);
|
||||||
row.get_int(RMV_GRUPPO), row.get_int(RMV_CONTO), row.get_long(RMV_SOTTOCONTO),
|
if (zio.is_analitico())
|
||||||
r, atol(numregcg));
|
{
|
||||||
|
for (int i = 3; i > 0; i--)
|
||||||
|
{
|
||||||
|
query = "USE RIP SELECT";
|
||||||
|
query << " (GRUPPO=" << zio.gruppo() << ')'; // Il gruppo c'e' sempre
|
||||||
|
const int conto = i > 1 ? zio.conto() : 0; // Il conto c'e' per i = 2 o 3
|
||||||
|
query << "&&(CONTO=" << conto << ')';
|
||||||
|
if (conto > 0)
|
||||||
|
{
|
||||||
|
const long sotto = i > 2 ? zio.sottoconto() : 0; // Il sottoconto c'e' per i = 3
|
||||||
|
query << "&&(SOTTOCONTO=" << sotto << ')';
|
||||||
|
}
|
||||||
|
query << "\nFROM TIPO='I'\nTO TIPO='I'";
|
||||||
|
|
||||||
|
TISAM_recordset rs(query);
|
||||||
|
if (rs.items() > 0) // Ho trovato la ripartizione!
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i <= 0) // Non trovato la ripartizione
|
||||||
|
{
|
||||||
|
ok = error_box("Non esiste una ripartizione del conto %d.%d.%ld\n"
|
||||||
|
"presente sulla riga %d del movimento %ld",
|
||||||
|
zio.gruppo(), zio.conto(), zio.sottoconto(),
|
||||||
|
r, atol(numregcg));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TMovanal_msk::load_cg_row(const TRectype& row)
|
void TMovanal_msk::load_cg_row(const TRectype& row)
|
||||||
@ -256,10 +267,21 @@ void TMovanal_msk::load_cg_row(const TRectype& row)
|
|||||||
if (i == 0) // Non ho trovato nessuno schema di ripartizione valido
|
if (i == 0) // Non ho trovato nessuno schema di ripartizione valido
|
||||||
{
|
{
|
||||||
// Creo una riga nuova
|
// Creo una riga nuova
|
||||||
TToken_string& riga = sfield(F_RIGHE).row(-1);
|
TSheet_field& sheet = sfield(F_RIGHE);
|
||||||
|
TToken_string& riga = sheet.row(-1);
|
||||||
const TImporto imp(row.get_char(RMV_SEZIONE), row.get_real(RMV_IMPORTO));
|
const TImporto imp(row.get_char(RMV_SEZIONE), row.get_real(RMV_IMPORTO));
|
||||||
imp2row(imp, riga); // Ci copio l'importo
|
imp2row(imp, riga); // Ci copio l'importo
|
||||||
riga.add(row.get(RMV_DESCR), 2); // e la descrizione della riga contabile
|
riga.add(row.get(RMV_DESCR), 2); // e la descrizione della riga contabile
|
||||||
|
|
||||||
|
if (_use_pdc)
|
||||||
|
{
|
||||||
|
TMask_field* f = sheet.sheet_mask().find_by_fieldname(RMOVANA_CODCONTO);
|
||||||
|
const int pos = sheet.cid2index(f->dlg());
|
||||||
|
TString8 str;
|
||||||
|
str = row.get(RMV_GRUPPO); str.right_just(3, '0'); riga.add(str, pos-2);
|
||||||
|
str = row.get(RMV_CONTO); str.right_just(3, '0'); riga.add(str, pos-1);
|
||||||
|
str = row.get(RMV_SOTTOCONTO); str.right_just(6, '0'); riga.add(str, pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,6 +323,44 @@ void TMovanal_msk::load_cg_mov()
|
|||||||
set(F_SEZIONE, sez);
|
set(F_SEZIONE, sez);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TMovanal_msk::get_constant_columns(TToken_string& tok) const
|
||||||
|
{
|
||||||
|
int n = 0;
|
||||||
|
TSheet_field& sf = sfield(F_RIGHE);
|
||||||
|
const int items = sf.items();
|
||||||
|
if (items > 0)
|
||||||
|
{
|
||||||
|
TMask& m = sf.sheet_mask();
|
||||||
|
for (int f = 0; f < m.fields(); f++)
|
||||||
|
{
|
||||||
|
const TMask_field& mf = m.fld(f);
|
||||||
|
const TFieldref* fr = mf.field();
|
||||||
|
if (fr != NULL && !fr->name().starts_with(RMOVANA_CODCONTO))
|
||||||
|
{
|
||||||
|
const int i = sf.cid2index(mf.dlg());
|
||||||
|
if (i >= 2)
|
||||||
|
{
|
||||||
|
const TString campione = sf.row(0).get(i);
|
||||||
|
if (!campione.blank())
|
||||||
|
{
|
||||||
|
for (int j = items-1; j > 0; j--)
|
||||||
|
{
|
||||||
|
if (campione != sf.row(j).get(i))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (j == 0)
|
||||||
|
{
|
||||||
|
tok.add(campione, i);
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
bool TMovanal_msk::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
bool TMovanal_msk::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||||
{
|
{
|
||||||
switch (o.dlg())
|
switch (o.dlg())
|
||||||
@ -394,9 +454,24 @@ bool TMovanal_msk::on_field_event(TOperable_field& o, TField_event e, long jolly
|
|||||||
{
|
{
|
||||||
if (is_ripartible_movcg())
|
if (is_ripartible_movcg())
|
||||||
{
|
{
|
||||||
|
TToken_string constants;
|
||||||
|
const int cc = get_constant_columns(constants);
|
||||||
TSheet_field& sf = sfield(F_RIGHE);
|
TSheet_field& sf = sfield(F_RIGHE);
|
||||||
sf.destroy();
|
sf.destroy();
|
||||||
load_cg_mov();
|
load_cg_mov();
|
||||||
|
if (cc > 0) // Se ci sono colonne costanti le recupera da quelle vecchie salvate
|
||||||
|
{
|
||||||
|
TString campione;
|
||||||
|
FOR_EACH_SHEET_ROW(sf, i, row)
|
||||||
|
{
|
||||||
|
for (int i = constants.items()-1; i > 0; i--)
|
||||||
|
{
|
||||||
|
constants.get(i, campione);
|
||||||
|
if (!campione.blank())
|
||||||
|
row->add(campione, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
sf.force_update();
|
sf.force_update();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -607,7 +682,7 @@ int TMovanal_msk::create_sheet_fields(int lf, int& y, short& dlg, bool required)
|
|||||||
if (logic == LF_PCON)
|
if (logic == LF_PCON)
|
||||||
{
|
{
|
||||||
const TFieldref* f = fld.field();
|
const TFieldref* f = fld.field();
|
||||||
const TString16 fieldname = f->name();
|
const TString& fieldname = f->name();
|
||||||
|
|
||||||
if (fieldname == "GRUPPO")
|
if (fieldname == "GRUPPO")
|
||||||
fld.set_field("CODCONTO[1,3]"); else
|
fld.set_field("CODCONTO[1,3]"); else
|
||||||
@ -683,9 +758,9 @@ void TMovanal_msk::create_sheet()
|
|||||||
if (fasinfo.levels() > 0 && fasinfo.parent() <= 0)
|
if (fasinfo.levels() > 0 && fasinfo.parent() <= 0)
|
||||||
create_sheet_fields(LF_FASI, y, dlg, fsc_req);
|
create_sheet_fields(LF_FASI, y, dlg, fsc_req);
|
||||||
|
|
||||||
const bool use_pdc = ini.get_bool("UsePdcc");
|
_use_pdc = ini.get_bool("UsePdcc");
|
||||||
const bool pdc_req = ini.get_bool("PdciRequired");
|
const bool pdc_req = ini.get_bool("PdciRequired");
|
||||||
create_sheet_fields(use_pdc ? LF_PCON : LF_PCONANA, y, dlg, pdc_req);
|
create_sheet_fields(_use_pdc ? LF_PCON : LF_PCONANA, y, dlg, pdc_req);
|
||||||
|
|
||||||
for (short id = S_CON4+100; id >= S_CDC1+100; id--)
|
for (short id = S_CON4+100; id >= S_CDC1+100; id--)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user