Patch level : 12.0 906
Files correlati : bacnv.exe bamenu.men Commento : Conversione righe CONAI
This commit is contained in:
parent
e871f306b8
commit
cda3e5af69
157
src/ba/bacnv.cpp
157
src/ba/bacnv.cpp
@ -200,9 +200,7 @@ public:
|
||||
void convert_pcon_ivd();
|
||||
void convert_profile(const char * profile_name);
|
||||
//roba per conai
|
||||
void convert_conai_anamag();
|
||||
void convert_conai_rdoc();
|
||||
void convert_conai_righe();
|
||||
void convert_CONAI_righe();
|
||||
//roba per il file della rilevazione ore
|
||||
void convert_rilore();
|
||||
void convert_CONAI();
|
||||
@ -373,7 +371,7 @@ bool TConversione_archivi::menu(MENU_TAG)
|
||||
convert_profile(argv(2));
|
||||
break;
|
||||
case 24:
|
||||
convert_conai_righe();
|
||||
convert_CONAI_righe();
|
||||
break;
|
||||
case 25:
|
||||
convert_rilore();
|
||||
@ -2135,7 +2133,6 @@ bool TConversione_archivi::to_be_converted(TFilename& name) const
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void TConversione_archivi::convert_profile(const char* profile_name)
|
||||
{
|
||||
TArray_sheet elenco(-1, -1, -4, -6,
|
||||
@ -2209,133 +2206,57 @@ void TConversione_archivi::convert_profile(const char* profile_name)
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Converte le righe documento e anamag in modo da riassegnare i campi CONAI
|
||||
// Converte le righe documento in modo da riassegnare i campi CONAI
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void TConversione_archivi::convert_conai_anamag()
|
||||
|
||||
void TConversione_archivi::convert_CONAI_righe()
|
||||
{
|
||||
TConfig ditta(CONFIG_DITTA, "ve");
|
||||
TString_array conai_default_vals;
|
||||
const char* conai_default_names[CONAI_CLASSES] = {"CONAI_DEFAULT_ACC", "CONAI_DEFAULT_ALL", "CONAI_DEFAULT_CAR",
|
||||
"CONAI_DEFAULT_LEG", "CONAI_DEFAULT_PLA", "CONAI_DEFAULT_VET"};
|
||||
const char* conai_default_values[CONAI_CLASSES] = {"AC99", "AL99", "CA40", "LE99", "PL12", "VE99"};
|
||||
const char* const old_conai_cod[CONAI_CLASSES] = { "CONSCACC", "CONSCALL", "CONSCCAR", "CONSCPLA", "CONSCLEG", "CONSCVET" };
|
||||
const char* const old_conai_peso[CONAI_CLASSES] = { "CONPUACC", "CONPUALL", "CONPUCAR", "CONPUPLA", "CONPULEG", "CONPUVET" };
|
||||
TFast_isamfile f(LF_RIGHEDOC);
|
||||
TCursor c(new TRelation(LF_DOC));
|
||||
|
||||
c.relation()->lfile().set_curr(new TDocumento);
|
||||
|
||||
FOR_EACH_CONAI_CLASS(cc)
|
||||
{
|
||||
const TString& conai_cat = ditta.get(conai_default_names[cc], NULL, -1, conai_default_values[cc]);
|
||||
conai_default_vals.add(conai_cat);
|
||||
}
|
||||
const long items = c.items();
|
||||
TProgind pi(items, TR("Conversione righe documento..."), false);
|
||||
|
||||
//prende solo le righe che hanno un peso conai di carta e/o plastica
|
||||
TISAM_recordset anamag("USE ANAMAG\nSELECT (CONCAR>0)||(CONPLA>0)\n");
|
||||
const long anamag_items = anamag.items();
|
||||
|
||||
TProgind pi(anamag_items, "Gestione anagrafica articoli...", false);
|
||||
for (bool ok = anamag.move_first(); ok; ok = anamag.move_next())
|
||||
{
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
|
||||
//prende i pesi conai su ciascuna riga
|
||||
FOR_EACH_CONAI_CLASS(cc)
|
||||
{
|
||||
const char* peso_name = conai_peso_name(cc);
|
||||
const real peso = anamag.get(peso_name).as_real();
|
||||
//se peso conai > 0, deve scrivere il codice conai nel campo CONAISC
|
||||
if (peso > ZERO)
|
||||
{
|
||||
const char* sottocat = conai_sottocat_name(cc);
|
||||
TFieldref fr(sottocat, LF_ANAMAG);
|
||||
fr.write(conai_default_vals.row(cc), anamag.cursor()->curr());
|
||||
}
|
||||
}
|
||||
anamag.cursor()->relation()->rewrite();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TConversione_archivi::convert_conai_rdoc()
|
||||
{
|
||||
TFast_isamfile f(LF_RIGHEDOC);
|
||||
|
||||
//deve considerare tutte le righe documento che abbiano almeno uno tra codagg1 e codagg2 compilato
|
||||
TString query;
|
||||
query << "USE RDOC\n";
|
||||
query << "SELECT (BETWEEN(CODAGG1,\"AC\",\"VE\"))||(BETWEEN(CODAGG2,\"AC01\",\"VE99\"))";
|
||||
TISAM_recordset righedoc(query);
|
||||
const long righedoc_items = righedoc.items();
|
||||
|
||||
TProgind pi(righedoc_items, TR("Ricostruzione righe documento..."), false);
|
||||
|
||||
//ci vuole un TVariable_rectype perchè il TRectype non ha campi virtuali!
|
||||
TVariable_rectype rdoc(LF_RIGHEDOC);
|
||||
rdoc.set_memo_fld(RDOC_RG1);
|
||||
for (bool ok = righedoc.move_first(); ok; ok = righedoc.move_next())
|
||||
for (c = 0L; c.pos() < items; ++c)
|
||||
{
|
||||
//deve prendere dalla riga il valore di codagg2 e confrontarlo con una delle nuove sottocategorie conai
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
rdoc = righedoc.cursor()->curr();
|
||||
|
||||
TString4 codagg1 = rdoc.get(RDOC_CODAGG1);
|
||||
TString4 codagg2 = rdoc.get(RDOC_CODAGG2);
|
||||
if (codagg1.full() || codagg2.full())
|
||||
{
|
||||
//se codagg2 non è 4 caratteri o è cazzato (<4) oppure non c'entra un cavolo (>4); quindi deve considerare..
|
||||
//..codagg1; se codagg1 è lungo 2 va bene lui
|
||||
if (codagg2.len() < 4 && codagg1.len() == 2)
|
||||
{
|
||||
codagg2 = codagg1;
|
||||
codagg2 << "99";
|
||||
}
|
||||
//per prima cosa sistema i codici categoria
|
||||
//quale è la classe conai? (plastica,carta,vetro,ecc.??)
|
||||
const TCONAI_class cc = conai_str2class(codagg2);
|
||||
//come si chiama il campo virtuale su rdoc in cui anrà inserito il codice categoria?
|
||||
const char* csn = conai_sottocat_name(cc);
|
||||
//noto il campo di destinazione ci mette il codice corretto
|
||||
rdoc.put(csn, codagg2);
|
||||
rdoc.zero(RDOC_CODAGG1);
|
||||
rdoc.zero(RDOC_CODAGG2);
|
||||
TDocumento & doc = (TDocumento &)c.curr();
|
||||
const int rows = doc.physical_rows();
|
||||
|
||||
//adesso tocca ai pesi conai
|
||||
const real qtagg1 = rdoc.get_real(RDOC_QTAGG1);
|
||||
if (!qtagg1.is_zero())
|
||||
{
|
||||
//la classe è sempre quella di prima;il campo virtuale no
|
||||
const char* cpn = conai_peso_name(cc);
|
||||
//noto il campo di destinazione ci mette il peso conai
|
||||
rdoc.put(cpn, qtagg1);
|
||||
rdoc.zero(RDOC_QTAGG1);
|
||||
}
|
||||
}
|
||||
for (int i = 1; i <= rows; i++)
|
||||
{
|
||||
TRiga_documento & r = doc[i];
|
||||
|
||||
const real qtagg3 = rdoc.get(RDOC_QTAGG3);
|
||||
if (!qtagg3.is_zero())
|
||||
{
|
||||
rdoc.put("NUMFOGLI", qtagg3);
|
||||
rdoc.zero(RDOC_QTAGG3);
|
||||
}
|
||||
if (r.is_merce() || r.is_omaggio())
|
||||
{
|
||||
int pos = 1;
|
||||
|
||||
//scrittura finale del record
|
||||
int err = rdoc.rewrite(f);
|
||||
if (err != NOERR)
|
||||
{
|
||||
cantwrite_box(f.description());
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < CONAI_CLASSES; j++)
|
||||
{
|
||||
const TString & cat = r.get(old_conai_cod[j]);
|
||||
|
||||
if (cat.full())
|
||||
{
|
||||
r.put(conai_sottocat_name(pos), cat);
|
||||
r.put(conai_peso_name(pos++), r.get_real(old_conai_peso[j]));
|
||||
}
|
||||
r.zero(old_conai_cod[j]);
|
||||
r.zero(old_conai_peso[j]);
|
||||
}
|
||||
if (r.rewrite(f) != NOERR)
|
||||
cantwrite_box(f.description());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TConversione_archivi::convert_conai_righe()
|
||||
{
|
||||
//gestione del file anamag
|
||||
convert_conai_anamag();
|
||||
|
||||
//gestione delle righedoc
|
||||
convert_conai_rdoc();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// Converte i dati del file LF_RILORE ($125) in base al nuovo e più logico tracciato
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -131,7 +131,7 @@ Flags = ""
|
||||
Item_01 = "Riattribuzione codice allegato", "bacnv 21", ""
|
||||
Item_02 = "Aggiornamento IV direttiva CEE", "bacnv 22", ""
|
||||
Item_03 = "Aggiornamento profili documento personalizzati", "bacnv 23", ""
|
||||
Item_04 = "Riattribuzione campi CONAI", "bacnv 24", ""
|
||||
Item_04 = "Conversione documenti CONAI", "bacnv 24", ""
|
||||
Item_05 = "Gestione attivazione licenze", "ba2 -7", ""
|
||||
Item_06 = "Aggiornamento Nazioni ISO 2017" "ba7 -4", ""
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user