1999-04-06 15:34:39 +00:00
|
|
|
|
#include <applicat.h>
|
|
|
|
|
#include <automask.h>
|
|
|
|
|
#include <defmask.h>
|
|
|
|
|
#include <execp.h>
|
2007-11-30 11:00:26 +00:00
|
|
|
|
#include <modaut.h>
|
1999-04-06 15:34:39 +00:00
|
|
|
|
#include <progind.h>
|
|
|
|
|
#include <relation.h>
|
2003-07-30 10:59:43 +00:00
|
|
|
|
#include <tabutil.h>
|
1999-04-06 15:34:39 +00:00
|
|
|
|
|
|
|
|
|
#include <clifo.h>
|
|
|
|
|
#include <cfven.h>
|
|
|
|
|
#include "../cg/cgsaldac.h"
|
|
|
|
|
#include "../ef/ef0301.h"
|
|
|
|
|
|
|
|
|
|
#include "ef0.h"
|
|
|
|
|
#include "ef0A00a.h"
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Main Mask
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TPE_mask : public TAutomask
|
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
TRelation* _rel;
|
|
|
|
|
bool _spork;
|
|
|
|
|
bool _is_new;
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
protected:
|
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
|
bool on_sheet_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
|
|
|
|
|
|
public:
|
2003-07-30 10:59:43 +00:00
|
|
|
|
bool calc_residual(const TRiga_scadenze& scad, real& impres, real& imppag,
|
2004-03-16 10:43:48 +00:00
|
|
|
|
char& accsal, int& rdist, int& reff,
|
|
|
|
|
bool& partially_unassigned, int& tipopag, bool is_old = false) const;
|
|
|
|
|
bool fill_row(const TRiga_scadenze& rs, TToken_string& row, bool& partially_unassigned, bool force, bool is_new);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
bool fill_rate();
|
2003-07-30 10:59:43 +00:00
|
|
|
|
int insert_row(const TToken_string& row);
|
2004-03-16 10:43:48 +00:00
|
|
|
|
bool fill_distinta(bool clear_all = false);
|
2003-07-30 10:59:43 +00:00
|
|
|
|
void sort_sheet();
|
1999-04-06 15:34:39 +00:00
|
|
|
|
void update_total();
|
|
|
|
|
|
|
|
|
|
TRectype& new_row_effetto(TDistinta& dist, char tipocf, long codcf,
|
|
|
|
|
int& rigadist, int& rigaeff) const;
|
2003-07-30 10:59:43 +00:00
|
|
|
|
long get_free_num() const;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
void save_rate();
|
|
|
|
|
void print();
|
|
|
|
|
|
2003-07-30 10:59:43 +00:00
|
|
|
|
TPE_mask();
|
|
|
|
|
virtual ~TPE_mask();
|
1999-04-06 15:34:39 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Calcola il residuo di una rata tenendo conto anche degli eventuali
|
|
|
|
|
// effetti non ancora contabilizzati
|
|
|
|
|
bool TPE_mask::calc_residual(const TRiga_scadenze& scad,
|
|
|
|
|
real& impres, real& imppag,
|
2003-07-30 10:59:43 +00:00
|
|
|
|
char& accsal, int& rdist, int& reff,
|
2004-03-16 10:43:48 +00:00
|
|
|
|
bool& partially_unassigned, int& tipopag,
|
|
|
|
|
bool is_old) const
|
2003-07-30 10:59:43 +00:00
|
|
|
|
{
|
|
|
|
|
tipopag = scad.get_int(SCAD_TIPOPAG);
|
|
|
|
|
const bool valuta = scad.in_valuta();
|
1999-04-06 15:34:39 +00:00
|
|
|
|
const char tipocf = scad.get_char(SCAD_TIPOCF);
|
|
|
|
|
|
2003-07-30 10:59:43 +00:00
|
|
|
|
TImporto importo = scad.residuo(TRUE);
|
|
|
|
|
importo.normalize(tipocf == 'C' ? 'D' : 'A');
|
1999-04-06 15:34:39 +00:00
|
|
|
|
|
2003-07-30 10:59:43 +00:00
|
|
|
|
impres = importo.valore();
|
1999-04-06 15:34:39 +00:00
|
|
|
|
imppag = ZERO;
|
|
|
|
|
accsal = 'A';
|
|
|
|
|
rdist = reff = 0;
|
2003-07-30 10:59:43 +00:00
|
|
|
|
partially_unassigned = FALSE;
|
|
|
|
|
|
|
|
|
|
// Contolla se ci sono pagamenti non assegnati da gestire
|
|
|
|
|
const TRiga_partite& fattura = scad.riga();
|
|
|
|
|
TPartita& partita = fattura.partita();
|
|
|
|
|
const TRecord_array& unassigned = partita.unassigned();
|
|
|
|
|
if (unassigned.rows() > 0)
|
1999-04-06 15:34:39 +00:00
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
real tot_unassigned; // Totale pagamenti non assegnati
|
|
|
|
|
for (int u = unassigned.last_row(); u > 0; u = unassigned.pred_row(u))
|
1999-04-06 15:34:39 +00:00
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
const real imp = unassigned[u].get(valuta ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO);
|
|
|
|
|
tot_unassigned += imp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Scala non assegnati dalle rate precedenti ancora aperte
|
|
|
|
|
const int nrata = scad.get_int(SCAD_NRATA);
|
|
|
|
|
for (int r = 1; r < nrata; r++)
|
|
|
|
|
{
|
|
|
|
|
if (!fattura.rata(r).chiusa())
|
1999-04-06 15:34:39 +00:00
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
TImporto res = fattura.rata(r).residuo(TRUE);
|
|
|
|
|
tot_unassigned -= res.valore();
|
|
|
|
|
if (tot_unassigned <= ZERO)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Scala non assegnati dalla rata corrente
|
|
|
|
|
if (tot_unassigned > ZERO)
|
|
|
|
|
{
|
|
|
|
|
if (tot_unassigned >= impres)
|
|
|
|
|
impres = ZERO;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
else
|
2003-07-30 10:59:43 +00:00
|
|
|
|
impres -= tot_unassigned;
|
|
|
|
|
partially_unassigned = TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Se c'e' ancora un residuo calcola totale pagato con effetti
|
|
|
|
|
if (!impres.is_zero())
|
|
|
|
|
{
|
|
|
|
|
TRectype& filter = _rel->curr();
|
|
|
|
|
const char* field[] = { SCAD_ANNO, SCAD_NUMPART, SCAD_NRIGA, SCAD_NRATA, NULL };
|
|
|
|
|
for (int i = 0; field[i]; i++)
|
|
|
|
|
filter.put(field[i], scad.get(field[i]));
|
|
|
|
|
TCursor cur(_rel, "", 2, &filter, &filter); // Elenco effetti su questa rata
|
|
|
|
|
|
|
|
|
|
const long codcf = scad.get_long(SCAD_SOTTOCONTO);
|
|
|
|
|
TString80 expr;
|
|
|
|
|
expr << '(' << LF_EFFETTI << "->EFFCONT!=\"X\")&&";
|
|
|
|
|
expr << '(' << LF_EFFETTI << "->TIPOCF==\"" << tipocf << "\")&&";
|
|
|
|
|
expr << '(' << LF_EFFETTI << "->CODCF==\"" << codcf << "\")";
|
|
|
|
|
cur.setfilter(expr, TRUE);
|
|
|
|
|
const long items = cur.items();
|
|
|
|
|
if (items > 0L)
|
|
|
|
|
{
|
|
|
|
|
cur.freeze();
|
|
|
|
|
const TRectype& riga = cur.curr();
|
|
|
|
|
const TRectype& effe = cur.curr(LF_EFFETTI);
|
2004-03-16 10:43:48 +00:00
|
|
|
|
TString8 key = get(F_TIPODIST); key << get(F_DIST);
|
2003-07-30 10:59:43 +00:00
|
|
|
|
for (cur = 0L; cur.pos() < items; ++cur)
|
1999-04-06 15:34:39 +00:00
|
|
|
|
{
|
2004-03-16 10:43:48 +00:00
|
|
|
|
TString8 effkey = effe.get(EFF_TIPODIST); effkey << effe.get(EFF_NDIST);
|
|
|
|
|
if (effkey == key)
|
1999-04-06 15:34:39 +00:00
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
rdist = effe.get_int(EFF_NRIGADIST);
|
|
|
|
|
reff = riga.get_int(REFF_NRIGATR);
|
|
|
|
|
accsal = riga.get_char(REFF_ACCSAL);
|
|
|
|
|
imppag += riga.get_real(valuta ? REFF_IMPORTOVAL : REFF_IMPORTO);
|
|
|
|
|
tipopag = effe.get_int(EFF_TIPOPAG);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (riga.get_char(REFF_ACCSAL) == 'S')
|
|
|
|
|
{
|
|
|
|
|
impres = ZERO;
|
2004-03-16 10:43:48 +00:00
|
|
|
|
if (is_old)
|
|
|
|
|
return true; // Devo farla vedere
|
2003-07-30 10:59:43 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
impres -= riga.get_real(valuta ? REFF_IMPORTOVAL : REFF_IMPORTO);
|
|
|
|
|
}
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return !impres.is_zero();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TPE_mask::update_total()
|
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
real tot;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
TSheet_field& s = sfield(F_SHEET);
|
|
|
|
|
const int postot = s.cid2index(F_IMPORTO);
|
|
|
|
|
FOR_EACH_SHEET_ROW_BACK(s, r, row)
|
|
|
|
|
tot += real(row->get(postot));
|
|
|
|
|
set(F_TOTAL, tot);
|
2003-07-30 10:59:43 +00:00
|
|
|
|
if (tot==ZERO)
|
|
|
|
|
disable(DLG_SAVEREC);
|
|
|
|
|
else
|
|
|
|
|
enable(DLG_SAVEREC);
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-16 10:43:48 +00:00
|
|
|
|
bool TPE_mask::fill_row(const TRiga_scadenze& rs, TToken_string& row, bool& partially_unassigned, bool force, bool is_old)
|
2003-07-30 10:59:43 +00:00
|
|
|
|
{
|
|
|
|
|
const int tipopageff = get_int(F_TIPOPAGEFF);
|
|
|
|
|
int tipopag;
|
|
|
|
|
real impres, imppag;
|
|
|
|
|
char accsal; int rigadist, rigaeff;
|
|
|
|
|
row.cut(0);
|
2004-03-16 10:43:48 +00:00
|
|
|
|
bool ok = calc_residual(rs, impres, imppag, accsal, rigadist, rigaeff, partially_unassigned, tipopag, is_old) || force;
|
|
|
|
|
if (ok)
|
|
|
|
|
ok = tipopag == tipopageff || tipopageff == 0;
|
2003-07-30 10:59:43 +00:00
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
row.add(imppag.string());
|
|
|
|
|
row.add(accsal);
|
|
|
|
|
row.add(impres.string());
|
|
|
|
|
row.add(rs.get_long(SCAD_SOTTOCONTO));
|
|
|
|
|
TString16 cod; cod << rs.get_char(SCAD_TIPOCF) << '|' << rs.get_long(SCAD_SOTTOCONTO);
|
|
|
|
|
row.add(cache().get(LF_CLIFO, cod, CLI_RAGSOC));
|
|
|
|
|
row.add(rs.get(SCAD_ANNO));
|
|
|
|
|
row.add(rs.get(SCAD_NUMPART));
|
|
|
|
|
row.add(rs.get(SCAD_NRIGA));
|
|
|
|
|
row.add(rs.get(SCAD_NRATA));
|
|
|
|
|
row.add(rs.get(SCAD_DATASCAD));
|
|
|
|
|
row.add(rigadist);
|
|
|
|
|
row.add(rigaeff);
|
|
|
|
|
switch (tipopag)
|
|
|
|
|
{
|
2004-03-16 10:43:48 +00:00
|
|
|
|
case 1:row.add(TR("Rimessa Diretta")); break;
|
|
|
|
|
case 2:row.add(TR("Tratta")); break;
|
|
|
|
|
case 3:row.add(TR("Ricevuta Bancaria")); break;
|
|
|
|
|
case 4:row.add(TR("Cessione")); break;
|
|
|
|
|
case 5:row.add(TR("Pagher<EFBFBD>")); break;
|
|
|
|
|
case 6:row.add(TR("Lettera di credito")); break;
|
|
|
|
|
case 7:row.add(TR("Tratta accettata")); break;
|
|
|
|
|
case 8:row.add(TR("Rapporti interbancari diretti")); break;
|
|
|
|
|
case 9:row.add(TR("Bonifico")); break;
|
2003-07-30 10:59:43 +00:00
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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 = 3; cmp == 0 && i <= 8; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i == 4) continue;
|
|
|
|
|
if (i == 6)
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TPE_mask::insert_row(const TToken_string& row)
|
|
|
|
|
{
|
|
|
|
|
const int sort_mode = get_int(F_SORT);
|
|
|
|
|
TString_array& sheet = sfield(F_SHEET).rows_array();
|
|
|
|
|
int first = 0;
|
|
|
|
|
int last = sheet.items()-1;
|
|
|
|
|
|
|
|
|
|
long cmp = -1;
|
|
|
|
|
int cur = 0;
|
|
|
|
|
while (first <= last)
|
|
|
|
|
{
|
|
|
|
|
cur = (first+last) / 2;
|
|
|
|
|
TToken_string& curr = sheet.row(cur);
|
|
|
|
|
cmp = row_compare((TToken_string&)row, curr, sort_mode);
|
|
|
|
|
if (cmp == 0)
|
|
|
|
|
break;
|
|
|
|
|
if (cmp > 0)
|
|
|
|
|
first = cur+1;
|
|
|
|
|
else
|
|
|
|
|
last = cur-1;
|
|
|
|
|
}
|
|
|
|
|
if (cmp)
|
|
|
|
|
{
|
|
|
|
|
if (cmp > 0)
|
|
|
|
|
cur++;
|
|
|
|
|
sheet.insert(row, cur);
|
|
|
|
|
}
|
|
|
|
|
return cur;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TPE_mask::sort_sheet()
|
|
|
|
|
{
|
|
|
|
|
TWait_cursor hourglass;
|
|
|
|
|
const int sort_mode = get_int(F_SORT);
|
|
|
|
|
|
|
|
|
|
TString_array& rows = sfield(F_SHEET).rows_array();
|
|
|
|
|
for (int i = 0; i < rows.items()-1; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = i+1; j < rows.items(); j++)
|
|
|
|
|
{
|
|
|
|
|
TToken_string& r1 = rows.row(i);
|
|
|
|
|
TToken_string& r2 = rows.row(j);
|
|
|
|
|
if (row_compare(r1, r2, sort_mode) > 0)
|
|
|
|
|
rows.swap(i, j);
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TPE_mask::fill_rate()
|
|
|
|
|
{
|
|
|
|
|
const long ndist = get_long(F_DIST);
|
|
|
|
|
const TDate dadata = get(F_DA_DATA);
|
2003-07-30 10:59:43 +00:00
|
|
|
|
const TDate adata = get(F_A_DATA);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
const TString& codval = get(F_CODVAL);
|
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
|
|
|
|
sheet.destroy();
|
|
|
|
|
|
|
|
|
|
TRelation rel(LF_PARTITE);
|
|
|
|
|
TRectype filter(LF_PARTITE);
|
|
|
|
|
filter.put(PART_TIPOCF, get(F_TIPOCF));
|
|
|
|
|
filter.put(PART_GRUPPO, 0);
|
|
|
|
|
filter.put(PART_CONTO, 0);
|
|
|
|
|
filter.put(PART_SOTTOCONTO, get(F_CLIFO));
|
|
|
|
|
|
|
|
|
|
TString filtro;
|
|
|
|
|
filtro << "(CHIUSA!=\"X\")&&(CODVAL==\"" << codval << "\")";
|
2003-07-30 10:59:43 +00:00
|
|
|
|
TCursor partite(&rel, filtro, 1, &filter, &filter);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
|
2003-07-30 10:59:43 +00:00
|
|
|
|
const long items = partite.items();
|
1999-04-06 15:34:39 +00:00
|
|
|
|
partite.freeze();
|
2003-07-30 10:59:43 +00:00
|
|
|
|
if (items > 0)
|
1999-04-06 15:34:39 +00:00
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
TRectype& partita = partite.curr();
|
|
|
|
|
|
|
|
|
|
TProgind pi(items, "Caricamento partite aperte", TRUE, TRUE);
|
|
|
|
|
|
|
|
|
|
long last_cf = 0;
|
|
|
|
|
int last_year = 0;
|
|
|
|
|
TString16 last_game;
|
|
|
|
|
|
|
|
|
|
TToken_string row;
|
|
|
|
|
|
|
|
|
|
for (partite = 0L; partite.pos() < items; ++partite)
|
1999-04-06 15:34:39 +00:00
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
pi.addstatus(1);
|
|
|
|
|
if (pi.iscancelled())
|
|
|
|
|
break;
|
|
|
|
|
if (sheet.items() > 900) // Anche troppe righe
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
const long cur_cf = partita.get_long(PART_SOTTOCONTO);
|
|
|
|
|
const int cur_year = partita.get_int(PART_ANNO);
|
|
|
|
|
const TString& cur_game = partita.get(PART_NUMPART);
|
|
|
|
|
if (cur_cf == last_cf && cur_year == last_year && cur_game == last_game)
|
|
|
|
|
continue;
|
|
|
|
|
last_cf = cur_cf;
|
|
|
|
|
last_year = cur_year;
|
|
|
|
|
last_game = cur_game;
|
|
|
|
|
|
|
|
|
|
const TPartita game(partita);
|
|
|
|
|
const int last = game.last();
|
|
|
|
|
for (int riga = game.prima_fattura(); riga > 0 && riga <= last; riga = game.succ(riga))
|
|
|
|
|
{
|
|
|
|
|
const TRiga_partite& rp = game.riga(riga);
|
|
|
|
|
if (rp.is_fattura())
|
|
|
|
|
{
|
|
|
|
|
for (int rata = 1; rata <= rp.rate(); rata++)
|
|
|
|
|
{
|
|
|
|
|
const TRiga_scadenze& rs = rp.rata(rata);
|
|
|
|
|
if (!rs.chiusa())
|
|
|
|
|
{
|
|
|
|
|
const TDate data = rs.get(SCAD_DATASCAD);
|
|
|
|
|
if (data >= dadata && (!adata.ok() || data <= adata))
|
|
|
|
|
{
|
|
|
|
|
bool partially_unassigned;
|
2004-03-16 10:43:48 +00:00
|
|
|
|
if (fill_row(rs, row, partially_unassigned, false, false))
|
2003-07-30 10:59:43 +00:00
|
|
|
|
{
|
|
|
|
|
const int numrow = sheet.items();
|
|
|
|
|
sheet.row(numrow) = row;
|
|
|
|
|
if (partially_unassigned)
|
|
|
|
|
sheet.disable_cell(numrow, 1); // Non permette di mettere a saldo
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} // if rata aperta
|
|
|
|
|
} // for ogni rata
|
|
|
|
|
} // if e' una fattura
|
|
|
|
|
} // for ogni fattura
|
|
|
|
|
} // for ogni partita
|
|
|
|
|
} // if ci sono partite
|
2004-03-16 10:43:48 +00:00
|
|
|
|
return fill_distinta(false);
|
2003-07-30 10:59:43 +00:00
|
|
|
|
}
|
1999-04-06 15:34:39 +00:00
|
|
|
|
|
2003-07-30 10:59:43 +00:00
|
|
|
|
bool TPE_mask::fill_distinta(bool clear_all)
|
|
|
|
|
{
|
|
|
|
|
TWait_cursor hourglass;
|
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
|
|
|
|
if (clear_all)
|
|
|
|
|
sheet.destroy();
|
|
|
|
|
const char tdist = get(F_TIPODIST)[0];
|
|
|
|
|
const long ndist = get_long(F_DIST);
|
|
|
|
|
TDistinta dist(tdist, ndist);
|
|
|
|
|
const bool dist_cont = dist.contabilizzata();
|
|
|
|
|
if (dist.items() > 0)
|
|
|
|
|
{
|
|
|
|
|
TToken_string row;
|
|
|
|
|
for (int e = 0; e < dist.items(); e++)
|
1999-04-06 15:34:39 +00:00
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
const TEffetto& eff = dist[e];
|
|
|
|
|
const TBill clifo(0, 0, eff.get_long(EFF_CODCF), eff.get_char(EFF_TIPOCF));
|
|
|
|
|
if (e==0)
|
|
|
|
|
set(F_TIPOPAG, eff.get_int(EFF_TIPOPAG));
|
|
|
|
|
for (int r = 1; r <= eff.rows_r(); r++)
|
1999-04-06 15:34:39 +00:00
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
const TRectype& reff = eff.row_r(r);
|
|
|
|
|
const int anno = reff.get_int(REFF_ANNO);
|
|
|
|
|
const TString16 part = reff.get(REFF_NUMPART);
|
|
|
|
|
const int nriga = reff.get_int(REFF_NRIGA);
|
|
|
|
|
const int nrata = reff.get_int(REFF_NRATA);
|
|
|
|
|
TPartita game(clifo, anno, part);
|
|
|
|
|
if (game.esiste(nriga, nrata))
|
1999-04-06 15:34:39 +00:00
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
TRiga_scadenze& rs = game.rata(nriga, nrata);
|
|
|
|
|
bool partially_unassigned;
|
2004-03-16 10:43:48 +00:00
|
|
|
|
if (fill_row(rs, row, partially_unassigned, dist_cont, clear_all))
|
1999-04-06 15:34:39 +00:00
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
const int numrow = insert_row(row);
|
|
|
|
|
if (partially_unassigned)
|
|
|
|
|
sheet.disable_cell(numrow, 1); // Non e' possibile mettere saldo
|
|
|
|
|
if (dist_cont)
|
|
|
|
|
sheet.disable_cell(numrow, -1); // Non e' possibile modificare nulla
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TString msg;
|
|
|
|
|
msg << "La riga " << (e+1) << " della distinta " << ndist
|
|
|
|
|
<< " si riferisce ad una rata o partita non valida:\n"
|
|
|
|
|
<< clifo.tipo() << ' ' << clifo.codclifo() << ' ' << anno << ' '
|
|
|
|
|
<< part << " Riga " << nriga << " Rata " << nrata << "\n"
|
|
|
|
|
<< "Si desidera eliminare l'effetto?";
|
|
|
|
|
if (yesno_box(msg))
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile righe(LF_REFFETTI);
|
|
|
|
|
righe.curr() = reff;
|
|
|
|
|
if (righe.remove() != NOERR)
|
|
|
|
|
error_box("Errore di cancellazione riga effetto: %d", righe.status());
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-07-30 10:59:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (get_bool(F_SORT))
|
|
|
|
|
sort_sheet();
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
sheet.force_update();
|
|
|
|
|
update_total();
|
2003-07-30 10:59:43 +00:00
|
|
|
|
_spork = FALSE;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
|
2003-07-30 10:59:43 +00:00
|
|
|
|
const bool full = sheet.items() > 0;
|
|
|
|
|
if (full)
|
|
|
|
|
{
|
|
|
|
|
disable(-3);
|
|
|
|
|
disable(-4);
|
|
|
|
|
}
|
|
|
|
|
enable(-5, full && !dist_cont);
|
|
|
|
|
show(F_UNCONTABIL, dist_cont);
|
|
|
|
|
|
|
|
|
|
return full;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRectype& TPE_mask::new_row_effetto(TDistinta& dist, char tipocf, long codcf,
|
|
|
|
|
int& rigadist, int& rigaeff ) const
|
|
|
|
|
{
|
|
|
|
|
TString16 codice; codice << tipocf << '|' << codcf;
|
2003-07-30 10:59:43 +00:00
|
|
|
|
const bool ragg = !cache().get(LF_CFVEN, codice, CFV_RAGGEFF).blank();
|
1999-04-06 15:34:39 +00:00
|
|
|
|
|
|
|
|
|
TEffetto* neweff = NULL;
|
|
|
|
|
if (ragg)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < dist.items(); i++)
|
|
|
|
|
{
|
|
|
|
|
TEffetto& eff = dist[i];
|
|
|
|
|
if (eff.get_char(EFF_TIPOCF) == tipocf &&
|
|
|
|
|
eff.get_long(EFF_CODCF) == codcf)
|
|
|
|
|
{
|
|
|
|
|
neweff = &eff;
|
|
|
|
|
rigadist = i+1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (neweff == NULL)
|
|
|
|
|
{
|
|
|
|
|
neweff = new TEffetto;
|
|
|
|
|
dist.righe().add(neweff);
|
|
|
|
|
rigadist = dist.items();
|
|
|
|
|
neweff->put(EFF_TIPOCF, tipocf);
|
|
|
|
|
neweff->put(EFF_CODCF, codcf);
|
|
|
|
|
neweff->put(EFF_CODVAL, get(F_CODVAL));
|
|
|
|
|
neweff->put(EFF_CAMBIO, get(F_CAMBIO));
|
2003-07-30 10:59:43 +00:00
|
|
|
|
neweff->put(EFF_DATACAMBIO, get(F_DATACAMBIO));
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
rigaeff = neweff->rows_r()+1;
|
|
|
|
|
return neweff->row_r(rigaeff, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TPE_mask::save_rate()
|
|
|
|
|
{
|
|
|
|
|
const char tipodist = get(F_TIPODIST)[0];
|
2003-07-30 10:59:43 +00:00
|
|
|
|
long numdist = get_long(F_DIST);
|
|
|
|
|
if (_is_new)
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile f(LF_EFFETTI); f.setkey(4);
|
|
|
|
|
while (TRUE)
|
|
|
|
|
{
|
|
|
|
|
f.put(EFF_TIPODIST, tipodist);
|
|
|
|
|
f.put(EFF_NDIST, numdist);
|
|
|
|
|
f.put(EFF_NRIGADIST, 1);
|
|
|
|
|
if (f.read() != NOERR)
|
|
|
|
|
break;
|
|
|
|
|
const long nd = get_free_num();
|
|
|
|
|
warning_box("La distinta %ld <20> gi<67> presente: verr<72> rinumerata in %ld", numdist, nd);
|
|
|
|
|
numdist = nd;
|
|
|
|
|
}
|
|
|
|
|
_is_new = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
TDistinta distinta(tipodist, numdist, _lock);
|
|
|
|
|
|
2003-07-30 10:59:43 +00:00
|
|
|
|
const TString& codval = get(F_CODVAL);
|
|
|
|
|
const real cambio = get(F_CAMBIO);
|
|
|
|
|
const bool eurocambio = get_bool(F_EURO);
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
bool zeroes = FALSE; // Esistono righe effetto da cancellare
|
|
|
|
|
|
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
|
|
|
|
FOR_EACH_SHEET_ROW(sheet, r, row)
|
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
real imp = row->get(sheet.cid2index(F_IMPORTO));
|
1999-04-06 15:34:39 +00:00
|
|
|
|
real impval;
|
|
|
|
|
if (codval.not_empty() && !imp.is_zero())
|
|
|
|
|
{
|
|
|
|
|
impval = imp;
|
2003-07-30 10:59:43 +00:00
|
|
|
|
TCurrency c(impval, codval, cambio, eurocambio ? _exchange_contro : _exchange_base);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
c.change_to_firm_val();
|
|
|
|
|
imp = c.get_num();
|
|
|
|
|
}
|
|
|
|
|
char accsal = row->get_char(sheet.cid2index(F_ACCSAL));
|
|
|
|
|
int rigadist = row->get_int(sheet.cid2index(F_RIGADIST));
|
|
|
|
|
int rigaeff = row->get_int(sheet.cid2index(F_RIGAEFF));
|
|
|
|
|
if (rigaeff > 0 || accsal == 'S' || imp > ZERO)
|
|
|
|
|
{
|
|
|
|
|
if (rigaeff <= 0)
|
|
|
|
|
{
|
|
|
|
|
char tipocf = get(F_TIPOCF)[0];
|
|
|
|
|
long codcf = row->get_long(sheet.cid2index(F_CODCF));
|
|
|
|
|
|
|
|
|
|
TRectype& reff = new_row_effetto(distinta, tipocf, codcf, rigadist, rigaeff);
|
|
|
|
|
reff.put(REFF_ANNO, row->get(sheet.cid2index(F_ANNO)));
|
|
|
|
|
reff.put(REFF_NUMPART, row->get(sheet.cid2index(F_PARTITA)));
|
|
|
|
|
reff.put(REFF_NRIGA, row->get(sheet.cid2index(F_RIGA)));
|
|
|
|
|
reff.put(REFF_NRATA, row->get(sheet.cid2index(F_RATA)));
|
|
|
|
|
|
|
|
|
|
TToken_string key;
|
|
|
|
|
key.add(get(F_TIPOCF));
|
|
|
|
|
key.add("0|0");
|
|
|
|
|
key.add(row->get(sheet.cid2index(F_CODCF)));
|
|
|
|
|
key.add(row->get(sheet.cid2index(F_ANNO)));
|
|
|
|
|
key.add(row->get(sheet.cid2index(F_PARTITA)));
|
|
|
|
|
key.add(row->get(sheet.cid2index(F_RIGA)));
|
2003-07-30 10:59:43 +00:00
|
|
|
|
// Trova partita
|
|
|
|
|
const TRectype& part = cache().get(LF_PARTITE, key);
|
|
|
|
|
reff.put(REFF_NFATT, part.get(PART_NUMDOC));
|
|
|
|
|
reff.put(REFF_DATAFATT, part.get(PART_DATADOC));
|
|
|
|
|
reff.put(REFF_IMPFATT, part.get(PART_IMPORTO));
|
|
|
|
|
|
|
|
|
|
// Trova rata
|
1999-04-06 15:34:39 +00:00
|
|
|
|
key.add(row->get(sheet.cid2index(F_RATA)));
|
|
|
|
|
const TRectype& scad = cache().get(LF_SCADENZE, key);
|
|
|
|
|
|
2003-11-10 15:01:25 +00:00
|
|
|
|
TString8 abi = scad.get(SCAD_CODABI);
|
|
|
|
|
TString8 cab = scad.get(SCAD_CODCAB);
|
|
|
|
|
|
|
|
|
|
key = get(F_TIPOCF);
|
|
|
|
|
key.add(row->get(sheet.cid2index(F_CODCF)));
|
|
|
|
|
const TRectype& clifo = cache().get(LF_CLIFO, key);
|
|
|
|
|
TString80 iban = clifo.get(CLI_IBAN);
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
if (atol(cab) == 0L)
|
|
|
|
|
{
|
|
|
|
|
abi = clifo.get(CLI_CODABI);
|
|
|
|
|
cab = clifo.get(CLI_CODCAB);
|
|
|
|
|
}
|
2003-11-10 15:01:25 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (iban.starts_with("IT"))
|
|
|
|
|
{
|
|
|
|
|
TString16 abicab; abicab << abi << cab;
|
|
|
|
|
if (iban.mid(5, 10) != abicab)
|
|
|
|
|
iban.cut(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-04-06 15:34:39 +00:00
|
|
|
|
|
|
|
|
|
TEffetto& eff = distinta[rigadist-1];
|
|
|
|
|
eff.put(EFF_DATASCAD, scad.get(SCAD_DATASCAD));
|
|
|
|
|
eff.put(EFF_CODABI, abi);
|
|
|
|
|
eff.put(EFF_CODCAB, cab);
|
2003-11-10 15:01:25 +00:00
|
|
|
|
eff.put(EFF_IBAN, iban);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEffetto& eff = distinta[rigadist-1];
|
|
|
|
|
TRectype& reff = eff.row_r(rigaeff);
|
|
|
|
|
real oldimp = reff.get(REFF_IMPORTO);
|
|
|
|
|
real oldimpval = reff.get(REFF_IMPORTOVAL);
|
|
|
|
|
reff.put(REFF_IMPORTO, imp);
|
|
|
|
|
reff.put(REFF_IMPORTOVAL, impval);
|
|
|
|
|
reff.put(REFF_ACCSAL, accsal);
|
|
|
|
|
|
|
|
|
|
if (imp.is_zero() && accsal != 'S')
|
|
|
|
|
{
|
|
|
|
|
reff.put(REFF_ACCSAL, 'Z'); // Segna la riga come NULLA
|
|
|
|
|
zeroes = TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ricalcola totali righe ed elimina le righe NULLE
|
2003-07-30 10:59:43 +00:00
|
|
|
|
TLocalisamfile f(LF_EFFETTI); f.setkey(1);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
for (int rd = distinta.items()-1; rd >= 0; rd--)
|
|
|
|
|
{
|
|
|
|
|
TEffetto& eff = distinta[rd];
|
|
|
|
|
real totimp, totimpval;
|
|
|
|
|
for (int i = eff.rows_r(); i > 0; i--)
|
|
|
|
|
{
|
|
|
|
|
const TRectype& reff = eff.row_r(i);
|
|
|
|
|
if (reff.get_char(REFF_ACCSAL) == 'Z')
|
2003-07-30 10:59:43 +00:00
|
|
|
|
{
|
1999-04-06 15:34:39 +00:00
|
|
|
|
eff.destroy_row_r(i, TRUE);
|
2003-07-30 10:59:43 +00:00
|
|
|
|
}
|
1999-04-06 15:34:39 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
totimp += reff.get_real(EFF_IMPORTO);
|
|
|
|
|
totimpval += reff.get_real(EFF_IMPORTOVAL);
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-07-30 10:59:43 +00:00
|
|
|
|
if (eff.rows_r() == 0)
|
|
|
|
|
{
|
|
|
|
|
int err = eff.read(f, eff, _lock);
|
|
|
|
|
if (err == NOERR)
|
|
|
|
|
err = eff.remove(f);
|
|
|
|
|
if (err == NOERR)
|
|
|
|
|
distinta.righe().destroy(rd, TRUE);
|
|
|
|
|
else
|
|
|
|
|
error_box("Errore %d durante la cancellazione della riga %d", err, rd+1);
|
|
|
|
|
}
|
1999-04-06 15:34:39 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
eff.put(EFF_TIPOPAG, get(F_TIPOPAG));
|
1999-04-06 15:34:39 +00:00
|
|
|
|
eff.put(EFF_IMPORTO, totimp);
|
|
|
|
|
eff.put(EFF_IMPORTOVAL, totimpval);
|
2003-07-30 10:59:43 +00:00
|
|
|
|
eff.put(EFF_CODVAL, codval);
|
|
|
|
|
eff.put(EFF_CAMBIO, cambio);
|
|
|
|
|
eff.put(EFF_CONTROEURO, eurocambio);
|
|
|
|
|
eff.put(EFF_DATACAMBIO, get(F_DATACAMBIO));
|
|
|
|
|
eff.put(EFF_SPESE, get(F_SPESE));
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TToken_string dati_dist;
|
|
|
|
|
dati_dist.add(tipodist);
|
|
|
|
|
dati_dist.add(numdist);
|
|
|
|
|
dati_dist.add(get(F_DATADIST));
|
|
|
|
|
dati_dist.add(get(F_ABI));
|
|
|
|
|
dati_dist.add(get(F_CAB));
|
|
|
|
|
distinta.write(FALSE, &dati_dist);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TPE_mask::print()
|
|
|
|
|
{
|
|
|
|
|
TString16 cmd;
|
|
|
|
|
cmd << "ef0 -4 " << get(F_TIPODIST) << ' ' << get(F_DIST);
|
|
|
|
|
TExternal_app app(cmd);
|
|
|
|
|
app.run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TPE_mask::on_sheet_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
|
{
|
|
|
|
|
TMask& m = o.mask();
|
|
|
|
|
switch (o.dlg())
|
|
|
|
|
{
|
|
|
|
|
case F_IMPORTO:
|
|
|
|
|
if (e == fe_modify)
|
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
TMask_field& as = m.field(F_ACCSAL);
|
|
|
|
|
if (as.enabled())
|
|
|
|
|
{
|
|
|
|
|
const real imp = m.get(F_IMPORTO);
|
|
|
|
|
const real res = m.get(F_RESIDUO);
|
|
|
|
|
as.set(imp >= res ? "S" : "A");
|
|
|
|
|
}
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case F_PAGA:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
TMask& m = o.mask();
|
|
|
|
|
if (m.get_real(F_IMPORTO).is_zero())
|
|
|
|
|
{
|
|
|
|
|
m.set(F_IMPORTO, m.get(F_RESIDUO));
|
2003-07-30 10:59:43 +00:00
|
|
|
|
TMask_field& as = m.field(F_ACCSAL);
|
|
|
|
|
if (as.enabled())
|
|
|
|
|
as.set("S");
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m.reset(F_IMPORTO);
|
|
|
|
|
m.reset(F_ACCSAL);
|
|
|
|
|
}
|
2003-07-30 10:59:43 +00:00
|
|
|
|
_spork = TRUE;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case F_SHEET:
|
|
|
|
|
switch(e)
|
|
|
|
|
{
|
|
|
|
|
case se_query_add:
|
|
|
|
|
{
|
2003-11-10 15:01:25 +00:00
|
|
|
|
TOperable_field& ronaldo = (TOperable_field&)field(F_AGGIORNA);
|
|
|
|
|
if (ronaldo.active())
|
|
|
|
|
on_field_event(ronaldo, fe_button, 0);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
case se_notify_modify:
|
2003-07-30 10:59:43 +00:00
|
|
|
|
_spork = TRUE;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
update_total();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2003-07-30 10:59:43 +00:00
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
2003-07-30 10:59:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long TPE_mask::get_free_num() const
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile eff(LF_EFFETTI); eff.setkey(4);
|
|
|
|
|
TRectype& curr = eff.curr();
|
|
|
|
|
const TString& tipodist = get(F_TIPODIST);
|
|
|
|
|
curr.put(EFF_TIPODIST, tipodist);
|
|
|
|
|
curr.put(EFF_NDIST, 99999L);
|
|
|
|
|
const int err = eff.read(_isgreat);
|
|
|
|
|
long n = 1L;
|
|
|
|
|
if (err != _isemptyfile)
|
|
|
|
|
{
|
|
|
|
|
if (err == NOERR)
|
|
|
|
|
eff.prev();
|
|
|
|
|
if (curr.get(EFF_TIPODIST) == tipodist)
|
|
|
|
|
n += curr.get_long(EFF_NDIST);
|
|
|
|
|
}
|
|
|
|
|
return n;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TPE_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
|
{
|
|
|
|
|
switch (o.dlg())
|
|
|
|
|
{
|
|
|
|
|
case DLG_NEWREC:
|
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
const long n = get_free_num();
|
1999-04-06 15:34:39 +00:00
|
|
|
|
set(F_DIST, n);
|
2003-07-30 10:59:43 +00:00
|
|
|
|
disable(F_DIST);
|
|
|
|
|
disable(DLG_NEWREC);
|
|
|
|
|
set_focus_field(F_ABI);
|
|
|
|
|
_is_new = TRUE;
|
|
|
|
|
_spork = FALSE;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case F_DIST:
|
|
|
|
|
if (e == fe_modify)
|
|
|
|
|
{
|
|
|
|
|
TEdit_field& ef = (TEdit_field&)o;
|
|
|
|
|
bool ok = ef.check();
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
const TCursor& cur = *ef.browse()->cursor();
|
|
|
|
|
ok = cur.ok();
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
const TRectype& rec = cur.curr();
|
|
|
|
|
if (rec.get_bool(EFF_EFFCONT))
|
2003-07-30 10:59:43 +00:00
|
|
|
|
{
|
|
|
|
|
warning_box("La distinta %s <20> gi<67> stata contabilizzata,\n"
|
|
|
|
|
"per cui non <20> possibile modificarla", (const char*)ef.get());
|
|
|
|
|
show(F_UNCONTABIL);
|
|
|
|
|
}
|
2004-03-16 10:43:48 +00:00
|
|
|
|
ok = fill_distinta(true);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-07-30 10:59:43 +00:00
|
|
|
|
_is_new = !ok; // Memorizza se <20> una distinta nuova
|
|
|
|
|
enable(-3, _is_new); // Abilita tipo, cliente, valuta, ecc., solo se nuova
|
|
|
|
|
enable(F_TIPOPAG, _is_new);
|
|
|
|
|
disable(F_AGGIORNA);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2003-07-30 10:59:43 +00:00
|
|
|
|
case F_CODVAL:
|
|
|
|
|
if (e == fe_modify && !o.empty())
|
|
|
|
|
{
|
|
|
|
|
TTable cam("CAM");
|
|
|
|
|
cam.put("CODTAB", o.get());
|
|
|
|
|
int err = cam.read(_isgteq);
|
|
|
|
|
if (err != NOERR || cam.get("CODTAB").compare(o.get(), 3) != 0)
|
|
|
|
|
{
|
|
|
|
|
const TRectype& val = cache().get("%VAL", o.get());
|
|
|
|
|
TString16 str = val.get("S4");
|
|
|
|
|
if (str.blank()) str = val.get("R10");
|
|
|
|
|
set(F_CAMBIO, str);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
case F_AGGIORNA:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
TEdit_field& numdist = efield(F_DIST);
|
|
|
|
|
if (!numdist.empty())
|
1999-04-06 15:34:39 +00:00
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
bool go = TRUE;
|
|
|
|
|
if (!numdist.enabled() && sfield(F_SHEET).items() > 0)
|
|
|
|
|
{
|
|
|
|
|
go = check_fields();
|
|
|
|
|
if (go && _spork && yesno_box("Si desidera registrare la distinta?"))
|
|
|
|
|
save_rate();
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
2003-07-30 10:59:43 +00:00
|
|
|
|
if (go)
|
|
|
|
|
go = fill_rate();
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
2003-07-30 10:59:43 +00:00
|
|
|
|
return error_box("E' necessario specificare un numero di distinta");
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case F_CONTABILI:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
const char tipodist = get(F_TIPODIST)[0];
|
|
|
|
|
const long numdist = get_long(F_DIST);
|
|
|
|
|
TString16 cmd;
|
|
|
|
|
cmd << "ef0 -7 " << tipodist << ' ' << numdist;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
TExternal_app app(cmd);
|
2003-07-30 10:59:43 +00:00
|
|
|
|
if (app.run() == 0)
|
|
|
|
|
{
|
|
|
|
|
long numreg = 0; // Numero di registrazione contabile
|
|
|
|
|
TLocalisamfile eff(LF_EFFETTI);
|
|
|
|
|
eff.setkey(4);
|
|
|
|
|
eff.put(EFF_TIPODIST, tipodist);
|
|
|
|
|
eff.put(EFF_NDIST,numdist);
|
|
|
|
|
eff.put(EFF_NRIGADIST, 1); // Cerco prima riga distinta
|
|
|
|
|
if (eff.read() == NOERR)
|
|
|
|
|
numreg = eff.get_long(EFF_NUMREG);
|
|
|
|
|
if (numreg > 0)
|
|
|
|
|
message_box("La distinta %ld e' stata contabilizzata col movimento %ld",
|
|
|
|
|
numdist, numreg);
|
|
|
|
|
else
|
|
|
|
|
warning_box("La distinta %ld non e' stata contabilizzata", numdist);
|
|
|
|
|
}
|
1999-04-06 15:34:39 +00:00
|
|
|
|
stop_run(K_ESC);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2003-07-30 10:59:43 +00:00
|
|
|
|
case F_UNCONTABIL:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
const char tipodist = get(F_TIPODIST)[0];
|
|
|
|
|
const long numdist = get_long(F_DIST);
|
|
|
|
|
if (tipodist > ' ' && numdist > 0)
|
|
|
|
|
{
|
|
|
|
|
TRelation rel(LF_EFFETTI);
|
|
|
|
|
TRectype& rec = rel.curr();
|
|
|
|
|
rec.put(EFF_TIPODIST, tipodist);
|
|
|
|
|
rec.put(EFF_NDIST,numdist);
|
|
|
|
|
TCursor cur(&rel, "", 4, &rec, &rec);
|
|
|
|
|
const TRecnotype items = cur.items();
|
|
|
|
|
cur.freeze();
|
|
|
|
|
|
|
|
|
|
TAssoc_array movs;
|
|
|
|
|
for (cur = 0; cur.pos() < items; ++cur)
|
|
|
|
|
{
|
|
|
|
|
movs.add(rec.get(EFF_NUMREG));
|
|
|
|
|
rec.zero(EFF_EFFCONT);
|
|
|
|
|
rec.zero(EFF_NUMREG);
|
|
|
|
|
rel.rewrite();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (movs.items() > 0)
|
|
|
|
|
{
|
|
|
|
|
TString msg;
|
|
|
|
|
msg = "E' necessario cancellare i seguenti movimenti contabili:\n";
|
|
|
|
|
FOR_EACH_ASSOC_OBJECT(movs, hash, key, obj)
|
|
|
|
|
msg << key << ' ';
|
|
|
|
|
warning_box(msg);
|
|
|
|
|
}
|
|
|
|
|
stop_run(K_ESC);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
case DLG_DELREC:
|
2003-07-30 10:59:43 +00:00
|
|
|
|
if (e == fe_button && yesno_box("Confermare l'eliminazione della distinta %ld",
|
1999-04-06 15:34:39 +00:00
|
|
|
|
get_long(F_DIST)))
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
|
|
|
|
FOR_EACH_SHEET_ROW(sheet, r, row)
|
2003-07-30 10:59:43 +00:00
|
|
|
|
{
|
|
|
|
|
row->add(" ", 0);
|
|
|
|
|
row->add("A", 1);
|
|
|
|
|
}
|
1999-04-06 15:34:39 +00:00
|
|
|
|
save_rate();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DLG_SAVEREC:
|
|
|
|
|
if (e == fe_button)
|
2003-07-30 10:59:43 +00:00
|
|
|
|
{
|
|
|
|
|
TEdit_field& cab = efield(F_CAB);
|
|
|
|
|
if (!cab.empty())
|
|
|
|
|
{
|
|
|
|
|
if (check_fields())
|
|
|
|
|
{
|
|
|
|
|
save_rate();
|
2004-03-16 10:43:48 +00:00
|
|
|
|
fill_distinta(true);
|
2003-07-30 10:59:43 +00:00
|
|
|
|
disable(F_TIPOPAG);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return error_box("E' necessario specificare una banca di presentazione");
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DLG_PRINT:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
print();
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2003-07-30 10:59:43 +00:00
|
|
|
|
case F_SORT:
|
|
|
|
|
if (e == fe_modify)
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& s = sfield(F_SHEET);
|
|
|
|
|
if (s.items() > 0)
|
|
|
|
|
{
|
|
|
|
|
sort_sheet();
|
|
|
|
|
s.force_update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case F_CLIFO:
|
|
|
|
|
case F_DA_DATA:
|
|
|
|
|
case F_A_DATA:
|
|
|
|
|
if (e == fe_modify)
|
|
|
|
|
{
|
|
|
|
|
if (get(F_CLIFO).not_empty() || get(F_DA_DATA).not_empty() || get(F_A_DATA).not_empty())
|
|
|
|
|
enable(F_AGGIORNA);
|
|
|
|
|
}
|
|
|
|
|
break;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
case F_SHEET:
|
|
|
|
|
return on_sheet_event(o, e, jolly);
|
|
|
|
|
default:
|
|
|
|
|
if (jolly > 0)
|
|
|
|
|
return on_sheet_event(o, e, jolly);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
2003-07-30 10:59:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TPE_mask::TPE_mask() : TAutomask("ef0a00a")
|
|
|
|
|
{
|
|
|
|
|
_rel = new TRelation(LF_REFFETTI);
|
|
|
|
|
_rel->add(LF_EFFETTI, "NPROGTR==NPROGTR");
|
1999-04-06 15:34:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-30 10:59:43 +00:00
|
|
|
|
TPE_mask::~TPE_mask()
|
|
|
|
|
{ delete _rel; }
|
|
|
|
|
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Main Program
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TPagamento_effetti : public TSkeleton_application
|
|
|
|
|
{
|
|
|
|
|
TPE_mask* _mask;
|
|
|
|
|
|
2007-11-30 11:00:26 +00:00
|
|
|
|
public:
|
|
|
|
|
virtual bool create();
|
1999-04-06 15:34:39 +00:00
|
|
|
|
virtual void main_loop();
|
|
|
|
|
virtual void print();
|
2007-11-30 11:00:26 +00:00
|
|
|
|
virtual bool firm_change_enabled() const { return false; }
|
1999-04-06 15:34:39 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void TPagamento_effetti::main_loop()
|
|
|
|
|
{
|
|
|
|
|
open_files(LF_TABCOM, LF_TAB, LF_CLIFO, LF_CFVEN,
|
|
|
|
|
LF_PARTITE, LF_SCADENZE, LF_PAGSCA,
|
|
|
|
|
LF_EFFETTI, LF_REFFETTI, LF_CESS, 0);
|
|
|
|
|
enable_menu_item(M_FILE_PRINT);
|
|
|
|
|
_mask = new TPE_mask;
|
|
|
|
|
do
|
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
_mask->reset();
|
1999-04-06 15:34:39 +00:00
|
|
|
|
_mask->enable(-3);
|
2003-07-30 10:59:43 +00:00
|
|
|
|
_mask->enable(F_TIPOPAG);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
_mask->enable(-4);
|
|
|
|
|
_mask->disable(-5);
|
2003-07-30 10:59:43 +00:00
|
|
|
|
_mask->disable(DLG_SAVEREC);
|
|
|
|
|
_mask->hide(F_UNCONTABIL);
|
1999-04-06 15:34:39 +00:00
|
|
|
|
_mask->sfield(F_SHEET).destroy();
|
|
|
|
|
}
|
|
|
|
|
while (_mask->run() != K_QUIT);
|
|
|
|
|
|
|
|
|
|
delete _mask;
|
|
|
|
|
_mask = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TPagamento_effetti::print()
|
|
|
|
|
{
|
|
|
|
|
if (_mask)
|
|
|
|
|
_mask->print();
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-30 11:00:26 +00:00
|
|
|
|
|
|
|
|
|
bool TPagamento_effetti::create()
|
|
|
|
|
{
|
2009-10-13 14:48:02 +00:00
|
|
|
|
if (!has_module(EPAUT))
|
2007-11-30 11:00:26 +00:00
|
|
|
|
return error_box(TR("Modulo non autorizzato"));
|
|
|
|
|
|
|
|
|
|
return TSkeleton_application::create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
int ef0A00(int argc, char* argv[])
|
|
|
|
|
{
|
2003-07-30 10:59:43 +00:00
|
|
|
|
int n = 0;
|
1999-04-06 15:34:39 +00:00
|
|
|
|
TPagamento_effetti pe;
|
2007-11-30 11:00:26 +00:00
|
|
|
|
pe.run(argc, argv, TR("Disposizioni incassi/pagamenti"));
|
1999-04-06 15:34:39 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|