Migliorata cancellazione automatica dei conti inutilizzati in contabilita'
git-svn-id: svn://10.65.10.50/trunk@337 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
027bf745b6
commit
1d0869e9a2
@ -564,7 +564,7 @@ void TPrimanota_application::mask2rel(const TMask& m)
|
||||
|
||||
const long numreg = m.get_long(F_NUMREG);
|
||||
const TDate datareg(m.get(F_DATAREG));
|
||||
const int annoes = (int) m.get_long(F_ANNOES);
|
||||
const int annoes = m.get_int(F_ANNOES);
|
||||
|
||||
_saldi.set_movprovv(m.get_bool(F_PROVVISORIO));
|
||||
_saldi.set_movap(_causale.apertura());
|
||||
@ -686,24 +686,6 @@ void TPrimanota_application::mask2rel(const TMask& m)
|
||||
|
||||
cur++;
|
||||
}
|
||||
|
||||
// Resetta il flag di calcolato sulla liquidazione IVA del mese di registrazione
|
||||
// TBI: occorre resettarlo anche su PLM (B0), attivita' per attivita'
|
||||
// Chiave di PLM: Anno (1-4), Cod. Att. (5-9), Mese (10-11)
|
||||
//
|
||||
const TDate d(m.get(F_DATAREG));
|
||||
TString16 chiave; chiave << d.year() << d.month();
|
||||
TTable lim("LIM");
|
||||
lim.put("CODTAB", chiave);
|
||||
if (lim.read() == NOERR)
|
||||
{
|
||||
const bool calcolato = lim.get_bool("B0");
|
||||
if (calcolato)
|
||||
{
|
||||
lim.put("B0", FALSE);
|
||||
lim.rewrite();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -136,36 +136,6 @@ BEGIN
|
||||
COPY OUTPUT F_CODCAUS
|
||||
END
|
||||
|
||||
STRING F_VALUTA 3
|
||||
BEGIN
|
||||
PROMPT 1 9 "Valuta "
|
||||
FIELD CODVAL
|
||||
FLAGS "U"
|
||||
GROUP 3
|
||||
USE %VAL
|
||||
INPUT CODTAB F_VALUTA
|
||||
DISPLAY "Codice" CODTAB
|
||||
DISPLAY "Nome@50" S0
|
||||
DISPLAY "Cambio corrente" R0
|
||||
OUTPUT F_VALUTA CODTAB
|
||||
OUTPUT F_CAMBIO R0
|
||||
END
|
||||
|
||||
NUMBER F_CAMBIO 10
|
||||
BEGIN
|
||||
PROMPT 16 9 "Cambio "
|
||||
FIELD CAMBIO
|
||||
FLAGS "RU"
|
||||
GROUP 3
|
||||
PICTURE ".3"
|
||||
END
|
||||
|
||||
BOOLEAN F_VISVAL
|
||||
BEGIN
|
||||
PROMPT 42 9 "Visualizza importi in valuta"
|
||||
GROUP 3
|
||||
END
|
||||
|
||||
SPREADSHEET F_SHEETCG
|
||||
BEGIN
|
||||
PROMPT 0 9 ""
|
||||
|
@ -349,6 +349,7 @@ BEGIN
|
||||
ITEM "LU|Lussemburgo"
|
||||
ITEM "NL|Olanda"
|
||||
ITEM "PT|Portogallo"
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
BUTTON F_OCCASEDIT 18
|
||||
@ -368,12 +369,14 @@ STRING F_CODPAG 4
|
||||
BEGIN
|
||||
PROMPT 60 11 "Pagamento "
|
||||
FIELD CODPAG
|
||||
FLAGS "U"
|
||||
USE %CPG
|
||||
INPUT CODTAB F_CODPAG
|
||||
DISPLAY "Codice" CODTAB
|
||||
DISPLAY "Descrizione@50" S0
|
||||
OUTPUT F_CODPAG CODTAB
|
||||
CHECKTYPE NORMAL
|
||||
WARNING "Codice pagamento assente"
|
||||
END
|
||||
|
||||
NUMBER F_TOTALE 15
|
||||
|
@ -167,6 +167,45 @@ int TMovimentoPN::registra(bool re, bool force)
|
||||
cancella(ri, i+1, _oldiva);
|
||||
_oldiva = iva_items();
|
||||
|
||||
// Resetta il flag di calcolato sulla liquidazione IVA del mese di registrazione
|
||||
// Chiave di LIM: Anno (1-4), Mese (5-6)
|
||||
|
||||
const TDate d(m.get("DATAREG"));
|
||||
TString16 chiave; chiave << d.year() << d.month();
|
||||
TTable lim("LIM");
|
||||
lim.put("CODTAB", chiave);
|
||||
if (lim.read() == NOERR)
|
||||
{
|
||||
const bool calcolato = lim.get_bool("B0");
|
||||
if (calcolato)
|
||||
{
|
||||
lim.put("B0", FALSE);
|
||||
lim.rewrite();
|
||||
}
|
||||
}
|
||||
|
||||
const TString16 cod(m.get("REG"));
|
||||
const int anno = m.get_int("ANNOIVA");
|
||||
TRegistro reg(cod, anno);
|
||||
const int att = reg.attivita_mista() ? 2 : 1;
|
||||
|
||||
// Chiave di PLM: Anno (1-4), Cod. Att. (5-9), Tipo att. (10-10), Mese (11-12)
|
||||
TTable plm("PLM");
|
||||
for (int a = 1; a <= att; a++)
|
||||
{
|
||||
chiave.cut(0);
|
||||
chiave << d.year() << reg.attivita() << a << d.month();
|
||||
plm.put("CODTAB", chiave);
|
||||
if (plm.read() == NOERR)
|
||||
{
|
||||
const bool calcolato = plm.get_bool("B0");
|
||||
if (calcolato)
|
||||
{
|
||||
plm.put("B0", FALSE);
|
||||
plm.rewrite();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ inline TPrimanota_application& app()
|
||||
// Certified 100%
|
||||
TipoIVA TPrimanota_application::cau2IVA(const char* causale, int annoiva)
|
||||
{
|
||||
TipoIVA i = iva_errata;
|
||||
TipoIVA i = nessuna_iva;
|
||||
|
||||
if (*causale > ' ')
|
||||
{
|
||||
@ -29,8 +29,11 @@ TipoIVA TPrimanota_application::cau2IVA(const char* causale, int annoiva)
|
||||
if (c.read(causale, annoiva))
|
||||
i = c.iva();
|
||||
else
|
||||
{
|
||||
error_box("Causale errata: '%s'", causale);
|
||||
} else i = nessuna_iva;
|
||||
i = iva_errata;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
@ -338,6 +341,15 @@ void TPrimanota_application::disable_cgs_cells(int n, char tipo)
|
||||
}
|
||||
|
||||
|
||||
void TPrimanota_application::reset_cgs_row(int n)
|
||||
{
|
||||
TSheet_field& cg = cgs();
|
||||
cg.row(cg.items()); // Append a new line
|
||||
cg.destroy(n); // Remove line n
|
||||
}
|
||||
|
||||
|
||||
|
||||
int TPrimanota_application::set_cgs_row(int n, const TImporto& imp,
|
||||
TBill& conto, const char* desc,
|
||||
char tipo)
|
||||
@ -535,7 +547,7 @@ bool TPrimanota_application::descr_handler(TMask_field& f, KEY k)
|
||||
if (k == K_ENTER && f.get().empty())
|
||||
{
|
||||
if (f.mask().get(F_CODCAUS).empty())
|
||||
return error_box("Descrizione documento necessaria in mancanza della causale");
|
||||
return f.error_box("La descrizione del documento e' necessaria in mancanza della causale");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -695,12 +707,12 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
|
||||
|
||||
const char tipod = detraibile(row) ? 'D' : 'N';
|
||||
oldposiva = type2pos(tipod);
|
||||
TString80 d;
|
||||
|
||||
if (oldposiva < 0 && oldiva != ZERO)
|
||||
{
|
||||
const int r = tipod == 'D' ? 3 : 4;
|
||||
TBill c; cau.bill(r, c);
|
||||
d = cau.desc_agg(r);
|
||||
const TString80 d(cau.desc_agg(r));
|
||||
oldposiva = app().set_cgs_row(-1, app().real2imp(ZERO, 'I'), c, d, tipod);
|
||||
}
|
||||
|
||||
@ -708,7 +720,7 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
|
||||
oldpos = bill2pos(oldconto, 'I');
|
||||
if (oldpos < 0 && oldconto.ok())
|
||||
{
|
||||
d = cau.desc_agg(2);
|
||||
const TString80 d(cau.desc_agg(2));
|
||||
oldpos = app().set_cgs_row(-1, app().real2imp(ZERO, 'I'), oldconto, d, 'I');
|
||||
}
|
||||
}
|
||||
@ -720,13 +732,16 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
|
||||
}
|
||||
if (k == K_ENTER)
|
||||
{
|
||||
int delimp = -1, deliva = -1;
|
||||
if (oldpos >= 0) // Il conto esisteva anche prima
|
||||
{
|
||||
const TImporto& imp = app().sub_cgs_imp(oldpos, oldimp);
|
||||
if (imp.valore().is_zero) delimp = oldpos;
|
||||
}
|
||||
if (oldposiva >= 0) // Il conto IVA esisteva anche prima
|
||||
{
|
||||
const TImporto& imp = app().sub_cgs_imp(oldposiva, oldiva);
|
||||
if (imp.valore().is_zero) deliva = oldposiva;
|
||||
}
|
||||
|
||||
// Aggiorna conto sulla riga contabile
|
||||
@ -745,6 +760,8 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
|
||||
|
||||
if (newpos < 0)
|
||||
{
|
||||
if (delimp >= 0) app().reset_cgs_row(delimp);
|
||||
|
||||
const TImporto val(app().real2imp(imp, 'I'));
|
||||
if (val.valore() != ZERO)
|
||||
{
|
||||
@ -758,7 +775,7 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
|
||||
val = app().add_cgs_imp(newpos, val);
|
||||
if (val.valore().is_zero())
|
||||
{
|
||||
app().cgs().destroy(newpos);
|
||||
app().reset_cgs_row(newpos);
|
||||
newpos = -1;
|
||||
}
|
||||
}
|
||||
@ -788,7 +805,7 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
|
||||
val = app().add_cgs_imp(newposiva, val);
|
||||
if (val.valore().is_zero())
|
||||
{
|
||||
app().cgs().destroy(newposiva);
|
||||
app().reset_cgs_row(newposiva);
|
||||
newposiva = -1;
|
||||
}
|
||||
}
|
||||
@ -907,8 +924,8 @@ bool TPrimanota_application::caus_modify_handler(TMask_field& f, KEY key)
|
||||
if (!ok) return FALSE;
|
||||
|
||||
const int ann = f.mask().get_int(F_ANNOIVA);
|
||||
const char* cau = f.get();
|
||||
TCausale c(cau, ann);
|
||||
const TString16 cau(f.get());
|
||||
const TCausale c(cau, ann);
|
||||
if (!c.ok()) return FALSE;
|
||||
|
||||
|
||||
@ -959,9 +976,9 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
|
||||
"ultima stampa del libro giornale dell'esercizio %d",
|
||||
gio.last_reg().string(), ae);
|
||||
if (dr < gio.last_reg())
|
||||
warning_box("La data dell'operazione e' antecedente al %s,\n"
|
||||
"ultima registrazione sul libro giornale dell'esercizio %d",
|
||||
gio.last_reg().string(), ae);
|
||||
f.warning_box("La data dell'operazione e' antecedente al %s,\n"
|
||||
"ultima registrazione sul libro giornale dell'esercizio %d",
|
||||
gio.last_reg().string(), ae);
|
||||
|
||||
if (m.query_mode())
|
||||
{
|
||||
@ -980,7 +997,6 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
|
||||
const TString16 codreg(reg.name());
|
||||
if (codreg.not_empty())
|
||||
{
|
||||
|
||||
if (reg.year() != dr.year())
|
||||
{
|
||||
const bool ok = reg.read(codreg, dr.year());
|
||||
@ -988,13 +1004,13 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
|
||||
}
|
||||
|
||||
if (dr < reg.last_print())
|
||||
return error_box("La data dell'operazione e' antecedente al %s,\n"
|
||||
"ultima stampa del registro '%s' dell'anno %d",
|
||||
reg.last_print().string(), (const char*)codreg, dr.year());
|
||||
return f.error_box("La data dell'operazione e' antecedente al %s,\n"
|
||||
"ultima stampa del registro '%s' dell'anno %d",
|
||||
reg.last_print().string(), (const char*)codreg, dr.year());
|
||||
if (dr < reg.last_reg())
|
||||
warning_box("La data dell'operazione e' antecedente al %s,\n"
|
||||
"ultima registrazione sul registro '%s' dell'anno %d",
|
||||
reg.last_reg().string(), (const char*)codreg, dr.year());
|
||||
f.warning_box("La data dell'operazione e' antecedente al %s,\n"
|
||||
"ultima registrazione sul registro '%s' dell'anno %d",
|
||||
reg.last_reg().string(), (const char*)codreg, dr.year());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1089,15 +1105,7 @@ bool TPrimanota_application::occas_code_handler(TMask_field& f, KEY key)
|
||||
f.mask().send_key(K_TAB, O_COMUNENAS);
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (key == K_ENTER)
|
||||
{
|
||||
const TFixed_string codice(f.get());
|
||||
if (codice.not_empty())
|
||||
app().mask().set(app().iva() == iva_vendite ? F_PIVACLIENTE : F_PIVAFORNITORE, codice);
|
||||
else
|
||||
return f.error_box("Il codice e' obbligatorio");
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1123,16 +1131,19 @@ void TPrimanota_application::add_cgs_tot(TMask& m)
|
||||
long codice = m.get_long(tipo == 'C' ? F_CLIENTE : F_FORNITORE);
|
||||
|
||||
// Se l'utente non ha ancora specificato un conto lo prendo dalla prima riga della causale
|
||||
TBill bill; _causale.bill(1, bill);
|
||||
if (conto == 0)
|
||||
{
|
||||
TBill bill; _causale.bill(1, bill);
|
||||
gruppo = bill.gruppo(); m.set(F_GRUPPOCLIFO, gruppo);
|
||||
conto = bill.conto(); m.set(F_CONTOCLIFO, conto);
|
||||
codice = bill.sottoconto();
|
||||
}
|
||||
|
||||
if (tipo == 'C' && causale().corrispettivi())
|
||||
{
|
||||
codice = bill.sottoconto();
|
||||
tipo = ' ';
|
||||
}
|
||||
|
||||
TBill c(gruppo, conto, codice, tipo);
|
||||
real tot(m.get(F_TOTALE));
|
||||
@ -1320,6 +1331,7 @@ bool TPrimanota_application::solaiva_handler(TMask_field& f, KEY key)
|
||||
}
|
||||
app().fill_sheet(m);
|
||||
app().cgs().force_update();
|
||||
m.set_focus();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -154,6 +154,7 @@ protected:
|
||||
|
||||
void set_ivas_row(int n, const char* codiva, TBill& tc, const char* desc);
|
||||
int set_cgs_row(int n, const TImporto& importo, TBill& conto, const char* desc, char tipo);
|
||||
void reset_cgs_row(int n);
|
||||
void disable_cgs_cells(int n, char tipo);
|
||||
void add_cgs_tot(TMask& m);
|
||||
void add_cgs_rit(bool fisc);
|
||||
|
@ -75,6 +75,16 @@ int TRegistro::year() const
|
||||
}
|
||||
|
||||
|
||||
static TString16 n;
|
||||
const TString& TRegistro::name() const
|
||||
{
|
||||
if (ok()) n = _rec.get("CODTAB").mid(4);
|
||||
else n = "";
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TRegistro& TRegistro::operator =(const TRegistro& r)
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
int tipo() const;
|
||||
TipoIVA iva() const;
|
||||
bool corrispettivi() const;
|
||||
const TString& name() const { return _rec.get("CODTAB").mid(4); }
|
||||
const TString& name() const;
|
||||
int year() const;
|
||||
TDate last_reg() const { return _rec.get_date("D2"); }
|
||||
TDate last_print() const { return _rec.get_date("D3"); }
|
||||
|
@ -12,9 +12,9 @@ int main(int argc,char** argv)
|
||||
switch (n)
|
||||
{
|
||||
case 0: cg5000(argc,argv) ; break;
|
||||
case 1: cg5100(argc,argv) ; break;
|
||||
case 3: cg5300(argc,argv) ; break;
|
||||
default: fatal_box(usage, argv[0]) ;
|
||||
case 1: cg5100(argc,argv) ; break;
|
||||
case 3: cg5300(argc,argv) ; break;
|
||||
default: fatal_box(usage, argv[0]) ;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user