Eliminati automatismi su movimenti trasferit da AS/400

git-svn-id: svn://10.65.10.50/trunk@2646 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-02-27 11:32:35 +00:00
parent beb6376b71
commit 5d08350c49
4 changed files with 105 additions and 44 deletions

View File

@ -273,7 +273,8 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
if (iva == nessuna_iva) if (iva == nessuna_iva)
{ {
m->enable(F_PROVVISORIO, !_is_saldaconto); // Il saldaconto vieta i movimenti provvisori m->enable(F_PROVVISORIO, !_is_saldaconto); // Il saldaconto vieta i movimenti provvisori
m->show(SK_TIPORIGA, is_pagamento()); m->show(SK_TIPORIGA, is_pagamento()); // Abilita scelta tipo riga
m->enable(SK_TIPORIGA);
} }
else else
{ {
@ -602,13 +603,38 @@ void TPrimanota_application::init_insert_mode(TMask& m)
} }
_saldi.reset(); // Inizializza saldi _saldi.reset(); // Inizializza saldi
_as400 = FALSE; // Un movimento nuovo non puo' essere trasferito da AS400
} }
void TPrimanota_application::init_modify_mode(TMask& m) void TPrimanota_application::init_modify_mode(TMask& m)
{ {
init_mask(m); init_mask(m); // Inizializzazione standard
calcola_saldo(); // Verifica eventuali sbilanci contabili calcola_saldo(); // Verifica eventuali sbilanci contabili
// Determina se il movimento e' stato trasferito da AS/400:
// praticamente controlla che non ci sia nessun tipo movimento sulle righe contabili.
_as400 = FALSE;
if (is_saldaconto() || iva() != nessuna_iva)
{
TSheet_field& cg = cgs();
if (cg.items() > 0)
{
_as400 = TRUE;
for (int i = cg.items()-1; i >= 0 && _as400; i--)
{
const char rt = row_type(cg.row(i));
_as400 = rt <= ' ';
}
}
}
if (_as400 && is_pagamento())
{
m.set(SK_TIPORIGA, "A"); // Forza il tipo riga normale
m.disable(SK_TIPORIGA); // Disabilita la sua modifica
}
} }
// Controlla sulla causale se il segno del totale documento (ritsoc=FALSE) // Controlla sulla causale se il segno del totale documento (ritsoc=FALSE)

View File

@ -442,14 +442,12 @@ bool TPrimanota_application::ci_sono_importi() const
real TPrimanota_application::calcola_saldo() const real TPrimanota_application::calcola_saldo() const
{ {
real tdare, tavere;
TImporto saldaconto;
const bool pag = is_pagamento() && !_as400;
TString_array& rows = cgs().rows_array(); TString_array& rows = cgs().rows_array();
const int max = rows.items(); const int max = rows.items();
TImporto saldaconto;
const bool pag = is_pagamento();
real tdare, tavere;
for (int i = 0; i < max; i++) for (int i = 0; i < max; i++)
{ {
TToken_string& r = rows.row(i); TToken_string& r = rows.row(i);
@ -550,6 +548,7 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
if (saldo != ZERO) if (saldo != ZERO)
{ {
const char* ss = saldo.string("."); const char* ss = saldo.string(".");
if (*ss == '-') ss++;
return f.error_box("Il movimento e' sbilanciato di %s lire.", ss); return f.error_box("Il movimento e' sbilanciato di %s lire.", ss);
} }
@ -583,11 +582,16 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
if (paga || nota) if (paga || nota)
{ {
const char tipo = row_type(r); const char tipo = row_type(r);
if (tipo == 'K' || tipo == 'T') if (tipo == 'K' || tipo == 'T' || a._as400)
{ {
const int currig = i+1; const int currig = i+1;
const TImporto speso = a.partite().importo_speso(numreg, currig); const TImporto speso = a.partite().importo_speso(numreg, currig);
if (importo != speso)
bool errato = importo != speso;
if (errato && a._as400 && speso.is_zero())
errato = FALSE;
if (errato)
{ {
TString msg(128); TString msg(128);
msg << "L'importo sulla riga " << currig << " deve essere " msg << "L'importo sulla riga " << currig << " deve essere "
@ -618,8 +622,7 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
if (empty) if (empty)
return f.error_box("Il movimento non ha nessuna riga contabile con un importo"); return f.error_box("Il movimento non ha nessuna riga contabile con un importo");
if ((paga || nota) && !a._as400)
if (paga || nota)
{ {
const char sez(a.causale().sezione(2)); const char sez(a.causale().sezione(2));
const TImporto totdoc(sez, m.get_real(F_TOTALE)); const TImporto totdoc(sez, m.get_real(F_TOTALE));
@ -676,14 +679,14 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
void TPrimanota_application::generazione_righe_cg(int r) void TPrimanota_application::generazione_righe_cg(int r)
{ {
begin_wait();
TSheet_field& cg = cgs(); TSheet_field& cg = cgs();
TToken_string& row = cg.row(r); TToken_string& row = cg.row(r);
if (can_remove(row)) // Ignora righe senza importo if (can_remove(row)) // Ignora righe senza importo
return; return;
begin_wait();
TImporto importo; importo = row; TImporto importo; importo = row;
const bool causale_ok = causale().codice()[0] > ' '; const bool causale_ok = causale().codice()[0] > ' ';
@ -997,6 +1000,8 @@ TSheet_field& TPrimanota_application::pags() const
// Gestione sheet IVA // Gestione sheet IVA
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Ritorna lo sheet delle righe IVA
// Certified 100%
TSheet_field& TPrimanota_application::ivas() const TSheet_field& TPrimanota_application::ivas() const
{ {
TSheet_field& s = (TSheet_field&)_msk[2]->field(F_SHEETIVA); TSheet_field& s = (TSheet_field&)_msk[2]->field(F_SHEETIVA);
@ -1016,6 +1021,8 @@ TBill& TPrimanota_application::ivas_bill(TBill& c)
return c; return c;
} }
// Gestione del campo imponibile sullo sheet iva
// Certified 90%
bool TPrimanota_application::imponibile_handler(TMask_field& f, KEY key) bool TPrimanota_application::imponibile_handler(TMask_field& f, KEY key)
{ {
if (key == K_TAB && f.dirty()) if (key == K_TAB && f.dirty())
@ -1041,6 +1048,8 @@ bool TPrimanota_application::imponibile_handler(TMask_field& f, KEY key)
} }
// Gestione del codice IVA sullo sheet iva
// Certified 90%
bool TPrimanota_application::codiva_handler(TMask_field& f, KEY key) bool TPrimanota_application::codiva_handler(TMask_field& f, KEY key)
{ {
if (!suspended_handler(f, key)) if (!suspended_handler(f, key))
@ -1079,6 +1088,8 @@ bool TPrimanota_application::codiva_handler(TMask_field& f, KEY key)
return TRUE; return TRUE;
} }
// Gestione del codice detrazione sullo sheet iva
// Certified 90%
bool TPrimanota_application::detrazione_handler(TMask_field& f, KEY key) bool TPrimanota_application::detrazione_handler(TMask_field& f, KEY key)
{ {
if (key == K_TAB && f.dirty() && app().iva() == iva_acquisti) if (key == K_TAB && f.dirty() && app().iva() == iva_acquisti)
@ -1090,6 +1101,8 @@ bool TPrimanota_application::detrazione_handler(TMask_field& f, KEY key)
return TRUE; return TRUE;
} }
// Gestione del campo imposta sullo sheet iva
// Certified 90%
bool TPrimanota_application::imposta_handler(TMask_field& f, KEY key) bool TPrimanota_application::imposta_handler(TMask_field& f, KEY key)
{ {
if ((key == K_ENTER || key == K_TAB) && f.dirty()) if ((key == K_ENTER || key == K_TAB) && f.dirty())
@ -1155,6 +1168,8 @@ real TPrimanota_application::calcola_imp() const
return imponibili+imposte; return imponibili+imposte;
} }
// Elimina dallo sheet le righr iva senza importi (imponibile e imposta)
// Certified 99%
void TPrimanota_application::ivas_pack() void TPrimanota_application::ivas_pack()
{ {
TString_array& rows = ivas().rows_array(); TString_array& rows = ivas().rows_array();
@ -1179,8 +1194,11 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k)
static int oldpos,oldposiva; static int oldpos,oldposiva;
static real oldimp, oldiva; static real oldimp, oldiva;
TToken_string& row = iva.row(r);
TPrimanota_application& a = app(); TPrimanota_application& a = app();
if (a._as400)
return TRUE;
TToken_string& row = iva.row(r);
const TCausale& cau = a.causale(); const TCausale& cau = a.causale();
if (k == K_SPACE) if (k == K_SPACE)
@ -1519,30 +1537,31 @@ bool TPrimanota_application::num_handler(TMask_field& f, KEY key)
const long num = atol(f.get()); const long num = atol(f.get());
if (key == K_TAB && m.is_running() && num > 0) if (key == K_TAB && m.is_running() && num > 0)
{ {
const long max = app()._lastreg+1; TPrimanota_application& a = app();
const long max = a._lastreg+1;
app()._skip_giornale_check = FALSE; a._skip_giornale_check = FALSE;
app()._skip_bollato_check = FALSE; a._skip_bollato_check = FALSE;
if (num < max) if (num < max)
{ {
if (app().find(1)) if (a.find(1))
{ {
const TLocalisamfile& mov = app()._rel->lfile(); const TLocalisamfile& mov = a._rel->lfile();
bool ok = TRUE; bool ok = TRUE;
if (mov.get_bool("STAMPATO")) if (mov.get_bool("STAMPATO"))
{ {
ok = yesno_box("Il movimento e' gia' stato stampato sul libro giornale:\n" ok = yesno_box("Il movimento e' gia' stato stampato sul libro giornale:\n"
"si desidera continuare ugualmente"); "si desidera continuare ugualmente");
app()._skip_giornale_check = ok; a._skip_giornale_check = ok;
} }
if (ok && mov.get_bool("REGST")) if (ok && mov.get_bool("REGST"))
{ {
ok = yesno_box("Il movimento e' gia' stato stampato sul bollato:\n" ok = yesno_box("Il movimento e' gia' stato stampato sul bollato:\n"
"si desidera continuare ugualmente"); "si desidera continuare ugualmente");
app()._skip_bollato_check = ok; a._skip_bollato_check = ok;
} }
if (ok && mov.get_bool("INVIATO")) if (ok && mov.get_bool("INVIATO"))
@ -1651,12 +1670,13 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
if (key == K_ENTER || f.focusdirty()) if (key == K_ENTER || f.focusdirty())
{ {
TPrimanota_application& a = app();
const long numreg = m.get_long(F_NUMREG); const long numreg = m.get_long(F_NUMREG);
const bool error = numreg == 0 || numreg > app()._lastreg; const bool error = numreg == 0 || numreg > a._lastreg;
if (key != K_ENTER && !app()._skip_giornale_check) if (key != K_ENTER && !app()._skip_giornale_check)
{ {
const TLibro_giornale& gio = app().giornale(); const TLibro_giornale& gio = a.giornale();
if (dr < gio.last_print()) if (dr < gio.last_print())
{ {
f.error_box("La data dell'operazione e' antecedente al %s,\n" f.error_box("La data dell'operazione e' antecedente al %s,\n"
@ -1671,22 +1691,22 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
} }
if (m.query_mode()) if (m.query_mode())
app().read_caus(m.get(F_CODCAUS), dr.year()); a.read_caus(m.get(F_CODCAUS), dr.year());
TRegistro& reg = app().causale().reg(); TRegistro& reg = a.causale().reg();
const TString16 codreg(reg.name()); const TString codreg(reg.name());
if (codreg.not_empty()) if (codreg.not_empty())
{ {
if (reg.year() != dr.year()) if (reg.year() != dr.year())
{ {
const bool ok = reg.read(codreg, dr.year()); const bool ok = reg.read(codreg, dr.year());
if (!ok) return FALSE; if (!ok) return FALSE;
app().read_caus(NULL, 0); a.read_caus(NULL, 0);
if (app().iva() != nessuna_iva) if (a.iva() != nessuna_iva)
m.field(F_CODREG).on_hit(); m.field(F_CODREG).on_hit();
} }
if (!app()._skip_bollato_check) if (!a._skip_bollato_check)
{ {
if (dr < reg.last_print()) if (dr < reg.last_print())
{ {
@ -1701,7 +1721,7 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
reg.last_reg().string(), (const char*)codreg, dr.year()); reg.last_reg().string(), (const char*)codreg, dr.year());
} }
if (reg.iva() != nessuna_iva && app()._rel->controlla_liquidazione(dr, reg) == TRUE) if (reg.iva() != nessuna_iva && a._rel->controlla_liquidazione(dr, reg) == TRUE)
{ {
const char* const mese = itom(dr.month()); const char* const mese = itom(dr.month());
f.warning_box("La liquidazione IVA relativa al mese di %s e' gia' stata calcolata", mese); f.warning_box("La liquidazione IVA relativa al mese di %s e' gia' stata calcolata", mese);
@ -1745,7 +1765,7 @@ bool TPrimanota_application::datacomp_handler(TMask_field& f, KEY key)
const int pr = esc.pred(ar); // Esercizio precedente const int pr = esc.pred(ar); // Esercizio precedente
if (ae != ar && ae != pr) if (ae != ar && ae != pr)
{ {
TString80 e; TString e(80);
e << "La data " << data << " deve appartenere all'esercizio " << ar; e << "La data " << data << " deve appartenere all'esercizio " << ar;
if (pr > 0) e << " o al " << pr; if (pr > 0) e << " o al " << pr;
return f.error_box(e); return f.error_box(e);
@ -1786,7 +1806,7 @@ bool TPrimanota_application::numdoc_handler(TMask_field& f, KEY key)
TMask& m = f.mask(); TMask& m = f.mask();
if (key == K_TAB && f.to_check(key, TRUE) && m.insert_mode() && app().is_saldaconto()) if (key == K_TAB && f.to_check(key, TRUE) && m.insert_mode() && app().is_saldaconto())
{ {
const TString16 n = f.get(); const TString n = f.get();
if (n.not_empty() && !app().npart_is_prot()) // Copiare numero documento nel numero partita? if (n.not_empty() && !app().npart_is_prot()) // Copiare numero documento nel numero partita?
{ {
if (m.field(F_NUMRIF).active() && m.get(F_NUMRIF).blank()) if (m.field(F_NUMRIF).active() && m.get(F_NUMRIF).blank())
@ -1914,9 +1934,13 @@ void TPrimanota_application::add_cgs_tot(TMask& m)
} }
} }
if (!_as400)
{
// Creazione/Aggiornamento riga totale // Creazione/Aggiornamento riga totale
const real tot(m.get(F_TOTALE)); const real tot(m.get(F_TOTALE));
set_cgs_row(riga_totale, real2imp(tot, 'T'), nuovo, m.get(F_DESCR), 'T'); set_cgs_row(riga_totale, real2imp(tot, 'T'), nuovo, m.get(F_DESCR), 'T');
}
calcola_imp(); // Ricalcola totale IVA calcola_imp(); // Ricalcola totale IVA
calcola_saldo(); // Ricalcola sbilanci calcola_saldo(); // Ricalcola sbilanci
} }
@ -2209,6 +2233,9 @@ bool TPrimanota_application::totdocval_handler(TMask_field& f, KEY key)
// Certified 99% // Certified 99%
void TPrimanota_application::add_cgs_rit(bool fiscali) void TPrimanota_application::add_cgs_rit(bool fiscali)
{ {
if (_as400)
return;
TMask& m = curr_mask(); TMask& m = curr_mask();
const real imp(m.get(fiscali ? F_RITFIS : F_RITSOC)); // Determina importo const real imp(m.get(fiscali ? F_RITFIS : F_RITSOC)); // Determina importo
@ -2220,7 +2247,7 @@ void TPrimanota_application::add_cgs_rit(bool fiscali)
{ // crea una nuova riga di ritenute { // crea una nuova riga di ritenute
const int riga = fiscali ? RIGA_RITENUTE_FISCALI : RIGA_RITENUTE_SOCIALI; const int riga = fiscali ? RIGA_RITENUTE_FISCALI : RIGA_RITENUTE_SOCIALI;
TBill conto; causale().bill(riga, conto); TBill conto; causale().bill(riga, conto);
const TString80 desc(causale().desc_agg(riga)); const TString desc(causale().desc_agg(riga));
set_cgs_row(-1, real2imp(imp, tipo), conto, desc, tipo); set_cgs_row(-1, real2imp(imp, tipo), conto, desc, tipo);
} }
} }

View File

@ -56,6 +56,7 @@ class TPrimanota_application : public TRelation_application
TMask* _msk[4]; // Maschere di query, cg, iva, occasionali TMask* _msk[4]; // Maschere di query, cg, iva, occasionali
long _lastreg; // Numero ultima registrazione long _lastreg; // Numero ultima registrazione
int _mode; // Modo maschera corrente int _mode; // Modo maschera corrente
bool _as400; // Movimento trasferito da as400?
TDate _last_dreg; // Ultima data registrazione inserita TDate _last_dreg; // Ultima data registrazione inserita
TDate _last_dcom; // Ultima data competenza inserita TDate _last_dcom; // Ultima data competenza inserita

View File

@ -996,7 +996,9 @@ bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k)
const char tipo = m.get(CG_ROWTYPE)[0]; const char tipo = m.get(CG_ROWTYPE)[0];
const bool is_nota = tipo == 'T' && a.causale().tipomov() == 2 && cm.field(F_NUMRIF).active(); const bool is_nota = tipo == 'T' && a.causale().tipomov() == 2 && cm.field(F_NUMRIF).active();
if (tipo == 'K' || is_nota) const bool tras = a._as400 && a.causale().tipomov() > 1 && m.get(CG_TIPO).not_empty();
if (tipo == 'K' || is_nota || tras)
{ {
TSheet_field& s = *m.get_sheet(); TSheet_field& s = *m.get_sheet();
const int riga = s.selected(); const int riga = s.selected();
@ -1048,6 +1050,9 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
const int riga_contabile = somma.get_int(PART_NUMRIG); // Riga movimento const int riga_contabile = somma.get_int(PART_NUMRIG); // Riga movimento
TSheet_field& sheet = cgs(); TSheet_field& sheet = cgs();
if (_as400)
deleting = -1; // Ignora contropartite
if (deleting >= 0) if (deleting >= 0)
{ {
const char sez = somma.sezione(); // Sezione importo e ritenute const char sez = somma.sezione(); // Sezione importo e ritenute
@ -1105,7 +1110,7 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
if (empty) sheet.destroy(riga); if (empty) sheet.destroy(riga);
} }
} }
} // if (deleting != 0) } // if (deleting >= 0)
char old_ap, new_ap; char old_ap, new_ap;
TImporto old_abbuono, new_abbuono, old_diffcam, new_diffcam; TImporto old_abbuono, new_abbuono, old_diffcam, new_diffcam;
@ -1267,9 +1272,11 @@ bool TPrimanota_application::notify_cgline_deletion(TPartita& partita, long nreg
bool TPrimanota_application::notify_cgline_deletion(int numrig) bool TPrimanota_application::notify_cgline_deletion(int numrig)
{ {
bool found = FALSE; bool found = FALSE;
const long nreg = curr_mask().get_long(F_NUMREG); const long nreg = curr_mask().get_long(F_NUMREG);
partite().add_numreg(nreg); partite().add_numreg(nreg);
for (TPartita* game = partite().first(); game; game = partite().next()) for (TPartita* game = partite().first(); game; game = partite().next())
found |= notify_cgline_deletion(*game, nreg, numrig); found |= notify_cgline_deletion(*game, nreg, numrig);
return found; return found;
} }