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;
commandline.format("lv0 -3 /i%s",(const char*)tempfile);
TExternal_app lv(commandline);
@ -652,7 +651,7 @@ HIDDEN bool contrlav_handler(TMask_field& f, KEY key)
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));
_gessal = !_has_cg || cnf.get_bool("GesSal");
_lbcn = cnf.get_bool("GsLbCn");
@ -662,8 +661,8 @@ void TClifo_application::on_config_change()
init_pages(*_msk);
_msk->show(-9, _gessal); // Mostra campi Estratti conto
_msk->enable(DLG_CONTRLAV, main_app().has_module(LVAUT));
if (_msk->id2pos(DLG_ALTNEWCLI) >= 0)
_msk->set_handler(DLG_ALTNEWCLI, altnewcli_handler);
if (_msk->id2pos(DLG_ALTNEWCLI) >= 0)
_msk->set_handler(DLG_ALTNEWCLI, altnewcli_handler);
}

View File

@ -72,7 +72,7 @@ class TStampa_bilanci : public TPrintapp
TRelation* _rel;
TCursor * _cur;
TProgind * _prog;
TProgress_monitor * _prog;
TSaldi_list* _listacf, * _lista;
TLocalisamfile* _com, * _pcn, * _mov, * _rmov, * _clifo, * _saldi, * _nditte,* _anag,* _caus;
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
if (_situazione.empty()) ncur /= 2;
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);
init_sort();
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
{
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);
_codici = m.get_bool(F_CODICI);
_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
_print_full_code = _verifica == 1 && m.get_bool(F_PRINT_FULL_CODE);
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);
if (_tipo_stampa1 == 1)
{

View File

@ -8,6 +8,7 @@
#include <execp.h>
#include <mailbox.h>
#include <modaut.h>
#include <recset.h>
#include <urldefid.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_OCCASEDIT, occas_handler);
m->set_handler(F_SOLAIVA, solaiva_handler);
m->set_handler(F_REVCHARGE, revcharge_handler);
m->set_handler(F_SHEETIVA, iva_handler);
m->show(F_LIQDIFF, _liqdiff);
@ -397,7 +399,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
}
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
const char tipo = nriga == 1 ? 'T' : ' ';
@ -567,7 +569,8 @@ void TPrimanota_application::init_mask(TMask& m)
}
else
{
const bool corrisp = causale().corrispettivi();
const TCausale& cc = causale();
const bool corrisp = cc.corrispettivi();
bool clig = false, forg = false;
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)
m.show(-4, causale().valintra());
m.show(F_DATAINTRA, causale().intra());
m.show(-4, cc.valintra());
m.show(F_DATAINTRA, cc.intra());
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);
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)
@ -966,6 +974,8 @@ void TPrimanota_application::init_modify_mode(TMask& m)
// Abilito il bottone di collegamento ai documenti se possibile
const long numdoc = mov.get_long(MOV_DNDOC);
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
if (_automatico->_tipo == 2)
{
_automatico->_totale += m.get_real(F_RITFIS);
_automatico->_totale += m.get_real(F_REVCHARGE);
_automatico->_codiva = m.get(F_CODIVA);
if (_automatico->_codiva.blank() && _rel->iva_items() > 0)
_automatico->_codiva = _rel->iva(0).get(RMI_CODIVA);

View File

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

View File

@ -207,7 +207,7 @@ BEGIN
PROMPT 1 9 "Cliente "
FIELD CODCF
GROUP 1
USE LF_CLIFO KEY 1
USE LF_CLIFO
INPUT TIPOCF "C"
INPUT CODCF F_CLIENTE
DISPLAY "Codice" CODCF
@ -233,7 +233,7 @@ BEGIN
PROMPT 1 9 "Fornitore "
FIELD CODCF
GROUP 2
USE LF_CLIFO KEY 1
USE LF_CLIFO
INPUT TIPOCF "F"
INPUT CODCF F_FORNITORE
DISPLAY "Codice" CODCF
@ -570,8 +570,18 @@ BEGIN
FIELD LIQDIFF
MESSAGE FALSE CLEAR,F_DATAINC
MESSAGE TRUE ENABLE,F_DATAINC
FLAGS "H"
FLAGS "HG"
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
BEGIN

View File

@ -47,3 +47,6 @@
#define S_MODOPAG 120
#define S_NREG 121
#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 "N.reg."
ITEM "N.riga"
ITEM "Blocco"
ITEM "Motivo"
ITEM "Note@50"
END
ENDPAGE
@ -285,7 +288,7 @@ ENDPAGE
ENDMASK
PAGE "Riga" -1 -1 78 13
PAGE "Riga" -1 -1 78 15
GROUPBOX DLG_NULL 76 6
BEGIN
@ -461,6 +464,21 @@ BEGIN
PROMPT 2 10 "Data "
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
TOOLBAR "topbar" 0 0 0 2

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -97,7 +97,7 @@ bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k)
break;
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)
{
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 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)
totale_sc += m.get_real(F_IMPOSTE);
@ -893,10 +893,16 @@ bool TPrimanota_application::read_scadenze(TMask& m)
m.set(FS_VSCAB, str.get(10));
m.set(FS_AGENTE, scadenza.get(SCAD_CODAG));
}
str.add(scadenza.get(SCAD_DESCR), 11);
str.add(scadenza.get(SCAD_BLOCCATA), 12);
str.add(scadenza.get(SCAD_MOTIVO), 13);
str.add(prot ? "X" : " ", 14);
str.add(scadenza.get(SCAD_DESCR), 11);
bool bloc = scadenza.get_bool(SCAD_BLOCCATA);
const TString8 motivo = scadenza.get(SCAD_MOTIVO);
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_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 (good_rat)
{
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;
}
*/
}
good_rat = nrigp <= 0 && !scad->chiusa();
}
else
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);
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_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
@ -907,7 +908,7 @@ bool TEasySolder_mask::sheet_rate_filler(TTree& tree, void* jolly, word /* flags
}
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))
{
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
BEGIN
@ -154,24 +154,30 @@ END
BOOLEAN 113
BEGIN
PROMPT 12 11 "Bloccata"
PROMPT 1 13 "Bloccata"
MESSAGE FALSE CLEAR,114
MESSAGE TRUE ENABLE,114
END
STRING 114 6
BEGIN
PROMPT 30 11 "Motivo "
PROMPT 17 13 "Motivazione del blocco "
USE %CBP
INPUT CODTAB 114
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@50" S0
OUTPUT 114 CODTAB
OUTPUT 115 S0
CHECKTYPE NORMAL
END
STRING 115 50 47
BEGIN
PROMPT 1 14 ""
FLAGS "D"
END
BOOLEAN 115
BOOLEAN 116
BEGIN
PROMPT 1 -1 "Non cancellabile"
FLAGS "D"

View File

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

View File

@ -6,7 +6,6 @@
#include <relation.h>
#include <tabutil.h>
class TAp_eser : public TSkeleton_application
{
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);
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);
}
return TRUE;
@ -52,9 +51,9 @@ bool TAp_eser::mask_dataini (TMask_field& f, KEY k)
TDate fine(f.mask().get(F_DATAFINC));
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()
@ -68,14 +67,13 @@ bool TAp_eser::create()
bool TAp_eser::destroy()
{
delete _esc;
delete _esc;
return TSkeleton_application::destroy();
}
void TAp_eser::main_loop()
{
int anno = _esc->last();
int anno = _esc->last();
if (anno > 0)
{
@ -109,17 +107,16 @@ void TAp_eser::main_loop()
}
}
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()
{
TString8 anno;
TString8 annonew;
TString4 anno, annonew;
TDate data;
TRelation reg("REG");
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.
//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"));
ok = TRUE;
ok = true;
annonew.format("%04d", _datafin.year());
cod.overwrite(annonew);
tabreg.put("CODTAB", cod);

View File

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

View File

@ -168,29 +168,34 @@ bool is_reverse_charge(const TRectype& mov)
bool is_split_payment(const TRectype& mov)
{
bool yes = false;
if (mov.get_char(MOV_TIPO) == 'C' && mov.get_int(MOV_ANNOIVA) >= 2015 &&
mov.get_real(MOV_RITFIS).is_zero() && mov_has_imposte(mov))
char s = mov.get_char(MOV_SPLITPAY);
if (s != 'N' && s != 'S') // Auto
{
const TRectype& clifo = cache().get_rec(LF_CLIFO, "C", mov.get(MOV_CODCF));
if (clifo.get_bool(CLI_SPLITPAY)) // Ente pubblico con split payment
bool yes = false;
if (mov.get_char(MOV_TIPO) == 'C' && mov.get_int(MOV_ANNOIVA) >= 2015 &&
mov.get_real(MOV_RITFIS).is_zero() && mov_has_imposte(mov))
{
yes = !is_reverse_charge(mov);
if (yes && get_tipo_movimento(mov) == tm_nota_credito) // Controlla le N.C.
const TRectype& clifo = cache().get_rec(LF_CLIFO, "C", mov.get(MOV_CODCF));
if (clifo.get_bool(CLI_SPLITPAY)) // Ente pubblico con split payment
{
if (mov.get_bool(MOV_LIQDIFF))
yes = false;
else
yes = !is_reverse_charge(mov);
if (yes && get_tipo_movimento(mov) == tm_nota_credito) // Controlla le N.C.
{
TISAM_recordset par("USE PART KEY 2 SELECT ANNO<2015\nFROM NREG=#NR\nTO NREG=#NR");
par.set_var("#NR", mov.get_long(MOV_NUMREG));
if (!par.empty()) // Se la nota si rifersice a partite vecchie non ha lo split payment
if (mov.get_bool(MOV_LIQDIFF))
yes = false;
else
{
TISAM_recordset par("USE PART KEY 2 SELECT ANNO<2015\nFROM NREG=#NR\nTO NREG=#NR");
par.set_var("#NR", mov.get_long(MOV_NUMREG));
if (!par.empty()) // Se la nota si rifersice a partite vecchie non ha lo split payment
yes = false;
}
}
}
}
s = yes ? 'S' : 'N';
}
return yes;
return s == 'S';
}
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);
if (name == PART_DESCR)
{
TString16 desc;
desc << nrata << '/' << fatt.rate();
TString80 desc;
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;
} else
if (name == PART_NUMDOC)

View File

@ -1,3 +1,3 @@
23
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
53
54
ANNOES|9|4|0|Codice esercizio
NUMREG|3|7|0|Numero di 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
LIQDIFF|8|1|0|Flag di movimento a liquidazione differita
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
INVIOFE|5|8|0|Data invio definitivo dati rilevanti
CONTSEP|1|6|0|Contabilità separata