1995-08-30 12:14:19 +00:00
|
|
|
#include <defmask.h> // Serve per DLG_NEWREC
|
|
|
|
|
1995-11-23 14:20:03 +00:00
|
|
|
#include "cg2100p.h" // Campi maschere partite e pagamenti
|
1995-08-23 14:39:46 +00:00
|
|
|
|
1995-11-23 14:20:03 +00:00
|
|
|
#ifndef __EXTRA__
|
1995-08-23 14:39:46 +00:00
|
|
|
#include "cg2100.h" // Campi maschere prima nota
|
1995-11-23 14:20:03 +00:00
|
|
|
#include "cg2102.h" // Applicazione di prima nota
|
1995-09-29 16:21:08 +00:00
|
|
|
#endif
|
|
|
|
|
1996-01-25 17:20:49 +00:00
|
|
|
#include <causali.h> // Archivio causali
|
1995-08-23 14:39:46 +00:00
|
|
|
#include <clifo.h> // Archivio clienti/fornitori
|
1995-08-30 12:14:19 +00:00
|
|
|
#include <mov.h> // Archivio movimenti di prima nota
|
|
|
|
#include <pagsca.h> // Archivio pagamenti
|
1995-08-23 14:39:46 +00:00
|
|
|
#include <partite.h> // Archivio partite
|
|
|
|
#include <scadenze.h> // Archivio scadenze
|
|
|
|
|
1995-09-29 16:21:08 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Maschera pagamenti
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TPay_mask : public TMask
|
1995-12-29 11:55:59 +00:00
|
|
|
{
|
|
|
|
TDate _datadoc;
|
1995-10-11 11:39:50 +00:00
|
|
|
real _da_pagare, _pagabile;
|
1995-09-29 16:21:08 +00:00
|
|
|
|
1996-01-25 17:20:49 +00:00
|
|
|
TDecoder _causale;
|
|
|
|
|
1995-09-29 16:21:08 +00:00
|
|
|
protected:
|
|
|
|
static bool importo_handler(TMask_field& f, KEY k);
|
1995-12-23 09:41:46 +00:00
|
|
|
static bool importolire_handler(TMask_field& f, KEY k);
|
1996-01-19 13:09:12 +00:00
|
|
|
static bool saldo_handler(TMask_field& f, KEY k);
|
1995-11-23 14:20:03 +00:00
|
|
|
static bool cambio_handler(TMask_field& f, KEY k);
|
1995-12-29 11:55:59 +00:00
|
|
|
static bool datapag_handler(TMask_field& f, KEY k);
|
1996-01-05 15:17:50 +00:00
|
|
|
static bool conto_handler(TMask_field& f, KEY k);
|
1996-01-03 12:10:02 +00:00
|
|
|
void gioca_cambi(int force = 0x0);
|
|
|
|
|
1995-09-29 16:21:08 +00:00
|
|
|
public:
|
1995-10-11 11:39:50 +00:00
|
|
|
void set_pag(const TRectype& oldpag, const TRiga_scadenze& scad, const TImporto& importo);
|
1995-09-29 16:21:08 +00:00
|
|
|
void get_pag(TRectype& oldpag) const;
|
|
|
|
|
|
|
|
TPay_mask();
|
|
|
|
virtual ~TPay_mask() {}
|
|
|
|
};
|
|
|
|
|
1996-01-25 17:20:49 +00:00
|
|
|
TPay_mask::TPay_mask()
|
|
|
|
: TMask("cg2100s"), _causale(LF_CAUSALI, CAU_CODCAUS, CAU_DESCR)
|
1995-09-29 16:21:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1995-10-11 11:39:50 +00:00
|
|
|
void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad,
|
1996-01-04 14:51:26 +00:00
|
|
|
const TImporto& residuo)
|
1995-09-29 16:21:08 +00:00
|
|
|
{
|
|
|
|
TRelation rel(LF_PAGSCA); // Working relation
|
|
|
|
rel.curr() = oldpag;
|
|
|
|
autoload(&rel); // Load current record on mask
|
|
|
|
|
1995-10-30 10:17:14 +00:00
|
|
|
const TPartita& p = scad.partita();
|
|
|
|
const int nrigp = oldpag.get_int(PAGSCA_NRIGP);
|
|
|
|
const TRiga_partite& sum = p.riga(nrigp);
|
1995-09-29 16:21:08 +00:00
|
|
|
const TRiga_partite& fatt = scad.riga();
|
1995-12-07 11:09:17 +00:00
|
|
|
|
|
|
|
TMask_field& group = field(S_RATA);
|
|
|
|
TString prompt(80);
|
|
|
|
prompt << "Partita:" << p.anno() << ' ' << p.numero()
|
|
|
|
<< " Riga:" << fatt.get_int(PART_NRIGA)
|
|
|
|
<< " Rata:" << scad.get_int(SCAD_NRATA)
|
|
|
|
<< " del " << scad.get_date(SCAD_DATASCAD).string();
|
|
|
|
group.set(prompt);
|
1995-10-30 10:17:14 +00:00
|
|
|
|
1995-09-29 16:21:08 +00:00
|
|
|
set(S_NUMDOC, fatt.get(PART_NUMDOC)); // Numero documento
|
|
|
|
set(S_DATADOC, fatt.get(PART_DATADOC)); // Data documento
|
|
|
|
set(S_NUMPROT, fatt.get(PART_PROTIVA)); // Protocollo IVA
|
1996-01-25 17:20:49 +00:00
|
|
|
|
|
|
|
TString desfat = fatt.get(PART_DESCR); // Descrizione fattura
|
|
|
|
if (desfat.empty()) // Se e' vuota ...
|
|
|
|
{
|
|
|
|
desfat = fatt.get(PART_CODCAUS);
|
|
|
|
desfat = _causale.decode(desfat); // ... usa descrizione causale
|
|
|
|
}
|
|
|
|
set(S_DESCR, desfat);
|
1996-01-23 15:37:14 +00:00
|
|
|
|
1995-12-01 11:46:35 +00:00
|
|
|
set(S_DATAPAG, sum.get(PART_DATAPAG)); // Data pagamento
|
1995-12-07 11:09:17 +00:00
|
|
|
set(S_TIPOPAG, sum.get(PART_TIPOPAG)); // Tipo pagamento
|
1996-01-23 15:37:14 +00:00
|
|
|
set(S_DESCAGG, sum.get(PART_DESCR)); // Descrizione documento
|
1995-09-29 16:21:08 +00:00
|
|
|
|
|
|
|
set(S_SEZIONE_SCAD, scad.riga().sezione()); // Sezione della rata
|
|
|
|
set(S_IMPORTO_SCAD, scad.get(SCAD_IMPORTO)); // Importo della rata
|
1995-11-23 14:20:03 +00:00
|
|
|
set(S_IMPORTOVAL_SCAD, scad.get(SCAD_IMPORTOVAL)); // Importo in valuta
|
1995-09-29 16:21:08 +00:00
|
|
|
|
|
|
|
const bool in_valuta = scad.in_valuta();
|
1995-11-23 14:20:03 +00:00
|
|
|
|
1995-12-29 11:55:59 +00:00
|
|
|
_da_pagare = scad.residuo(in_valuta).valore(); // Calcola residuo in valuta
|
1995-09-29 16:21:08 +00:00
|
|
|
|
|
|
|
TReal_field& res = (TReal_field&)field(S_RESIDUORATA);
|
1996-01-03 12:10:02 +00:00
|
|
|
res.set_decimals(in_valuta ? 3 : 0);
|
1995-12-20 16:16:14 +00:00
|
|
|
if (get(S_SALDOACC)[0] != 'S')
|
|
|
|
res.set(_da_pagare.string());
|
1995-12-23 09:41:46 +00:00
|
|
|
|
|
|
|
if (in_valuta)
|
|
|
|
{
|
|
|
|
set_handler(S_IMPORTOVAL, importo_handler);
|
|
|
|
set_handler(S_IMPORTO, importolire_handler);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
set_handler(S_IMPORTO, importo_handler);
|
1996-01-19 13:09:12 +00:00
|
|
|
set_handler(S_SALDOACC, saldo_handler);
|
1995-09-29 16:21:08 +00:00
|
|
|
|
1995-11-23 14:20:03 +00:00
|
|
|
real oldimp = oldpag.get_real(in_valuta ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO);
|
|
|
|
if (!in_valuta)
|
|
|
|
oldimp += oldpag.get_real(PAGSCA_RITENUTE);
|
|
|
|
|
1995-09-29 16:21:08 +00:00
|
|
|
// Ricorda l'importo da pagare
|
1995-11-23 14:20:03 +00:00
|
|
|
_da_pagare += oldimp;
|
1995-09-29 16:21:08 +00:00
|
|
|
|
1995-12-29 11:55:59 +00:00
|
|
|
const TValuta val(sum);
|
1995-11-23 14:20:03 +00:00
|
|
|
val.set(*this, S_VALUTA, S_DATACAMBIO, S_CAMBIO);
|
1995-09-29 16:21:08 +00:00
|
|
|
|
|
|
|
const long numreg = sum.get_long(PART_NREG);
|
|
|
|
const int numrig = sum.get_int(PART_NUMRIG);
|
1995-10-11 11:39:50 +00:00
|
|
|
|
|
|
|
if (in_valuta)
|
1996-01-04 14:51:26 +00:00
|
|
|
_pagabile = val.lit2val(residuo.valore());
|
1995-10-11 11:39:50 +00:00
|
|
|
else
|
1996-01-04 14:51:26 +00:00
|
|
|
_pagabile = residuo.valore();
|
|
|
|
|
|
|
|
TReal_field& resp = (TReal_field&)field(S_RESIDUOPAG);
|
|
|
|
resp.set_decimals(in_valuta ? 3 : 0);
|
1995-10-11 11:39:50 +00:00
|
|
|
resp.set(_pagabile.string());
|
1995-11-23 14:20:03 +00:00
|
|
|
|
|
|
|
_pagabile += oldimp;
|
1995-09-29 16:21:08 +00:00
|
|
|
|
1995-12-01 11:46:35 +00:00
|
|
|
// Il flag di saldo/acconto e' attivo solo se non ci sono acconti, cioe':
|
|
|
|
// pagamento non assegnato o con data documento antecedente quella della fattura
|
1995-09-29 16:21:08 +00:00
|
|
|
bool sa = oldpag.get_int(PAGSCA_NRIGA) != TPartita::UNASSIGNED;
|
|
|
|
if (sa)
|
1995-12-11 11:20:18 +00:00
|
|
|
{
|
|
|
|
const tipo_movimento tm = sum.tipo();
|
|
|
|
sa = !(tm == tm_nota_credito || tm == tm_insoluto);
|
|
|
|
if (sa)
|
|
|
|
{
|
|
|
|
const TDate datasca(fatt.get(PART_DATADOC));
|
|
|
|
const TDate datapag(sum.get(PART_DATADOC));
|
|
|
|
sa = datapag >= datasca;
|
|
|
|
}
|
1995-09-29 16:21:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1995-12-01 11:46:35 +00:00
|
|
|
hide(S_RESIDUORATA); // Se non assegnato nascondi residuo rata
|
1995-09-29 16:21:08 +00:00
|
|
|
}
|
1995-12-07 11:09:17 +00:00
|
|
|
// Mostra saldo solo se non e' ne' un acconto, ne' una nota di credito
|
1995-12-11 11:20:18 +00:00
|
|
|
enable(S_SALDOACC, sa);
|
1995-11-23 14:20:03 +00:00
|
|
|
|
|
|
|
show(-3, in_valuta); // Attiva campi relativi alla valuta
|
1996-01-03 12:10:02 +00:00
|
|
|
show(-4, in_valuta); // Attiva campi relativi al cambio
|
1995-11-23 14:20:03 +00:00
|
|
|
|
1995-09-29 16:21:08 +00:00
|
|
|
#ifdef __EXTRA__
|
1995-11-23 14:20:03 +00:00
|
|
|
set_handler(S_CAMBIO, cambio_handler);
|
1995-10-31 13:59:03 +00:00
|
|
|
hide(S_RESIDUOPAG);
|
1995-11-23 14:20:03 +00:00
|
|
|
const bool mostra_conto = FALSE;
|
1995-09-29 16:21:08 +00:00
|
|
|
#else
|
1996-01-03 12:10:02 +00:00
|
|
|
disable(-4);
|
|
|
|
|
1995-12-29 11:55:59 +00:00
|
|
|
_datadoc = sum.get_date(PART_DATADOC);
|
1996-01-05 15:17:50 +00:00
|
|
|
set_handler(S_DATAPAG, datapag_handler);
|
|
|
|
set_handler(S_GRUPPO, conto_handler);
|
|
|
|
set_handler(S_CONTO, conto_handler);
|
1996-01-03 12:10:02 +00:00
|
|
|
|
1995-11-23 14:20:03 +00:00
|
|
|
const bool mostra_conto = !sum.is_nota_credito();
|
1995-09-29 16:21:08 +00:00
|
|
|
#endif
|
1995-12-29 11:55:59 +00:00
|
|
|
show(-2, mostra_conto); // mostra/nasconde conto contropartita
|
1995-11-23 14:20:03 +00:00
|
|
|
|
|
|
|
const bool mostra_ritenute = !(sum.is_nota_credito() || in_valuta);
|
|
|
|
show(S_RITENUTE, mostra_ritenute); // mostra/nasconde ritenute
|
1995-09-29 16:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TPay_mask::get_pag(TRectype& newpag) const
|
|
|
|
{
|
|
|
|
TRelation rel(LF_PAGSCA); // Working relation
|
|
|
|
rel.curr() = newpag;
|
|
|
|
autosave(&rel); // Load current record from mask
|
|
|
|
newpag = rel.curr();
|
|
|
|
}
|
|
|
|
|
1996-01-03 12:10:02 +00:00
|
|
|
// Riempie i campi valuta a zero in base agli altri
|
|
|
|
void TPay_mask::gioca_cambi(int force)
|
|
|
|
{
|
|
|
|
const real totale = get(S_IMPORTO);
|
|
|
|
const real totval = get(S_IMPORTOVAL);
|
|
|
|
const TValuta cambio(*this, S_VALUTA, S_DATACAMBIO, S_CAMBIO);
|
|
|
|
|
|
|
|
if ( (force == 0x1 || totale.is_zero()) && !(totval.is_zero() || cambio.in_lire()) )
|
|
|
|
{
|
|
|
|
const real new_totale = cambio.val2lit(totval);
|
|
|
|
if (new_totale != totale)
|
|
|
|
set(S_IMPORTO, new_totale, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (force == 0x2 || totval.is_zero()) && !(totale.is_zero() || cambio.in_lire()))
|
|
|
|
{
|
|
|
|
const real new_totval = cambio.lit2val(totale);
|
|
|
|
if (new_totval != totval)
|
|
|
|
set(S_IMPORTOVAL, new_totval, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (force == 0x4 || cambio.in_lire()) && !(totale.is_zero() || totval.is_zero()))
|
|
|
|
{
|
|
|
|
real new_cambio = totale / totval; new_cambio.round(5);
|
|
|
|
if (new_cambio != cambio.cambio())
|
|
|
|
set(S_CAMBIO, new_cambio, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-09-29 16:21:08 +00:00
|
|
|
bool TPay_mask::importo_handler(TMask_field& f, KEY k)
|
|
|
|
{
|
|
|
|
TPay_mask& m = (TPay_mask&)f.mask();
|
|
|
|
|
|
|
|
if (k == K_F8)
|
1995-10-11 11:39:50 +00:00
|
|
|
{
|
1995-11-23 14:20:03 +00:00
|
|
|
real imp;
|
|
|
|
if (m.field(S_RESIDUORATA).shown() && m.field(S_RESIDUOPAG).shown())
|
|
|
|
imp = fnc_min(m._da_pagare, m._pagabile);
|
|
|
|
else
|
|
|
|
imp = m.field(S_RESIDUORATA).shown() ? m._da_pagare : m._pagabile;
|
|
|
|
|
|
|
|
if (m.field(S_RITENUTE).active())
|
|
|
|
imp -= real(m.get(S_RITENUTE));
|
|
|
|
|
1995-10-11 11:39:50 +00:00
|
|
|
f.set(imp.string());
|
1995-09-29 16:21:08 +00:00
|
|
|
k = K_TAB;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (k == K_TAB && f.focusdirty())
|
1996-01-03 12:10:02 +00:00
|
|
|
{
|
|
|
|
if (m.field(S_IMPORTOVAL).active())
|
|
|
|
m.gioca_cambi();
|
|
|
|
|
1995-11-23 14:20:03 +00:00
|
|
|
real i(f.get());
|
|
|
|
if (m.field(S_RITENUTE).active())
|
|
|
|
i += real(m.get(S_RITENUTE));
|
|
|
|
|
1996-01-19 13:09:12 +00:00
|
|
|
if (i >= m._da_pagare && m.mode() == NO_MODE && m.field(S_SALDOACC).active())
|
1995-09-29 16:21:08 +00:00
|
|
|
m.set(S_SALDOACC, "S");
|
1995-12-20 16:16:14 +00:00
|
|
|
|
|
|
|
if (m.get(S_SALDOACC)[0] != 'S')
|
|
|
|
{
|
|
|
|
const real residuo(m._da_pagare - i);
|
|
|
|
m.set(S_RESIDUORATA, residuo);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m.reset(S_RESIDUORATA);
|
|
|
|
|
1995-10-11 11:39:50 +00:00
|
|
|
const real residuopag(m._pagabile - i);
|
1995-11-23 14:20:03 +00:00
|
|
|
m.set(S_RESIDUOPAG, residuopag);
|
1995-09-29 16:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1995-12-23 09:41:46 +00:00
|
|
|
bool TPay_mask::importolire_handler(TMask_field& f, KEY k)
|
1996-01-03 12:10:02 +00:00
|
|
|
{
|
|
|
|
TPay_mask& m = (TPay_mask&)f.mask();
|
|
|
|
|
|
|
|
if (k == K_F8)
|
|
|
|
m.send_key(k, S_IMPORTOVAL);
|
|
|
|
|
1995-12-23 09:41:46 +00:00
|
|
|
if (f.to_check(k))
|
1996-01-03 12:10:02 +00:00
|
|
|
m.gioca_cambi();
|
1995-12-23 09:41:46 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1996-01-19 13:09:12 +00:00
|
|
|
bool TPay_mask::saldo_handler(TMask_field& f, KEY k)
|
|
|
|
{
|
|
|
|
if (k == K_SPACE)
|
|
|
|
{
|
|
|
|
TMask& m = f.mask();
|
|
|
|
m.set_mode(MODE_QUERY);
|
|
|
|
TMask_field& imp = m.field(m.field(S_IMPORTOVAL).active() ? S_IMPORTOVAL : S_IMPORTO);
|
|
|
|
imp.set_dirty();
|
|
|
|
imp.on_hit();
|
|
|
|
m.set_mode(NO_MODE);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-11-23 14:20:03 +00:00
|
|
|
bool TPay_mask::cambio_handler(TMask_field& f, KEY k)
|
|
|
|
{
|
|
|
|
if (k == K_TAB && f.focusdirty())
|
|
|
|
{
|
1996-01-03 12:10:02 +00:00
|
|
|
TPay_mask& m = (TPay_mask&)f.mask();
|
|
|
|
m.gioca_cambi(0x1);
|
1995-11-23 14:20:03 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1995-12-29 11:55:59 +00:00
|
|
|
bool TPay_mask::datapag_handler(TMask_field& f, KEY k)
|
|
|
|
{
|
|
|
|
if (f.to_check(k))
|
|
|
|
{
|
|
|
|
const TDate datapag(f.get());
|
|
|
|
TPay_mask& m = (TPay_mask&)f.mask();
|
|
|
|
if (datapag < m._datadoc)
|
|
|
|
return f.error_box("La data del pagamento e' inferiore alla data del documento %s",
|
|
|
|
m._datadoc.string());
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1996-01-05 15:17:50 +00:00
|
|
|
bool TPay_mask::conto_handler(TMask_field& f, KEY k)
|
|
|
|
{
|
|
|
|
if (k == K_TAB && f.focusdirty())
|
|
|
|
{
|
|
|
|
TMask& m = f.mask();
|
|
|
|
TBill conto; conto.get(m, S_GRUPPO, S_CONTO, S_SOTTOCONTO);
|
|
|
|
const TString& desc = conto.descrizione();
|
|
|
|
if (desc.empty())
|
|
|
|
m.reset(S_SOTTOCONTO);
|
|
|
|
m.set(S_DESCRCONTO, desc);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1995-11-23 14:20:03 +00:00
|
|
|
|
1995-08-23 14:39:46 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Maschera partite
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TGame_mask : public TMask
|
|
|
|
{
|
1995-08-30 12:14:19 +00:00
|
|
|
const TBill _conto; // Conto fisso del cliente/fornitore
|
1995-09-08 10:57:44 +00:00
|
|
|
long _numreg; // Numero movimento contabile
|
|
|
|
int _numrig; // Riga contabile corrente (prima = 1!)
|
1996-01-04 14:51:26 +00:00
|
|
|
TImporto _importo; // Importo su riga contabile
|
|
|
|
TImporto _residuo; // Residuo della riga contabile
|
1995-08-30 12:14:19 +00:00
|
|
|
int _riga_partite; // Riga corrente delle partite
|
1995-12-29 11:55:59 +00:00
|
|
|
bool _changed; // Flag di modifica partite
|
|
|
|
bool _valfirst; // La colonna della valuta precede le lire
|
1995-10-25 09:34:53 +00:00
|
|
|
|
1995-12-07 11:09:17 +00:00
|
|
|
tipo_movimento _tipomov; // Dati per la creazione di un nuovo movimento
|
1995-10-25 09:34:53 +00:00
|
|
|
char _sezione;
|
|
|
|
TDate _datadoc;
|
|
|
|
TString _codpag, _descr, _numdoc;
|
1995-08-30 12:14:19 +00:00
|
|
|
|
1995-12-01 11:46:35 +00:00
|
|
|
TDecoder _causali; // Decodificatore delle causali
|
|
|
|
|
1995-08-23 14:39:46 +00:00
|
|
|
protected:
|
|
|
|
static bool annopart_handler(TMask_field& f, KEY k);
|
|
|
|
static bool numpart_handler(TMask_field& f, KEY k);
|
|
|
|
static bool partite_notify(TSheet_field& partite, int r, KEY k);
|
1995-10-25 09:34:53 +00:00
|
|
|
static bool scadenze_notify(TSheet_field& partite, int r, KEY k);
|
1995-08-23 14:39:46 +00:00
|
|
|
static bool show_all_handler(TMask_field& f, KEY k);
|
|
|
|
static bool edit_scadenza_handler(TMask_field& f, KEY k);
|
1995-08-30 12:14:19 +00:00
|
|
|
static bool nuovo_handler(TMask_field& f, KEY k);
|
1995-09-12 07:58:03 +00:00
|
|
|
static bool cambio_handler(TMask_field& f, KEY k);
|
1995-08-23 14:39:46 +00:00
|
|
|
|
1995-12-01 11:46:35 +00:00
|
|
|
void add_importo(TToken_string& s, const TImporto& i, bool val = FALSE, int pos = -1);
|
|
|
|
void add_descrizione(TToken_string& s, const TRiga_partite& riga, int pos = -1);
|
1995-08-28 07:50:28 +00:00
|
|
|
TImporto get_importo(TToken_string& s, int pos) const;
|
|
|
|
|
1996-01-04 14:51:26 +00:00
|
|
|
void fill_partite();
|
1995-08-25 07:39:49 +00:00
|
|
|
real aggiorna_residuo();
|
1995-08-28 07:50:28 +00:00
|
|
|
|
1995-09-13 16:01:30 +00:00
|
|
|
int update_partita(const TPartita& game, int prow);
|
|
|
|
void update_saldo_clifo();
|
1995-10-25 09:34:53 +00:00
|
|
|
int nuova_riga(TPartita& partita) const;
|
1995-09-29 16:21:08 +00:00
|
|
|
int nuovo_pagamento(TPartita& partita, int nriga, int rata) const;
|
|
|
|
bool edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) const;
|
1995-11-10 13:35:00 +00:00
|
|
|
|
1996-01-03 12:10:02 +00:00
|
|
|
void align_number(TMask_field& f) const;
|
1995-12-29 11:55:59 +00:00
|
|
|
long number_distance(const char* key, const char* num) const;
|
|
|
|
bool same_number(const char* key, const char* num) const;
|
1996-01-03 12:10:02 +00:00
|
|
|
void append_conto(TString& s) const;
|
1995-11-10 13:35:00 +00:00
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
#ifdef __EXTRA__
|
|
|
|
bool edit_fattura(TPartita& p, int nriga);
|
1995-11-17 10:27:24 +00:00
|
|
|
bool prima_nota(const long nreg);
|
1995-10-25 09:34:53 +00:00
|
|
|
#endif
|
1995-08-23 14:39:46 +00:00
|
|
|
|
1995-12-07 11:09:17 +00:00
|
|
|
const TRiga_partite* cerca_prima_riga() const;
|
1995-09-13 16:01:30 +00:00
|
|
|
void aggiorna_valuta(const TValuta& val);
|
1995-12-07 11:09:17 +00:00
|
|
|
void aggiorna_sorelle(const TRiga_partite& part) const;
|
1995-10-25 09:34:53 +00:00
|
|
|
|
1995-08-23 14:39:46 +00:00
|
|
|
public:
|
|
|
|
TSheet_field& partite() const { return (TSheet_field&)field(P_PARTITE); }
|
|
|
|
TSheet_field& scadenze() const { return (TSheet_field&)field(P_SCADENZE); }
|
|
|
|
const TBill& conto() const { return _conto; }
|
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
bool changed() const { return _changed; }
|
|
|
|
|
1995-09-08 10:57:44 +00:00
|
|
|
TGame_mask(const TBill& bill, long numreg, int riga);
|
1995-08-23 14:39:46 +00:00
|
|
|
virtual ~TGame_mask() {}
|
|
|
|
};
|
|
|
|
|
1996-01-03 12:10:02 +00:00
|
|
|
void TGame_mask::append_conto(TString& s) const
|
|
|
|
{
|
|
|
|
switch (conto().tipo())
|
|
|
|
{
|
|
|
|
case 'C':
|
|
|
|
s << "Cliente"; break;
|
|
|
|
case 'F':
|
|
|
|
s << "Fornitore"; break;
|
|
|
|
default:
|
|
|
|
s << "Conto " << conto().gruppo() << ' ' << conto().conto(); break;
|
|
|
|
}
|
|
|
|
s << ' ' << conto().sottoconto();
|
|
|
|
}
|
|
|
|
|
1995-09-08 10:57:44 +00:00
|
|
|
TGame_mask::TGame_mask(const TBill& bill, long numreg, int riga)
|
1995-10-25 09:34:53 +00:00
|
|
|
: TMask("cg2100p"), _conto(bill), _numreg(numreg), _numrig(riga),
|
1995-12-29 11:55:59 +00:00
|
|
|
_changed(FALSE), _valfirst(FALSE), _causali(LF_CAUSALI, "CODCAUS", "DESCR")
|
1995-09-13 16:01:30 +00:00
|
|
|
{
|
1995-12-07 14:46:56 +00:00
|
|
|
TString descr(80);
|
1996-01-03 12:10:02 +00:00
|
|
|
append_conto(descr);
|
|
|
|
descr << ' ' << ((TBill&)_conto).descrizione();
|
1995-12-07 14:46:56 +00:00
|
|
|
set(P_DESCR, descr);
|
|
|
|
|
1995-09-27 13:45:27 +00:00
|
|
|
TValuta val;
|
1995-09-29 16:21:08 +00:00
|
|
|
#ifndef __EXTRA__
|
1996-01-11 15:44:06 +00:00
|
|
|
const TRiga_partite* row = cerca_prima_riga();
|
|
|
|
if (row != NULL)
|
|
|
|
{
|
|
|
|
val.get(*row); // Legge valuta standard dalla partita
|
1996-01-03 12:10:02 +00:00
|
|
|
|
1996-01-11 15:44:06 +00:00
|
|
|
set(P_ANNO, row->get(PART_ANNO)); // Propone anno e partita
|
|
|
|
set(P_NUMERO, row->get(PART_NUMPART));
|
|
|
|
}
|
|
|
|
else
|
1996-01-03 12:10:02 +00:00
|
|
|
{
|
1996-01-11 15:44:06 +00:00
|
|
|
TMask& cm = app().curr_mask(); // Legge valuta dal movimento
|
|
|
|
val.get(cm, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO);
|
|
|
|
|
1996-01-12 17:43:52 +00:00
|
|
|
if (cm.id2pos(F_ANNORIF) > 0) // Se in testata c'e' l'anno di riferimento
|
|
|
|
{
|
|
|
|
set(P_ANNO, cm.get(F_ANNORIF)); // Propone anno e partita
|
|
|
|
set(P_NUMERO, cm.get(F_NUMRIF));
|
|
|
|
}
|
1996-01-03 12:10:02 +00:00
|
|
|
}
|
1996-01-11 15:44:06 +00:00
|
|
|
val.set(*this, P_VALUTA, P_DATACAMBIO, P_CAMBIO);
|
1995-11-14 15:58:25 +00:00
|
|
|
#endif
|
1996-01-11 15:44:06 +00:00
|
|
|
|
1995-09-29 16:21:08 +00:00
|
|
|
enable(-3, val.in_valuta());
|
1995-09-08 10:57:44 +00:00
|
|
|
|
1995-09-01 15:06:35 +00:00
|
|
|
set_handler(P_ANNO, annopart_handler);
|
|
|
|
set_handler(P_NUMERO, numpart_handler);
|
|
|
|
set_handler(P_SHOWALL, show_all_handler);
|
|
|
|
set_handler(P_NUOVO, nuovo_handler);
|
1995-09-12 07:58:03 +00:00
|
|
|
set_handler(P_CAMBIO, cambio_handler);
|
1995-08-23 14:39:46 +00:00
|
|
|
|
1996-01-11 15:44:06 +00:00
|
|
|
TSheet_field& games = partite();
|
|
|
|
games.set_notify(partite_notify);
|
1995-11-09 08:05:53 +00:00
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
scadenze().set_notify(scadenze_notify);
|
1995-08-23 14:39:46 +00:00
|
|
|
scadenze().sheet_mask().set_handler(100, edit_scadenza_handler);
|
1996-01-11 15:44:06 +00:00
|
|
|
|
|
|
|
fill_partite(); // Riempie sheet partite
|
1995-08-23 14:39:46 +00:00
|
|
|
}
|
|
|
|
|
1995-08-30 12:14:19 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Handlers dei campi e della maschera principale
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
1995-08-23 14:39:46 +00:00
|
|
|
bool TGame_mask::annopart_handler(TMask_field& f, KEY k)
|
|
|
|
{
|
1995-08-25 07:39:49 +00:00
|
|
|
if (k == K_TAB && f.focusdirty() && f.get().not_empty())
|
1995-08-23 14:39:46 +00:00
|
|
|
{
|
|
|
|
TMask_field& n = f.mask().field(P_NUMERO);
|
|
|
|
n.set_dirty();
|
|
|
|
numpart_handler(n, k);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TGame_mask::numpart_handler(TMask_field& f, KEY k)
|
|
|
|
{
|
1995-12-29 11:55:59 +00:00
|
|
|
if (k == K_TAB && f.focusdirty())
|
1995-08-23 14:39:46 +00:00
|
|
|
{
|
|
|
|
const TGame_mask& m = (const TGame_mask&)f.mask();
|
1995-12-29 11:55:59 +00:00
|
|
|
const int anno = m.get_int(P_ANNO); // Anno partita da cercare
|
|
|
|
if (anno > 0)
|
1995-08-23 14:39:46 +00:00
|
|
|
{
|
1995-12-29 11:55:59 +00:00
|
|
|
const TString key = f.get(); // Numero partita da cercare
|
|
|
|
int best_match = 0; // Partita piu' somigliante
|
|
|
|
long min_dist = 10000000L; // Livello di somiglianza migliore
|
|
|
|
|
1995-08-23 14:39:46 +00:00
|
|
|
TSheet_field& sheet = m.partite();
|
|
|
|
for (int i = 0; i < sheet.items(); i++)
|
|
|
|
{
|
|
|
|
TToken_string& row = sheet.row(i);
|
1995-12-29 11:55:59 +00:00
|
|
|
if (anno == row.get_int(0)) // Se corrisponde l'anno e ...
|
|
|
|
{
|
|
|
|
const long dist = m.number_distance(key, row.get());
|
1996-01-11 15:44:06 +00:00
|
|
|
if (i == 0 || dist < min_dist)
|
1995-08-23 14:39:46 +00:00
|
|
|
{
|
1995-12-29 11:55:59 +00:00
|
|
|
min_dist = dist;
|
|
|
|
best_match = i;
|
|
|
|
if (dist == 0L)
|
|
|
|
break;
|
1995-08-23 14:39:46 +00:00
|
|
|
}
|
1995-11-10 13:35:00 +00:00
|
|
|
}
|
1995-08-23 14:39:46 +00:00
|
|
|
}
|
1996-01-11 15:44:06 +00:00
|
|
|
sheet.select(best_match); // seleziona la partita
|
1995-08-23 14:39:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TGame_mask::show_all_handler(TMask_field& f, KEY k)
|
|
|
|
{
|
1996-01-23 15:37:14 +00:00
|
|
|
TGame_mask& gm = (TGame_mask&)f.mask();
|
|
|
|
if (k == K_SPACE && gm.is_running())
|
1995-08-23 14:39:46 +00:00
|
|
|
{
|
1995-09-12 07:58:03 +00:00
|
|
|
gm.fill_partite();
|
1995-08-23 14:39:46 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1995-09-12 07:58:03 +00:00
|
|
|
bool TGame_mask::cambio_handler(TMask_field& f, KEY k)
|
|
|
|
{
|
|
|
|
if (k == K_TAB && f.focusdirty() &&
|
|
|
|
yesno_box("Aggiornare gli importi dei pagamenti?"))
|
|
|
|
{
|
1995-09-13 16:01:30 +00:00
|
|
|
TGame_mask& gm = (TGame_mask&)f.mask();
|
1995-12-23 09:41:46 +00:00
|
|
|
const TValuta val(gm, P_VALUTA, P_DATACAMBIO, P_CAMBIO);
|
1995-09-12 07:58:03 +00:00
|
|
|
gm.aggiorna_valuta(val);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Metodi dei campi e della maschera principale
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
1995-11-09 08:05:53 +00:00
|
|
|
// Aggiorna il campo con il residuo da spendere sui pagamenti
|
1995-08-25 07:39:49 +00:00
|
|
|
real TGame_mask::aggiorna_residuo()
|
1995-10-11 11:39:50 +00:00
|
|
|
{
|
1995-10-25 09:34:53 +00:00
|
|
|
#ifdef __EXTRA__
|
1995-10-11 11:39:50 +00:00
|
|
|
return ZERO;
|
1995-09-29 16:21:08 +00:00
|
|
|
#else
|
1995-11-09 08:05:53 +00:00
|
|
|
_importo = app().get_cgs_imp(_numrig-1); // Importo sulla riga contabile
|
1996-01-04 14:51:26 +00:00
|
|
|
_residuo = _importo;
|
|
|
|
_residuo -= app().partite().importo_speso(_numreg, _numrig); // Residuo della riga
|
1996-01-11 15:44:06 +00:00
|
|
|
const real& res = _residuo.valore();
|
|
|
|
set(P_RESIDUO, res);
|
|
|
|
|
|
|
|
if (field(P_CAMBIO).enabled())
|
|
|
|
{
|
|
|
|
const TValuta cambio(*this, P_VALUTA, P_DATACAMBIO, P_CAMBIO);
|
|
|
|
if (cambio.in_valuta())
|
|
|
|
{
|
1996-01-25 17:20:49 +00:00
|
|
|
TImporto resval = _importo; cambio.lit2val(resval);
|
|
|
|
resval -= app().partite().importo_speso(_numreg, _numrig, TRUE); // Residuo della riga
|
|
|
|
set(P_RESIDUOVAL, resval.valore());
|
1996-01-11 15:44:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
1995-10-11 11:39:50 +00:00
|
|
|
#endif
|
1995-08-25 07:39:49 +00:00
|
|
|
}
|
|
|
|
|
1995-12-07 11:09:17 +00:00
|
|
|
// Scandisce tutte le partite per cercare la prima del movimento corrente
|
|
|
|
const TRiga_partite* TGame_mask::cerca_prima_riga() const
|
|
|
|
{
|
1996-01-11 15:44:06 +00:00
|
|
|
const TRiga_partite* riga = app().partite().mov2rig(_numreg, _numrig);
|
1995-12-07 11:09:17 +00:00
|
|
|
return riga;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-09-13 16:01:30 +00:00
|
|
|
void TGame_mask::aggiorna_valuta(const TValuta& val)
|
1995-09-12 07:58:03 +00:00
|
|
|
{
|
|
|
|
TPartite_array& pa = app().partite();
|
|
|
|
for (TPartita* game = pa.first(); game; game = pa.next())
|
|
|
|
{
|
|
|
|
for (int r = game->last(); r > 0; r = game->pred(r))
|
|
|
|
{
|
|
|
|
const TRiga_partite& riga = game->riga(r);
|
|
|
|
for (int s = riga.rate(); s > 0; s--)
|
|
|
|
{
|
|
|
|
const TRiga_scadenze& scad = riga.rata(s);
|
|
|
|
for (int p = scad.last(); p > 0; p = scad.pred(p))
|
|
|
|
{
|
|
|
|
TRiga_partite& sum = game->riga(p);
|
|
|
|
if (sum.get_long(PART_NREG) == _numreg &&
|
|
|
|
sum.get_int(PART_NUMRIG) == _numrig)
|
1995-09-13 16:01:30 +00:00
|
|
|
{
|
1995-09-12 07:58:03 +00:00
|
|
|
TRectype pag(scad.row(p));
|
|
|
|
real imp(pag.get(PAGSCA_IMPORTOVAL));
|
|
|
|
val.val2lit(imp);
|
|
|
|
pag.put(PAGSCA_IMPORTO, imp); // Converte in lire l'importo in valuta
|
1995-09-29 16:21:08 +00:00
|
|
|
#ifdef __EXTRA__
|
1995-11-23 14:20:03 +00:00
|
|
|
game->modifica_pagamento(pag, val, TRUE);
|
|
|
|
#else
|
1995-09-12 07:58:03 +00:00
|
|
|
app().notify_edit_pagamento(*game, pag, val);
|
1995-09-29 16:21:08 +00:00
|
|
|
#endif
|
1995-09-12 07:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1996-01-04 14:51:26 +00:00
|
|
|
fill_partite();
|
1995-09-12 07:58:03 +00:00
|
|
|
}
|
|
|
|
|
1995-12-07 11:09:17 +00:00
|
|
|
void TGame_mask::aggiorna_sorelle(const TRiga_partite& part) const
|
|
|
|
{
|
|
|
|
TPartite_array& pa = app().partite();
|
|
|
|
for (TPartita* game = pa.first(); game; game = pa.next())
|
|
|
|
{
|
|
|
|
for (int r = game->last(); r > 0; r = game->pred(r))
|
|
|
|
{
|
|
|
|
TRiga_partite& row = game->riga(r);
|
|
|
|
if (row.get_long(PART_NREG) == _numreg && row.get_int(PART_NUMRIG) == _numrig)
|
|
|
|
{
|
|
|
|
row.put(PART_DESCR, part.get(PART_DESCR));
|
|
|
|
row.put(PART_DATAPAG, part.get(PART_DATAPAG));
|
|
|
|
row.put(PART_TIPOPAG, part.get(PART_TIPOPAG));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-08-23 14:39:46 +00:00
|
|
|
bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
|
|
|
{
|
1995-10-25 09:34:53 +00:00
|
|
|
TGame_mask& gm = (TGame_mask&)partite.mask();
|
|
|
|
|
1995-08-23 14:39:46 +00:00
|
|
|
if (k == K_TAB)
|
|
|
|
{
|
1996-01-22 10:10:43 +00:00
|
|
|
const bool changing_row = gm._riga_partite != r;
|
|
|
|
if (!changing_row)
|
|
|
|
return TRUE;
|
1996-01-23 15:37:14 +00:00
|
|
|
|
|
|
|
main_app().begin_wait();
|
|
|
|
|
1995-08-23 14:39:46 +00:00
|
|
|
gm._riga_partite = r;
|
|
|
|
|
1996-01-11 15:44:06 +00:00
|
|
|
TSheet_field& sheet = gm.scadenze();
|
|
|
|
TString_array& scadenze = sheet.rows_array(); // Array delle righe
|
1996-01-12 17:43:52 +00:00
|
|
|
scadenze.destroy(); // Azzera righe
|
1995-08-23 14:39:46 +00:00
|
|
|
|
|
|
|
TToken_string& row = partite.row(r);
|
|
|
|
const int anno = row.get_int(0); // Anno partita
|
|
|
|
const TString16 num = row.get(); // Numero partita
|
|
|
|
gm.set(P_ANNO, anno); // Aggiorna campi di ricerca
|
|
|
|
gm.set(P_NUMERO, num);
|
|
|
|
|
1996-01-04 14:51:26 +00:00
|
|
|
TValuta cambio;
|
1996-01-19 13:09:12 +00:00
|
|
|
bool prima_valuta = FALSE;
|
1995-12-29 11:55:59 +00:00
|
|
|
|
1995-11-10 13:35:00 +00:00
|
|
|
if (anno > 0)
|
1995-08-23 14:39:46 +00:00
|
|
|
{
|
1995-11-10 13:35:00 +00:00
|
|
|
const TBill& zio = gm.conto(); // Conto cliente/fornitore
|
1995-10-25 09:34:53 +00:00
|
|
|
|
1995-11-10 13:35:00 +00:00
|
|
|
TPartita* game = app().partite().exist(zio, anno, num); // Cerca la partita tra quelle editate
|
|
|
|
const bool should_delete_game = (game == NULL); // Ricorda di fare delete
|
|
|
|
if (should_delete_game) // Se non c'era ...
|
|
|
|
game = new TPartita(zio, anno, num); // ... creane una temporanea
|
1995-10-25 09:34:53 +00:00
|
|
|
|
1995-11-10 13:35:00 +00:00
|
|
|
TImporto tot_lit, tot_val;
|
1995-11-13 15:32:37 +00:00
|
|
|
TToken_string riga_fattura(80);
|
1995-11-10 13:35:00 +00:00
|
|
|
|
|
|
|
const int lastrow = game->last();
|
|
|
|
for (int ri = game->first(); ri <= lastrow; ri = game->succ(ri))
|
1995-08-23 14:39:46 +00:00
|
|
|
{
|
1995-11-10 13:35:00 +00:00
|
|
|
const TRiga_partite& riga = game->riga(ri);
|
1995-11-13 15:32:37 +00:00
|
|
|
if (!riga.is_fattura())
|
|
|
|
continue;
|
|
|
|
|
1996-01-04 14:51:26 +00:00
|
|
|
cambio.get(riga);
|
1996-01-19 13:09:12 +00:00
|
|
|
const bool in_valuta = cambio.in_valuta();
|
|
|
|
if (in_valuta)
|
|
|
|
prima_valuta = TRUE;
|
1996-01-04 14:51:26 +00:00
|
|
|
|
1995-11-13 15:32:37 +00:00
|
|
|
riga_fattura.cut(0);
|
|
|
|
riga_fattura.add(ri);
|
|
|
|
riga_fattura.add("");
|
|
|
|
riga_fattura.add(riga.get(PART_DATADOC));
|
1995-12-29 11:55:59 +00:00
|
|
|
riga_fattura.add(""); // Data scad
|
1995-12-01 11:46:35 +00:00
|
|
|
gm.add_descrizione(riga_fattura, riga);
|
1995-12-18 10:56:53 +00:00
|
|
|
gm.add_importo(riga_fattura, riga.importo(FALSE, 0x1));
|
1995-11-13 15:32:37 +00:00
|
|
|
if (in_valuta)
|
1995-12-18 10:56:53 +00:00
|
|
|
gm.add_importo(riga_fattura, riga.importo(TRUE, 0x1), TRUE);
|
1995-11-13 15:32:37 +00:00
|
|
|
else
|
|
|
|
riga_fattura.add("");
|
|
|
|
riga_fattura.add(riga.get(PART_NREG));
|
|
|
|
riga_fattura.add(riga.get(PART_DATAREG));
|
|
|
|
riga_fattura.add(riga.get(PART_NUMDOC));
|
|
|
|
riga_fattura.add(riga.get(PART_PROTIVA));
|
|
|
|
scadenze.add(riga_fattura);
|
|
|
|
|
1995-11-10 13:35:00 +00:00
|
|
|
for (int ra = 1; ra <= riga.rate(); ra++)
|
1995-08-29 13:11:15 +00:00
|
|
|
{
|
1995-11-10 13:35:00 +00:00
|
|
|
const TRiga_scadenze& scad = riga.rata(ra);
|
1995-11-13 15:32:37 +00:00
|
|
|
|
1995-11-10 13:35:00 +00:00
|
|
|
TToken_string& row = scadenze.row(scadenze.add(riga_fattura));
|
|
|
|
row.add(ra, 1);
|
1995-12-29 11:55:59 +00:00
|
|
|
row.add(scad.get(SCAD_DATASCAD), 3);
|
1995-12-18 10:56:53 +00:00
|
|
|
gm.add_importo(row, scad.importo(FALSE), FALSE, 5);
|
1995-09-08 10:57:44 +00:00
|
|
|
if (in_valuta)
|
1995-12-18 10:56:53 +00:00
|
|
|
gm.add_importo(row, scad.importo(TRUE), TRUE, 6);
|
1995-11-13 15:32:37 +00:00
|
|
|
|
1995-11-10 13:35:00 +00:00
|
|
|
const int lastp = scad.last();
|
|
|
|
for (int pa = scad.first(); pa <= lastp; pa = scad.succ(pa))
|
1995-09-08 10:57:44 +00:00
|
|
|
{
|
1995-11-10 13:35:00 +00:00
|
|
|
const TRectype& pag = scad.row(pa);
|
|
|
|
const TRiga_partite& sum = game->riga(pa);
|
|
|
|
const char sez = sum.sezione();
|
1995-11-13 15:32:37 +00:00
|
|
|
|
1995-11-10 13:35:00 +00:00
|
|
|
TToken_string& row = scadenze.row(scadenze.add(""));
|
|
|
|
row.add(ri);
|
|
|
|
row.add(ra);
|
|
|
|
row.add(sum.get(PART_DATADOC));
|
1995-12-29 11:55:59 +00:00
|
|
|
row.add(sum.get(PART_DATAPAG));
|
1995-12-01 11:46:35 +00:00
|
|
|
gm.add_descrizione(row, sum);
|
1995-11-23 14:20:03 +00:00
|
|
|
TImporto imp(sez, pag.get_real(PAGSCA_IMPORTO));
|
1995-11-10 13:35:00 +00:00
|
|
|
if (in_valuta)
|
1995-11-23 14:20:03 +00:00
|
|
|
{
|
1995-12-01 11:46:35 +00:00
|
|
|
gm.add_importo(row, imp);
|
|
|
|
gm.add_importo(row, TImporto(sez, pag.get_real(PAGSCA_IMPORTOVAL)), TRUE);
|
1995-11-23 14:20:03 +00:00
|
|
|
}
|
1995-11-10 13:35:00 +00:00
|
|
|
else
|
1995-11-23 14:20:03 +00:00
|
|
|
{
|
1995-12-01 11:46:35 +00:00
|
|
|
gm.add_importo(row, imp);
|
1995-11-10 13:35:00 +00:00
|
|
|
row.add("");
|
1995-11-23 14:20:03 +00:00
|
|
|
}
|
1995-11-10 13:35:00 +00:00
|
|
|
row.add(sum.get(PART_NREG));
|
|
|
|
row.add(sum.get(PART_DATAREG));
|
|
|
|
row.add(sum.get(PART_NUMDOC));
|
|
|
|
row.add("");
|
|
|
|
row.add(pa);
|
1995-09-08 10:57:44 +00:00
|
|
|
}
|
1995-12-23 09:41:46 +00:00
|
|
|
|
|
|
|
const TImporto rit(scad.importo_pagato(FALSE, 0x8));
|
|
|
|
if (!rit.is_zero())
|
|
|
|
{
|
|
|
|
TToken_string& rrit = scadenze.row(scadenze.add(""));
|
|
|
|
rrit.add("Ritenute professionali", 4);
|
|
|
|
gm.add_importo(rrit, rit, FALSE);
|
|
|
|
}
|
1995-11-13 15:32:37 +00:00
|
|
|
|
1995-11-10 13:35:00 +00:00
|
|
|
TImporto abb(scad.importo_pagato(TRUE, 0x2));
|
|
|
|
if (!abb.is_zero())
|
1995-09-08 10:57:44 +00:00
|
|
|
{
|
1995-11-10 13:35:00 +00:00
|
|
|
TToken_string& rabb = scadenze.row(scadenze.add(""));
|
1995-12-23 09:41:46 +00:00
|
|
|
rabb.add("Abbuoni ", 4);
|
|
|
|
abb.normalize();
|
|
|
|
rabb << (abb.sezione() == 'D' ? "attivi" : "passivi");
|
|
|
|
|
1995-11-10 13:35:00 +00:00
|
|
|
if (in_valuta)
|
|
|
|
{
|
1995-12-01 11:46:35 +00:00
|
|
|
gm.add_importo(rabb, scad.importo_pagato(FALSE, 0x2), FALSE);
|
|
|
|
gm.add_importo(rabb, abb, TRUE);
|
1995-11-10 13:35:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1995-12-01 11:46:35 +00:00
|
|
|
gm.add_importo(rabb, abb, FALSE);
|
1995-11-10 13:35:00 +00:00
|
|
|
rabb.add("");
|
|
|
|
}
|
1995-09-08 10:57:44 +00:00
|
|
|
}
|
1995-11-13 15:32:37 +00:00
|
|
|
|
1995-09-08 10:57:44 +00:00
|
|
|
if (in_valuta)
|
|
|
|
{
|
1995-11-10 13:35:00 +00:00
|
|
|
TImporto diff(scad.importo_pagato(FALSE, 0x4));
|
|
|
|
if (!diff.is_zero())
|
|
|
|
{
|
|
|
|
TToken_string& rdiff = scadenze.row(scadenze.add(""));
|
1995-12-23 09:41:46 +00:00
|
|
|
rdiff.add("Differenza cambio", 4);
|
1995-12-18 10:56:53 +00:00
|
|
|
gm.add_importo(rdiff, diff);
|
1995-11-10 13:35:00 +00:00
|
|
|
}
|
|
|
|
}
|
1995-11-13 15:32:37 +00:00
|
|
|
|
1995-11-10 13:35:00 +00:00
|
|
|
TToken_string& rsal = scadenze.row(scadenze.add(""));
|
|
|
|
rsal.add("Saldo rata ", 4); rsal << ra;
|
|
|
|
if (!scad.chiusa())
|
|
|
|
{
|
1995-12-12 12:37:01 +00:00
|
|
|
TImporto sl = scad.residuo(FALSE);
|
1995-12-01 11:46:35 +00:00
|
|
|
gm.add_importo(rsal, sl);
|
1995-11-10 13:35:00 +00:00
|
|
|
tot_lit += sl;
|
1995-11-13 15:32:37 +00:00
|
|
|
|
1995-11-10 13:35:00 +00:00
|
|
|
if (in_valuta)
|
1995-12-01 11:46:35 +00:00
|
|
|
{
|
1995-12-12 12:37:01 +00:00
|
|
|
sl = scad.residuo(TRUE, 0xB);
|
1995-12-01 11:46:35 +00:00
|
|
|
gm.add_importo(rsal, sl, TRUE);
|
1995-11-10 13:35:00 +00:00
|
|
|
tot_val += sl;
|
|
|
|
}
|
1995-09-08 10:57:44 +00:00
|
|
|
}
|
1995-11-10 13:35:00 +00:00
|
|
|
}
|
1995-11-13 12:07:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TRecord_array& unas = game->unassigned();
|
|
|
|
const int lastp = unas.last_row();
|
|
|
|
for (int pa = unas.first_row(); pa <= lastp; pa = unas.succ_row(pa))
|
|
|
|
{
|
|
|
|
const TRectype& pag = unas.row(pa);
|
|
|
|
const TRiga_partite& sum = game->riga(pa);
|
|
|
|
TImporto imp(sum.sezione(), ZERO);
|
1995-11-10 13:35:00 +00:00
|
|
|
|
1995-11-13 12:07:05 +00:00
|
|
|
TToken_string& row = scadenze.row(scadenze.add(""));
|
|
|
|
row.add(pag.get(PAGSCA_NRIGA));
|
|
|
|
row.add(pag.get(PAGSCA_NRATA));
|
|
|
|
row.add(sum.get(PART_DATADOC));
|
1995-12-29 11:55:59 +00:00
|
|
|
row.add(sum.get(PART_DATAPAG));
|
1995-12-01 11:46:35 +00:00
|
|
|
gm.add_descrizione(row, sum);
|
1995-11-13 12:07:05 +00:00
|
|
|
TImporto i(sum.sezione(), pag.get_real(PAGSCA_IMPORTO));
|
1995-11-23 14:20:03 +00:00
|
|
|
i.valore() += pag.get_real(PAGSCA_RITENUTE);
|
1995-11-13 12:07:05 +00:00
|
|
|
i.normalize();
|
1995-12-01 11:46:35 +00:00
|
|
|
gm.add_importo(row, i);
|
1995-11-13 12:07:05 +00:00
|
|
|
tot_lit += i;
|
|
|
|
|
|
|
|
const real& impval = pag.get_real(PAGSCA_IMPORTOVAL);
|
|
|
|
if (!impval.is_zero())
|
|
|
|
{
|
1995-12-01 11:46:35 +00:00
|
|
|
i.set(sum.sezione(), impval);
|
1995-09-29 16:21:08 +00:00
|
|
|
i.normalize();
|
1995-12-01 11:46:35 +00:00
|
|
|
gm.add_importo(row, i, TRUE);
|
1995-11-13 12:07:05 +00:00
|
|
|
tot_val += i;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
row.add("");
|
|
|
|
row.add(sum.get(PART_NREG));
|
|
|
|
row.add(sum.get(PART_DATAREG));
|
|
|
|
row.add(sum.get(PART_NUMDOC));
|
|
|
|
row.add("");
|
|
|
|
row.add(pa);
|
1995-11-10 13:35:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (lastrow > 0)
|
|
|
|
{
|
|
|
|
TToken_string& sp = scadenze.row(scadenze.add(""));
|
1996-01-12 17:43:52 +00:00
|
|
|
sp.add("Saldo partita", 4);
|
1996-01-04 14:51:26 +00:00
|
|
|
if (cambio.in_valuta())
|
1996-01-12 17:43:52 +00:00
|
|
|
sp << ' ' << cambio.codice();
|
1996-01-04 14:51:26 +00:00
|
|
|
|
1995-12-18 10:56:53 +00:00
|
|
|
gm.add_importo(sp, tot_lit);
|
|
|
|
gm.add_importo(sp, tot_val, TRUE);
|
1995-09-01 15:06:35 +00:00
|
|
|
}
|
1995-08-28 07:50:28 +00:00
|
|
|
|
1995-11-10 13:35:00 +00:00
|
|
|
if (should_delete_game)
|
|
|
|
delete game;
|
1995-10-11 11:39:50 +00:00
|
|
|
}
|
1995-09-08 10:57:44 +00:00
|
|
|
|
1996-01-19 13:09:12 +00:00
|
|
|
if (prima_valuta != gm._valfirst)
|
1995-12-29 11:55:59 +00:00
|
|
|
{
|
1996-01-11 15:44:06 +00:00
|
|
|
sheet.swap_columns(106, 107); // Scambia le colonne dell'importo in lire e in valuta
|
1996-01-19 13:09:12 +00:00
|
|
|
gm._valfirst = prima_valuta;
|
1995-12-29 11:55:59 +00:00
|
|
|
}
|
1996-01-11 15:44:06 +00:00
|
|
|
|
1996-01-22 10:10:43 +00:00
|
|
|
sheet.force_update();
|
|
|
|
if (sheet.items() > 0 && sheet.selected() > 0)
|
|
|
|
sheet.select(0, TRUE);
|
1996-01-23 15:37:14 +00:00
|
|
|
|
|
|
|
main_app().end_wait();
|
1995-10-25 09:34:53 +00:00
|
|
|
}
|
1996-01-23 15:37:14 +00:00
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
if (k == K_INS)
|
|
|
|
{
|
|
|
|
gm.send_key(K_CTRL + 'N', 0, &partite); // Simula la pressione del tasto nuovo
|
|
|
|
return FALSE; // Rifiuta l'aggiunta di una riga
|
1995-08-23 14:39:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
bool TGame_mask::scadenze_notify(TSheet_field& scadenze, int r, KEY k)
|
|
|
|
{
|
|
|
|
if (k == K_INS)
|
|
|
|
{
|
|
|
|
TGame_mask& gm = (TGame_mask&)scadenze.mask();
|
|
|
|
gm.send_key(K_CTRL + 'N', 0, &scadenze); // Simula la pressione del tasto nuovo
|
|
|
|
return FALSE; // Rifiuta l'aggiunta di una riga
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
1995-09-29 16:21:08 +00:00
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
int TGame_mask::nuova_riga(TPartita& partita) const
|
|
|
|
{
|
1995-11-10 13:35:00 +00:00
|
|
|
TRiga_partite& part = partita.new_row(); // Creazione nuova riga vuota
|
1995-10-25 09:34:53 +00:00
|
|
|
const int nriga = part.get_int(PART_NRIGA);
|
|
|
|
|
|
|
|
// Copia dati movimento corrente
|
1995-11-10 13:35:00 +00:00
|
|
|
part.put(PART_NREG, _numreg); // Numero operazione
|
|
|
|
part.put(PART_NUMRIG, _numrig); // Riga su cui ho cliccato
|
1995-10-25 09:34:53 +00:00
|
|
|
|
1995-11-10 13:35:00 +00:00
|
|
|
// Forza il gruppo/conto cliente corretto
|
|
|
|
part.put(PART_GRUPPOCL, conto().gruppo());
|
|
|
|
part.put(PART_CONTOCL, conto().conto());
|
|
|
|
|
|
|
|
// Setta il cambio corrente
|
1995-12-29 11:55:59 +00:00
|
|
|
const TValuta valuta(*this, P_VALUTA, P_DATACAMBIO, P_CAMBIO);
|
1995-11-23 14:20:03 +00:00
|
|
|
valuta.put(part);
|
1995-09-29 16:21:08 +00:00
|
|
|
|
|
|
|
#ifdef __EXTRA__
|
1995-12-07 11:09:17 +00:00
|
|
|
part.put(PART_TIPOMOV, (int)_tipomov);
|
1995-10-25 09:34:53 +00:00
|
|
|
part.put(PART_DESCR, _descr);
|
|
|
|
part.put(PART_NUMDOC, _numdoc);
|
|
|
|
part.put(PART_DATADOC, _datadoc);
|
1995-12-01 11:46:35 +00:00
|
|
|
part.put(PART_DATAPAG, _datadoc);
|
1995-10-25 09:34:53 +00:00
|
|
|
part.put(PART_DATAREG, TDate(TODAY));
|
|
|
|
part.put(PART_SEZ, _sezione);
|
|
|
|
part.put(PART_SEZABB, _sezione);
|
|
|
|
part.put(PART_SEZDIFCAM,_sezione);
|
1995-12-07 11:09:17 +00:00
|
|
|
if (_tipomov == tm_fattura)
|
1995-10-25 09:34:53 +00:00
|
|
|
{
|
|
|
|
part.put(PART_IMPORTO, _importo.valore());
|
1995-11-23 14:20:03 +00:00
|
|
|
if (valuta.in_valuta())
|
1995-09-27 13:45:27 +00:00
|
|
|
{
|
1995-11-23 14:20:03 +00:00
|
|
|
const real impval = valuta.lit2val(_importo.valore());
|
1995-10-25 09:34:53 +00:00
|
|
|
part.put(PART_IMPORTOVAL, impval);
|
1995-09-27 13:45:27 +00:00
|
|
|
}
|
1995-10-25 09:34:53 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
TMask& cm = app().curr_mask();
|
|
|
|
const TCausale& causale = app().causale();
|
1995-12-07 11:09:17 +00:00
|
|
|
const tipo_movimento tm = (tipo_movimento)causale.tipomov();
|
|
|
|
part.put(PART_TIPOMOV, (int)tm);
|
1995-10-25 09:34:53 +00:00
|
|
|
part.put(PART_NUMDOC, cm.get(F_NUMDOC));
|
|
|
|
part.put(PART_DATADOC, cm.get(F_DATADOC));
|
|
|
|
part.put(PART_DATAREG, cm.get(F_DATAREG));
|
1995-12-07 11:09:17 +00:00
|
|
|
part.put(PART_DESCR, cm.get(F_DESCR));
|
1995-12-01 11:46:35 +00:00
|
|
|
part.put(PART_DATAPAG, cm.get(F_DATAREG));
|
1995-12-07 11:09:17 +00:00
|
|
|
part.put(PART_TIPOPAG, 1);
|
|
|
|
|
|
|
|
const TRiga_partite* prima = (tm != tm_fattura) ? cerca_prima_riga() : NULL;
|
|
|
|
if (prima != NULL && prima != &part)
|
|
|
|
{
|
|
|
|
part.put(PART_DESCR, prima->get(PART_DESCR));
|
|
|
|
part.put(PART_DATAPAG, prima->get(PART_DATAPAG));
|
|
|
|
part.put(PART_TIPOPAG, prima->get(PART_TIPOPAG));
|
|
|
|
}
|
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
// Copia dati causale corrente
|
|
|
|
part.put(PART_CODCAUS, causale.codice());
|
|
|
|
if (causale.iva() != nessuna_iva)
|
|
|
|
{
|
|
|
|
part.put(PART_REG, cm.get(F_CODREG));
|
|
|
|
part.put(PART_PROTIVA, cm.get(F_PROTIVA));
|
|
|
|
}
|
|
|
|
|
|
|
|
const char tipoc = conto().tipo();
|
|
|
|
// Complesso algoritmo per calcolare la sezione di una nuova riga partita
|
|
|
|
char sezione = causale.sezione(1); // Usa la sezione della causale
|
|
|
|
if (sezione <= ' ') // Se non c'e' la sezione bell'e' ch'e' pronta
|
|
|
|
{
|
1995-12-07 11:09:17 +00:00
|
|
|
if (tm == tm_fattura || tm == tm_insoluto) // calcola in base al tipo movimento e
|
|
|
|
sezione = (tipoc == 'C') ? 'D' : 'A'; // al tipo cliente/fornitore
|
1995-10-25 09:34:53 +00:00
|
|
|
else
|
|
|
|
sezione = (tipoc == 'C') ? 'A' : 'D';
|
|
|
|
}
|
1995-12-07 11:09:17 +00:00
|
|
|
if (tipoc > ' ') // Se il tipo e' C o F
|
1995-10-25 09:34:53 +00:00
|
|
|
{
|
1995-12-07 11:09:17 +00:00
|
|
|
TBill bill; causale.bill(1, bill); // Legge primo conto causale
|
1995-10-25 09:34:53 +00:00
|
|
|
if (bill.tipo() != tipoc)
|
1995-12-07 11:09:17 +00:00
|
|
|
sezione = (sezione == 'D') ? 'A' : 'D'; // scambia segno
|
1995-10-25 09:34:53 +00:00
|
|
|
}
|
|
|
|
// Memorizza solo la sezione (importi nulli)
|
|
|
|
part.put(PART_SEZ, sezione);
|
|
|
|
part.put(PART_SEZABB, sezione);
|
|
|
|
part.put(PART_SEZDIFCAM, sezione);
|
1995-09-29 16:21:08 +00:00
|
|
|
#endif
|
1995-10-25 09:34:53 +00:00
|
|
|
|
|
|
|
return nriga;
|
|
|
|
}
|
1995-09-27 13:45:27 +00:00
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
int TGame_mask::nuovo_pagamento(TPartita& partita, int nriga, int rata) const
|
|
|
|
{
|
1995-11-17 10:27:24 +00:00
|
|
|
#ifdef __EXTRA__
|
|
|
|
const int nrigp = nuova_riga(partita);
|
1996-01-25 17:20:49 +00:00
|
|
|
if (nriga > 0 && nriga != TPartita::UNASSIGNED)
|
1995-11-23 14:20:03 +00:00
|
|
|
{
|
|
|
|
const TRiga_partite& fattura = partita.riga(nriga);
|
|
|
|
const TValuta val(fattura);
|
|
|
|
TRiga_partite& somma = partita.riga(nrigp);
|
|
|
|
val.put(somma);
|
|
|
|
}
|
1995-11-17 10:27:24 +00:00
|
|
|
#else
|
1995-10-25 09:34:53 +00:00
|
|
|
int nrigp = partita.mov2rig(_numreg, _numrig); // Cerca riga partita relativa alla riga rmov
|
|
|
|
if (nrigp <= 0) // Devo creare una nuova riga di partita
|
|
|
|
nrigp = nuova_riga(partita);
|
1995-11-17 10:27:24 +00:00
|
|
|
#endif
|
1995-09-27 13:45:27 +00:00
|
|
|
TRectype& pagamento = partita.pagamento(nriga, rata, nrigp); // Crea nuovo pagamento
|
1995-12-20 16:16:14 +00:00
|
|
|
|
|
|
|
// Calcola riga causale per la contropartita in base al tipo pagamento
|
|
|
|
int caus = 2;
|
1995-09-27 13:45:27 +00:00
|
|
|
if (rata != TPartita::UNASSIGNED)
|
|
|
|
{
|
|
|
|
const TRiga_scadenze& scad = partita.rata(nriga, rata);
|
|
|
|
const int tp = scad.get_int(SCAD_TIPOPAG);
|
1995-12-20 16:16:14 +00:00
|
|
|
caus = partita.tipopag2causale(tp);
|
1995-09-27 13:45:27 +00:00
|
|
|
|
1995-12-07 11:09:17 +00:00
|
|
|
TRiga_partite& somma = partita.riga(nrigp);
|
|
|
|
somma.put(PART_TIPOPAG, tp);
|
|
|
|
|
1995-09-27 13:45:27 +00:00
|
|
|
pagamento.put(PAGSCA_CODABIPR, scad.get(SCAD_CODABIPR));
|
|
|
|
pagamento.put(PAGSCA_CODCABPR, scad.get(SCAD_CODCABPR));
|
|
|
|
pagamento.put(PAGSCA_CODABI, scad.get(SCAD_CODABI));
|
|
|
|
pagamento.put(PAGSCA_CODCAB, scad.get(SCAD_CODCAB));
|
|
|
|
pagamento.put(PAGSCA_CODAG, scad.get(SCAD_CODAG));
|
|
|
|
}
|
1995-09-29 16:21:08 +00:00
|
|
|
|
|
|
|
#ifndef __EXTRA__
|
1995-10-25 09:34:53 +00:00
|
|
|
const TCausale& causale = app().causale();
|
1995-09-27 13:45:27 +00:00
|
|
|
TBill contro; causale.bill(caus, contro); // Legge conto contropartita
|
1995-09-29 16:21:08 +00:00
|
|
|
if (caus != 2 && contro.empty()) // Se non specificato ...
|
|
|
|
causale.bill(caus = 2, contro); // ... prende il primo
|
1995-09-27 13:45:27 +00:00
|
|
|
contro.put(pagamento, TRUE); // Scrive conto contropartita
|
1995-09-29 16:21:08 +00:00
|
|
|
#endif
|
1995-09-27 13:45:27 +00:00
|
|
|
|
|
|
|
return nrigp;
|
|
|
|
}
|
|
|
|
|
1995-08-23 14:39:46 +00:00
|
|
|
bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
|
|
|
|
{
|
|
|
|
if (k == K_SPACE)
|
|
|
|
{
|
|
|
|
TMask& m = f.mask();
|
1995-09-08 10:57:44 +00:00
|
|
|
const int nriga = m.get_int(101);
|
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
if (nriga == 0)
|
|
|
|
return FALSE; // Ho cliccato su di un saldo (per sbaglio!)
|
|
|
|
|
1995-08-23 14:39:46 +00:00
|
|
|
TGame_mask& gm = (TGame_mask&)(m.get_sheet()->mask());
|
|
|
|
const TBill& bill = gm.conto();
|
|
|
|
const int anno = gm.get_int(P_ANNO);
|
|
|
|
const TString16 numero = gm.get(P_NUMERO);
|
1996-01-04 14:51:26 +00:00
|
|
|
|
1995-08-29 13:11:15 +00:00
|
|
|
TPartita& game = app().partite().partita(bill, anno, numero);
|
1996-01-04 14:51:26 +00:00
|
|
|
|
1995-11-09 08:05:53 +00:00
|
|
|
long nreg = m.get_long(108); // Numero registrazione
|
|
|
|
const int nrata = m.get_int(102); // Rata selezionata (puo' essere 0)
|
|
|
|
int nrigp = m.get_int(112); // Pagamento selezionato (puo' essere 0)
|
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
if (nrata != 0 && nrigp == 0)
|
1995-11-09 08:05:53 +00:00
|
|
|
{
|
1996-01-04 14:51:26 +00:00
|
|
|
const TValuta parval(game.riga(nriga));
|
|
|
|
const TValuta curval(gm, P_VALUTA, P_DATACAMBIO, P_CAMBIO);
|
|
|
|
if (parval != curval)
|
|
|
|
{
|
|
|
|
TString c = parval.codice();
|
|
|
|
if (c.empty()) c = "lire";
|
|
|
|
return error_box("La fattura deve essere pagata in %s.", (const char*)c);
|
|
|
|
}
|
|
|
|
|
1995-11-10 13:35:00 +00:00
|
|
|
#ifdef __EXTRA__
|
1995-12-15 12:17:27 +00:00
|
|
|
gm._tipomov = (tipo_movimento) 3;
|
1995-11-10 13:35:00 +00:00
|
|
|
gm._descr = "";
|
|
|
|
gm._numdoc = "";
|
|
|
|
gm._datadoc = TDate(TODAY);
|
|
|
|
gm._sezione = game.riga(nriga).sezione() == 'D' ? 'A' : 'D';
|
|
|
|
#endif
|
1995-09-27 13:45:27 +00:00
|
|
|
nrigp = gm.nuovo_pagamento(game, nriga, nrata);
|
1995-11-09 08:05:53 +00:00
|
|
|
nreg = gm._numreg;
|
|
|
|
}
|
1995-10-25 09:34:53 +00:00
|
|
|
|
1995-11-17 10:27:24 +00:00
|
|
|
bool cambiato = FALSE;
|
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
if (nrigp > 0) // Si vuole editare un pagamento
|
1995-10-31 13:59:03 +00:00
|
|
|
{
|
1995-11-09 08:05:53 +00:00
|
|
|
if (nreg == gm._numreg)
|
|
|
|
{
|
1995-11-17 10:27:24 +00:00
|
|
|
cambiato = gm.edit_pagamento(game, nriga, nrata, nrigp);
|
|
|
|
if (cambiato)
|
1995-11-09 08:05:53 +00:00
|
|
|
{
|
1996-01-04 14:51:26 +00:00
|
|
|
if (m.is_running() && !game.esiste(nriga, nrata, nrigp))
|
|
|
|
m.stop_run(K_FORCE_CLOSE);
|
1995-11-09 08:05:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
1995-11-10 13:35:00 +00:00
|
|
|
{
|
|
|
|
#ifdef __EXTRA__
|
|
|
|
gm.prima_nota(nreg);
|
|
|
|
#else
|
1995-11-09 08:05:53 +00:00
|
|
|
return f.error_box("Modificare il movimento %ld", nreg);
|
1995-11-10 13:35:00 +00:00
|
|
|
#endif
|
|
|
|
}
|
1995-10-25 09:34:53 +00:00
|
|
|
}
|
1995-08-23 14:39:46 +00:00
|
|
|
else
|
1995-10-25 09:34:53 +00:00
|
|
|
{ // Si vogliono editare le rate
|
|
|
|
#ifdef __EXTRA__
|
|
|
|
if (nreg > 0)
|
1995-11-10 13:35:00 +00:00
|
|
|
gm.prima_nota(nreg);
|
1995-10-25 09:34:53 +00:00
|
|
|
else
|
1995-11-17 10:27:24 +00:00
|
|
|
cambiato = gm.edit_fattura(game, nriga);
|
1995-10-25 09:34:53 +00:00
|
|
|
#else
|
|
|
|
if (nreg != gm._numreg || nrata == 0)
|
|
|
|
{
|
|
|
|
if (nreg == 0)
|
|
|
|
f.error_box("Utilizzare la gestione extra-contabile");
|
|
|
|
else
|
|
|
|
f.error_box("Modificare il movimento %ld", nreg);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
#endif
|
1995-08-25 07:39:49 +00:00
|
|
|
}
|
1995-11-17 10:27:24 +00:00
|
|
|
if (cambiato)
|
1996-01-19 13:09:12 +00:00
|
|
|
{
|
|
|
|
if (game.ok())
|
|
|
|
{
|
|
|
|
gm.update_partita(game, gm._riga_partite);
|
1996-01-23 15:37:14 +00:00
|
|
|
const int r = gm._riga_partite;
|
|
|
|
gm._riga_partite = -1; // Forza aggiornamento sheet
|
|
|
|
partite_notify(gm.partite(), r, K_TAB);
|
1996-01-19 13:09:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
app().partite().destroy(game);
|
|
|
|
gm.fill_partite();
|
|
|
|
}
|
1995-11-17 10:27:24 +00:00
|
|
|
gm._changed = TRUE;
|
|
|
|
}
|
1995-08-23 14:39:46 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1996-01-03 12:10:02 +00:00
|
|
|
void TGame_mask::align_number(TMask_field& f) const
|
|
|
|
{
|
|
|
|
const TPartita game(conto(), 0, "*");
|
|
|
|
const char a = game.allineamento_richiesto();
|
|
|
|
f.set_justify(a == 'R');
|
|
|
|
}
|
|
|
|
|
1995-08-23 14:39:46 +00:00
|
|
|
|
1995-08-30 12:14:19 +00:00
|
|
|
bool TGame_mask::nuovo_handler(TMask_field& f, KEY k)
|
|
|
|
{
|
|
|
|
if (k == K_SPACE)
|
1995-10-25 09:34:53 +00:00
|
|
|
{
|
|
|
|
TGame_mask& gm = (TGame_mask&)f.mask();
|
1995-10-11 11:39:50 +00:00
|
|
|
int anno;
|
1995-10-25 09:34:53 +00:00
|
|
|
TString numero;
|
1995-10-11 11:39:50 +00:00
|
|
|
|
1996-01-03 12:10:02 +00:00
|
|
|
TMask* new_game = new TMask("cg2100n"); // We must create mask on the heap!
|
|
|
|
gm.align_number(new_game->field(P_NUMERO));
|
|
|
|
new_game->first_focus(P_NUMERO);
|
1995-08-30 12:14:19 +00:00
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
#ifndef __EXTRA__
|
|
|
|
const TMask& cm = app().curr_mask();
|
1996-01-03 12:10:02 +00:00
|
|
|
new_game->disable(-1);
|
1995-12-07 11:09:17 +00:00
|
|
|
gm._tipomov = (tipo_movimento)app().causale().tipomov();
|
1996-01-03 12:10:02 +00:00
|
|
|
new_game->set(P_NUOVO, gm._tipomov);
|
1996-01-04 14:51:26 +00:00
|
|
|
new_game->set(P_SEZIONE, gm._residuo.sezione());
|
|
|
|
new_game->set(P_RESIDUO, gm._residuo.valore());
|
1996-01-03 12:10:02 +00:00
|
|
|
new_game->set(P_DATADOC, cm.get(F_DATADOC));
|
|
|
|
new_game->set(P_NUMDOC, cm.get(F_NUMDOC));
|
|
|
|
new_game->set(P_DESCR, cm.get(F_DESCR));
|
1995-10-25 09:34:53 +00:00
|
|
|
if (gm._tipomov < 3)
|
1996-01-03 12:10:02 +00:00
|
|
|
new_game->set(P_CODPAG,cm.get(F_CODPAG));
|
1995-10-25 09:34:53 +00:00
|
|
|
if (gm._tipomov == 2)
|
1995-09-13 16:01:30 +00:00
|
|
|
{
|
1996-01-03 12:10:02 +00:00
|
|
|
new_game->set(P_ANNO, cm.get(F_ANNORIF));
|
|
|
|
new_game->set(P_NUMERO, cm.get(F_NUMRIF));
|
1995-09-13 16:01:30 +00:00
|
|
|
}
|
1995-10-25 09:34:53 +00:00
|
|
|
#endif
|
|
|
|
|
1996-01-03 12:10:02 +00:00
|
|
|
k = new_game->run();
|
|
|
|
anno = new_game->get_int(P_ANNO);
|
|
|
|
numero = new_game->get(P_NUMERO);
|
|
|
|
|
|
|
|
gm._tipomov = (tipo_movimento)new_game->get_int(P_NUOVO);
|
|
|
|
gm._codpag = new_game->get(P_CODPAG);
|
|
|
|
gm._sezione = new_game->get(P_SEZIONE)[0];
|
|
|
|
gm._numdoc = new_game->get(P_NUMDOC);
|
|
|
|
gm._datadoc = new_game->get(P_DATADOC);
|
|
|
|
gm._descr = new_game->get(P_DESCR);
|
|
|
|
|
|
|
|
delete new_game; new_game = NULL;
|
1995-09-13 16:01:30 +00:00
|
|
|
|
1995-10-11 11:39:50 +00:00
|
|
|
if (k == K_ENTER)
|
1995-08-30 12:14:19 +00:00
|
|
|
{
|
|
|
|
TPartita& game = app().partite().partita(gm.conto(), anno, numero);
|
1995-09-08 10:57:44 +00:00
|
|
|
|
1996-01-03 12:10:02 +00:00
|
|
|
if (gm._tipomov != tm_fattura)
|
1995-10-25 09:34:53 +00:00
|
|
|
{
|
1995-12-01 11:46:35 +00:00
|
|
|
if (game.ok())
|
|
|
|
return error_box("La partita %d '%s' esiste gia'.", anno, (const char*)game.numero());
|
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
const int nriga = TPartita::UNASSIGNED;
|
|
|
|
const int nrata = TPartita::UNASSIGNED;
|
|
|
|
const int nrigp = gm.nuovo_pagamento(game, nriga, nrata);
|
|
|
|
gm.edit_pagamento(game, nriga, nrata, nrigp);
|
|
|
|
}
|
|
|
|
#ifdef __EXTRA__
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gm.edit_fattura(game, 0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (game.ok())
|
1996-01-04 14:51:26 +00:00
|
|
|
{
|
|
|
|
gm.set(P_ANNO, anno);
|
|
|
|
gm.set(P_NUMERO, numero);
|
1995-10-25 09:34:53 +00:00
|
|
|
gm._changed = TRUE;
|
|
|
|
}
|
1995-09-01 15:06:35 +00:00
|
|
|
else
|
1996-01-19 13:09:12 +00:00
|
|
|
app().partite().destroy(game);
|
1996-01-11 15:44:06 +00:00
|
|
|
gm.fill_partite(); // Aggiorna sheet partite
|
1995-08-30 12:14:19 +00:00
|
|
|
}
|
|
|
|
}
|
1995-10-11 11:39:50 +00:00
|
|
|
|
1995-08-30 12:14:19 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Metodi della maschera delle partite
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
void TGame_mask::add_importo(TToken_string& s, const TImporto& i, bool valuta, int pos)
|
1995-08-23 14:39:46 +00:00
|
|
|
{
|
|
|
|
if (i.is_zero())
|
1995-10-25 09:34:53 +00:00
|
|
|
s.add("", pos);
|
1995-08-23 14:39:46 +00:00
|
|
|
else
|
1995-10-25 09:34:53 +00:00
|
|
|
{
|
|
|
|
TString80 v;
|
1995-12-18 10:56:53 +00:00
|
|
|
TImporto n(i); n.normalize();
|
1995-12-29 11:55:59 +00:00
|
|
|
if (valuta)
|
|
|
|
{
|
1996-01-12 17:43:52 +00:00
|
|
|
v = n.valore().string(0, 3);
|
1995-12-29 11:55:59 +00:00
|
|
|
const int sep = v.find('.');
|
|
|
|
v[sep] = ',';
|
|
|
|
}
|
|
|
|
else
|
1996-01-12 17:43:52 +00:00
|
|
|
v = n.valore().string(0, 0);
|
1995-12-29 11:55:59 +00:00
|
|
|
v << ' ' << n.sezione();
|
1995-10-25 09:34:53 +00:00
|
|
|
s.add(v, pos);
|
1995-08-23 14:39:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-12-01 11:46:35 +00:00
|
|
|
void TGame_mask::add_descrizione(TToken_string& s, const TRiga_partite& riga, int pos)
|
|
|
|
{
|
|
|
|
const TString& desc = riga.get(PART_DESCR);
|
|
|
|
if (desc.empty())
|
|
|
|
{
|
|
|
|
const TString& caus = riga.get(PART_CODCAUS);
|
|
|
|
if (caus.not_empty())
|
|
|
|
s.add(_causali.decode(caus), pos);
|
|
|
|
else
|
|
|
|
s.add("", pos);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
s.add(desc, pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-08-28 07:50:28 +00:00
|
|
|
TImporto TGame_mask::get_importo(TToken_string& s, int pos) const
|
|
|
|
{
|
|
|
|
const TFixed_string imp(s.get(pos));
|
|
|
|
const real i(imp);
|
|
|
|
const char sez = imp.right(1)[0];
|
|
|
|
return TImporto(sez, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-09-13 16:01:30 +00:00
|
|
|
int TGame_mask::update_partita(const TPartita& game, int prow)
|
1996-01-11 15:44:06 +00:00
|
|
|
{
|
1995-08-25 07:39:49 +00:00
|
|
|
TImporto saldo, doc, pag, imp;
|
|
|
|
game.calcola_saldo(saldo, doc, pag, imp);
|
1995-09-13 16:01:30 +00:00
|
|
|
|
1995-08-28 07:50:28 +00:00
|
|
|
int riga_fatt = game.prima_fattura();
|
|
|
|
if (riga_fatt <= 0) riga_fatt = game.first(); // E' un anticipo
|
1995-09-13 16:01:30 +00:00
|
|
|
|
1996-01-23 15:37:14 +00:00
|
|
|
TSheet_field& games = partite();
|
1995-09-13 16:01:30 +00:00
|
|
|
TToken_string &r = games.row(prow); // Stringa di lavoro per lo sheet
|
|
|
|
if (game.esiste(riga_fatt)) // Esiste veramente
|
|
|
|
{
|
|
|
|
const TRiga_partite& riga = game.riga(riga_fatt);
|
|
|
|
r.cut(0);
|
1996-01-11 15:44:06 +00:00
|
|
|
r.add(riga.get(PART_ANNO)); r.right_just(4); // Mette gli spazi se ce n'e' bisogno
|
1995-09-13 16:01:30 +00:00
|
|
|
r.add(riga.get(PART_NUMPART));
|
|
|
|
r.add(riga.get(PART_DATADOC));
|
|
|
|
r.add(riga.get(PART_NUMDOC));
|
|
|
|
add_importo(r, saldo);
|
|
|
|
add_importo(r, doc);
|
|
|
|
add_importo(r, pag);
|
|
|
|
add_importo(r, imp);
|
|
|
|
r.add(riga.get(PART_DESCR));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r.add("", 4);
|
|
|
|
r.add("", 5);
|
|
|
|
r.add("", 6);
|
|
|
|
r.add("", 7);
|
|
|
|
}
|
1995-08-28 07:50:28 +00:00
|
|
|
|
|
|
|
if (prow >= 0)
|
1995-08-29 13:11:15 +00:00
|
|
|
{
|
|
|
|
games.force_update(prow);
|
1995-08-28 07:50:28 +00:00
|
|
|
update_saldo_clifo();
|
1995-08-29 13:11:15 +00:00
|
|
|
games.force_update(games.items()-1);
|
1995-09-13 16:01:30 +00:00
|
|
|
aggiorna_residuo();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
prow = partite().items()-1;
|
1995-11-10 13:35:00 +00:00
|
|
|
|
|
|
|
if (prow == 0)
|
|
|
|
{
|
|
|
|
const char all = game.allineamento_richiesto();
|
|
|
|
field(P_NUMERO).set_justify(all == 'R');
|
|
|
|
}
|
1995-09-13 16:01:30 +00:00
|
|
|
|
|
|
|
return prow;
|
1995-08-28 07:50:28 +00:00
|
|
|
}
|
|
|
|
|
1995-09-13 16:01:30 +00:00
|
|
|
void TGame_mask::update_saldo_clifo()
|
1995-08-28 07:50:28 +00:00
|
|
|
{
|
|
|
|
TString_array& s = partite().rows_array();
|
|
|
|
|
|
|
|
TImporto sal, doc, pag, imp;
|
|
|
|
for (int i = 0; i < s.items(); i++)
|
|
|
|
{
|
|
|
|
TToken_string& r = s.row(i);
|
|
|
|
if (r.get_int(0) > 0)
|
|
|
|
{
|
|
|
|
sal += get_importo(r, 4);
|
|
|
|
doc += get_importo(r, -1);
|
|
|
|
pag += get_importo(r, -1);
|
|
|
|
imp += get_importo(r, -1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
1995-08-25 07:39:49 +00:00
|
|
|
}
|
1995-08-28 07:50:28 +00:00
|
|
|
|
|
|
|
TToken_string& r = s.row(s.add("", i));
|
|
|
|
r.add("");
|
|
|
|
r.add("");
|
|
|
|
r.add(TDate(TODAY).string());
|
|
|
|
r.add("");
|
1995-12-18 10:56:53 +00:00
|
|
|
add_importo(r, sal);
|
|
|
|
add_importo(r, doc);
|
|
|
|
add_importo(r, pag);
|
|
|
|
add_importo(r, imp);
|
1995-08-28 07:50:28 +00:00
|
|
|
r.add("Saldo ");
|
1996-01-03 12:10:02 +00:00
|
|
|
append_conto(r);
|
1995-08-25 07:39:49 +00:00
|
|
|
}
|
|
|
|
|
1995-12-29 11:55:59 +00:00
|
|
|
long TGame_mask::number_distance(const char* k, const char* n) const
|
|
|
|
{
|
|
|
|
TString16 key(k); key.upper(); key.trim();
|
|
|
|
const int kl = key.len();
|
|
|
|
TString16 num(n); num.upper(); num.trim();
|
|
|
|
const int nl = num.len();
|
|
|
|
long dist = 0;
|
1996-01-03 12:10:02 +00:00
|
|
|
for (int i = kl-1; i >= 0; i--)
|
1995-12-29 11:55:59 +00:00
|
|
|
{
|
|
|
|
const char kc = i < kl ? key[i] : 0;
|
|
|
|
const char nc = i < nl ? num[i] : 0;
|
1996-01-03 12:10:02 +00:00
|
|
|
const long d = abs(kc - nc) * (kl - i) * 32;
|
|
|
|
dist += d;
|
1995-12-29 11:55:59 +00:00
|
|
|
}
|
|
|
|
return dist;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TGame_mask::same_number(const char* key, const char* num) const
|
1995-11-10 13:35:00 +00:00
|
|
|
{
|
1995-12-29 11:55:59 +00:00
|
|
|
TString16 k(key); k.upper(); k.trim();
|
|
|
|
TString16 n(num); n.upper(); n.trim();
|
|
|
|
return k == n;
|
1995-11-10 13:35:00 +00:00
|
|
|
}
|
|
|
|
|
1996-01-04 14:51:26 +00:00
|
|
|
void TGame_mask::fill_partite()
|
|
|
|
{
|
|
|
|
const int annorif = get_int(P_ANNO); // Anno corrente
|
|
|
|
const TString numrif = get(P_NUMERO); // Partita corrente
|
|
|
|
const bool all = get(P_SHOWALL).not_empty(); // Visualizza anche partite chiuse
|
|
|
|
|
1995-08-23 14:39:46 +00:00
|
|
|
TString_array& a = partite().rows_array();
|
|
|
|
a.destroy();
|
|
|
|
|
|
|
|
app().begin_wait();
|
1995-10-11 11:39:50 +00:00
|
|
|
|
|
|
|
for (TPartita* gioco = app().partite().first(); gioco != NULL; gioco = app().partite().next())
|
1995-11-20 15:25:19 +00:00
|
|
|
{
|
|
|
|
const TBill& zio = gioco->conto();
|
|
|
|
if (zio.tipo() <= ' ' || zio.sottoconto() == conto().sottoconto())
|
|
|
|
update_partita(*gioco, -1);
|
|
|
|
}
|
1995-08-23 14:39:46 +00:00
|
|
|
|
|
|
|
TLocalisamfile partita(LF_PARTITE);
|
|
|
|
partita.zero();
|
|
|
|
if (conto().tipo() > ' ') // Ignora gruppo e conto dei clifo
|
|
|
|
{
|
|
|
|
partita.put(PART_TIPOCF, conto().tipo());
|
1995-11-09 08:05:53 +00:00
|
|
|
partita.put(PART_SOTTOCONTO, conto().codclifo());
|
1995-08-23 14:39:46 +00:00
|
|
|
}
|
1995-11-09 08:05:53 +00:00
|
|
|
else
|
|
|
|
conto().put(partita.curr()); // Scrive completamente i conti normali
|
1995-08-28 07:50:28 +00:00
|
|
|
|
1995-08-23 14:39:46 +00:00
|
|
|
const TRectype filter(partita.curr()); // Record campione
|
|
|
|
|
|
|
|
for (int err = partita.read(_isgteq);
|
|
|
|
err == NOERR && partita.curr() == filter;
|
|
|
|
err = partita.read(_isgreat))
|
|
|
|
{
|
|
|
|
const int anno = partita.get_int(PART_ANNO);
|
|
|
|
const TString16 num(partita.get(PART_NUMPART));
|
|
|
|
|
1995-10-11 11:39:50 +00:00
|
|
|
if (!app().partite().exist(conto(), anno, num))
|
1995-08-23 14:39:46 +00:00
|
|
|
{
|
1995-10-11 11:39:50 +00:00
|
|
|
TPartita game(conto(), anno, num);
|
1996-01-09 10:32:00 +00:00
|
|
|
if (all || !game.chiusa())
|
|
|
|
update_partita(game, -1);
|
1995-10-11 11:39:50 +00:00
|
|
|
}
|
1995-08-23 14:39:46 +00:00
|
|
|
partita.put(PART_NRIGA, 9999); // Forza lettura partita successiva nella prossima read
|
|
|
|
}
|
1995-11-13 12:07:05 +00:00
|
|
|
|
|
|
|
a.sort();
|
|
|
|
for (int r = a.items()-1; r > 0; r--)
|
|
|
|
{
|
|
|
|
TToken_string& row = a.row(r);
|
|
|
|
if (annorif == row.get_int(0) && same_number(numrif, row.get(1)))
|
|
|
|
break;
|
|
|
|
}
|
1995-10-11 11:39:50 +00:00
|
|
|
|
1995-08-28 07:50:28 +00:00
|
|
|
update_saldo_clifo();
|
1995-08-23 14:39:46 +00:00
|
|
|
partite().force_update();
|
1995-09-13 16:01:30 +00:00
|
|
|
aggiorna_residuo();
|
1995-08-29 13:11:15 +00:00
|
|
|
|
1995-11-13 12:07:05 +00:00
|
|
|
if (a.items() > 1)
|
1996-01-22 10:10:43 +00:00
|
|
|
{
|
|
|
|
_riga_partite = -1;
|
|
|
|
partite().select(r, TRUE);
|
1995-09-13 16:01:30 +00:00
|
|
|
}
|
1995-08-23 14:39:46 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
scadenze().destroy();
|
|
|
|
}
|
|
|
|
app().end_wait();
|
|
|
|
}
|
|
|
|
|
1995-09-01 15:06:35 +00:00
|
|
|
|
1995-09-29 16:21:08 +00:00
|
|
|
bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) const
|
1995-08-23 14:39:46 +00:00
|
|
|
{
|
1995-10-11 11:39:50 +00:00
|
|
|
TRectype oldpag = p.pagamento(nriga, nrata, nrigp);
|
|
|
|
TRiga_partite& somma = p.riga(nrigp);
|
1995-12-07 11:09:17 +00:00
|
|
|
|
1996-01-11 15:44:06 +00:00
|
|
|
TPay_mask* pm = new TPay_mask; // We must create masks on the heap
|
1995-12-07 11:09:17 +00:00
|
|
|
TPay_mask& m = *pm;
|
1996-01-03 12:10:02 +00:00
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
if (nriga == TPartita::UNASSIGNED)
|
1996-01-11 15:44:06 +00:00
|
|
|
{
|
|
|
|
TRiga_scadenze& scaden = somma.new_row(); // Crea una rata falsa
|
1996-01-03 12:10:02 +00:00
|
|
|
scaden.put(SCAD_DATASCAD, somma.get(PART_DATADOC));
|
1996-01-04 14:51:26 +00:00
|
|
|
m.set_pag(oldpag, scaden, _residuo);
|
1996-01-11 15:44:06 +00:00
|
|
|
somma.destroy_rows(); // Distrugge la rata falsa
|
1995-10-25 09:34:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const TRiga_scadenze& scaden = p.rata(nriga, nrata);
|
1996-01-04 14:51:26 +00:00
|
|
|
m.set_pag(oldpag, scaden, _residuo);
|
1995-09-01 15:06:35 +00:00
|
|
|
}
|
1995-08-23 14:39:46 +00:00
|
|
|
|
1995-11-17 10:27:24 +00:00
|
|
|
const bool nuovo = oldpag.get(PAGSCA_ACCSAL) != "S" &&
|
1995-12-01 11:46:35 +00:00
|
|
|
oldpag.get_real(PAGSCA_IMPORTO).is_zero() &&
|
|
|
|
oldpag.get_real(PAGSCA_RITENUTE).is_zero();
|
1995-12-07 11:09:17 +00:00
|
|
|
|
1995-11-17 10:27:24 +00:00
|
|
|
KEY key = m.run();
|
1995-12-07 11:09:17 +00:00
|
|
|
|
1995-11-17 10:27:24 +00:00
|
|
|
if (key == K_ESC && nuovo)
|
|
|
|
key = K_DEL;
|
|
|
|
|
1995-08-23 14:39:46 +00:00
|
|
|
if (key == K_ENTER || key == K_DEL)
|
|
|
|
{
|
1995-12-07 11:09:17 +00:00
|
|
|
TRectype newpag(oldpag);
|
|
|
|
|
1995-08-23 14:39:46 +00:00
|
|
|
if (key == K_DEL)
|
|
|
|
{
|
1995-12-07 11:09:17 +00:00
|
|
|
newpag.zero(PAGSCA_ACCSAL); // Non puo' essere un saldo
|
|
|
|
newpag.zero(PAGSCA_IMPORTO); // Azzera importo ...
|
|
|
|
newpag.zero(PAGSCA_IMPORTOVAL); // .. anche in valuta
|
|
|
|
newpag.zero(PAGSCA_RITENUTE); // Azzera ritenute
|
1995-08-23 14:39:46 +00:00
|
|
|
}
|
1995-11-09 08:05:53 +00:00
|
|
|
else
|
|
|
|
{
|
1995-12-07 11:09:17 +00:00
|
|
|
m.get_pag(newpag);
|
1995-12-01 11:46:35 +00:00
|
|
|
somma.put(PART_DESCR, m.get(S_DESCAGG)); // Aggiorna descrizione (comune alla riga)
|
|
|
|
somma.put(PART_DATAPAG, m.get(S_DATAPAG)); // Aggiorna data pagamento (comune alla riga)
|
1995-12-07 11:09:17 +00:00
|
|
|
somma.put(PART_TIPOPAG, m.get(S_TIPOPAG)); // Aggiorna tipo pagamento (comune alla riga)
|
|
|
|
#ifndef __EXTRA__
|
1996-01-19 13:09:12 +00:00
|
|
|
// aggiorna_sorelle(somma); // Tolta chiamata alla aggiorna sorelle lasciare la funzione perche potrebbe servire in futuro
|
1995-12-07 11:09:17 +00:00
|
|
|
#endif
|
1995-11-09 08:05:53 +00:00
|
|
|
}
|
|
|
|
|
1995-11-23 14:20:03 +00:00
|
|
|
TValuta val;
|
1995-09-29 16:21:08 +00:00
|
|
|
#ifdef __EXTRA__
|
1995-11-23 14:20:03 +00:00
|
|
|
val.get(m, S_VALUTA, S_DATACAMBIO, S_CAMBIO);
|
|
|
|
p.modifica_pagamento(newpag, val, TRUE);
|
|
|
|
#else
|
|
|
|
if (somma.is_nota_credito())
|
|
|
|
p.modifica_pagamento(newpag, val, TRUE);
|
|
|
|
else
|
|
|
|
app().notify_edit_pagamento(p, newpag, val);
|
1995-10-25 09:34:53 +00:00
|
|
|
#endif
|
1996-01-03 12:10:02 +00:00
|
|
|
}
|
1995-12-07 11:09:17 +00:00
|
|
|
|
|
|
|
delete pm;
|
1996-01-03 12:10:02 +00:00
|
|
|
|
1995-11-09 08:05:53 +00:00
|
|
|
return key != K_ESC;
|
1995-08-23 14:39:46 +00:00
|
|
|
}
|
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
#ifndef __EXTRA__
|
|
|
|
|
1995-09-29 16:21:08 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Edit delle partite
|
|
|
|
///////////////////////////////////////////////////////////
|
1995-08-25 07:39:49 +00:00
|
|
|
|
1995-10-11 11:39:50 +00:00
|
|
|
bool TPrimanota_application::edit_partite(const TMask& m, int riga)
|
1995-09-29 16:21:08 +00:00
|
|
|
{
|
1995-11-03 10:23:24 +00:00
|
|
|
const char tipo = m.get(103)[0];
|
|
|
|
const int gruppo = m.get_int(104);
|
|
|
|
const int conto = m.get_int(105);
|
|
|
|
const long sottoconto = m.get_int(106);
|
|
|
|
const TBill b(gruppo, conto, sottoconto, tipo); // Legge il conto della riga selezionata
|
1995-09-29 16:21:08 +00:00
|
|
|
if (!b.ok())
|
|
|
|
return FALSE; // Esci se il conto della riga cliente non e' valido
|
1995-12-19 15:53:50 +00:00
|
|
|
|
|
|
|
TMovimentoPN* pn = (TMovimentoPN*)get_relation();
|
|
|
|
curr_mask().autosave(pn); // Aggiorna i dati della testata sulle partite
|
|
|
|
const TRectype& mov = pn->curr();
|
|
|
|
partite().update_reg(mov, pn->cg_rows());
|
1995-09-29 16:21:08 +00:00
|
|
|
|
|
|
|
// Esecuzione maschera di selezione partite
|
1995-12-07 11:09:17 +00:00
|
|
|
TGame_mask* mask = new TGame_mask(b, mov.get_long(MOV_NUMREG), riga+1);
|
|
|
|
mask->run();
|
|
|
|
const bool changed = mask->changed();
|
|
|
|
delete mask;
|
1995-09-29 16:21:08 +00:00
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
if (changed)
|
|
|
|
{
|
|
|
|
cgs().force_update(); // Aggiornamento righe contabili
|
|
|
|
calcola_saldo();
|
|
|
|
}
|
|
|
|
return changed;
|
1995-08-23 14:39:46 +00:00
|
|
|
}
|
|
|
|
|
1995-10-25 09:34:53 +00:00
|
|
|
#endif
|