Aggiunto supporto per elaborzione da chiamare al passaggio da provvisorio a definitivo

git-svn-id: svn://10.65.10.50/branches/R_10_00@22730 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2012-09-18 10:38:43 +00:00
parent ffc8c4a48d
commit e1a988050f
9 changed files with 339 additions and 260 deletions

View File

@ -400,13 +400,19 @@ bool TMotore_application::menu(MENU_TAG mt)
return ok; return ok;
} }
void TMotore_application::do_elab( TDocumento& doc, bool stampa ) // C 90 void TMotore_application::do_elab( TDocumento& doc, int when) // C 90
{ {
const TString16 codelab = stampa ? doc.tipo().elaborazione_stampa() : doc.tipo().elaborazione(); TString16 codelab;
switch (when)
{
case 1: codelab = doc.tipo().elaborazione_stampa(); break;
case 2: codelab = doc.tipo().elaborazione_definitiva(); break;
default: codelab = doc.tipo().elaborazione(); break;
}
if (codelab.full()) if (codelab.full())
{ {
TRectype eld = cache().get("%ELD", codelab); const TRectype& eld = cache().get("%ELD", codelab);
if (!eld.empty()) if (!eld.empty())
{ {
TElaborazione * el = NULL; TElaborazione * el = NULL;
@ -439,14 +445,17 @@ void TMotore_application::do_elab( TDocumento& doc, bool stampa ) // C 90
default : default :
break; break;
} }
TToken_string tipi;
TToken_string stati;
TToken_string tipi, stati;
el->tipi_stati_iniziali(tipi, stati); el->tipi_stati_iniziali(tipi, stati);
if (stati.find(doc.stato()) >= 0) if (stati.find(doc.stato()) >= 0)
{ {
TDocumento newdoc(doc.get_char(DOC_PROVV), doc.get_int(DOC_ANNO), el->codice_numerazione_finale(), 0L); TLista_documenti in; in.add(doc);
TLista_documenti out;
TDocumento newdoc(doc.get_char(DOC_PROVV), doc.get_int(DOC_ANNO), el->codice_numerazione_finale(), 0L);
if (when == 0)
{
TDocumento::copy_data(newdoc.head(), doc.head()); TDocumento::copy_data(newdoc.head(), doc.head());
newdoc.put(DOC_TIPODOC, el->tipo_finale()); newdoc.put(DOC_TIPODOC, el->tipo_finale());
newdoc.put(DOC_STATO, el->stato_finale()); newdoc.put(DOC_STATO, el->stato_finale());
@ -454,14 +463,14 @@ void TMotore_application::do_elab( TDocumento& doc, bool stampa ) // C 90
newdoc.put(DOC_CAUSMAG, newdoc.tipo().caus_mov()); newdoc.put(DOC_CAUSMAG, newdoc.tipo().caus_mov());
else else
newdoc.zero(DOC_CAUSMAG); newdoc.zero(DOC_CAUSMAG);
out.add(newdoc);
}
TLista_documenti in; in.add(doc);
TLista_documenti out; out.add(newdoc);
if (el->elabora(in, out, TDate(TODAY), true)) if (el->elabora(in, out, TDate(TODAY), true))
{ {
if (out[0] != newdoc) if (when == 0 && out.items() && out[0] != newdoc)
out.rewrite(); out.rewrite();
if (doc != in[0]) if (when < 2 && in.items() && in[0] != doc)
doc = in[0]; doc = in[0];
} }
} }

View File

@ -49,7 +49,6 @@ protected:
virtual void init_modify_mode(TMask& m); virtual void init_modify_mode(TMask& m);
void load_auto_reopen_data(); void load_auto_reopen_data();
virtual int read(TMask& m); virtual int read(TMask& m);
virtual void do_elab(TDocumento& doc, bool stampa = false);
virtual int write(const TMask& m); virtual int write(const TMask& m);
virtual int rewrite(const TMask& m); virtual int rewrite(const TMask& m);
virtual bool remove(); virtual bool remove();
@ -81,6 +80,7 @@ protected:
bool save_and_print(bool savedoc, TPrtype mode); bool save_and_print(bool savedoc, TPrtype mode);
public: public:
virtual void do_elab(TDocumento& doc, int w = 0); // w 0=Save; 1=Print; 2=Definitive
virtual void print(); virtual void print();
virtual void preview(); virtual void preview();

View File

@ -12,6 +12,7 @@ END
BUTTON F_RIPRISTINA 12 2 BUTTON F_RIPRISTINA 12 2
BEGIN BEGIN
PROMPT -23 -11 "~Ricevi" PROMPT -23 -11 "~Ricevi"
PICTURE BMP_IMPORT
MESSAGE EXIT,K_DEL MESSAGE EXIT,K_DEL
END END

View File

@ -300,6 +300,7 @@ public:
const char stato_provvigioni() const {return get("S3")[0]; } const char stato_provvigioni() const {return get("S3")[0]; }
const TString & elaborazione() const {return get("S3").mid(4,8); } const TString & elaborazione() const {return get("S3").mid(4,8); }
const TString & elaborazione_stampa() const {return get("S3").mid(12,8); } const TString & elaborazione_stampa() const {return get("S3").mid(12,8); }
const TString & elaborazione_definitiva() const {return get("S3").mid(20,8); }
const TString & caus_mov() const {return get("S9"); } const TString & caus_mov() const {return get("S9"); }
const TString & caus_anticipo() const {return get("S10"); } const TString & caus_anticipo() const {return get("S10"); }
const TString & tipi_iva_validi() const {return get("S11"); } const TString & tipi_iva_validi() const {return get("S11"); }

View File

@ -1460,7 +1460,7 @@ const TRectype* TRiga_documento::find_original_rdoc() const
const TRectype* TRiga_documento::find_original_doc() const const TRectype* TRiga_documento::find_original_doc() const
{ {
const long id = get_long(RDOC_DAIDRIGA); const long id = get_long(RDOC_DANDOC);
if (id > 0L) if (id > 0L)
{ {
TToken_string key; TToken_string key;

View File

@ -498,55 +498,56 @@ bool TElaborazione_esterna::elabora(TLista_documenti& doc_in, TLista_documenti&
const TDate& data_elab, bool interattivo) const TDate& data_elab, bool interattivo)
{ {
if (applicazione_esterna().blank()) if (applicazione_esterna().blank())
error_box("Non e' stato specificato il nome del'applicazione esterna"); return error_box("Non e' stato specificato il nome del'applicazione esterna");
CHECK(doc_in.items() == 1, "Si deve specificare uno e un solo documento in entrata"); CHECK(doc_in.items() == 1, "Si deve specificare uno e un solo documento in entrata");
CHECK(doc_out.items() == 1, "Si deve specificare uno e un solo documento in uscita"); CHECK(doc_out.items() <= 1, "Si deve specificare uno e un solo documento in uscita");
TFilename name; name.temp("ext"); TFilename name; name.temp("ext");
TDocumento& d = doc_in[0];
const int doc_fields = d.items();
TString16 par; TString16 par;
{ {
TConfig c(name, "Transaction"); TConfig c(name, "Transaction");
c.set("Action", codice()); c.set("Action", codice());
c.set("DataElab", data_elab.string());
c.set("Interattivo", interattivo);
if (doc_out.items() == 1)
{
c.set("ProvvOut", doc_out[0].get(DOC_PROVV)); c.set("ProvvOut", doc_out[0].get(DOC_PROVV));
c.set("AnnoOut", doc_out[0].get(DOC_ANNO)); c.set("AnnoOut", doc_out[0].get(DOC_ANNO));
c.set("CodNumOut", doc_out[0].get(DOC_CODNUM)); c.set("CodNumOut", doc_out[0].get(DOC_CODNUM));
c.set("NDocOut", doc_out[0].get(DOC_NDOC)); c.set("NDocOut", doc_out[0].get(DOC_NDOC));
}
par.format("%d", LF_DOC); par.format("%d", LF_DOC);
TDocumento& d = doc_in[0];
const int doc_fields = d.items();
for (int i = 0; i < doc_fields; i++) for (int i = 0; i < doc_fields; i++)
{ {
const TString16 fname(d.fieldname(i)); const char* fname = d.fieldname(i);
TFieldref f(fname, LF_DOC); const TFieldref f(fname, LF_DOC);
f.write(c, par, d.get(fname)); f.write(c, par, d.get(fname));
} }
for (TVariable_field* v = d.first_variable_field(); v ; v = d.succ_variable_field()) for (TVariable_field* v = d.first_variable_field(); v ; v = d.succ_variable_field())
c.set(v->name(), v->get(), par); c.set(v->name(), v->get(), par);
const int rows = d.physical_rows();
if (rows > 0)
{
const int row_fields = d[1].items();
for (int r = 1; r <= rows; r++) FOR_EACH_PHYSICAL_RDOC(d, r, row)
{ {
TRiga_documento row = d[r];
par.format("%d,%d", LF_RIGHEDOC, r); par.format("%d,%d", LF_RIGHEDOC, r);
const int row_fields = row->items();
for (int i = 0; i < row_fields; i++) for (int i = 0; i < row_fields; i++)
{ {
const TString16 fname(row.fieldname(i)); const char* fname = row->fieldname(i);
TFieldref f(fname, LF_RIGHEDOC); const TFieldref f(fname, LF_RIGHEDOC);
f.write(c, par, row.get(fname)); f.write(c, par, row->get(fname));
} }
for (TVariable_field * v = row.first_variable_field(); v ; v = row.succ_variable_field()) for (TVariable_field * v = row->first_variable_field(); v ; v = row->succ_variable_field())
c.set(v->name(), v->get(), par); c.set(v->name(), v->get(), par);
} }
} }
}
TString command_line(applicazione_esterna()); command_line << " /i" << name; TString command_line; command_line << applicazione_esterna() << " /i" << name;
TExternal_app app(command_line); TExternal_app app(command_line);
if (app.run() == 0) if (app.run() == 0)
{ {
@ -554,10 +555,13 @@ bool TElaborazione_esterna::elabora(TLista_documenti& doc_in, TLista_documenti&
const TString & res = c.get("Result"); const TString & res = c.get("Result");
if (res == "SUCCESS") if (res == "SUCCESS")
{ {
TDocumento& d = doc_in[0];
const int doc_fields = d.items();
par.format("%d", LF_DOC); par.format("%d", LF_DOC);
for (int i = 0; i < doc_fields; i++) for (int i = 0; i < doc_fields; i++)
{ {
const TString16 fname(d.fieldname(i)); const char* fname = d.fieldname(i);
TFieldref f(fname, LF_DOC); TFieldref f(fname, LF_DOC);
d.put(fname, f.read(c, par)); d.put(fname, f.read(c, par));
} }
@ -576,24 +580,29 @@ bool TElaborazione_esterna::elabora(TLista_documenti& doc_in, TLista_documenti&
TRiga_documento& row = d.new_row(tiporiga); TRiga_documento& row = d.new_row(tiporiga);
for (int i = row.items()-1; i >= 0; i--) for (int i = row.items()-1; i >= 0; i--)
{ {
const TString16 fname(row.fieldname(i)); const char* fname = row.fieldname(i);
TFieldref f(fname, LF_RIGHEDOC); const TFieldref f(fname, LF_RIGHEDOC);
const TString& val = f.read(c, par); const TString& val = f.read(c, par);
if (val.not_empty()) if (val.not_empty())
row.put(fname, val); row.put(fname, val);
} }
r++; par.format("%d,%d", LF_RIGHEDOC, ++r);
par.format("%d,%d", LF_RIGHEDOC, r);
} }
d.stato(stato_finale_doc_iniziale()[0]);
const char final = stato_finale_doc_iniziale()[0];
if (d.stato() != final)
d.stato(final);
return true; return true;
} } else
else
if (res == "OUTDOC") if (res == "OUTDOC")
{
if (doc_out.items())
{ {
doc_out[0].read(); doc_out[0].read();
return true; return true;
} }
}
} }
return false; return false;

View File

@ -4154,8 +4154,11 @@ bool TDocumento_mask::confirm_handler( TMask_field& f, KEY key )
if (err == NOERR) if (err == NOERR)
{ {
err = src.remove(); err = src.remove();
if (err != NOERR) if (err == NOERR)
app().do_elab(dest, 2);
else
warning_box("Errore %d nell'eliminazione del documento provvisorio", err); warning_box("Errore %d nell'eliminazione del documento provvisorio", err);
mask.stop_run(K_ESC); mask.stop_run(K_ESC);
TMask & qmask = app().query_mask(); TMask & qmask = app().query_mask();
qmask.set(F_CODNUM, codnum); qmask.set(F_CODNUM, codnum);

View File

@ -36,6 +36,10 @@
#define F_STATOCHI 153 #define F_STATOCHI 153
#define F_CODELAB 154 #define F_CODELAB 154
#define F_DESCELAB 155 #define F_DESCELAB 155
#define F_CODELABS 156
#define F_DESCELABS 157
#define F_CODELABD 158
#define F_DESCELABD 159
#define F_STATOI_MOD_1 201 #define F_STATOI_MOD_1 201
#define F_STATOI_MOD_2 202 #define F_STATOI_MOD_2 202

View File

@ -1245,9 +1245,14 @@ BEGIN
FIELD B11 FIELD B11
END END
GROUPBOX DLG_NULL 78 5
BEGIN
PROMPT 1 12 "@bElaborazioni automatiche"
END
STRING F_CODELAB 8 STRING F_CODELAB 8
BEGIN BEGIN
PROMPT 2 12 "Codice " PROMPT 2 13 "Salva "
FLAG "U" FLAG "U"
FIELD S3[5,12] FIELD S3[5,12]
CHECKTYPE NORMAL CHECKTYPE NORMAL
@ -1262,7 +1267,7 @@ END
STRING F_DESCELAB 50 STRING F_DESCELAB 50
BEGIN BEGIN
PROMPT 20 12 "" PROMPT 26 13 ""
CHECKTYPE SEARCH CHECKTYPE SEARCH
WARNING "E' necessario specificare un valore" WARNING "E' necessario specificare un valore"
USE %ELD KEY 2 USE %ELD KEY 2
@ -1272,6 +1277,53 @@ BEGIN
COPY OUTPUT F_CODELAB COPY OUTPUT F_CODELAB
END END
STRING F_CODELABS 8
BEGIN
PROMPT 2 14 "Stampa "
FLAG "U"
FIELD S3[13,20]
CHECKTYPE NORMAL
COPY USE F_CODELAB
INPUT CODTAB F_CODELABS
COPY DISPLAY F_CODELAB
OUTPUT F_CODELABS CODTAB
OUTPUT F_DESCELABS S0
HELP "Codice dell'elaborazione differita da eseguire"
END
STRING F_DESCELABS 50
BEGIN
PROMPT 26 14 ""
COPY USE F_DESCELAB
INPUT S0 F_DESCELABS
COPY DISPLAY F_DESCELAB
COPY OUTPUT F_CODELABS
CHECKTYPE NORMAL
END
STRING F_CODELABD 8
BEGIN
PROMPT 2 15 "Definitivo "
FLAG "U"
FIELD S3[21,28]
CHECKTYPE NORMAL
COPY USE F_CODELAB
INPUT CODTAB F_CODELABD
COPY DISPLAY F_CODELAB
OUTPUT F_CODELABD CODTAB
OUTPUT F_DESCELABD S0
HELP "Codice dell'elaborazione differita da eseguire"
END
STRING F_DESCELABD 50
BEGIN
PROMPT 26 15 ""
COPY USE F_DESCELAB
INPUT S0 F_DESCELABD
COPY DISPLAY F_DESCELAB
COPY OUTPUT F_CODELABD
CHECKTYPE NORMAL
END
ENDPAGE ENDPAGE