Magnifiche correzioni al saldaconto

git-svn-id: svn://10.65.10.50/trunk@1940 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-10-11 11:39:50 +00:00
parent c4c1549aed
commit 6398370de6
11 changed files with 207 additions and 205 deletions

View File

@ -28,13 +28,15 @@ TMask* TPrimanota_application::load_mask(int n)
if (_msk[n] != NULL) if (_msk[n] != NULL)
return _msk[n]; return _msk[n];
if (n == 1 || n == 2) // Se voglio una maschera principale (cg o iva) if (n < 3)
{ {
const int d = 3-n; // Indice maschera complementare for (int i = 3; i >= 0; i--)
if (_msk[d] != NULL)
{ {
delete _msk[d]; if (_msk[i] != NULL)
_msk[d] = NULL; {
delete _msk[i];
_msk[i] = NULL;
}
} }
} }
@ -133,7 +135,7 @@ TMask* TPrimanota_application::load_mask(int n)
m->set_handler(O_CODICE, occas_code_handler); m->set_handler(O_CODICE, occas_code_handler);
break; break;
default: default:
CHECKD(0, "Che cavolo di maschera e' la ", n); CHECKD(0, "Che ca$$o di maschera e' la ", n);
break; break;
} }
@ -938,7 +940,7 @@ bool TPrimanota_application::remove()
{ {
if (iva() == nessuna_iva) if (iva() == nessuna_iva)
{ {
notify_cgline_deletion(0); // Notify deletion of all cg lines notify_cgline_deletion(-1); // Notify deletion of all cg lines
partite().rewrite(); partite().rewrite();
} }
else else
@ -1017,11 +1019,16 @@ void TPrimanota_application::genera_incasso(const char* causimm)
if (m.run() == K_SAVE) if (m.run() == K_SAVE)
{ {
TMovimentoPN inc; // Nuovo movimento di incasso immediato TMovimentoPN inc; // Nuovo movimento di incasso immediato
TRectype& curr = inc.curr();
inc.lfile().zero(); curr.zero();
m.autosave(&inc); m.autosave(&inc);
inc.lfile().put("TIPODOC", caus.tipo_doc()); // Tipo documento
inc.lfile().put("REG", caus.reg().name()); // Registro curr.put("TIPODOC", caus.tipo_doc()); // Tipo documento
curr.put("REG", caus.reg().name()); // Registro
curr.zero(MOV_TIPO);
curr.zero(MOV_CODCF);
curr.zero(MOV_TOTDOC);
curr.zero(MOV_ANNOIVA);
const int annoes = m.get_int(F_ANNOES); const int annoes = m.get_int(F_ANNOES);
const TString16 datareg = m.get(F_DATAREG); const TString16 datareg = m.get(F_DATAREG);

View File

@ -631,7 +631,7 @@ SPREADSHEET F_SHEETIVA 0 7
BEGIN BEGIN
PROMPT 0 4 "" PROMPT 0 4 ""
ITEM "Imponibile@15" ITEM "Imponibile@15"
ITEM "Iva@4" ITEM "Iva@5"
ITEM "Det@1" ITEM "Det@1"
ITEM "Imposta@15" ITEM "Imposta@15"
ITEM "CR@1" ITEM "CR@1"

View File

@ -122,13 +122,13 @@ BEGIN
PROMPT 0 11 "" PROMPT 0 11 ""
ITEM "Riga" ITEM "Riga"
ITEM "Rata" ITEM "Rata"
ITEM "Data doc.@10"
ITEM "Num. reg."
ITEM "Data reg.@10"
ITEM "Data scad." ITEM "Data scad."
ITEM "Data doc.@10"
ITEM "Descrizione@20"
ITEM "Importo Lire@14" ITEM "Importo Lire@14"
ITEM "Importo Valuta@14" ITEM "Importo Valuta@14"
ITEM "Descrizione@50" ITEM "Num. reg."
ITEM "Data reg.@10"
ITEM "Num. doc." ITEM "Num. doc."
ITEM "Prot. IVA" ITEM "Prot. IVA"
ITEM "Pagamento" ITEM "Pagamento"
@ -140,11 +140,6 @@ BEGIN
PROMPT 1 -1 "Mostra tutte le partite" PROMPT 1 -1 "Mostra tutte le partite"
END END
BUTTON P_SCAMBIO 28
BEGIN
PROMPT 40 -1 "Num. reg. <-> Num. doc."
END
ENDPAGE ENDPAGE
ENDMASK ENDMASK
@ -212,16 +207,16 @@ ENDPAGE
ENDMASK ENDMASK
PAGE "Sheet Scadenze" -1 -1 66 10 PAGE "Sheet Scadenze" -1 -1 68 10
NUMBER 101 4 STRING 101 4
BEGIN BEGIN
PROMPT 1 1 "Numero riga " PROMPT 1 1 "Numero riga "
END END
NUMBER 102 4 STRING 102 4
BEGIN BEGIN
PROMPT 30 1 "Numero rata " PROMPT 41 1 "Numero rata "
END END
NUMBER 112 4 NUMBER 112 4
@ -229,50 +224,50 @@ BEGIN
PROMPT 1 2 "Riga pagamento " PROMPT 1 2 "Riga pagamento "
END END
DATE 103 DATE 104
BEGIN BEGIN
PROMPT 30 2 "Data documento " PROMPT 41 2 "Data documento "
END END
NUMBER 104 5 NUMBER 108 5
BEGIN BEGIN
PROMPT 1 3 "Numero reg. " PROMPT 1 3 "Numero reg. "
END END
DATE 105 DATE 109
BEGIN BEGIN
PROMPT 30 3 "Data reg. " PROMPT 41 3 "Data reg. "
END END
NUMBER 110 5 NUMBER 110 5
BEGIN BEGIN
PROMPT 1 4 "Numero doc. " PROMPT 1 4 "Numero doc. "
END END
NUMBER 111 5 NUMBER 111 5
BEGIN BEGIN
PROMPT 30 5 "Protocollo IVA " PROMPT 41 5 "Protocollo IVA "
END END
DATE 106 DATE 103
BEGIN BEGIN
PROMPT 30 4 "Data scad. " PROMPT 41 4 "Data scad. "
END END
STRING 109 50 STRING 105 50
BEGIN BEGIN
PROMPT 1 6 "Descrizione " PROMPT 1 6 "Descrizione "
END
STRING 106 14
BEGIN
PROMPT 1 7 "Importo Lire "
FLAGS "R"
END END
STRING 107 14 STRING 107 14
BEGIN BEGIN
PROMPT 1 7 "Importo Lire " PROMPT 37 7 "Importo Valuta "
FLAGS "R"
END
STRING 108 14
BEGIN
PROMPT 30 7 "Importo Valuta "
FLAGS "R" FLAGS "R"
END END

View File

@ -264,6 +264,12 @@ int TMovimentoPN::remove(TDate&)
if (err == NOERR) if (err == NOERR)
err = TRelation::remove(); err = TRelation::remove();
if (err == NOERR)
{
const TDate datareg(curr().get("DATAREG"));
controlla_liquidazione(datareg, TRUE);
}
return err; return err;
} }

View File

@ -227,13 +227,14 @@ void TPrimanota_application::set_cgs_imp(int n, const TImporto& imp)
TSheet_field& s = cgs(); TSheet_field& s = cgs();
imp.add_to(s.row(n), 0); imp.add_to(s.row(n), 0);
s.force_update(n); s.force_update(n);
/*
TMask& m = s.sheet_mask(); TMask& m = s.sheet_mask();
if (m.is_running() && s.selected() == n) if (m.is_running() && s.selected() == n)
{ {
m.set(101, imp.sezione() == 'D' ? imp.valore().string() : ""); m.set(101, imp.sezione() == 'D' ? imp.valore().string() : "");
m.set(102, imp.sezione() == 'A' ? imp.valore().string() : ""); m.set(102, imp.sezione() == 'A' ? imp.valore().string() : "");
} }
*/
} }
// Legge l'importo della riga n e lo ritorna col segno dovuto // Legge l'importo della riga n e lo ritorna col segno dovuto
@ -262,18 +263,17 @@ TImporto TPrimanota_application::get_cgs_imp(int n)
// Certified 90% // Certified 90%
bool TPrimanota_application::add_cgs_imp(int n, const TImporto& imp) bool TPrimanota_application::add_cgs_imp(int n, const TImporto& imp)
{ {
TImporto tot; TImporto tot(get_cgs_imp(n));
tot = cgs().row(n);
tot += imp; tot += imp;
set_cgs_imp(n, tot.normalize()); tot.normalize();
set_cgs_imp(n, tot);
return tot.is_zero(); return tot.is_zero();
} }
// Certified 90% // Certified 90%
bool TPrimanota_application::sub_cgs_imp(int n, const TImporto& imp) bool TPrimanota_application::sub_cgs_imp(int n, const TImporto& imp)
{ {
TImporto tot; TImporto tot(get_cgs_imp(n));
tot = cgs().row(n);
tot -= imp; tot -= imp;
tot.normalize(); tot.normalize();
set_cgs_imp(n, tot); set_cgs_imp(n, tot);
@ -301,6 +301,8 @@ TImporto TPrimanota_application::real2imp(const real& r, char row_type)
// Disabilita le celle della riga contabile n in base al suo tipo // Disabilita le celle della riga contabile n in base al suo tipo
void TPrimanota_application::disable_cgs_cells(int n, char tipo) void TPrimanota_application::disable_cgs_cells(int n, char tipo)
{ {
TSheet_field& cg = cgs();
int first = 0, last = 0; int first = 0, last = 0;
switch(tipo) switch(tipo)
{ {
@ -315,9 +317,14 @@ void TPrimanota_application::disable_cgs_cells(int n, char tipo)
case 'S': // Ritenute Sociali case 'S': // Ritenute Sociali
case 'T': // Totale documento case 'T': // Totale documento
last = 3; last = 3;
if (!causale().corrispettivi())
{
cg.disable_cell(n, 5);
cg.disable_cell(n, 6);
}
break; break;
case 'K': // Riga cliente/fornitore per saldaconto case 'K': // Riga cliente/fornitore per saldaconto
if (get_cgs_imp(n).is_zero()) if (n == cg.items()-1)
break; break;
first = 2; first = 2;
case 'I': case 'I':
@ -328,17 +335,8 @@ void TPrimanota_application::disable_cgs_cells(int n, char tipo)
break; break;
} }
if (last > 0) for (int i = first; i < last; i++)
{ cg.disable_cell(n, i);
TSheet_field& cg = cgs();
for (int i = first; i < last; i++)
cg.disable_cell(n, i);
if (tipo == 'T' && !causale().corrispettivi())
{
cg.disable_cell(n, 5);
cg.disable_cell(n, 6);
}
}
} }
void TPrimanota_application::reset_sheet_row(TSheet_field& s, int n) void TPrimanota_application::reset_sheet_row(TSheet_field& s, int n)
@ -506,10 +504,8 @@ real TPrimanota_application::calcola_saldo() const
if (pag) if (pag)
{ {
const char sez = causale().sezione(1);
saldaconto.normalize(sez);
real t(m.get(F_TOTALE)); real t(m.get(F_TOTALE));
t -= saldaconto.valore(); t -= saldaconto.normalize().valore();
m.set(K_RESIDUO, t.string()); m.set(K_RESIDUO, t.string());
} }
@ -576,12 +572,14 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
if (paga) if (paga)
{ {
real t(f.mask().get(F_TOTALE)); const real totdoc(f.mask().get(F_TOTALE));
t -= saldaconto.valore(); const real valore = saldaconto.normalize().valore();
if (!t.is_zero()) if (totdoc != valore)
{ {
const char* ss = saldaconto.valore().string("."); const TString16 td(totdoc.string("."));
return f.error_box("Il totale documento deve essere %s", ss); const char* ss = valore.string(".");
return f.error_box("Il totale documento inserito e' %s\n"
"mentre i pagamenti ammontano a %s", (const char*)td, ss);
} }
} }
@ -750,6 +748,7 @@ bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
} }
else else
app().sub_cgs_imp(s, growth); app().sub_cgs_imp(s, growth);
app().calcola_saldo();
} }
} }
else else
@ -768,7 +767,10 @@ bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
const int k = tipo == 'K' ? 1 : 10; const int k = tipo == 'K' ? 1 : 10;
TBill conto; app().causale().bill(k, conto); TBill conto; app().causale().bill(k, conto);
const TString80 desc(app().causale().desc_agg(k)); const TString80 desc(app().causale().desc_agg(k));
app().set_cgs_row(r, TImporto('D', ZERO), conto, desc, tipo); const char sez = app().causale().sezione(k);
const real imp(cg.mask().get(K_RESIDUO));
app().set_cgs_row(r, TImporto(sez, imp), conto, desc, tipo);
if (tipo == 'K') if (tipo == 'K')
{ {
for (int i = 0; i < r; i++) for (int i = 0; i < r; i++)
@ -778,6 +780,7 @@ bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
{ {
cg.swap_rows(r, i); cg.swap_rows(r, i);
cg.force_update(); cg.force_update();
cg.select(i);
break; break;
} }
} }

View File

@ -216,7 +216,7 @@ protected:
void remove_scadenze(const TMask& m, const char* rif); void remove_scadenze(const TMask& m, const char* rif);
void renumber_partita(TMask& m, const char* oldp, const char* newp); void renumber_partita(TMask& m, const char* oldp, const char* newp);
bool edit_partite(int riga); bool edit_partite(const TMask& m, int riga);
bool notify_cgline_deletion(TPartita& partita, long nreg, int numrig); bool notify_cgline_deletion(TPartita& partita, long nreg, int numrig);
bool notify_cgline_deletion(int numrig); bool notify_cgline_deletion(int numrig);
@ -231,7 +231,7 @@ public:
TPartite_array& partite() { return _partite; } // Partite editate TPartite_array& partite() { return _partite; } // Partite editate
bool edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp); bool edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp);
bool notify_edit_pagamento(TPartita& partita, TRectype& new_pag, bool notify_edit_pagamento(TPartita& partita, TRectype& new_pag,
const TValuta& valuta, int deleting = -1); const TValuta& valuta, int deleting = 0);
TSheet_field& cgs() const; TSheet_field& cgs() const;
TSheet_field& ivas() const; TSheet_field& ivas() const;

View File

@ -557,7 +557,7 @@ bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k)
if (k == K_SPACE) if (k == K_SPACE)
{ {
const bool ok = app().edit_partite(riga); const bool ok = app().edit_partite(m, riga);
if (ok) if (ok)
k = K_ENTER; k = K_ENTER;
} }
@ -581,8 +581,8 @@ bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k)
// deleting significato // deleting significato
// -1 non sto cancellando nulla // -1 sto cancellando tutto
// 0 sto cancellando tutto // 0 non sto cancellando nulla
// 1 sto cancellando la prima riga contabile // 1 sto cancellando la prima riga contabile
// n sto cancellando la ennesima riga contabile // n sto cancellando la ennesima riga contabile
bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pag, bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pag,
@ -595,7 +595,7 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
const TRiga_partite& somma = p.riga(nrigp); const TRiga_partite& somma = p.riga(nrigp);
const int riga_contabile = somma.get_int(PART_NUMRIG); // Riga movimento const int riga_contabile = somma.get_int(PART_NUMRIG); // Riga movimento
if (deleting != 0) if (deleting >= 0)
{ {
const char sez = somma.sezione(); // Sezione importo e ritenute const char sez = somma.sezione(); // Sezione importo e ritenute
const char controsez = sez == 'A' ? 'D' : 'A'; // Sezione contropartita const char controsez = sez == 'A' ? 'D' : 'A'; // Sezione contropartita
@ -655,7 +655,7 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
old_ap, old_abbuono, old_diffcam, old_ap, old_abbuono, old_diffcam,
new_ap, new_abbuono, new_diffcam); new_ap, new_abbuono, new_diffcam);
if (deleting != 0) if (deleting >= 0)
{ {
// Se c'e' differenza negli abbuoni // Se c'e' differenza negli abbuoni
if (old_abbuono != new_abbuono || old_ap != new_ap) if (old_abbuono != new_abbuono || old_ap != new_ap)
@ -721,7 +721,7 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
sub_cgs_imp(riga_contabile-1, grow_diffcam); sub_cgs_imp(riga_contabile-1, grow_diffcam);
} }
} }
} // if (deleting != 0) } // if (deleting >= 0)
return empty; return empty;
} }
@ -772,7 +772,7 @@ bool TPrimanota_application::notify_cgline_deletion(int numrig)
{ {
bool found = FALSE; bool found = FALSE;
const long nreg = curr_mask().get_long(F_NUMREG); const long nreg = curr_mask().get_long(F_NUMREG);
for (TPartita* game = _partite.first(); game; game = _partite.next()) for (TPartita* game = partite().first(); game; game = partite().next())
found |= notify_cgline_deletion(*game, nreg, numrig); found |= notify_cgline_deletion(*game, nreg, numrig);
return found; return found;
} }

View File

@ -23,14 +23,14 @@
class TPay_mask : public TMask class TPay_mask : public TMask
{ {
real _da_pagare; real _da_pagare, _pagabile;
TValuta _valuta; TValuta _valuta;
protected: protected:
static bool importo_handler(TMask_field& f, KEY k); static bool importo_handler(TMask_field& f, KEY k);
public: public:
void set_pag(const TRectype& oldpag, const TRiga_scadenze& scad); void set_pag(const TRectype& oldpag, const TRiga_scadenze& scad, const TImporto& importo);
void get_pag(TRectype& oldpag) const; void get_pag(TRectype& oldpag) const;
const TValuta& valuta() const { return _valuta; } const TValuta& valuta() const { return _valuta; }
@ -42,7 +42,8 @@ TPay_mask::TPay_mask() : TMask("cg2100s")
{ {
} }
void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad) void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad,
const TImporto& importo)
{ {
TRelation rel(LF_PAGSCA); // Working relation TRelation rel(LF_PAGSCA); // Working relation
rel.curr() = oldpag; rel.curr() = oldpag;
@ -65,8 +66,8 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad)
TReal_field& res = (TReal_field&)field(S_RESIDUORATA); TReal_field& res = (TReal_field&)field(S_RESIDUORATA);
res.set_decimals(in_valuta ? 2 : 0); res.set_decimals(in_valuta ? 2 : 0);
res.set(_da_pagare.string()); res.set(_da_pagare.string());
if (!_da_pagare.is_zero())
set_handler(in_valuta ? S_IMPORTOVAL : S_IMPORTO, importo_handler); set_handler(in_valuta ? S_IMPORTOVAL : S_IMPORTO, importo_handler);
// Ricorda l'importo da pagare // Ricorda l'importo da pagare
_da_pagare += oldpag.get_real(in_valuta ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO); _da_pagare += oldpag.get_real(in_valuta ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO);
@ -77,17 +78,20 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad)
const TPartita& p = scad.partita(); const TPartita& p = scad.partita();
const int nrigp = oldpag.get_int(PAGSCA_NRIGP); const int nrigp = oldpag.get_int(PAGSCA_NRIGP);
const TRiga_partite& sum = p.riga(nrigp); const TRiga_partite& sum = p.riga(nrigp);
_valuta.get(sum);
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);
#ifdef __EXTRA__ _valuta.get(sum);
TImporto residuo(app().curr_mask().get(F_TOTALE));
#else TReal_field& resp = (TReal_field&)field(S_RESIDUOPAG);
TImporto residuo(app().get_cgs_imp(numrig-1)); resp.set_decimals(in_valuta ? 2 : 0);
#endif TImporto r(importo);
residuo -= app().partite().importo_speso(numreg, numrig); r -= app().partite().importo_speso(numreg, numrig);
set(S_RESIDUOPAG, residuo.valore().string()); if (in_valuta)
_pagabile = _valuta.lit2val(r.valore());
else
_pagabile = r.valore();
resp.set(_pagabile.string());
_pagabile += oldpag.get_real(in_valuta ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO);
// Il flag di saldo/acconto e' attivo solo se non ci sono acconti // Il flag di saldo/acconto e' attivo solo se non ci sono acconti
bool sa = oldpag.get_int(PAGSCA_NRIGA) != TPartita::UNASSIGNED; bool sa = oldpag.get_int(PAGSCA_NRIGA) != TPartita::UNASSIGNED;
@ -126,7 +130,8 @@ bool TPay_mask::importo_handler(TMask_field& f, KEY k)
if (k == K_F8) if (k == K_F8)
{ {
f.set(m._da_pagare.string()); const real& imp = fnc_min(m._da_pagare, m._pagabile);
f.set(imp.string());
k = K_TAB; k = K_TAB;
} }
@ -139,6 +144,9 @@ bool TPay_mask::importo_handler(TMask_field& f, KEY k)
const real residuo(m._da_pagare - i); const real residuo(m._da_pagare - i);
m.set(S_RESIDUORATA, residuo.string()); m.set(S_RESIDUORATA, residuo.string());
const real residuopag(m._pagabile - i);
m.set(S_RESIDUOPAG, residuopag.string());
if (f.dlg() == S_IMPORTOVAL) if (f.dlg() == S_IMPORTOVAL)
{ {
const real lit = m.valuta().val2lit(i); const real lit = m.valuta().val2lit(i);
@ -158,6 +166,7 @@ class TGame_mask : public TMask
const TBill _conto; // Conto fisso del cliente/fornitore const TBill _conto; // Conto fisso del cliente/fornitore
long _numreg; // Numero movimento contabile long _numreg; // Numero movimento contabile
int _numrig; // Riga contabile corrente (prima = 1!) int _numrig; // Riga contabile corrente (prima = 1!)
TImporto _importo; // Importo riga contabile
int _riga_partite; // Riga corrente delle partite int _riga_partite; // Riga corrente delle partite
protected: protected:
@ -165,7 +174,6 @@ protected:
static bool numpart_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); static bool partite_notify(TSheet_field& partite, int r, KEY k);
static bool show_all_handler(TMask_field& f, KEY k); static bool show_all_handler(TMask_field& f, KEY k);
static bool scambio_handler(TMask_field& f, KEY k);
static bool edit_scadenza_handler(TMask_field& f, KEY k); static bool edit_scadenza_handler(TMask_field& f, KEY k);
static bool nuovo_handler(TMask_field& f, KEY k); static bool nuovo_handler(TMask_field& f, KEY k);
static bool cambio_handler(TMask_field& f, KEY k); static bool cambio_handler(TMask_field& f, KEY k);
@ -215,7 +223,6 @@ TGame_mask::TGame_mask(const TBill& bill, long numreg, int riga)
set_handler(P_ANNO, annopart_handler); set_handler(P_ANNO, annopart_handler);
set_handler(P_NUMERO, numpart_handler); set_handler(P_NUMERO, numpart_handler);
set_handler(P_SHOWALL, show_all_handler); set_handler(P_SHOWALL, show_all_handler);
set_handler(P_SCAMBIO, scambio_handler);
set_handler(P_NUOVO, nuovo_handler); set_handler(P_NUOVO, nuovo_handler);
set_handler(P_CAMBIO, cambio_handler); set_handler(P_CAMBIO, cambio_handler);
@ -277,18 +284,6 @@ bool TGame_mask::show_all_handler(TMask_field& f, KEY k)
return TRUE; return TRUE;
} }
bool TGame_mask::scambio_handler(TMask_field& f, KEY k)
{
if (k == K_SPACE)
{
const TGame_mask& gm = (const TGame_mask&)f.mask();
const TSheet_field& sheet = gm.scadenze();
sheet.swap_columns(103, 110); // Scambia colonne
sheet.swap_columns(104, 111);
}
return TRUE;
}
bool TGame_mask::cambio_handler(TMask_field& f, KEY k) bool TGame_mask::cambio_handler(TMask_field& f, KEY k)
{ {
if (k == K_TAB && f.focusdirty() && if (k == K_TAB && f.focusdirty() &&
@ -307,14 +302,15 @@ bool TGame_mask::cambio_handler(TMask_field& f, KEY k)
real TGame_mask::aggiorna_residuo() real TGame_mask::aggiorna_residuo()
{ {
#ifdef __EXTRA__ #ifdef EXTRA
TImporto residuo(app().curr_mask().get(F_TOTALE)); return ZERO;
#else #else
TImporto residuo(app().get_cgs_imp(_numrig-1)); _importo = app().get_cgs_imp(_numrig-1);
#endif TImporto residuo(_importo);
residuo -= app().partite().importo_speso(_numreg, _numrig); residuo -= app().partite().importo_speso(_numreg, _numrig);
set(P_RESIDUO, residuo.valore().string()); set(P_RESIDUO, residuo.valore().string());
return residuo.valore(); return residuo.valore();
#endif
} }
bool TGame_mask::cerca_valuta(TValuta& val) const bool TGame_mask::cerca_valuta(TValuta& val) const
@ -377,11 +373,10 @@ void TGame_mask::aggiorna_valuta(const TValuta& val)
if (annorif != 0) if (annorif != 0)
{ {
const bool proponi =
#ifdef __EXTRA__ #ifdef __EXTRA__
TRUE; const bool proponi = RUE;
#else #else
app().causale().tipomov() == 2; const bool proponi = app().causale().tipomov() == 2;
#endif #endif
if (proponi) if (proponi)
{ {
@ -434,16 +429,16 @@ 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(riga.get(PART_DATADOC));
row.add(riga.get(PART_NREG));
row.add(riga.get(PART_DATAREG));
row.add(scad.get(SCAD_DATASCAD)); row.add(scad.get(SCAD_DATASCAD));
row.add(riga.get(PART_DATADOC));
row.add(riga.get(PART_DESCR));
add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTO))); add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTO)));
if (in_valuta) if (in_valuta)
add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTOVAL)), 2); add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTOVAL)), 2);
else else
row.add(""); row.add("");
row.add(riga.get(PART_DESCR)); row.add(riga.get(PART_NREG));
row.add(riga.get(PART_DATAREG));
row.add(riga.get(PART_NUMDOC)); row.add(riga.get(PART_NUMDOC));
row.add(riga.get(PART_PROTIVA)); row.add(riga.get(PART_PROTIVA));
@ -457,18 +452,16 @@ 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_DATADOC));
row.add(sum.get(PART_NREG));
row.add(sum.get(PART_DATAREG));
row.add(scad.get(SCAD_DATASCAD)); row.add(scad.get(SCAD_DATASCAD));
row.add(sum.get(PART_DATADOC));
row.add(sum.get(PART_DESCR));
add_importo(row, TImporto(sez, pag.get_real(PAGSCA_IMPORTO))); add_importo(row, TImporto(sez, pag.get_real(PAGSCA_IMPORTO)));
if (in_valuta) if (in_valuta)
add_importo(row, TImporto(sez, pag.get_real(PAGSCA_IMPORTOVAL)), 2); add_importo(row, TImporto(sez, pag.get_real(PAGSCA_IMPORTOVAL)), 2);
else else
row.add(""); row.add("");
row.add(sum.get(PART_NREG));
row.add(sum.get(PART_DESCR)); row.add(sum.get(PART_DATAREG));
row.add(sum.get(PART_NUMDOC)); row.add(sum.get(PART_NUMDOC));
row.add(""); row.add("");
row.add(pa); row.add(pa);
@ -478,7 +471,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
if (!abb.is_zero()) if (!abb.is_zero())
{ {
TToken_string& rabb = scadenze.row(scadenze.add("")); TToken_string& rabb = scadenze.row(scadenze.add(""));
rabb.add("", 5); rabb.add("Abbuoni rata ", 4); rabb << ra;
if (in_valuta) if (in_valuta)
{ {
add_importo(rabb, scad.importo_pagato(FALSE, 0x2)); add_importo(rabb, scad.importo_pagato(FALSE, 0x2));
@ -489,7 +482,6 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
add_importo(rabb, abb, 2); add_importo(rabb, abb, 2);
rabb.add(""); rabb.add("");
} }
rabb.add("Abbuoni rata ", 8); rabb << ra;
} }
if (in_valuta) if (in_valuta)
@ -498,17 +490,15 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
if (!diff.is_zero()) if (!diff.is_zero())
{ {
TToken_string& rdiff = scadenze.row(scadenze.add("")); TToken_string& rdiff = scadenze.row(scadenze.add(""));
rdiff.add("", 5); rdiff.add("Differenza cambio rata ", 4); rdiff << ra;
add_importo(rdiff, diff.normalize()); add_importo(rdiff, diff.normalize());
rdiff.add("Differenza cambio rata ", 8); rdiff << ra;
} }
} }
TToken_string& rsal = scadenze.row(scadenze.add("")); TToken_string& rsal = scadenze.row(scadenze.add(""));
rsal.add("Saldo rata ", 4); rsal << ra;
if (!scad.chiusa()) if (!scad.chiusa())
{ {
rsal.add("", 5);
TImporto sl(scad.residuo(FALSE, 0x7)); TImporto sl(scad.residuo(FALSE, 0x7));
sl.normalize(); sl.normalize();
add_importo(rsal, sl); add_importo(rsal, sl);
@ -518,11 +508,10 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
{ {
sl = scad.residuo(TRUE, 0x3); sl = scad.residuo(TRUE, 0x3);
sl.normalize(); sl.normalize();
tot_val += sl;
add_importo(rsal, sl, 2); add_importo(rsal, sl, 2);
tot_val += sl;
} }
} }
rsal.add("Saldo rata ", 8); rsal << ra;
} }
TRecord_array& unas = game->unassigned(); TRecord_array& unas = game->unassigned();
@ -534,13 +523,9 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
TImporto imp(sum.sezione(), ZERO); TImporto imp(sum.sezione(), ZERO);
TToken_string& row = scadenze.row(scadenze.add("")); TToken_string& row = scadenze.row(scadenze.add(""));
row.add(pag.get(PAGSCA_NRIGA)); row.add("9999|9999| ");
row.add(pag.get(PAGSCA_NRATA));
row.add(sum.get(PART_DATADOC)); row.add(sum.get(PART_DATADOC));
row.add(sum.get(PART_NREG)); row.add(sum.get(PART_DESCR));
row.add(sum.get(PART_DATAREG));
row.add("");
TImporto i(sum.sezione(), pag.get_real(PAGSCA_IMPORTO)); TImporto i(sum.sezione(), pag.get_real(PAGSCA_IMPORTO));
i.normalize(); i.normalize();
tot_lit += i; tot_lit += i;
@ -554,18 +539,21 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
} }
else else
row.add(""); row.add("");
row.add(sum.get(PART_DESCR)); row.add(sum.get(PART_NREG));
row.add(sum.get(PART_DATAREG));
row.add(sum.get(PART_NUMDOC)); row.add(sum.get(PART_NUMDOC));
row.add(""); row.add("");
row.add(pa); row.add(pa);
} }
} }
TToken_string& sp = scadenze.row(scadenze.add("")); if (lastrow > 0)
sp.add("", 5); {
add_importo(sp, tot_lit.normalize()); TToken_string& sp = scadenze.row(scadenze.add(""));
add_importo(sp, tot_val.normalize(), 2); sp.add("Saldo partita ", 4); sp << anno << ' ' << num;
sp.add("Saldo partita", 8); add_importo(sp, tot_lit.normalize());
add_importo(sp, tot_val.normalize(), 2);
}
gm.scadenze().force_update(); gm.scadenze().force_update();
if (should_delete_game) if (should_delete_game)
@ -715,7 +703,7 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
} }
else else
{ {
const long nreg = m.get_long(104); const long nreg = m.get_long(108);
if (nreg != gm._numreg) if (nreg != gm._numreg)
return f.error_box("Modificare il movimento %ld", nreg); return f.error_box("Modificare il movimento %ld", nreg);
} }
@ -734,6 +722,11 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
bool TGame_mask::nuovo_handler(TMask_field& f, KEY k) bool TGame_mask::nuovo_handler(TMask_field& f, KEY k)
{ {
if (k == K_SPACE) if (k == K_SPACE)
{
int anno;
TString16 numero;
// Graffa tattica per distruggere la maschera new_game alla fine del blocco
{ {
TMask new_game("Nuova partita", 1, 24, 5); TMask new_game("Nuova partita", 1, 24, 5);
new_game.add_number(P_ANNO, 0, "Anno ", 1, 1, 4, "A"); new_game.add_number(P_ANNO, 0, "Anno ", 1, 1, 4, "A");
@ -753,12 +746,14 @@ bool TGame_mask::nuovo_handler(TMask_field& f, KEY k)
new_game.set(P_ANNO, cm.get(F_ANNORIF)); new_game.set(P_ANNO, cm.get(F_ANNORIF));
new_game.set(P_NUMERO, cm.get(F_NUMRIF)); new_game.set(P_NUMERO, cm.get(F_NUMRIF));
} }
k = new_game.run();
anno = new_game.get_int(P_ANNO);
numero = new_game.get(P_NUMERO);
}
if (new_game.run() == K_ENTER) if (k == K_ENTER)
{ {
TGame_mask& gm = (TGame_mask&)f.mask(); TGame_mask& gm = (TGame_mask&)f.mask();
const int anno = new_game.get_int(P_ANNO);
const TString16 numero(new_game.get(P_NUMERO));
TPartita& game = app().partite().partita(gm.conto(), anno, numero); TPartita& game = app().partite().partita(gm.conto(), anno, numero);
if (game.ok()) if (game.ok())
return error_box("La partita %d %s esiste gia'.", anno, (const char*)numero); return error_box("La partita %d %s esiste gia'.", anno, (const char*)numero);
@ -768,14 +763,12 @@ bool TGame_mask::nuovo_handler(TMask_field& f, KEY k)
const int nrigp = gm.nuovo_pagamento(game, nriga, nrata); const int nrigp = gm.nuovo_pagamento(game, nriga, nrata);
gm.edit_pagamento(game, nriga, nrata, nrigp); gm.edit_pagamento(game, nriga, nrata, nrigp);
if (game.ok()) if (game.ok())
{
game.write();
gm.fill_partite(anno, numero); // Aggiorna sheet partite gm.fill_partite(anno, numero); // Aggiorna sheet partite
}
else else
app().partite().destroy(gm.conto(), anno, numero); app().partite().destroy(gm.conto(), anno, numero);
} }
} }
return TRUE; return TRUE;
} }
@ -897,6 +890,13 @@ void TGame_mask::fill_partite(int annorif, const char* numrif)
app().begin_wait(); app().begin_wait();
for (TPartita* gioco = app().partite().first(); gioco != NULL; gioco = app().partite().next())
{
const int added = update_partita(*gioco, -1);
if (first_game < 0 && gioco->anno() == annorif && gioco->numero() == numrif)
first_game = added;
}
TLocalisamfile partita(LF_PARTITE); TLocalisamfile partita(LF_PARTITE);
partita.zero(); partita.zero();
if (conto().tipo() > ' ') // Ignora gruppo e conto dei clifo if (conto().tipo() > ' ') // Ignora gruppo e conto dei clifo
@ -915,28 +915,20 @@ void TGame_mask::fill_partite(int annorif, const char* numrif)
const int anno = partita.get_int(PART_ANNO); const int anno = partita.get_int(PART_ANNO);
const TString16 num(partita.get(PART_NUMPART)); const TString16 num(partita.get(PART_NUMPART));
TPartita* game = NULL; if (!app().partite().exist(conto(), anno, num))
bool should_delete_game = FALSE;
if (app().partite().exist(conto(), anno, num))
game = &app().partite().partita(conto(), anno, num);
else
{ {
game = new TPartita(conto(), anno, num); TPartita game(conto(), anno, num);
should_delete_game = TRUE;
int added = -1;
if (all || !game.chiusa())
added = update_partita(game, -1);
if (first_game < 0 && added >= 0 && anno == annorif && num == numrif)
first_game = added;
} }
int added = -1;
if (all || (!game->chiusa() || game->mov2rig(_numreg, 0) > 0))
added = update_partita(*game, -1);
if (first_game < 0 && added >= 0 && anno == annorif && num == numrif)
first_game = added;
if (should_delete_game)
delete game;
partita.put(PART_NRIGA, 9999); // Forza lettura partita successiva nella prossima read partita.put(PART_NRIGA, 9999); // Forza lettura partita successiva nella prossima read
} }
update_saldo_clifo(); update_saldo_clifo();
partite().force_update(); partite().force_update();
aggiorna_residuo(); aggiorna_residuo();
@ -957,8 +949,8 @@ void TGame_mask::fill_partite(int annorif, const char* numrif)
bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) const bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) const
{ {
const TRectype& oldpag = p.pagamento(nriga, nrata, nrigp); TRectype oldpag = p.pagamento(nriga, nrata, nrigp);
TRiga_partite& somma = p.riga(nrigp); TRiga_partite& somma = p.riga(nrigp);
TPay_mask m; TPay_mask m;
@ -966,14 +958,14 @@ bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) co
if (nriga != TPartita::UNASSIGNED) if (nriga != TPartita::UNASSIGNED)
{ {
const TRiga_scadenze& scaden = p.rata(nriga, nrata); const TRiga_scadenze& scaden = p.rata(nriga, nrata);
m.set_pag(oldpag, scaden); m.set_pag(oldpag, scaden, _importo);
} }
else else
{ {
nriga = p.primo_pagamento(); nriga = p.primo_pagamento();
TRiga_partite& riga = p.riga(nriga); TRiga_partite& riga = p.riga(nriga);
TRiga_scadenze& scaden = riga.new_row(); TRiga_scadenze& scaden = riga.new_row();
m.set_pag(oldpag, scaden); m.set_pag(oldpag, scaden, _importo);
riga.destroy_rows(); riga.destroy_rows();
} }
m.set(S_DESCAGG, somma.get(PART_DESCR)); m.set(S_DESCAGG, somma.get(PART_DESCR));
@ -991,14 +983,14 @@ bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) co
else else
somma.put(PART_DESCR, m.get(S_DESCAGG)); // Aggiorna descrizione (comune ai pagamenti) somma.put(PART_DESCR, m.get(S_DESCAGG)); // Aggiorna descrizione (comune ai pagamenti)
TRectype new_pag(oldpag); TRectype newpag(oldpag);
m.get_pag(new_pag); m.get_pag(newpag);
const TValuta val; // Non cambiare valuta! const TValuta val; // Non cambiare valuta!
#ifdef __EXTRA__ #ifdef __EXTRA__
p.modifica_pagamento(new_pag, val); p.modifica_pagamento(newpag, val);
#else #else
app().notify_edit_pagamento(p, new_pag, val); app().notify_edit_pagamento(p, newpag, val);
#endif #endif
} }
@ -1009,15 +1001,14 @@ else
// Edit delle partite // Edit delle partite
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
bool TPrimanota_application::edit_partite(int riga) bool TPrimanota_application::edit_partite(const TMask& m, int riga)
{ {
TToken_string& cgr = cgs().row(riga); const TImporto imp = get_cgs_imp(riga);
TImporto imp; imp = cgr;
if (imp.is_zero()) // Esci se 'importo e' nullo if (imp.is_zero()) // Esci se 'importo e' nullo
return FALSE; return FALSE;
const TBill b(cgr, 2, 0x3); // Legge il conto della riga selezionata TBill b; // Legge il conto della riga selezionata
b.set(m.get_int(104), m.get_int(105), m.get_long(106), m.get(103)[0]);
if (!b.ok()) if (!b.ok())
return FALSE; // Esci se il conto della riga cliente non e' valido return FALSE; // Esci se il conto della riga cliente non e' valido
@ -1029,6 +1020,7 @@ bool TPrimanota_application::edit_partite(int riga)
TGame_mask mask(b, mov.get_long(MOV_NUMREG), riga+1); TGame_mask mask(b, mov.get_long(MOV_NUMREG), riga+1);
mask.run(); mask.run();
cgs().force_update(); // Aggiornamento righe contabili cgs().force_update(); // Aggiornamento righe contabili
calcola_saldo();
return TRUE; return TRUE;
} }

View File

@ -382,7 +382,6 @@ END
BUTTON 100 9 2 BUTTON 100 9 2
BEGIN BEGIN
PROMPT -44 -1 "Partite" PROMPT -44 -1 "Partite"
MESSAGE EXIT,K_DEL
END END

View File

@ -164,7 +164,7 @@ END
STRING FLD_CODLIN 1 STRING FLD_CODLIN 1
BEGIN BEGIN
PROMPT 48 17 "Codice lingua" PROMPT 50 17 "Codice lingua "
HELP "Lingua di riferimento per rendiconti contabili" HELP "Lingua di riferimento per rendiconti contabili"
FIELD CodLin FIELD CodLin
USE %LNG USE %LNG

View File

@ -623,9 +623,9 @@ bool TPartita::read(const TBill& clifo, int year, const char* num)
} }
str.cut(0); str << clifo.sottoconto(); str.cut(0); str << clifo.sottoconto();
partita->renum_key(PART_SOTTOCONTO, str); // Sottoconto o codice clifo partita->renum_key(PART_SOTTOCONTO, str); // Sottoconto o codice clifo
str.cut(0); str << anno(); str.cut(0); str << _anno;
partita->renum_key(PART_ANNO, str); // Anno partita partita->renum_key(PART_ANNO, str); // Anno partita
partita->renum_key(PART_NUMPART, num); // Numero partita partita->renum_key(PART_NUMPART, _num); // Numero partita
_part.read(partita); _part.read(partita);
TRectype* unas = new TRectype(LF_PAGSCA); // Record pagamenti non assegnati TRectype* unas = new TRectype(LF_PAGSCA); // Record pagamenti non assegnati