Riaggiustato Parametri Liquidazione per:
- ricalcolo forzato se si cambiano prorata o plafond - controllo presenza registri essenziali git-svn-id: svn://10.65.10.50/trunk@629 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
efccdb6226
commit
47870c3f84
@ -148,7 +148,7 @@ public:
|
||||
// Application
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
class CG4300_App : public TPrintapp
|
||||
class CG4300_App : public TPrinter_application
|
||||
{
|
||||
TArray_sheet* _ditte;
|
||||
wht _what;
|
||||
|
@ -474,14 +474,14 @@ void CG4300_App::recalc_att(int month, const char* codatt)
|
||||
{
|
||||
acq_ies += imponibile;
|
||||
acq_ies_iva += imposta;
|
||||
continue;
|
||||
continue; // non entrano in liquidazione
|
||||
}
|
||||
|
||||
if (tipodet == 3) // passaggi interni (solo ventilaz.)
|
||||
{
|
||||
acq_pint += imponibile;
|
||||
acq_pint_iva += imposta;
|
||||
continue;
|
||||
continue; // precauzionale (in genere sono esenti IVA)
|
||||
}
|
||||
|
||||
// *****************************************
|
||||
@ -521,7 +521,10 @@ void CG4300_App::recalc_att(int month, const char* codatt)
|
||||
lor += imponibile;
|
||||
_pim_r->put("I0",LORDO);
|
||||
add_vendite(month, reg, imponibile);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* corrispettivi non da ventilare vanno comunque scorporati poi
|
||||
*/
|
||||
else if (corrisp)
|
||||
{
|
||||
real perc = _iva->get_real("R0") / CENTO;
|
||||
@ -550,8 +553,6 @@ void CG4300_App::recalc_att(int month, const char* codatt)
|
||||
// calcolati tutti i movimenti e aggiornati i pim
|
||||
// salviamo i totali antes que seja tarde
|
||||
|
||||
real dd6 = ammort_6 * real(DETRAZIONE_6PERCENTO);
|
||||
|
||||
// calcola il lercio prorata
|
||||
real prorata;
|
||||
if (!_prorata.is_zero())
|
||||
@ -623,7 +624,7 @@ void CG4300_App::recalc_att(int month, const char* codatt)
|
||||
}
|
||||
_plm->put("R0", vendite_iva);
|
||||
_plm->put("R1", acquisti_iva);
|
||||
_plm->put("R3", dd6);
|
||||
_plm->put("R3", ult_detr);
|
||||
_plm->put("R12", _prorata); // per comodita' in stampa
|
||||
_plm->put("B0", "X"); // calcolato (deve essere invalidato dalla
|
||||
// primanota)
|
||||
|
141
cg/cg5300.cpp
141
cg/cg5300.cpp
@ -28,6 +28,8 @@ class CG5300_App : public TRelation_application
|
||||
long _lastditta;
|
||||
TString16 _freqiva;
|
||||
|
||||
void check_registers(int year);
|
||||
|
||||
protected:
|
||||
|
||||
virtual bool user_create();
|
||||
@ -58,10 +60,60 @@ public:
|
||||
CG5300_App() { _lastditta = 0L;}
|
||||
virtual ~CG5300_App() {}
|
||||
};
|
||||
|
||||
|
||||
void CG5300_App::check_registers(int year)
|
||||
{
|
||||
// controlla che per ogni data attivita' esistano almeno un registro
|
||||
// acquisti, vendite e giornale; warning appropriato in caso negativo
|
||||
TTable reg("REG");
|
||||
TRecfield reg_year(reg.curr(), "CODTAB", 0,3);
|
||||
|
||||
const byte R_ACQ = 0x01;
|
||||
const byte R_VEN = 0x02;
|
||||
const byte R_GIO = 0x04;
|
||||
const byte R_ALL = R_ACQ | R_VEN | R_GIO;
|
||||
|
||||
for (int i = 0; i < _atts.items(); i++)
|
||||
{
|
||||
byte flags = 0x00;
|
||||
TString& att = (TString&)_atts[i];
|
||||
|
||||
for (reg.first(); !reg.eof(); reg.next())
|
||||
{
|
||||
if (atoi(reg_year) != year || att != reg.get("S8"))
|
||||
continue;
|
||||
|
||||
switch ((int)reg.get_long("I0"))
|
||||
{
|
||||
case 1: // vendite
|
||||
flags |= R_VEN;
|
||||
break;
|
||||
case 2: // acquisti
|
||||
flags |= R_ACQ;
|
||||
break;
|
||||
case 5: // giornale
|
||||
flags |= R_GIO;
|
||||
break;
|
||||
}
|
||||
if (flags == R_ALL) break;
|
||||
}
|
||||
if (flags < R_ALL)
|
||||
{
|
||||
TString att = (TString&)_atts[i];
|
||||
TString wrn("I seguenti registri non esistono per l'attivita' ");
|
||||
wrn << att << ":";
|
||||
if ((flags & R_VEN) == 0x00) wrn << "\n\tregistro vendite";
|
||||
if ((flags & R_ACQ) == 0x00) wrn << "\n\tregistro acquisti";
|
||||
if ((flags & R_GIO) == 0x00) wrn << "\n\tlibro giornale";
|
||||
warning_box(wrn);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CG5300_App::init_ditta(TMask& m)
|
||||
|
||||
{
|
||||
// qui per evitare casini da cambio ditta
|
||||
const long newditta = get_firm();
|
||||
@ -90,22 +142,21 @@ void CG5300_App::init_ditta(TMask& m)
|
||||
}
|
||||
|
||||
bool CG5300_App::user_create()
|
||||
|
||||
{
|
||||
TConfig d(CONFIG_DITTA);
|
||||
|
||||
_yearliq = (int)d.get_long("AnLiIv");
|
||||
_rel = new TRelation(TAB_LIA);
|
||||
_pla = new TTable(TAB_PLA);
|
||||
_attiv = new TLocalisamfile(LF_ATTIV);
|
||||
_ditte = new TLocalisamfile(LF_NDITTE);
|
||||
_msk = new TMask("cg5300a");
|
||||
_rel = new TRelation(TAB_LIA);
|
||||
_pla = new TTable(TAB_PLA);
|
||||
_attiv = new TLocalisamfile(LF_ATTIV);
|
||||
_ditte = new TLocalisamfile(LF_NDITTE);
|
||||
_msk = new TMask("cg5300a");
|
||||
|
||||
((TSheet_field&)_msk->field(F_SHEET_PLA)).set_notify(sheet_action);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool CG5300_App::user_destroy()
|
||||
|
||||
bool CG5300_App::user_destroy()
|
||||
{
|
||||
delete _rel;
|
||||
delete _attiv;
|
||||
@ -115,15 +166,13 @@ bool CG5300_App::user_destroy()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool CG5300_App::sheet_action(int r, KEY k)
|
||||
|
||||
bool CG5300_App::sheet_action(int r, KEY k)
|
||||
{
|
||||
// non si possono cancellare o aggiungere righe in PLA
|
||||
return (k != K_DEL && k != K_INS);
|
||||
}
|
||||
|
||||
void CG5300_App::init_query_mode(TMask& m)
|
||||
|
||||
{
|
||||
// svuota tutto
|
||||
TSheet_field& sh = (TSheet_field&)m.field(F_SHEET_PLA);
|
||||
@ -155,36 +204,68 @@ void CG5300_App::init_insert_mode(TMask& m)
|
||||
}
|
||||
}
|
||||
|
||||
int CG5300_App::rewrite(const TMask& m)
|
||||
|
||||
int CG5300_App::rewrite(const TMask& m)
|
||||
{
|
||||
// scrive LIA
|
||||
// scrive tutte le righe di PLA a partire dalle righe sheet
|
||||
// scrive tutte le righe di PLA a partire dalle righe sheet
|
||||
static int oldyear;
|
||||
|
||||
TSheet_field& sf = (TSheet_field&)m.field(F_SHEET_PLA);
|
||||
const TString16 year(m.get(F_YEAR));
|
||||
int yr = atoi(year);
|
||||
|
||||
int err = NOERR;
|
||||
bool was = FALSE;
|
||||
|
||||
for (int i = 0; err == NOERR && i < _atts.items(); i++)
|
||||
{
|
||||
TToken_string& tt = sf.row(i);
|
||||
const TString& att = (TString&) _atts[i];
|
||||
const TString16 tips(tt.get(1));
|
||||
TToken_string& tt = sf.row(i);
|
||||
const TString& att = (TString&) _atts[i];
|
||||
const TString16 tips(tt.get(1));
|
||||
|
||||
_pla->zero();
|
||||
_pla->put("CODTAB", format("%s%s1", (const char *) year, (const char *) att));
|
||||
was =_pla->read() == NOERR;
|
||||
if (!was) _pla->zero();
|
||||
|
||||
real prorata = _pla->get_real("R8");
|
||||
real es_a8 = _pla->get_real("R5");
|
||||
real es_a8b = _pla->get_real("R6");
|
||||
real es_a9 = _pla->get_real("R7");
|
||||
|
||||
_pla->put("CODTAB", format("%s%s1", (const char *) year, (const char *) att));
|
||||
// scrive i campi (vedi a read() per i nomi)
|
||||
// in base alla riga sheet
|
||||
_pla->put("S7", tips); // tipo attivita'
|
||||
_pla->put("R8", tt.get()); // prorata
|
||||
_pla->put("R5", tt.get()); // plafond art. 8
|
||||
_pla->put("R6", tt.get()); // plafond art. 8bis
|
||||
_pla->put("R7", tt.get()); // plafond art. 9
|
||||
err = (was ? _pla->rewrite() : _pla->write());
|
||||
_pla->put("R8", tt.get()); // prorata
|
||||
_pla->put("R5", tt.get()); // plafond art. 8
|
||||
_pla->put("R6", tt.get()); // plafond art. 8bis
|
||||
_pla->put("R7", tt.get()); // plafond art. 9
|
||||
|
||||
err = (was ? _pla->rewrite() : _pla->write());
|
||||
|
||||
// se si e' cambiato qualcosa..
|
||||
if (prorata != _pla->get_real("R8") ||
|
||||
es_a8 != _pla->get_real("R5") ||
|
||||
es_a8b != _pla->get_real("R6") ||
|
||||
es_a9 != _pla->get_real("R7"))
|
||||
{
|
||||
// invalida la prima liquidazione calcolata se ce n'e'
|
||||
TTable lim("LIM");
|
||||
|
||||
TRecfield lim_anno(lim.curr(),"CODTAB",0,3);
|
||||
|
||||
for (lim.first(); !lim.eof(); lim.next())
|
||||
{
|
||||
if (yr == atoi(lim_anno))
|
||||
{
|
||||
lim.put("B0","");
|
||||
lim.rewrite();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
TTable & lia = (TTable &) _rel->lfile();
|
||||
|
||||
@ -203,12 +284,18 @@ int CG5300_App::rewrite(const TMask& m)
|
||||
_ditte->put(NDT_FREQVIVA, m.get(F_FREQ_VERS));
|
||||
_ditte->rewrite();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// per ogni anno liquidazione controlla (una volta) l'esistenza
|
||||
// dei registri fondamentali
|
||||
if (yr != oldyear && err == NOERR)
|
||||
check_registers(yr);
|
||||
oldyear = yr;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int CG5300_App::read(TMask& m)
|
||||
|
||||
{
|
||||
// legge da LIA (si istanziano i campi credito prec. e Freq. Vers
|
||||
// prende le attivita' una per una da _atts e
|
||||
@ -225,7 +312,8 @@ int CG5300_App::read(TMask& m)
|
||||
|
||||
// cerca l'attivita' in pla
|
||||
_pla->zero();
|
||||
_pla->put("CODTAB", format("%s%s1", (const char *) year, (const char *) att));
|
||||
_pla->put("CODTAB", format("%s%s1", (const char *) year,
|
||||
(const char *) att));
|
||||
tt = "";
|
||||
tt.add(att);
|
||||
if (_pla->read() == NOERR)
|
||||
@ -252,7 +340,6 @@ int CG5300_App::read(TMask& m)
|
||||
|
||||
|
||||
int cg5300(int argc, char* argv[])
|
||||
|
||||
{
|
||||
CG5300_App a;
|
||||
a.run(argc, argv, "Parametri liquidazione");
|
||||
|
Loading…
x
Reference in New Issue
Block a user