cg2100.cpp Aggiunto test sulla congruenza del prorata

cg2100.h     Aggiunto F_ADJUST_PRORATA
cg2100c.uml  Aggiunto bottone di correzione prorata
cg2102.h     Aggiunti metodi per test prorata
cg2103.cpp   Aggiunta possibilita' di cambiare il prorata di un registro
cg2106.cpp   Aggiunti metodi per gestire correzione prorata


git-svn-id: svn://10.65.10.50/trunk@4019 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-12-18 16:17:47 +00:00
parent 64c7e537f6
commit cd25e0c500
7 changed files with 133 additions and 3 deletions

View File

@ -72,7 +72,7 @@ TMask* TPrimanota_application::load_mask(int n)
break;
case 2:
if (m)
{
{
m->set_handler(F_DATADOC, datadoc_handler);
m->set_handler(F_NUMDOC, numdoc_handler);
m->set_handler(F_DATA74TER, data74ter_handler);
@ -799,6 +799,22 @@ int TPrimanota_application::read(TMask& m)
}
}
if (_iva == iva_acquisti && !test_prorata())
{
m.show(F_ADJUST_PRORATA);
m.set_handler(F_ADJUST_PRORATA, prorata_handler);
warning_box("Questo movimento e' stato registrato con una percentuale\n"
"prorata non compatibile con quella corrente:\n"
"Premere il bottone di correzione automatica delle righe.");
}
else
{
m.set_handler(F_ADJUST_PRORATA, NULL);
m.hide(F_ADJUST_PRORATA);
}
return _rel->status();
}

View File

@ -53,6 +53,8 @@
#define F_CAMBIOINTRA 142
#define F_STAMPATO 143
#define F_REGST 144
#define F_ADJUST_PRORATA 145
#define F_SHEETCG 190
#define F_SHEETIVA 191

View File

@ -2,7 +2,15 @@
#include "cg21sld.h"
TOOLBAR "" 0 20 0 2
#include <toolbar.h>
BUTTON F_ADJUST_PRORATA 40
BEGIN
PROMPT 1 -3 "Correzione ~automatica righe contabili"
FLAGS "H"
END
ENDPAGE
PAGE "Testata" -1 -1 77 20

View File

@ -125,6 +125,7 @@ class TPrimanota_application : public TRelation_application
static bool recalc_handler(TMask_field& f, KEY key);
static bool codcab_handler(TMask_field& f, KEY key);
static bool tipopag_handler(TMask_field& f, KEY key);
static bool prorata_handler(TMask_field& f, KEY k);
static bool ratalit_handler(TMask_field& f, KEY key);
static bool rataval_handler(TMask_field& f, KEY key);
@ -136,7 +137,7 @@ class TPrimanota_application : public TRelation_application
static bool pag_notify(TSheet_field& s, int r, KEY key);
static bool pag_sheet_handler(TMask_field& f, KEY key);
void reset_sheet_row(TSheet_field& s, int n);
int crea_somma_spese(TImporto& imp);
@ -247,6 +248,9 @@ protected:
void remove_scadenze(const TMask& m, const char* rif);
void renumber_partita(TMask& m, const char* oldp, const char* newp);
void recalc_scadenze(const TDate& d);
bool test_prorata();
bool aggiusta_prorata();
int cerca_conto_cf(TBill& bill) const;

View File

@ -179,12 +179,16 @@ const TString& TRegistro::tipo_attivita()
return _att.get("TIPOATT");
}
const real& TRegistro::prorata()
{
return _prorata;
}
void TRegistro::set_prorata(const real& pro)
{
_prorata = pro;
}
// Certified 99%
bool TRegistro::update(long protiva, const TDate& datareg)
{

View File

@ -63,6 +63,7 @@ public:
const TString& tipo_attivita();
bool attivita_mista() { const char a = tipo_attivita()[0]; return a == 'E'; }
const real& prorata();
void set_prorata(const real& pro);
bool update(long uprotiva, const TDate& lastreg);
TRegistro(const char* code = "", int year = 0);

View File

@ -237,3 +237,98 @@ void TPrimanota_application::set_colors()
app().load_colors();
}
///////////////////////////////////////////////////////////
// Gestione cambiamento prorata
///////////////////////////////////////////////////////////
#include <rmov.h>
#include <rmoviva.h>
bool TPrimanota_application::test_prorata()
{
if (iva() != iva_acquisti)
return TRUE;
bool esistono_righe_senza_tipo_detrazione = FALSE;
TString_array& righe_iva = ivas().rows_array();
for (int r = 0; r < righe_iva.items(); r++)
{
TToken_string& row = righe_iva.row(r);
if (!row.empty_items())
{
const int tipodet = row.get_int(2);
if (tipodet == 0)
{
esistono_righe_senza_tipo_detrazione = TRUE;
break;
}
}
else
break;
}
bool ok = TRUE;
if (esistono_righe_senza_tipo_detrazione)
{
const bool prorata100 = causale().reg().prorata() >= 100.0;
const bool esistono_righe_iva_detraibile = type2pos('D') >= 0;
if (prorata100)
ok = !esistono_righe_iva_detraibile;
else
ok = esistono_righe_iva_detraibile;
}
return ok;
}
bool TPrimanota_application::aggiusta_prorata()
{
if (test_prorata())
return FALSE;
begin_wait();
TRegistro& reg = causale().reg();
const bool prorata_attuale = reg.prorata();
const real vecchio_prorata = prorata_attuale < 100.0 ? 100.0 : 0.0;
TSheet_field& iva_sheet = ivas();
TString_array& righe_iva = iva_sheet.rows_array();
TToken_string oldrow(128);
for (int i = 0; i < righe_iva.items(); i++)
{
TToken_string& r = righe_iva.row(i);
if (!r.empty_items())
{
oldrow = r; // Memorizza riga iva
reg.set_prorata(vecchio_prorata);
iva_notify(iva_sheet, i, K_SPACE);
r.add("", 0); r.add("", 3); // Simula l'azzeramento degli importi
iva_notify(iva_sheet, i, K_ENTER); // Simula uscita dalla riga
reg.set_prorata(prorata_attuale);
iva_notify(iva_sheet, i, K_SPACE);
r = oldrow; // Simula riscrittura importi
iva_notify(iva_sheet, i, K_ENTER); // Simula uscita dalla riga
}
else
break;
}
end_wait();
return TRUE;
}
bool TPrimanota_application::prorata_handler(TMask_field& f, KEY k)
{
if (k == K_SPACE)
{
if (app().aggiusta_prorata())
f.hide();
}
return TRUE;
}