Corretto ordinamento righe IVA, selezione documento da contabilizzare.
Corretta anche la selezione sulle righe di descrizione. git-svn-id: svn://10.65.10.50/trunk@3841 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
3507f88800
commit
c5ca0a32d4
@ -1237,7 +1237,7 @@ void TContabilizzazione_app::calculate_spese(real& spese, real& sp_iva, int ndec
|
||||
gr = zio.gruppo();
|
||||
co = zio.conto();
|
||||
so = zio.sottoconto();
|
||||
key.format("%-4s|%c|%3d|%3d|%6ld",(const char*)sp_cod.codice(),tipo,gr,co,so);
|
||||
key.format("5|%-4s|%c|%3d|%3d|%6ld",(const char*)sp_cod.codice(),tipo,gr,co,so);
|
||||
const bool exists = _righe_iva.is_key(key);
|
||||
TIVA_element& el = (exists ? (TIVA_element&)_righe_iva[key] : el_tmp);
|
||||
el.imp() = spese;
|
||||
@ -1278,7 +1278,31 @@ error_type TContabilizzazione_app::add_iva_row(const TBill& conto, const TRiga_d
|
||||
const int co = conto.conto();
|
||||
const long so = conto.sottoconto();
|
||||
TString key;
|
||||
key.format("%-4s|%c|%3d|%3d|%6ld",(const char*)cod,tipo,gr,co,so);
|
||||
const char tipo_r = r.tipo().tipo();
|
||||
int ord=0;
|
||||
// Ordine con cui vengono immesse le righe IVA:
|
||||
// merce, omaggi, prestazioni, spese, bolli/spese d'incasso, sconti.
|
||||
|
||||
switch (tipo_r)
|
||||
{
|
||||
case 'M':
|
||||
ord = 1;
|
||||
break;
|
||||
case 'O':
|
||||
ord = 2;
|
||||
break;
|
||||
case 'P':
|
||||
ord = 3;
|
||||
break;
|
||||
case 'S':
|
||||
ord = 4;
|
||||
break;
|
||||
case 'C':
|
||||
ord = 6;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
key.format("%d|%-4s|%c|%3d|%3d|%6ld",ord,(const char*)cod,tipo,gr,co,so);
|
||||
const bool exists = _righe_iva.is_key(key);
|
||||
TIVA_element& el = (exists ? (TIVA_element&)_righe_iva[key] : el_tmp);
|
||||
el += r;
|
||||
@ -1290,12 +1314,12 @@ error_type TContabilizzazione_app::create_iva_rows()
|
||||
{
|
||||
const int items = _righe_iva.items();
|
||||
const bool in_valuta = _doc->in_valuta();
|
||||
TIVA_element* cur = (TIVA_element*)_righe_iva.first_item();
|
||||
TRectype& head = _movimento->lfile().curr();
|
||||
int gr,co;
|
||||
long so;
|
||||
char tipo;
|
||||
TToken_string key;
|
||||
TString_array key_arr;
|
||||
TString16 codiva;
|
||||
TBill conto;
|
||||
|
||||
@ -1304,23 +1328,30 @@ error_type TContabilizzazione_app::create_iva_rows()
|
||||
real cambio = head.get_real(MOV_CAMBIO);
|
||||
real imponibile,imposta;
|
||||
|
||||
for (int i = 0; i<items && cur != NULL;i++)
|
||||
_righe_iva.get_keys(key_arr);
|
||||
key_arr.sort();
|
||||
//TIVA_element* cur = (TIVA_element*)_righe_iva.first_item();
|
||||
TIVA_element cur;
|
||||
for (int i = 0; i<items/* && cur != NULL*/;i++)
|
||||
{
|
||||
key =_righe_iva.get_hashobj()->key();
|
||||
codiva = key.get(0);
|
||||
tipo = key.get_char(1);
|
||||
gr = key.get_int(2);
|
||||
co = key.get_int(3);
|
||||
so = atol(key.get(4));
|
||||
//key =_righe_iva.get_hashobj()->key();
|
||||
key = key_arr.row(i);
|
||||
cur = (TIVA_element&) _righe_iva[key];
|
||||
codiva = key.get(1);
|
||||
tipo = key.get_char(2);
|
||||
gr = key.get_int(3);
|
||||
co = key.get_int(4);
|
||||
so = atol(key.get(5));
|
||||
conto.set(gr,co,so,tipo);
|
||||
imponibile = cur->imp();
|
||||
conto.find();
|
||||
imponibile = cur.imp();
|
||||
if (in_valuta)
|
||||
{
|
||||
imponibile = cur->imp() * cambio; // imponibile in lire
|
||||
imposta = (imponibile * cur->ali()) / 100.0; // questa e' l'imposta ricalcolata
|
||||
imponibile = cur.imp() * cambio; // imponibile in lire
|
||||
imposta = (imponibile * cur.ali()) / 100.0; // questa e' l'imposta ricalcolata
|
||||
}
|
||||
else
|
||||
imposta = cur->iva();
|
||||
imposta = cur.iva();
|
||||
// In contabilita' abbiamo 2 decimali...
|
||||
imponibile.ceil(2);
|
||||
imposta.ceil(2);
|
||||
@ -1337,7 +1368,7 @@ error_type TContabilizzazione_app::create_iva_rows()
|
||||
rec_iva.put(RMI_GRUPPO,conto.gruppo());
|
||||
rec_iva.put(RMI_CONTO,conto.conto());
|
||||
rec_iva.put(RMI_SOTTOCONTO,conto.sottoconto());
|
||||
cur = (TIVA_element*)_righe_iva.succ_item();
|
||||
//cur = (TIVA_element*)_righe_iva.succ_item();
|
||||
}
|
||||
return _error;
|
||||
}
|
||||
@ -1422,9 +1453,13 @@ error_type TContabilizzazione_app::compile_rows_mov()
|
||||
if (_tri->read() == NOERR) // controlla l'esistenza della riga
|
||||
{
|
||||
TBill conto;
|
||||
search_costo_ricavo(conto,r); // l'errore eventuale viene settato qui dentro
|
||||
if (good())
|
||||
add_iva_row(conto,r);
|
||||
const char tipo = r.tipo().tipo();
|
||||
if (tipo != 'D')
|
||||
{
|
||||
search_costo_ricavo(conto,r); // l'errore eventuale viene settato qui dentro
|
||||
if (good())
|
||||
add_iva_row(conto,r);
|
||||
}
|
||||
}
|
||||
else
|
||||
_error = row_type_error;
|
||||
@ -1742,23 +1777,23 @@ void TContabilizzazione_app::contabilize()
|
||||
int year_from = _data_ini.year();
|
||||
int year_to = _data_fine.year();
|
||||
TString16 codnum;
|
||||
TString msg;
|
||||
TString msg,filt_expr;
|
||||
|
||||
|
||||
_total_docs = 0;
|
||||
da.put("DATADOC",_data_ini);
|
||||
da.put("PROVV","D");
|
||||
da.put("ANNO",year_from);
|
||||
a.put("DATADOC",_data_fine);
|
||||
a.put("PROVV","D");
|
||||
a.put("ANNO",year_to);
|
||||
for (long i=0L; i<items;i++) // Scorre per tutte le numerazioni dello sheet
|
||||
if (_num_sheet->checked(i)) // Se la numerazione corrente e' stata selezionata
|
||||
{ // istanzia un cursore per la numerazione corrente, con i limiti di data
|
||||
codnum = _num_sheet->row(i).get(1);
|
||||
da.put("DATADOC",_data_ini);
|
||||
da.put("PROVV","D");
|
||||
da.put("ANNO",year_from);
|
||||
da.put("CODNUM",codnum);
|
||||
a.put("DATADOC",_data_fine);
|
||||
a.put("PROVV","D");
|
||||
a.put("ANNO",year_to);
|
||||
a.put("CODNUM",codnum);
|
||||
TCursor doc_cur(&doc_rel,"",3,&da,&a);
|
||||
filt_expr = "CODNUM=\"";
|
||||
filt_expr << codnum << "\"";
|
||||
TCursor doc_cur(&doc_rel,filt_expr,3,&da,&a);
|
||||
const long cur_items = doc_cur.items(); // Scorre tutti i documenti che rientrano nell'intervallo selezionato
|
||||
if (cur_items == 0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user