Gestione saldaconto

git-svn-id: svn://10.65.10.50/trunk@2365 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-12-29 11:55:59 +00:00
parent f4ea67e046
commit cb27a9beae
12 changed files with 218 additions and 151 deletions

View File

@ -107,6 +107,7 @@ TMask* TPrimanota_application::load_mask(int n)
ism.set_handler(103, detrazione_handler); ism.set_handler(103, detrazione_handler);
ism.set_handler(104, imposta_handler); ism.set_handler(104, imposta_handler);
ism.set_handler(109, iva_sottoconto_handler); ism.set_handler(109, iva_sottoconto_handler);
ism.set_handler(110, iva_sottoconto_handler);
ism.set_handler(209, sheet_clifo_handler); ism.set_handler(209, sheet_clifo_handler);
ism.set_handler(309, sheet_clifo_handler); ism.set_handler(309, sheet_clifo_handler);

View File

@ -229,7 +229,6 @@ END
NUMBER F_CLIENTE 6 NUMBER F_CLIENTE 6
BEGIN BEGIN
PROMPT 1 10 "Cliente " PROMPT 1 10 "Cliente "
FLAGS "R"
FIELD CODCF FIELD CODCF
GROUP 1 GROUP 1
USE LF_CLIFO KEY 1 USE LF_CLIFO KEY 1
@ -254,7 +253,6 @@ END
NUMBER F_FORNITORE 6 NUMBER F_FORNITORE 6
BEGIN BEGIN
PROMPT 1 10 "Fornitore " PROMPT 1 10 "Fornitore "
FLAGS "R"
FIELD CODCF FIELD CODCF
GROUP 2 GROUP 2
USE LF_CLIFO KEY 1 USE LF_CLIFO KEY 1

View File

@ -27,7 +27,6 @@ END
STRING P_VALUTA 3 STRING P_VALUTA 3
BEGIN BEGIN
PROMPT 1 2 "Valuta " PROMPT 1 2 "Valuta "
HELP "Codice della valuta per movimento"
FLAGS "DUZ" FLAGS "DUZ"
END END
@ -43,13 +42,13 @@ BEGIN
DISPLAY "Cambio@18" R10 DISPLAY "Cambio@18" R10
OUTPUT P_DATACAMBIO D0 OUTPUT P_DATACAMBIO D0
OUTPUT P_CAMBIO R10 OUTPUT P_CAMBIO R10
CHECKTYPE SEARCH
GROUP 3 GROUP 3
END END
NUMBER P_CAMBIO 15 5 NUMBER P_CAMBIO 15 5
BEGIN BEGIN
PROMPT 48 2 "Cambio " PROMPT 48 2 "Cambio "
HELP "Cambio della valuta"
FLAGS "DRU" FLAGS "DRU"
GROUP 3 GROUP 3
PICTURE ".5" PICTURE ".5"
@ -95,9 +94,9 @@ BEGIN
PROMPT 0 11 "" PROMPT 0 11 ""
ITEM "Riga" ITEM "Riga"
ITEM "Rata" ITEM "Rata"
ITEM "Data scad."
ITEM "Data doc.@10" ITEM "Data doc.@10"
ITEM "Descrizione@20" ITEM "Data scad."
ITEM "Descrizione@16"
ITEM "Importo Lire@14" ITEM "Importo Lire@14"
ITEM "Importo Valuta@14" ITEM "Importo Valuta@14"
ITEM "Num. reg." ITEM "Num. reg."
@ -105,7 +104,7 @@ BEGIN
ITEM "Num. doc." ITEM "Num. doc."
ITEM "Prot. IVA" ITEM "Prot. IVA"
ITEM "Pagamento" ITEM "Pagamento"
// FLAGS "D" FLAGS "D"
END END
BOOLEAN P_SHOWALL BOOLEAN P_SHOWALL
@ -198,7 +197,7 @@ BEGIN
PROMPT 1 2 "Riga pagamento " PROMPT 1 2 "Riga pagamento "
END END
DATE 104 DATE 103
BEGIN BEGIN
PROMPT 41 2 "Data documento " PROMPT 41 2 "Data documento "
END END
@ -213,7 +212,7 @@ BEGIN
PROMPT 41 3 "Data reg. " PROMPT 41 3 "Data reg. "
END END
NUMBER 110 5 STRING 110 5
BEGIN BEGIN
PROMPT 1 4 "Numero doc. " PROMPT 1 4 "Numero doc. "
END END
@ -223,7 +222,7 @@ BEGIN
PROMPT 41 5 "Protocollo IVA " PROMPT 41 5 "Protocollo IVA "
END END
DATE 103 DATE 104
BEGIN BEGIN
PROMPT 41 4 "Data scad. " PROMPT 41 4 "Data scad. "
END END

View File

@ -67,10 +67,10 @@ BEGIN
FLAGS "DR" FLAGS "DR"
END END
NUMBER S_IMPORTOVAL_SCAD 15 2 NUMBER S_IMPORTOVAL_SCAD 15 3
BEGIN BEGIN
PROMPT 43 4 "Importo in valuta " PROMPT 43 4 "Importo in valuta "
PICTURE ".2" PICTURE ".3"
FLAGS "DRV" FLAGS "DRV"
GROUP 3 GROUP 3
END END
@ -103,10 +103,10 @@ BEGIN
WARNING "L'importo deve essere specificato" WARNING "L'importo deve essere specificato"
END END
NUMBER S_IMPORTOVAL 15 2 NUMBER S_IMPORTOVAL 15 3
BEGIN BEGIN
PROMPT 2 9 "Importo in valuta " PROMPT 2 9 "Importo in valuta "
PICTURE ".2" PICTURE ".3"
FIELD IMPORTOVAL FIELD IMPORTOVAL
GROUP 3 GROUP 3
VALIDATE REQIF_FUNC 1 S_IMPORTO VALIDATE REQIF_FUNC 1 S_IMPORTO
@ -235,11 +235,10 @@ BEGIN
DISPLAY "Valuta" CODTAB[1,3] DISPLAY "Valuta" CODTAB[1,3]
DISPLAY "Data@10" D0 DISPLAY "Data@10" D0
DISPLAY "Cambio@18" R10 DISPLAY "Cambio@18" R10
OUTPUT S_VALUTA CODTAB[1,3]
OUTPUT S_DATACAMBIO D0 OUTPUT S_DATACAMBIO D0
OUTPUT S_CAMBIO R10 OUTPUT S_CAMBIO R10
GROUP 4 GROUP 4
CHECKTYPE NORMAL CHECKTYPE SEARCH
END END
NUMBER S_CAMBIO 15 5 NUMBER S_CAMBIO 15 5

View File

@ -567,14 +567,18 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
const char s(app().causale().sezione(2)); const char s(app().causale().sezione(2));
const real t(f.mask().get(F_TOTALE)); const real t(f.mask().get(F_TOTALE));
const TImporto totdoc(s, t); const TImporto totdoc(s, t);
if (totdoc != saldaconto) TImporto residuo(totdoc); residuo += saldaconto; residuo.normalize();
if (!residuo.is_zero())
{ {
const TString st(totdoc.valore().string(".")); const TString st(totdoc.valore().string("."));
const TString ss(saldaconto.valore().string(".")); const TString ss(saldaconto.valore().string("."));
return f.error_box("Il totale documento inserito e' %s %c mentre\n" const TString sr(residuo.valore().string("."));
"i pagamenti e le spese ammontano a %s %c", return f.error_box("Il totale documento inserito e' %s %c,\n"
"i pagamenti e le spese ammontano a %s %c,\n"
"per cui il residuo e' %s.",
(const char*)st, totdoc.sezione(), (const char*)st, totdoc.sezione(),
(const char*)ss, saldaconto.sezione()); (const char*)ss, saldaconto.sezione(),
(const char*)sr);
} }
} }
@ -877,8 +881,9 @@ TBill& TPrimanota_application::ivas_bill(TBill& c)
const int spric = c.tipo_cr(); const int spric = c.tipo_cr();
if (spric == 2 || spric == 3) if (spric == 2 || spric == 3)
{ {
const TFixed_string td(causale().tipo_doc()); const TString& td = causale().tipo_doc();
if (td == "FV" || td == "NC") c.tipo_cr(4); if (td == "FV" || td == "NC")
c.tipo_cr(4);
} }
return c; return c;
} }
@ -1274,6 +1279,7 @@ bool TPrimanota_application::cg_conto_handler(TMask_field& f, KEY key)
} }
// Gestore del sottoconto dello sheet IVA // Gestore del sottoconto dello sheet IVA
// Attenzione questo handler e' agganciato anche alla descrizione del sottoconto
bool TPrimanota_application::iva_sottoconto_handler(TMask_field& f, KEY key) bool TPrimanota_application::iva_sottoconto_handler(TMask_field& f, KEY key)
{ {
if (!suspended_handler(f, key)) if (!suspended_handler(f, key))
@ -1281,14 +1287,19 @@ bool TPrimanota_application::iva_sottoconto_handler(TMask_field& f, KEY key)
if (key == K_TAB && f.dirty()) if (key == K_TAB && f.dirty())
{ {
const TLocalisamfile& piano = ((TEdit_field&)f).browse()->cursor()->file(); TMask& m = f.mask();
const TEdit_field& sotto = m.efield(109);
const TRectype& piano = sotto.browse()->cursor()->curr();
const TCausale& caus = app().causale();
int spric = piano.get_int("TIPOSPRIC"); int spric = piano.get_int("TIPOSPRIC");
if ((spric == 2 || spric == 3) && !app().causale().corrispettivi()) if ((spric == 2 || spric == 3) && !caus.corrispettivi())
{ {
const TFixed_string td(app().causale().tipo_doc()); const TString& td = caus.tipo_doc();
if (td == "FV" || td == "NC") spric = 4; if (td == "FV" || td == "NC") spric = 4;
} }
f.mask().set(105, spric > 0 ? format("%d", spric) : "", TRUE);
TString16 s; if (spric > 0) s << spric;
m.set(105, s, TRUE); // Setta il campo spesa-ricavo della riga IVA
} }
return TRUE; return TRUE;
} }
@ -1604,14 +1615,12 @@ bool TPrimanota_application::doc_handler(TMask_field& f, KEY key)
{ {
if (f.dlg() == F_DATADOC) if (f.dlg() == F_DATADOC)
{ {
if (app().is_fattura()) const TDate dd(val); // Fattura o nota credito
{
const TDate dd(val);
if (m.get(F_ANNORIF).empty()) if (m.get(F_ANNORIF).empty())
m.set(F_ANNORIF, dd.year()); // copia anno documento m.set(F_ANNORIF, dd.year()); // copia anno documento
if (app().is_fattura())
app().recalc_scadenze(dd); app().recalc_scadenze(dd);
} }
}
else else
if (!app().npart_is_prot()) if (!app().npart_is_prot())
{ {
@ -1760,11 +1769,7 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
{ {
const TString& valuta = clifo.get(CLI_CODVAL); const TString& valuta = clifo.get(CLI_CODVAL);
if (valuta.not_empty()) if (valuta.not_empty())
{
m.set(SK_VALUTA, valuta, TRUE); m.set(SK_VALUTA, valuta, TRUE);
if (m.get(SK_DATACAMBIO).empty())
m.set(SK_DATACAMBIO, m.get(F_DATADOC), TRUE);
}
} }
if (clifo.get(CLI_CODCAB).not_empty()) if (clifo.get(CLI_CODCAB).not_empty())
@ -1878,21 +1883,21 @@ void TPrimanota_application::gioca_cambi(int force)
if ( (force == 0x1 || totale.is_zero()) && !(totval.is_zero() || cambio.is_zero()) ) if ( (force == 0x1 || totale.is_zero()) && !(totval.is_zero() || cambio.is_zero()) )
{ {
const real new_totale = totval * cambio; real new_totale = totval * cambio; new_totale.round(0);
if (new_totale != totale) if (new_totale != totale)
m.set(F_TOTALE, new_totale, TRUE); m.set(F_TOTALE, new_totale, TRUE);
} }
if ( (force == 0x2 || totval.is_zero()) && !(totale.is_zero() || cambio.is_zero())) if ( (force == 0x2 || totval.is_zero()) && !(totale.is_zero() || cambio.is_zero()))
{ {
const real new_totval = totale / cambio; real new_totval = totale / cambio; new_totval.round(3);
if (new_totval != totval) if (new_totval != totval)
m.set(SK_TOTDOCVAL, new_totval, TRUE); m.set(SK_TOTDOCVAL, new_totval, TRUE);
} }
if ( (force == 0x4 || cambio.is_zero()) && !(totale.is_zero() || totval.is_zero())) if ( (force == 0x4 || cambio.is_zero()) && !(totale.is_zero() || totval.is_zero()))
{ {
const real new_cambio = totale / totval; real new_cambio = totale / totval; new_cambio.round(5);
if (new_cambio != cambio) if (new_cambio != cambio)
m.set(SK_CAMBIO, new_cambio, TRUE); m.set(SK_CAMBIO, new_cambio, TRUE);
} }
@ -1947,7 +1952,7 @@ bool TPrimanota_application::totdocval_handler(TMask_field& f, KEY key)
{ {
if (key == K_TAB && f.focusdirty()) if (key == K_TAB && f.focusdirty())
{ {
app().gioca_cambi(0x1); app().gioca_cambi();
const TMask& m = f.mask(); const TMask& m = f.mask();
if (app().is_fattura() && m.insert_mode()) // Se e' una vera fattura if (app().is_fattura() && m.insert_mode()) // Se e' una vera fattura

View File

@ -376,10 +376,10 @@ bool TCausale::intra() const
bool TCausale::valintra() const bool TCausale::valintra() const
{ return _rec.get_bool(CAU_VALINTRA); } { return _rec.get_bool(CAU_VALINTRA); }
const char* TCausale::causale_inc_imm() const const TString& TCausale::causale_inc_imm() const
{ return _rec.get(CAU_CODCAUSIM); } { return _rec.get(CAU_CODCAUSIM); }
const char* TCausale::tipo_doc() const const TString& TCausale::tipo_doc() const
{ return _rec.get(CAU_TIPODOC); } { return _rec.get(CAU_TIPODOC); }
int TCausale::tipomov() const int TCausale::tipomov() const
@ -437,11 +437,10 @@ void TCausale::calcIVA()
TipoIVA i = nessuna_iva; // Tipo IVA di default TipoIVA i = nessuna_iva; // Tipo IVA di default
bool c = FALSE; // Corrispettivi di default bool c = FALSE; // Corrispettivi di default
const TString16 td(tipo_doc()); const TString& td = tipo_doc();
if (td.not_empty()) if (td.not_empty())
{ {
TTable tpd("%TPD"); TTable tpd("%TPD");
tpd.setkey(1);
tpd.put("CODTAB", td); tpd.put("CODTAB", td);
if (tpd.read() == NOERR) if (tpd.read() == NOERR)
{ {
@ -468,6 +467,7 @@ bool TCausale::similar(const TCausale& c) const
if (sezionale() != c.sezionale()) err = "il segnale di sezionale"; if (sezionale() != c.sezionale()) err = "il segnale di sezionale";
if (intra() != c.intra()) err = "la gestione dei movimenti intra"; if (intra() != c.intra()) err = "la gestione dei movimenti intra";
if (valuta() != c.valuta()) err = "la gestione valuta"; if (valuta() != c.valuta()) err = "la gestione valuta";
if (valintra() != c.valintra()) err = "la gestione valuta intracomunitaria";
if (corrispettivi() != c.corrispettivi()) err = "la gestione dei corrispettivi"; if (corrispettivi() != c.corrispettivi()) err = "la gestione dei corrispettivi";
if (iva() != c.iva()) err = "il tipo di IVA"; if (iva() != c.iva()) err = "il tipo di IVA";
if (tipomov() != c.tipomov()) err = "il tipo di movimento"; if (tipomov() != c.tipomov()) err = "il tipo di movimento";

View File

@ -110,8 +110,8 @@ public:
bool valuta() const; bool valuta() const;
bool intra() const; bool intra() const;
bool valintra() const; bool valintra() const;
const char* causale_inc_imm() const; const TString& causale_inc_imm() const;
const char* tipo_doc() const; const TString& tipo_doc() const;
TRegistro& reg() const { return (TRegistro&)_reg; } TRegistro& reg() const { return (TRegistro&)_reg; }
TipoIVA iva() const { return _iva; } TipoIVA iva() const { return _iva; }

View File

@ -277,6 +277,7 @@ bool TPrimanota_application::numrif_handler(TMask_field& f, KEY key)
{ {
TMask& m = f.mask(); TMask& m = f.mask();
const bool empty = f.get().blank(); const bool empty = f.get().blank();
if (empty && m.insert_mode()) if (empty && m.insert_mode())
{ {
f.set(m.get(app()._npart_is_prot ? F_PROTIVA : F_NUMDOC)); f.set(m.get(app()._npart_is_prot ? F_PROTIVA : F_NUMDOC));
@ -290,25 +291,30 @@ bool TPrimanota_application::numrif_handler(TMask_field& f, KEY key)
"essere modificato prima di registrare il movimento."); "essere modificato prima di registrare il movimento.");
} }
if (m.edit_mode())
{
const TPartita* old = app().partite().first(); const TPartita* old = app().partite().first();
if (old && empty) // Se esisteva una partita ma ora non piu' if (old && empty) // Se esisteva una partita ma ora non piu'
{ {
const KEY k = yesnocancel_box("Attenzione la fattura della partita %d %s verra' eliminata.\n" const KEY k = yesnocancel_box("Attenzione la fattura della partita %d %s verra' eliminata.\n"
"Premere SI per cancellarla, NO per ripristinarla, ANNULLA modificarla", "Premere SI per cancellarla, NO per ripristinarla, ANNULLA per modificarla",
old->anno(), (const char*)old->numero()); old->anno(), (const char*)old->numero());
switch (k) switch (k)
{ {
case K_NO: case K_NO:
f.set(old->numero());
if (m.get(F_ANNORIF).empty())
m.set(F_ANNORIF, old->anno()); m.set(F_ANNORIF, old->anno());
m.set(F_NUMRIF, old->numero());
break; break;
case K_ESC: case K_ESC:
ok = FALSE; ok = FALSE;
break;
default: default:
f.reset();
break; break;
} }
} }
m.enable_page(2, !f.get().blank());
}
} }
return ok; return ok;
} }
@ -337,6 +343,8 @@ bool TPrimanota_application::cambio_handler(TMask_field& f, KEY key)
{ {
if (key == K_TAB && f.focusdirty()) if (key == K_TAB && f.focusdirty())
{ {
app().gioca_cambi(0x1); // Forza il ricalcolo del totale in lire
if (app().is_fattura()) if (app().is_fattura())
{ {
TPagamento& pag = app().pagamento(); TPagamento& pag = app().pagamento();
@ -355,8 +363,6 @@ bool TPrimanota_application::cambio_handler(TMask_field& f, KEY key)
// Copio la valuta a pagina 3 // Copio la valuta a pagina 3
const TValuta val(m, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO); const TValuta val(m, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO);
val.set(m, FS_VALUTA, FS_DATACAMBIO, FS_CAMBIO); val.set(m, FS_VALUTA, FS_DATACAMBIO, FS_CAMBIO);
app().gioca_cambi(0x1); // Forza il ricalcolo del totale in lire
} }
} }
return TRUE; return TRUE;
@ -572,7 +578,7 @@ bool TPrimanota_application::read_scadenze(TMask& m)
const real spese(0.0); const real spese(0.0);
const real cambio(partita.get(PART_CAMBIO)); const real cambio(partita.get(PART_CAMBIO));
const bool in_valuta = cambio > 1.0; const bool in_valuta = partita.in_valuta();
if (in_valuta) if (in_valuta)
{ {
imponibile = m.get_real(SK_TOTDOCVAL); imponibile = m.get_real(SK_TOTDOCVAL);

View File

@ -19,12 +19,14 @@
class TPay_mask : public TMask class TPay_mask : public TMask
{ {
TDate _datadoc;
real _da_pagare, _pagabile; real _da_pagare, _pagabile;
protected: protected:
static bool importo_handler(TMask_field& f, KEY k); static bool importo_handler(TMask_field& f, KEY k);
static bool importolire_handler(TMask_field& f, KEY k); static bool importolire_handler(TMask_field& f, KEY k);
static bool cambio_handler(TMask_field& f, KEY k); static bool cambio_handler(TMask_field& f, KEY k);
static bool datapag_handler(TMask_field& f, KEY k);
public: public:
void set_pag(const TRectype& oldpag, const TRiga_scadenze& scad, const TImporto& importo); void set_pag(const TRectype& oldpag, const TRiga_scadenze& scad, const TImporto& importo);
@ -94,14 +96,14 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad,
// Ricorda l'importo da pagare // Ricorda l'importo da pagare
_da_pagare += oldimp; _da_pagare += oldimp;
TValuta val; val.get(sum); const TValuta val(sum);
val.set(*this, S_VALUTA, S_DATACAMBIO, S_CAMBIO); val.set(*this, S_VALUTA, S_DATACAMBIO, S_CAMBIO);
const long numreg = sum.get_long(PART_NREG); const long numreg = sum.get_long(PART_NREG);
const int numrig = sum.get_int(PART_NUMRIG); const int numrig = sum.get_int(PART_NUMRIG);
TReal_field& resp = (TReal_field&)field(S_RESIDUOPAG); TReal_field& resp = (TReal_field&)field(S_RESIDUOPAG);
resp.set_decimals(in_valuta ? 2 : 0); resp.set_decimals(in_valuta ? 3 : 0);
TImporto r(importo); TImporto r(importo);
r -= app().partite().importo_speso(numreg, numrig); r -= app().partite().importo_speso(numreg, numrig);
if (in_valuta) if (in_valuta)
@ -138,9 +140,13 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad,
#ifdef __EXTRA__ #ifdef __EXTRA__
set_handler(S_CAMBIO, cambio_handler); set_handler(S_CAMBIO, cambio_handler);
hide(S_RESIDUOPAG); hide(S_RESIDUOPAG);
const bool mostra_conto = FALSE; const bool mostra_conto = FALSE;
show(-4, in_valuta); // Attiva campi relativi al cambio show(-4, in_valuta); // Attiva campi relativi al cambio
#else #else
_datadoc = sum.get_date(PART_DATADOC);
set_handler(S_DATAPAG, datapag_handler);
const bool mostra_conto = !sum.is_nota_credito(); const bool mostra_conto = !sum.is_nota_credito();
#endif #endif
show(-2, mostra_conto); // mostra/nasconde conto contropartita show(-2, mostra_conto); // mostra/nasconde conto contropartita
@ -234,6 +240,19 @@ bool TPay_mask::cambio_handler(TMask_field& f, KEY k)
return TRUE; return TRUE;
} }
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;
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Maschera partite // Maschera partite
@ -246,7 +265,8 @@ class TGame_mask : public TMask
int _numrig; // Riga contabile corrente (prima = 1!) int _numrig; // Riga contabile corrente (prima = 1!)
TImporto _importo; // Importo riga contabile TImporto _importo; // Importo riga contabile
int _riga_partite; // Riga corrente delle partite int _riga_partite; // Riga corrente delle partite
bool _changed; bool _changed; // Flag di modifica partite
bool _valfirst; // La colonna della valuta precede le lire
tipo_movimento _tipomov; // Dati per la creazione di un nuovo movimento tipo_movimento _tipomov; // Dati per la creazione di un nuovo movimento
char _sezione; char _sezione;
@ -278,7 +298,8 @@ protected:
int nuovo_pagamento(TPartita& partita, int nriga, int rata) const; int nuovo_pagamento(TPartita& partita, int nriga, int rata) const;
bool edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) const; bool edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) const;
bool same_number(const char* s1, const char* s2) const; long number_distance(const char* key, const char* num) const;
bool same_number(const char* key, const char* num) const;
#ifdef __EXTRA__ #ifdef __EXTRA__
bool edit_fattura(TPartita& p, int nriga); bool edit_fattura(TPartita& p, int nriga);
@ -303,7 +324,7 @@ public:
TGame_mask::TGame_mask(const TBill& bill, long numreg, int riga) TGame_mask::TGame_mask(const TBill& bill, long numreg, int riga)
: TMask("cg2100p"), _conto(bill), _numreg(numreg), _numrig(riga), : TMask("cg2100p"), _conto(bill), _numreg(numreg), _numrig(riga),
_changed(FALSE), _causali(LF_CAUSALI, "CODCAUS", "DESCR") _changed(FALSE), _valfirst(FALSE), _causali(LF_CAUSALI, "CODCAUS", "DESCR")
{ {
TString descr(80); TString descr(80);
switch (_conto.tipo()) switch (_conto.tipo())
@ -353,31 +374,35 @@ bool TGame_mask::annopart_handler(TMask_field& f, KEY k)
bool TGame_mask::numpart_handler(TMask_field& f, KEY k) bool TGame_mask::numpart_handler(TMask_field& f, KEY k)
{ {
if (k == K_TAB && f.dirty()) if (k == K_TAB && f.focusdirty())
{ {
const TGame_mask& m = (const TGame_mask&)f.mask(); const TGame_mask& m = (const TGame_mask&)f.mask();
const int anno = m.get_int(P_ANNO); const int anno = m.get_int(P_ANNO); // Anno partita da cercare
const TString16 num = f.get(); if (anno > 0)
if (anno > 0 && num.not_empty())
{ {
const TString key = f.get(); // Numero partita da cercare
int best_match = 0; // Partita piu' somigliante
long min_dist = 10000000L; // Livello di somiglianza migliore
TSheet_field& sheet = m.partite(); TSheet_field& sheet = m.partite();
for (int i = 0; i < sheet.items(); i++) for (int i = 0; i < sheet.items(); i++)
{ {
TToken_string& row = sheet.row(i); TToken_string& row = sheet.row(i);
if (anno == row.get_int(0)) // Se corrisponde l'anno e ... if (anno == row.get_int(0)) // Se corrisponde l'anno e ...
{ {
TString16 n = row.get(); n.trim(); const long dist = m.number_distance(key, row.get());
if (num == n) // corrisponde il numero partita ... if (dist < min_dist)
{ {
sheet.select(i); // ... seleziona la partita min_dist = dist;
partite_notify(sheet, i, K_TAB); // ed esplodi le sue righe best_match = i;
if (dist == 0L)
break; break;
} }
} }
} }
if (i >= sheet.items()) sheet.select(best_match); // ... seleziona la partita
f.warning_box("Partita inesistente"); partite_notify(sheet, best_match, K_TAB); // ed esplodi le sue righe
} }
} }
return TRUE; return TRUE;
@ -544,6 +569,8 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
gm.set(P_ANNO, anno); // Aggiorna campi di ricerca gm.set(P_ANNO, anno); // Aggiorna campi di ricerca
gm.set(P_NUMERO, num); gm.set(P_NUMERO, num);
bool in_valuta = FALSE;
if (anno > 0) if (anno > 0)
{ {
const TBill& zio = gm.conto(); // Conto cliente/fornitore const TBill& zio = gm.conto(); // Conto cliente/fornitore
@ -563,12 +590,12 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
if (!riga.is_fattura()) if (!riga.is_fattura())
continue; continue;
const bool in_valuta = riga.in_valuta(); in_valuta = riga.in_valuta();
riga_fattura.cut(0); riga_fattura.cut(0);
riga_fattura.add(ri); riga_fattura.add(ri);
riga_fattura.add(""); riga_fattura.add("");
riga_fattura.add("");
riga_fattura.add(riga.get(PART_DATADOC)); riga_fattura.add(riga.get(PART_DATADOC));
riga_fattura.add(""); // Data scad
gm.add_descrizione(riga_fattura, riga); gm.add_descrizione(riga_fattura, riga);
gm.add_importo(riga_fattura, riga.importo(FALSE, 0x1)); gm.add_importo(riga_fattura, riga.importo(FALSE, 0x1));
if (in_valuta) if (in_valuta)
@ -587,7 +614,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
TToken_string& row = scadenze.row(scadenze.add(riga_fattura)); TToken_string& row = scadenze.row(scadenze.add(riga_fattura));
row.add(ra, 1); row.add(ra, 1);
row.add(scad.get(SCAD_DATASCAD), 2); row.add(scad.get(SCAD_DATASCAD), 3);
gm.add_importo(row, scad.importo(FALSE), FALSE, 5); gm.add_importo(row, scad.importo(FALSE), FALSE, 5);
if (in_valuta) if (in_valuta)
gm.add_importo(row, scad.importo(TRUE), TRUE, 6); gm.add_importo(row, scad.importo(TRUE), TRUE, 6);
@ -602,8 +629,8 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
TToken_string& row = scadenze.row(scadenze.add("")); TToken_string& row = scadenze.row(scadenze.add(""));
row.add(ri); row.add(ri);
row.add(ra); row.add(ra);
row.add(sum.get(PART_DATAPAG));
row.add(sum.get(PART_DATADOC)); row.add(sum.get(PART_DATADOC));
row.add(sum.get(PART_DATAPAG));
gm.add_descrizione(row, sum); gm.add_descrizione(row, sum);
TImporto imp(sez, pag.get_real(PAGSCA_IMPORTO)); TImporto imp(sez, pag.get_real(PAGSCA_IMPORTO));
if (in_valuta) if (in_valuta)
@ -691,8 +718,8 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
TToken_string& row = scadenze.row(scadenze.add("")); TToken_string& row = scadenze.row(scadenze.add(""));
row.add(pag.get(PAGSCA_NRIGA)); row.add(pag.get(PAGSCA_NRIGA));
row.add(pag.get(PAGSCA_NRATA)); row.add(pag.get(PAGSCA_NRATA));
row.add(sum.get(PART_DATAPAG));
row.add(sum.get(PART_DATADOC)); row.add(sum.get(PART_DATADOC));
row.add(sum.get(PART_DATAPAG));
gm.add_descrizione(row, sum); gm.add_descrizione(row, sum);
TImporto i(sum.sezione(), pag.get_real(PAGSCA_IMPORTO)); TImporto i(sum.sezione(), pag.get_real(PAGSCA_IMPORTO));
i.valore() += pag.get_real(PAGSCA_RITENUTE); i.valore() += pag.get_real(PAGSCA_RITENUTE);
@ -729,6 +756,11 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
delete game; delete game;
} }
if (in_valuta != gm._valfirst)
{
gm.scadenze().swap_columns(106, 107); // Scambia le colonne dell'importo in lire e in valuta
gm._valfirst = in_valuta;
}
gm.scadenze().force_update(); gm.scadenze().force_update();
} }
if (k == K_INS) if (k == K_INS)
@ -765,7 +797,7 @@ int TGame_mask::nuova_riga(TPartita& partita) const
part.put(PART_CONTOCL, conto().conto()); part.put(PART_CONTOCL, conto().conto());
// Setta il cambio corrente // Setta il cambio corrente
TValuta valuta; valuta.get(*this, P_VALUTA, P_DATACAMBIO, P_CAMBIO); const TValuta valuta(*this, P_VALUTA, P_DATACAMBIO, P_CAMBIO);
valuta.put(part); valuta.put(part);
#ifdef __EXTRA__ #ifdef __EXTRA__
@ -1067,7 +1099,15 @@ void TGame_mask::add_importo(TToken_string& s, const TImporto& i, bool valuta, i
{ {
TString80 v; TString80 v;
TImporto n(i); n.normalize(); TImporto n(i); n.normalize();
v << n.valore().string(0, valuta ? 3 : 0) << ' ' << n.sezione(); if (valuta)
{
v = n.valore().string(3);
const int sep = v.find('.');
v[sep] = ',';
}
else
v = n.valore().string(0);
v << ' ' << n.sezione();
s.add(v, pos); s.add(v, pos);
} }
} }
@ -1186,11 +1226,28 @@ void TGame_mask::update_saldo_clifo()
r << ' ' << conto().sottoconto(); r << ' ' << conto().sottoconto();
} }
bool TGame_mask::same_number(const char* s1, const char* s2) const long TGame_mask::number_distance(const char* k, const char* n) const
{ {
TString16 t1(s1); t1.upper(); t1.trim(); TString16 key(k); key.upper(); key.trim();
TString16 t2(s2); t2.upper(); t2.trim(); t2.cut(t1.len()); const int kl = key.len();
return t1 == t2; TString16 num(n); num.upper(); num.trim();
const int nl = num.len();
long dist = 0;
for (int i = max(kl, nl)-1; i >= 0; i--)
{
const char kc = i < kl ? key[i] : 0;
const char nc = i < nl ? num[i] : 0;
const int d = kc - nc;
dist += d*d;
}
return dist;
}
bool TGame_mask::same_number(const char* key, const char* num) const
{
TString16 k(key); k.upper(); k.trim();
TString16 n(num); n.upper(); n.trim();
return k == n;
} }
void TGame_mask::fill_partite(int annorif, const char* numrif) void TGame_mask::fill_partite(int annorif, const char* numrif)

View File

@ -94,7 +94,6 @@ END
NUMBER 108 3 NUMBER 108 3
BEGIN BEGIN
PROMPT 38 7 "Conto " PROMPT 38 7 "Conto "
HELP "Codice del conto"
FIELD CONTO FIELD CONTO
USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="") USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="")
INPUT GRUPPO 107 INPUT GRUPPO 107
@ -117,7 +116,6 @@ END
NUMBER 109 6 NUMBER 109 6
BEGIN BEGIN
PROMPT 55 7 "Sottoconto " PROMPT 55 7 "Sottoconto "
HELP "Codice del sottoconto"
FIELD SOTTOCONTO FIELD SOTTOCONTO
USE LF_PCON SELECT SOTTOCONTO!="" USE LF_PCON SELECT SOTTOCONTO!=""
INPUT GRUPPO 107 INPUT GRUPPO 107
@ -182,7 +180,6 @@ END
STRING 110 50 STRING 110 50
BEGIN BEGIN
PROMPT 2 8 "Descrizione " PROMPT 2 8 "Descrizione "
HELP "Descrizione del conto"
FIELD LF_PCON->DESCR FIELD LF_PCON->DESCR
USE LF_PCON KEY 2 USE LF_PCON KEY 2
INPUT DESCR 110 INPUT DESCR 110
@ -190,6 +187,7 @@ BEGIN
DISPLAY "Gruppo" GRUPPO DISPLAY "Gruppo" GRUPPO
DISPLAY "Conto" CONTO DISPLAY "Conto" CONTO
DISPLAY "Sottoconto" SOTTOCONTO DISPLAY "Sottoconto" SOTTOCONTO
DISPLAY "C/R" TIPOSPRIC
COPY OUTPUT 109 COPY OUTPUT 109
CHECKTYPE NORMAL CHECKTYPE NORMAL
ADD RUN cg0 -0 ADD RUN cg0 -0
@ -198,7 +196,6 @@ END
STRING 210 50 STRING 210 50
BEGIN BEGIN
PROMPT 2 8 "Cliente " PROMPT 2 8 "Cliente "
HELP "Ragione sociale del cliente"
FIELD LF_CLIFO->RAGSOC FIELD LF_CLIFO->RAGSOC
USE LF_CLIFO KEY 2 USE LF_CLIFO KEY 2
INPUT TIPOCF "C" INPUT TIPOCF "C"
@ -216,7 +213,6 @@ END
STRING 310 50 STRING 310 50
BEGIN BEGIN
PROMPT 2 8 "Fornitore " PROMPT 2 8 "Fornitore "
HELP "Ragione sociale del forntore"
FIELD LF_PCON->SOTTOCONTO FIELD LF_PCON->SOTTOCONTO
USE LF_CLIFO KEY 2 USE LF_CLIFO KEY 2
INPUT TIPOCF "F" INPUT TIPOCF "F"

View File

@ -192,7 +192,7 @@ void TValuta::get(const TMask& m, short v, short d, short c)
{ {
if (v > 0) _cod = m.get(v); if (v > 0) _cod = m.get(v);
if (d > 0) _dat = m.get(d); if (d > 0) _dat = m.get(d);
_cam = real(m.get(c)); _cam = m.get_real(c);
adjust(); adjust();
} }
@ -690,6 +690,12 @@ int TRiga_partite::rata_con_abbuoni_diffcam() const
return found; return found;
} }
bool TRiga_partite::in_valuta() const
{
const TString& cod = get(PART_CODVAL);
return cod.not_empty() && cod != "LIT";
}
// Calcola l'importo in lire o in valuta su di una riga di partita // Calcola l'importo in lire o in valuta su di una riga di partita
// E' possibile considerare o meno IMPORTO, ABBUONI e DIFFCAM // E' possibile considerare o meno IMPORTO, ABBUONI e DIFFCAM
TImporto TRiga_partite::importo(bool valuta, int mode) const TImporto TRiga_partite::importo(bool valuta, int mode) const
@ -1062,7 +1068,7 @@ TImporto TPartita::importo_speso(long nreg, int numrig) const
{ {
const TRiga_partite& row = riga(r); const TRiga_partite& row = riga(r);
if (nreg == row.get_long(PART_NREG) && numrig == row.get_int(PART_NUMRIG)) if (nreg == row.get_long(PART_NREG) && numrig == row.get_int(PART_NUMRIG))
imp += row.importo(FALSE, 0x7); // Importo in lire imp += row.importo(FALSE); // Importo in lire
} }
return imp; return imp;

View File

@ -198,7 +198,7 @@ public:
char sezione() const { return get_char(PART_SEZ); } char sezione() const { return get_char(PART_SEZ); }
TImporto importo(bool valuta, int mode = 0xF) const; TImporto importo(bool valuta, int mode = 0xF) const;
bool in_valuta() const { return get(PART_CODVAL).not_empty(); } bool in_valuta() const;
bool update(const TRectype& vec, const TRectype& nuo, const char* field); bool update(const TRectype& vec, const TRectype& nuo, const char* field);
bool update(const TImporto& vec, const TImporto& nuo, const char* sez, const char* val); bool update(const TImporto& vec, const TImporto& nuo, const char* sez, const char* val);