Aggiunta personalizzazione per istituto suore.
git-svn-id: svn://10.65.10.50/trunk@4296 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
14bc9c7e69
commit
bdd6fcc3a3
18
cg/cgp0.cpp
Executable file
18
cg/cgp0.cpp
Executable file
@ -0,0 +1,18 @@
|
||||
#include <xvt.h>
|
||||
#include <checks.h>
|
||||
|
||||
#include "cgp0.h"
|
||||
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
const int n = (argc > 1) ? atoi(&argv[1][1]) : 0;
|
||||
|
||||
switch(n)
|
||||
{
|
||||
case 0:
|
||||
cgp0100(argc, argv); break;
|
||||
default:
|
||||
error_box("Usage: cgp0 -0");break;
|
||||
}
|
||||
return 0;
|
||||
}
|
6
cg/cgp0.h
Executable file
6
cg/cgp0.h
Executable file
@ -0,0 +1,6 @@
|
||||
#ifndef __CGP0_H
|
||||
#define __CGP0_H
|
||||
|
||||
int cgp0100(int argc, char** argv);
|
||||
|
||||
#endif // __CGP0_H
|
3
cg/cgp0.mnu
Executable file
3
cg/cgp0.mnu
Executable file
@ -0,0 +1,3 @@
|
||||
0|Personalizzazioni|400|F,7
|
||||
400|Personalizzazioni|400
|
||||
400|Liquidazione riepilogativa IVA|cgp0 -0
|
13
cg/cgp0.url
Executable file
13
cg/cgp0.url
Executable file
@ -0,0 +1,13 @@
|
||||
#include <default.url>
|
||||
|
||||
/* cgp0 -0 Programma personalizzato per Istituto Suore */
|
||||
|
||||
MENU TASK_MENUBAR
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
MENUBAR MENU_BAR(1)
|
||||
|
||||
MENU MENU_BAR(1)
|
||||
SUBMENU MENU_FILE "~File"
|
||||
|
||||
|
424
cg/cgp0100.cpp
Executable file
424
cg/cgp0100.cpp
Executable file
@ -0,0 +1,424 @@
|
||||
// cgp0100.cpp Programma personalizzato per Istituto Suore: Liquidazione riepilogativa IVA
|
||||
// Che cosa fa:
|
||||
// prende un serie di codici ditta in input, piu' un anno ed un mese (da 1 a 13)
|
||||
// e copia tutti i movimenti (mov, rmoviva) in una unica ditta ricevente.
|
||||
// (il mese 13 copia tutti i movimenti dell'anno).
|
||||
|
||||
#include <applicat.h>
|
||||
#include <tabutil.h>
|
||||
#include <mask.h>
|
||||
#include <sheet.h>
|
||||
#include <prefix.h>
|
||||
#include <relation.h>
|
||||
#include <progind.h>
|
||||
#include <urldefid.h>
|
||||
#include <nditte.h>
|
||||
#include <mov.h>
|
||||
#include <rmoviva.h>
|
||||
#include "cgp0100a.h"
|
||||
|
||||
// La parte di selezione delle ditte e' tratta dal programma di liquidazione IVA (cg4300.cpp)
|
||||
class TCopia_movimenti : public TApplication
|
||||
{
|
||||
TArray_sheet *_ditte; // Array sheet delle ditte selezionabili
|
||||
TLocalisamfile *_nditte; // File delle ditte
|
||||
TTable *_lia; // Tabella LIA per controllare i parametri liquidazione
|
||||
long _rcv_firm, // Ditta ricevente
|
||||
_firm; // Ditta iniziale, da ripristinare alla fine di tutto
|
||||
int _anno; // Anno da copiare
|
||||
int _mese; // Mese da copiare (13 == tutti)
|
||||
protected:
|
||||
virtual bool menu(MENU_TAG) ;
|
||||
static bool fr_ditt_handler(TMask_field& f, KEY key);
|
||||
static bool to_ditt_handler(TMask_field& f, KEY key);
|
||||
static bool select_button (TMask_field& f, KEY key);
|
||||
static bool reset_button (TMask_field& f, KEY key);
|
||||
static bool firm_handler (TMask_field& f, KEY key);
|
||||
static TCopia_movimenti& app() { return (TCopia_movimenti&)main_app(); }
|
||||
|
||||
public:
|
||||
virtual bool create();
|
||||
virtual bool destroy();
|
||||
TArray_sheet* get_ditte_sheet() { return _ditte; }
|
||||
bool look_lia(long codditta, int anno);
|
||||
long select_firm_range(long from, long to);
|
||||
void build_ditte_sheet();
|
||||
void reset_choices(TMask&);
|
||||
void set_choice_limits(TMask&);
|
||||
void copia_mov();
|
||||
|
||||
TCopia_movimenti() {};
|
||||
virtual ~TCopia_movimenti() {};
|
||||
};
|
||||
|
||||
bool TCopia_movimenti::look_lia(long ditta, int year)
|
||||
{
|
||||
if (year == 0) year = _anno;
|
||||
if (ditta == 0l) ditta = get_firm();
|
||||
TString16 y; y.format("%05ld%04d", ditta, year);
|
||||
|
||||
_lia->zero();
|
||||
_lia->put("CODTAB", y);
|
||||
_lia->read();
|
||||
return _lia->good();
|
||||
}
|
||||
|
||||
bool TCopia_movimenti::firm_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (k == K_ENTER && f.to_check(k))
|
||||
{
|
||||
const long codditta = atol(f.get());
|
||||
const int anno = f.mask().get_int(F_ANNO);
|
||||
if (!prefix().exist(codditta))
|
||||
return f.error_box("La ditta specificata non e' abilitata in contabilita'.");
|
||||
if (!app().look_lia(codditta,anno))
|
||||
return f.error_box("Non esistono i parametri di liquidazione per la ditta specificata.");
|
||||
}
|
||||
if (k == K_TAB && f.to_check(k))
|
||||
{
|
||||
const long codditta = atol(f.get());
|
||||
TArray_sheet* s = app()._ditte;
|
||||
const long items = s->items();
|
||||
for (long j=0;j<items;j++)
|
||||
{
|
||||
const long ditta = s->row(j).get_long(1);
|
||||
if (ditta == codditta)
|
||||
{
|
||||
s->uncheck(j);
|
||||
s->disable_row(j);
|
||||
}
|
||||
else
|
||||
if (ditta == app()._rcv_firm)
|
||||
s->enable_row(j);
|
||||
}
|
||||
app()._rcv_firm = codditta;
|
||||
app().set_choice_limits(f.mask());
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TCopia_movimenti::to_ditt_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
if (key == K_F9)
|
||||
{
|
||||
TArray_sheet* sh = app().get_ditte_sheet();
|
||||
|
||||
sh->disable_check();
|
||||
sh->disable(DLG_USER);
|
||||
if (sh->run() == K_ENTER)
|
||||
{
|
||||
app().select_firm_range(m.get_long(F_DFR),sh->row(sh->selected()).get_long(1));
|
||||
app().set_choice_limits(m);
|
||||
}
|
||||
sh->enable(DLG_USER);
|
||||
}
|
||||
if (key == K_TAB && f.focusdirty())
|
||||
{
|
||||
const long l = app().select_firm_range(m.get_long(F_DFR), m.get_long(F_DTO));
|
||||
app().set_choice_limits(m);
|
||||
m.set(F_SELECTED, l);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TCopia_movimenti::fr_ditt_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
if (key == K_F9)
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
TArray_sheet* sh = app().get_ditte_sheet();
|
||||
|
||||
sh->disable_check();
|
||||
sh->disable(DLG_USER);
|
||||
if (sh->run() == K_ENTER)
|
||||
{
|
||||
app().select_firm_range(sh->row(sh->selected()).get_long(1), m.get_long(F_DTO));
|
||||
app().set_choice_limits(m);
|
||||
}
|
||||
sh->enable(DLG_USER);
|
||||
}
|
||||
else if (key == K_TAB && f.focusdirty())
|
||||
{
|
||||
const long l = app().select_firm_range(m.get_long(F_DFR), m.get_long(F_DTO));
|
||||
app().set_choice_limits(m);
|
||||
m.set(F_SELECTED, l);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TCopia_movimenti::set_choice_limits(TMask& m)
|
||||
{
|
||||
long first = -1l, last = -1l;
|
||||
const long items = _ditte->items();
|
||||
for (long i = 0; i < items; i++)
|
||||
{
|
||||
if (_ditte->checked(i))
|
||||
{
|
||||
const long dit = _ditte->row(i).get_long(1);
|
||||
if (first == -1l) first = dit;
|
||||
if (last < dit) last = dit;
|
||||
}
|
||||
}
|
||||
if (first != -1) m.set(F_DFR, first);
|
||||
if (last != -1) m.set(F_DTO, last);
|
||||
m.set(F_SELECTED, _ditte->checked());
|
||||
}
|
||||
|
||||
void TCopia_movimenti::reset_choices(TMask& m)
|
||||
{
|
||||
m.reset(F_SELECTED);
|
||||
m.reset(F_DFR);
|
||||
m.reset(F_DTO);
|
||||
_ditte->check(-1, FALSE);
|
||||
}
|
||||
|
||||
long TCopia_movimenti::select_firm_range(long from, long to)
|
||||
{
|
||||
if (to == 0l) to = 99999L;
|
||||
const long items = _ditte->items();
|
||||
for (long i = 0; i < items; i++)
|
||||
{
|
||||
if (_ditte->row_disabled(i))
|
||||
continue;
|
||||
|
||||
const long cod = _ditte->row(i).get_long(1);
|
||||
if (cod >= from && cod <= to)
|
||||
_ditte->check(i);
|
||||
else
|
||||
_ditte->uncheck(i);
|
||||
}
|
||||
return _ditte->checked();
|
||||
}
|
||||
|
||||
void TCopia_movimenti::build_ditte_sheet()
|
||||
{
|
||||
// ricostruisce l'array_sheet delle ditte slezionabili
|
||||
_ditte->destroy();
|
||||
TLocalisamfile& dt = *_nditte;
|
||||
|
||||
for (dt.first(); !dt.eof(); dt.next())
|
||||
{
|
||||
TToken_string* d = new TToken_string(64);
|
||||
d->add(" ");
|
||||
d->add(dt.get(NDT_CODDITTA));
|
||||
d->add(dt.get(NDT_RAGSOC));
|
||||
const long pos = _ditte->add(d);
|
||||
if (prefix().exist(dt.get_long(NDT_CODDITTA)))
|
||||
_ditte->enable_row(pos);
|
||||
else
|
||||
_ditte->disable_row(pos);
|
||||
}
|
||||
}
|
||||
|
||||
bool TCopia_movimenti::select_button(TMask_field& f, KEY key)
|
||||
{
|
||||
if (key == K_SPACE)
|
||||
{
|
||||
app()._ditte->enable_check();
|
||||
// seleziona e aggiungi alle gia' selezionate
|
||||
if (app()._ditte->run() == K_ENTER)
|
||||
app().set_choice_limits(f.mask());
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TCopia_movimenti::reset_button(TMask_field& f, KEY key)
|
||||
{
|
||||
if (key == K_SPACE)
|
||||
app().reset_choices(f.mask());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TCopia_movimenti::menu(MENU_TAG m)
|
||||
{
|
||||
TMask msk("cgp0100a");
|
||||
msk.set_handler(F_DFR, fr_ditt_handler);
|
||||
msk.set_handler(F_DTO, to_ditt_handler);
|
||||
msk.set_handler(F_RCVFIRM, firm_handler);
|
||||
msk.set_handler(FBUT_SELECT,select_button);
|
||||
msk.set_handler(FBUT_RESET,reset_button);
|
||||
KEY k;
|
||||
do
|
||||
{
|
||||
k = msk.run();
|
||||
if (k == K_ENTER)
|
||||
{
|
||||
if (msk.get_int(F_SELECTED) == 0)
|
||||
{
|
||||
error_box("Selezionare le ditte invianti.");
|
||||
continue;
|
||||
}
|
||||
_anno = msk.get_int(F_ANNO);
|
||||
_mese = msk.get_int(F_MESE);
|
||||
_rcv_firm = msk.get_long(F_RCVFIRM);
|
||||
copia_mov();
|
||||
message_box("Copia movimenti completata.");
|
||||
}
|
||||
} while(k == K_ENTER);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void TCopia_movimenti::copia_mov()
|
||||
{
|
||||
TFilename t1,t2;
|
||||
t1.tempdir();
|
||||
t1.insert("%");
|
||||
t2 = t1;
|
||||
t1 << "/tmov";
|
||||
t2 << "/trmoviva";
|
||||
|
||||
long numreg = 0L; // numero di registrazione progressivo
|
||||
long count = 0L; // numero di items (mov+rmoviva) totali
|
||||
TIsamtempfile tmov(LF_MOV,t1,TRUE);
|
||||
TIsamtempfile trmoviva(LF_RMOVIVA,t2,TRUE);
|
||||
tmov.set_autodel();
|
||||
trmoviva.set_autodel();
|
||||
int err=NOERR;
|
||||
{
|
||||
TLocalisamfile m(LF_MOV); // necessario per allocare i records
|
||||
TRectype from(LF_MOV),to(LF_MOV);
|
||||
TDate inizio(1,_mese == 13 ? 1 : _mese,_anno);
|
||||
TDate fine(inizio);
|
||||
|
||||
if (_mese == 13) fine.set_month(12);
|
||||
fine.set_end_month();
|
||||
from.put(MOV_DATAREG,inizio);
|
||||
to.put(MOV_DATAREG,fine);
|
||||
TRelation rel(LF_MOV);
|
||||
rel.add(LF_RMOVIVA,"NUMREG=NUMREG");
|
||||
TCursor cur(&rel,"",2,&from,&to);
|
||||
|
||||
const long items = _ditte->items();
|
||||
|
||||
TProgind p(items,"Copia movimenti ditte...", FALSE,TRUE);
|
||||
TString msg;
|
||||
|
||||
for (long i=0; i<items && err == NOERR; i++) // ciclo sulle ditte selezionate
|
||||
if (_ditte->checked(i))
|
||||
{
|
||||
const long codditta = _ditte->row(i).get_long(1);
|
||||
set_firm(codditta);
|
||||
msg.format("Copia movimenti ditta %ld in corso...",codditta);
|
||||
p.setstatus(i);
|
||||
p.set_text(msg);
|
||||
const TRecnotype recs = cur.items();
|
||||
for (TRecnotype j=0; j<recs && err==NOERR;j++)
|
||||
{
|
||||
cur = j;
|
||||
if (cur.is_first_match(LF_RMOVIVA))
|
||||
{
|
||||
tmov.curr() = cur.curr();
|
||||
const long orig_nreg = tmov.get_long(MOV_NUMREG);
|
||||
tmov.put(MOV_NUMREG,numreg+1);
|
||||
count++;
|
||||
if (tmov.write() != NOERR)
|
||||
{
|
||||
err=tmov.status();
|
||||
error_box("Errore %d in scrittura file temporaneo movimenti. Ditta %ld, movimento %ld.",
|
||||
err,codditta,orig_nreg);
|
||||
break;
|
||||
}
|
||||
do
|
||||
{
|
||||
trmoviva.curr() = cur.curr(LF_RMOVIVA);
|
||||
const int numrig = trmoviva.get_int(RMI_NUMRIG);
|
||||
trmoviva.put(RMI_NUMREG,numreg+1);
|
||||
if (trmoviva.write() != NOERR)
|
||||
{
|
||||
err=trmoviva.status();
|
||||
error_box("Errore %d in scrittura file temporaneo righe iva. Ditta %ld, movimento %ld, riga %d.",
|
||||
err,codditta,orig_nreg, numrig);
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
} while (cur.next_match(LF_RMOVIVA));
|
||||
numreg++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// una volta finita la copia, se non ci sono errori e ci sono record da trasferire
|
||||
// copia i records nella ditta ricevente
|
||||
if (err == NOERR && numreg > 0)
|
||||
{
|
||||
set_firm(_rcv_firm); // setta la ditta ricevente
|
||||
// Zappa i files
|
||||
{
|
||||
TDir d;
|
||||
d.get(LF_MOV);
|
||||
d.eod() = 0L;
|
||||
d.put(LF_MOV);
|
||||
d.get(LF_RMOVIVA);
|
||||
d.eod() = 0L;
|
||||
d.put(LF_RMOVIVA);
|
||||
TSystemisamfile m(LF_MOV),r(LF_RMOVIVA);
|
||||
err = m.pack();
|
||||
if (err == NOERR)
|
||||
err = r.pack();
|
||||
}
|
||||
if (err == NOERR)
|
||||
{
|
||||
TIsamfile mov(LF_MOV,FALSE);
|
||||
TIsamfile rmoviva(LF_RMOVIVA,FALSE);
|
||||
|
||||
err = mov.open(_excllock);
|
||||
if (err == NOERR)
|
||||
err = rmoviva.open(_excllock);
|
||||
if (err == NOERR) // Scrive sui files della ditta ricevente
|
||||
{
|
||||
long j=0L;
|
||||
TProgind p(count,"Trasferimento movimenti...",FALSE,TRUE);
|
||||
for (tmov.first(); tmov.good(); tmov.next())
|
||||
{
|
||||
p.setstatus(j++);
|
||||
mov.write(tmov.curr());
|
||||
}
|
||||
for (trmoviva.first(); trmoviva.good(); trmoviva.next())
|
||||
{
|
||||
p.setstatus(j++);
|
||||
rmoviva.write(trmoviva.curr());
|
||||
}
|
||||
}
|
||||
else
|
||||
error_box("Errore %d tentando di aprire in modo esclusivo i files della ditta ricevente",err);
|
||||
}
|
||||
else
|
||||
error_box("Errore %d azzerando i files della ditta ricevente",err);
|
||||
}
|
||||
|
||||
// Il distruttore di TIsamtempfile rimuove i files temporanei automaticamente
|
||||
// dato che e' stato settato l'apposito flag
|
||||
set_firm(_firm); // ripristina la ditta
|
||||
}
|
||||
|
||||
bool TCopia_movimenti::create()
|
||||
{
|
||||
_ditte = new TArray_sheet(-1, -1, -4, -4, "Selezione Ditte",
|
||||
"@1|Cod.@5R|Ragione Sociale@50");
|
||||
_nditte = new TLocalisamfile(LF_NDITTE);
|
||||
_lia = new TTable("%LIA");
|
||||
_firm = TApplication::get_firm();
|
||||
build_ditte_sheet();
|
||||
dispatch_e_menu (BAR_ITEM(1));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TCopia_movimenti::destroy()
|
||||
{
|
||||
delete _ditte;
|
||||
delete _nditte;
|
||||
delete _lia;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int cgp0100 (int argc, char** argv)
|
||||
{
|
||||
TCopia_movimenti a;
|
||||
a.run(argc,argv,"Liquidazione riepilogativa IVA");
|
||||
return 0;
|
||||
}
|
||||
|
10
cg/cgp0100a.h
Executable file
10
cg/cgp0100a.h
Executable file
@ -0,0 +1,10 @@
|
||||
#define F_DFR 101
|
||||
#define F_DTO 102
|
||||
#define F_SELECTED 103
|
||||
#define FBUT_SELECT 104
|
||||
#define FBUT_RESET 105
|
||||
#define F_MESE 106
|
||||
#define F_ANNO 107
|
||||
#define F_RCVFIRM 108
|
||||
#define F_DESRCVFIRM 109
|
||||
|
91
cg/cgp0100a.uml
Executable file
91
cg/cgp0100a.uml
Executable file
@ -0,0 +1,91 @@
|
||||
#include "cgp0100a.h"
|
||||
|
||||
PAGE "Liquidazione riepilogativa IVA" -1 -1 78 14
|
||||
|
||||
LIST F_MESE 15
|
||||
BEGIN
|
||||
PROMPT 2 1 "Periodo "
|
||||
ITEM "13|Annuale"
|
||||
FLAGS "AM"
|
||||
END
|
||||
|
||||
NUMBER F_ANNO 4
|
||||
BEGIN
|
||||
PROMPT 35 1 "Anno "
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 76 3
|
||||
BEGIN
|
||||
PROMPT 2 3 "Ditta ricevente"
|
||||
END
|
||||
|
||||
NUMBER F_RCVFIRM 5
|
||||
BEGIN
|
||||
PROMPT 3 4 "Codice "
|
||||
USE LF_NDITTE
|
||||
INPUT CODDITTA F_RCVFIRM
|
||||
DISPLAY "Codice" CODDITTA
|
||||
DISPLAY "Ragione sociale@50" RAGSOC
|
||||
OUTPUT F_RCVFIRM CODDITTA
|
||||
OUTPUT F_DESRCVFIRM RAGSOC
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
STRING F_DESRCVFIRM 50
|
||||
BEGIN
|
||||
PROMPT 22 4 ""
|
||||
USE LF_NDITTE KEY 2
|
||||
INPUT RAGSOC F_DESRCVFIRM
|
||||
DISPLAY "Ragione sociale@50" RAGSOC
|
||||
DISPLAY "Codice" CODDITTA
|
||||
COPY OUTPUT F_RCVFIRM
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 40 5
|
||||
BEGIN
|
||||
PROMPT 2 6 "Ditte invianti"
|
||||
END
|
||||
|
||||
NUMBER F_DFR 5
|
||||
BEGIN
|
||||
PROMPT 3 7 "Da codice "
|
||||
FLAGS "B"
|
||||
END
|
||||
|
||||
NUMBER F_DTO 5
|
||||
BEGIN
|
||||
PROMPT 3 8 "A codice "
|
||||
FLAGS "B"
|
||||
END
|
||||
|
||||
STRING F_SELECTED 5
|
||||
BEGIN
|
||||
PROMPT 3 9 "Scelte n. "
|
||||
FLAGS "DR"
|
||||
END
|
||||
|
||||
BUTTON FBUT_SELECT 10 2
|
||||
BEGIN
|
||||
PROMPT 25 7 "~Selezione"
|
||||
PICTURE BMP_SELECT
|
||||
END
|
||||
|
||||
BUTTON FBUT_RESET 10
|
||||
BEGIN
|
||||
PROMPT 25 9 "A~zzera"
|
||||
END
|
||||
|
||||
BUTTON DLG_OK 10 2
|
||||
BEGIN
|
||||
PROMPT -12 -1 ""
|
||||
END
|
||||
|
||||
BUTTON DLG_QUIT 10 2
|
||||
BEGIN
|
||||
PROMPT -22 -1 ""
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
ENDMASK
|
Loading…
x
Reference in New Issue
Block a user