Corretta gestione ini in banche clifo

git-svn-id: svn://10.65.10.50/branches/R_10_00@22933 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2014-05-14 08:25:17 +00:00
parent bbd81dbc13
commit e9f6cac415
7 changed files with 164 additions and 98 deletions

View File

@ -575,7 +575,7 @@ HIDDEN bool codalleg_handler(TMask_field& f, KEY key)
return error_box(TR("Codice non utilizzabile: partita IVA e codice fiscale non specificati")); return error_box(TR("Codice non utilizzabile: partita IVA e codice fiscale non specificati"));
const int tipoall = clifo.get_int(CLI_ALLEG); const int tipoall = clifo.get_int(CLI_ALLEG);
if (tipoall != 0 && tipoall != 1 && tipoall != 4 && tipoall != 6) if (tipoall != 0 && tipoall != 1 && tipoall != 4 && tipoall != 6 && tipoall != 7)
return error_box(TR("Codice non utilizzabile: codice inserimento allegato non corretto")); return error_box(TR("Codice non utilizzabile: codice inserimento allegato non corretto"));
} }
return true; return true;
@ -984,10 +984,8 @@ void TClifo_application::ini2mask(TConfig& ini, TMask& m, bool query)
field_sheet(F_CODINDSP).add(riga); field_sheet(F_CODINDSP).add(riga);
field_sheet(F_CODINDEFF).add(riga); field_sheet(F_CODINDEFF).add(riga);
} }
}
} }
TString p; TString p;
p << LF_CFBAN << ",V"; p << LF_CFBAN << ",V";
TSheet_field & ns_sh = m.sfield(F_BANA); TSheet_field & ns_sh = m.sfield(F_BANA);
@ -1000,14 +998,15 @@ void TClifo_application::ini2mask(TConfig& ini, TMask& m, bool query)
TToken_string & row = ns_sh.row(i); TToken_string & row = ns_sh.row(i);
row.add(abi, ns_sh.cid2index(F_BBAN_ABI)); row.add(abi, ns_sh.cid2index(F_BBAN_ABI));
row.add(ini.get(CFBAN_CAB, para), ns_sh.cid2index(F_BBAN_CAB)); row.add(ini.get(CFBAN_CAB), ns_sh.cid2index(F_BBAN_CAB));
row.add(ini.get(CFBAN_NUMCC, para), ns_sh.cid2index(F_BBAN_CONTO)); row.add(ini.get(CFBAN_NUMCC), ns_sh.cid2index(F_BBAN_CONTO));
const TString & iban = ini.get(CFBAN_IBAN, para); const TString & iban = ini.get(CFBAN_IBAN);
row.add(iban, ns_sh.cid2index(F_IBAN)); row.add(iban, ns_sh.cid2index(F_IBAN));
ns_sh.update_mask(i - 1); ns_sh.update_mask(i);
} }
p.cut(0); p.cut(0);
p << LF_CFBAN << ",N"; p << LF_CFBAN << ",N";
TSheet_field & vs_sh = m.sfield(F_BANP); TSheet_field & vs_sh = m.sfield(F_BANP);
@ -1022,9 +1021,10 @@ void TClifo_application::ini2mask(TConfig& ini, TMask& m, bool query)
TToken_string & row = vs_sh.row(i); TToken_string & row = vs_sh.row(i);
row.add(abi, vs_sh.cid2index(F_BBAN_ABI)); row.add(abi, vs_sh.cid2index(F_BBAN_ABI));
row.add(ini.get(CFBAN_CAB, para), vs_sh.cid2index(F_BBAN_CAB)); row.add(ini.get(CFBAN_CAB), vs_sh.cid2index(F_BBAN_CAB));
row.add(ini.get(CFBAN_PROGPR, para), vs_sh.cid2index(F_PROGPR)); row.add(ini.get(CFBAN_PROGPR), vs_sh.cid2index(F_PROGPR));
vs_sh.update_mask(i - 1); vs_sh.update_mask(i);
}
} }
} }

View File

@ -595,37 +595,9 @@ BEGIN
GROUP 5 GROUP 5
END END
STRING F_COMNASC 4
BEGIN
PROMPT 2 18 "Comune "
FIELD COMNASC
FLAGS "U"
COPY USE F_COMCF
INPUT STATO ""
INPUT COM F_COMNASC
COPY DISPLAY F_COMCF
OUTPUT F_COMNASC COM
OUTPUT F_DENCOMNASC DENCOM
HELP "Codice del comune di nascita del cliente/fornitore"
CHECKTYPE NORMAL
WARNING "Comune assente"
ADD RUN ba4 -0
END
STRING F_DENCOMNASC 50
BEGIN
PROMPT 23 18 ""
USE LF_COMUNI KEY 2
INPUT DENCOM F_DENCOMNASC
COPY DISPLAY F_DENCOMCF
COPY OUTPUT F_COMNASC
HELP "Nome del comune di nascita"
ADD RUN ba4 -0
END
NUMBER F_STATONASC 3 NUMBER F_STATONASC 3
BEGIN BEGIN
PROMPT 2 19 "Stato " PROMPT 2 18 "Stato "
FIELD STATONASC FIELD STATONASC
FLAGS "Z" FLAGS "Z"
USE %STA USE %STA
@ -641,7 +613,7 @@ END
STRING F_DESTANASC 50 STRING F_DESTANASC 50
BEGIN BEGIN
PROMPT 23 19 "" PROMPT 23 18 ""
USE %STA KEY 2 USE %STA KEY 2
INPUT S0 F_DESTANASC INPUT S0 F_DESTANASC
DISPLAY "Stato@60" S0 DISPLAY "Stato@60" S0
@ -649,6 +621,33 @@ BEGIN
COPY OUTPUT F_STATONASC COPY OUTPUT F_STATONASC
END END
STRING F_COMNASC 4
BEGIN
PROMPT 2 19 "Comune "
FIELD COMNASC
FLAGS "U"
COPY USE F_COMCF
INPUT STATO F_STATONASC SELECT
INPUT COM F_COMNASC
COPY DISPLAY F_COMCF
OUTPUT F_COMNASC COM
OUTPUT F_DENCOMNASC DENCOM
HELP "Codice del comune di nascita"
CHECKTYPE NORMAL
WARNING "Comune assente"
ADD RUN ba4 -0
END
STRING F_DENCOMNASC 50
BEGIN
PROMPT 23 19 ""
USE LF_COMUNI KEY 2
INPUT DENCOM F_DENCOMNASC
COPY DISPLAY F_DENCOMCF
COPY OUTPUT F_COMNASC
HELP "Nome del comune di nascita"
ADD RUN ba4 -0
END
ENDPAGE ENDPAGE

View File

@ -555,19 +555,21 @@ HIDDEN bool imptot_error(const TImporto& imptot, const TImporto& impsal, bool va
msg << TR("Il totale documento in valuta") << ' ' << codval; msg << TR("Il totale documento in valuta") << ' ' << codval;
else else
msg << TR("Il totale documento inserito"); msg << TR("Il totale documento inserito");
msg << TR(" e' ") << euro.string(true) << ' ' << imptot.sezione() << ",\n"; msg << TR(" è ") << euro.string(true) << ' ' << imptot.sezione() << ",\n";
euro.set_num(cassa.valore()); euro.set_num(cassa.valore());
msg << TR("i pagamenti e le spese ammontano a ") msg << TR("i pagamenti e le spese ammontano a ")
<< euro.string(true) << ' ' << cassa.sezione() << ",\n"; << euro.string(true) << ' ' << cassa.sezione() << ",\n";
euro.set_num(residuo.valore()); euro.set_num(residuo.valore());
msg << TR("per cui il residuo e' ") << euro.string(true); msg << TR("per cui il residuo è ") << euro.string(true);
if (m.edit_mode() && impsal.is_zero()) if (impsal.is_zero())
{ {
/* fastidioso per Pragma
msg << TR("\nSi desidera registrare ugualmente?"); msg << TR("\nSi desidera registrare ugualmente?");
ok = a.cgs().yesno_box(msg); ok = a.cgs().yesno_box(msg);
*/
} }
else else
ok = a.cgs().error_box(msg); ok = a.cgs().error_box(msg);
@ -592,7 +594,7 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
const TRectype& rec = cache().get("%VAL", TCurrency::get_firm_val()); const TRectype& rec = cache().get("%VAL", TCurrency::get_firm_val());
const char* name = rec.get("S0"); const char* name = rec.get("S0");
return f.error_box(FR("Il movimento e' sbilanciato di %s %s."), ss, name); return f.error_box(FR("Il movimento è sbilanciato di %s %s."), ss, name);
} }
TMask& m = f.mask(); TMask& m = f.mask();
@ -666,7 +668,7 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
{ {
TString msg(128); TString msg(128);
const TCurrency euro(speso.valore()); const TCurrency euro(speso.valore());
msg.format("L'importo sul saldaconto della riga %d e' %s", currig, (const char*)euro.string(true)); msg.format("L'importo sul saldaconto della riga %d è %s", currig, (const char*)euro.string(true));
if (!speso.is_zero()) if (!speso.is_zero())
msg << (speso.sezione() == 'A' ? TR(" Avere") : TR(" Dare")); msg << (speso.sezione() == 'A' ? TR(" Avere") : TR(" Dare"));

View File

@ -2042,8 +2042,8 @@ void TMastrini_grid::on_record_button(long rec)
{ {
_primanoting = true; _primanoting = true;
const TRectype& testata = _mastrino.testata(rec); const TRectype& testata = _mastrino.testata(rec);
bool refresh = testata.edit(); testata.edit();
if (refresh && yesno_box(TR("Si desidera aggiornare il mastrino?"))) if (yesno_box(TR("Si desidera aggiornare il mastrino?")))
reread(); reread();
_primanoting = false; _primanoting = false;
} }

View File

@ -155,6 +155,7 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
// Ritorna FALSE soltanto se il ricalcolo era necessario e non e' // Ritorna FALSE soltanto se il ricalcolo era necessario e non e'
// stato effettuato per scelta dello stronzo commercialista. // stato effettuato per scelta dello stronzo commercialista.
// Gestione IVA differita, da non confondere con _isdifferita
_isdiff = ini_get_bool(CONFIG_DITTA, "cg", "GesLiqDiff"); _isdiff = ini_get_bool(CONFIG_DITTA, "cg", "GesLiqDiff");
if (month == 13 && recalc) if (month == 13 && recalc)
@ -171,7 +172,7 @@ bool TLiquidazione_app::update_firm(int month, bool recalc)
look_lim(liq_month(month), true); look_lim(liq_month(month), true);
_isdiffacc = is_acconto_differito(); // Gestione differimento acconto IVA _isdiffacc = is_acconto_differito(); // Gestione differimento acconto IVA
_isdifferita = _isdiffacc; // Gestione IVA differita con stesso flag! _isdifferita = _isdiffacc;
look_lia(); look_lia();
_isintr = _freqviva == "T" && !_lia->get_bool("B3"); // was CNF_DITTA->InTrtr _isintr = _freqviva == "T" && !_lia->get_bool("B3"); // was CNF_DITTA->InTrtr
@ -563,7 +564,8 @@ void TLiquidazione_app::zero_att(int month, const char* codatt)
zero_diff(month,codatt); zero_diff(month,codatt);
} }
bool TLiquidazione_app::ivadiff_chiusa(const TRectype& mov, const TDate& fine) const /*
static bool ivadiff_chiusa_old(const TRectype& mov, const TDate& fine)
{ {
const long numreg = mov.get_long(MOV_NUMREG); const long numreg = mov.get_long(MOV_NUMREG);
@ -591,6 +593,50 @@ bool TLiquidazione_app::ivadiff_chiusa(const TRectype& mov, const TDate& fine) c
const bool chiusa = some_pag && tot.valore() < 0.01; const bool chiusa = some_pag && tot.valore() < 0.01;
return chiusa; return chiusa;
} }
*/
static bool ivadiff_chiusa_new(const TRectype& mov, const TDate& fine)
{
bool chiusa = false;
const long numreg = mov.get_long(MOV_NUMREG);
TLocalisamfile id(LF_IVADIFF);
TRectype& rid = id.curr();
rid.put(MOV_NUMREG, numreg);
int err = id.read(_isgteq);
if (err == NOERR && rid.get_long(MOV_NUMREG) == numreg)
{
chiusa = id.get_bool("CHIUSA");
if (chiusa)
{
bool some_pag = false; // Ci sono pagamenti?
TImporto tot;
for (; err == NOERR && rid.get_long(MOV_NUMREG) == numreg; err = id.next())
{
const TDate data = rid.get("DATAREGP");
if (data > fine)
continue;
const real imp = rid.get(RMI_IMPOSTA);
if (!imp.is_zero())
{
const char sez = rid.get_char("SEZIONE");
tot += TImporto(sez, imp);
if (rid.get_int(MOV_TIPOMOV) > 1)
some_pag = true;
}
}
chiusa = some_pag && tot.valore() < 0.01;
}
}
return chiusa;
}
bool TLiquidazione_app::ivadiff_chiusa(const TRectype& mov, const TDate& fine) const
{
bool cnew = ivadiff_chiusa_new(mov, fine);
//bool cold = ivadiff_chiusa_old(mov, fine);
// CHECK(cold == cnew, "Cazzo");
return cnew;
}
// Fattura più vecchia di un anno a ente NON pubblico // Fattura più vecchia di un anno a ente NON pubblico
bool TLiquidazione_app::sarebbe_da_pagare(const TRectype& mov, const TDate& fine) const bool TLiquidazione_app::sarebbe_da_pagare(const TRectype& mov, const TDate& fine) const
@ -1060,6 +1106,10 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
if (movdiff && tm == tm_fattura) if (movdiff && tm == tm_fattura)
{ {
const bool id_chiusa = ivadiff_chiusa(_mov->curr(), inizio);
if (!dok && id_chiusa)
continue; // Salta vecchi movimenti differiti già chiusi
// Sezione preferita per fatture decisa in base a vendita->'A' o acquisto->'D' // Sezione preferita per fatture decisa in base a vendita->'A' o acquisto->'D'
const char sezfat = tipomov == vendita ? 'D' : 'A'; const char sezfat = tipomov == vendita ? 'D' : 'A';
const char sezpag = tipomov == vendita ? 'A' : 'D'; const char sezpag = tipomov == vendita ? 'A' : 'D';
@ -1074,7 +1124,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
const TPartita* p = arrpart.first(); const TPartita* p = arrpart.first();
const int row = p ? p->mov2rig(numreg, 0) : 0; const int row = p ? p->mov2rig(numreg, 0) : 0;
game_found = row > 0; game_found = row > 0;
if (game_found && !ivadiff_chiusa(_mov->curr(), inizio)) // 25-02-2014 sostituito inizio al posto di fine if (game_found && !id_chiusa) // 25-02-2014 sostituito inizio al posto di fine
{ {
const TRiga_partite& rp = p->riga(row); const TRiga_partite& rp = p->riga(row);
TImporto pg, nc; TImporto pg, nc;
@ -1462,7 +1512,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
//qui da verificare //qui da verificare
if ((imponibile.is_zero() && imposta.is_zero()) && if ((imponibile.is_zero() && imposta.is_zero()) &&
(_isdiff && (movdiff &&
(is_detraibile > 0 || (is_detraibile > 0 ||
(diff_imp.is_zero() && diff_iva.is_zero() && (diff_imp.is_zero() && diff_iva.is_zero() &&
incdiff_imp.is_zero() && incdiff_iva.is_zero()) incdiff_imp.is_zero() && incdiff_iva.is_zero())
@ -1482,7 +1532,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
// Cumula l'ammontare delle operazioni attive/passive // Cumula l'ammontare delle operazioni attive/passive
// per la dichiarazione annuale fati iva // per la dichiarazione annuale dati iva e quadro VT
if (month == 13 && !fattrit) if (month == 13 && !fattrit)
{ {
if (tipomov == vendita) if (tipomov == vendita)
@ -1512,23 +1562,27 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt)
key << "|" << clifo.get(CLI_COMCF); key << "|" << clifo.get(CLI_COMCF);
} }
const TRectype & comune = cache().get(LF_COMUNI, key); const TRectype& comune = cache().get(LF_COMUNI, key);
codreg = comune.get_int(COM_CODREG) + 1; codreg = comune.get_int(COM_CODREG) + 1;
} }
if (movdiff)
{
vt_imponibile[codreg] += incdiff_imp;
vt_imposta[codreg] += incdiff_iva;
}
else
{
vt_imponibile[codreg] += imponibile; vt_imponibile[codreg] += imponibile;
vt_imposta[codreg] += imposta; vt_imposta[codreg] += imposta;
} }
} }
}
const TString& iva_vpn = _iva->get(tipomov == vendita ? "S10" : "S11"); const TString& iva_vpn = _iva->get(tipomov == vendita ? "S10" : "S11");
if (iva_vpn.full()) if (iva_vpn.full())
{ {
if (_mov->get(MOV_ANNOIVA) != _year) if (_mov->get(MOV_ANNOIVA) == _year)
{
int cazzone = 2;
}
else
switch (tipomov) switch (tipomov)
{ {
case vendita: // CD1 - 1 2 3 4 case vendita: // CD1 - 1 2 3 4

View File

@ -379,7 +379,7 @@ const TString& cap2comune(const TString& cap, const TString& denom)
denominazione.upper(); denominazione.upper();
if (!denominazione.starts_with(pref)) if (!denominazione.starts_with(pref))
break; break;
const double fc = xvt_str_fuzzy_compare (up_denom, denominazione); const double fc = xvt_str_fuzzy_compare(up_denom, denominazione);
if (fc > cmp) if (fc > cmp)
{ {
cmp = fc; cmp = fc;

View File

@ -875,6 +875,14 @@ void TSaldo_agg::aggiorna(const TRectype& rmov, bool somma, bool scaricato)
const char sez = rmov.get_char(RMV_SEZIONE); const char sez = rmov.get_char(RMV_SEZIONE);
const TImporto importo(sez, imp); const TImporto importo(sez, imp);
const TBill bill(rmov); const TBill bill(rmov);
const long numreg = rmov.get_long(RMV_NUMREG);
if (numreg > _num_ulmov)
{
_num_ulmov = numreg;
_data_ulmov = rmov.get_date(RMV_DATAREG);
_anno_es = rmov.get_int(RMV_ANNOES);
}
aggiorna(bill, importo, somma, scaricato); aggiorna(bill, importo, somma, scaricato);
} }
} }
@ -945,8 +953,8 @@ void TSaldo_agg::registra()
{ {
THash_object* hobj = _tab_conti.get_hashobj(); THash_object* hobj = _tab_conti.get_hashobj();
TContoExt& tcon = (TContoExt&)hobj->obj(); TContoExt& tcon = (TContoExt&)hobj->obj();
CHECK(tcon.ok(), "Tentativo di saldare un conto incompleto");
const int annoes = atoi(hobj->key().left(4)); const int annoes = atoi(hobj->key().left(4));
CHECK(tcon.ok() && annoes > 2000, "Tentativo di saldare un conto incompleto");
saldi.zero(); saldi.zero();
saldi.put(SLD_ANNOES, annoes); saldi.put(SLD_ANNOES, annoes);
@ -1005,13 +1013,16 @@ void TSaldo_agg::registra()
r = tcon.saldo(); r = tcon.saldo();
si = saldi.get_real(SLD_SALDO); si = saldi.get_real(SLD_SALDO);
flag_salini = saldi.get_char(SLD_FLAGSALINI); flag_salini = saldi.get_char(SLD_FLAGSALINI);
if (r != ZERO) if (!r.is_zero())
{ {
if (flag_salini == 'A') si = r - si; if (flag_salini == 'A')
else si += r; si = r - si;
else
si += r;
if (si < ZERO) if (si < ZERO)
{ {
flag_salini = 'A'; si = -si; flag_salini = 'A';
si = -si;
} }
else else
flag_salini = 'D'; flag_salini = 'D';