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();
|
gr = zio.gruppo();
|
||||||
co = zio.conto();
|
co = zio.conto();
|
||||||
so = zio.sottoconto();
|
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);
|
const bool exists = _righe_iva.is_key(key);
|
||||||
TIVA_element& el = (exists ? (TIVA_element&)_righe_iva[key] : el_tmp);
|
TIVA_element& el = (exists ? (TIVA_element&)_righe_iva[key] : el_tmp);
|
||||||
el.imp() = spese;
|
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 int co = conto.conto();
|
||||||
const long so = conto.sottoconto();
|
const long so = conto.sottoconto();
|
||||||
TString key;
|
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);
|
const bool exists = _righe_iva.is_key(key);
|
||||||
TIVA_element& el = (exists ? (TIVA_element&)_righe_iva[key] : el_tmp);
|
TIVA_element& el = (exists ? (TIVA_element&)_righe_iva[key] : el_tmp);
|
||||||
el += r;
|
el += r;
|
||||||
@ -1290,12 +1314,12 @@ error_type TContabilizzazione_app::create_iva_rows()
|
|||||||
{
|
{
|
||||||
const int items = _righe_iva.items();
|
const int items = _righe_iva.items();
|
||||||
const bool in_valuta = _doc->in_valuta();
|
const bool in_valuta = _doc->in_valuta();
|
||||||
TIVA_element* cur = (TIVA_element*)_righe_iva.first_item();
|
|
||||||
TRectype& head = _movimento->lfile().curr();
|
TRectype& head = _movimento->lfile().curr();
|
||||||
int gr,co;
|
int gr,co;
|
||||||
long so;
|
long so;
|
||||||
char tipo;
|
char tipo;
|
||||||
TToken_string key;
|
TToken_string key;
|
||||||
|
TString_array key_arr;
|
||||||
TString16 codiva;
|
TString16 codiva;
|
||||||
TBill conto;
|
TBill conto;
|
||||||
|
|
||||||
@ -1303,24 +1327,31 @@ error_type TContabilizzazione_app::create_iva_rows()
|
|||||||
const long numreg = head.get_long(MOV_NUMREG);
|
const long numreg = head.get_long(MOV_NUMREG);
|
||||||
real cambio = head.get_real(MOV_CAMBIO);
|
real cambio = head.get_real(MOV_CAMBIO);
|
||||||
real imponibile,imposta;
|
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();
|
//key =_righe_iva.get_hashobj()->key();
|
||||||
codiva = key.get(0);
|
key = key_arr.row(i);
|
||||||
tipo = key.get_char(1);
|
cur = (TIVA_element&) _righe_iva[key];
|
||||||
gr = key.get_int(2);
|
codiva = key.get(1);
|
||||||
co = key.get_int(3);
|
tipo = key.get_char(2);
|
||||||
so = atol(key.get(4));
|
gr = key.get_int(3);
|
||||||
|
co = key.get_int(4);
|
||||||
|
so = atol(key.get(5));
|
||||||
conto.set(gr,co,so,tipo);
|
conto.set(gr,co,so,tipo);
|
||||||
imponibile = cur->imp();
|
conto.find();
|
||||||
|
imponibile = cur.imp();
|
||||||
if (in_valuta)
|
if (in_valuta)
|
||||||
{
|
{
|
||||||
imponibile = cur->imp() * cambio; // imponibile in lire
|
imponibile = cur.imp() * cambio; // imponibile in lire
|
||||||
imposta = (imponibile * cur->ali()) / 100.0; // questa e' l'imposta ricalcolata
|
imposta = (imponibile * cur.ali()) / 100.0; // questa e' l'imposta ricalcolata
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
imposta = cur->iva();
|
imposta = cur.iva();
|
||||||
// In contabilita' abbiamo 2 decimali...
|
// In contabilita' abbiamo 2 decimali...
|
||||||
imponibile.ceil(2);
|
imponibile.ceil(2);
|
||||||
imposta.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_GRUPPO,conto.gruppo());
|
||||||
rec_iva.put(RMI_CONTO,conto.conto());
|
rec_iva.put(RMI_CONTO,conto.conto());
|
||||||
rec_iva.put(RMI_SOTTOCONTO,conto.sottoconto());
|
rec_iva.put(RMI_SOTTOCONTO,conto.sottoconto());
|
||||||
cur = (TIVA_element*)_righe_iva.succ_item();
|
//cur = (TIVA_element*)_righe_iva.succ_item();
|
||||||
}
|
}
|
||||||
return _error;
|
return _error;
|
||||||
}
|
}
|
||||||
@ -1422,9 +1453,13 @@ error_type TContabilizzazione_app::compile_rows_mov()
|
|||||||
if (_tri->read() == NOERR) // controlla l'esistenza della riga
|
if (_tri->read() == NOERR) // controlla l'esistenza della riga
|
||||||
{
|
{
|
||||||
TBill conto;
|
TBill conto;
|
||||||
search_costo_ricavo(conto,r); // l'errore eventuale viene settato qui dentro
|
const char tipo = r.tipo().tipo();
|
||||||
if (good())
|
if (tipo != 'D')
|
||||||
add_iva_row(conto,r);
|
{
|
||||||
|
search_costo_ricavo(conto,r); // l'errore eventuale viene settato qui dentro
|
||||||
|
if (good())
|
||||||
|
add_iva_row(conto,r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_error = row_type_error;
|
_error = row_type_error;
|
||||||
@ -1742,23 +1777,23 @@ void TContabilizzazione_app::contabilize()
|
|||||||
int year_from = _data_ini.year();
|
int year_from = _data_ini.year();
|
||||||
int year_to = _data_fine.year();
|
int year_to = _data_fine.year();
|
||||||
TString16 codnum;
|
TString16 codnum;
|
||||||
TString msg;
|
TString msg,filt_expr;
|
||||||
|
|
||||||
|
|
||||||
_total_docs = 0;
|
_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
|
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
|
if (_num_sheet->checked(i)) // Se la numerazione corrente e' stata selezionata
|
||||||
{ // istanzia un cursore per la numerazione corrente, con i limiti di data
|
{ // istanzia un cursore per la numerazione corrente, con i limiti di data
|
||||||
codnum = _num_sheet->row(i).get(1);
|
codnum = _num_sheet->row(i).get(1);
|
||||||
da.put("DATADOC",_data_ini);
|
filt_expr = "CODNUM=\"";
|
||||||
da.put("PROVV","D");
|
filt_expr << codnum << "\"";
|
||||||
da.put("ANNO",year_from);
|
TCursor doc_cur(&doc_rel,filt_expr,3,&da,&a);
|
||||||
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);
|
|
||||||
const long cur_items = doc_cur.items(); // Scorre tutti i documenti che rientrano nell'intervallo selezionato
|
const long cur_items = doc_cur.items(); // Scorre tutti i documenti che rientrano nell'intervallo selezionato
|
||||||
if (cur_items == 0)
|
if (cur_items == 0)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user