Corretta compattazione righe contabili vuote
git-svn-id: svn://10.65.10.50/trunk@1260 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
56b49e4991
commit
500c9c1fe7
@ -144,14 +144,20 @@ bool TPrimanota_application::detraibile(TToken_string& row)
|
|||||||
// Funzioni di ricerca
|
// Funzioni di ricerca
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
HIDDEN char row_type(const TToken_string& s)
|
||||||
|
{
|
||||||
|
const int l = s.len()-1;
|
||||||
|
return l > 0 ? s[l] : ' ';
|
||||||
|
}
|
||||||
|
|
||||||
int TPrimanota_application::type2pos(char tipo)
|
int TPrimanota_application::type2pos(char tipo)
|
||||||
{
|
{
|
||||||
TSheet_field& cg = app().cgs();
|
TSheet_field& cg = app().cgs();
|
||||||
for (int i = 0; i < cg.items(); i++)
|
for (int i = 0; i < cg.items(); i++)
|
||||||
{
|
{
|
||||||
TToken_string& s = cg.row(i);
|
TToken_string& s = cg.row(i);
|
||||||
const int l = s.len()-1;
|
const char t = row_type(s);
|
||||||
if (l > 0 && s[l] == tipo)
|
if (t == tipo)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@ -165,8 +171,8 @@ int TPrimanota_application::bill2pos(const TBill& conto, char tipo)
|
|||||||
for (int i = 0; i < cg.items(); i++)
|
for (int i = 0; i < cg.items(); i++)
|
||||||
{
|
{
|
||||||
TToken_string& s = cg.row(i);
|
TToken_string& s = cg.row(i);
|
||||||
const int l = s.len()-1;
|
const char t = row_type(s);
|
||||||
if (l > 0 && s[l] == tipo)
|
if (t == tipo)
|
||||||
{
|
{
|
||||||
const TBill c(s, 3, 0x0);
|
const TBill c(s, 3, 0x0);
|
||||||
if (c == conto)
|
if (c == conto)
|
||||||
@ -396,33 +402,44 @@ HIDDEN int compare_rows(const TObject** o1, const TObject** o2)
|
|||||||
|
|
||||||
const TToken_string* r1 = (const TToken_string*)*o1;
|
const TToken_string* r1 = (const TToken_string*)*o1;
|
||||||
const TToken_string* r2 = (const TToken_string*)*o2;
|
const TToken_string* r2 = (const TToken_string*)*o2;
|
||||||
const char c1 = r1->right(1)[0];
|
const char c1 = row_type(*r1);
|
||||||
const char c2 = r2->right(1)[0];
|
const char c2 = row_type(*r2);
|
||||||
return int(strchr(sort_order, c1) - strchr(sort_order, c2));
|
return int(strchr(sort_order, c1) - strchr(sort_order, c2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HIDDEN bool can_remove(TToken_string& s)
|
||||||
|
{
|
||||||
|
const char* dare = s.get(0);
|
||||||
|
bool yes = dare == NULL ;
|
||||||
|
if (!yes)
|
||||||
|
{
|
||||||
|
if (*dare == '\0' || *dare == ' ' || strcmp(dare,"0") == 0)
|
||||||
|
{
|
||||||
|
const char* avere = s.get();
|
||||||
|
yes = (avere == NULL || *avere == '\0' || *avere == ' ' || strcmp(avere,"0") == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TPrimanota_application::cgs_pack()
|
void TPrimanota_application::cgs_pack()
|
||||||
{
|
{
|
||||||
TString_array& rows = cgs().rows_array();
|
TString_array& rows = cgs().rows_array();
|
||||||
const int max = rows.items();
|
const bool salda = is_saldaconto() && iva() == nessuna_iva;
|
||||||
for (int i = 0; i < max; i++)
|
|
||||||
|
for (int i = rows.items()-1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
TToken_string& r = rows.row(i);
|
TToken_string& r = rows.row(i);
|
||||||
bool del = FALSE;
|
if (can_remove(r))
|
||||||
if (r.empty_items()) // Remove all empty strings
|
|
||||||
del = TRUE;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
const TImporto& imp = get_cgs_imp(i);
|
if (salda && row_type(r) == ' ')
|
||||||
if (imp.valore() == ZERO)
|
cg_notify(i, K_DEL);
|
||||||
del = TRUE;
|
rows.destroy(i, salda);
|
||||||
}
|
}
|
||||||
if (del)
|
}
|
||||||
rows.destroy(i, FALSE);
|
if (!salda)
|
||||||
}
|
rows.sort(compare_rows); // Pack and sort array
|
||||||
|
|
||||||
rows.sort(compare_rows); // Pack and sort array
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -643,6 +660,9 @@ bool TPrimanota_application::cg_notify(int r, KEY k)
|
|||||||
case K_DEL:
|
case K_DEL:
|
||||||
if (tipo > ' ')
|
if (tipo > ' ')
|
||||||
return error_box("La riga %d non puo' essere cancellata", r+1);
|
return error_box("La riga %d non puo' essere cancellata", r+1);
|
||||||
|
if (app().is_saldaconto() && app().iva() == nessuna_iva)
|
||||||
|
app().notify_cgline_deletion(r+1);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user