Patch level : 10

Files correlati     :
Ricompilazione Demo : [ ]
Commento            : programma di gestione anticipi fatture per gio costruzioni


git-svn-id: svn://10.65.10.50/trunk@20508 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
cris 2010-05-27 12:59:41 +00:00
parent 7ab9ec614e
commit 3ade9a48ed
3 changed files with 89 additions and 112 deletions

View File

@ -32,7 +32,7 @@ protected:
public:
void update_scad();
void update_sheet();
bool calc_residual(const TRiga_scadenze& scad, real& impres, real& imppag,
bool calc_residual(const TRiga_scadenze& scad, real& impres,
bool& partially_unassigned, int& tipopag) const;
bool fill_row(const TRiga_partite& rp, const TRiga_scadenze& rs, TToken_string& row, bool& partially_unassigned, bool force);
void update_total();
@ -40,6 +40,67 @@ public:
virtual ~TPF_mask();
};
bool TPF_mask::on_sheet_event(TOperable_field& o, TField_event e, long jolly)
{
TMask& m = o.mask();
switch (o.dlg())
{
case F_PAGATO:
if (e == fe_modify)
update_total();
break;
case F_IMPORTOANT:
if (e == fe_modify)
update_total();
break;
case F_SHEET:
switch(e)
{
case se_query_add:
return false;
case se_notify_modify:
update_total();
break;
default:
break;
}
default:
break;
}
return true;
}
bool TPF_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
const int id = o.dlg();
switch (id)
{
case DLG_SAVEREC:
if (e == fe_button)
{
update_scad();
update_sheet();
update_total();
}
break;
case F_CLIFO:
if (e == fe_modify)
{
update_sheet();
update_total();
}
break;
case F_SHEET:
return on_sheet_event(o, e, jolly);
break;
default:
if (jolly > 0)
return on_sheet_event(o, e, jolly);
break;
}
return true;
}
void TPF_mask::update_scad()
{
TSheet_field& s = sfield(F_SHEET);
@ -67,10 +128,9 @@ void TPF_mask::update_scad()
scad.put(SCAD_NRATA, row.get(posnrata));
if (scad.read() == NOERR)
{
real pagato(row.get(pospagato));
real importoant(row.get(posanticip));
scad.put(SCAD_IMPORTOPAG, pagato);
scad.put(SCAD_IMPORTOANT, importoant);
const real importoant(row.get(posanticip));
const real importopag(row.get(pospagato));
scad.put(SCAD_IMPORTOANT, importoant-importopag);
scad.put(SCAD_CODABIPR, row.get(posabi));
scad.put(SCAD_CODCABPR, row.get(poscab));
scad.rewrite();
@ -78,34 +138,9 @@ void TPF_mask::update_scad()
}
}
bool TPF_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
const int id = o.dlg();
switch (id)
{
case DLG_SAVEREC:
if (e == fe_button)
update_scad();
break;
case F_CLIFO:
if (e == fe_modify)
update_sheet();
break;
case F_SHEET:
return on_sheet_event(o, e, jolly);
break;
default:
if (jolly > 0)
return on_sheet_event(o, e, jolly);
break;
}
return true;
}
// Calcola il residuo di una rata tenendo conto anche degli eventuali
// effetti non ancora contabilizzati
bool TPF_mask::calc_residual(const TRiga_scadenze& scad,
real& impres, real& imppag,
bool TPF_mask::calc_residual(const TRiga_scadenze& scad, real& impres,
bool& partially_unassigned, int& tipopag) const
{
tipopag = scad.get_int(SCAD_TIPOPAG);
@ -116,7 +151,6 @@ bool TPF_mask::calc_residual(const TRiga_scadenze& scad,
importo.normalize(tipocf == 'C' ? 'D' : 'A');
impres = importo.valore();
imppag = ZERO;
partially_unassigned = FALSE;
// Contolla se ci sono pagamenti non assegnati da gestire
@ -160,31 +194,34 @@ bool TPF_mask::calc_residual(const TRiga_scadenze& scad,
void TPF_mask::update_total()
{
TSheet_field& s = sfield(F_SHEET);
const int postot = s.cid2index(F_IMPORTOANT);
real tot;
const int postoa = s.cid2index(F_IMPORTOANT);
const int postop = s.cid2index(F_PAGATO);
real tota;
real totp;
FOR_EACH_SHEET_ROW_BACK(s, r, row)
tot += real(row->get(postot));
set(F_TOTALEANT, tot);
enable(DLG_SAVEREC, !tot.is_zero());
{
tota += real(row->get(postoa));
totp += real(row->get(postop));
}
set(F_TOTALEANT, tota);
set(F_TOTALEPAG, totp);
enable(DLG_SAVEREC, !tota.is_zero()||!totp.is_zero());
}
bool TPF_mask::fill_row(const TRiga_partite& rp, const TRiga_scadenze& rs, TToken_string& row, bool& partially_unassigned, bool force)
{
int tipopag = 0;
real impres, imppag;
TDate datapag;
bool valben = false;
real impres;
row.cut(0);
bool ok = calc_residual(rs, impres, imppag, partially_unassigned, tipopag) || force;
bool ok = calc_residual(rs, impres, partially_unassigned, tipopag) || force;
if (ok)
{
row.add(imppag.string()); // importo pagato
row.add(""); // importo pagato e' solo da inserire
row.add(rs.get(SCAD_IMPORTOANT)); // importo anticipato
row.add(rs.get(SCAD_CODABIPR));
row.add(rs.get(SCAD_CODCABPR));
row.add(rp.get(PART_IMPTOTDOC)); // importo fattura
row.add(""); // residuo
row.add(impres.string()); // residuo
row.add(rs.get(SCAD_ANNO));
row.add(rs.get(SCAD_NUMPART));
row.add(rs.get(SCAD_NRIGA));
@ -207,46 +244,6 @@ bool TPF_mask::fill_row(const TRiga_partite& rp, const TRiga_scadenze& rs, TToke
return ok;
}
HIDDEN long row_compare(TToken_string& r1, TToken_string& r2, const int sort_mode)
{
long cmp = 0;
if (sort_mode == 1)
{
const TDate d1 = r1.get(F_DATA-FIRST_FIELD);
const TDate d2 = r2.get(F_DATA-FIRST_FIELD);
cmp = d1 - d2;
if (cmp != 0)
return cmp; // else normal comparing
}
else if (sort_mode == 2)
{
const real i1 = r1.get(F_RESIDUO-FIRST_FIELD);
const real i2 = r2.get(F_RESIDUO-FIRST_FIELD);
const real diff = i1 - i2;
cmp = diff.sign();
if (cmp != 0)
return cmp; // else normal comparing
}
for (int i = 5; cmp == 0 && i <= 10; i++)
{
if (i == 6) continue;
if (i == 8)
{
TString16 p1; r1.get(i, p1);
TString16 p2; r2.get(i, p2);
cmp = p1.compare(p2);
}
else
{
long n1; r1.get(i, n1);
long n2; r2.get(i, n2);
cmp = n1 - n2;
}
}
return cmp;
}
void TPF_mask::update_sheet()
{
TSheet_field& sheet = sfield(F_SHEET);
@ -321,32 +318,6 @@ void TPF_mask::update_sheet()
sheet.force_update();
}
bool TPF_mask::on_sheet_event(TOperable_field& o, TField_event e, long jolly)
{
TMask& m = o.mask();
switch (o.dlg())
{
case F_IMPORTOANT:
if (e == fe_modify)
update_total();
break;
case F_SHEET:
switch(e)
{
case se_query_add:
return false;
case se_notify_modify:
update_total();
break;
default:
break;
}
default:
break;
}
return true;
}
TPF_mask::TPF_mask() : TAutomask("pi0002100a")
{
}
@ -355,7 +326,6 @@ TPF_mask::~TPF_mask()
{
}
///////////////////////////////////////////////////////////
// Main Program
///////////////////////////////////////////////////////////

View File

@ -2,6 +2,7 @@
#define F_RAGSOCCF 202
#define F_DATAMOV 203
#define F_TOTALEANT 204
#define F_TOTALEPAG 205
#define F_SHEET 300

View File

@ -54,7 +54,13 @@ END
CURRENCY F_TOTALEANT
BEGIN
PROMPT 2 4 "Totale "
PROMPT 2 4 "Totale anticipato "
FLAGS "D"
END
CURRENCY F_TOTALEPAG
BEGIN
PROMPT 52 4 "Totale pagato "
FLAGS "D"
END