Aggiunti controlli per tabella "Versamenti ed interessi IVA" %VER.
git-svn-id: svn://10.65.10.50/trunk@2760 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
fb2159ee47
commit
fa9d4c96d0
109
ba/ba3100.cpp
109
ba/ba3100.cpp
@ -3,11 +3,14 @@
|
||||
#include <tabapp.h>
|
||||
#include <tabutil.h>
|
||||
|
||||
#include "../cg/cglib03.h"
|
||||
#include "batbreg.h"
|
||||
#include "batbcam.h"
|
||||
#include "batbdel.h"
|
||||
#include "batbver.h"
|
||||
|
||||
#define REG_JOURNAL 5
|
||||
#define Versamenti_table "%VER"
|
||||
|
||||
class TGeneric_table_app : public Tab_application
|
||||
{
|
||||
@ -16,8 +19,14 @@ class TGeneric_table_app : public Tab_application
|
||||
bool _exist_journal;
|
||||
bool _stampa_intest;
|
||||
|
||||
// ------------- specifiche tabella versamenti ed interessi IVA
|
||||
TTable* _ver;
|
||||
void load_rec_in_disabled_fields(TMask& m);
|
||||
void copy_rec_in_insert_fields(TMask& m);
|
||||
// ------------------------------------------------------------
|
||||
protected: // TRelation_application
|
||||
virtual bool user_create() ;
|
||||
virtual bool user_destroy() ;
|
||||
virtual bool user_create() ;
|
||||
virtual bool protected_record(TRectype& rec) ;
|
||||
virtual void init_insert_mode(TMask& m) ;
|
||||
virtual void init_modify_mode(TMask& m);
|
||||
@ -35,9 +44,61 @@ public:
|
||||
HIDDEN inline TGeneric_table_app& app() { return (TGeneric_table_app&) main_app();}
|
||||
|
||||
|
||||
// - tabella versamenti-specific -------------------------------
|
||||
void TGeneric_table_app::load_rec_in_disabled_fields(TMask& m)
|
||||
// carica il record del periodo precedente a quello immesso
|
||||
// nei campi disabilitati relativi
|
||||
{
|
||||
TString key(m.get(F_ANNOES));
|
||||
|
||||
key << m.get(F_MESEES);
|
||||
_ver->put("CODTAB",key);
|
||||
if (_ver->read(_isgteq) == _iseof) // Se non lo trova si posiziona sull'ultimo
|
||||
_ver->last();
|
||||
else
|
||||
_ver->prev(); // altrimenti legge il periodo precedente.
|
||||
if (_ver->good()) // se si e' immesso un periodo precedente al primo , non copiera' nulla
|
||||
{
|
||||
m.set(F_1_TRIMESTRE_P,_ver->get("R0"));
|
||||
m.set(F_2_TRIMESTRE_P,_ver->get("R1"));
|
||||
m.set(F_3_TRIMESTRE_P,_ver->get("R2"));
|
||||
m.set(F_4_TRIMESTRE_P,_ver->get("R3"));
|
||||
m.set(F_ANNUALE_P,_ver->get("R4"));
|
||||
m.set(F_I_PERIODO_P,_ver->get("R5"));
|
||||
m.set(F_I_ANNUALE_P,_ver->get("R6"));
|
||||
m.set(F_I_ACCONTO_P,_ver->get("R7"));
|
||||
m.set(F_I_INTEGRATIVO_P,_ver->get("R8"));
|
||||
m.set(F_I_CESSAZIONE_P,_ver->get("R9"));
|
||||
m.set(F_I_ART74_P,_ver->get("R10"));
|
||||
m.set(F_P_LIQ_NORMALE_P,_ver->get("R11"));
|
||||
m.set(F_P_LIQ_DIFFERI_P,_ver->get("R12"));
|
||||
}
|
||||
}
|
||||
|
||||
void TGeneric_table_app::copy_rec_in_insert_fields(TMask& m)
|
||||
{
|
||||
TString tmp;
|
||||
|
||||
tmp = m.get(F_1_TRIMESTRE_P); m.set(F_1_TRIMESTRE, tmp);
|
||||
tmp = m.get(F_2_TRIMESTRE_P); m.set(F_2_TRIMESTRE, tmp);
|
||||
tmp = m.get(F_3_TRIMESTRE_P); m.set(F_3_TRIMESTRE, tmp);
|
||||
tmp = m.get(F_4_TRIMESTRE_P); m.set(F_4_TRIMESTRE, tmp);
|
||||
tmp = m.get(F_ANNUALE_P); m.set(F_ANNUALE, tmp);
|
||||
tmp = m.get(F_I_PERIODO_P); m.set(F_I_PERIODO,tmp);
|
||||
tmp = m.get(F_I_ANNUALE_P); m.set(F_I_ANNUALE,tmp);
|
||||
tmp = m.get(F_I_ACCONTO_P); m.set(F_I_ACCONTO,tmp);
|
||||
tmp = m.get(F_I_INTEGRATIVO_P); m.set(F_I_INTEGRATIVO,tmp);
|
||||
tmp = m.get(F_I_CESSAZIONE_P); m.set(F_I_CESSAZIONE,tmp);
|
||||
tmp = m.get(F_I_ART74_P); m.set(F_I_ART74,tmp);
|
||||
tmp = m.get(F_P_LIQ_NORMALE_P); m.set(F_P_LIQ_NORMALE,tmp);
|
||||
tmp = m.get(F_P_LIQ_DIFFERI_P); m.set(F_P_LIQ_DIFFERI,tmp);
|
||||
}
|
||||
// -------------------------------------------------------------
|
||||
|
||||
void TGeneric_table_app::init_insert_mode(TMask& m)
|
||||
{
|
||||
if (get_tabname() == "REG")
|
||||
TString n(get_tabname());
|
||||
if (n == "REG")
|
||||
{
|
||||
const long ditta = get_firm();
|
||||
const int anno = atoi(m.get(F_ANNO));
|
||||
@ -59,13 +120,23 @@ void TGeneric_table_app::init_insert_mode(TMask& m)
|
||||
for (reg.read(_isgteq); !_exist_journal && reg.good() && reg.curr() <= to; reg.next())
|
||||
_exist_journal = (reg.get_long("I0") == REG_JOURNAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (n == Versamenti_table)
|
||||
{
|
||||
// Se il record e' nuovo prima carica il record precedente
|
||||
load_rec_in_disabled_fields(m);
|
||||
// poi copia il contenuto nei campi di input, come valori predefiniti
|
||||
copy_rec_in_insert_fields(m);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TGeneric_table_app::init_modify_mode(TMask& m)
|
||||
{
|
||||
Tab_application::init_modify_mode(m);
|
||||
if (get_tabname() == "REG")
|
||||
TString n(get_tabname());
|
||||
if (n == "REG")
|
||||
{
|
||||
TString16 config;
|
||||
config.format("REG%05ld", m.get_long(F_CODDITTA));
|
||||
@ -75,6 +146,9 @@ void TGeneric_table_app::init_modify_mode(TMask& m)
|
||||
m.set(F_CONFIG, what >= 0 ? "X" : "");
|
||||
m.enable(F_CONFIG, what >= 0);
|
||||
}
|
||||
else
|
||||
if (n == Versamenti_table)
|
||||
load_rec_in_disabled_fields(m);
|
||||
}
|
||||
|
||||
void TGeneric_table_app::init_query_mode(TMask& m)
|
||||
@ -251,18 +325,21 @@ HIDDEN bool impdel_handler(TMask_field& f, KEY k)
|
||||
const int tipo_del = m.get_int(F_TIPODEL);
|
||||
if (tipo_del == 1 || tipo_del == 7)
|
||||
{
|
||||
const double lim[3] = { 500.0, 50500.0, 200000.0};
|
||||
TInteressi_IVA_table ver;
|
||||
const int mese_del = m.get_int(F_MESEDEL);
|
||||
int t;
|
||||
real lim;
|
||||
|
||||
if (ver.read(m.get_int(F_ANNODEL), (mese_del>12) ? 12 : mese_del) != NOERR)
|
||||
warning_box("Errore %d in lettura tabella versamenti ed interessi.",ver.status());
|
||||
if (tipo_del == 1)
|
||||
{
|
||||
if (mese_del == 12) t = 0;
|
||||
else t = 1;
|
||||
if (mese_del == 12) lim = ver.get(I_ANNUALE);
|
||||
else lim = ver.get(I_PERIODICO);
|
||||
}
|
||||
else t = 2;
|
||||
else lim = ver.get(I_ACCONTOIVA);
|
||||
const real imp(m.get(F_IMPORTO));
|
||||
if (imp < lim[t])
|
||||
return yesno_box("Importo inferiore a Lit. %s. Registrare ugualmente?", real(lim[t]).string("."));
|
||||
if (imp < lim)
|
||||
return yesno_box("Importo inferiore a Lit. %s. Registrare ugualmente?", lim.string("."));
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
@ -345,10 +422,20 @@ bool TGeneric_table_app::user_create()
|
||||
}
|
||||
if (name == "CAM")
|
||||
set_search_field(FLD_TABCAM_D0);
|
||||
if (name == Versamenti_table)
|
||||
_ver = new TTable(Versamenti_table);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TGeneric_table_app::user_destroy()
|
||||
{
|
||||
TString n(get_tabname());
|
||||
if (n == Versamenti_table)
|
||||
delete _ver;
|
||||
return Tab_application::user_destroy();
|
||||
}
|
||||
|
||||
int TGeneric_table_app::rewrite(const TMask& m)
|
||||
{
|
||||
if (get_tabname() == "REG" && !m.get_bool(F_CONFIG))
|
||||
|
Loading…
x
Reference in New Issue
Block a user