Nuova gestione ritenute, reverse charge e split payment

git-svn-id: svn://10.65.10.50/branches/R_10_00@23120 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2015-07-10 14:50:35 +00:00
parent b3087bdca7
commit 4537d255f5
19 changed files with 3834 additions and 3721 deletions

View File

@ -639,7 +639,6 @@ HIDDEN bool contrlav_handler(TMask_field& f, KEY key)
} }
TString commandline; TString commandline;
commandline.format("lv0 -3 /i%s",(const char*)tempfile); commandline.format("lv0 -3 /i%s",(const char*)tempfile);
TExternal_app lv(commandline); TExternal_app lv(commandline);
@ -652,7 +651,7 @@ HIDDEN bool contrlav_handler(TMask_field& f, KEY key)
void TClifo_application::on_config_change() void TClifo_application::on_config_change()
{ {
TConfig cnf(CONFIG_DITTA); TConfig cnf(CONFIG_DITTA, "cg");
_gesven = !_has_cg || (cnf.get_bool("GesVen") || main_app().has_module(PAAUT)); _gesven = !_has_cg || (cnf.get_bool("GesVen") || main_app().has_module(PAAUT));
_gessal = !_has_cg || cnf.get_bool("GesSal"); _gessal = !_has_cg || cnf.get_bool("GesSal");
_lbcn = cnf.get_bool("GsLbCn"); _lbcn = cnf.get_bool("GsLbCn");

View File

@ -72,7 +72,7 @@ class TStampa_bilanci : public TPrintapp
TRelation* _rel; TRelation* _rel;
TCursor * _cur; TCursor * _cur;
TProgind * _prog; TProgress_monitor * _prog;
TSaldi_list* _listacf, * _lista; TSaldi_list* _listacf, * _lista;
TLocalisamfile* _com, * _pcn, * _mov, * _rmov, * _clifo, * _saldi, * _nditte,* _anag,* _caus; TLocalisamfile* _com, * _pcn, * _mov, * _rmov, * _clifo, * _saldi, * _nditte,* _anag,* _caus;
TIsamtempfile * _tmp_saldi_att, * _tmp_saldi_pass, * _tmp_saldi_conti_uno; TIsamtempfile * _tmp_saldi_att, * _tmp_saldi_pass, * _tmp_saldi_conti_uno;
@ -2488,7 +2488,7 @@ void TStampa_bilanci::crea_sort_clifo()
//serve solo per la progind: stima alla meno peggio //serve solo per la progind: stima alla meno peggio
if (_situazione.empty()) ncur /= 2; if (_situazione.empty()) ncur /= 2;
long nitems = ncur*(_clienti.items()+_fornitori.items()); long nitems = ncur*(_clienti.items()+_fornitori.items());
_prog = new TProgind(nitems,TR("Elaborazione in corso... prego attendere"),FALSE); _prog = new TProgress_monitor(nitems,TR("Elaborazione clienti/fornitori"),false);
_prog->addstatus(1); _prog->addstatus(1);
init_sort(); init_sort();
if (_situazione == "C") leggi_clifo(_clienti); if (_situazione == "C") leggi_clifo(_clienti);
@ -3695,7 +3695,7 @@ void TStampa_bilanci::stampa_un_bilancio(const TMask& m)
if (_bilancio == 1) //bilancio a sezioni contrapposte if (_bilancio == 1) //bilancio a sezioni contrapposte
{ {
printer().footerlen(3); printer().footerlen(3);
_prog = new TProgind(_pcn->items(),TR("Elaborazione in corso..."),FALSE); _prog = new TProgress_monitor(_pcn->items(),TR("Elaborazione conti"), false);
_totali = m.get_bool(F_TOTALI); _totali = m.get_bool(F_TOTALI);
_codici = m.get_bool(F_CODICI); _codici = m.get_bool(F_CODICI);
_saldo = m.get_bool(F_SALDO); _saldo = m.get_bool(F_SALDO);
@ -3726,7 +3726,7 @@ void TStampa_bilanci::stampa_un_bilancio(const TMask& m)
_verifica = m.get_int(F_VERIFICA); //tipo di bilancio di verifica da stampare _verifica = m.get_int(F_VERIFICA); //tipo di bilancio di verifica da stampare
_print_full_code = _verifica == 1 && m.get_bool(F_PRINT_FULL_CODE); _print_full_code = _verifica == 1 && m.get_bool(F_PRINT_FULL_CODE);
if ( (_verifica == 1)||(_verifica == 2) ) if ( (_verifica == 1)||(_verifica == 2) )
_prog = new TProgind(_pcn->items(),TR("Elaborazione in corso..."),FALSE); _prog = new TProgress_monitor(_pcn->items(),TR("Elaborazione conti"),false);
_tipo_stampa1 = m.get_int(F_STAMPA1); _tipo_stampa1 = m.get_int(F_STAMPA1);
if (_tipo_stampa1 == 1) if (_tipo_stampa1 == 1)
{ {

View File

@ -8,6 +8,7 @@
#include <execp.h> #include <execp.h>
#include <mailbox.h> #include <mailbox.h>
#include <modaut.h> #include <modaut.h>
#include <recset.h>
#include <urldefid.h> #include <urldefid.h>
#include <utility.h> #include <utility.h>
@ -94,6 +95,7 @@ TMask* TPrimanota_application::load_mask(int n)
m->set_handler(F_IVAXCASSA, ivaxcassa_handler); m->set_handler(F_IVAXCASSA, ivaxcassa_handler);
m->set_handler(F_OCCASEDIT, occas_handler); m->set_handler(F_OCCASEDIT, occas_handler);
m->set_handler(F_SOLAIVA, solaiva_handler); m->set_handler(F_SOLAIVA, solaiva_handler);
m->set_handler(F_REVCHARGE, revcharge_handler);
m->set_handler(F_SHEETIVA, iva_handler); m->set_handler(F_SHEETIVA, iva_handler);
m->show(F_LIQDIFF, _liqdiff); m->show(F_LIQDIFF, _liqdiff);
@ -397,7 +399,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
} }
else else
{ {
if (nriga >= 2 && nriga <= RIGA_IVA_PER_CASSA) if (nriga >= 2 && nriga <= RIGA_REVERSE_CHARGE)
continue; // Conti per IVA detraibile e non, ritenute sociali e fiscali continue; // Conti per IVA detraibile e non, ritenute sociali e fiscali
const char tipo = nriga == 1 ? 'T' : ' '; const char tipo = nriga == 1 ? 'T' : ' ';
@ -567,7 +569,8 @@ void TPrimanota_application::init_mask(TMask& m)
} }
else else
{ {
const bool corrisp = causale().corrispettivi(); const TCausale& cc = causale();
const bool corrisp = cc.corrispettivi();
bool clig = false, forg = false; bool clig = false, forg = false;
if (_iva == iva_acquisti) if (_iva == iva_acquisti)
@ -597,8 +600,8 @@ void TPrimanota_application::init_mask(TMask& m)
} }
// Show/Hide campi valuta: F_VALUTAINTRA, F_CAMBIOINTRA, F_CORRISPETTIVO, F_CORRVAL (GROUP 4) // Show/Hide campi valuta: F_VALUTAINTRA, F_CAMBIOINTRA, F_CORRISPETTIVO, F_CORRVAL (GROUP 4)
m.show(-4, causale().valintra()); m.show(-4, cc.valintra());
m.show(F_DATAINTRA, causale().intra()); m.show(F_DATAINTRA, cc.intra());
m.show(F_CODIVA, m.insert_mode()); // Codice IVA standard m.show(F_CODIVA, m.insert_mode()); // Codice IVA standard
@ -633,6 +636,11 @@ void TPrimanota_application::init_mask(TMask& m)
const TDate dr = m.get(F_DATAREG); const TDate dr = m.get(F_DATAREG);
ixc->enable(gestione_IVAxCassa(dr)); ixc->enable(gestione_IVAxCassa(dr));
} }
TEdit_field& rc = m.efield(F_REVCHARGE);
rc.show(cc.iva() == iva_acquisti && cc.reverse_charge());
activate_split_payment(m);
} }
// Show/Hide campi valuta: F_VALUTA, F_CAMBIO, F_DATACAMBIO (GROUP 3) // Show/Hide campi valuta: F_VALUTA, F_CAMBIO, F_DATACAMBIO (GROUP 3)
@ -966,6 +974,8 @@ void TPrimanota_application::init_modify_mode(TMask& m)
// Abilito il bottone di collegamento ai documenti se possibile // Abilito il bottone di collegamento ai documenti se possibile
const long numdoc = mov.get_long(MOV_DNDOC); const long numdoc = mov.get_long(MOV_DNDOC);
m.show(F_LINKDOC, numdoc > 0 && has_module(VEAUT)); m.show(F_LINKDOC, numdoc > 0 && has_module(VEAUT));
activate_split_payment(m);
} }
} }
@ -1535,7 +1545,7 @@ void TPrimanota_application::genera_automatico(int tipo, const char* causimm)
// Solo regolarizzazioni IVA // Solo regolarizzazioni IVA
if (_automatico->_tipo == 2) if (_automatico->_tipo == 2)
{ {
_automatico->_totale += m.get_real(F_RITFIS); _automatico->_totale += m.get_real(F_REVCHARGE);
_automatico->_codiva = m.get(F_CODIVA); _automatico->_codiva = m.get(F_CODIVA);
if (_automatico->_codiva.blank() && _rel->iva_items() > 0) if (_automatico->_codiva.blank() && _rel->iva_items() > 0)
_automatico->_codiva = _rel->iva(0).get(RMI_CODIVA); _automatico->_codiva = _rel->iva(0).get(RMI_CODIVA);

View File

@ -76,6 +76,7 @@
#define F_DATAINC 149 #define F_DATAINC 149
#define F_LIQDIFF 150 #define F_LIQDIFF 150
#define F_IVAXCASSA 167 #define F_IVAXCASSA 167
#define F_SPLITPAY 173
#define F_GRUPPO 180 #define F_GRUPPO 180
#define F_CONTO 181 #define F_CONTO 181

View File

@ -207,7 +207,7 @@ BEGIN
PROMPT 1 9 "Cliente " PROMPT 1 9 "Cliente "
FIELD CODCF FIELD CODCF
GROUP 1 GROUP 1
USE LF_CLIFO KEY 1 USE LF_CLIFO
INPUT TIPOCF "C" INPUT TIPOCF "C"
INPUT CODCF F_CLIENTE INPUT CODCF F_CLIENTE
DISPLAY "Codice" CODCF DISPLAY "Codice" CODCF
@ -233,7 +233,7 @@ BEGIN
PROMPT 1 9 "Fornitore " PROMPT 1 9 "Fornitore "
FIELD CODCF FIELD CODCF
GROUP 2 GROUP 2
USE LF_CLIFO KEY 1 USE LF_CLIFO
INPUT TIPOCF "F" INPUT TIPOCF "F"
INPUT CODCF F_FORNITORE INPUT CODCF F_FORNITORE
DISPLAY "Codice" CODCF DISPLAY "Codice" CODCF
@ -570,9 +570,19 @@ BEGIN
FIELD LIQDIFF FIELD LIQDIFF
MESSAGE FALSE CLEAR,F_DATAINC MESSAGE FALSE CLEAR,F_DATAINC
MESSAGE TRUE ENABLE,F_DATAINC MESSAGE TRUE ENABLE,F_DATAINC
FLAGS "H" FLAGS "HG"
END END
LIST F_SPLITPAY 1 2
BEGIN
PROMPT 51 18 "Scissione pagamenti "
FIELD SPLITPAY
ITEM "| "
ITEM "S|Si"
ITEM "N|No"
END
DATE F_DATAINC DATE F_DATAINC
BEGIN BEGIN
PROMPT 52 17 "Data incasso " PROMPT 52 17 "Data incasso "

View File

@ -47,3 +47,6 @@
#define S_MODOPAG 120 #define S_MODOPAG 120
#define S_NREG 121 #define S_NREG 121
#define S_NRIG 122 #define S_NRIG 122
#define S_BLOCCO 123
#define S_MOTIVO 124
#define S_NOTE 125

View File

@ -244,6 +244,9 @@ BEGIN
ITEM "Modalità di\npagamento@30" ITEM "Modalità di\npagamento@30"
ITEM "N.reg." ITEM "N.reg."
ITEM "N.riga" ITEM "N.riga"
ITEM "Blocco"
ITEM "Motivo"
ITEM "Note@50"
END END
ENDPAGE ENDPAGE
@ -285,7 +288,7 @@ ENDPAGE
ENDMASK ENDMASK
PAGE "Riga" -1 -1 78 13 PAGE "Riga" -1 -1 78 15
GROUPBOX DLG_NULL 76 6 GROUPBOX DLG_NULL 76 6
BEGIN BEGIN
@ -461,6 +464,21 @@ BEGIN
PROMPT 2 10 "Data " PROMPT 2 10 "Data "
END END
BOOLEAN S_BLOCCO
BEGIN
PROMPT 2 11 "Rata Bloccata"
END
STRING S_MOTIVO 6
BEGIN
PROMPT 24 11 "Motivo "
END
STRING S_NOTE 50
BEGIN
PROMPT 2 12 "Note "
END
ENDPAGE ENDPAGE
TOOLBAR "topbar" 0 0 0 2 TOOLBAR "topbar" 0 0 0 2

View File

@ -316,7 +316,7 @@ void TPrimanota_application::disable_cgs_cells(int n, char tipo)
case 'R': // Ritenute professionali case 'R': // Ritenute professionali
case 'S': // Ritenute Sociali case 'S': // Ritenute Sociali
case 'V': // Reverse charge case 'V': // Reverse charge
case '2': // IVA per scissione pagamenti art, 17-ter DPR 633/72 case '2': // IVA per scissione pagamenti art.17-ter DPR 633/72
last = 3; last = 3;
break; break;
case 'K': // Riga cliente/fornitore per saldaconto case 'K': // Riga cliente/fornitore per saldaconto
@ -324,7 +324,7 @@ void TPrimanota_application::disable_cgs_cells(int n, char tipo)
break; break;
first = 2; first = 2;
case 'I': // Imponibile o contropartita saldaconto case 'I': // Imponibile o contropartita saldaconto
case '1': // Cliente per scissione pagamenti art, 17-ter DPR 633/72 case '1': // Cliente per scissione pagamenti art.17-ter DPR 633/72
last = 7; last = 7;
break; break;
default: default:
@ -388,8 +388,7 @@ int TPrimanota_application::set_cgs_row(int n, const TImporto& imp,
} }
else else
{ {
const char contro_type = tipo == '2' ? 'D' : 'T'; const int pos = type2pos('T');
const int pos = type2pos(contro_type);
if (pos >= 0) if (pos >= 0)
{ {
TBill contro(cg.row(pos), 2, 0x3); TBill contro(cg.row(pos), 2, 0x3);
@ -1390,7 +1389,9 @@ real TPrimanota_application::calcola_imp() const
// Se e' attiva la terza pagina allora riporta i totali in testata // Se e' attiva la terza pagina allora riporta i totali in testata
if (is_fattura()) if (is_fattura())
{ {
real tot = m.get(F_TOTALE); tot -= imposte; real tot = m.get(F_TOTALE);
if (!m.efield(F_REVCHARGE).active())
tot -= imposte;
m.set(FS_IMPONIBILI, tot); m.set(FS_IMPONIBILI, tot);
m.set(FS_IMPOSTE, imposte); m.set(FS_IMPOSTE, imposte);
} }
@ -2160,21 +2161,21 @@ bool TPrimanota_application::num_handler(TMask_field& f, KEY key)
if (mov.get_bool(MOV_STAMPATO)) if (mov.get_bool(MOV_STAMPATO))
{ {
ok = f.yesno_box(TR("Il movimento e' gia' stato stampato sul libro giornale:\n" ok = f.yesno_box(TR("Il movimento è già stato stampato sul libro giornale:\n"
"si desidera continuare ugualmente?")); "si desidera continuare ugualmente?"));
a._skip_giornale_check = ok; a._skip_giornale_check = ok;
} }
if (ok && mov.get_bool(MOV_REGST)) if (ok && mov.get_bool(MOV_REGST))
{ {
ok = f.yesno_box(TR("Il movimento e' gia' stato stampato sul bollato:\n" ok = f.yesno_box(TR("Il movimento è già stato stampato sul bollato:\n"
"si desidera continuare ugualmente?")); "si desidera continuare ugualmente?"));
a._skip_bollato_check = ok; a._skip_bollato_check = ok;
} }
if (ok && mov.get_bool(MOV_INVIATO)) if (ok && mov.get_bool(MOV_INVIATO))
{ {
ok = f.yesno_box(TR("Il movimento e' stato inviato ad un'altra contabilita':\n" ok = f.yesno_box(TR("Il movimento è stato inviato ad un'altra contabilità:\n"
"si desidera continuare ugualmente?")); "si desidera continuare ugualmente?"));
} }
@ -2235,9 +2236,7 @@ bool TPrimanota_application::caus_modify_handler(TMask_field& f, KEY key)
if (!suspended_handler(f, key)) if (!suspended_handler(f, key))
return false; return false;
TMask& m = f.mask(); TMask& m = f.mask();
const int ann = m.get_int(F_ANNOIVA); const int ann = m.get_int(F_ANNOIVA);
const TString& cau = f.get(); const TString& cau = f.get();
@ -2245,21 +2244,25 @@ bool TPrimanota_application::caus_modify_handler(TMask_field& f, KEY key)
if (!c.ok()) if (!c.ok())
return false; return false;
const TCausale& k = app().causale(); TPrimanota_application& a = app();
const TCausale& k = a.causale();
const TString& msg = c.compatible(k); const TString& msg = c.compatible(k);
if (msg.not_empty()) // La causale non e' compatibile if (msg.not_empty()) // La causale non e' compatibile
{ {
if (m.insert_mode() && !app()._sal_dirty) if (m.insert_mode() && !a._sal_dirty)
{ {
// Cambio la maschera al volo // Cambio la maschera al volo
if (app().force_mask_swap(k, c)) if (a.force_mask_swap(k, c))
{ {
TString4 provv; TString4 provv;
provv << c.provvisorio(); provv << c.provvisorio();
m.set(F_PROVVISORIO, provv); m.set(F_PROVVISORIO, provv);
if (c.iva() != nessuna_iva && m.id2pos(F_SOLAIVA) > 0) if (c.iva() != nessuna_iva && m.id2pos(F_SOLAIVA) > 0)
{
m.set(F_SOLAIVA, c.soloiva() ? "X" : " "); m.set(F_SOLAIVA, c.soloiva() ? "X" : " ");
m.efield(F_REVCHARGE).show(c.iva() == iva_acquisti && c.reverse_charge());
}
return true; return true;
} }
} }
@ -2268,15 +2271,17 @@ bool TPrimanota_application::caus_modify_handler(TMask_field& f, KEY key)
if (key == K_TAB) if (key == K_TAB)
{ {
app().read_caus(cau, ann); a.read_caus(cau, ann);
app().cgs().force_update(); a.cgs().force_update();
TString4 provv; TString4 provv; provv << c.provvisorio();
provv << c.provvisorio();
m.set(F_PROVVISORIO, provv); m.set(F_PROVVISORIO, provv);
if (c.iva() != nessuna_iva) if (c.iva() != nessuna_iva)
{
m.set(F_SOLAIVA, c.soloiva() ? "X" : " "); m.set(F_SOLAIVA, c.soloiva() ? "X" : " ");
m.efield(F_REVCHARGE).show(c.iva() == iva_acquisti && c.reverse_charge());
a.activate_split_payment(m);
}
} }
} }
@ -2323,12 +2328,12 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
return f.error_box(TR("La data dell'operazione non appartiene a nessun esercizio")); return f.error_box(TR("La data dell'operazione non appartiene a nessun esercizio"));
TLibro_giornale& gio = a.giornale(); TLibro_giornale& gio = a.giornale();
const int ar = dr.year(); // Anno per registri const int ag = a._esercizi[ae].inizio().year(); // Anno libro giornale
if (m.query_mode() || gio.year() != ar) if (m.query_mode() || gio.year() != ag)
{ {
ok = gio.read(ar); ok = gio.read(ag);
if (!ok) if (!ok)
return f.error_box(FR("Non esiste il libro giornale del %d"), ar); return f.error_box(FR("Non esiste il libro giornale del %d"), ag);
} }
else else
ok = true; ok = true;
@ -2344,15 +2349,16 @@ bool TPrimanota_application::datareg_handler(TMask_field& f, KEY key)
{ {
f.error_box(FR("La data dell'operazione è antecedente al %s,\n" f.error_box(FR("La data dell'operazione è antecedente al %s,\n"
"ultima stampa del libro giornale del %d"), "ultima stampa del libro giornale del %d"),
gio.last_print().string(), ar); gio.last_print().string(), ag);
if (error) return false; if (error) return false;
} }
if (key == K_TAB && dr < gio.last_reg()) if (key == K_TAB && dr < gio.last_reg())
f.warning_box(FR("La data dell'operazione è antecedente al %s,\n" f.warning_box(FR("La data dell'operazione è antecedente al %s,\n"
"ultima registrazione sul libro giornale del %d"), "ultima registrazione sul libro giornale del %d"),
gio.last_reg().string(), ar); gio.last_reg().string(), ag);
} }
const int ar = dr.year(); // Anno solare registri
if (m.query_mode()) if (m.query_mode())
a.read_caus(m.get(F_CODCAUS), ar); a.read_caus(m.get(F_CODCAUS), ar);
@ -2896,6 +2902,7 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
f.set_dirty(); // warning_box cleans the field! f.set_dirty(); // warning_box cleans the field!
} }
a.activate_numrif(m, true); a.activate_numrif(m, true);
a.activate_split_payment(m);
if (f.focusdirty()) if (f.focusdirty())
{ {
@ -3036,10 +3043,47 @@ static void force_iva_det_bill()
cgs.force_update(); cgs.force_update();
} }
bool TPrimanota_application::is_split_payment() const bool TPrimanota_application::activate_split_payment(TMask& m)
{ {
bool yes = false; bool yes = false;
TMask_field* sp = m.find_by_id(F_SPLITPAY);
if (sp != NULL)
{
if (clifo() == 'C' && m.get_int(F_ANNOIVA) >= 2015 && !causale().reverse_charge())
{
const TRectype& cliente = cache().get_rec(LF_CLIFO, "C", m.get(F_CLIENTE));
yes = cliente.get_bool(CLI_SPLITPAY);
}
if (yes)
{
sp->show();
if (sp->get().blank())
sp->set("S"); // Set
}
else
{
sp->hide();
sp->reset();
}
}
return yes;
}
bool TPrimanota_application::is_split_payment() const
{
const TMask& m = curr_mask(); const TMask& m = curr_mask();
char s = ' ';
TMask_field* sp = m.find_by_id(F_SPLITPAY);
if (sp != NULL)
{
if (sp->shown())
s = sp->get()[0];
else
return false;
}
if (s != 'N' && s != 'S')
{
s = 'N';
if (clifo() == 'C' && m.get_int(F_ANNOIVA) >= 2015 && !causale().reverse_charge()) if (clifo() == 'C' && m.get_int(F_ANNOIVA) >= 2015 && !causale().reverse_charge())
{ {
const TRectype& cliente = cache().get_rec(LF_CLIFO, "C", m.get(F_CLIENTE)); const TRectype& cliente = cache().get_rec(LF_CLIFO, "C", m.get(F_CLIENTE));
@ -3048,11 +3092,12 @@ bool TPrimanota_application::is_split_payment() const
TRelation rel(LF_MOV); TRelation rel(LF_MOV);
rel.add(LF_PARTITE, "NREG==NUMREG", 2); rel.add(LF_PARTITE, "NREG==NUMREG", 2);
m.autosave(rel); m.autosave(rel);
yes = ::is_split_payment(rel.curr()); // Controlla reverse charge e ritenute if (::is_split_payment(rel.curr()))
s = 'S';
} }
} }
}
return yes; return s == 'S';
} }
bool TPrimanota_application::is_fattura_split() const bool TPrimanota_application::is_fattura_split() const
@ -3060,7 +3105,6 @@ bool TPrimanota_application::is_fattura_split() const
return is_fattura() && is_split_payment(); return is_fattura() && is_split_payment();
} }
// Handler of the F_LIQDIFF // Handler of the F_LIQDIFF
// Certified 99% // Certified 99%
bool TPrimanota_application::liqdiff_handler(TMask_field& f, KEY key) bool TPrimanota_application::liqdiff_handler(TMask_field& f, KEY key)

View File

@ -214,6 +214,7 @@ protected:
bool is_fattura() const { return is_saldaconto() && causale().tipomov() == 1; } bool is_fattura() const { return is_saldaconto() && causale().tipomov() == 1; }
bool is_nota_credito() const { return is_saldaconto() && causale().tipomov() == 2; } bool is_nota_credito() const { return is_saldaconto() && causale().tipomov() == 2; }
bool is_pagamento() const { return is_saldaconto() && causale().tipomov() >= 3; } bool is_pagamento() const { return is_saldaconto() && causale().tipomov() >= 3; }
bool activate_split_payment(TMask& m);
bool is_split_payment() const; bool is_split_payment() const;
bool is_fattura_split() const; bool is_fattura_split() const;

View File

@ -97,7 +97,7 @@ bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k)
break; break;
case K_DEL: case K_DEL:
doit = !recalc && pag.n_rate() > 1 && ps.row(r).get_char(14) != 'X'; // non cancellabile doit = !recalc && pag.n_rate() > 1 && ps.row(r).get_char(15) != 'X'; // non cancellabile
if (doit) if (doit)
{ {
pag.remove_rata(r); pag.remove_rata(r);
@ -829,7 +829,7 @@ bool TPrimanota_application::read_scadenze(TMask& m)
const bool is_split = !in_valuta && clifo.tipo() == 'C' && anno >= 2015 && is_split_payment(); const bool is_split = !in_valuta && clifo.tipo() == 'C' && anno >= 2015 && is_split_payment();
const real totale_cg = m.get_real(in_valuta ? SK_TOTDOCVAL : F_TOTALE); const real totale_cg = m.get_real(in_valuta ? SK_TOTDOCVAL : F_TOTALE);
real totale_sc = partita.importo(in_valuta).valore() + partita.get_real(PART_SPESE); real totale_sc = partita.importo(in_valuta).valore();
if (is_split) if (is_split)
totale_sc += m.get_real(F_IMPOSTE); totale_sc += m.get_real(F_IMPOSTE);
@ -894,9 +894,15 @@ bool TPrimanota_application::read_scadenze(TMask& m)
m.set(FS_AGENTE, scadenza.get(SCAD_CODAG)); m.set(FS_AGENTE, scadenza.get(SCAD_CODAG));
} }
str.add(scadenza.get(SCAD_DESCR), 11); str.add(scadenza.get(SCAD_DESCR), 11);
str.add(scadenza.get(SCAD_BLOCCATA), 12); bool bloc = scadenza.get_bool(SCAD_BLOCCATA);
str.add(scadenza.get(SCAD_MOTIVO), 13); const TString8 motivo = scadenza.get(SCAD_MOTIVO);
str.add(prot ? "X" : " ", 14); if (bloc || motivo.full())
{
str.add("X", 12);
str.add(motivo, 13);
str.add(cache().get("%CBP", motivo, "S0"), 14);
}
str.add(prot ? "X" : " ", 15);
} }
m.set(FS_RDIFFER, pag.rate_differenziate() ? "1" : "2"); m.set(FS_RDIFFER, pag.rate_differenziate() ? "1" : "2");
m.set(FS_NAMEPAG, pag.name()); m.set(FS_NAMEPAG, pag.name());

View File

@ -775,19 +775,7 @@ bool TEasySolder_mask::sheet_rate_filler(TTree& tree, void* jolly, word /* flags
if (level == 3) if (level == 3)
{ {
if (good_rat) if (good_rat)
{ good_rat = nrigp <= 0 && !scad->chiusa();
good_rat = nrigp <= 0 && !scad->chiusa() && !scad->get_bool(SCAD_BLOCCATA);
/* Commentato in quanto impedisce di saldare le note di credito
if (good_rat)
{
const char expected_section = scad->get_char(SCAD_TIPOCF) == 'C' ? 'D' : 'A';
TImporto res = scad->residuo(true);
res.normalize(expected_section); // res.normalize(scad->riga().sezione());
if (res.valore () <= ZERO) // In realtà è chiusa!
good_rat = false;
}
*/
}
} }
else else
good_rat &= good_pag; good_rat &= good_pag;
@ -844,6 +832,19 @@ bool TEasySolder_mask::sheet_rate_filler(TTree& tree, void* jolly, word /* flags
const TRiga_partite& riga = game.riga(nriga); const TRiga_partite& riga = game.riga(nriga);
set_row_str(sheet, row, S_NUMDOC, riga.get(PART_NUMDOC)); set_row_str(sheet, row, S_NUMDOC, riga.get(PART_NUMDOC));
set_row_str(sheet, row, S_DATADOC, riga.get(PART_DATADOC)); set_row_str(sheet, row, S_DATADOC, riga.get(PART_DATADOC));
set_row_str(sheet, row, S_NOTE, scad->get(SCAD_DESCR));
if (scad->get_bool(SCAD_BLOCCATA))
{
set_row_bool(sheet, row, S_BLOCCO, true);
sheet.disable_cell(sheet.items()-1, -1);
const TString8 cbp = scad->get(SCAD_MOTIVO);
if (cbp.full())
{
set_row_str(sheet, row, S_MOTIVO, cbp);
set_row_str(sheet, row, S_NOTE, cache().get("%CBP", cbp, "S0"));
}
}
} }
// Propone data di pagamento per le RIBA // Propone data di pagamento per le RIBA
@ -907,7 +908,7 @@ bool TEasySolder_mask::sheet_rate_filler(TTree& tree, void* jolly, word /* flags
} }
else else
{ {
// Nota di credito non assegnata e senza pagamenti n questo movimento // Nota di credito non assegnata e senza pagamenti in questo movimento
if (level == 4 && nriga == TPartita::UNASSIGNED && nrigp == 0 && has_lonely_nc(game)) if (level == 4 && nriga == TPartita::UNASSIGNED && nrigp == 0 && has_lonely_nc(game))
{ {
const TImporto sld = game.calcola_saldo(true); const TImporto sld = game.calcola_saldo(true);

View File

@ -1,4 +1,4 @@
PAGE "Rata pagamento" -1 -1 51 15 PAGE "Rata pagamento" -1 -1 51 16
DATE 101 DATE 101
BEGIN BEGIN
@ -154,24 +154,30 @@ END
BOOLEAN 113 BOOLEAN 113
BEGIN BEGIN
PROMPT 12 11 "Bloccata" PROMPT 1 13 "Bloccata"
MESSAGE FALSE CLEAR,114 MESSAGE FALSE CLEAR,114
MESSAGE TRUE ENABLE,114 MESSAGE TRUE ENABLE,114
END END
STRING 114 6 STRING 114 6
BEGIN BEGIN
PROMPT 30 11 "Motivo " PROMPT 17 13 "Motivazione del blocco "
USE %CBP USE %CBP
INPUT CODTAB 114 INPUT CODTAB 114
DISPLAY "Codice" CODTAB DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@50" S0 DISPLAY "Descrizione@50" S0
OUTPUT 114 CODTAB OUTPUT 114 CODTAB
OUTPUT 115 S0
CHECKTYPE NORMAL CHECKTYPE NORMAL
END
STRING 115 50 47
BEGIN
PROMPT 1 14 ""
FLAGS "D" FLAGS "D"
END END
BOOLEAN 115 BOOLEAN 116
BEGIN BEGIN
PROMPT 1 -1 "Non cancellabile" PROMPT 1 -1 "Non cancellabile"
FLAGS "D" FLAGS "D"

View File

@ -232,7 +232,8 @@ BEGIN
ITEM "Vs.CAB" ITEM "Vs.CAB"
ITEM "Note@50" ITEM "Note@50"
ITEM "Bloccata" ITEM "Bloccata"
ITEM "Motivo" ITEM "Codice"
ITEM "Motivazione@50"
ITEM "Non cancellabile" ITEM "Non cancellabile"
END END

View File

@ -6,7 +6,6 @@
#include <relation.h> #include <relation.h>
#include <tabutil.h> #include <tabutil.h>
class TAp_eser : public TSkeleton_application class TAp_eser : public TSkeleton_application
{ {
int _anno, _newanno; int _anno, _newanno;
@ -38,7 +37,7 @@ bool TAp_eser::mask_newanno (TMask_field& f, KEY k)
const int newanno = f.mask().get_int(F_NUOVOANNO); const int newanno = f.mask().get_int(F_NUOVOANNO);
if (app()._esc->exist(newanno)) if (app()._esc->exist(newanno))
return f.warning_box (FR("Il codice %04d e' gia' presente nella tabella degli esercizi!"), return f.warning_box (FR("Il codice %04d è già presente nella tabella degli esercizi!"),
newanno); newanno);
} }
return TRUE; return TRUE;
@ -52,9 +51,9 @@ bool TAp_eser::mask_dataini (TMask_field& f, KEY k)
TDate fine(f.mask().get(F_DATAFINC)); TDate fine(f.mask().get(F_DATAFINC));
if ( data <= fine ) if ( data <= fine )
return f.warning_box (TR("La data di inizio del nuovo esercizio deve essere superiore alla data di fine esercizio precedente")); return f.error_box (TR("La data di inizio del nuovo esercizio deve essere superiore alla data di fine esercizio precedente"));
} }
return TRUE; return true;
} }
bool TAp_eser::create() bool TAp_eser::create()
@ -69,7 +68,6 @@ bool TAp_eser::create()
bool TAp_eser::destroy() bool TAp_eser::destroy()
{ {
delete _esc; delete _esc;
return TSkeleton_application::destroy(); return TSkeleton_application::destroy();
} }
@ -109,17 +107,16 @@ void TAp_eser::main_loop()
} }
} }
else else
error_box(TR("Non e' ancora stato aperto alcun esercizio!")); error_box(TR("Non è ancora stato aperto alcun esercizio!"));
} }
bool TAp_eser::apertura_es() bool TAp_eser::apertura_es()
{ {
TString8 anno; TString4 anno, annonew;
TString8 annonew;
TDate data; TDate data;
TRelation reg("REG"); TRelation reg("REG");
TRectype & tabreg = reg.curr(); TRectype & tabreg = reg.curr();
bool ok = FALSE; bool ok = false;
//viene aggiornata la tabella dei registri. Se esisteva gia' un record relativo al nuovo esercizio, viene cancellato. //viene aggiornata la tabella dei registri. Se esisteva gia' un record relativo al nuovo esercizio, viene cancellato.
//In ogni caso ne viene creato uno nuovo relativo al nuovo esercizio. //In ogni caso ne viene creato uno nuovo relativo al nuovo esercizio.
@ -150,7 +147,7 @@ bool TAp_eser::apertura_es()
{ {
TString16 cod(tabreg.get("CODTAB")); TString16 cod(tabreg.get("CODTAB"));
ok = TRUE; ok = true;
annonew.format("%04d", _datafin.year()); annonew.format("%04d", _datafin.year());
cod.overwrite(annonew); cod.overwrite(annonew);
tabreg.put("CODTAB", cod); tabreg.put("CODTAB", cod);

View File

@ -600,8 +600,8 @@ bool TLibro_giornale::read(int y)
if (y <= 0) if (y <= 0)
{ {
const TDate oggi(TODAY); TEsercizi_contabili esc;
y = oggi.year(); y = esc[esc.last()].inizio().year();
} }
TString4 anno; anno.format("%04d", y); TString4 anno; anno.format("%04d", y);

View File

@ -167,6 +167,9 @@ bool is_reverse_charge(const TRectype& mov)
} }
bool is_split_payment(const TRectype& mov) bool is_split_payment(const TRectype& mov)
{
char s = mov.get_char(MOV_SPLITPAY);
if (s != 'N' && s != 'S') // Auto
{ {
bool yes = false; bool yes = false;
if (mov.get_char(MOV_TIPO) == 'C' && mov.get_int(MOV_ANNOIVA) >= 2015 && if (mov.get_char(MOV_TIPO) == 'C' && mov.get_int(MOV_ANNOIVA) >= 2015 &&
@ -190,7 +193,9 @@ bool is_split_payment(const TRectype& mov)
} }
} }
} }
return yes; s = yes ? 'S' : 'N';
}
return s == 'S';
} }
bool is_IVA_diff(const TRectype& mov) bool is_IVA_diff(const TRectype& mov)

View File

@ -628,8 +628,18 @@ TFieldtypes TSolder_tree::get_var(const TString& name, TVariant& var) const
const TRiga_scadenze& rata = fatt.rata(nrata); const TRiga_scadenze& rata = fatt.rata(nrata);
if (name == PART_DESCR) if (name == PART_DESCR)
{ {
TString16 desc; TString80 desc;
desc << nrata << '/' << fatt.rate(); desc.format("%d/%d ", nrata, fatt.rate());
if (rata.get_bool(SCAD_BLOCCATA))
{
const TString8 cbp = rata.get(SCAD_MOTIVO);
if (cbp.full())
desc << cache().get("%CBP", cbp, "S0");
else
desc << TR("Bloccata");
}
else
desc << rata.get(SCAD_DESCR);
var = desc; var = desc;
} else } else
if (name == PART_NUMDOC) if (name == PART_NUMDOC)

View File

@ -1,3 +1,3 @@
23 23
0 0
$mov|0|0|460|0|Movimenti di prima nota||| $mov|0|0|461|0|Movimenti di prima nota|||

View File

@ -1,5 +1,5 @@
23 23
53 54
ANNOES|9|4|0|Codice esercizio ANNOES|9|4|0|Codice esercizio
NUMREG|3|7|0|Numero di operazione NUMREG|3|7|0|Numero di operazione
DATAREG|5|8|0|Data operazione DATAREG|5|8|0|Data operazione
@ -50,6 +50,7 @@ DNDOC|3|7|0|Documento originale NDOC
DATAINC|5|8|0|Data di incasso per liquidazione differita DATAINC|5|8|0|Data di incasso per liquidazione differita
LIQDIFF|8|1|0|Flag di movimento a liquidazione differita LIQDIFF|8|1|0|Flag di movimento a liquidazione differita
IVAXCASSA|8|1|0|Flag di movimento IVA per cassa IVAXCASSA|8|1|0|Flag di movimento IVA per cassa
SPLITPAY|1|1|0|Flag di scissione pagamenti [_=Auto,S=Split,N=Normale]
NOLEGGIO|1|1|0|Tipo veicolo Auto, Camper, Altro, Diporto, aEreo NOLEGGIO|1|1|0|Tipo veicolo Auto, Camper, Altro, Diporto, aEreo
INVIOFE|5|8|0|Data invio definitivo dati rilevanti INVIOFE|5|8|0|Data invio definitivo dati rilevanti
CONTSEP|1|6|0|Contabilità separata CONTSEP|1|6|0|Contabilità separata