Separati i programmi di rinumerazione e ricalcolo saldi

Corretta segnalazione nelle copie


git-svn-id: svn://10.65.10.50/trunk@668 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1994-11-18 17:38:53 +00:00
parent 00bfa3954b
commit 30ff853857
5 changed files with 314 additions and 278 deletions

View File

@ -4,9 +4,6 @@
MENU TASK_MENUBAR MENU TASK_MENUBAR
SUBMENU MENU_FILE "~File" SUBMENU MENU_FILE "~File"
ITEM BAR_ITEM(1) "~Movimenti"
ITEM BAR_ITEM(2) "~Saldi"
/* cg4 -1 Copia archivi piano conti, causali, clienti/fornitori iv direttiva */ /* cg4 -1 Copia archivi piano conti, causali, clienti/fornitori iv direttiva */
MENUBAR MENU_BAR(1) MENUBAR MENU_BAR(1)

View File

@ -49,13 +49,14 @@ struct therec {
class CG4100_App : public TApplication class CG4100_App : public TApplication
{ {
TString _year; TString _year;
char _optype;
public: public:
virtual bool create(); virtual bool create();
virtual bool destroy(); virtual bool destroy();
bool set_parms(bool year); bool set_parms();
virtual bool menu(MENU_TAG m); virtual bool menu(MENU_TAG m);
void restore_mov(TSystemisamfile& a, TSystemisamfile& b, TSystemisamfile& c); void restore_mov(TSystemisamfile& a, TSystemisamfile& b, TSystemisamfile& c);
@ -63,8 +64,7 @@ public:
bool sort_mov(); bool sort_mov();
bool sort_sal(); bool sort_sal();
CG4100_App() : TApplication(), _year(4) CG4100_App() : TApplication(), _year(4), _optype('S') {}
{ }
virtual ~CG4100_App() {} virtual ~CG4100_App() {}
}; };
@ -85,7 +85,9 @@ bool CG4100_App::create()
if (fexist("__mov__.sav")) if (fexist("__mov__.sav"))
warning_box("Un'operazione di riordino movimenti si e' conclusa" warning_box("Un'operazione di riordino movimenti si e' conclusa"
" impropriamente. Si raccomanda di rieseguirla"); " impropriamente. Si raccomanda di rieseguirla");
if (argc() > 2)
_optype = toupper(argv(2)[0]);
dispatch_e_menu(MENU_ITEM(1));
return TRUE; return TRUE;
} }
@ -99,16 +101,17 @@ bool CG4100_App::destroy()
return TApplication::destroy(); return TApplication::destroy();
} }
bool CG4100_App::set_parms(bool year) bool CG4100_App::set_parms()
{ {
TMask m("cg4100a"); const bool saldi = _optype == 'S';
TMask m(saldi ? "cg4100b" : "cg4100a");
if (!year)
m.hide(FLD_CG41_YEAR);
m.run(); m.run();
_year = m.get(FLD_CG41_YEAR); if (saldi)
_year = m.get(FLD_CG41_YEAR);
else
_year = 0;
return m.last_key() == K_ENTER; return m.last_key() == K_ENTER;
} }
@ -116,16 +119,12 @@ bool CG4100_App::set_parms(bool year)
bool CG4100_App::menu(MENU_TAG m) bool CG4100_App::menu(MENU_TAG m)
{ {
switch (m) if (_optype == 'S')
{
case BAR_ITEM(1):
sort_mov();
break;
case BAR_ITEM(2):
sort_sal(); sort_sal();
break; else
} if (_optype == 'M')
return TApplication::menu(m); sort_mov();
return FALSE;
} }
@ -187,7 +186,7 @@ void CG4100_App::restore_mov(TSystemisamfile& mov, TSystemisamfile& rmov,
bool CG4100_App::sort_mov() bool CG4100_App::sort_mov()
{ {
if (!set_parms(FALSE)) if (!set_parms())
return FALSE; return FALSE;
TSystemisamfile mov(LF_MOV); TSystemisamfile mov(LF_MOV);
@ -238,7 +237,7 @@ bool CG4100_App::sort_mov()
strcpy(rbuf.REG, mov.get(MOV_REG)); strcpy(rbuf.REG, mov.get(MOV_REG));
d = mov.get(MOV_DATADOC); d = mov.get(MOV_DATADOC);
s = mov.get(MOV_PROTIVA); s = mov.get(MOV_PROTIVA);
if (isdigit(s[s.len() - 1])) s << " "; if (s.len() > 0 && isdigit(s[s.len() - 1])) s << " ";
s.right_just(8); s.right_just(8);
strcpy(rbuf.NUMPROT, (const char *) s); strcpy(rbuf.NUMPROT, (const char *) s);
strcpy(rbuf.DATADOC, d.string(ANSI)); strcpy(rbuf.DATADOC, d.string(ANSI));
@ -347,7 +346,7 @@ bool CG4100_App::sort_mov()
bool CG4100_App::sort_sal() bool CG4100_App::sort_sal()
{ {
if (!set_parms(TRUE)) if (!set_parms())
return FALSE; return FALSE;
FILE* fp = fopen ("__sal__.sav","w"); FILE* fp = fopen ("__sal__.sav","w");

View File

@ -1,6 +1,4 @@
#define FLD_CG41_YEAR 100 PAGE "Riordino Movimenti" -1 -1 47 10
PAGE "Riordino Movimenti/Saldi" -1 -1 47 10
TEXT DLG_NULL TEXT DLG_NULL
BEGIN BEGIN
@ -17,22 +15,14 @@ BEGIN
PROMPT 3 4 "tempo. Siate certi di voler proseguire." PROMPT 3 4 "tempo. Siate certi di voler proseguire."
END END
NUMBER FLD_CG41_YEAR 4
BEGIN
PROMPT 3 6 "Anno da riordinare "
FLAGS "A"
HELP "Anno del quale si desidera il riordino degli archivi"
END
BUTTON DLG_OK 9 2 BUTTON DLG_OK 9 2
BEGIN BEGIN
PROMPT -12 -1 "Conferma" PROMPT -12 -1 "Conferma"
END END
BUTTON DLG_CANCEL 9 2 BUTTON DLG_QUIT 9 2
BEGIN BEGIN
PROMPT -22 -1 "Annulla" PROMPT -22 -1 ""
END END
ENDPAGE ENDPAGE

46
cg/cg4100b.uml Executable file
View File

@ -0,0 +1,46 @@
#define FLD_CG41_YEAR 100
PAGE "Ricalcolo Saldi" -1 -1 47 10
TEXT DLG_NULL
BEGIN
PROMPT 16 1 "ATTENZIONE"
END
TEXT DLG_NULL
BEGIN
PROMPT 2 3 "Il ricalcolo degli saldi puo' richiedere"
END
TEXT DLG_NULL
BEGIN
PROMPT 3 4 "tempo. Siate certi di voler proseguire."
END
NUMBER FLD_CG41_YEAR 4
BEGIN
PROMPT 3 6 "Anno di esercizio "
USE ESC
INPUT CODTAB FLD_CG41_YEAR
DISPLAY "Anno Esercizio" CODTAB
DISPLAY "Data inizio esercizio" D0
DISPLAY "Data fine esercizio " D1
OUTPUT FLD_CG41_YEAR CODTAB
CHECKTYPE REQUIRED
HELP "Anno del quale si desidera il ricalcolo dei saldi"
WARNING "L' anno di esercizio e' obbligatorio"
END
BUTTON DLG_OK 9 2
BEGIN
PROMPT -12 -1 "Conferma"
END
BUTTON DLG_QUIT 9 2
BEGIN
PROMPT -22 -1 ""
END
ENDPAGE
ENDMASK

View File

@ -1,240 +1,244 @@
#include <applicat.h> #include <applicat.h>
#include <isam.h> #include <isam.h>
#include <mask.h> #include <mask.h>
#include <pconti.h> #include <pconti.h>
#include <assoc.h> #include <assoc.h>
#include <urldefid.h> #include <urldefid.h>
#include <prefix.h> #include <prefix.h>
#include "cg4.h" #include "cg4.h"
#include "cg4200.h" #include "cg4200.h"
class TCopia_archivi : public TApplication class TCopia_archivi : public TApplication
{ {
TMask* _msk; TMask* _msk;
long _default_firm; long _default_firm;
virtual bool create() ; virtual bool create() ;
virtual bool destroy() ; virtual bool destroy() ;
bool menu(MENU_TAG); bool menu(MENU_TAG);
bool copyfile(int logicnum, long from, long to); bool copyfile(int logicnum, long from, long to);
void clearivd(long to); void clearivd(long to);
void copyivd(long from, long to); void copyivd(long from, long to);
public: public:
TCopia_archivi() : _msk(NULL) {} TCopia_archivi() : _msk(NULL) {}
}; };
bool TCopia_archivi::copyfile(int logicnum, long from, long to) bool TCopia_archivi::copyfile(int logicnum, long from, long to)
{ {
if (from > 0) set_firm(from); if (from > 0) set_firm(from);
else prefhndl->set("com"); else prefhndl->set("com");
TSystemisamfile file(logicnum); TSystemisamfile file(logicnum);
TFilename t; t.tempdir(); t << "/tr" << logicnum; TFilename t; t.tempdir(); t << "/tr" << logicnum;
if (file.dump(t) != NOERR) if (file.dump(t) != NOERR)
return error_box("Impossibile leggere i dati da copiare errore n. %d", file.status()); return error_box("Impossibile leggere i dati da copiare errore n. %d", file.status());
set_firm(to); set_firm(to);
TFilename s; s.tempdir(); s << "/sv" << logicnum; TFilename s; s.tempdir(); s << "/sv" << logicnum;
if (file.dump(s) != NOERR) if (file.dump(s) != NOERR)
return error_box("Impossibile salvare i dati originali errore n. %d", file.status()); return error_box("Impossibile salvare i dati originali errore n. %d", file.status());
TDir dir; TDir dir;
dir.get(logicnum, _lock, _nordir, _sysdirop); dir.get(logicnum, _lock, _nordir, _sysdirop);
dir.eod() = 0L; dir.eod() = 0L;
dir.put(logicnum, _nordir, _sysdirop); dir.put(logicnum, _nordir, _sysdirop);
file.packindex(); file.packindex();
if (file.load(t) != NOERR) if (file.load(t) != NOERR)
{ {
error_box("Impossibile scrivere i dati errore n. %d. Cerco di ripristinare i dati originali.", file.status()); error_box("Impossibile scrivere i dati errore n. %d. Cerco di ripristinare i dati originali.", file.status());
dir.get(logicnum, _lock, _nordir, _sysdirop); dir.get(logicnum, _lock, _nordir, _sysdirop);
dir.eod() = 0L; dir.eod() = 0L;
dir.put(logicnum, _nordir, _sysdirop); dir.put(logicnum, _nordir, _sysdirop);
file.packindex(); file.packindex();
if (file.load(s)) if (file.load(s))
error_box("Impossibile scrivere i dati originali errore n. %d", file.status()); error_box("Impossibile scrivere i dati originali errore n. %d", file.status());
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
void TCopia_archivi::clearivd(long to) void TCopia_archivi::clearivd(long to)
{ {
TLocalisamfile pcon(LF_PCON); TLocalisamfile pcon(LF_PCON);
for (pcon.first(); pcon.good(); pcon.next()) for (pcon.first(); pcon.good(); pcon.next())
{ {
pcon.put(PCN_SEZIVD, "0"); pcon.put(PCN_SEZIVD, "0");
pcon.zero(PCN_LETTIVD); pcon.zero(PCN_LETTIVD);
pcon.zero(PCN_NUMRIVD); pcon.zero(PCN_NUMRIVD);
pcon.zero(PCN_NUMIVD); pcon.zero(PCN_NUMIVD);
pcon.put(PCN_SEZIVDOPP, "0"); pcon.put(PCN_SEZIVDOPP, "0");
pcon.zero(PCN_LETTIVDOPP); pcon.zero(PCN_LETTIVDOPP);
pcon.zero(PCN_NUMRIVDOPP); pcon.zero(PCN_NUMRIVDOPP);
pcon.zero(PCN_NUMIVDOPP); pcon.zero(PCN_NUMIVDOPP);
pcon.rewrite(); pcon.rewrite();
} }
} }
void TCopia_archivi::copyivd(long from, long to) void TCopia_archivi::copyivd(long from, long to)
{ {
if (from > 0) set_firm(from); if (from > 0) set_firm(from);
else prefhndl->set("com"); else prefhndl->set("com");
TLocalisamfile pcon(LF_PCON); TLocalisamfile pcon(LF_PCON);
TAssoc_array riclass; TAssoc_array riclass;
for (pcon.first(); pcon.good(); pcon.next()) for (pcon.first(); pcon.good(); pcon.next())
{ {
TString16 key; TString16 key;
TToken_string data; TToken_string data;
key.format("%03d%03d%06ld", pcon.get_int(PCN_GRUPPO), key.format("%03d%03d%06ld", pcon.get_int(PCN_GRUPPO),
pcon.get_int(PCN_CONTO), pcon.get_long(PCN_SOTTOCONTO)); pcon.get_int(PCN_CONTO), pcon.get_long(PCN_SOTTOCONTO));
data.add(pcon.get(PCN_SEZIVD)); data.add(pcon.get(PCN_SEZIVD));
data.add(pcon.get(PCN_LETTIVD)); data.add(pcon.get(PCN_LETTIVD));
data.add(pcon.get(PCN_NUMRIVD)); data.add(pcon.get(PCN_NUMRIVD));
data.add(pcon.get(PCN_NUMIVD)); data.add(pcon.get(PCN_NUMIVD));
data.add(pcon.get(PCN_SEZIVDOPP)); data.add(pcon.get(PCN_SEZIVDOPP));
data.add(pcon.get(PCN_LETTIVDOPP)); data.add(pcon.get(PCN_LETTIVDOPP));
data.add(pcon.get(PCN_NUMRIVDOPP)); data.add(pcon.get(PCN_NUMRIVDOPP));
data.add(pcon.get(PCN_NUMIVDOPP)); data.add(pcon.get(PCN_NUMIVDOPP));
riclass.add(key, data); riclass.add(key, data);
} }
set_firm(to); set_firm(to);
for (pcon.first(); pcon.good(); pcon.next()) for (pcon.first(); pcon.good(); pcon.next())
{ {
TString16 key; TString16 key;
key.format("%03d%03d%06ld", pcon.get_int(PCN_GRUPPO), key.format("%03d%03d%06ld", pcon.get_int(PCN_GRUPPO),
pcon.get_int(PCN_CONTO), pcon.get_long(PCN_SOTTOCONTO)); pcon.get_int(PCN_CONTO), pcon.get_long(PCN_SOTTOCONTO));
TToken_string * data = (TToken_string *) riclass.objptr(key); TToken_string * data = (TToken_string *) riclass.objptr(key);
if (data == NULL) if (data == NULL)
{ {
pcon.put(PCN_SEZIVD, "0"); pcon.put(PCN_SEZIVD, "0");
pcon.zero(PCN_LETTIVD); pcon.zero(PCN_LETTIVD);
pcon.zero(PCN_NUMRIVD); pcon.zero(PCN_NUMRIVD);
pcon.zero(PCN_NUMIVD); pcon.zero(PCN_NUMIVD);
pcon.put(PCN_SEZIVDOPP, "0"); pcon.put(PCN_SEZIVDOPP, "0");
pcon.zero(PCN_LETTIVDOPP); pcon.zero(PCN_LETTIVDOPP);
pcon.zero(PCN_NUMRIVDOPP); pcon.zero(PCN_NUMRIVDOPP);
pcon.zero(PCN_NUMIVDOPP); pcon.zero(PCN_NUMIVDOPP);
} }
else else
{ {
pcon.put(PCN_SEZIVD, data->get(0)); pcon.put(PCN_SEZIVD, data->get(0));
pcon.put(PCN_LETTIVD, data->get()); pcon.put(PCN_LETTIVD, data->get());
pcon.put(PCN_NUMRIVD, data->get()); pcon.put(PCN_NUMRIVD, data->get());
pcon.put(PCN_NUMIVD, data->get()); pcon.put(PCN_NUMIVD, data->get());
pcon.put(PCN_SEZIVDOPP, data->get()); pcon.put(PCN_SEZIVDOPP, data->get());
pcon.put(PCN_LETTIVDOPP, data->get()); pcon.put(PCN_LETTIVDOPP, data->get());
pcon.put(PCN_NUMRIVDOPP, data->get()); pcon.put(PCN_NUMRIVDOPP, data->get());
pcon.put(PCN_NUMIVDOPP, data->get()); pcon.put(PCN_NUMIVDOPP, data->get());
} }
pcon.rewrite(); pcon.rewrite();
} }
} }
bool TCopia_archivi::create() bool TCopia_archivi::create()
{ {
_msk = new TMask("cg4200a") ; _msk = new TMask("cg4200a") ;
_default_firm = get_firm(); _default_firm = get_firm();
dispatch_e_menu(BAR_ITEM(1)); dispatch_e_menu(BAR_ITEM(1));
return TRUE; return TRUE;
} }
bool TCopia_archivi::destroy() bool TCopia_archivi::destroy()
{ {
if (_msk != NULL) delete _msk; if (_msk != NULL) delete _msk;
return TRUE; return TRUE;
} }
bool TCopia_archivi::menu(MENU_TAG) bool TCopia_archivi::menu(MENU_TAG)
{ {
while (_msk->run() == K_ENTER) while (_msk->run() == K_ENTER)
{ {
const long from_firm = _msk->get_long(F_FROMFIRM); const long from_firm = _msk->get_long(F_FROMFIRM);
const long to_firm = _msk->get_long(F_TOFIRM); const long to_firm = _msk->get_long(F_TOFIRM);
const bool copy_pcon = _msk->get_bool(F_PCON); const bool copy_pcon = _msk->get_bool(F_PCON);
const bool copy_causali = _msk->get_bool(F_CAUS); const bool copy_causali = _msk->get_bool(F_CAUS);
const bool copy_clifo = _msk->get_bool(F_CLIFO); const bool copy_clifo = _msk->get_bool(F_CLIFO);
const bool copy_ivd = _msk->get_bool(F_IVD); const bool copy_ivd = _msk->get_bool(F_IVD);
if (copy_pcon || copy_causali || copy_clifo || copy_ivd) if (copy_pcon || copy_causali || copy_clifo || copy_ivd)
{ {
if (prefhndl->exist(to_firm)) if (prefhndl->exist(to_firm))
{ {
set_firm(to_firm); set_firm(to_firm);
TLocalisamfile mov(LF_MOV); TLocalisamfile mov(LF_MOV);
if ((mov.eod() == 0) || (!copy_pcon && !copy_causali && !copy_clifo)) if ((mov.eod() == 0) || (!copy_pcon && !copy_causali && !copy_clifo))
{ {
TString mess("Attenzione "); TString mess("Attenzione \n");
int count = 0; int count = 0;
if (copy_pcon) if (copy_pcon)
{ {
mess << "il piano dei conti"; mess << "il piano dei conti";
count++; count++;
} }
if (copy_causali) if (copy_causali)
{ {
if (count > 0) mess << ","; if (count > 0) mess << ",\n";
mess << " le causali"; mess << " le causali";
count++; count++;
} }
if (copy_clifo) if (copy_clifo)
{ {
if (count > 0) mess << ","; if (count > 0) mess << ",\n";
mess << " i clienti e fornitori"; mess << " i clienti e fornitori";
count++; count++;
} }
if (copy_ivd) if (copy_ivd)
{ {
if (count > 0) mess << ","; if (count > 0) mess << ",\n";
mess << " la riclassificazione IV direttiva"; mess << " la riclassificazione IV direttiva";
count++; count++;
} }
mess << " della ditta " << to_firm; mess << "\n della ditta " << to_firm;
if (count > 1) if (count > 1)
mess << " saranno sovrascritti"; mess << " saranno sovrascritti";
else else
mess << " sara' sovrascritto"; mess << " sara' sovrascritto";
mess << ". Devo continuare"; mess << ". Devo continuare";
if (yesno_box((const char *) mess)) if (yesno_box((const char *) mess))
{ {
if (copy_pcon) mess.rtrim(16); mess << " Devo veramente continuare";
{ if (yesno_box((const char *) mess))
if (copyfile(LF_PCON, from_firm, to_firm) && !copy_ivd) {
clearivd(to_firm); if (copy_pcon)
} {
if (copy_causali) if (copyfile(LF_PCON, from_firm, to_firm) && !copy_ivd)
{ clearivd(to_firm);
if (copyfile(LF_CAUSALI, from_firm, to_firm)) }
copyfile(LF_RCAUSALI, from_firm, to_firm); if (copy_causali)
} {
if (copy_clifo) if (copyfile(LF_CAUSALI, from_firm, to_firm))
copyfile(LF_CLIFO, from_firm, to_firm); copyfile(LF_RCAUSALI, from_firm, to_firm);
if (!copy_pcon && copy_ivd) }
copyivd(from_firm, to_firm); if (copy_clifo)
} copyfile(LF_CLIFO, from_firm, to_firm);
} if (!copy_pcon && copy_ivd)
else error_box("La copia si puo' effettuare solo se non sono stati registrati movimenti"); copyivd(from_firm, to_firm);
set_firm(_default_firm); }
} }
else error_box("Gli archivi della ditta %d non sono stati ancora generati",to_firm); }
_msk->reset(); else error_box("La copia si puo' effettuare solo se non sono stati registrati movimenti");
} set_firm(_default_firm);
} }
return FALSE; else error_box("Gli archivi della ditta %d non sono stati ancora generati",to_firm);
} _msk->reset();
}
int cg4200(int argc, char* argv[]) }
{ return FALSE;
TCopia_archivi a ; }
a.run(argc, argv, "Copia archivi");
return 0; int cg4200(int argc, char* argv[])
} {
TCopia_archivi a ;
a.run(argc, argv, "Copia archivi");
return 0;
}