Aggiunta colonna prezzi in articoli per preventivazione
git-svn-id: svn://10.65.10.50/branches/R_10_00@22895 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c9dc6931b2
commit
7c4407fcae
176
pe/pe1400.cpp
176
pe/pe1400.cpp
@ -12,6 +12,7 @@
|
||||
|
||||
#include "pe1400.h"
|
||||
#include "pe1401.h"
|
||||
#include "pe1500.h"
|
||||
|
||||
#include "../db/rdist.h"
|
||||
#include "../mg/anamag.h"
|
||||
@ -94,6 +95,49 @@ static real ricarico2perc(const TString& exp)
|
||||
return val_perc;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TPreventivo_app
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TPreventivo_app : public TRelation_application
|
||||
{
|
||||
TMask* _qmsk;
|
||||
TMask* _emsk;
|
||||
TRelation* _rel;
|
||||
bool _revisioning;
|
||||
TString8 _codelab;
|
||||
|
||||
protected:
|
||||
int save_rows(const TMask& m, bool re);
|
||||
virtual const char* extra_modules() const { return "ci"; }
|
||||
bool save_and_print(TPrtype mode);
|
||||
|
||||
public:
|
||||
virtual bool user_create();
|
||||
virtual bool user_destroy();
|
||||
virtual bool changing_mask(int mode) { return !(_revisioning && mode == MODE_INS); }
|
||||
virtual TMask* get_mask(int mode) { return mode == MODE_QUERY ? _qmsk : _emsk; }
|
||||
virtual TRelation* get_relation() const { return _rel; }
|
||||
virtual bool get_next_key(TToken_string& key);
|
||||
virtual bool has_filtered_cursor() const { return true; }
|
||||
virtual TCursor& get_filtered_cursor() const;
|
||||
|
||||
virtual void init_insert_mode(TMask& m);
|
||||
virtual void init_modify_mode(TMask& m);
|
||||
|
||||
virtual int read(TMask& m);
|
||||
virtual int write(const TMask& m);
|
||||
virtual int rewrite(const TMask& m);
|
||||
virtual bool remove();
|
||||
|
||||
virtual void print();
|
||||
virtual void preview();
|
||||
|
||||
void update_tools(TMask& m);
|
||||
bool set_elab_code(const TString& cod) { _codelab = cod; return cod.full(); }
|
||||
};
|
||||
|
||||
inline TPreventivo_app& app() { return (TPreventivo_app&)main_app(); }
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TPreventivo_nmsk
|
||||
@ -341,6 +385,7 @@ class TPreventivo_emsk : public TPreventivo_msk
|
||||
TString _idfase, _iddist;
|
||||
int _edit_dist, _edit_dett, _edit_misu;
|
||||
int _curr_dist, _curr_dett, _curr_misu;
|
||||
bool _locked;
|
||||
|
||||
private:
|
||||
bool on_fasi_button(TOperable_field& btn, TField_event e, long jolly);
|
||||
@ -360,6 +405,7 @@ private:
|
||||
real get_costo(const TString& codart) const;
|
||||
|
||||
protected:
|
||||
virtual bool on_key(KEY k);
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
void set_sheet_color(short id, COLOR col);
|
||||
bool sync_tree();
|
||||
@ -367,6 +413,7 @@ protected:
|
||||
|
||||
public:
|
||||
TPreventivo_tree& tree(bool reset = false);
|
||||
|
||||
TPreventivo_emsk();
|
||||
};
|
||||
|
||||
@ -416,6 +463,7 @@ bool TPreventivo_emsk::set_dist(const TString& idd)
|
||||
ok = idd.full() && t.goto_node(idd);
|
||||
if (ok)
|
||||
{
|
||||
_locked = true; // Diabilita ricalcolo prezzi
|
||||
int n = 0;
|
||||
for (bool ok = t.goto_firstson(); ok; ok = t.goto_rbrother())
|
||||
{
|
||||
@ -433,6 +481,7 @@ bool TPreventivo_emsk::set_dist(const TString& idd)
|
||||
}
|
||||
s.update_row(n++);
|
||||
}
|
||||
_locked = false;
|
||||
}
|
||||
|
||||
// Visualizza nuovamente i due sheet eventualemente riempiti
|
||||
@ -515,6 +564,16 @@ bool TPreventivo_emsk::msk2rec(const TMask& msk, TRectype& rec) const
|
||||
return !rec.empty();
|
||||
}
|
||||
|
||||
bool TPreventivo_emsk::on_key(KEY k)
|
||||
{
|
||||
if (k == K_SHIFT + K_F12)
|
||||
{
|
||||
enable(F_STATO);
|
||||
return true;
|
||||
}
|
||||
return TAutomask::on_key(k);
|
||||
}
|
||||
|
||||
bool TPreventivo_emsk::on_fasi_button(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
TPreventivo_tree& t = tree();
|
||||
@ -817,7 +876,7 @@ bool TPreventivo_emsk::on_dett_event(TOperable_field& o, TField_event e, long jo
|
||||
switch (o.dlg())
|
||||
{
|
||||
case S_CODART:
|
||||
if (e == fe_modify && !o.empty())
|
||||
if (e == fe_modify && !o.empty() && !_locked)
|
||||
{
|
||||
const TString& codart = o.get();
|
||||
const TArticolo_giacenza& art = cached_article_balances(codart);
|
||||
@ -905,7 +964,7 @@ bool TPreventivo_emsk::on_misu_event(TOperable_field& o, TField_event e, long jo
|
||||
switch (e)
|
||||
{
|
||||
case se_query_add:
|
||||
return _iddist.full() && !sfield(F_ARTICOLI).empty();
|
||||
return _iddist.full();
|
||||
case se_notify_add:
|
||||
tree().misu(_iddist, _edit_misu = jolly, true);
|
||||
break;
|
||||
@ -970,14 +1029,19 @@ void TPreventivo_emsk::update_dist_costo()
|
||||
if (_curr_dist >= 0)
|
||||
{
|
||||
TSheet_field& sheet = sfield(F_ARTICOLI);
|
||||
real costo;
|
||||
real costo, prezzo;
|
||||
FOR_EACH_SHEET_ROW(sheet, i, row)
|
||||
{
|
||||
const real q = row->get(3);
|
||||
const real c = row->get();
|
||||
costo += q*c;
|
||||
const real p = row->get();
|
||||
costo += q*c;
|
||||
prezzo += q*p;
|
||||
}
|
||||
update_dist(costo, 4);
|
||||
if (!costo.is_zero())
|
||||
update_dist(costo, 4);
|
||||
if (!prezzo.is_zero())
|
||||
update_dist(prezzo, 5);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1021,6 +1085,8 @@ bool TPreventivo_emsk::on_field_event(TOperable_field& o, TField_event e, long j
|
||||
case F_STATO:
|
||||
if ((e == fe_init || e == fe_close) && o.empty())
|
||||
o.set("1");
|
||||
if (e == fe_modify && !o.empty())
|
||||
app().update_tools(*this);
|
||||
break;
|
||||
case F_FASI:
|
||||
return on_fasi_event((TTree_field&)o, e, jolly);
|
||||
@ -1071,19 +1137,29 @@ bool TPreventivo_emsk::on_field_event(TOperable_field& o, TField_event e, long j
|
||||
case DLG_ELABORA:
|
||||
if (e == fe_button)
|
||||
{
|
||||
// const TString& cod = trova_elaborazione();
|
||||
const TString& cod = pe_trova_elaborazione(*this);
|
||||
if (cod.full())
|
||||
{
|
||||
TPreventivo_app& relapp = (TPreventivo_app&)main_app();
|
||||
if (relapp.set_elab_code(cod))
|
||||
stop_run(K_SAVE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case F_RICARICO:
|
||||
if (e == fe_modify && !o.empty())
|
||||
{
|
||||
// Controllo che ci sia almeno una fase prima di ricalcolare tutto
|
||||
TPreventivo_tree& t = tree();
|
||||
if (t.goto_root() && yesno_box(TR("Si desidera applicare il nuovo ricarico a tutte fasi?")))
|
||||
if (t.goto_root() && t.has_son() && yesno_box(TR("Si desidera applicare il nuovo ricarico a tutte fasi?")))
|
||||
{
|
||||
const real perc = ricarico2perc(o.get());
|
||||
t.scan_depth_first(ricarica, (void*)&perc);
|
||||
sync_tree();
|
||||
set_fase("");
|
||||
if (t.goto_root())
|
||||
{
|
||||
const real perc = ricarico2perc(o.get());
|
||||
t.scan_depth_first(ricarica, (void*)&perc);
|
||||
sync_tree();
|
||||
set_fase("");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1113,14 +1189,14 @@ void TPreventivo_emsk::set_sheet_color(short id, COLOR col)
|
||||
s.set_back_and_fore_color(rgb, NORMAL_COLOR, -1);
|
||||
}
|
||||
|
||||
TPreventivo_emsk::TPreventivo_emsk() : TPreventivo_msk("pe1400b"), _tree(NULL)
|
||||
TPreventivo_emsk::TPreventivo_emsk() : TPreventivo_msk("pe1400b"), _tree(NULL), _locked(false)
|
||||
{
|
||||
TMask_field& cdc0 = field(F_CDC0);
|
||||
RCT rct0; cdc0.get_rect(rct0);
|
||||
const int yca = rct0.top / ROWY + 1; // Riga del primo campo di analitica
|
||||
short idcdc, idcms, idfase, idconto;
|
||||
ca_create_fields_ext(*this, 0, 2, yca, F_CDC0+1, idcdc, idcms, idfase, idconto,
|
||||
DOC_CODCOSTO, DOC_CODCMS, DOC_FASCMS);
|
||||
DOC_CODCOSTO, DOC_CODCMS /*, DOC_FASCMS */); // Niente fasi qui!
|
||||
|
||||
set_sheet_color(F_DISTINTE, COLOR_YELLOW);
|
||||
set_sheet_color(F_ARTICOLI, COLOR_GREEN);
|
||||
@ -1132,40 +1208,6 @@ TPreventivo_emsk::TPreventivo_emsk() : TPreventivo_msk("pe1400b"), _tree(NULL)
|
||||
// TPreventivo_app
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TPreventivo_app : public TRelation_application
|
||||
{
|
||||
TMask* _qmsk;
|
||||
TMask* _emsk;
|
||||
TRelation* _rel;
|
||||
bool _revisioning;
|
||||
|
||||
protected:
|
||||
int save_rows(const TMask& m, bool re);
|
||||
virtual const char* extra_modules() const { return "ci"; }
|
||||
bool save_and_print(TPrtype mode);
|
||||
|
||||
public:
|
||||
virtual bool user_create();
|
||||
virtual bool user_destroy();
|
||||
virtual bool changing_mask(int mode) { return !(_revisioning && mode == MODE_INS); }
|
||||
virtual TMask* get_mask(int mode) { return mode == MODE_QUERY ? _qmsk : _emsk; }
|
||||
virtual TRelation* get_relation() const { return _rel; }
|
||||
virtual bool get_next_key(TToken_string& key);
|
||||
virtual bool has_filtered_cursor() const { return true; }
|
||||
virtual TCursor& get_filtered_cursor() const;
|
||||
|
||||
virtual void init_insert_mode(TMask& m);
|
||||
virtual void init_modify_mode(TMask& m);
|
||||
|
||||
virtual int read(TMask& m);
|
||||
virtual int write(const TMask& m);
|
||||
virtual int rewrite(const TMask& m);
|
||||
virtual bool remove();
|
||||
|
||||
virtual void print();
|
||||
virtual void preview();
|
||||
};
|
||||
|
||||
bool TPreventivo_app::user_create()
|
||||
{
|
||||
_rel = new TRelation(LF_DOC);
|
||||
@ -1258,6 +1300,7 @@ int TPreventivo_app::read(TMask& m)
|
||||
t.expand();
|
||||
t.owner().force_update();
|
||||
}
|
||||
_codelab.cut(0); // Azzera in ogni caso l'elaborazione
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -1278,6 +1321,8 @@ static bool tree_save_row(TTree& tree, void* jolly, word /*flags*/)
|
||||
row.put(RDOC_TIPORIGA, rec->get(RDOC_TIPORIGA));
|
||||
row.put(RDOC_QTA, rec->get(RDOC_QTA));
|
||||
row.put(RDOC_DESCR, rec->get(RDOC_DESCR));
|
||||
row.put(RDOC_DESCLUNGA, rec->get(RDOC_DESCLUNGA));
|
||||
row.put(RDOC_DESCEST, rec->get(RDOC_DESCEST));
|
||||
row.put(RDOC_CODART, rec->get(RDOC_CODART));
|
||||
row.put(RDOC_UMQTA, rec->get(RDOC_UMQTA));
|
||||
row.put(RDOC_QTAGG1, rec->get(RDOC_QTAGG1));
|
||||
@ -1306,7 +1351,12 @@ int TPreventivo_app::save_rows(const TMask& m, bool re)
|
||||
rdoc.set_key(rkey);
|
||||
if (tree.goto_root() && tree.goto_firstson())
|
||||
tree.scan_depth_first(tree_save_row, &rdoc);
|
||||
return rdoc.write(re);
|
||||
int err = rdoc.write(re);
|
||||
if (err == NOERR && _codelab.full())
|
||||
pe_genera_ordine(get_relation()->curr(), _codelab);
|
||||
_codelab.cut(0); // Azzera in ogni caso l'elaborazione
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int TPreventivo_app::write(const TMask& m)
|
||||
@ -1342,24 +1392,39 @@ bool TPreventivo_app::remove()
|
||||
return done;
|
||||
}
|
||||
|
||||
void TPreventivo_app::update_tools(TMask& m)
|
||||
{
|
||||
const bool is_edit = m.edit_mode();
|
||||
const bool can_elab = is_edit && pe_trova_elaborazione(m).full();
|
||||
bool can_print = is_edit;
|
||||
if (can_print)
|
||||
{
|
||||
const TTipo_documento& tip = cached_tipodoc(m.get(DOC_TIPODOC));
|
||||
TFilename rep;
|
||||
can_print = tip.main_print_profile(rep, 0x2);
|
||||
}
|
||||
|
||||
m.enable(DLG_COPY, is_edit);
|
||||
m.enable(DLG_NEWREC, is_edit);
|
||||
m.enable(DLG_ELABORA, can_elab);
|
||||
m.enable(DLG_PRINT, can_print);
|
||||
m.enable(DLG_PREVIEW, can_print);
|
||||
m.disable(F_STATO); // Enable with F12
|
||||
}
|
||||
|
||||
void TPreventivo_app::init_insert_mode(TMask& m)
|
||||
{
|
||||
_revisioning = false;
|
||||
TRelation_application::init_insert_mode(m);
|
||||
m.set(F_DATADOC, TDate(TODAY));
|
||||
m.disable(DLG_COPY);
|
||||
m.disable(DLG_NEWREC);
|
||||
m.disable(DLG_ELABORA);
|
||||
update_tools(m);
|
||||
}
|
||||
|
||||
void TPreventivo_app::init_modify_mode(TMask& m)
|
||||
{
|
||||
_revisioning = false;
|
||||
TRelation_application::init_modify_mode(m);
|
||||
m.enable(DLG_COPY);
|
||||
m.enable(DLG_NEWREC);
|
||||
const TRectype& doc = get_relation()->curr();
|
||||
m.enable(DLG_ELABORA, trova_elaborazione(doc).full());
|
||||
update_tools(m);
|
||||
}
|
||||
|
||||
bool TPreventivo_app::save_and_print(TPrtype mode)
|
||||
@ -1409,3 +1474,4 @@ int pe1400(int argc, char* argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -120,6 +120,12 @@ END
|
||||
STRING F_STATO 1
|
||||
BEGIN
|
||||
PROMPT 53 1 "Stato "
|
||||
USE %STD
|
||||
INPUT CODTAB F_STATO
|
||||
DISPLAY "Codice" CODTAB
|
||||
DISPLAY "Descrizione@50" S0
|
||||
OUTPUT F_STATO CODTAB
|
||||
CHECKTYPE NORMAL
|
||||
FIELD STATO
|
||||
FLAGS "DG"
|
||||
END
|
||||
@ -292,7 +298,7 @@ END
|
||||
|
||||
ZOOM F_NOTE 62
|
||||
BEGIN
|
||||
PROMPT 2 10 "Note "
|
||||
PROMPT 2 10 "Oggetto "
|
||||
FIELD NOTE
|
||||
END
|
||||
|
||||
@ -386,8 +392,8 @@ TLIST F_FASI 60 -1
|
||||
BEGIN
|
||||
PROMPT 0 2 ""
|
||||
DISPLAY "Fasi@15" CODART
|
||||
DISPLAY "Costo@7R" QTAGG5
|
||||
DISPLAY "Prezzo@7R" PREZZO
|
||||
DISPLAY "Costo@10R" QTAGG5
|
||||
DISPLAY "Prezzo@10R" PREZZO
|
||||
DISPLAY "Descrizione@35" DESCR
|
||||
END
|
||||
|
||||
@ -455,8 +461,8 @@ BEGIN
|
||||
ITEM "Descrizione@50"
|
||||
ITEM "U.M."
|
||||
ITEM "Quantità@9"
|
||||
ITEM "Costo@9R"
|
||||
ITEM "Prezzo@9R"
|
||||
ITEM "Costo@16R"
|
||||
ITEM "Prezzo@16R"
|
||||
END
|
||||
|
||||
SPREADSHEET F_ARTICOLI 0 7
|
||||
@ -466,7 +472,8 @@ BEGIN
|
||||
ITEM "Descrizione@50"
|
||||
ITEM "U.M."
|
||||
ITEM "Quantità@9R"
|
||||
ITEM "Costo@9R"
|
||||
ITEM "Costo@16R"
|
||||
ITEM "Prezzo@16R"
|
||||
END
|
||||
|
||||
SPREADSHEET F_MISURE
|
||||
@ -483,7 +490,7 @@ ENDPAGE
|
||||
|
||||
ENDMASK
|
||||
|
||||
PAGE "Distinta" -1 -1 60 6
|
||||
PAGE "Distinta" -1 -1 65 6
|
||||
|
||||
STRING 101 20
|
||||
BEGIN
|
||||
@ -493,7 +500,7 @@ BEGIN
|
||||
DISPLAY "Codice@20" CODDIST
|
||||
DISPLAY "Descrizione@50" DESCR
|
||||
DISPLAY "U.M." UM
|
||||
DISPLAY "Prezzo@V" PREZZO
|
||||
DISPLAY "Prezzo@14V" PREZZO
|
||||
OUTPUT 101 CODDIST
|
||||
OUTPUT 102 DESCR
|
||||
OUTPUT 103 UM
|
||||
@ -503,15 +510,15 @@ BEGIN
|
||||
FIELD CODART
|
||||
END
|
||||
|
||||
STRING 102 50 45
|
||||
ZOOM 102 50
|
||||
BEGIN
|
||||
PROMPT 1 2 "Descriz. "
|
||||
PROMPT 1 2 "Descriz. "
|
||||
USE LF_DIST KEY 2
|
||||
INPUT DESCR 105
|
||||
DISPLAY "Descrizione@50" DESCR
|
||||
DISPLAY "Codice@20" CODDIST
|
||||
DISPLAY "U.M." UM
|
||||
DISPLAY "Prezzo@V" PREZZO
|
||||
DISPLAY "Prezzo@14V" PREZZO
|
||||
COPY OUTPUT 101
|
||||
CHEKTYPE SEARCH
|
||||
FIELD DESCR
|
||||
@ -531,19 +538,19 @@ END
|
||||
|
||||
NUMBER 104 9 2
|
||||
BEGIN
|
||||
PROMPT 11 3 "Quantitŕ "
|
||||
PROMPT 13 3 "Quantità "
|
||||
FIELD QTA
|
||||
END
|
||||
|
||||
CURRENCY 105 9
|
||||
CURRENCY 105 16
|
||||
BEGIN
|
||||
PROMPT 37 3 "Costo "
|
||||
PROMPT 35 3 "Costo "
|
||||
FIELD QTAGG5
|
||||
END
|
||||
|
||||
CURRENCY 106 9
|
||||
CURRENCY 106 16
|
||||
BEGIN
|
||||
PROMPT 37 4 "Prezzo "
|
||||
PROMPT 35 4 "Prezzo "
|
||||
FIELD PREZZO
|
||||
END
|
||||
|
||||
@ -569,7 +576,7 @@ END
|
||||
ENDPAGE
|
||||
ENDMASK
|
||||
|
||||
PAGE "Riga" -1 -1 50 5
|
||||
PAGE "Riga" -1 -1 65 5
|
||||
|
||||
STRING 101 20
|
||||
BEGIN
|
||||
@ -585,9 +592,9 @@ BEGIN
|
||||
ADD RUN ve2 -3
|
||||
END
|
||||
|
||||
STRING 102 50 40
|
||||
STRING 102 50
|
||||
BEGIN
|
||||
PROMPT 1 2 "Descriz. "
|
||||
PROMPT 1 2 "Descriz. "
|
||||
USE LF_ANAMAG KEY 2
|
||||
INPUT DESCR 102
|
||||
DISPLAY "Descrizione@50" DESCR
|
||||
@ -613,16 +620,23 @@ END
|
||||
|
||||
NUMBER 104 9 2
|
||||
BEGIN
|
||||
PROMPT 11 3 "Quantitŕ "
|
||||
PROMPT 13 3 "Quantità "
|
||||
FIELD QTA
|
||||
END
|
||||
|
||||
CURRENCY 105 9
|
||||
CURRENCY 105 16
|
||||
BEGIN
|
||||
PROMPT 31 3 "Costo "
|
||||
PROMPT 34 3 "Costo "
|
||||
FIELD QTAGG5
|
||||
END
|
||||
|
||||
CURRENCY 106 16
|
||||
BEGIN
|
||||
PROMPT 34 4 "Prezzo "
|
||||
FIELD PREZZO
|
||||
END
|
||||
|
||||
|
||||
ENDPAGE
|
||||
|
||||
TOOLBAR "" 0 0 0 2
|
||||
|
@ -61,7 +61,4 @@ public:
|
||||
bool append_row(const TRectype& rec);
|
||||
};
|
||||
|
||||
const TString& trova_elaborazione(const TRectype& doc);
|
||||
bool genera_ordine(const TRectype& doc);
|
||||
|
||||
#endif
|
||||
|
@ -1,86 +0,0 @@
|
||||
#include "pe1401.h"
|
||||
#include "../ve/velib04.h"
|
||||
|
||||
class TPreventivazione : public TElaborazione
|
||||
{
|
||||
public:
|
||||
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||
const TDate& data_elab, bool interattivo = false);
|
||||
TPreventivazione(const TString& cod) : TElaborazione(cod) { }
|
||||
};
|
||||
|
||||
bool TPreventivazione::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||
const TDate& data_elab, bool interattivo)
|
||||
{
|
||||
for (int i = 0; i < doc_in.items(); i++)
|
||||
{
|
||||
if (i >= doc_out.items())
|
||||
{
|
||||
TDocumento* doc = new TDocumento('D', data_elab.year(), codice_numerazione_finale(), 0L);
|
||||
doc->put(DOC_TIPODOC, tipo_finale());
|
||||
doc->put(DOC_STATO, stato_finale());
|
||||
doc_out.add(doc);
|
||||
}
|
||||
|
||||
TDocumento& din = doc_in[i];
|
||||
TDocumento& don = doc_out[i];
|
||||
|
||||
don.put(DOC_TIPOCF, din.get(DOC_TIPOCF));
|
||||
don.put(DOC_CODCF, din.get(DOC_CODCF));
|
||||
don.put(DOC_DATADOC, data_elab);
|
||||
don.put(DOC_NOTE, din.get(DOC_NOTE));
|
||||
don.put(DOC_CODCMS, din.get(DOC_CODCMS));
|
||||
|
||||
FOR_EACH_PHYSICAL_RDOC(din, r, rdoc)
|
||||
{
|
||||
if (rdoc->is_descrizione())
|
||||
{
|
||||
TRiga_documento& rout = don.new_row(rdoc->get(RDOC_TIPORIGA));
|
||||
TDocumento::copy_data(rout, *rdoc);
|
||||
} else
|
||||
if (rdoc->is_merce())
|
||||
{
|
||||
TRiga_documento& rout = don.new_row(rdoc->get(RDOC_TIPORIGA));
|
||||
TDocumento::copy_data(rout, *rdoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const TString& trova_elaborazione(const TRectype& doc)
|
||||
{
|
||||
TString8 cod;
|
||||
TISAM_recordset eld("USE %ELD SELECT (I0==0)||(I0=4)");
|
||||
const TString4 codnum = doc.get(DOC_CODNUM);
|
||||
const TString4 tipodoc = doc.get(DOC_TIPODOC);
|
||||
const TString4 stato = doc.get(DOC_STATO);
|
||||
for (bool ok = eld.move_first(); ok; ok = eld.move_next())
|
||||
{
|
||||
const TString4 c = eld.get("CODTAB").as_string();
|
||||
const TElaborazione e(c);
|
||||
if (codnum != e.codice_numerazione_iniziale())
|
||||
continue;
|
||||
if (tipodoc != e.tipo_iniziale(0))
|
||||
continue;
|
||||
if (stato >= e.stato_finale_doc_iniziale())
|
||||
continue;
|
||||
cod = c;
|
||||
break;
|
||||
}
|
||||
return get_tmp_string() = cod;
|
||||
}
|
||||
|
||||
bool genera_ordine(const TRectype& doc)
|
||||
{
|
||||
const TString& codelab = trova_elaborazione(doc);
|
||||
if (codelab.empty())
|
||||
return false;
|
||||
|
||||
const TDate oggi(TODAY);
|
||||
TLista_documenti doc_in, doc_out;
|
||||
doc_in.add(new TDocumento(doc));
|
||||
|
||||
TPreventivazione prev(codelab);
|
||||
return prev.elabora(doc_in, doc_out, oggi);
|
||||
}
|
192
pe/pe1500.cpp
Normal file
192
pe/pe1500.cpp
Normal file
@ -0,0 +1,192 @@
|
||||
#include "../ve/velib04.h"
|
||||
#include "../ca/calib01.h"
|
||||
#include "pe1500.h"
|
||||
|
||||
#include "../ca/fasi.h"
|
||||
|
||||
class TOrdinazione : public TElaborazione_esterna
|
||||
{
|
||||
public:
|
||||
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||
const TDate& data_elab, bool interattivo = false);
|
||||
TOrdinazione(const TString& cod) : TElaborazione_esterna(cod) { }
|
||||
};
|
||||
|
||||
bool TOrdinazione::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||
const TDate& data_elab, bool interattivo)
|
||||
{
|
||||
const TString80 codart = ini_get_string(CONFIG_DITTA, "ci", "CODARTPR");
|
||||
|
||||
for (int i = 0; i < doc_in.items(); i++)
|
||||
{
|
||||
if (i >= doc_out.items())
|
||||
{
|
||||
TDocumento* doc = new TDocumento('D', data_elab.year(), codice_numerazione_finale(), 0L);
|
||||
doc->put(DOC_TIPODOC, tipo_finale());
|
||||
doc->put(DOC_STATO, stato_finale());
|
||||
doc_out.add(doc);
|
||||
}
|
||||
|
||||
TDocumento& din = doc_in[i];
|
||||
TDocumento& don = doc_out[i];
|
||||
|
||||
don.put(DOC_TIPOCF, din.get(DOC_TIPOCF));
|
||||
don.put(DOC_CODCF, din.get(DOC_CODCF));
|
||||
don.put(DOC_DATADOC, data_elab);
|
||||
don.put(DOC_NOTE, din.get(DOC_NOTE));
|
||||
don.put(DOC_CODCMS, din.get(DOC_CODCMS));
|
||||
|
||||
TLocalisamfile fasi(LF_FASI);
|
||||
|
||||
const TMultilevel_code_info cfg_fasi(LF_FASI);
|
||||
TString16 fase;
|
||||
|
||||
FOR_EACH_PHYSICAL_RDOC(din, r, rdoc)
|
||||
{
|
||||
if (rdoc->is_descrizione())
|
||||
{
|
||||
TRiga_documento& rout = don.new_row(rdoc->get(RDOC_TIPORIGA));
|
||||
TDocumento::copy_data(rout, *rdoc);
|
||||
|
||||
const int last_lev = cfg_fasi.levels()-1;
|
||||
if (last_lev >= 0)
|
||||
{
|
||||
const int last_len = cfg_fasi.len(last_lev);
|
||||
const long last_val = atol(fase)+1;
|
||||
fase.format("%0*ld", last_len, last_val);
|
||||
fasi.put(FASI_CODCMSFAS, din.get(DOC_CODCMS));
|
||||
fasi.put(FASI_CODFASE, fase);
|
||||
fasi.put(FASI_DESCRIZ, rdoc->get(RDOC_DESCR));
|
||||
fasi.write_rewrite();
|
||||
}
|
||||
} else
|
||||
if (rdoc->is_merce())
|
||||
{
|
||||
TRiga_documento& rout = don.new_row(rdoc->get(RDOC_TIPORIGA));
|
||||
TDocumento::copy_data(rout, *rdoc);
|
||||
rout.set_original_rdoc_key(*rdoc);
|
||||
rout.put(RDOC_FASCMS, fase);
|
||||
rout.put(RDOC_CODARTMAG, codart);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const TString& pe_trova_elaborazione(const TRectype& doc)
|
||||
{
|
||||
TString16 cod;
|
||||
|
||||
const TString4 codnum = doc.get(DOC_CODNUM);
|
||||
const TString4 tipodoc = doc.get(DOC_TIPODOC);
|
||||
const TString4 stato = doc.get(DOC_STATO);
|
||||
TString str;
|
||||
str << "USE %ELD SELECT (STR(I0=\"0\"))&&(S3=\"pe1 -4\")&&(S5=\"" << codnum << "\")";
|
||||
TRecordset* eld = create_recordset(str);
|
||||
if (eld != NULL)
|
||||
{
|
||||
for (bool ok = eld->move_first(); ok; ok = eld->move_next())
|
||||
{
|
||||
const TString16 c = eld->get("CODTAB").as_string();
|
||||
const TElaborazione e(c);
|
||||
if (e.is_document_ok(doc))
|
||||
{
|
||||
cod = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete eld;
|
||||
}
|
||||
return get_tmp_string() = cod;
|
||||
}
|
||||
|
||||
const TString& pe_trova_elaborazione(const TMask& m)
|
||||
{
|
||||
TRectype doc(LF_DOC);
|
||||
doc.put(DOC_PROVV, 'D');
|
||||
doc.put(DOC_ANNO, m.get(DOC_ANNO));
|
||||
doc.put(DOC_CODNUM, m.get(DOC_CODNUM));
|
||||
doc.put(DOC_NDOC, m.get(DOC_NDOC));
|
||||
doc.put(DOC_TIPODOC, m.get(DOC_TIPODOC));
|
||||
doc.put(DOC_STATO, m.get(DOC_STATO));
|
||||
return pe_trova_elaborazione(doc);
|
||||
}
|
||||
|
||||
bool pe_genera_ordine(TRectype& doc, const TString& cod)
|
||||
{
|
||||
TString16 codelab = cod;
|
||||
if (codelab.blank())
|
||||
codelab = pe_trova_elaborazione(doc);
|
||||
|
||||
TOrdinazione prev(codelab);
|
||||
if (prev.empty())
|
||||
return false;
|
||||
|
||||
const TDate oggi(TODAY);
|
||||
TLista_documenti doc_in, doc_out;
|
||||
doc_in.add(new TDocumento(doc));
|
||||
|
||||
bool ok = prev.elabora(doc_in, doc_out, oggi);
|
||||
if (ok)
|
||||
{
|
||||
doc_in.rewrite();
|
||||
doc_out.write();
|
||||
|
||||
const TRectype& idoc = doc_in[0];
|
||||
for (int i = 0; i < idoc.items(); i++)
|
||||
{
|
||||
const char* fld = idoc.fieldname(i);
|
||||
const TString& val = idoc.get(fld);
|
||||
if (val.full())
|
||||
doc.put(fld, val);
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TOrdinazione_app
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TOrdinazione_app : public TSkeleton_application
|
||||
{
|
||||
protected:
|
||||
virtual void main_loop();
|
||||
};
|
||||
|
||||
void TOrdinazione_app::main_loop()
|
||||
{
|
||||
TFilename ininame;
|
||||
if (argc() >= 2)
|
||||
{
|
||||
const TFixed_string arg = argv(2);
|
||||
ininame = arg.starts_with("-i", true) ? arg.mid(2) : arg;
|
||||
}
|
||||
|
||||
TConfig ini(ininame, "Transaction");
|
||||
const TString8 codelab = ini.get("Action");
|
||||
|
||||
ini.set_paragraph("33");
|
||||
TRectype doc(LF_DOC);
|
||||
doc.put(DOC_PROVV, ini.get(DOC_PROVV));
|
||||
doc.put(DOC_ANNO, ini.get(DOC_ANNO));
|
||||
doc.put(DOC_CODNUM, ini.get(DOC_CODNUM));
|
||||
doc.put(DOC_NDOC, ini.get(DOC_NDOC));
|
||||
|
||||
if (pe_genera_ordine(doc, codelab))
|
||||
{
|
||||
ini.set_paragraph("Transaction");
|
||||
ini.set("Result", "OK");
|
||||
ini.set("Error", "0");
|
||||
|
||||
ini.set_paragraph("33");
|
||||
for (int i = 0; i < doc.items(); i++)
|
||||
{
|
||||
const char* fld = doc.fieldname(i);
|
||||
const TString& val = doc.get(fld);
|
||||
if (val.full())
|
||||
ini.set(fld, val);
|
||||
}
|
||||
}
|
||||
}
|
8
pe/pe1500.h
Normal file
8
pe/pe1500.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef __PE1500_H
|
||||
#define __PE1500_H
|
||||
|
||||
const TString& pe_trova_elaborazione(const TRectype& doc);
|
||||
const TString& pe_trova_elaborazione(const TMask& doc);
|
||||
bool pe_genera_ordine(TRectype& doc, const TString& codelab);
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user