Corretto un mare di errori
git-svn-id: svn://10.65.10.50/trunk@2435 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
e24e990a50
commit
3c2c64c22a
@ -8,6 +8,7 @@
|
||||
#define P_VALUTA 109
|
||||
#define P_DATACAMBIO 110
|
||||
#define P_CAMBIO 111
|
||||
#define P_RESIDUOVAL 112
|
||||
|
||||
#define P_SHOWALL 180
|
||||
#define P_NUOVO 182
|
||||
@ -15,10 +16,10 @@
|
||||
#define P_SCADENZE 202
|
||||
|
||||
// Campi aggiuntivi per extra-contabile
|
||||
#define P_DATADOC 112
|
||||
#define P_SEZIONE 113
|
||||
#define P_CODPAG 114
|
||||
#define P_NUMDOC 115
|
||||
#define P_DATADOC 120
|
||||
#define P_SEZIONE 121
|
||||
#define P_CODPAG 122
|
||||
#define P_NUMDOC 123
|
||||
|
||||
|
||||
// Scadenze
|
||||
|
@ -26,13 +26,13 @@ END
|
||||
|
||||
STRING P_VALUTA 3
|
||||
BEGIN
|
||||
PROMPT 1 2 "Valuta "
|
||||
PROMPT 1 2 "Valuta "
|
||||
FLAGS "DUZ"
|
||||
END
|
||||
|
||||
DATE P_DATACAMBIO
|
||||
BEGIN
|
||||
PROMPT 21 2 "Data cambio "
|
||||
PROMPT 18 2 "Data cambio "
|
||||
FLAGS "DR"
|
||||
USE CAM
|
||||
INPUT CODTAB[1,3] P_VALUTA
|
||||
@ -57,23 +57,30 @@ END
|
||||
|
||||
NUMBER P_ANNO 4
|
||||
BEGIN
|
||||
PROMPT 1 3 "Partita "
|
||||
PROMPT 1 3 "Partita "
|
||||
FLAGS "U"
|
||||
END
|
||||
|
||||
STRING P_NUMERO 7
|
||||
BEGIN
|
||||
PROMPT 21 3 ""
|
||||
PROMPT 16 3 ""
|
||||
FLAGS "U"
|
||||
END
|
||||
|
||||
NUMBER P_RESIDUO 15
|
||||
BEGIN
|
||||
PROMPT 48 3 "Residuo "
|
||||
PROMPT 30 3 "Residuo "
|
||||
FLAGS "D"
|
||||
PICTURE "."
|
||||
END
|
||||
|
||||
NUMBER P_RESIDUOVAL 15 3
|
||||
BEGIN
|
||||
PROMPT 56 3 ""
|
||||
FLAGS "D"
|
||||
PICTURE ".3"
|
||||
END
|
||||
|
||||
SPREADSHEET P_PARTITE 0 7
|
||||
BEGIN
|
||||
PROMPT 0 4 ""
|
||||
|
209
cg/cg2101.cpp
209
cg/cg2101.cpp
@ -42,20 +42,24 @@ TRectype& TMovimentoPN::iva(int i)
|
||||
return _iva.row(i >= 0 ? i+1 : -1, TRUE);
|
||||
}
|
||||
|
||||
|
||||
int TMovimentoPN::read_mov_rows()
|
||||
{
|
||||
const long numreg = lfile().get_long(MOV_NUMREG);
|
||||
const TRectype& mov = curr();
|
||||
const long numreg = mov.get_long(MOV_NUMREG);
|
||||
|
||||
TRectype cgfilter(LF_RMOV);
|
||||
cgfilter.zero();
|
||||
cgfilter.put(RMV_NUMREG, numreg);
|
||||
TRectype* cgfilter = new TRectype(LF_RMOV);
|
||||
cgfilter->put(RMV_NUMREG, numreg);
|
||||
_cg.read(cgfilter);
|
||||
|
||||
TRectype ivafilter(LF_RMOVIVA);
|
||||
ivafilter.zero();
|
||||
ivafilter.put(RMI_NUMREG, numreg);
|
||||
TRectype* ivafilter = new TRectype(LF_RMOVIVA);
|
||||
ivafilter->put(RMI_NUMREG, numreg);
|
||||
_iva.read(ivafilter);
|
||||
|
||||
/*
|
||||
if (_cg.rows() > 0 && _iva.rows() > 0 && cg(0).get_char(RMV_ROWTYPE) != 'T')
|
||||
adjust_row_types();
|
||||
*/
|
||||
return _cg.rows();
|
||||
}
|
||||
|
||||
@ -262,3 +266,194 @@ int TMovimentoPN::remove(TDate&)
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Aggiustamento movimenti rovinati o convertiti male
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TConti_array : private TAssoc_array
|
||||
{
|
||||
public: // TObject
|
||||
virtual bool ok() const { return items() != 0; }
|
||||
|
||||
public:
|
||||
bool add(const TBill& conto, const real& importo);
|
||||
real importo(const TBill& conto);
|
||||
bool remove(const TBill& conto);
|
||||
|
||||
bool add_iva(bool det, const real& importo);
|
||||
real importo_iva(bool det);
|
||||
bool remove_iva(bool det);
|
||||
|
||||
TConti_array() {}
|
||||
virtual ~TConti_array() {}
|
||||
};
|
||||
|
||||
bool TConti_array::add(const TBill& conto, const real& importo)
|
||||
{
|
||||
const char* key = conto.string();
|
||||
real* imp = (real*)objptr(key);
|
||||
if (imp == NULL)
|
||||
TAssoc_array::add(key, importo);
|
||||
else
|
||||
*imp += importo;
|
||||
return imp != NULL;
|
||||
}
|
||||
|
||||
real TConti_array::importo(const TBill& conto)
|
||||
{
|
||||
const char* key = conto.string();
|
||||
const real* imp = (real*)objptr(key);
|
||||
return imp ? *imp : ZERO;
|
||||
}
|
||||
|
||||
bool TConti_array::remove(const TBill& conto)
|
||||
{
|
||||
const char* key = conto.string();
|
||||
return TAssoc_array::remove(key);
|
||||
}
|
||||
|
||||
bool TConti_array::add_iva(bool det, const real& importo)
|
||||
{
|
||||
const char* const key = det ? "D" : "N";
|
||||
real* imp = (real*)objptr(key);
|
||||
if (imp == NULL)
|
||||
TAssoc_array::add(key, importo);
|
||||
else
|
||||
*imp += importo;
|
||||
|
||||
return imp != NULL;
|
||||
}
|
||||
|
||||
real TConti_array::importo_iva(bool det)
|
||||
{
|
||||
const char* const key = det ? "D" : "N";
|
||||
const real* imp = (real*)objptr(key);
|
||||
return imp ? *imp : ZERO;
|
||||
}
|
||||
|
||||
|
||||
bool TConti_array::remove_iva(bool det)
|
||||
{
|
||||
const char* const key = det ? "D" : "N";
|
||||
return TAssoc_array::remove(key);
|
||||
}
|
||||
|
||||
|
||||
HIDDEN bool detraibile(const TRectype& row, const TCausale& cau)
|
||||
{
|
||||
if (cau.iva() == iva_vendite) // Vendite sempre detraibili
|
||||
return TRUE;
|
||||
|
||||
const int tipo_det = row.get_int(RMI_TIPODET); // Leggi tipo detraibilita
|
||||
if (tipo_det != 0)
|
||||
return FALSE;
|
||||
|
||||
const real& prorata = cau.reg().prorata();
|
||||
return prorata < 100.0; // Se prorata = 100% e' indetraibile
|
||||
}
|
||||
|
||||
// Aggiusta i row types se sono andati persi o non sono stati convertiti
|
||||
void TMovimentoPN::adjust_rowtypes()
|
||||
{
|
||||
const TRectype& mov = curr();
|
||||
const char tipo = mov.get_char(MOV_TIPO);
|
||||
const long codice = mov.get_long(MOV_CODCF);
|
||||
const int annoiva = mov.get_int(MOV_ANNOIVA);
|
||||
const TCausale causale(mov.get(MOV_CODCAUS), annoiva);
|
||||
|
||||
TConti_array conti;
|
||||
for (int r = 0; r < _iva.rows(); r++)
|
||||
{
|
||||
const TRectype& row = iva(r);
|
||||
const TBill bill(row);
|
||||
real imponibile(row.get(RMI_IMPONIBILE));
|
||||
|
||||
real imposta(row.get(RMI_IMPOSTA));
|
||||
const bool det = detraibile(row, causale);
|
||||
|
||||
if (imposta.is_zero() && causale.corrispettivi())
|
||||
{
|
||||
const TCodiceIVA iva(row.get(RMI_CODIVA));
|
||||
imposta = iva.scorpora(imponibile);
|
||||
}
|
||||
conti.add(bill, imponibile);
|
||||
conti.add_iva(det, imposta);
|
||||
}
|
||||
|
||||
bool totale = FALSE;
|
||||
bool ritfis = mov.get_real(MOV_RITFIS).is_zero();
|
||||
bool ritsoc = mov.get_real(MOV_RITSOC).is_zero();
|
||||
bool ivadet = conti.importo_iva(TRUE).is_zero();
|
||||
bool ivanon = conti.importo_iva(FALSE).is_zero();
|
||||
|
||||
for (r = 0; r < _cg.rows(); r++)
|
||||
{
|
||||
TRectype& row = cg(r);
|
||||
const char rt = row.get_char(RMV_ROWTYPE);
|
||||
switch(rt)
|
||||
{
|
||||
case 'F': ritfis = TRUE; break;
|
||||
case 'S': ritsoc = TRUE; break;
|
||||
case 'T': totale = TRUE; break;
|
||||
default : break;
|
||||
}
|
||||
if (rt > ' ') continue;
|
||||
|
||||
if (!totale && row.get_char(RMV_TIPOC) == tipo && row.get_long(RMV_SOTTOCONTO) == codice)
|
||||
{
|
||||
row.put(RMV_ROWTYPE, 'T');
|
||||
totale = TRUE;
|
||||
continue;
|
||||
}
|
||||
|
||||
const real importo(row.get(RMV_IMPORTO));
|
||||
const TBill bill(row);
|
||||
|
||||
if (!ritfis && importo == mov.get_real(MOV_RITFIS))
|
||||
{
|
||||
TBill conto_rit; causale.bill(RIGA_RITENUTE_FISCALI, conto_rit);
|
||||
if (!conto_rit.ok() || conto_rit == bill)
|
||||
{
|
||||
row.put(RMV_ROWTYPE, 'F');
|
||||
ritfis = TRUE;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ritsoc && importo == mov.get_real(MOV_RITSOC))
|
||||
{
|
||||
TBill conto_rit; causale.bill(RIGA_RITENUTE_SOCIALI, conto_rit);
|
||||
if (!conto_rit.ok() || conto_rit == bill)
|
||||
{
|
||||
row.put(RMV_ROWTYPE, 'S');
|
||||
ritsoc = TRUE;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!conti.ok())
|
||||
continue; // Ho esaurito i conti IVA
|
||||
|
||||
if (importo == conti.importo(bill))
|
||||
{
|
||||
row.put(RMV_ROWTYPE, 'I');
|
||||
conti.remove(bill);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!ivadet && importo == conti.importo_iva(TRUE))
|
||||
{
|
||||
row.put(RMV_ROWTYPE, 'D');
|
||||
conti.remove_iva(TRUE);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!ivanon && importo == conti.importo_iva(FALSE))
|
||||
{
|
||||
row.put(RMV_ROWTYPE, 'N');
|
||||
conti.remove_iva(FALSE);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
int date2liq(const TDate& data) const; // Estrae dalla data il mese di liquidazione
|
||||
char frequenza_versamenti(int year) const; // Ritorna 'M'ensile o 'T'rimestrale
|
||||
bool controlla_liquidazione(const TDate& data, TRegistro& reg, bool reset = FALSE) const;
|
||||
void adjust_rowtypes();
|
||||
|
||||
TMovimentoPN();
|
||||
virtual ~TMovimentoPN() {}
|
||||
|
119
cg/cg2102.cpp
119
cg/cg2102.cpp
@ -33,9 +33,9 @@ TipoIVA TPrimanota_application::cau2IVA(const char* cod, int annoiva)
|
||||
// Certified 99%
|
||||
const real& TPrimanota_application::cod2IVA(const TMask& m)
|
||||
{
|
||||
static TString16 _codiva;
|
||||
static real _percent;
|
||||
|
||||
static TString16 _codiva; // Ultimo codice iva decodificato
|
||||
static real _percent; // Percentuale dell'ultimo codice iva
|
||||
// Tipo Costo Ricavo
|
||||
if (app().iva() == iva_acquisti && m.get_int(103) == 3)
|
||||
return ZERO;
|
||||
|
||||
@ -519,9 +519,11 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
|
||||
return f.error_box("Il movimento e' sbilanciato di %s lire.", ss);
|
||||
}
|
||||
|
||||
const long numreg = f.mask().get_long(F_NUMREG);
|
||||
const bool paga = app().is_pagamento();
|
||||
const bool nota = app().is_saldaconto() && app().causale().tipomov() == 2;
|
||||
const bool nota = app().is_nota_credito();
|
||||
|
||||
TMask& m = f.mask();
|
||||
const long numreg = m.get_long(F_NUMREG);
|
||||
|
||||
TImporto saldaconto;
|
||||
|
||||
@ -582,6 +584,34 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
|
||||
}
|
||||
}
|
||||
|
||||
if (app().is_fattura())
|
||||
{
|
||||
TBill contocf;
|
||||
if (!app().cerca_conto_cf(contocf))
|
||||
{
|
||||
TString msg(80); msg = "Non esiste una riga contabile riferita al ";
|
||||
msg << (contocf.tipo() == 'C' ? "cliente" : "fornitore") << ' ';
|
||||
msg << contocf.codclifo() << ":\n";
|
||||
if (m.edit_mode() && m.field(F_NUMRIF).enabled())
|
||||
{
|
||||
msg << "Si desidera eliminare il saldaconto?";
|
||||
const bool kill = f.yesno_box(msg);
|
||||
if (kill)
|
||||
{
|
||||
m.reset(F_ANNORIF);
|
||||
m.reset(F_NUMRIF);
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg << "Impossibile registrare il saldaconto!";
|
||||
return f.error_box(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty)
|
||||
return f.error_box("Il movimento non ha nessuna riga contabile con un importo");
|
||||
}
|
||||
@ -727,7 +757,6 @@ bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
|
||||
break;
|
||||
case K_TAB:
|
||||
cg.sheet_mask().enable(DLG_DELREC, tipo <= ' ' || tipo == 'K' || tipo == 'G');
|
||||
// cg.sheet_mask().enable(100, tipo == 'K');
|
||||
break;
|
||||
case K_DEL:
|
||||
if (tipo == 'G')
|
||||
@ -784,7 +813,7 @@ bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
|
||||
{
|
||||
cg.swap_rows(r, i);
|
||||
cg.force_update();
|
||||
cg.select(i);
|
||||
cg.select(i, FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -967,7 +996,7 @@ bool TPrimanota_application::imposta_handler(TMask_field& f, KEY key)
|
||||
if ((key == K_ENTER || key == K_TAB) && f.dirty())
|
||||
{
|
||||
const real imponibile(f.mask().get(101));
|
||||
const real& percent = app().causale().corrispettivi() ? ZERO : cod2IVA(f.mask());
|
||||
const real percent = app().causale().corrispettivi() ? ZERO : cod2IVA(f.mask());
|
||||
real imposta = abs(imponibile) * percent / 100.0;
|
||||
imposta.ceil();
|
||||
if (imponibile.sign() < 0) imposta = -imposta;
|
||||
@ -1137,8 +1166,11 @@ bool TPrimanota_application::iva_notify(TSheet_field& iva, int r, KEY k)
|
||||
int newpos = bill2pos(conto, 'I'); // Riga in cui andra' l'imponibile
|
||||
|
||||
const bool detrarre = detraibile(row); // Determina se IVA detraibile
|
||||
const int ri = detrarre ? 3 : 4; // Calcola riga causale col conto opportuno
|
||||
|
||||
// Calcola riga causale col conto opportuno
|
||||
const int ri = detrarre ? RIGA_IVA_DETRAIBILE : RIGA_IVA_NON_DETRAIBILE;
|
||||
TBill contoiva; app().causale().bill(ri, contoiva);
|
||||
|
||||
if (ri == 4 && !contoiva.ok()) // Se non c'e' il conto IVA indetraibile ...
|
||||
{ // ... somma imponibile e imposta
|
||||
imponibile += imposta;
|
||||
@ -1678,38 +1710,36 @@ bool TPrimanota_application::occas_handler(TMask_field& f, KEY key)
|
||||
// Certified 99%
|
||||
void TPrimanota_application::add_cgs_tot(TMask& m)
|
||||
{
|
||||
// Lettura del conto dalla maschera
|
||||
char tipo = app().clifo();
|
||||
long codice = m.get_long(tipo == 'C' ? F_CLIENTE : F_FORNITORE);
|
||||
TBill bill(0, 0, codice, tipo);
|
||||
|
||||
if (!causale().corrispettivi())
|
||||
bill.find();
|
||||
|
||||
if (bill.conto() == 0)
|
||||
{
|
||||
// Se l'utente non ha ancora specificato un conto lo prendo dalla prima riga della causale
|
||||
causale().bill(1, bill);
|
||||
if (causale().corrispettivi())
|
||||
{
|
||||
tipo = ' ';
|
||||
codice = bill.sottoconto();
|
||||
}
|
||||
const char tipo = app().clifo();
|
||||
int gruppo = 0, conto = 0;
|
||||
const long codice = m.get_long(tipo == 'C' ? F_CLIENTE : F_FORNITORE);
|
||||
|
||||
const int riga_totale = type2pos('T');
|
||||
if (riga_totale >= 0)
|
||||
{
|
||||
TToken_string& rowt = cgs().row(riga_totale);
|
||||
gruppo = rowt.get_int(3);
|
||||
conto = rowt.get_int();
|
||||
}
|
||||
|
||||
TBill nuovo(bill.gruppo(), bill.conto(), codice, tipo);
|
||||
|
||||
real tot(m.get(F_TOTALE));
|
||||
TBill nuovo(gruppo, conto, codice, tipo);
|
||||
if ((gruppo == 0 || conto == 0) && !causale().corrispettivi())
|
||||
nuovo.find(); // Compila anche gruppo e conto
|
||||
|
||||
const int pos = type2pos('T');
|
||||
if (pos >= 0)
|
||||
if (nuovo.gruppo() == 0 || nuovo.conto() == 0)
|
||||
{
|
||||
// Se l'utente non ha ancora specificato un conto lo prendo dalla prima riga della causale
|
||||
causale().bill(1, nuovo);
|
||||
}
|
||||
|
||||
if (riga_totale >= 0)
|
||||
{
|
||||
TSheet_field& ss = cgs();
|
||||
TToken_string& row = ss.row(pos);
|
||||
TToken_string& row = ss.row(riga_totale);
|
||||
const TBill vecchio(row, 2, 0x1);
|
||||
if (!vecchio.empty() && nuovo != vecchio) // Se cambio cliente/fornitore
|
||||
{
|
||||
for (int i = 0; i < ss.items(); i++) if (i != pos)
|
||||
for (int i = 0; i < ss.items(); i++) if (i != riga_totale)
|
||||
{
|
||||
TToken_string& r = ss.row(i);
|
||||
const TBill tacchia(r, 9, 0x1);
|
||||
@ -1723,7 +1753,8 @@ void TPrimanota_application::add_cgs_tot(TMask& m)
|
||||
}
|
||||
|
||||
// Creazione/Aggiornamento riga totale
|
||||
set_cgs_row(pos, real2imp(tot, 'T'), nuovo, m.get(F_DESCR), 'T');
|
||||
const real tot(m.get(F_TOTALE));
|
||||
set_cgs_row(riga_totale, real2imp(tot, 'T'), nuovo, m.get(F_DESCR), 'T');
|
||||
calcola_imp(); // Ricalcola totale IVA
|
||||
calcola_saldo(); // Ricalcola sbilanci
|
||||
}
|
||||
@ -1840,23 +1871,9 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
|
||||
bool TPrimanota_application::IVA2bill(const TCodiceIVA& iva, TBill& bill)
|
||||
{
|
||||
const TCausale& cau = causale();
|
||||
const TString& tipo = iva.tipo();
|
||||
|
||||
if (tipo.not_empty())
|
||||
{
|
||||
if (tipo == "ES") cau.bill(5, bill); else
|
||||
if (tipo == "NI") cau.bill(6, bill); else
|
||||
if (tipo == "NS") cau.bill(7, bill);
|
||||
}
|
||||
if (!bill.ok() && !cau.corrispettivi())
|
||||
if (!cau.corrispettivi())
|
||||
bill = _conto_ricavo;
|
||||
|
||||
if (!bill.ok())
|
||||
cau.bill(2, bill);
|
||||
|
||||
ivas_bill(bill);
|
||||
|
||||
return bill.ok();
|
||||
return cau.IVA2bill(iva, bill);
|
||||
}
|
||||
|
||||
|
||||
@ -2020,7 +2037,7 @@ void TPrimanota_application::add_cgs_rit(bool fiscali)
|
||||
{
|
||||
if (!imp.is_zero()) // ... e l'importo e' valido
|
||||
{ // crea una nuova riga di ritenute
|
||||
const int riga = fiscali ? 8 : 9;
|
||||
const int riga = fiscali ? RIGA_RITENUTE_FISCALI : RIGA_RITENUTE_SOCIALI;
|
||||
TBill conto; causale().bill(riga, conto);
|
||||
const TString80 desc(causale().desc_agg(riga));
|
||||
set_cgs_row(-1, real2imp(imp, tipo), conto, desc, tipo);
|
||||
|
@ -25,12 +25,6 @@
|
||||
#include "cg2103.h"
|
||||
#endif
|
||||
|
||||
#define RIGA_ABBUONI_PASSIVI 9
|
||||
#define RIGA_ABBUONI_ATTIVI 10
|
||||
#define RIGA_SPESE 11
|
||||
#define RIGA_RITENUTE 12
|
||||
#define RIGA_DIFFCAM 13
|
||||
|
||||
class TPrimanota_application : public TRelation_application
|
||||
{
|
||||
TArray _file; // Tutti i fiels da usare
|
||||
@ -236,6 +230,8 @@ protected:
|
||||
void remove_scadenze(const TMask& m, const char* rif);
|
||||
void renumber_partita(TMask& m, const char* oldp, const char* newp);
|
||||
void recalc_scadenze(const TDate& d);
|
||||
|
||||
bool cerca_conto_cf(TBill& bill) const;
|
||||
|
||||
bool edit_partite(const TMask& m, int riga);
|
||||
|
||||
|
@ -250,6 +250,39 @@ TLibro_giornale::TLibro_giornale(int y)
|
||||
read(y);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Codice IVA
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TCodiceIVA::TCodiceIVA(const char* cod) : TRectype(LF_TABCOM)
|
||||
{
|
||||
read(cod);
|
||||
}
|
||||
|
||||
bool TCodiceIVA::read(const char* cod)
|
||||
{
|
||||
int err = ~NOERR;
|
||||
if (cod && *cod)
|
||||
{
|
||||
TTable iva("%IVA");
|
||||
iva.put("CODTAB", cod);
|
||||
err = iva.read();
|
||||
TRectype::operator=(iva.curr());
|
||||
}
|
||||
if (err != NOERR)
|
||||
zero();
|
||||
return err == NOERR;
|
||||
}
|
||||
|
||||
real TCodiceIVA::scorpora(real& imponibile) const
|
||||
{
|
||||
const real percent = percentuale();
|
||||
real imposta = abs(imponibile) * percent / (percent + 100.0); imposta.ceil();
|
||||
if (imponibile.sign() < 0) imposta = -imposta;
|
||||
imponibile -= imposta;
|
||||
return imposta;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Causale
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -477,29 +510,31 @@ bool TCausale::similar(const TCausale& c) const
|
||||
|
||||
return *err ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Codice IVA
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TCodiceIVA::TCodiceIVA(const char* cod) : TRectype(LF_TABCOM)
|
||||
|
||||
bool TCausale::IVA2bill(const TCodiceIVA& iva, TBill& c) const
|
||||
{
|
||||
read(cod);
|
||||
}
|
||||
|
||||
bool TCodiceIVA::read(const char* cod)
|
||||
{
|
||||
int err = ~NOERR;
|
||||
if (cod && *cod)
|
||||
const TString& tipo = iva.tipo();
|
||||
|
||||
if (tipo.not_empty())
|
||||
{
|
||||
TTable iva("%IVA");
|
||||
iva.put("CODTAB", cod);
|
||||
err = iva.read();
|
||||
TRectype::operator=(iva.curr());
|
||||
}
|
||||
if (err != NOERR)
|
||||
zero();
|
||||
return err == NOERR;
|
||||
}
|
||||
if (tipo == "ES") bill(5, c); else
|
||||
if (tipo == "NI") bill(6, c); else
|
||||
if (tipo == "NS") bill(7, c);
|
||||
}
|
||||
|
||||
if (!c.ok())
|
||||
bill(2, c);
|
||||
|
||||
const int spric = c.tipo_cr();
|
||||
if (spric == 2 || spric == 3)
|
||||
{
|
||||
const TString& td = tipo_doc();
|
||||
if (td == "FV" || td == "NC")
|
||||
c.tipo_cr(4);
|
||||
}
|
||||
|
||||
return c.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
40
cg/cg2103.h
40
cg/cg2103.h
@ -79,6 +79,22 @@ public:
|
||||
virtual ~TLibro_giornale() {}
|
||||
};
|
||||
|
||||
class TCodiceIVA : private TRectype
|
||||
{
|
||||
public: // TObject
|
||||
virtual bool ok() const { return !empty(); }
|
||||
|
||||
public:
|
||||
bool read(const char* codice);
|
||||
const TString& codice() const { return get("CODTAB"); }
|
||||
real percentuale() const { return get_real("R0"); }
|
||||
const TString& tipo() const { return get("S1"); }
|
||||
|
||||
real scorpora(real& imponibile) const; // Scorpora dall'imponibile l'imposta e la ritorna
|
||||
|
||||
TCodiceIVA(const char* codice = NULL);
|
||||
virtual ~TCodiceIVA() {}
|
||||
};
|
||||
|
||||
class TCausale : public TArray
|
||||
{
|
||||
@ -116,6 +132,10 @@ public:
|
||||
TRegistro& reg() const { return (TRegistro&)_reg; }
|
||||
TipoIVA iva() const { return _iva; }
|
||||
bool corrispettivi() const { return _corrisp; }
|
||||
|
||||
// bill deve essere il conto di ricavo
|
||||
bool IVA2bill(const TCodiceIVA& iva, TBill& bill) const;
|
||||
|
||||
int tipomov() const;
|
||||
bool saldaconto() const;
|
||||
int link_m770() const;
|
||||
@ -132,16 +152,16 @@ public:
|
||||
virtual ~TCausale() {}
|
||||
};
|
||||
|
||||
#define RIGA_IVA_DETRAIBILE 3
|
||||
#define RIGA_IVA_NON_DETRAIBILE 4
|
||||
|
||||
class TCodiceIVA : public TRectype
|
||||
{
|
||||
public:
|
||||
TCodiceIVA(const char* codice = NULL);
|
||||
bool read(const char* codice);
|
||||
bool ok() const { return !empty(); }
|
||||
const TString& codice() const { return get("CODTAB"); }
|
||||
real percentuale() const { return get_real("R0"); }
|
||||
const TString& tipo() const { return get("S1"); }
|
||||
};
|
||||
#define RIGA_RITENUTE_FISCALI 8
|
||||
#define RIGA_RITENUTE_SOCIALI 9
|
||||
|
||||
#define RIGA_ABBUONI_PASSIVI 9
|
||||
#define RIGA_ABBUONI_ATTIVI 10
|
||||
#define RIGA_SPESE 11
|
||||
#define RIGA_RITENUTE 12
|
||||
#define RIGA_DIFFCAM 13
|
||||
|
||||
#endif
|
||||
|
@ -46,7 +46,13 @@ bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k)
|
||||
bool mcomm = msk->get_bool(FS_MCOMM);
|
||||
|
||||
switch (k)
|
||||
{
|
||||
{
|
||||
case K_SPACE:
|
||||
{
|
||||
const bool can = !recalc && (pag.n_rate() > 1) && (*ts.get(11) != 'X');
|
||||
ps.sheet_mask().enable(DLG_DELREC, can);
|
||||
}
|
||||
break;
|
||||
case K_ENTER:
|
||||
ns = ps.row(r);
|
||||
ts = rws.row(r);
|
||||
@ -81,26 +87,23 @@ bool TPrimanota_application::pag_notify(TSheet_field& ps, int r, KEY k)
|
||||
|
||||
break;
|
||||
case K_DEL:
|
||||
doit = !recalc;
|
||||
doit = !recalc && (pag.n_rate() > 1) && *ts.get(11) != 'X';
|
||||
if (doit)
|
||||
{
|
||||
pag.remove_rata(r);
|
||||
const int nrate = msk->get_int(FS_NRATE) - 1;
|
||||
msk->set(FS_NRATE, nrate);
|
||||
msk->set(FS_NRATE, pag.n_rate());
|
||||
}
|
||||
break;
|
||||
case K_INS:
|
||||
// permette aggiunta e cancellazione solo se non c'e'
|
||||
// ricalcolo automatico
|
||||
// permette aggiunta e cancellazione solo se non c'e' ricalcolo automatico
|
||||
doit = !recalc;
|
||||
if (doit)
|
||||
break;
|
||||
case K_CTRL+K_INS: // Post inserimento
|
||||
{
|
||||
const int prev = r - 1;
|
||||
const int nrate = msk->get_int(FS_NRATE) + 1;
|
||||
const int gio_scad = pag.scad_rata(prev);
|
||||
TDate data_scad(pag.data_rata(prev));
|
||||
|
||||
msk->set(FS_NRATE, nrate);
|
||||
pag.add_rata(ZERO, gio_scad, pag.tipo_rata(prev), pag.ulc_rata(prev));
|
||||
pag.next_scad(data_scad, gio_scad, pag.mese_commerciale(), r);
|
||||
pag.set_datarata(r, data_scad);
|
||||
@ -604,7 +607,7 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
partite().destroy();
|
||||
const TPartita& part = partite().partita(clifo, anno, numpart);
|
||||
|
||||
int npart = part.prima_fattura(nreg);
|
||||
const int npart = part.prima_fattura(nreg);
|
||||
if (npart <= 0) // la gh'e' no!
|
||||
return FALSE;
|
||||
|
||||
@ -617,7 +620,8 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
}
|
||||
set_pagamento(codpag, datadoc.string());
|
||||
TPagamento& pag = pagamento();
|
||||
const bool in_valuta = pag.in_valuta();
|
||||
|
||||
const bool in_valuta = m.get(SK_VALUTA).not_empty();
|
||||
|
||||
const real totale = m.get(in_valuta ? SK_TOTDOCVAL : F_TOTALE);
|
||||
if (totale != partita.importo(in_valuta).valore() ||
|
||||
@ -629,6 +633,8 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
set_totale_pagamento();
|
||||
|
||||
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
||||
|
||||
const int protette = partita.ultima_rata_con_abbuoni_diffcam();
|
||||
|
||||
pag.zap_rate(); // Azzera pagamento
|
||||
for (int i = 1; i <= partita.rate(); i++) // E' necessario andare in avanti!!!
|
||||
@ -637,7 +643,7 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
real importo = scadenza.get(SCAD_IMPORTO);
|
||||
const TDate scad = scadenza.get(SCAD_DATASCAD);
|
||||
const int tipop = scadenza.get_int(SCAD_TIPOPAG);
|
||||
const bool paid = scadenza.get_bool(SCAD_PAGATA);
|
||||
const bool paid = i <= protette; // Non cancellabile
|
||||
const TString16 ulc = scadenza.get(SCAD_ULTCLASS);
|
||||
if (in_valuta)
|
||||
{
|
||||
@ -674,6 +680,23 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TPrimanota_application::cerca_conto_cf(TBill& bill) const
|
||||
{
|
||||
const char tipocf = clifo();
|
||||
const long codcf = curr_mask().get_long(tipocf == 'C' ? F_CLIENTE : F_FORNITORE);
|
||||
|
||||
TString_array& a = cgs().rows_array();
|
||||
for (int r = 0; r < a.items(); r++)
|
||||
{
|
||||
bill.get(a.row(r), 2, 0x1);
|
||||
if (bill.tipo() == tipocf && bill.codclifo() == codcf)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bill.set(0, 0, codcf, tipocf);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void TPrimanota_application::write_scadenze(const TMask& m)
|
||||
{
|
||||
const long nreg = m.get_long(F_NUMREG);
|
||||
@ -693,7 +716,8 @@ void TPrimanota_application::write_scadenze(const TMask& m)
|
||||
const TString agente (m.get(FS_AGENTE));
|
||||
const char sezione = get_cgs_imp(0).sezione(); // Dare/Avere
|
||||
|
||||
const TBill clifo(cgs().row(0), 2, 0x3);
|
||||
TBill clifo; cerca_conto_cf(clifo);
|
||||
CHECK(clifo.ok(), "Impossibile generare la fattura senza gruppo/conto cliente");
|
||||
newgame = new TPartita(clifo, anno, numpart);
|
||||
|
||||
const int row = newgame->prima_fattura(nreg); // Riga fattura di questo movimento
|
||||
|
107
cg/cg2105.cpp
107
cg/cg2105.cpp
@ -349,7 +349,6 @@ protected:
|
||||
#endif
|
||||
|
||||
const TRiga_partite* cerca_prima_riga() const;
|
||||
bool cerca_valuta(TValuta& val) const;
|
||||
void aggiorna_valuta(const TValuta& val);
|
||||
void aggiorna_sorelle(const TRiga_partite& part) const;
|
||||
|
||||
@ -389,19 +388,25 @@ TGame_mask::TGame_mask(const TBill& bill, long numreg, int riga)
|
||||
|
||||
TValuta val;
|
||||
#ifndef __EXTRA__
|
||||
TMask& cm = app().curr_mask();
|
||||
val.get(cm, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO);
|
||||
cerca_valuta(val);
|
||||
val.set(*this, P_VALUTA, P_DATACAMBIO, P_CAMBIO);
|
||||
const TRiga_partite* row = cerca_prima_riga();
|
||||
if (row != NULL)
|
||||
{
|
||||
val.get(*row); // Legge valuta standard dalla partita
|
||||
|
||||
const TCausale& causale = app().causale();
|
||||
const tipo_movimento tm = (tipo_movimento)causale.tipomov();
|
||||
if (tm == tm_nota_credito)
|
||||
{
|
||||
set(P_ANNO, cm.get(F_ANNORIF));
|
||||
set(P_NUMERO, cm.get(F_NUMRIF));
|
||||
set(P_ANNO, row->get(PART_ANNO)); // Propone anno e partita
|
||||
set(P_NUMERO, row->get(PART_NUMPART));
|
||||
}
|
||||
else
|
||||
{
|
||||
TMask& cm = app().curr_mask(); // Legge valuta dal movimento
|
||||
val.get(cm, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO);
|
||||
|
||||
set(P_ANNO, cm.get(F_ANNORIF)); // Propone anno e partita
|
||||
set(P_NUMERO, cm.get(F_NUMRIF));
|
||||
}
|
||||
val.set(*this, P_VALUTA, P_DATACAMBIO, P_CAMBIO);
|
||||
#endif
|
||||
|
||||
enable(-3, val.in_valuta());
|
||||
|
||||
set_handler(P_ANNO, annopart_handler);
|
||||
@ -410,10 +415,13 @@ TGame_mask::TGame_mask(const TBill& bill, long numreg, int riga)
|
||||
set_handler(P_NUOVO, nuovo_handler);
|
||||
set_handler(P_CAMBIO, cambio_handler);
|
||||
|
||||
partite().set_notify(partite_notify);
|
||||
TSheet_field& games = partite();
|
||||
games.set_notify(partite_notify);
|
||||
|
||||
scadenze().set_notify(scadenze_notify);
|
||||
scadenze().sheet_mask().set_handler(100, edit_scadenza_handler);
|
||||
|
||||
fill_partite(); // Riempie sheet partite
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -436,7 +444,6 @@ bool TGame_mask::numpart_handler(TMask_field& f, KEY k)
|
||||
if (k == K_TAB && f.focusdirty())
|
||||
{
|
||||
const TGame_mask& m = (const TGame_mask&)f.mask();
|
||||
|
||||
const int anno = m.get_int(P_ANNO); // Anno partita da cercare
|
||||
if (anno > 0)
|
||||
{
|
||||
@ -451,7 +458,7 @@ bool TGame_mask::numpart_handler(TMask_field& f, KEY k)
|
||||
if (anno == row.get_int(0)) // Se corrisponde l'anno e ...
|
||||
{
|
||||
const long dist = m.number_distance(key, row.get());
|
||||
if (dist < min_dist)
|
||||
if (i == 0 || dist < min_dist)
|
||||
{
|
||||
min_dist = dist;
|
||||
best_match = i;
|
||||
@ -460,8 +467,7 @@ bool TGame_mask::numpart_handler(TMask_field& f, KEY k)
|
||||
}
|
||||
}
|
||||
}
|
||||
sheet.select(best_match); // ... seleziona la partita
|
||||
partite_notify(sheet, best_match, K_TAB); // ed esplodi le sue righe
|
||||
sheet.select(best_match); // seleziona la partita
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
@ -469,7 +475,7 @@ bool TGame_mask::numpart_handler(TMask_field& f, KEY k)
|
||||
|
||||
bool TGame_mask::show_all_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (k == K_SPACE)
|
||||
if (k == K_SPACE && f.focusdirty())
|
||||
{
|
||||
TGame_mask& gm = (TGame_mask&)f.mask();
|
||||
gm.fill_partite();
|
||||
@ -502,38 +508,31 @@ real TGame_mask::aggiorna_residuo()
|
||||
_importo = app().get_cgs_imp(_numrig-1); // Importo sulla riga contabile
|
||||
_residuo = _importo;
|
||||
_residuo -= app().partite().importo_speso(_numreg, _numrig); // Residuo della riga
|
||||
set(P_RESIDUO, _residuo.valore().string());
|
||||
return _residuo.valore();
|
||||
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())
|
||||
{
|
||||
const real resval = cambio.lit2val(res);
|
||||
set(P_RESIDUOVAL, resval);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Scandisce tutte le partite per cercare la prima del movimento corrente
|
||||
const TRiga_partite* TGame_mask::cerca_prima_riga() const
|
||||
{
|
||||
const TRiga_partite* riga = NULL;
|
||||
TPartite_array& pa = app().partite();
|
||||
for (const TPartita* game = pa.first(); game != NULL; game = pa.next())
|
||||
{
|
||||
const int r = game->mov2rig(_numreg, _numrig);
|
||||
if (r > 0)
|
||||
{
|
||||
riga = &game->riga(r);
|
||||
break;
|
||||
}
|
||||
}
|
||||
const TRiga_partite* riga = app().partite().mov2rig(_numreg, _numrig);
|
||||
return riga;
|
||||
}
|
||||
|
||||
|
||||
// Cerca la valuta della prima riga di partita relativa al movimento corrente
|
||||
bool TGame_mask::cerca_valuta(TValuta& val) const
|
||||
{
|
||||
const TRiga_partite* row = cerca_prima_riga();
|
||||
if (row != NULL)
|
||||
val.get(*row);
|
||||
return row != NULL;
|
||||
}
|
||||
|
||||
void TGame_mask::aggiorna_valuta(const TValuta& val)
|
||||
{
|
||||
TPartite_array& pa = app().partite();
|
||||
@ -594,8 +593,9 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
{
|
||||
gm._riga_partite = r;
|
||||
|
||||
TString_array& scadenze = gm.scadenze().rows_array();
|
||||
scadenze.destroy();
|
||||
TSheet_field& sheet = gm.scadenze();
|
||||
sheet.destroy(); // Azzera righe
|
||||
TString_array& scadenze = sheet.rows_array(); // Array delle righe
|
||||
|
||||
TToken_string& row = partite.row(r);
|
||||
const int anno = row.get_int(0); // Anno partita
|
||||
@ -799,10 +799,11 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
|
||||
if (in_valuta != gm._valfirst)
|
||||
{
|
||||
gm.scadenze().swap_columns(106, 107); // Scambia le colonne dell'importo in lire e in valuta
|
||||
sheet.swap_columns(106, 107); // Scambia le colonne dell'importo in lire e in valuta
|
||||
gm._valfirst = in_valuta;
|
||||
}
|
||||
gm.scadenze().force_update();
|
||||
|
||||
sheet.force_update();
|
||||
}
|
||||
if (k == K_INS)
|
||||
{
|
||||
@ -1129,11 +1130,11 @@ bool TGame_mask::nuovo_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
gm.set(P_ANNO, anno);
|
||||
gm.set(P_NUMERO, numero);
|
||||
gm.fill_partite(); // Aggiorna sheet partite
|
||||
gm._changed = TRUE;
|
||||
}
|
||||
else
|
||||
app().partite().destroy(gm.conto(), anno, numero);
|
||||
gm.fill_partite(); // Aggiorna sheet partite
|
||||
}
|
||||
}
|
||||
|
||||
@ -1192,7 +1193,7 @@ TImporto TGame_mask::get_importo(TToken_string& s, int pos) const
|
||||
|
||||
|
||||
int TGame_mask::update_partita(const TPartita& game, int prow)
|
||||
{
|
||||
{
|
||||
TImporto saldo, doc, pag, imp;
|
||||
game.calcola_saldo(saldo, doc, pag, imp);
|
||||
|
||||
@ -1206,7 +1207,7 @@ int TGame_mask::update_partita(const TPartita& game, int prow)
|
||||
{
|
||||
const TRiga_partite& riga = game.riga(riga_fatt);
|
||||
r.cut(0);
|
||||
r.add(riga.get(PART_ANNO));
|
||||
r.add(riga.get(PART_ANNO)); r.right_just(4); // Mette gli spazi se ce n'e' bisogno
|
||||
r.add(riga.get(PART_NUMPART));
|
||||
r.add(riga.get(PART_DATADOC));
|
||||
r.add(riga.get(PART_NUMDOC));
|
||||
@ -1358,8 +1359,8 @@ void TGame_mask::fill_partite()
|
||||
aggiorna_residuo();
|
||||
|
||||
if (a.items() > 1)
|
||||
{
|
||||
partite_notify(partite(), r, K_TAB);
|
||||
{
|
||||
partite().select(r, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1374,17 +1375,15 @@ bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) co
|
||||
TRectype oldpag = p.pagamento(nriga, nrata, nrigp);
|
||||
TRiga_partite& somma = p.riga(nrigp);
|
||||
|
||||
TPay_mask* pm = new TPay_mask; // We must create masks on the heap
|
||||
TPay_mask* pm = new TPay_mask; // We must create masks on the heap
|
||||
TPay_mask& m = *pm;
|
||||
|
||||
if (nriga == TPartita::UNASSIGNED)
|
||||
{
|
||||
nriga = p.primo_pagamento();
|
||||
TRiga_partite& riga = p.riga(nriga);
|
||||
TRiga_scadenze& scaden = riga.new_row(); // Crea una rata falsa
|
||||
{
|
||||
TRiga_scadenze& scaden = somma.new_row(); // Crea una rata falsa
|
||||
scaden.put(SCAD_DATASCAD, somma.get(PART_DATADOC));
|
||||
m.set_pag(oldpag, scaden, _residuo);
|
||||
riga.destroy_rows(); // Distrugge la rata falsa
|
||||
somma.destroy_rows(); // Distrugge la rata falsa
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -222,7 +222,7 @@ BEGIN
|
||||
ITEM "Ns.CAB"
|
||||
ITEM "Vs.ABI"
|
||||
ITEM "Vs.CAB"
|
||||
ITEM "Pagata"
|
||||
ITEM "Protetta"
|
||||
END
|
||||
|
||||
BUTTON FS_RESET 7 1
|
||||
|
43
cg/conto.cpp
43
cg/conto.cpp
@ -8,8 +8,7 @@
|
||||
#include "conto.h"
|
||||
|
||||
// Certified 90%
|
||||
TBill::TBill(TToken_string& s, int from, int mode)
|
||||
: _tipo_cr(-1), _sezione(' ')
|
||||
const TBill& TBill::get(TToken_string& s, int from, int mode)
|
||||
{
|
||||
const char* first = s.get(from);
|
||||
if (mode & 0x1)
|
||||
@ -31,6 +30,11 @@ TBill::TBill(TToken_string& s, int from, int mode)
|
||||
_sottoconto = s.get_long();
|
||||
if (mode & 0x2)
|
||||
_descrizione = s.get();
|
||||
|
||||
_tipo_cr = -1;
|
||||
_sezione = ' ';
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@ -88,21 +92,25 @@ const char* TBill::field_name(int n, bool contro) const
|
||||
|
||||
const char* f;
|
||||
if (contro)
|
||||
{
|
||||
switch(n)
|
||||
{
|
||||
case 0: f = "GRUPPOC"; break;
|
||||
case 1: f = "CONTOC"; break;
|
||||
case 2: f = "SOTTOCONTC"; break;
|
||||
default:f = "TIPOCC"; break;
|
||||
}
|
||||
case 1: f = "CONTOC"; break;
|
||||
case 2: f = "SOTTOCONTC"; break;
|
||||
default:f = "TIPOCC"; break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(n)
|
||||
{
|
||||
case 0: f = "GRUPPO"; break;
|
||||
case 1: f = "CONTO"; break;
|
||||
case 2: f = "SOTTOCONTO"; break;
|
||||
default:f = "TIPOC"; break;
|
||||
}
|
||||
case 1: f = "CONTO"; break;
|
||||
case 2: f = "SOTTOCONTO"; break;
|
||||
default:f = "TIPOC"; break;
|
||||
}
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
@ -121,6 +129,10 @@ bool TBill::get(const TRectype& r, bool c)
|
||||
r.get_long(field_name(2, c)),
|
||||
r.get_char(field_name(3, c)));
|
||||
|
||||
_descrizione.cut(0);
|
||||
_tipo_cr = -1;
|
||||
_sezione = ' ';
|
||||
|
||||
if (r.num() == LF_RMOVIVA)
|
||||
tipo_cr(r.get_int("TIPOCR"));
|
||||
|
||||
@ -285,16 +297,19 @@ const TString& TBill::descrizione() const
|
||||
return _descrizione;
|
||||
}
|
||||
|
||||
int TBill::tipo_cr()
|
||||
int TBill::tipo_cr() const
|
||||
{
|
||||
if (_tipo_cr < 0)
|
||||
find();
|
||||
if (_tipo_cr < 0)
|
||||
{
|
||||
TBill& myself = (TBill&)*this;
|
||||
myself.find();
|
||||
}
|
||||
return _tipo_cr;
|
||||
}
|
||||
|
||||
|
||||
// Certified 99% (uses __tmp_string)
|
||||
const char* TBill::string(int mode)
|
||||
const char* TBill::string(int mode) const
|
||||
{
|
||||
TFixed_string s(&__tmp_string[256], 80);
|
||||
s.cut(0);
|
||||
|
13
cg/conto.h
13
cg/conto.h
@ -31,22 +31,27 @@ protected:
|
||||
const TBill& copy(const TBill& b);
|
||||
const char* field_name(int n, bool contro) const;
|
||||
|
||||
public: // TObject
|
||||
virtual bool ok() const; // Gruppo, Conto e Sottoconto non nulli
|
||||
|
||||
public:
|
||||
TBill(int g = 0, int c = 0, long s = 0L, char t = ' ', const char* d = NULL, int r = -1)
|
||||
: _tipo(t), _gruppo(g), _conto(c), _sottoconto(s), _descrizione(d),
|
||||
_sezione(' '), _sospeso(FALSE)
|
||||
{ set(g,c,s,t,d,r);}
|
||||
|
||||
TBill(TToken_string& tgcsd, int from, int mode = 0);
|
||||
TBill(TToken_string& tgcsd, int from, int mode = 0) { get(tgcsd, from, mode); }
|
||||
TBill(const TRectype& rec, bool contro = FALSE) { get(rec, contro); }
|
||||
TBill(const TBill& b) { copy(b); }
|
||||
virtual ~TBill() {}
|
||||
|
||||
const TBill& set(int g = 0, int c = 0, long s = 0L, char t = ' ',
|
||||
const char* d = NULL, int r = -1);
|
||||
|
||||
const TBill& get(TToken_string& ts, int from, int mode = 0);
|
||||
const TBill& add_to(TToken_string& ts, int from, int mode = 0);
|
||||
const TBill& operator=(const TBill& b) { return copy(b); }
|
||||
|
||||
virtual bool ok() const; // Gruppo, Conto e Sottoconto non nulli
|
||||
bool empty() const { return _gruppo==0 && _conto==0 && _sottoconto == 0; }
|
||||
|
||||
char tipo() const { return _tipo; }
|
||||
@ -57,7 +62,7 @@ public:
|
||||
|
||||
bool find();
|
||||
const TString& descrizione() const;
|
||||
int tipo_cr();
|
||||
int tipo_cr() const;
|
||||
void tipo_cr(int tcr) { _tipo_cr = tcr; }
|
||||
|
||||
int tipo_att();
|
||||
@ -71,7 +76,7 @@ public:
|
||||
void set(TMask& m, short g, short c, short s, short t = 0, short d = 0) const;
|
||||
void get(const TMask& m, short g, short c, short s, short t = 0, short d = 0);
|
||||
|
||||
const char* string(int mode = 0);
|
||||
const char* string(int mode = 0) const;
|
||||
};
|
||||
|
||||
|
||||
|
@ -134,8 +134,7 @@ void TPagamento::set_tipo_prima_rata(int v, int sscad)
|
||||
tt.add(tipo_rata(i-1),2);
|
||||
tt.add(ulc_rata(i-1),5);
|
||||
}
|
||||
_rate.destroy(0);
|
||||
_rate.pack();
|
||||
_rate.destroy(0, TRUE);
|
||||
}
|
||||
else
|
||||
if ( _tpr < 4 && v > 3)
|
||||
@ -471,10 +470,8 @@ void TPagamento::set_default_ulc(const char* ulc, bool change_existing)
|
||||
|
||||
void TPagamento::remove_rata(int i)
|
||||
{
|
||||
// non fa nessun ricalcolo, si limita ad impacchettare se
|
||||
// necessario
|
||||
_rate.destroy(i);
|
||||
_rate.pack();
|
||||
// non fa nessun ricalcolo, si limita ad impacchettare se necessario
|
||||
_rate.destroy(i, TRUE);
|
||||
_dirty = TRUE;
|
||||
}
|
||||
|
||||
|
@ -535,6 +535,26 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag, const TValuta&
|
||||
return empty;
|
||||
}
|
||||
|
||||
bool TRiga_scadenze::esistono_abbuoni_diffcam() const
|
||||
{
|
||||
bool ad = FALSE;
|
||||
for (int p = last(); p > 0; p = pred(p))
|
||||
{
|
||||
const TRectype& pag = row(p);
|
||||
if (pag.get_char(PAGSCA_ACCSAL) == 'S')
|
||||
{
|
||||
if (!pag.get_real(PAGSCA_ABBUONI).is_zero() ||
|
||||
!pag.get_real(PAGSCA_DIFFCAM).is_zero())
|
||||
{
|
||||
ad = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ad;
|
||||
}
|
||||
|
||||
|
||||
bool TRiga_scadenze::elimina_pagamento(int p)
|
||||
{
|
||||
TRectype old_pag(row(p));
|
||||
@ -698,27 +718,15 @@ bool TRiga_partite::update(const TImporto& vec, const TImporto& nuo,
|
||||
|
||||
// Cerca una rata con abbuoni o differenze cambio
|
||||
// Certified 99%
|
||||
int TRiga_partite::rata_con_abbuoni_diffcam() const
|
||||
int TRiga_partite::ultima_rata_con_abbuoni_diffcam() const
|
||||
{
|
||||
int found = 0;
|
||||
for (int s = rate(); s > 0 && found == 0; s--)
|
||||
for (int s = rate(); s > 0; s--)
|
||||
{
|
||||
const TRiga_scadenze& scad = rata(s);
|
||||
for (int p = scad.last(); p > 0; p = scad.pred(p))
|
||||
{
|
||||
const TRectype& pag = scad.row(p);
|
||||
if (pag.get_char(PAGSCA_ACCSAL) == 'S')
|
||||
{
|
||||
if (!pag.get_real(PAGSCA_ABBUONI).is_zero() ||
|
||||
!pag.get_real(PAGSCA_DIFFCAM).is_zero())
|
||||
{
|
||||
found = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (scad.esistono_abbuoni_diffcam())
|
||||
break;
|
||||
}
|
||||
return found;
|
||||
return s;
|
||||
}
|
||||
|
||||
// Determina se una riga e' in valuta in base al codice valuta
|
||||
@ -865,7 +873,7 @@ char TPartita::allineamento_corrente() const
|
||||
const TString& n = numero();
|
||||
|
||||
char all = n[0] == ' ' ? 'R' : 'L';
|
||||
if (all == 'L' && n.len() == NUMLEN && n[6] != ' ')
|
||||
if (all == 'L' && n.len() == NUMLEN && n[NUMLEN-1] != ' ')
|
||||
all = ' ';
|
||||
return all;
|
||||
}
|
||||
@ -1041,7 +1049,6 @@ TRiga_partite& TPartita::new_row(int r)
|
||||
|
||||
TRiga_scadenze& TPartita::rata(int nriga, int nrata) const
|
||||
{
|
||||
// if (nriga <= 0) nriga = prima_fattura();
|
||||
const TRiga_partite& r = riga(nriga);
|
||||
return r.rata(nrata);
|
||||
}
|
||||
@ -1061,8 +1068,8 @@ bool TPartita::esistono_abbuoni_diffcam(long nreg) const
|
||||
{
|
||||
int nrata = 0;
|
||||
const int nriga = prima_fattura(nreg);
|
||||
if (_part.exist(nriga))
|
||||
nrata = riga(nriga).rata_con_abbuoni_diffcam();
|
||||
if (nriga > 0)
|
||||
nrata = riga(nriga).ultima_rata_con_abbuoni_diffcam();
|
||||
return nrata > 0;
|
||||
}
|
||||
|
||||
@ -1151,24 +1158,23 @@ int TPartita::mov2rig(long numreg, int rm) const
|
||||
for (int r = last(); r > 0; r = pred(r))
|
||||
{
|
||||
const TRiga_partite& row = riga(r);
|
||||
if (row.get_long(PART_NREG) == numreg)
|
||||
if (numreg == row.get_long(PART_NREG))
|
||||
{
|
||||
if (rm <= 0 || row.get_int(PART_NUMRIG) == rm)
|
||||
if (rm <= 0 || rm == row.get_int(PART_NUMRIG))
|
||||
return r;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Trova la prima riga della partita contenente una fattura
|
||||
int TPartita::prima_fattura(long nreg) const
|
||||
// Trova la prima riga della partita corrispondente alla registrazione nreg
|
||||
int TPartita::prima_riga(long nreg, tipo_movimento tipo) const
|
||||
{
|
||||
const int lastrow = last();
|
||||
for (int r = first(); r <= lastrow; r = succ(r))
|
||||
{
|
||||
const TRiga_partite& row = riga(r);
|
||||
const int tipomov = row.get_int(PART_TIPOMOV);
|
||||
if (tipomov == 1 || tipomov == 2)
|
||||
if (tipo == tm_nessuno || tipo == row.tipo())
|
||||
if (nreg <= 0 || nreg == row.get_long(PART_NREG))
|
||||
return r;
|
||||
}
|
||||
@ -1176,18 +1182,15 @@ int TPartita::prima_fattura(long nreg) const
|
||||
}
|
||||
|
||||
// Trova la prima riga della partita contenente una fattura
|
||||
int TPartita::prima_fattura(long nreg) const
|
||||
{
|
||||
return prima_riga(nreg, tm_fattura);
|
||||
}
|
||||
|
||||
// Trova la prima riga della partita contenente una pagamento
|
||||
int TPartita::primo_pagamento(long nreg) const
|
||||
{
|
||||
const int lastrow = last();
|
||||
for (int r = first(); r <= lastrow; r = succ(r))
|
||||
{
|
||||
const TRiga_partite& row = riga(r);
|
||||
const int tipomov = row.get_int(PART_TIPOMOV);
|
||||
if (tipomov != 1)
|
||||
if (nreg <= 0 || nreg == row.get_long(PART_NREG))
|
||||
return r;
|
||||
}
|
||||
return -1;
|
||||
return prima_riga(nreg, tm_pagamento);
|
||||
}
|
||||
|
||||
void TPartita::calcola_saldo(TImporto& saldo, TImporto& doc, TImporto& pag, TImporto& imp) const
|
||||
@ -1689,3 +1692,13 @@ void TPartite_array::update_reg(const TRectype& mov, const TRecord_array& cg, lo
|
||||
game->update_reg(old_nreg, mov, cg);
|
||||
}
|
||||
|
||||
TRiga_partite* TPartite_array::mov2rig(long numreg, int numrig)
|
||||
{
|
||||
for (TPartita* game = first(); game; game = next())
|
||||
{
|
||||
const int r = game->mov2rig(numreg, numrig);
|
||||
if (r > 0)
|
||||
return &game->riga(r);
|
||||
}
|
||||
return NULL;
|
||||
}
|
@ -157,6 +157,8 @@ public:
|
||||
TImporto importo_pagato(bool val, int mode = 0xF) const;
|
||||
TImporto importo(bool val) const;
|
||||
TImporto residuo(bool val, int mode = 0xF) const; // Differenza delle due funzioni precedenti
|
||||
|
||||
bool esistono_abbuoni_diffcam() const;
|
||||
|
||||
TRiga_scadenze(TRiga_partite* riga);
|
||||
TRiga_scadenze(const TRiga_scadenze& s);
|
||||
@ -193,7 +195,7 @@ public:
|
||||
bool is_nota_credito() const { return tipo() == tm_nota_credito; }
|
||||
int ultima_ratapagata() const;
|
||||
int ultimo_pagamento(int rata) const;
|
||||
int rata_con_abbuoni_diffcam() const;
|
||||
int ultima_rata_con_abbuoni_diffcam() const;
|
||||
|
||||
char sezione() const { return get_char(PART_SEZ); }
|
||||
TImporto importo(bool valuta, int mode = 0xF) const;
|
||||
@ -263,6 +265,8 @@ public:
|
||||
|
||||
int mov2rig(long nreg, int rmov) const;
|
||||
int rig2mov(int rmov) const;
|
||||
|
||||
int prima_riga(long nreg = -1, tipo_movimento tipo = tm_nessuno) const;
|
||||
int prima_fattura(long nreg = -1) const;
|
||||
int primo_pagamento(long nreg = -1) const;
|
||||
|
||||
@ -331,6 +335,8 @@ public:
|
||||
|
||||
// Controlla se esistono righe di pagamento relative alla riga numrig
|
||||
bool utilizzata(long numreg, int numrig);
|
||||
// Cerca la riga della partita relativa alla registrazione numreg
|
||||
TRiga_partite* mov2rig(long numreg, int numrig);
|
||||
|
||||
TPartita* first() { restart(); return next(); }
|
||||
TPartita* next() { return (TPartita*)get(); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user