Corretto azzeramento righe iva
git-svn-id: svn://10.65.10.50/trunk@959 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
fa97dca95b
commit
a33eb771fb
@ -718,12 +718,11 @@ void TPrimanota_application::mask2rel(const TMask& m)
|
||||
_rel->lfile().put("TOTDOC", totale);
|
||||
}
|
||||
|
||||
ivas_pack();
|
||||
TArray& irows = ivas().rows_array();
|
||||
for (int i = 0; i < irows.items(); i++)
|
||||
{
|
||||
TToken_string& row = (TToken_string&)irows[i];
|
||||
if (row.empty_items())
|
||||
continue;
|
||||
|
||||
TRectype &r = _rel->iva(i);
|
||||
r.zero();
|
||||
|
@ -387,12 +387,11 @@ HIDDEN int compare_rows(const TObject** o1, const TObject** o2)
|
||||
|
||||
void TPrimanota_application::cgs_pack()
|
||||
{
|
||||
TArray& rows = cgs().rows_array();
|
||||
|
||||
TString_array& rows = cgs().rows_array();
|
||||
const int max = rows.items();
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
TToken_string& r = (TToken_string&)rows[i];
|
||||
TToken_string& r = rows.row(i);
|
||||
bool del = FALSE;
|
||||
if (r.empty_items()) // Remove all empty strings
|
||||
del = TRUE;
|
||||
@ -412,25 +411,27 @@ void TPrimanota_application::cgs_pack()
|
||||
|
||||
bool TPrimanota_application::ci_sono_importi() const
|
||||
{
|
||||
TArray& rows = cgs().rows_array();
|
||||
TString_array& rows = cgs().rows_array();
|
||||
for (int i = 0; i < rows.items(); i++)
|
||||
{
|
||||
TToken_string& r = (TToken_string&)rows[i];
|
||||
if (r.get_char(0) > '0') return TRUE;
|
||||
if (r.get_char() > '0') return TRUE;
|
||||
TToken_string& r = rows.row(i);
|
||||
const real dare(r.get(0));
|
||||
if (dare != ZERO) return TRUE;
|
||||
const real avere(r.get());
|
||||
if (avere != ZERO) return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
real TPrimanota_application::calcola_saldo() const
|
||||
{
|
||||
TArray& rows = cgs().rows_array();
|
||||
TString_array& rows = cgs().rows_array();
|
||||
const int max = rows.items();
|
||||
|
||||
real tdare, tavere;
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
TToken_string& r = (TToken_string&)rows[i];
|
||||
TToken_string& r = rows.row(i);
|
||||
tdare += real(r.get(0));
|
||||
tavere += real(r.get());
|
||||
}
|
||||
@ -821,6 +822,24 @@ real TPrimanota_application::calcola_imp() const
|
||||
return imponibili+imposte;
|
||||
}
|
||||
|
||||
void TPrimanota_application::ivas_pack()
|
||||
{
|
||||
TString_array& rows = ivas().rows_array();
|
||||
|
||||
const int max = rows.items();
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
TToken_string& r = rows.row(i);
|
||||
const real imponibile(r.get(0));
|
||||
if (imponibile != ZERO) continue;
|
||||
const real imposta(r.get(3));
|
||||
if (imposta != ZERO) continue;
|
||||
rows.destroy(i, FALSE);
|
||||
}
|
||||
|
||||
rows.pack(); // Pack array
|
||||
}
|
||||
|
||||
// Certified 50%
|
||||
bool TPrimanota_application::iva_notify(int r, KEY k)
|
||||
{
|
||||
@ -884,7 +903,7 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
|
||||
}
|
||||
if (k == K_ENTER)
|
||||
{
|
||||
int delimp = -1, deliva = -1; // Eventuali righe da cancellare
|
||||
int delimp = -1, deliva = -1; // Eventuali righe contabili da cancellare
|
||||
if (oldpos >= 0) // Se il conto esisteva anche prima ...
|
||||
{ // sottrai il vecchio imponibile
|
||||
const TImporto imp = app().sub_cgs_imp(oldpos, oldimp);
|
||||
@ -921,8 +940,11 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
|
||||
// Aggiorna conto sulla riga contabile
|
||||
if (newpos < 0)
|
||||
{
|
||||
if (delimp >= 0)
|
||||
if (delimp >= 0)
|
||||
{
|
||||
app().reset_cgs_row(delimp); // Cancella vecchia riga
|
||||
if (deliva > delimp) deliva--;
|
||||
}
|
||||
|
||||
const TImporto val(app().real2imp(imponibile, 'I'));
|
||||
if (conto.ok() && !val.is_zero()) // Se c'e' imponibile ...
|
||||
@ -949,11 +971,11 @@ bool TPrimanota_application::iva_notify(int r, KEY k)
|
||||
const char tipod = detrarre ? 'D' : 'N';
|
||||
int newposiva = type2pos(tipod);
|
||||
|
||||
if (deliva >= 0 && newposiva != deliva) // E' cambiato il tipo d'imposta
|
||||
app().reset_cgs_row(deliva); // Azzera il vecchio tipo se necessario
|
||||
|
||||
if (newposiva < 0)
|
||||
{
|
||||
if (deliva >= 0)
|
||||
app().reset_ivas_row(deliva);
|
||||
|
||||
if (!imposta.is_zero()) // Se c'e' imposta ...
|
||||
{ // ... crea nuova riga per l'IVA
|
||||
const TImporto val(app().real2imp(imposta, 'I'));
|
||||
@ -965,7 +987,7 @@ else
|
||||
{
|
||||
TImporto val(app().real2imp(imposta, 'I'));
|
||||
val = app().add_cgs_imp(newposiva, val);
|
||||
if (val.is_zero()) // Se la riga si e' azzerata ...
|
||||
if (val.is_zero()) // Se l'imposta si e' azzerata ...
|
||||
{
|
||||
app().reset_cgs_row(newposiva); // ... cancellala
|
||||
newposiva = -1;
|
||||
@ -977,10 +999,7 @@ oldposiva = newposiva;
|
||||
|
||||
if (r == 0) // Se cambio la prima riga ...
|
||||
app().add_cgs_tot(app().curr_mask()); // ... ricalcola conti
|
||||
|
||||
if (imponibile.is_zero() && imposta.is_zero()) // Svuota riga iva nulla
|
||||
app().reset_ivas_row(r);
|
||||
|
||||
|
||||
app().calcola_imp(); // Ricalcola totale IVA
|
||||
app().calcola_saldo(); // Ricalcola sbilanci
|
||||
}
|
||||
|
@ -169,6 +169,7 @@ protected:
|
||||
TImporto add_cgs_imp(int n, const TImporto& importo);
|
||||
TImporto sub_cgs_imp(int n, const real& imp);
|
||||
|
||||
void ivas_pack();
|
||||
void cgs_pack();
|
||||
bool ci_sono_importi() const;
|
||||
real calcola_saldo() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user