Corretta gestione del libro giornale
git-svn-id: svn://10.65.10.50/trunk@3521 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
fb5f11a162
commit
8246fd8547
@ -235,7 +235,9 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
||||
|
||||
const bool nota_credito = is_nota_credito();
|
||||
const bool show_games = is_pagamento() || nota_credito;
|
||||
TMask& cgm = cgs().sheet_mask();
|
||||
|
||||
TSheet_field& cgsheet = (TSheet_field&)m->field(F_SHEETCG);
|
||||
TMask& cgm = cgsheet.sheet_mask();
|
||||
cgm.set_handler(100, show_games ? showpartite_handler : NULL); // bottoncino riga
|
||||
cgm.enable(100, show_games);
|
||||
if (iva == nessuna_iva)
|
||||
@ -265,8 +267,8 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
||||
}
|
||||
|
||||
if (ins && !ci_sono_importi())
|
||||
{
|
||||
cgs().reset();
|
||||
{
|
||||
cgsheet.reset();
|
||||
for (int i = 1; i < causale().size(); i++)
|
||||
{
|
||||
const TRectype* rcaus = (TRectype*)causale().objptr(i);
|
||||
@ -313,7 +315,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
||||
}
|
||||
const int pos = set_cgs_row(-1, zero, tc, desc, tipr);
|
||||
if (sezione > ' ')
|
||||
cgs().disable_cell(pos, sezione == 'A' ? 0 : 1);
|
||||
cgsheet.disable_cell(pos, sezione == 'A' ? 0 : 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -405,7 +407,7 @@ void TPrimanota_application::on_firm_change()
|
||||
|
||||
void TPrimanota_application::on_config_change()
|
||||
{
|
||||
TConfig cnf(CONFIG_DITTA);
|
||||
TConfig cnf(CONFIG_DITTA, "cg");
|
||||
_ges_val = cnf.get_bool("GesVal");
|
||||
_ges_sal = cnf.get_bool("GesSal");
|
||||
_npart_is_prot = cnf.get_bool("RifPro");
|
||||
@ -624,7 +626,7 @@ int TPrimanota_application::read(TMask& m)
|
||||
|
||||
occas_mask().reset();
|
||||
const TString16 occode(_rel->lfile().get("OCFPI"));
|
||||
occas_mask().set(O_CODICE, occode);
|
||||
occas_mask().set(O_CODICE, occode, TRUE);
|
||||
|
||||
const char clifo = _rel->lfile().get_char("TIPO");
|
||||
if (_iva == iva_acquisti && clifo == 'C')
|
||||
@ -806,23 +808,22 @@ void TPrimanota_application::mask2rel(const TMask& m)
|
||||
{
|
||||
rec.put("TIPO", clifo());
|
||||
|
||||
int err = ~NOERR;
|
||||
if (m.field(F_OCCASEDIT).active()) // Se e' un occasionale
|
||||
{
|
||||
TRelation occas(LF_OCCAS);
|
||||
const TMask& om = occas_mask();
|
||||
TRelation occas(LF_OCCAS);
|
||||
om.autosave(occas); // Salva i dati anagrafici
|
||||
|
||||
err = occas.write();
|
||||
|
||||
int err = occas.write();
|
||||
if (err == _isreinsert)
|
||||
err = occas.rewrite();
|
||||
|
||||
|
||||
if (err == NOERR)
|
||||
rec.put("OCFPI", occas_mask().get(O_CODICE));
|
||||
rec.put("OCFPI", om.get(O_CODICE));
|
||||
else
|
||||
error_box("Errore di scrittura sul file dei clienti/fornitori occasionali: %d", err);
|
||||
}
|
||||
if (err)
|
||||
else
|
||||
rec.zero("OCFPI");
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,8 @@ BEGIN
|
||||
FLAGS "RU"
|
||||
GROUP 3
|
||||
PICTURE ".5"
|
||||
CHECKTYPE REQUIRED
|
||||
CHECKTYPE REQUIRED
|
||||
WARNING "Inserire il cambio o eliminare il codice valuta"
|
||||
END
|
||||
|
||||
NUMBER F_TOTALE 15
|
||||
|
103
cg/cg2102.cpp
103
cg/cg2102.cpp
@ -203,8 +203,10 @@ int TPrimanota_application::bill_used(const TBill& conto) const
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TSheet_field& TPrimanota_application::cgs() const
|
||||
{
|
||||
TSheet_field& s = (TSheet_field&)curr_mask().field(F_SHEETCG);
|
||||
{
|
||||
const TMask* m = _msk[_iva == nessuna_iva ? 1 : 2];
|
||||
CHECK(m, "Null cgs() mask");
|
||||
TSheet_field& s = (TSheet_field&)m->field(F_SHEETCG);
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -1194,7 +1196,7 @@ void TPrimanota_application::ivas_pack()
|
||||
bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k)
|
||||
{
|
||||
static int oldpos,oldposiva;
|
||||
static real oldimp, oldiva;
|
||||
static TImporto oldimp, oldiva;
|
||||
|
||||
TPrimanota_application& a = app();
|
||||
if (a._as400)
|
||||
@ -1205,14 +1207,14 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k)
|
||||
|
||||
if (k == K_SPACE)
|
||||
{
|
||||
oldimp = real(row.get(0)); // Imponibile
|
||||
oldiva = real(row.get(3)); // Imposta
|
||||
oldimp = a.real2imp(real(row.get(0)), 'I'); // Imponibile
|
||||
oldiva = a.real2imp(real(row.get(3)), 'I'); // Imposta
|
||||
|
||||
if (oldiva.is_zero() && cau.corrispettivi()) // In caso di corrispettivi ...
|
||||
if (oldiva.is_zero() && cau.corrispettivi()) // In caso di corrispettivi ...
|
||||
{
|
||||
const TString zanicchi(row.get(1)); // Codice IVA
|
||||
const TString zanicchi(row.get(1)); // Codice IVA
|
||||
const TCodiceIVA i(zanicchi);
|
||||
oldiva = i.scorpora(oldimp); // ... scorpora imposta dall'imponibile
|
||||
oldiva.valore() = i.scorpora(oldimp.valore()); // ... scorpora imposta dall'imponibile
|
||||
}
|
||||
|
||||
const char tipod = detraibile(row) ? 'D' : 'N';
|
||||
@ -1220,12 +1222,12 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k)
|
||||
|
||||
if (oldposiva < 0 && !oldiva.is_zero())
|
||||
{
|
||||
const int ri = tipod == 'D' ? 3 : 4; // Calcola riga causale per l'IVA
|
||||
const int ri = tipod == 'D' ? 3 : 4; // Calcola riga causale per l'IVA
|
||||
TBill c; cau.bill(ri, c);
|
||||
if (c.ok())
|
||||
{
|
||||
const TString80 d(cau.desc_agg(ri));
|
||||
oldposiva = a.set_cgs_row(-1, app().real2imp(ZERO, 'I'), c, d, tipod);
|
||||
oldposiva = a.set_cgs_row(-1, a.real2imp(ZERO, 'I'), c, d, tipod);
|
||||
}
|
||||
else
|
||||
if (ri == 4) // Se non esiste il conto IVA indetraibile ...
|
||||
@ -1260,14 +1262,14 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k)
|
||||
if (oldpos >= 0) // Se il conto esisteva anche prima ...
|
||||
{ // sottrai il vecchio imponibile
|
||||
TImporto i(a.get_cgs_imp(oldpos));
|
||||
i.valore() -= oldimp;
|
||||
i -= oldimp;
|
||||
a.set_cgs_imp(oldpos, i);
|
||||
if (i.is_zero()) delimp = oldpos;
|
||||
}
|
||||
if (oldposiva >= 0) // Se conto IVA esisteva anche prima ...
|
||||
{ // sottrai la vecchia imposta
|
||||
TImporto i(a.get_cgs_imp(oldposiva));
|
||||
i.valore() -= oldiva;
|
||||
i -= oldiva;
|
||||
a.set_cgs_imp(oldposiva, i);
|
||||
if (i.is_zero()) deliva = oldposiva;
|
||||
}
|
||||
@ -1297,6 +1299,8 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k)
|
||||
imposta = 0.0;
|
||||
}
|
||||
|
||||
const TImporto newimp = a.real2imp(imponibile, 'I');
|
||||
|
||||
// Aggiorna conto sulla riga contabile
|
||||
if (newpos < 0)
|
||||
{
|
||||
@ -1306,24 +1310,22 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k)
|
||||
if (deliva > delimp) deliva--;
|
||||
}
|
||||
|
||||
const TImporto val(a.real2imp(imponibile, 'I'));
|
||||
if (conto.ok() && !val.is_zero()) // Se c'e' imponibile ...
|
||||
if (conto.ok() && !newimp.is_zero()) // Se c'e' imponibile ...
|
||||
{ // crea una nuova riga contabile
|
||||
const TString d(cau.desc_agg(2));
|
||||
a.set_cgs_row(-1, val, conto, d, 'I');
|
||||
a.set_cgs_row(-1, newimp, conto, d, 'I');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TImporto val(a.real2imp(imponibile, 'I'));
|
||||
const bool empty = a.add_cgs_imp(newpos, val);
|
||||
const bool empty = a.add_cgs_imp(newpos, newimp);
|
||||
if (empty) // Se la riga si e' azzerata ...
|
||||
{ // ... cancellala
|
||||
a.reset_cgs_row(newpos);
|
||||
newpos = -1;
|
||||
}
|
||||
}
|
||||
oldimp = imponibile;
|
||||
oldimp = newimp;
|
||||
oldpos = newpos;
|
||||
|
||||
// Aggiorna conto IVA sulla riga contabile
|
||||
@ -1334,19 +1336,18 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k)
|
||||
if (deliva >= 0 && newposiva != deliva) // E' cambiato il tipo d'imposta
|
||||
a.reset_cgs_row(deliva); // Azzera il vecchio tipo se necessario
|
||||
|
||||
const TImporto newiva = a.real2imp(imposta, 'I');
|
||||
if (newposiva < 0)
|
||||
{
|
||||
if (!imposta.is_zero()) // Se c'e' imposta ...
|
||||
{ // ... crea nuova riga per l'IVA
|
||||
const TImporto val(a.real2imp(imposta, 'I'));
|
||||
const TString d(cau.desc_agg(ri));
|
||||
newposiva = a.set_cgs_row(-1, val, contoiva, d, tipod);
|
||||
newposiva = a.set_cgs_row(-1, newiva, contoiva, d, tipod);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const TImporto val(a.real2imp(imposta, 'I'));
|
||||
const bool empty = a.add_cgs_imp(newposiva, val);
|
||||
const bool empty = a.add_cgs_imp(newposiva, newiva);
|
||||
if (empty) // Se l'imposta si e' azzerata ...
|
||||
{
|
||||
a.reset_cgs_row(newposiva); // ... cancellala
|
||||
@ -1354,7 +1355,7 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k)
|
||||
}
|
||||
}
|
||||
|
||||
oldiva = imposta;
|
||||
oldiva = newiva;
|
||||
oldposiva = newposiva;
|
||||
|
||||
TMask& m = a.curr_mask();
|
||||
@ -1663,20 +1664,22 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
|
||||
return f.error_box("La data dell'operazione e' superiore quella di sistema");
|
||||
|
||||
TPrimanota_application& a = app();
|
||||
TLibro_giornale& gio = a.giornale();
|
||||
|
||||
const int ae = a._esercizi.date2esc(dr); // Anno esercizio
|
||||
|
||||
const int ae = a._esercizi.date2esc(dr); // Codice esercizio
|
||||
if (ae <= 0)
|
||||
return f.error_box("La data dell'operazione non appartiene a nessun esercizio");
|
||||
|
||||
if (m.query_mode() || gio.year() != ae)
|
||||
ok = gio.read(ae);
|
||||
|
||||
TLibro_giornale& gio = a.giornale();
|
||||
const int ar = dr.year(); // Anno per registri
|
||||
if (m.query_mode() || gio.year() != ar)
|
||||
{
|
||||
ok = gio.read(ar);
|
||||
if (!ok)
|
||||
return f.error_box("Non esiste il libro giornale del %d", ar);
|
||||
}
|
||||
else
|
||||
ok = TRUE;
|
||||
|
||||
if (!ok)
|
||||
return f.error_box("Non esiste il libro giornale dell'esercizio %d", ae);
|
||||
|
||||
if (key == K_ENTER || f.focusdirty())
|
||||
{
|
||||
const long numreg = m.get_long(F_NUMREG);
|
||||
@ -1687,26 +1690,26 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
|
||||
if (dr < gio.last_print())
|
||||
{
|
||||
f.error_box("La data dell'operazione e' antecedente al %s,\n"
|
||||
"ultima stampa del libro giornale dell'esercizio %d",
|
||||
gio.last_print().string(), ae);
|
||||
"ultima stampa del libro giornale del %d",
|
||||
gio.last_print().string(), ar);
|
||||
if (error) return FALSE;
|
||||
}
|
||||
if (key == K_TAB && dr < gio.last_reg())
|
||||
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);
|
||||
"ultima registrazione sul libro giornale del %d",
|
||||
gio.last_reg().string(), ar);
|
||||
}
|
||||
|
||||
if (m.query_mode())
|
||||
a.read_caus(m.get(F_CODCAUS), dr.year());
|
||||
a.read_caus(m.get(F_CODCAUS), ar);
|
||||
|
||||
TRegistro& reg = a.causale().reg();
|
||||
const TString codreg(reg.name());
|
||||
if (codreg.not_empty())
|
||||
{
|
||||
if (reg.year() != dr.year())
|
||||
if (reg.year() != ar)
|
||||
{
|
||||
const bool ok = reg.read(codreg, dr.year());
|
||||
const bool ok = reg.read(codreg, ar);
|
||||
if (!ok) return FALSE;
|
||||
a.read_caus(NULL, 0);
|
||||
if (a.iva() != nessuna_iva)
|
||||
@ -1718,14 +1721,14 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
|
||||
if (dr < reg.last_print())
|
||||
{
|
||||
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());
|
||||
"ultima stampa del registro '%s' del %d",
|
||||
reg.last_print().string(), (const char*)codreg, ar);
|
||||
if (error) return FALSE;
|
||||
}
|
||||
if (key == K_TAB && dr < reg.last_reg())
|
||||
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());
|
||||
"ultima registrazione sul registro '%s' del %d",
|
||||
reg.last_reg().string(), (const char*)codreg, ar);
|
||||
}
|
||||
|
||||
if (reg.iva() != nessuna_iva && a._rel->controlla_liquidazione(dr, reg) == TRUE)
|
||||
@ -1856,16 +1859,16 @@ bool TPrimanota_application::datadoc_handler(TMask_field& f, KEY key)
|
||||
|
||||
bool TPrimanota_application::occas_code_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
if (key == K_TAB)
|
||||
TMask& m = f.mask();
|
||||
if (key == K_TAB && (f.dirty() || !m.is_running()))
|
||||
{
|
||||
const char* code = f.get();
|
||||
if (*code)
|
||||
const TString& code = f.get();
|
||||
if (code.not_empty())
|
||||
{
|
||||
TRelation occas(LF_OCCAS);
|
||||
occas.curr().put("CFPI", code);
|
||||
if (occas.read(_isequal) == NOERR)
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
m.autoload(occas);
|
||||
m.send_key(K_TAB, O_COMUNE); // Forza decodifica comuni
|
||||
m.send_key(K_TAB, O_COMUNENAS);
|
||||
@ -2401,9 +2404,9 @@ bool TPrimanota_application::corrvaluta_handler(TMask_field& f, KEY key)
|
||||
|
||||
bool TPrimanota_application::activate_numrif(bool init_pag)
|
||||
{
|
||||
CHECK(iva() != nessuna_iva, "Non esiste il numero riferimento in questa maschera!");
|
||||
TMask& m = curr_mask();
|
||||
|
||||
CHECK(_msk[2] != NULL, "Null saldaconto mask");
|
||||
TMask& m = *_msk[2];
|
||||
|
||||
bool shown = is_saldaconto(); // Il numero riferimento esiste
|
||||
|
||||
if (shown)
|
||||
|
@ -227,11 +227,13 @@ bool TLibro_giornale::read(int y)
|
||||
TString16 anno; anno.format("%04d", y);
|
||||
TTable reg("REG");
|
||||
reg.setkey(1);
|
||||
reg.put("CODTAB", anno); // Cerca il primo registro dell'anno y
|
||||
reg.put("CODTAB", anno); // Cerca il primo registro dell'anno
|
||||
|
||||
for (int err = reg.read(_isgteq); err == NOERR; err = reg.next())
|
||||
{
|
||||
//if (reg.get("CODTAB").compare(anno, 4) != 0) break;
|
||||
if (reg.get("CODTAB").compare(anno, 4) != 0)
|
||||
break; // Sono arrivato all'anno dopo
|
||||
|
||||
if (reg.get_int("I0") == libro_giornale)
|
||||
{
|
||||
found = TRUE;
|
||||
@ -337,7 +339,7 @@ bool TCausale::read(const char* cod, int year)
|
||||
const TString codreg(caus.get(CAU_REG));
|
||||
const bool ok = _reg.read(codreg, year); // Read register
|
||||
if (!ok && codreg.not_empty())
|
||||
return error_box("Non esiste il registro '%s' per l'anno %d",
|
||||
return error_box("Non esiste il registro '%s' del %d",
|
||||
(const char*)codreg, year);
|
||||
calcIVA();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user