Patch level : 12.0 428
Files correlati : Corretta l'impostazione del flag split payment nella contabilizzazione fatture. Gestita la concorrenza nell'attribuzione del protocollo IVA sempre in contabilizzazione git-svn-id: svn://10.65.10.50/branches/R_10_00@24026 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
d0696d8126
commit
53df66542c
@ -907,6 +907,8 @@ public:
|
|||||||
const TString & codesiva() const;
|
const TString & codesiva() const;
|
||||||
void get_protocolli_esenzione(TString & esenzione, TString & data_esenzione,
|
void get_protocolli_esenzione(TString & esenzione, TString & data_esenzione,
|
||||||
TString & registrazione, TString & data_registrazione) const;
|
TString & registrazione, TString & data_registrazione) const;
|
||||||
|
bool is_split_payment() const;
|
||||||
|
|
||||||
void cli2doc() { clifor().cli2doc(*this); }
|
void cli2doc() { clifor().cli2doc(*this); }
|
||||||
TDocumento ();
|
TDocumento ();
|
||||||
TDocumento (const TDocumento& d);
|
TDocumento (const TDocumento& d);
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#include "../sv/svlib01.h"
|
#include "../sv/svlib01.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <causali.h>
|
||||||
|
|
||||||
#include "veini.h"
|
#include "veini.h"
|
||||||
#include "velib.h"
|
#include "velib.h"
|
||||||
#include "sconti.h"
|
#include "sconti.h"
|
||||||
@ -3240,3 +3242,27 @@ void TDocumento::get_protocolli_esenzione(TString& esenzione, TString& data_esen
|
|||||||
data_registrazione = c.vendite().get(CFV_NSDATAREG);
|
data_registrazione = c.vendite().get(CFV_NSDATAREG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TDocumento::is_split_payment() const
|
||||||
|
{
|
||||||
|
bool yes = get_int(DOC_ANNO) >= 2015 && clifor().get_bool(CLI_SPLITPAY) &&
|
||||||
|
(is_fattura() || is_nota_credito()) && !imposta().is_zero() && ritenute().is_zero();
|
||||||
|
if (yes)
|
||||||
|
{
|
||||||
|
const TRectype& causale = cache().get(LF_CAUSALI, tipo().causale());
|
||||||
|
const int rsi = causale.get_int(CAU_REGSPIVA);
|
||||||
|
yes = rsi != 13 && rsi != 50 && rsi != 51; // No reverse charge
|
||||||
|
if(yes && physical_rows() > 0)
|
||||||
|
{
|
||||||
|
TAssoc_array& table = ((TDocumento*)this)->tabella_iva();
|
||||||
|
|
||||||
|
for (TRiepilogo_iva * ri = (TRiepilogo_iva *) table.get(); ri != NULL && yes;
|
||||||
|
ri = (TRiepilogo_iva *) table.get())
|
||||||
|
{
|
||||||
|
TString ivaPA = cache().get("%IVA", ri->cod_iva().codice()).get("S12");
|
||||||
|
yes = ivaPA != "N6" && ivaPA != "N5";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return yes;
|
||||||
|
}
|
@ -1212,11 +1212,10 @@ error_type TContabilizzazione::compile_head_mov(TDocumento& doc)
|
|||||||
{
|
{
|
||||||
if (_nump_iva) // Reperisce l'ultimo numero di protocollo dal registro IVA
|
if (_nump_iva) // Reperisce l'ultimo numero di protocollo dal registro IVA
|
||||||
{
|
{
|
||||||
static int _ult_prot = -1;
|
TRegistro reg(registro);
|
||||||
if (_ult_prot < 0)
|
|
||||||
_ult_prot = registro.protocol();
|
ult_prot = registro.protocol();
|
||||||
_ult_prot++;
|
ult_prot++;
|
||||||
ult_prot = _ult_prot;
|
|
||||||
if (ult_prot <= 0)
|
if (ult_prot <= 0)
|
||||||
{
|
{
|
||||||
_error = ultprot_error;
|
_error = ultprot_error;
|
||||||
@ -1428,6 +1427,7 @@ error_type TContabilizzazione::compile_head_mov(TDocumento& doc)
|
|||||||
if (_caus->valintra())
|
if (_caus->valintra())
|
||||||
mov_rec.put(MOV_CORRVALUTA, corrval.get_num());
|
mov_rec.put(MOV_CORRVALUTA, corrval.get_num());
|
||||||
|
|
||||||
|
|
||||||
TDate dataintra = data_reg;
|
TDate dataintra = data_reg;
|
||||||
if (doc.tipo().nota_credito())
|
if (doc.tipo().nota_credito())
|
||||||
{
|
{
|
||||||
@ -1438,11 +1438,7 @@ error_type TContabilizzazione::compile_head_mov(TDocumento& doc)
|
|||||||
mov_rec.put(MOV_DATACOMPI, dataintra);
|
mov_rec.put(MOV_DATACOMPI, dataintra);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
mov_rec.put(MOV_SPLITPAY, doc.is_split_payment() ? 'S': 'N'); // Imposta nelle fatture di vendita normali il flag di split payment
|
||||||
// Imposta nelle fatture di vendita normali il flag di split payment
|
|
||||||
if (mov_rec.get_char(MOV_SPLITPAY) <= ' ')
|
|
||||||
mov_rec.put(MOV_SPLITPAY, is_split_payment(mov_rec) ? 'S': 'N');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,432 +1,424 @@
|
|||||||
#include "velib05.h"
|
#include "velib05.h"
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <diction.h>
|
#include <diction.h>
|
||||||
#include <utility.h>
|
#include <utility.h>
|
||||||
|
|
||||||
#include "../cg/cglib03.h"
|
#include "../cg/cglib03.h"
|
||||||
|
|
||||||
#include <causali.h>
|
#include <causali.h>
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
//TDocumentoEsteso
|
//TDocumentoEsteso
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
void TDocumentoEsteso::compile_summary()
|
void TDocumentoEsteso::compile_summary()
|
||||||
{
|
{
|
||||||
const int ndec = decimals();
|
const int ndec = decimals();
|
||||||
|
|
||||||
_sum_filter = 0;
|
_sum_filter = 0;
|
||||||
_summary_array.destroy();
|
_summary_array.destroy();
|
||||||
|
|
||||||
_summary_table = tabella_iva();
|
_summary_table = tabella_iva();
|
||||||
_summary_table.restart();
|
_summary_table.restart();
|
||||||
for (TRiepilogo_iva * ri = (TRiepilogo_iva *) _summary_table.get(); ri != NULL;
|
for (TRiepilogo_iva * ri = (TRiepilogo_iva *) _summary_table.get(); ri != NULL;
|
||||||
ri = (TRiepilogo_iva *) _summary_table.get())
|
ri = (TRiepilogo_iva *) _summary_table.get())
|
||||||
{
|
{
|
||||||
const real imponibile = ri->imponibile();
|
const real imponibile = ri->imponibile();
|
||||||
real imposta = ri->imposta();
|
real imposta = ri->imposta();
|
||||||
if (ndec == 0)
|
if (ndec == 0)
|
||||||
{
|
{
|
||||||
if (imposta < ZERO)
|
if (imposta < ZERO)
|
||||||
imposta.floor();
|
imposta.floor();
|
||||||
else
|
else
|
||||||
imposta.ceil();
|
imposta.ceil();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
imposta.round(ndec);
|
imposta.round(ndec);
|
||||||
|
|
||||||
ri->imp() = imponibile;
|
ri->imp() = imponibile;
|
||||||
ri->imp_spese() = ZERO;
|
ri->imp_spese() = ZERO;
|
||||||
ri->iva() = imposta;
|
ri->iva() = imposta;
|
||||||
ri->iva_spese() = ZERO;
|
ri->iva_spese() = ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inizializza l'array di ordine
|
// Inizializza l'array di ordine
|
||||||
if (_order_array.items() == 0)
|
if (_order_array.items() == 0)
|
||||||
{
|
{
|
||||||
TToken_string s;
|
TToken_string s;
|
||||||
for (int i = 0; i < 32; i++) // ??
|
for (int i = 0; i < 32; i++) // ??
|
||||||
_order_array.add(s);
|
_order_array.add(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int riep_sort(const TSortable& o1, const TSortable& o2, void*)
|
static int riep_sort(const TSortable& o1, const TSortable& o2, void*)
|
||||||
{
|
{
|
||||||
const TRiepilogo_iva& r1 = (const TRiepilogo_iva&)o1;
|
const TRiepilogo_iva& r1 = (const TRiepilogo_iva&)o1;
|
||||||
const TRiepilogo_iva& r2 = (const TRiepilogo_iva&)o2;
|
const TRiepilogo_iva& r2 = (const TRiepilogo_iva&)o2;
|
||||||
const real delta = r1.imposta() - r2.imposta();
|
const real delta = r1.imposta() - r2.imposta();
|
||||||
return delta.sign();
|
return delta.sign();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDocumentoEsteso::summary_filter(byte selector)
|
void TDocumentoEsteso::summary_filter(byte selector)
|
||||||
{
|
{
|
||||||
if (_sum_filter == -1)
|
if (_sum_filter == -1)
|
||||||
compile_summary(); // Crea la tabella se deve ancora farlo
|
compile_summary(); // Crea la tabella se deve ancora farlo
|
||||||
|
|
||||||
// se ha selezionato una riga in precedenza deve finire di stamparla
|
// se ha selezionato una riga in precedenza deve finire di stamparla
|
||||||
// ovvero non seleziona il filtro fino a quando non ha ricevuto una summary_set_next()
|
// ovvero non seleziona il filtro fino a quando non ha ricevuto una summary_set_next()
|
||||||
if (_sum_selected)
|
if (_sum_selected)
|
||||||
return;
|
return;
|
||||||
//
|
//
|
||||||
// Procedimento:
|
// Procedimento:
|
||||||
// Memorizza in un TString_array tante TToken_string quanti sono i filtri possibili
|
// Memorizza in un TString_array tante TToken_string quanti sono i filtri possibili
|
||||||
// (al massimo 31 [1+2+4+8+16]). Ogni TToken_string contiene i codici IVA
|
// (al massimo 31 [1+2+4+8+16]). Ogni TToken_string contiene i codici IVA
|
||||||
// delle righe di TRiepilogo_iva che soddisfano la condizione di filtro
|
// delle righe di TRiepilogo_iva che soddisfano la condizione di filtro
|
||||||
_sum_selected = true;
|
_sum_selected = true;
|
||||||
_sum_filter = selector;
|
_sum_filter = selector;
|
||||||
CHECKD(_sum_filter > 0 && _sum_filter <= 32, "Bad selector ", _sum_filter);
|
CHECKD(_sum_filter > 0 && _sum_filter <= 32, "Bad selector ", _sum_filter);
|
||||||
TToken_string& codici = _order_array.row(_sum_filter-1);
|
TToken_string& codici = _order_array.row(_sum_filter-1);
|
||||||
if (codici.blank()) // Se non c'e' nemmeno un codice IVA allora deve effettuare il filtro
|
if (codici.blank()) // Se non c'e' nemmeno un codice IVA allora deve effettuare il filtro
|
||||||
{ // ovvero mette in <<codici>> tutti i codici IVA che soddisfano tale filtro
|
{ // ovvero mette in <<codici>> tutti i codici IVA che soddisfano tale filtro
|
||||||
// sara' poi la summary_set_next() a selezionare sequenzialmente il giusto codice a seconda del filtro corrente
|
// sara' poi la summary_set_next() a selezionare sequenzialmente il giusto codice a seconda del filtro corrente
|
||||||
|
|
||||||
// Scorre sequenzialmente la tabella _summary_table e compone la TToken_string con i codici IVA
|
// Scorre sequenzialmente la tabella _summary_table e compone la TToken_string con i codici IVA
|
||||||
/*
|
/*
|
||||||
const int items = summary_items();
|
const int items = summary_items();
|
||||||
TRiepilogo_iva* curr = (TRiepilogo_iva *) _summary_table.first_item();
|
TRiepilogo_iva* curr = (TRiepilogo_iva *) _summary_table.first_item();
|
||||||
for (int i = 0; i < items && curr != NULL; i++)
|
for (int i = 0; i < items && curr != NULL; i++)
|
||||||
{
|
{
|
||||||
if (curr->tipo() & _sum_filter) // se fa parte del filtro selezionato schiaffa il codice nella TToken_string
|
if (curr->tipo() & _sum_filter) // se fa parte del filtro selezionato schiaffa il codice nella TToken_string
|
||||||
codici.add(curr->cod_iva().codice());
|
codici.add(curr->cod_iva().codice());
|
||||||
curr = (TRiepilogo_iva*) _summary_table.succ_item();
|
curr = (TRiepilogo_iva*) _summary_table.succ_item();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Ordina i riepiloghi in ordine descrescente di imposta (Da marzo 2016)
|
// Ordina i riepiloghi in ordine descrescente di imposta (Da marzo 2016)
|
||||||
TPointer_array ri;
|
TPointer_array ri;
|
||||||
FOR_EACH_ASSOC_OBJECT(_summary_table, obj, key, itm)
|
FOR_EACH_ASSOC_OBJECT(_summary_table, obj, key, itm)
|
||||||
{
|
{
|
||||||
TRiepilogo_iva* curr = (TRiepilogo_iva*)itm;
|
TRiepilogo_iva* curr = (TRiepilogo_iva*)itm;
|
||||||
if (curr->tipo() & _sum_filter) // se fa parte del filtro selezionato schiaffa il codice nella lista
|
if (curr->tipo() & _sum_filter) // se fa parte del filtro selezionato schiaffa il codice nella lista
|
||||||
ri.add(curr);
|
ri.add(curr);
|
||||||
}
|
}
|
||||||
ri.sort(riep_sort, NULL);
|
ri.sort(riep_sort, NULL);
|
||||||
FOR_EACH_ARRAY_ITEM(ri, r, obj)
|
FOR_EACH_ARRAY_ITEM(ri, r, obj)
|
||||||
{
|
{
|
||||||
const TRiepilogo_iva* curr = (const TRiepilogo_iva*)obj;
|
const TRiepilogo_iva* curr = (const TRiepilogo_iva*)obj;
|
||||||
codici.add(curr->cod_iva().codice());
|
codici.add(curr->cod_iva().codice());
|
||||||
}
|
}
|
||||||
// Fine ordinamento
|
// Fine ordinamento
|
||||||
|
|
||||||
codici.restart();
|
codici.restart();
|
||||||
summary_set_next(); // setta l'elemento corrente
|
summary_set_next(); // setta l'elemento corrente
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDocumentoEsteso::summary_reset(bool force)
|
void TDocumentoEsteso::summary_reset(bool force)
|
||||||
{
|
{
|
||||||
if (force)
|
if (force)
|
||||||
{
|
{
|
||||||
_sum_filter = -1;
|
_sum_filter = -1;
|
||||||
_sum_selected = false;
|
_sum_selected = false;
|
||||||
}
|
}
|
||||||
FOR_EACH_ARRAY_ROW(_order_array, i, row)
|
FOR_EACH_ARRAY_ROW(_order_array, i, row)
|
||||||
row->cut(0);
|
row->cut(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDocumentoEsteso::summary_set_next()
|
void TDocumentoEsteso::summary_set_next()
|
||||||
{
|
{
|
||||||
_sum_selected = false;
|
_sum_selected = false;
|
||||||
TToken_string& codici = _order_array.row(_sum_filter-1);
|
TToken_string& codici = _order_array.row(_sum_filter-1);
|
||||||
|
|
||||||
const TString4 codiva(codici.get()); // Reperisce il prossimo codice nella lista. (son gia' ordinati per codice)
|
const TString4 codiva(codici.get()); // Reperisce il prossimo codice nella lista. (son gia' ordinati per codice)
|
||||||
if (codiva.full() && _summary_table.is_key(codiva))
|
if (codiva.full() && _summary_table.is_key(codiva))
|
||||||
{
|
{
|
||||||
// Estrae da _summary_table i dati relativio al codice corrispondente.
|
// Estrae da _summary_table i dati relativio al codice corrispondente.
|
||||||
const TRiepilogo_iva& riep= (const TRiepilogo_iva&) _summary_table[codiva];
|
const TRiepilogo_iva& riep= (const TRiepilogo_iva&) _summary_table[codiva];
|
||||||
_sum_current = riep;
|
_sum_current = riep;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const TRiepilogo_iva i;
|
const TRiepilogo_iva i;
|
||||||
_sum_current = i; // se non esiste il codice azzera l'elemento corrente (non stampera' nulla)
|
_sum_current = i; // se non esiste il codice azzera l'elemento corrente (non stampera' nulla)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * TDocumentoEsteso::summary_get(const TString& w)
|
const char * TDocumentoEsteso::summary_get(const TString& w)
|
||||||
{
|
{
|
||||||
if (w == "COD") // Ritorna il codice IVA
|
if (w == "COD") // Ritorna il codice IVA
|
||||||
return _sum_current.cod_iva().codice(); else
|
return _sum_current.cod_iva().codice(); else
|
||||||
if (w == "IMP") // Ritorna l'imponibile
|
if (w == "IMP") // Ritorna l'imponibile
|
||||||
return _sum_current.imp().string(); else
|
return _sum_current.imp().string(); else
|
||||||
if (w == "IVA") // Ritorna l'imposta
|
if (w == "IVA") // Ritorna l'imposta
|
||||||
return _sum_current.iva().string(); else
|
return _sum_current.iva().string(); else
|
||||||
if (w == "ALI") // Ritorna l'aliquota %
|
if (w == "ALI") // Ritorna l'aliquota %
|
||||||
return _sum_current.cod_iva().percentuale().string(); else
|
return _sum_current.cod_iva().percentuale().string(); else
|
||||||
if (w == "DES") // Ritorna la descrizione ( se il codice e' regime normale la descr. e' vuota)
|
if (w == "DES") // Ritorna la descrizione ( se il codice e' regime normale la descr. e' vuota)
|
||||||
{
|
{
|
||||||
if (_sum_current.cod_iva().tipo().not_empty())
|
if (_sum_current.cod_iva().tipo().not_empty())
|
||||||
return _sum_current.cod_iva().descrizione();
|
return _sum_current.cod_iva().descrizione();
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDocumentoEsteso::scadenze_recalc()
|
void TDocumentoEsteso::scadenze_recalc()
|
||||||
{
|
{
|
||||||
_scadenze_array.destroy();
|
_scadenze_array.destroy();
|
||||||
_scadenze_current = -1;
|
_scadenze_current = -1;
|
||||||
TRectype& hh = head();
|
TRectype& hh = head();
|
||||||
TPagamento& pag = pagamento();
|
TPagamento& pag = pagamento();
|
||||||
real totspese = spese();
|
real totspese = spese();
|
||||||
real totimposte = imposta(TRUE);
|
real totimposte = imposta(TRUE);
|
||||||
const bool anticipo = clifor().vendite().get(CFV_CODCAUSINC).full() || tipo().caus_anticipo().full();
|
const bool anticipo = clifor().vendite().get(CFV_CODCAUSINC).full() || tipo().caus_anticipo().full();
|
||||||
real pagato = anticipo ? hh.get_real(DOC_IMPPAGATO) : ZERO;
|
real pagato = anticipo ? hh.get_real(DOC_IMPPAGATO) : ZERO;
|
||||||
const bool saldo = hh.get_bool(DOC_ACCSALDO);
|
const bool saldo = hh.get_bool(DOC_ACCSALDO);
|
||||||
real totimponibili = totale_doc() - ritenute() - totimposte - totspese;
|
real totimponibili = totale_doc() - ritenute() - totimposte - totspese;
|
||||||
const bool is_in_valuta = in_valuta();
|
const bool is_in_valuta = in_valuta();
|
||||||
|
|
||||||
if (is_split_payment())
|
if (is_split_payment())
|
||||||
totimposte = ZERO;
|
totimposte = ZERO;
|
||||||
|
|
||||||
if (saldo || pagato > totale_doc())
|
if (saldo || pagato > totale_doc())
|
||||||
{
|
{
|
||||||
totimponibili = ZERO;
|
totimponibili = ZERO;
|
||||||
totimposte = ZERO;
|
totimposte = ZERO;
|
||||||
totspese = ZERO;
|
totspese = ZERO;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TGeneric_distrib d(pagato, decimals());
|
TGeneric_distrib d(pagato, decimals());
|
||||||
|
|
||||||
d.add(totimponibili);
|
d.add(totimponibili);
|
||||||
d.add(totimposte);
|
d.add(totimposte);
|
||||||
d.add(totspese);
|
d.add(totspese);
|
||||||
|
|
||||||
totimponibili -= d.get();
|
totimponibili -= d.get();
|
||||||
totimposte -= d.get();
|
totimposte -= d.get();
|
||||||
totspese -= d.get();
|
totspese -= d.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_in_valuta)
|
if (is_in_valuta)
|
||||||
{
|
{
|
||||||
const real change(cambio());
|
const real change(cambio());
|
||||||
TCurrency_documento val1(totimponibili, *this); val1.change_to_firm_val();
|
TCurrency_documento val1(totimponibili, *this); val1.change_to_firm_val();
|
||||||
TCurrency_documento val2(totimposte, *this); val2.change_to_firm_val();
|
TCurrency_documento val2(totimposte, *this); val2.change_to_firm_val();
|
||||||
TCurrency_documento val3(totspese, *this); val3.change_to_firm_val();
|
TCurrency_documento val3(totspese, *this); val3.change_to_firm_val();
|
||||||
TString4 codval = valuta();
|
TString4 codval = valuta();
|
||||||
pag.set_total_valuta(totimponibili, totimposte, totspese, change, val1.get_num(), val2.get_num() ,val3.get_num(), codval);
|
pag.set_total_valuta(totimponibili, totimposte, totspese, change, val1.get_num(), val2.get_num() ,val3.get_num(), codval);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pag.set_total(totimponibili, totimposte, totspese);
|
pag.set_total(totimponibili, totimposte, totspese);
|
||||||
pag.set_rate_auto();
|
pag.set_rate_auto();
|
||||||
const int numrate = pag.n_rate( );
|
const int numrate = pag.n_rate( );
|
||||||
real rata;
|
real rata;
|
||||||
for (int i = 0; i< numrate; i++)
|
for (int i = 0; i< numrate; i++)
|
||||||
{
|
{
|
||||||
rata = pag.importo_rata(i, is_in_valuta);
|
rata = pag.importo_rata(i, is_in_valuta);
|
||||||
TToken_string t;
|
TToken_string t;
|
||||||
t.add(pag.data_rata(i));
|
t.add(pag.data_rata(i));
|
||||||
t.add(rata.string());
|
t.add(rata.string());
|
||||||
_scadenze_array.add(t);
|
_scadenze_array.add(t);
|
||||||
}
|
}
|
||||||
if (_scadenze_array.items() > 0)
|
if (_scadenze_array.items() > 0)
|
||||||
_scadenze_current++;
|
_scadenze_current++;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* TDocumentoEsteso::scadenze_get(const TString& w)
|
const char* TDocumentoEsteso::scadenze_get(const TString& w)
|
||||||
{
|
{
|
||||||
// TString ret; // Pena di morte
|
// TString ret; // Pena di morte
|
||||||
const char* ret = "";
|
const char* ret = "";
|
||||||
|
|
||||||
if (_scadenze_current == -1)
|
if (_scadenze_current == -1)
|
||||||
// calcola le scadenze e le mette in _scadenze_array
|
// calcola le scadenze e le mette in _scadenze_array
|
||||||
scadenze_recalc();
|
scadenze_recalc();
|
||||||
if (_scadenze_current > -1 && _scadenze_current < _scadenze_array.items())
|
if (_scadenze_current > -1 && _scadenze_current < _scadenze_array.items())
|
||||||
{
|
{
|
||||||
if (w == "DATA")
|
if (w == "DATA")
|
||||||
ret = _scadenze_array.row(_scadenze_current).get(0); // ritorna la data di scadenza
|
ret = _scadenze_array.row(_scadenze_current).get(0); // ritorna la data di scadenza
|
||||||
if (w == "IMPORTO")
|
if (w == "IMPORTO")
|
||||||
ret = _scadenze_array.row(_scadenze_current).get(1); // ritorna l'importo in scadenza
|
ret = _scadenze_array.row(_scadenze_current).get(1); // ritorna l'importo in scadenza
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDocumentoEsteso::scadenze_set_next()
|
void TDocumentoEsteso::scadenze_set_next()
|
||||||
{
|
{
|
||||||
if (_scadenze_current >= 0 &&
|
if (_scadenze_current >= 0 &&
|
||||||
_scadenze_current < _scadenze_array.items() )
|
_scadenze_current < _scadenze_array.items() )
|
||||||
_scadenze_current++;
|
_scadenze_current++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDocumentoEsteso::scadenze_reset()
|
void TDocumentoEsteso::scadenze_reset()
|
||||||
{
|
{
|
||||||
if (_scadenze_current > 0)
|
if (_scadenze_current > 0)
|
||||||
_scadenze_current = 0;
|
_scadenze_current = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
real TDocumentoEsteso::tot_imponibili(byte selector)
|
real TDocumentoEsteso::tot_imponibili(byte selector)
|
||||||
{
|
{
|
||||||
if (!summary_compiled())
|
if (!summary_compiled())
|
||||||
compile_summary();
|
compile_summary();
|
||||||
|
|
||||||
real number = 0.0;
|
real number = 0.0;
|
||||||
const int items = summary_items();
|
const int items = summary_items();
|
||||||
TRiepilogo_iva* curr = (TRiepilogo_iva *) _summary_table.first_item();
|
TRiepilogo_iva* curr = (TRiepilogo_iva *) _summary_table.first_item();
|
||||||
for (int i = 0; i < items && curr != NULL; i++)
|
for (int i = 0; i < items && curr != NULL; i++)
|
||||||
{
|
{
|
||||||
if (curr->tipo() & selector) // se fa parte del filtro selezionato schiaffa il codice nella TToken_string
|
if (curr->tipo() & selector) // se fa parte del filtro selezionato schiaffa il codice nella TToken_string
|
||||||
number += curr->imp();
|
number += curr->imp();
|
||||||
curr = (TRiepilogo_iva *) _summary_table.succ_item();
|
curr = (TRiepilogo_iva *) _summary_table.succ_item();
|
||||||
}
|
}
|
||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TDocumentoEsteso::readat(TBaseisamfile& file, TRecnotype nrec, word lockop)
|
int TDocumentoEsteso::readat(TBaseisamfile& file, TRecnotype nrec, word lockop)
|
||||||
{
|
{
|
||||||
int err = TDocumento::readat(file, nrec, lockop);
|
int err = TDocumento::readat(file, nrec, lockop);
|
||||||
dirty_tabella_iva();
|
dirty_tabella_iva();
|
||||||
summary_reset(true);
|
summary_reset(true);
|
||||||
scadenze_reset();
|
scadenze_reset();
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
TDocumentoEsteso::TDocumentoEsteso(const TRectype& rec)
|
TDocumentoEsteso::TDocumentoEsteso(const TRectype& rec)
|
||||||
: TDocumento(rec), _sum_filter(-1), _sum_selected(FALSE), _scadenze_current(-1),
|
: TDocumento(rec), _sum_filter(-1), _sum_selected(FALSE), _scadenze_current(-1),
|
||||||
_conai(NULL), _tic(NULL), _split(NULL)
|
_conai(NULL), _tic(NULL), _split(NULL)
|
||||||
|
|
||||||
{
|
{
|
||||||
// Inizializza i parametri di default
|
// Inizializza i parametri di default
|
||||||
_parm.qta_lit = 3; _parm.qta_val = 3;
|
_parm.qta_lit = 3; _parm.qta_val = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
TDocumentoEsteso::TDocumentoEsteso(const TRectype& rec, dec_parm & parm)
|
TDocumentoEsteso::TDocumentoEsteso(const TRectype& rec, dec_parm & parm)
|
||||||
: TDocumento(rec), _sum_filter(-1), _sum_selected(FALSE), _scadenze_current(-1),
|
: TDocumento(rec), _sum_filter(-1), _sum_selected(FALSE), _scadenze_current(-1),
|
||||||
_conai(NULL), _tic(NULL), _split(NULL)
|
_conai(NULL), _tic(NULL), _split(NULL)
|
||||||
{
|
{
|
||||||
_parm = parm;
|
_parm = parm;
|
||||||
}
|
}
|
||||||
|
|
||||||
TDocumentoEsteso::TDocumentoEsteso()
|
TDocumentoEsteso::TDocumentoEsteso()
|
||||||
: TDocumento(), _sum_filter(-1), _sum_selected(FALSE), _scadenze_current(-1),
|
: TDocumento(), _sum_filter(-1), _sum_selected(FALSE), _scadenze_current(-1),
|
||||||
_conai(NULL), _tic(NULL), _split(NULL)
|
_conai(NULL), _tic(NULL), _split(NULL)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
TDocumentoEsteso::~TDocumentoEsteso()
|
TDocumentoEsteso::~TDocumentoEsteso()
|
||||||
{
|
{
|
||||||
if (_conai) delete _conai;
|
if (_conai) delete _conai;
|
||||||
if (_tic) delete _tic;
|
if (_tic) delete _tic;
|
||||||
if (_split) delete _split;
|
if (_split) delete _split;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDocumentoEsteso::set_riga_conai()
|
void TDocumentoEsteso::set_riga_conai()
|
||||||
{
|
{
|
||||||
if (_conai != NULL)
|
if (_conai != NULL)
|
||||||
{
|
{
|
||||||
delete _conai;
|
delete _conai;
|
||||||
_conai = NULL;
|
_conai = NULL;
|
||||||
}
|
}
|
||||||
if (physical_rows() > 0)
|
if (physical_rows() > 0)
|
||||||
{
|
{
|
||||||
const bool has_conai = (tipo().add_conai() && clifor().vendite().get_bool(CFV_CONAIASS));
|
const bool has_conai = (tipo().add_conai() && clifor().vendite().get_bool(CFV_CONAIASS));
|
||||||
if (has_conai)
|
if (has_conai)
|
||||||
{
|
{
|
||||||
_conai = new TRiga_documento(this, "05");
|
_conai = new TRiga_documento(this, "05");
|
||||||
|
|
||||||
TString conai = ini_get_string(CONFIG_DITTA, "ve", "DESCCONAIASS");
|
TString conai = ini_get_string(CONFIG_DITTA, "ve", "DESCCONAIASS");
|
||||||
if (conai.blank()) // se la variabile e' vuota ma scritta sull ini non stampa nulla
|
if (conai.blank()) // se la variabile e' vuota ma scritta sull ini non stampa nulla
|
||||||
conai = TR("Contributo CONAI assolto");
|
conai = TR("Contributo CONAI assolto");
|
||||||
_conai->put(RDOC_DESCR, conai);
|
_conai->put(RDOC_DESCR, conai);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDocumentoEsteso::set_riga_tic()
|
void TDocumentoEsteso::set_riga_tic()
|
||||||
{
|
{
|
||||||
if (_tic != NULL)
|
if (_tic != NULL)
|
||||||
{
|
{
|
||||||
delete _tic;
|
delete _tic;
|
||||||
_tic = NULL;
|
_tic = NULL;
|
||||||
}
|
}
|
||||||
if (get_int(DOC_ANNO) >= 2013 && is_fattura())
|
if (get_int(DOC_ANNO) >= 2013 && is_fattura())
|
||||||
{
|
{
|
||||||
FOR_EACH_PHYSICAL_RDOC(*this, r, rdoc) if (!rdoc->is_descrizione())
|
FOR_EACH_PHYSICAL_RDOC(*this, r, rdoc) if (!rdoc->is_descrizione())
|
||||||
{
|
{
|
||||||
const TString& cod = rdoc->get(RDOC_CODIVA);
|
const TString& cod = rdoc->get(RDOC_CODIVA);
|
||||||
if (cod.full() && !rdoc->imponibile().is_zero())
|
if (cod.full() && !rdoc->imponibile().is_zero())
|
||||||
{
|
{
|
||||||
const TCodiceIVA iva(cod);
|
const TCodiceIVA iva(cod);
|
||||||
TString4 tic; tic.format("%04d", iva.get_int("I1"));
|
TString4 tic; tic.format("%04d", iva.get_int("I1"));
|
||||||
if (tic != "0000")
|
if (tic != "0000")
|
||||||
{
|
{
|
||||||
_tic = new TRiga_documento(this, "05");
|
_tic = new TRiga_documento(this, "05");
|
||||||
_tic->put(RDOC_DESCR, cache().get("%TIC", tic, "S0"));
|
_tic->put(RDOC_DESCR, cache().get("%TIC", tic, "S0"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TDocumentoEsteso::is_split_payment() const
|
/*bool TDocumentoEsteso::is_split_payment() const
|
||||||
{/*
|
{
|
||||||
const long numregcg = get_long(DOC_NUMREG);
|
bool yes = get_int(DOC_ANNO) >= 2015 && clifor().get_bool(CLI_SPLITPAY) &&
|
||||||
if (numregcg > 0)
|
(is_fattura() || is_nota_credito()) && !imposta().is_zero() && ritenute().is_zero();
|
||||||
{
|
if (yes)
|
||||||
const TRectype& mov = cache().get(LF_MOV, numregcg);
|
{
|
||||||
if (!mov.empty())
|
const TRectype& causale = cache().get(LF_CAUSALI, tipo().causale());
|
||||||
return ::is_split_payment(mov);
|
const int rsi = causale.get_int(CAU_REGSPIVA);
|
||||||
}
|
yes = rsi != 13 && rsi != 50 && rsi != 51; // No reverse charge
|
||||||
*/
|
if(yes && physical_rows() > 0)
|
||||||
bool yes = get_int(DOC_ANNO) >= 2015 && clifor().get_bool(CLI_SPLITPAY) &&
|
|
||||||
(is_fattura() || is_nota_credito()) && !imposta().is_zero() && ritenute().is_zero();
|
|
||||||
if (yes)
|
|
||||||
{
|
|
||||||
const TRectype& causale = cache().get(LF_CAUSALI, tipo().causale());
|
|
||||||
const int rsi = causale.get_int(CAU_REGSPIVA);
|
|
||||||
yes = rsi != 13 && rsi != 50 && rsi != 51; // No reverse charge
|
|
||||||
if(yes && physical_rows() > 0)
|
|
||||||
{
|
{
|
||||||
TAssoc_array& table = ((TDocumento*)this)->tabella_iva();
|
TAssoc_array& table = ((TDocumento*)this)->tabella_iva();
|
||||||
|
|
||||||
for (TRiepilogo_iva * ri = (TRiepilogo_iva *) table.get(); ri != NULL && yes;
|
for (TRiepilogo_iva * ri = (TRiepilogo_iva *) table.get(); ri != NULL && yes;
|
||||||
ri = (TRiepilogo_iva *) table.get())
|
ri = (TRiepilogo_iva *) table.get())
|
||||||
{
|
{
|
||||||
TString ivaPA = cache().get("%IVA", ri->cod_iva().codice()).get("S12");
|
TString ivaPA = cache().get("%IVA", ri->cod_iva().codice()).get("S12");
|
||||||
yes = ivaPA != "N6" && ivaPA != "N5";
|
yes = ivaPA != "N6" && ivaPA != "N5";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return yes;
|
return yes;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void TDocumentoEsteso::set_riga_split()
|
void TDocumentoEsteso::set_riga_split()
|
||||||
{
|
{
|
||||||
if (_split != NULL)
|
if (_split != NULL)
|
||||||
{
|
{
|
||||||
delete _split;
|
delete _split;
|
||||||
_split = NULL;
|
_split = NULL;
|
||||||
}
|
}
|
||||||
if (is_split_payment())
|
if (is_split_payment())
|
||||||
{
|
{
|
||||||
_split = new TRiga_documento(this, "05");
|
_split = new TRiga_documento(this, "05");
|
||||||
TString split = esc(ini_get_string(CONFIG_DITTA, "ve", "DESCSPLIT", TR("SCISSIONE DEI PAGAMENTI Art.17-ter D.P.R. 633/72")));
|
TString split = esc(ini_get_string(CONFIG_DITTA, "ve", "DESCSPLIT", TR("SCISSIONE DEI PAGAMENTI Art.17-ter D.P.R. 633/72")));
|
||||||
if (split[0] > ' ') split.insert("\n");
|
if (split[0] > ' ') split.insert("\n");
|
||||||
_split->set_descr(split);
|
_split->set_descr(split);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int TDocumentoEsteso::rows() const
|
int TDocumentoEsteso::rows() const
|
||||||
{
|
{
|
||||||
int n = TDocumento::rows();
|
int n = TDocumento::rows();
|
||||||
if (_conai) n++;
|
if (_conai) n++;
|
||||||
if (_tic) n++;
|
if (_tic) n++;
|
||||||
if (_split) n++;
|
if (_split) n++;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRiga_documento& TDocumentoEsteso::row(int index)
|
TRiga_documento& TDocumentoEsteso::row(int index)
|
||||||
{
|
{
|
||||||
const int n = TDocumento::rows();
|
const int n = TDocumento::rows();
|
||||||
if (index > n)
|
if (index > n)
|
||||||
{
|
{
|
||||||
TRiga_documento* extra[4] = { NULL };
|
TRiga_documento* extra[4] = { NULL };
|
||||||
int ne = 0;
|
int ne = 0;
|
||||||
if (_conai) extra[ne++] = _conai;
|
if (_conai) extra[ne++] = _conai;
|
||||||
if (_tic ) extra[ne++] = _tic;
|
if (_tic ) extra[ne++] = _tic;
|
||||||
if (_split) extra[ne++] = _split;
|
if (_split) extra[ne++] = _split;
|
||||||
if(extra[index-n-1] == NULL)
|
if(extra[index-n-1] == NULL)
|
||||||
fatal_box(format(FR("Non esiste la riga %d"), index));
|
fatal_box(format(FR("Non esiste la riga %d"), index));
|
||||||
return *extra[index-n-1];
|
return *extra[index-n-1];
|
||||||
}
|
}
|
||||||
return TDocumento::row(index);
|
return TDocumento::row(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public:
|
|||||||
int summary_items() { return tabella_iva().items();} // ritorna il numero di righe in totale della tabellina
|
int summary_items() { return tabella_iva().items();} // ritorna il numero di righe in totale della tabellina
|
||||||
const TAssoc_array& summary() const { return _summary_table; }
|
const TAssoc_array& summary() const { return _summary_table; }
|
||||||
const TArray& summary_array() const { return _summary_array;}
|
const TArray& summary_array() const { return _summary_array;}
|
||||||
bool is_split_payment() const;
|
// bool is_split_payment() const;
|
||||||
|
|
||||||
// Funzioni per il ricalcolo delle scadenze
|
// Funzioni per il ricalcolo delle scadenze
|
||||||
void scadenze_reset(); // riposiziona sulla prima scadenza
|
void scadenze_reset(); // riposiziona sulla prima scadenza
|
||||||
|
Loading…
x
Reference in New Issue
Block a user