Errore MI4310

git-svn-id: svn://10.65.10.50/trunk@3556 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1996-09-09 13:29:15 +00:00
parent e2556e6d78
commit 6fdf2fd7f4

View File

@ -1,7 +1,7 @@
#include <applicat.h> #include <applicat.h>
#include <config.h> #include <config.h>
#include <form.h> #include <form.h>
#include <mask.h> #include <mask.h>
#include <printer.h> #include <printer.h>
#include <relation.h> #include <relation.h>
#include <sheet.h> #include <sheet.h>
@ -26,7 +26,7 @@ class TStampa_deleghe_IVA : public TApplication
bool _stampa_distinte, _aggiorna_codici, _definitiva; bool _stampa_distinte, _aggiorna_codici, _definitiva;
TDate _pd; TDate _pd;
protected: protected:
virtual bool create(); virtual bool create();
virtual bool destroy(); virtual bool destroy();
@ -50,15 +50,15 @@ bool TStampa_deleghe_IVA::create()
_nditte = new TRelation(LF_NDITTE); _nditte = new TRelation(LF_NDITTE);
_nditte->add(LF_ANAG, "TIPOA=TIPOA|CODANAGR=CODANAGR"); _nditte->add(LF_ANAG, "TIPOA=TIPOA|CODANAGR=CODANAGR");
_nditte->add(LF_COMUNI, "COM=COMRF(COMRES)", 1, LF_ANAG); _nditte->add(LF_COMUNI, "COM=COMRF(COMRES)", 1, LF_ANAG);
_banche = new TTable("%BAN"); _banche = new TTable("%BAN");
_ditte = new TArray_sheet(-1, -1, -4, -4, "Selezione Deleghe da stampare", _ditte = new TArray_sheet(-1, -1, -4, -4, "Selezione Deleghe da stampare",
"@1|Cod.@5|Ragione Sociale@30|Importo@15r|Interessi@15r|ABI@5|CAB@5|Concessione|Tit. Conto Fis."); "@1|Cod.@5|Ragione Sociale@30|Importo@15R|Interessi@15R|ABI@5|CAB@5|Concessione|Tit. Conto Fis.");
_azienda = "" ; _azienda = "" ;
_dipendenza = "" ; _dipendenza = "" ;
dispatch_e_menu(BAR_ITEM(1)); dispatch_e_menu(BAR_ITEM(1));
return TRUE; return TRUE;
} }
@ -79,9 +79,9 @@ int TStampa_deleghe_IVA::select()
m.set(F_CONCESSIONE, _concessione); m.set(F_CONCESSIONE, _concessione);
m.set(F_ABI, _azienda); m.set(F_ABI, _azienda);
m.set(F_CAB, _dipendenza); m.set(F_CAB, _dipendenza);
if (m.run() != K_ENTER) if (m.run() != K_ENTER)
return 0; return 0;
_azienda = m.get(F_ABI); _azienda = m.get(F_ABI);
_dipendenza = m.get(F_CAB); _dipendenza = m.get(F_CAB);
@ -92,21 +92,21 @@ int TStampa_deleghe_IVA::select()
_definitiva = m.get_bool(F_DEFINITIVA); _definitiva = m.get_bool(F_DEFINITIVA);
_stampa_distinte = m.get_bool(F_DISTINTA); _stampa_distinte = m.get_bool(F_DISTINTA);
_aggiorna_codici = m.get_bool(F_AGGIORNA); _aggiorna_codici = m.get_bool(F_AGGIORNA);
_profilo = m.get(F_PROFILO); _profilo = m.get(F_PROFILO);
_codice = m.get_long(F_CODICE); _codice = m.get_long(F_CODICE);
const bool contofis = _profilo.right(2) == "CF"; const bool contofis = _profilo.right(2) == "CF";
int del_dis_bol=0; int del_dis_bol=0;
if (_profilo.left(3) == "DIS") del_dis_bol = 2; if (_profilo.left(3) == "DIS") del_dis_bol = 2;
else else
if (_profilo.left(3) == "BOL") del_dis_bol = 1; if (_profilo.left(3) == "BOL") del_dis_bol = 1;
//const TDate pd(m.get(F_DATA)); //const TDate pd(m.get(F_DATA));
//printer().setdate(pd); //printer().setdate(pd);
_pd = m.get(F_DATA); _pd = m.get(F_DATA);
printer().setdate(_pd); printer().setdate(_pd);
_concessione = m.get(F_CONCESSIONE); _concessione = m.get(F_CONCESSIONE);
const long soloabi = m.get_long(F_SOLO_ABI); const long soloabi = m.get_long(F_SOLO_ABI);
const long solocab = m.get_long(F_SOLO_CAB); const long solocab = m.get_long(F_SOLO_CAB);
@ -122,16 +122,16 @@ int TStampa_deleghe_IVA::select()
{ {
TLocalisamfile& anag = _nditte->lfile(LF_ANAG); TLocalisamfile& anag = _nditte->lfile(LF_ANAG);
TLocalisamfile& com = _nditte->lfile(LF_COMUNI); // Comune residenza fiscale TLocalisamfile& com = _nditte->lfile(LF_COMUNI); // Comune residenza fiscale
const TString16 con = com.get("UFFCONC"); const TString16 con = com.get("UFFCONC");
if (_concessione.not_empty() && _concessione != con) continue; if (_concessione.not_empty() && _concessione != con) continue;
const bool cf = anag.get_bool("TITCF"); const bool cf = anag.get_bool("TITCF");
if (contofis != cf) continue; if (contofis != cf) continue;
const int tstdel = anag.get_int("TIPOSTDEL"); const int tstdel = anag.get_int("TIPOSTDEL");
if (tstdel != del_dis_bol) continue; if (tstdel != del_dis_bol) continue;
const long dit = _nditte->lfile().get_long("CODDITTA"); const long dit = _nditte->lfile().get_long("CODDITTA");
chiave.format("%05ld%04d%02d%d", dit, _anno, _mese, _tipo); chiave.format("%05ld%04d%02d%d", dit, _anno, _mese, _tipo);
deleghe.put("CODTAB", chiave); deleghe.put("CODTAB", chiave);
@ -141,7 +141,7 @@ int TStampa_deleghe_IVA::select()
const long abi = deleghe.get_long("S7"); const long abi = deleghe.get_long("S7");
const long cab = deleghe.get_long("S8"); const long cab = deleghe.get_long("S8");
if ((soloabi == 0 || soloabi == abi) && (solocab == 0 || solocab == cab)) if ((soloabi == 0 || soloabi == abi) && (solocab == 0 || solocab == cab))
{ {
d = " "; // Selezione d = " "; // Selezione
d.add(dit); // Codice ditta d.add(dit); // Codice ditta
d.add(_nditte->lfile().get("RAGSOC").left(30)); // Cognome d.add(_nditte->lfile().get("RAGSOC").left(30)); // Cognome
@ -152,23 +152,23 @@ int TStampa_deleghe_IVA::select()
d.add(con); // Concessione d.add(con); // Concessione
d.add(cf ? "X" : " "); // Conto fiscale d.add(cf ? "X" : " "); // Conto fiscale
_ditte->add(d); _ditte->add(d);
} }
} }
} }
end_wait(); end_wait();
int res = 1; int res = 1;
if (_ditte->items() > 0) if (_ditte->items() > 0)
{ {
const bool ok = _ditte->run() == K_ENTER && _ditte->one_checked(); const bool ok = _ditte->run() == K_ENTER && _ditte->one_checked();
if (!ok) res = 2; if (!ok) res = 2;
} }
else else
{ {
warning_box("Nessuna ditta ha deleghe del tipo specificato"); warning_box("Nessuna ditta ha deleghe del tipo specificato");
res = 2; res = 2;
} }
enable_menu_item(M_FILE_PRINT, res == 1); enable_menu_item(M_FILE_PRINT, res == 1);
return res; return res;
} }
@ -185,7 +185,7 @@ void TStampa_deleghe_IVA::print()
{ {
bool ok = yesno_box("Inserire il modulo prefincato nella stampante " bool ok = yesno_box("Inserire il modulo prefincato nella stampante "
"e confermare la stampa delle deleghe"); "e confermare la stampa delle deleghe");
if (ok) if (ok)
{ {
print_deleghe(); print_deleghe();
if (_stampa_distinte) if (_stampa_distinte)
@ -193,7 +193,7 @@ void TStampa_deleghe_IVA::print()
ok = yesno_box("Inserire il modulo in carta bianca nella stampante " ok = yesno_box("Inserire il modulo in carta bianca nella stampante "
"e confermare la stampa della distinta"); "e confermare la stampa della distinta");
if (ok) print_distinta(); if (ok) print_distinta();
} }
} }
} }
@ -229,15 +229,15 @@ void TStampa_deleghe_IVA::print_distinta()
TString256 t("Dichiarazione "); TString256 t("Dichiarazione ");
switch (_tipo) switch (_tipo)
{ {
case 2: case 2:
t << "annuale :"; break; t << "annuale :"; break;
case 3: case 3:
t << "articolo 74 : " << itom(_mese); break; t << "articolo 74 : " << itom(_mese); break;
case 4: case 4:
t << "cessazione attivita' : " << itom(_mese); break; t << "cessazione attivita' : " << itom(_mese); break;
case 5: case 5:
t << "integrativa : " << itom(_mese); break; t << "integrativa : " << itom(_mese); break;
default: default:
t << "periodica : " << itom(_mese); break; t << "periodica : " << itom(_mese); break;
} }
t << ' ' << _anno; t << ' ' << _anno;
@ -263,11 +263,11 @@ void TStampa_deleghe_IVA::print_distinta()
for (int i = 0; i < _ditte->items(); i++) for (int i = 0; i < _ditte->items(); i++)
if (_ditte->checked(i)) if (_ditte->checked(i))
{ {
TToken_string& riga = _ditte->row(i); TToken_string& riga = _ditte->row(i);
const TString16 cod(riga.get(1)); const TString16 cod(riga.get(1));
_nditte->lfile().put("CODDITTA", cod); _nditte->lfile().put("CODDITTA", cod);
_nditte->read(); _nditte->read();
TParagraph_string dencom(com.get("DENCOM"), 18); TParagraph_string dencom(com.get("DENCOM"), 18);
@ -303,25 +303,25 @@ void TStampa_deleghe_IVA::print_distinta()
// Calcola frequenza dei versamenti IVA di una ditta // Calcola frequenza dei versamenti IVA di una ditta
// Certified 99% // Certified 99%
char TStampa_deleghe_IVA::frequenza_versamenti(long firm, int year) const char TStampa_deleghe_IVA::frequenza_versamenti(long firm, int year) const
{ {
char freq = 'M'; char freq = 'M';
TString16 key; key.format("%05ld%d", firm, year); TString16 key; key.format("%05ld%d", firm, year);
TTable lia("%LIA"); TTable lia("%LIA");
lia.put("CODTAB", key); lia.put("CODTAB", key);
if (lia.read() != NOERR) if (lia.read() != NOERR)
{ {
TLocalisamfile nditte(LF_NDITTE); TLocalisamfile nditte(LF_NDITTE);
nditte.put("CODDITTA", firm); nditte.put("CODDITTA", firm);
nditte.read(); nditte.read();
freq = nditte.get_char("FREQVIVA"); freq = nditte.get_char("FREQVIVA");
} }
else else
freq = lia.get_char("S7"); freq = lia.get_char("S7");
CHECK(freq == 'M' || freq == 'T', "Frequenza versamenti IVA assurda"); CHECK(freq == 'M' || freq == 'T', "Frequenza versamenti IVA assurda");
return freq; return freq;
} }
bool TStampa_deleghe_IVA::print_deleghe() bool TStampa_deleghe_IVA::print_deleghe()
@ -332,11 +332,11 @@ bool TStampa_deleghe_IVA::print_deleghe()
TCursor& cur = *f.cursor(); TCursor& cur = *f.cursor();
TLocalisamfile& delega = cur.file(); TLocalisamfile& delega = cur.file();
TString16 chiave; TString16 chiave;
for (int i = 0; ok && i < _ditte->items(); i++) for (int i = 0; ok && i < _ditte->items(); i++)
if (_ditte->checked(i)) if (_ditte->checked(i))
{ {
TToken_string& r = _ditte->row(i); TToken_string& r = _ditte->row(i);
const long firm = r.get_long(1); const long firm = r.get_long(1);
@ -344,10 +344,10 @@ bool TStampa_deleghe_IVA::print_deleghe()
delega.put("CODTAB", chiave); delega.put("CODTAB", chiave);
cur.read(); // Posiziona il cursore cur.read(); // Posiziona il cursore
if (_pd.ok()) if (_pd.ok())
delega.put("D0",_pd); delega.put("D0",_pd);
const bool cera_abi = _azienda.empty() || _dipendenza.empty(); const bool cera_abi = _azienda.empty() || _dipendenza.empty();
if (!cera_abi) if (!cera_abi)
{ {
@ -359,19 +359,19 @@ bool TStampa_deleghe_IVA::print_deleghe()
const bool cera_conc = (*r.get(7) <= ' ') || delega.get("S9").not_empty(); const bool cera_conc = (*r.get(7) <= ' ') || delega.get("S9").not_empty();
if (!cera_conc) if (!cera_conc)
delega.put("S9", r.get(7)); // Concessione delega.put("S9", r.get(7)); // Concessione
const bool cera_tribu = delega.get("S6").not_empty(); const bool cera_tribu = delega.get("S6").not_empty();
if (!cera_tribu) // Metti codice tributo if (!cera_tribu) // Metti codice tributo
{ {
TString16 tributo; TString16 tributo;
switch(_tipo) switch(_tipo)
{ {
case 1: case 1:
if (frequenza_versamenti(firm, _anno) == 'T') if (frequenza_versamenti(firm, _anno) == 'T')
tributo << "603" << ((_mese-1)/3+1); tributo << "603" << ((_mese-1)/3+1);
else else
tributo << "60" << format("%02d", _mese); tributo << "60" << format("%02d", _mese);
break; break;
case 2: case 2:
tributo = "6099"; // Annuale tributo = "6099"; // Annuale
break; break;
@ -380,14 +380,14 @@ bool TStampa_deleghe_IVA::print_deleghe()
tributo = "6035"; tributo = "6035";
else else
tributo = "6013"; tributo = "6013";
break;
default:
tributo = "";
break; break;
} default:
tributo = "";
break;
}
delega.put("S6", tributo); delega.put("S6", tributo);
} }
ok = f.print(-1); // Stampa solo il record corrente ok = f.print(-1); // Stampa solo il record corrente
if (!arng) if (!arng)
{ // Scopo di cio' e' far si' che esegua il { // Scopo di cio' e' far si' che esegua il
@ -405,23 +405,23 @@ bool TStampa_deleghe_IVA::print_deleghe()
scrivi = TRUE; scrivi = TRUE;
} }
if (!_aggiorna_codici) // Cancella codici se non richiesti if (!_aggiorna_codici) // Cancella codici se non richiesti
{ {
if (!cera_abi) if (!cera_abi)
{ {
delega.zero("S7"); delega.zero("S7");
delega.zero("S8"); delega.zero("S8");
scrivi = TRUE; scrivi = TRUE;
} }
if (!cera_conc) if (!cera_conc)
{ {
delega.zero("S9"); delega.zero("S9");
scrivi = TRUE; scrivi = TRUE;
} }
if (!cera_tribu) if (!cera_tribu)
{ {
delega.zero("S6"); delega.zero("S6");
scrivi = TRUE; scrivi = TRUE;
} }
} }
if (scrivi) if (scrivi)
delega.rewrite(); delega.rewrite();
@ -435,6 +435,6 @@ bool TStampa_deleghe_IVA::print_deleghe()
int cg1400(int argc, char* argv[]) int cg1400(int argc, char* argv[])
{ {
TStampa_deleghe_IVA a; TStampa_deleghe_IVA a;
a.run(argc, argv, "Stampa Deleghe IVA"); a.run(argc, argv, "Stampa Versamenti");
return 0; return 0;
} }