Gestione descrizione IVA cee in stampa fatture

Correzioni varie a lettere d'intento

git-svn-id: svn://10.65.10.50/branches/R_10_00@22830 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2013-03-15 11:08:44 +00:00
parent 12d9139ed1
commit 56c30da236
14 changed files with 155 additions and 105 deletions

View File

@ -65,27 +65,24 @@ TRectype& TCli_for::vendite() const
return (TRectype &) _ven_rec;
}
bool TCli_for::read_lettera(const TDate & data, bool extended)
bool TCli_for::read_lettera(const TDate& data, bool extended)
{
if (_use_lettere)
if (use_lettere())
{
if (data != _last_data || _extended != extended)
if (data != _last_data || _extended != extended)
{
_letint.zero();
TRelation * r = new TRelation(LF_LETINT);
TRectype to(r->curr());
to.put(LETINT_ANNO, data.year());
TRelation r(LF_LETINT);
TRectype to(r.curr());
to.put(LETINT_CODCLI, codice());
to.put(LETINT_ANNO, data.year());
TRectype from(to);
from.put(LETINT_ANNO, data.year() - 1);
TCursor c(r, "", 2 ,&from, &to);
const int items = c.items();
TCursor c(&r, "", 2, &from, &to);
const int items = c.items();
if (items > 0)
{
TDate dal;
@ -97,7 +94,7 @@ bool TCli_for::read_lettera(const TDate & data, bool extended)
const int tipo = c.curr().get_int(LETINT_TIPOOP);
if (tipo == 3)
if (tipo == 3) // Nel periodo
{
dal = c.curr().get_date(LETINT_DAL);
al = c.curr().get_date(LETINT_AL);
@ -163,7 +160,7 @@ int TCli_for::remove(TBaseisamfile& f) const
const int err = vendite().remove(v);
if (err != NOERR && err != _iskeynotfound)
return err;
return TMultiple_rectype:: remove(f);
return TMultiple_rectype::remove(f);
}
void TCli_for::init()

View File

@ -19,7 +19,7 @@ END
ENDPAGE
TOOLBAR "botbar" 0 -2 0 2
TOOLBAR "botbar" 0 0 0 2
BUTTON DLG_SAVEREC 10 2
BEGIN
@ -78,4 +78,4 @@ END
ENDPAGE
ENDMASK
ENDMASK

View File

@ -200,6 +200,7 @@ TDoc_recordset::TDoc_recordset(const TRecordset& doc, const TString& old_query)
rows.sort(compare_rdocs);
}
_doc->set_riga_conai();
_doc->set_riga_tic();
// Posiziona correttamente anche il cursore principale
*cursor() = 0L;

View File

@ -378,10 +378,12 @@ void TMask_anamag::set_parametered_fields()
enable_page(PAGE_GIACENZE,gestmag);
enable_page(PAGE_STORICO,gestmag);
/* Obsoleto
// abilita la visualizzazione dei campi per la vendita al dettaglio
const bool dettaglio = app().has_module(VDAUT);
show(-G_VD, dettaglio);
*/
// abilita la visualizzazione dei campi distinti per i livelli articolo
set_handler(F_CODART, handle_codice);
}

View File

@ -229,7 +229,7 @@
#define G_CATVEN 6
#define G_CONVEN 7
#define G_RAGGFISC 8
#define G_VD 9
// #define G_VD 9 Vendite al dettaglio Obsolete
#define G_LV 10
// definizioni per l'archivio di misura articoli

View File

@ -257,6 +257,7 @@ BEGIN
CHECKTYPE NORMAL
END
/*
STRING F_REPARTO 3
BEGIN
PROMPT 1 6 "Reparto "
@ -313,6 +314,7 @@ BEGIN
CHECKTYPE NORMAL
GROUP G_VD
END
*/
STRING F_CATCONV 3
BEGIN

View File

@ -207,7 +207,6 @@ BEGIN
DISPLAY "Descrizione@50" S0
DISPLAY "Cambio" S4
OUTPUT FA_CODVAL CODTAB
OUTPUT FA_CONTROEURO B1
OUTPUT FA_CAMBIO S4
CHECKTYPE NORMAL
MESSAGE EMPTY CLEAR,FA_CAMBIO|CLEAR,FA_DATACAM|DISABLE,FA_DATACAM
@ -220,14 +219,6 @@ BEGIN
FIELD CAMBIO
END
/*
BOOLEAN FA_CONTROEURO
BEGIN
PROMPT 42 1 "Contro Euro"
FIELD CONTROEURO
END
*/
DATA FA_DATACAM
BEGIN
PROMPT 61 1 "Data "

View File

@ -403,7 +403,7 @@ real TDocumento::spese_incasso(real & imp, int ndec, TTipo_importo t) const
if (t == _lordo || t == _imposta)
{
TString4 codiva_es; iva_esente(codiva_es);
const real iva_spese(TRiga_documento::iva(codiva_es.full() ? (const TString &)codiva_es : codiva_spese()).imposta(imp_spese, ndec));
const real iva_spese = TRiga_documento::iva(codiva_es.full() ? (const TString&)codiva_es : codiva_spese()).imposta(imp_spese, ndec);
if (t == _lordo)
imp_spese += iva_spese;
else
@ -432,7 +432,7 @@ void TDocumento::iva_esente(TString& codiva_es) const
for (int r = 1; codiva_es.empty() && r <= rows; r++)
{
const TRiga_documento& riga = ((TDocumento*)this)->row(r);
const TString4 str_codiva(riga.get(RDOC_CODIVA));
const TString4 str_codiva = riga.get(RDOC_CODIVA);
if (str_codiva.full())
{
@ -868,7 +868,7 @@ void TDocumento::set_riga_sconto()
{
_tipo_riga_sc = "08";
conf.set("TRSCONTI", _tipo_riga_sc);
warning_box(FR("Il tipo riga sconti di testa non risultava impostato.\n L'applicazione usera' automaticamente il tipo %s"), (const char*) _tipo_riga_sc);
warning_box(FR("Il tipo riga sconti di testa non risultava impostato.\n L'applicazione userà automaticamente il tipo %s"), (const char*) _tipo_riga_sc);
}
}
_sconto = new TRiga_documento(this, _tipo_riga_sc);
@ -883,18 +883,18 @@ void TDocumento::update_esenzione()
if (clifor().use_lettere())
{
bool to_update = false;
const TString8 codiva = codesiva();
const TString4 codiva = codesiva();
for (int i = physical_rows(); !to_update && i > 0; i--)
{
const TString & cod = row(i).get(RDOC_CODIVA);
to_update = cod.full() && cod != codiva;
}
if (to_update)
for (int i = physical_rows(); i > 0; i--)
for (int i = physical_rows(); i > 0; i--)
{
TRiga_documento & rdoc = row(i);
const TString & cod = rdoc.get(RDOC_CODIVA);
const TString& cod = rdoc.get(RDOC_CODIVA);
if (cod.full())
{
@ -902,41 +902,37 @@ void TDocumento::update_esenzione()
rdoc.put(RDOC_CODIVA, codiva);
else
{
TCodiceIVA i(cod);
const TCodiceIVA i(cod);
const bool plafond = i.get_int("S3") > 0;
if (plafond)
{
TString codivarow;
TString4 codivarow;
if (rdoc.is_merce())
codivarow =cached_article(rdoc.get(RDOC_CODARTMAG)).get(ANAMAG_CODIVA);
else
if (rdoc.is_spese())
{
TSpesa_prest s(rdoc.get(RDOC_CODART));
const TSpesa_prest s(rdoc.get(RDOC_CODART));
codivarow = s.cod_iva();
}
else
if (rdoc.is_prestazione())
{
TSpesa_prest p(rdoc.get(RDOC_CODART), 'P');
TSpesa_prest p(rdoc.get(RDOC_CODART), 'P');
codivarow = p.cod_iva();
}
else
if (rdoc.is_risorsa())
{
TSpesa_prest r(rdoc.get(RDOC_CODART), 'R');
TSpesa_prest r(rdoc.get(RDOC_CODART), 'R');
codivarow = r.cod_iva();
}
else
if (rdoc.is_attrezzatura())
{
TSpesa_prest a(rdoc.get(RDOC_CODART), 'A');
TSpesa_prest a(rdoc.get(RDOC_CODART), 'A');
codivarow = a.cod_iva();
}
if (codivarow.full())
@ -965,16 +961,18 @@ void TDocumento::set_riga_esenzione()
if (esente)
{
esente = false;
const TString8 codiva = codes.codice();
const TString4 codiva = codes.codice();
for (int i = physical_rows(); !esente && i > 0; i--)
esente = row(i).get(RDOC_CODIVA) == codiva;
}
if (!esente)
{
if(_esenzione != NULL)
if (_esenzione != NULL)
{
delete _esenzione;
_esenzione = NULL;
_esenzione = NULL;
}
}
else
{
@ -2181,7 +2179,6 @@ void TDocumento::update_tabella_iva(bool solo_imponibili)
const bool fatt_comm = tipo().fattura_commerciale();
TString4 codiva_es;
iva_esente(codiva_es);
for (int i = items; i > 0; i--)
{
@ -2293,7 +2290,7 @@ void TDocumento::update_tabella_iva(bool solo_imponibili)
if (!val.is_zero())
{
const TString& codiva = codiva_es.full() ? (const TString &) codiva_es : codiva_spese();
const TString& codiva = codiva_es.full() ? (const TString&)codiva_es : codiva_spese();
TRiepilogo_iva* ri = (TRiepilogo_iva*)table.objptr(codiva);
if (ri == NULL && codiva.full())
{
@ -2732,7 +2729,7 @@ void TDocumento::update_raee()
r1.put(RDOC_UMQTA, um);
if (cod_iva_cli.blank())
{
const TString & codiva = sp.cod_iva();
const TString& codiva = sp.cod_iva();
if (codiva.full())
r1.put(RDOC_CODIVA, codiva);
}
@ -2941,7 +2938,7 @@ void TDocumento::update_conai()
// Genera nuove righe
if (cli_add_conai)
{
const TString4 cod_iva_cli = codesiva() ;
const TString4 cod_iva_cli = codesiva();
TSpesa_prest sp;
FOR_EACH_CONFIGURED_CONAI_CLASS(ct) if (!updated[ct])
@ -2961,7 +2958,7 @@ void TDocumento::update_conai()
const TString& s = conai_sp.row(ct);
if (sp.read(s) != NOERR)
message_box(FR("Il codice spesa CONAI %s specificato nei parametri ditta e' assente: '%s'"),
message_box(FR("Il codice spesa CONAI %s specificato nei parametri ditta è assente: '%s'"),
conai_material(ct), (const char*)s);
else
{
@ -3106,17 +3103,24 @@ int TDocumento::tipo_riclassificato() const
const TString& TDocumento::codesiva() const
{
TCli_for& c = clifor();
const TString4 codiva(c.vendite().get(CFV_ASSFIS));
TCodiceIVA i(codiva);
const bool plafond = i.get_int("S3") > 0;
const TString& codiva = c.vendite().get(CFV_ASSFIS);
if (!c.use_lettere())
return codiva;
const TCodiceIVA i(codiva);
if (!i.has_plafond()) // Era presente nella 3.x, poi è sparito nella 10, ora torna nella 11.0 (7-3-2013)
return codiva;
if (!c.use_lettere() || c.read_lettera(get_date(DOC_DATADOC)))
return c.vendite().get(CFV_ASSFIS);
return EMPTY_STRING;
const TDate datadoc = get(DOC_DATADOC);
if (c.read_lettera(datadoc))
return c.vendite().get(CFV_ASSFIS); // codiva may be lost
return EMPTY_STRING;
}
void TDocumento::get_protocolli_esenzione(TString & esenzione, TString & data_esenzione,
TString & registrazione, TString & data_registrazione) const
void TDocumento::get_protocolli_esenzione(TString& esenzione, TString& data_esenzione,
TString& registrazione, TString& data_registrazione) const
{
TCli_for& c = clifor();
if (c.use_lettere())

View File

@ -23,7 +23,7 @@ TFatturazione_bolle::TFatturazione_bolle(const char* cod)
TFatturazione_bolle::TFatturazione_bolle(const TRectype& rec)
: TElaborazione(rec)
{
TString cod(rec.get("CODTAB"));
const TString8 cod = rec.get("CODTAB");
TString80 name; name.format("AGGFLD(%s)", cod);
_lista_campi = ini_get_string(CONFIG_DITTA, "ve", name);
@ -383,38 +383,45 @@ bool TFatturazione_bolle::elabora(TLista_documenti& doc_in, TLista_documenti& do
TToken_string s("", '=');
for (s = _lista_campi.get(0); s.full(); s = _lista_campi.get())
{
TString16 oname(s.get());
const TString16 oname(s.get());
TString16 iname(s.get());
if (oname == RDOC_CODIVA)
{
const int rows = campione.physical_rows();
const TString8 codesiva = campione.codesiva();
const TString4 codesiva = campione.codesiva();
FOR_EACH_PHYSICAL_RDOC(campione, i, rdoc)
{
if (codesiva.full())
rdoc->put(RDOC_CODIVA, codesiva);
else
{
if (rdoc->is_articolo())
{
const TArticolo_giacenza & art = rdoc->articolo();
const TString8 codiva = art.get(ANAMAG_CODIVA);
if (codiva.full())
rdoc->put(RDOC_CODIVA, codiva);
}
else
if ((rdoc->is_spese() || rdoc->is_prestazione()))
{
const TSpesa_prest & s = rdoc->spesa();
const TString8 codiva = s.cod_iva();
FOR_EACH_PHYSICAL_RDOC(campione, i, rdoc)
{
// Elabora solo righe articolo, spese o prestazioni valide
if (!rdoc->is_descrizione())
{
if (codesiva.full())
{
if (rdoc->imponibile().is_zero())
rdoc->zero(RDOC_CODIVA);
else
rdoc->put(RDOC_CODIVA, codesiva);
}
else
{
if (rdoc->is_articolo())
{
const TArticolo_giacenza& art = rdoc->articolo();
const TString& codiva = art.get(ANAMAG_CODIVA);
if (codiva.full())
rdoc->put(RDOC_CODIVA, codiva);
} else
if ((rdoc->is_spese() || rdoc->is_prestazione()))
{
const TSpesa_prest& s = rdoc->spesa();
const TString& codiva = s.cod_iva();
if (codiva.full())
rdoc->put(RDOC_CODIVA, codiva);
}
}
}
}
}
}
}
}
else
{

View File

@ -4135,7 +4135,7 @@ void TContabilizzazione::display_error(TDocumento& doc)
break;
case nr_reg_error:
msg.format("Rilevato un numero di registrazione errato contabilizzando il documento %s/%ld."
"Verificare l'integrita' del file movimenti.",(const char*)numerazione,numero);
"Verificare l'integrità del file movimenti.",(const char*)numerazione,numero);
break;
case nr_doc_error:
msg.format("Rilevato un numero di documento errato contabilizzando il documento %s/%ld."
@ -4143,7 +4143,7 @@ void TContabilizzazione::display_error(TDocumento& doc)
break;
case chg_stat_error:
msg.format("Rilevato un errore cambiando lo stato al documento %s/%ld."
"Verificare l'integrita' del file documenti.",(const char*)numerazione,numero);
"Verificare l'integrità del file documenti.",(const char*)numerazione,numero);
break;
case clifo_error:
msg.format("Rilevato un errore caricando le informazioni del Cli/Fo sul documento %s/%ld."

View File

@ -244,7 +244,7 @@ int TDocumentoEsteso::readat(TBaseisamfile& file, TRecnotype nrec, word lockop)
TDocumentoEsteso::TDocumentoEsteso(const TRectype& rec)
: TDocumento(rec), _sum_filter(-1), _sum_selected(FALSE), _scadenze_current(-1),
_conai(NULL)
_conai(NULL), _tic(NULL)
{
// Inizializza i parametri di default
@ -253,25 +253,29 @@ TDocumentoEsteso::TDocumentoEsteso(const TRectype& rec)
TDocumentoEsteso::TDocumentoEsteso(const TRectype& rec, dec_parm & parm)
: TDocumento(rec), _sum_filter(-1), _sum_selected(FALSE), _scadenze_current(-1),
_conai(NULL)
_conai(NULL), _tic(NULL)
{
_parm = parm;
}
TDocumentoEsteso::TDocumentoEsteso()
: TDocumento(), _sum_filter(-1), _sum_selected(FALSE), _scadenze_current(-1),
_conai(NULL)
_conai(NULL), _tic(NULL)
{ }
TDocumentoEsteso::~TDocumentoEsteso()
{ }
{
if (_conai) delete _conai;
if (_tic) delete _tic;
}
void TDocumentoEsteso::set_riga_conai()
{
if(_conai != NULL)
if (_conai != NULL)
{
delete _conai;
_conai = NULL;
_conai = NULL;
}
if (rows() > 0)
{
const bool has_conai = (tipo().add_conai() && clifor().vendite().get_bool(CFV_CONAIASS));
@ -287,10 +291,51 @@ void TDocumentoEsteso::set_riga_conai()
}
}
TRiga_documento & TDocumentoEsteso::row(int index)
{
if (index == TDocumento::rows() + 1)
return * _conai;
void TDocumentoEsteso::set_riga_tic()
{
if (_tic != NULL)
{
delete _tic;
_tic = NULL;
}
if (get_int(DOC_ANNO) >= 2013 && is_fattura())
{
FOR_EACH_PHYSICAL_RDOC(*this, r, rdoc) if (!rdoc->is_descrizione())
{
const TString& cod = rdoc->get(RDOC_CODIVA);
if (cod.full() && !rdoc->imponibile().is_zero())
{
const TCodiceIVA iva(cod);
TString4 tic; tic.format("%04d", iva.get_int("I1"));
if (tic != "0000")
{
_tic = new TRiga_documento(this, "05");
_tic->put(RDOC_DESCR, cache().get("%TIC", tic, "S0"));
break;
}
}
}
}
}
int TDocumentoEsteso::rows() const
{
int n = TDocumento::rows();
if (_conai) n++;
if (_tic) n++;
return n;
}
TRiga_documento& TDocumentoEsteso::row(int index)
{
const int n = TDocumento::rows();
if (index > n)
{
if (_conai != NULL && _tic != NULL)
return index == n+1 ? *_conai : *_tic;
else
return _conai ? *_conai : *_tic;
}
return TDocumento::row(index);
}

View File

@ -20,7 +20,8 @@ class TDocumentoEsteso : public TDocumento
{
// Parametri del documento
dec_parm _parm; // Parametri per gli arrotondamenti
TRiga_documento * _conai;
TRiga_documento* _conai;
TRiga_documento* _tic;
// membri per il calcolo del riepilogo IVA
@ -68,11 +69,11 @@ public:
// pertanto i non imponibili avranno selettore 1 e gli esenti selettore 4.
// per avere esenti + non soggetti il selettore sara' 20 e cosi' via.
real tot_imponibili(byte selector);
virtual int rows() const { return TDocumento::rows() + ((_conai != NULL) ? 1 : 0); }
virtual TRiga_documento & row(int index);
virtual int rows() const;
virtual TRiga_documento& row(int index);
void set_riga_conai();
void set_riga_tic();
// Funzioni per settare i parametri
void set_decimals(dec_parm & parm) { _parm = parm ; }

View File

@ -311,7 +311,7 @@ TDocumento_mask::TDocumento_mask(const char* td)
}
}
if (main_app().has_module(CUAUT))
if (main_app().has_module(CTAUT))
{
if (_ges_ca && id2pos(F_CUP) > 0)
{

View File

@ -2777,7 +2777,7 @@ bool codcms_handler(TMask_field& f, KEY key)
}
}
if (main_app().has_module(CUAUT) && (key == K_TAB && f.focusdirty()))
if (main_app().has_module(CTAUT) && (key == K_TAB && f.focusdirty()))
{
TToken_string key;
static TRecord_cache __cfcm(LF_CFCMS, 4);
@ -3279,7 +3279,7 @@ bool TNar_mask::show_note()
const TRecnotype items = cur.items();
if (items > 0)
{
close();
// close(); // Pare un doppione rispetto alla close() precedente
cur.freeze();
const TRectype& curr = rel.curr();
TSheet_field& sheet = sfield(N_NOTES);