9693095752
git-svn-id: svn://10.65.10.50/trunk@812 c028cbd2-c16b-5b4b-a496-9718f37d4682
334 lines
7.4 KiB
C++
Executable File
334 lines
7.4 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <config.h>
|
|
#include <form.h>
|
|
#include <mask.h>
|
|
#include <relation.h>
|
|
#include <sheet.h>
|
|
#include <tabutil.h>
|
|
#include <utility.h>
|
|
|
|
#include <urldefid.h>
|
|
|
|
#include "cg1400.h"
|
|
|
|
class TStampa_deleghe_IVA : public TApplication
|
|
{
|
|
TLocalisamfile *_nditte, *_anag, *_comuni;
|
|
TTable* _banche;
|
|
|
|
TArray_sheet* _ditte;
|
|
|
|
int _mese, _anno, _tipo;
|
|
TString16 _azienda, _dipendenza;
|
|
TFilename _profilo;
|
|
bool _stampa_distinte, _aggiorna_codici, _stampa_prova;
|
|
|
|
protected:
|
|
virtual bool create();
|
|
virtual bool destroy();
|
|
virtual bool menu(MENU_TAG);
|
|
virtual void print();
|
|
|
|
int select(bool cf);
|
|
bool print_deleghe();
|
|
void print_distinta();
|
|
|
|
public:
|
|
TStampa_deleghe_IVA() : _ditte(NULL) {}
|
|
};
|
|
|
|
|
|
bool TStampa_deleghe_IVA::create()
|
|
{
|
|
TApplication::create();
|
|
|
|
_nditte = new TLocalisamfile(LF_NDITTE);
|
|
_anag = new TLocalisamfile(LF_ANAG);
|
|
_comuni = new TLocalisamfile(LF_COMUNI);
|
|
_banche = new TTable("%BAN");
|
|
|
|
_ditte = new TArray_sheet(-1, -1, 0, 0, "Selezione Deleghe da stampare",
|
|
"@1|Cod.@5|Ragione Sociale@50|Importo@15|Azienda|Dipendenza");
|
|
|
|
TConfig c(CONFIG_STUDIO, "cg");
|
|
_azienda = c.get("CodABI");
|
|
_dipendenza = c.get("CodCAB");
|
|
|
|
dispatch_e_menu(BAR_ITEM(1));
|
|
return TRUE;
|
|
}
|
|
|
|
bool TStampa_deleghe_IVA::destroy()
|
|
{
|
|
delete _ditte;
|
|
|
|
delete _nditte;
|
|
delete _anag;
|
|
delete _comuni;
|
|
delete _banche;
|
|
|
|
return TApplication::destroy();
|
|
}
|
|
|
|
|
|
int TStampa_deleghe_IVA::select(bool cf)
|
|
{
|
|
TMask m(cf ? "cg1400b" : "cg1400a");
|
|
TConfig c(CONFIG_STUDIO, "cg");
|
|
m.set(F_ABI, _azienda);
|
|
m.set(F_CAB, _dipendenza);
|
|
if (m.run() != K_ENTER)
|
|
return 0;
|
|
|
|
_azienda = m.get(F_ABI);
|
|
_dipendenza = m.get(F_CAB);
|
|
|
|
_mese = m.get_int(F_MESE);
|
|
_anno = m.get_int(F_ANNO);
|
|
_tipo = m.get_int(F_TIPO);
|
|
|
|
_stampa_prova = !m.get_bool(F_DEFINITIVA);
|
|
_stampa_distinte = m.get_bool(F_DISTINTA);
|
|
_aggiorna_codici = m.get_bool(F_AGGIORNA);
|
|
|
|
if (m.get_bool(F_CONTOFIS))
|
|
_profilo = m.get(F_PROFILO);
|
|
else
|
|
{
|
|
_profilo = "del";
|
|
_profilo << _azienda;
|
|
}
|
|
const TDate pd(m.get(F_DATA));
|
|
printer().setdate(pd);
|
|
|
|
TLocalisamfile nditte(LF_NDITTE);
|
|
TTable deleghe("%DEL");
|
|
|
|
TString16 chiave;
|
|
TToken_string d(80);
|
|
|
|
_ditte->destroy();
|
|
for (nditte.first(); !nditte.eof(); nditte.next())
|
|
{
|
|
const long dit = nditte.get_long("CODDITTA");
|
|
chiave.format("%05ld", dit);
|
|
chiave << format("%04d%02d%d", _anno, _mese, _tipo);
|
|
deleghe.put("CODTAB", chiave);
|
|
if (deleghe.read() == NOERR && deleghe.get_bool("B0") == FALSE) // Da stampare
|
|
{
|
|
d = " "; // Selezione
|
|
d.add(chiave.left(5)); // Codice ditta
|
|
d.add(nditte.get("RAGSOC")); // Ragione sociale
|
|
|
|
const real importo(deleghe.get("R0"));
|
|
d.add(importo.string(".")); // Importo
|
|
|
|
const long az = deleghe.get_long("I0");
|
|
d.add(format("%05ld", az)); // Azienda
|
|
|
|
const long di = deleghe.get_long("I1");
|
|
d.add(format("%05ld", di)); // Dipendenza
|
|
|
|
_ditte->add(d);
|
|
}
|
|
}
|
|
|
|
if (_ditte->items() > 0)
|
|
{
|
|
const bool ok = _ditte->run() == K_ENTER;
|
|
enable_menu_item(M_FILE_PRINT, ok);
|
|
}
|
|
else
|
|
{
|
|
warning_box("Nessuna ditta ha deleghe da stampare");
|
|
disable_menu_item(M_FILE_PRINT);
|
|
return 2;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
bool TStampa_deleghe_IVA::menu(MENU_TAG mt)
|
|
{
|
|
int s = 0;
|
|
while ((s = select(mt == BAR_ITEM(2))) != 0)
|
|
if (s == 1) print();
|
|
return TRUE;
|
|
}
|
|
|
|
void TStampa_deleghe_IVA::print()
|
|
{
|
|
print_deleghe();
|
|
if (_stampa_distinte)
|
|
{
|
|
const bool ok = yesno_box("Inserire il modulo continuo nella stampante "
|
|
"e confermare la stampa della distinta");
|
|
if (ok) print_distinta();
|
|
}
|
|
}
|
|
|
|
|
|
void TStampa_deleghe_IVA::print_distinta()
|
|
{
|
|
enum Tabulatori { TAB_DITTA = 0, TAB_SEDE = 52, TAB_PROV = 78,
|
|
TAB_IMPORTO = 82, TAB_NOTE = 100 };
|
|
|
|
printer().open();
|
|
|
|
TString16 codban;
|
|
if (_azienda.not_empty())
|
|
{
|
|
codban = _azienda; codban << _dipendenza;
|
|
_banche->put("CODTAB", codban);
|
|
_banche->read();
|
|
}
|
|
|
|
TPrintrow row;
|
|
|
|
if (atol(_azienda))
|
|
row.put(_banche->get("S0"), 0);
|
|
row.put("DISTINTA DELEGHE DI VERSAMENTO", 60);
|
|
row.put("Data @>", 110);
|
|
row.put("Pag.@#", 124);
|
|
printer().setheaderline(0, row);
|
|
|
|
row.reset();
|
|
if (atol(_dipendenza))
|
|
row.put(_banche->get("S1"), 0);
|
|
|
|
TString256 t("Dichiarazione ");
|
|
switch (_tipo)
|
|
{
|
|
case 2:
|
|
t << "annuale : "; break;
|
|
case 7:
|
|
t << "acconti IVA : "; break;
|
|
default:
|
|
t << "periodica : " << _mese << '-'; break;
|
|
}
|
|
t << _anno;
|
|
row.put(t, 60);
|
|
printer().setheaderline(1, row);
|
|
|
|
t.fill('-', 130);
|
|
row.reset();
|
|
row.put(t, 0);
|
|
printer().setheaderline(2, row);
|
|
printer().setheaderline(4, row);
|
|
|
|
row.reset();
|
|
row.put("Ditta", TAB_DITTA);
|
|
row.put("Sede" , TAB_SEDE);
|
|
row.put("Importo", TAB_IMPORTO+8);
|
|
row.put("Note", TAB_NOTE);
|
|
printer().setheaderline(3, row);
|
|
|
|
real totale;
|
|
|
|
for (int i = 0; i < _ditte->items(); i++)
|
|
if (_ditte->checked(i))
|
|
{
|
|
const TString16 cod(_ditte->row(i).get(1));
|
|
_nditte->put("CODDITTA", cod);
|
|
_nditte->read();
|
|
|
|
_anag->put("TIPOA", _nditte->get("TIPOA"));
|
|
_anag->put("CODANAGR", _nditte->get("CODANAGR"));
|
|
_anag->read();
|
|
|
|
_comuni->put("STATO", _anag->get("STATORF"));
|
|
_comuni->put("COM", _anag->get("COMRF"));
|
|
_comuni->read();
|
|
|
|
TParagraph_string dencom(_comuni->get("DENCOM"), 18);
|
|
|
|
row.reset();
|
|
row.put(_nditte->get("RAGSOC"), TAB_DITTA);
|
|
row.put(dencom.get(), TAB_SEDE);
|
|
row.put(_comuni->get("PROVCOM"), TAB_PROV);
|
|
|
|
TString imp(_ditte->row(i).get(3));
|
|
row.put(imp, TAB_IMPORTO);
|
|
printer().print(row);
|
|
|
|
imp.strip(".");
|
|
real importo(imp);
|
|
totale += importo;
|
|
|
|
const char* r;
|
|
while ((r = dencom.get()) != NULL)
|
|
{
|
|
row.reset();
|
|
row.put(r, TAB_SEDE);
|
|
printer().print(row);
|
|
}
|
|
}
|
|
|
|
row.reset();
|
|
printer().print(row);
|
|
row.put("@BTotale versamenti :", TAB_SEDE);
|
|
row.put(totale.string("###.###.###.###"), TAB_IMPORTO);
|
|
printer().print(row);
|
|
|
|
printer().close();
|
|
}
|
|
|
|
bool TStampa_deleghe_IVA::print_deleghe()
|
|
{
|
|
bool ok = printer().open();
|
|
if (!ok) return FALSE;
|
|
|
|
TForm f(_profilo);
|
|
|
|
for (int i = 0; ok && i < _ditte->items(); i++)
|
|
if (_ditte->checked(i))
|
|
{
|
|
const TString16 d(_ditte->row(i).get(1));
|
|
|
|
TRectype& delega = f.cursor()->curr();
|
|
|
|
TString16 chiave;
|
|
chiave = d; chiave << format("%04d%02d%d", _anno, _mese, _tipo);
|
|
delega.put("CODTAB", chiave);
|
|
|
|
f.cursor()->file().read();
|
|
const bool cera = atoi(delega.get("S7")) != 0;
|
|
if (!cera)
|
|
{
|
|
delega.put("S7", _azienda);
|
|
delega.put("S8", _dipendenza);
|
|
f.cursor()->file().rewrite();
|
|
}
|
|
f.cursor()->read(); // Posiziona il cursore
|
|
|
|
ok = f.print(-1); // Stampa solo il record corrente
|
|
if (!ok) break;
|
|
|
|
bool scrivi = _aggiorna_codici && !cera;
|
|
|
|
if (!_stampa_prova)
|
|
{
|
|
delega.put("B0", "X"); // Stampato
|
|
scrivi = TRUE;
|
|
}
|
|
if (!_aggiorna_codici && !cera) // Cancella codice se non richiesto
|
|
{
|
|
delega.put("S7", "");
|
|
delega.put("S8", "");
|
|
scrivi = TRUE;
|
|
}
|
|
if (scrivi)
|
|
f.cursor()->file().rewrite();
|
|
}
|
|
printer().close();
|
|
|
|
return ok;
|
|
}
|
|
|
|
|
|
int cg1400(int argc, char* argv[])
|
|
{
|
|
TStampa_deleghe_IVA a;
|
|
a.run(argc, argv, "Stampa Deleghe IVA");
|
|
return 0;
|
|
}
|