Aggiunto programma per calcolo ed invio storico consumi a terminalini
git-svn-id: svn://10.65.10.50/branches/R_10_00@22756 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
200b962343
commit
ce161a46a0
@ -36,6 +36,8 @@ bool THA_table_mask::on_field_event(TOperable_field &o, TField_event e, long jol
|
|||||||
// applicazione per la gestione delle tabelle di lavanderia
|
// applicazione per la gestione delle tabelle di lavanderia
|
||||||
class THA_table_app : public TTable_module_application
|
class THA_table_app : public TTable_module_application
|
||||||
{
|
{
|
||||||
|
bool _trans_done;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int update_gcg(const TRectype& att);
|
int update_gcg(const TRectype& att);
|
||||||
|
|
||||||
@ -50,6 +52,9 @@ protected: // TRelation_application
|
|||||||
virtual int rewrite(const TMask& m);
|
virtual int rewrite(const TMask& m);
|
||||||
|
|
||||||
virtual bool get_next_key(TToken_string& key);
|
virtual bool get_next_key(TToken_string& key);
|
||||||
|
|
||||||
|
public:
|
||||||
|
THA_table_app() : _trans_done(false) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -98,7 +103,8 @@ bool THA_table_app::protected_record(TRectype& record)
|
|||||||
const long items = attr_recset.items();
|
const long items = attr_recset.items();
|
||||||
return items > 0;
|
return items > 0;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void THA_table_app::init_insert_mode(TMask& m)
|
void THA_table_app::init_insert_mode(TMask& m)
|
||||||
@ -128,12 +134,33 @@ void THA_table_app::init_query_mode(TMask& m)
|
|||||||
{
|
{
|
||||||
m.hide(F_CODCLI1);
|
m.hide(F_CODCLI1);
|
||||||
m.show(F_CODCLI);
|
m.show(F_CODCLI);
|
||||||
}
|
} else
|
||||||
if (name == "ATT") //inizialmente vedo il gruppo 2 di SEARCH e non quello 1 di NEW
|
if (name == "ATT") //inizialmente vedo il gruppo 2 di SEARCH e non quello 1 di NEW
|
||||||
{
|
{
|
||||||
m.hide(-1);
|
m.hide(-1);
|
||||||
m.show(-2);
|
m.show(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_trans_done && argc() > 3)
|
||||||
|
{
|
||||||
|
_trans_done = true;
|
||||||
|
const TFixed_string a = argv(3);
|
||||||
|
if (a.starts_with("CODTAB="))
|
||||||
|
{
|
||||||
|
const TString& codtab = a.after("=");
|
||||||
|
get_relation()->curr().put("CODTAB", codtab);
|
||||||
|
FOR_EACH_MASK_FIELD(m, i, f) if (f->active() && f->field() != NULL && f->in_key(1))
|
||||||
|
{
|
||||||
|
const TFieldref* fref = f->field();
|
||||||
|
if (fref->name() == "CODTAB")
|
||||||
|
{
|
||||||
|
const TString& val = fref->read(*get_relation());
|
||||||
|
f->set(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m.send_key(K_AUTO_ENTER, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void THA_table_app::init_query_insert_mode(TMask& m)
|
void THA_table_app::init_query_insert_mode(TMask& m)
|
||||||
@ -198,6 +225,6 @@ int THA_table_app::rewrite(const TMask& m)
|
|||||||
int ha0100(int argc, char* argv[])
|
int ha0100(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
THA_table_app a;
|
THA_table_app a;
|
||||||
a.run(argc, argv, TR("Tabella Caffé Hardy"));
|
a.run(argc, argv, TR("Tabella Hardy"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ int main(int argc,char** argv)
|
|||||||
case 0: ha1100(argc, argv); break; // generazione .txt da files .ini del postino (file tipo XXXvar.txt)
|
case 0: ha1100(argc, argv); break; // generazione .txt da files .ini del postino (file tipo XXXvar.txt)
|
||||||
case 1: ha1200(argc, argv); break; // generazione .txt da anagrafica campo (file tipo XXX.txt)
|
case 1: ha1200(argc, argv); break; // generazione .txt da anagrafica campo (file tipo XXX.txt)
|
||||||
case 2: ha1300(argc, argv); break; // importazione file da terminalini (file tipo upload.d)
|
case 2: ha1300(argc, argv); break; // importazione file da terminalini (file tipo upload.d)
|
||||||
|
case 3: ha1400(argc, argv); break; // generazione tabella STC storico consumi
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
1
ha/ha1.h
1
ha/ha1.h
@ -1,3 +1,4 @@
|
|||||||
int ha1100(int argc, char* argv[]);
|
int ha1100(int argc, char* argv[]);
|
||||||
int ha1200(int argc, char* argv[]);
|
int ha1200(int argc, char* argv[]);
|
||||||
int ha1300(int argc, char* argv[]);
|
int ha1300(int argc, char* argv[]);
|
||||||
|
int ha1400(int argc, char* argv[]);
|
||||||
|
@ -87,6 +87,7 @@ protected:
|
|||||||
bool genera_tabpag_txt();
|
bool genera_tabpag_txt();
|
||||||
bool genera_carico_txt(const TMask& mask);
|
bool genera_carico_txt(const TMask& mask);
|
||||||
bool genera_ripristino_txt(const TMask& mask);
|
bool genera_ripristino_txt(const TMask& mask);
|
||||||
|
bool genera_consumi_txt(const TMask& mask);
|
||||||
|
|
||||||
void fill_anagrafica_cliente(const TISAM_recordset& archivio_clienti,
|
void fill_anagrafica_cliente(const TISAM_recordset& archivio_clienti,
|
||||||
TEsporta_clienti_recordset& clienti, const bool is_fatt = false);
|
TEsporta_clienti_recordset& clienti, const bool is_fatt = false);
|
||||||
@ -786,6 +787,45 @@ bool TFile2Txt::genera_attrezzature_txt()
|
|||||||
return salva_recordset(storico, "storico");
|
return salva_recordset(storico, "storico");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TFile2Txt::genera_consumi_txt(const TMask& mask)
|
||||||
|
{
|
||||||
|
// esporta i consumi per cliente
|
||||||
|
TEsporta_consumi_recordset consumi;
|
||||||
|
|
||||||
|
TISAM_recordset archivio_stc("USE &STC SELECT CODTAB[7,9]=='001'");
|
||||||
|
const TRecnotype archivio_stc_items = archivio_stc.items();
|
||||||
|
|
||||||
|
TProgind progind_att(archivio_stc_items, TR("Consumi..."), false, true);
|
||||||
|
for (bool ok = archivio_stc.move_first(); ok; ok = archivio_stc.move_next())
|
||||||
|
{
|
||||||
|
if (!progind_att.addstatus(1))
|
||||||
|
break;
|
||||||
|
|
||||||
|
const TString& codtab = archivio_stc.get("CODTAB").as_string();
|
||||||
|
const TString4 grmerc = codtab.mid(6, 3);
|
||||||
|
if (grmerc != "001")
|
||||||
|
continue; // You never know!
|
||||||
|
|
||||||
|
consumi.new_rec("");
|
||||||
|
|
||||||
|
//in base al codice cliente stabilisce quale è il codice agente
|
||||||
|
const long codcf = atol(codtab.left(6));
|
||||||
|
consumi.set("CodiceTerminale", hd_find_codag(codcf));
|
||||||
|
consumi.set("CodiceCliente", codcf);
|
||||||
|
consumi.set("Anno", codtab.right(4));
|
||||||
|
consumi.set("GruppoMerc", grmerc);
|
||||||
|
for (int i = 1; i <= 12; i++)
|
||||||
|
{
|
||||||
|
TString8 inpfld; inpfld.format("I%d", i);
|
||||||
|
TString8 outfld; outfld.format("Qta%d", i);
|
||||||
|
consumi.set(outfld, archivio_stc.get(inpfld));
|
||||||
|
}
|
||||||
|
consumi.set("QtaOmaggi", archivio_stc.get("I0"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return salva_recordset(consumi, "consumi");
|
||||||
|
}
|
||||||
|
|
||||||
bool TFile2Txt::genera_tabpag_txt()
|
bool TFile2Txt::genera_tabpag_txt()
|
||||||
{
|
{
|
||||||
TEsporta_pagamenti_recordset tabpag;
|
TEsporta_pagamenti_recordset tabpag;
|
||||||
@ -993,6 +1033,9 @@ void TFile2Txt::elabora(const TMask& mask, TLog_report& log)
|
|||||||
if (mask.get_bool(F_INIMAG) && go_on)
|
if (mask.get_bool(F_INIMAG) && go_on)
|
||||||
go_on = genera_ripristino_txt(mask);
|
go_on = genera_ripristino_txt(mask);
|
||||||
|
|
||||||
|
if (mask.get_bool(F_CONSUMI) && go_on)
|
||||||
|
go_on = genera_consumi_txt(mask);
|
||||||
|
|
||||||
/* Per il momento preferiscono agire manualmente
|
/* Per il momento preferiscono agire manualmente
|
||||||
//c) lancia il concentratore in modalità di carico
|
//c) lancia il concentratore in modalità di carico
|
||||||
carica_concentratore();
|
carica_concentratore();
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#define F_TABPAG 223
|
#define F_TABPAG 223
|
||||||
#define F_CARICO 224
|
#define F_CARICO 224
|
||||||
#define F_INIMAG 225
|
#define F_INIMAG 225
|
||||||
|
#define F_CONSUMI 226
|
||||||
|
|
||||||
#define F_DA_CODCLI 230
|
#define F_DA_CODCLI 230
|
||||||
#define F_DA_SOSP_CODCLI 231
|
#define F_DA_SOSP_CODCLI 231
|
||||||
|
@ -111,6 +111,12 @@ BEGIN
|
|||||||
FIELD Barcode
|
FIELD Barcode
|
||||||
END
|
END
|
||||||
|
|
||||||
|
BOOLEAN F_CONSUMI
|
||||||
|
BEGIN
|
||||||
|
PROMPT 32 7 "Storico Consumi"
|
||||||
|
FIELD Consumi
|
||||||
|
END
|
||||||
|
|
||||||
BOOLEAN F_ATTREZZA
|
BOOLEAN F_ATTREZZA
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 53 4 "Attrezzature"
|
PROMPT 53 4 "Attrezzature"
|
||||||
@ -224,6 +230,14 @@ BEGIN
|
|||||||
FIELD Annomag
|
FIELD Annomag
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
|
STRING 30 70 50
|
||||||
|
BEGIN
|
||||||
|
PROMPT 10 -3 "Profilo "
|
||||||
|
PSELECT
|
||||||
|
FLAGS "G"
|
||||||
|
END
|
||||||
|
|
||||||
ENDPAGE
|
ENDPAGE
|
||||||
|
|
||||||
TOOLBAR "topbar" 0 0 0 2
|
TOOLBAR "topbar" 0 0 0 2
|
||||||
|
@ -565,10 +565,35 @@ TEsporta_storico_attrezzature_recordset::TEsporta_storico_attrezzature_recordset
|
|||||||
//Pagamenti
|
//Pagamenti
|
||||||
//---------------
|
//---------------
|
||||||
TEsporta_pagamenti_recordset::TEsporta_pagamenti_recordset()
|
TEsporta_pagamenti_recordset::TEsporta_pagamenti_recordset()
|
||||||
: THardy_recordset(27)
|
: THardy_recordset(27)
|
||||||
{
|
{
|
||||||
add_field("CodicePagamento", T_X, 1, 2); //x
|
add_field("CodicePagamento", T_X, 1, 2); //x
|
||||||
add_field("DescrPagamento", T_X, 3, 20); //x
|
add_field("DescrPagamento", T_X, 3, 20); //x
|
||||||
add_field("GiorniScadenza", T_N, 23, 3); //x
|
add_field("GiorniScadenza", T_N, 23, 3); //x
|
||||||
add_eol_field();
|
add_eol_field();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Consumi
|
||||||
|
//---------------
|
||||||
|
TEsporta_consumi_recordset::TEsporta_consumi_recordset()
|
||||||
|
: THardy_recordset(137)
|
||||||
|
{
|
||||||
|
add_field("CodiceTerminale", T_N, 1, 3);
|
||||||
|
add_field("CodiceCliente", T_X, 4, 6);
|
||||||
|
add_field("Anno", T_N, 10, 4);
|
||||||
|
add_field("GruppoMerc", T_X, 14, 5);
|
||||||
|
add_field("Qta1", T_N, 19, 9);
|
||||||
|
add_field("Qta2", T_N, 28, 9);
|
||||||
|
add_field("Qta3", T_N, 37, 9);
|
||||||
|
add_field("Qta4", T_N, 46, 9);
|
||||||
|
add_field("Qta5", T_N, 55, 9);
|
||||||
|
add_field("Qta6", T_N, 64, 9);
|
||||||
|
add_field("Qta7", T_N, 73, 9);
|
||||||
|
add_field("Qta8", T_N, 82, 9);
|
||||||
|
add_field("Qta9", T_N, 91, 9);
|
||||||
|
add_field("Qta10", T_N,100, 9);
|
||||||
|
add_field("Qta11", T_N,109, 9);
|
||||||
|
add_field("Qta12", T_N,118, 9);
|
||||||
|
add_field("QtaOmaggi", T_N,127, 9);
|
||||||
|
add_eol_field();
|
||||||
|
}
|
||||||
|
@ -212,6 +212,13 @@ public:
|
|||||||
TEsporta_pagamenti_recordset();
|
TEsporta_pagamenti_recordset();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Storico Consumi ()
|
||||||
|
//-----------------
|
||||||
|
class TEsporta_consumi_recordset : public THardy_recordset
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TEsporta_consumi_recordset();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
182
ha/ha1400.cpp
Normal file
182
ha/ha1400.cpp
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
#include <applicat.h>
|
||||||
|
#include <mask.h>
|
||||||
|
#include <progind.h>
|
||||||
|
#include <recarray.h>
|
||||||
|
#include <recset.h>
|
||||||
|
|
||||||
|
#include <../mg/anamag.h>
|
||||||
|
#include <doc.h>
|
||||||
|
#include <rdoc.h>
|
||||||
|
|
||||||
|
class TStorico_consumi : public TSkeleton_application
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
TRecnotype kill_records(int anno, TAssoc_array& clifo_grmerc) const;
|
||||||
|
TRecnotype build_records(int anno, TAssoc_array& clifo_grmerc) const;
|
||||||
|
void elabora(int anno) const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual void main_loop();
|
||||||
|
};
|
||||||
|
|
||||||
|
TRecnotype TStorico_consumi::kill_records(int anno, TAssoc_array& clifo_grmerc) const
|
||||||
|
{
|
||||||
|
TISAM_recordset stc("&STC");
|
||||||
|
TProgind pi(stc.items(), TR("Analisi storico consumi"));
|
||||||
|
for (bool ok = stc.move_first(); ok; ok = stc.move_next())
|
||||||
|
{
|
||||||
|
if (!pi.addstatus(1))
|
||||||
|
break;
|
||||||
|
const TString& key = stc.get("CODTAB").as_string();
|
||||||
|
if (atoi(key.right(4)) == anno || key.find('@') > 0)
|
||||||
|
clifo_grmerc.add(key);
|
||||||
|
}
|
||||||
|
return clifo_grmerc.items();
|
||||||
|
}
|
||||||
|
|
||||||
|
TRecnotype TStorico_consumi::build_records(int anno, TAssoc_array& clifo_grmerc) const
|
||||||
|
{
|
||||||
|
TString query, limit;
|
||||||
|
limit << "PROVV=D ANNO=" << anno;
|
||||||
|
query << "USE RDOC KEY 3"
|
||||||
|
<< "\nFROM " << limit
|
||||||
|
<< "\nTO " << limit;
|
||||||
|
|
||||||
|
TISAM_recordset rdoc(query);
|
||||||
|
TProgind pi(rdoc.items(), TR("Scansione documenti"));
|
||||||
|
|
||||||
|
TToken_string key;
|
||||||
|
for (bool ok = rdoc.move_first(); ok; ok = rdoc.move_next())
|
||||||
|
{
|
||||||
|
if (!pi.addstatus(1))
|
||||||
|
break;
|
||||||
|
|
||||||
|
const TString4 tiporiga = rdoc.get(RDOC_TIPORIGA).as_string();
|
||||||
|
if (tiporiga != "01" && tiporiga != "09")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
key = rdoc.get(RDOC_PROVV).as_string();
|
||||||
|
key.add(rdoc.get(RDOC_ANNO).as_string());
|
||||||
|
key.add(rdoc.get(RDOC_CODNUM).as_string());
|
||||||
|
key.add(rdoc.get(RDOC_NDOC).as_string());
|
||||||
|
|
||||||
|
const TRectype& doc = cache().get(LF_DOC, key);
|
||||||
|
const long codcf = doc.get_long(DOC_CODCF);
|
||||||
|
const TDate datadoc = doc.get(DOC_DATADOC);
|
||||||
|
const TString4 tipo = doc.get(DOC_TIPODOC);
|
||||||
|
|
||||||
|
const TString& b2 = cache().get("%TIP", tipo, "B2");
|
||||||
|
if (b2.blank())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const TRectype& anamag = cache().get(LF_ANAMAG, rdoc.get(RDOC_CODARTMAG).as_string());
|
||||||
|
TString4 grmerc = anamag.get(ANAMAG_GRMERC).left(3);
|
||||||
|
grmerc.left_just(3);
|
||||||
|
|
||||||
|
key.format("%06ld%s%4d", codcf, (const char*)grmerc, anno);
|
||||||
|
TRectype* rec = (TRectype*)clifo_grmerc.objptr(key);
|
||||||
|
if (rec == NULL)
|
||||||
|
{
|
||||||
|
rec = new TRectype(LF_TABMOD);
|
||||||
|
rec->put("MOD", "HA");
|
||||||
|
rec->put("COD", "STC");
|
||||||
|
rec->put("CODTAB", key);
|
||||||
|
|
||||||
|
TString16 s0;
|
||||||
|
s0.format("%s%06ld%4d", (const char*)grmerc, codcf, anno);
|
||||||
|
rec->put("S0", s0);
|
||||||
|
|
||||||
|
clifo_grmerc.add(key, rec);
|
||||||
|
}
|
||||||
|
|
||||||
|
real qta = rdoc.get(RDOC_QTA).as_real();
|
||||||
|
qta *= CENTO; qta.round(); // Salvo la quantità moltiplicata per 100 ed arrotondata
|
||||||
|
|
||||||
|
const real valore = rdoc.get("RG1:IMPNS").as_real();
|
||||||
|
|
||||||
|
TString8 qta_field, val_field;
|
||||||
|
if (tiporiga == "01")
|
||||||
|
{
|
||||||
|
qta_field.format("I%d", datadoc.month());
|
||||||
|
val_field.format("R%d", datadoc.month());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qta_field = "I0";
|
||||||
|
val_field = "R0";
|
||||||
|
}
|
||||||
|
rec->add(qta_field, qta);
|
||||||
|
rec->add(val_field, valore);
|
||||||
|
}
|
||||||
|
|
||||||
|
return clifo_grmerc.items();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TStorico_consumi::elabora(int anno) const
|
||||||
|
{
|
||||||
|
TAssoc_array old_recs, new_recs;
|
||||||
|
|
||||||
|
TRecnotype old_tot = kill_records(anno, old_recs);
|
||||||
|
const TRecnotype new_tot = build_records(anno, new_recs);
|
||||||
|
|
||||||
|
TFast_isamfile stc(LF_TABMOD);
|
||||||
|
if (new_tot)
|
||||||
|
{
|
||||||
|
TProgind pi(new_tot, TR("Salvataggio storico"));
|
||||||
|
FOR_EACH_ASSOC_OBJECT(new_recs, obj, key, rec)
|
||||||
|
{
|
||||||
|
if (!pi.addstatus(1))
|
||||||
|
break;
|
||||||
|
const TRectype& r = *(TRectype*)rec;
|
||||||
|
int err = r.rewrite_write(stc);
|
||||||
|
if (err == NOERR)
|
||||||
|
{
|
||||||
|
const TString& key = r.get("CODTAB");
|
||||||
|
old_recs.remove(key); // Tolgo il record dalla lista di quelli da cancellare
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error_box(FR("Errore %d di scrittura sulla tabella STC"), err);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
old_tot = old_recs.items();
|
||||||
|
if (old_tot) // Cancello i record dell'anno che non esistono più
|
||||||
|
{
|
||||||
|
TProgind pi(old_tot, TR("Allineamento storico"));
|
||||||
|
TRectype& rec = stc.curr();
|
||||||
|
FOR_EACH_ASSOC_OBJECT(old_recs, obj, key, itm)
|
||||||
|
{
|
||||||
|
if (!pi.addstatus(1))
|
||||||
|
break;
|
||||||
|
rec.put("MOD", "HA");
|
||||||
|
rec.put("COD", "STC");
|
||||||
|
rec.put("CODTAB", key);
|
||||||
|
const int err = rec.remove(stc);
|
||||||
|
if (err != NOERR)
|
||||||
|
{
|
||||||
|
error_box(FR("Errore %d di cancellazione sulla tabella STC"), err);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TStorico_consumi::main_loop()
|
||||||
|
{
|
||||||
|
TMask m(main_app().title(), 1, 24, 5);
|
||||||
|
m.add_number(101, 0, "Anno ", 1, 1, 4, "U").check_type(CHECK_REQUIRED);
|
||||||
|
m.add_button(DLG_OK, 0, "", -12, -1, 8, 2);
|
||||||
|
m.add_button(DLG_CANCEL, 0, "", -22, -1, 8, 2);
|
||||||
|
while (m.run() == K_ENTER)
|
||||||
|
elabora(m.get_int(101));
|
||||||
|
}
|
||||||
|
|
||||||
|
int ha1400(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
TStorico_consumi a;
|
||||||
|
a.run(argc, argv, TR("Storico Consumi"));
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user