Magnifiche correzioni al saldaconto
git-svn-id: svn://10.65.10.50/trunk@1940 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c4c1549aed
commit
6398370de6
@ -28,15 +28,17 @@ TMask* TPrimanota_application::load_mask(int n)
|
||||
if (_msk[n] != NULL)
|
||||
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
|
||||
if (_msk[d] != NULL)
|
||||
for (int i = 3; i >= 0; i--)
|
||||
{
|
||||
delete _msk[d];
|
||||
_msk[d] = NULL;
|
||||
if (_msk[i] != NULL)
|
||||
{
|
||||
delete _msk[i];
|
||||
_msk[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TFilename name("cg2100"); name << char(n == 3 ? 'o' : 'a'+n);
|
||||
TMask* m = new TMask(name);
|
||||
@ -133,7 +135,7 @@ TMask* TPrimanota_application::load_mask(int n)
|
||||
m->set_handler(O_CODICE, occas_code_handler);
|
||||
break;
|
||||
default:
|
||||
CHECKD(0, "Che cavolo di maschera e' la ", n);
|
||||
CHECKD(0, "Che ca$$o di maschera e' la ", n);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -938,7 +940,7 @@ bool TPrimanota_application::remove()
|
||||
{
|
||||
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();
|
||||
}
|
||||
else
|
||||
@ -1017,11 +1019,16 @@ void TPrimanota_application::genera_incasso(const char* causimm)
|
||||
if (m.run() == K_SAVE)
|
||||
{
|
||||
TMovimentoPN inc; // Nuovo movimento di incasso immediato
|
||||
TRectype& curr = inc.curr();
|
||||
curr.zero();
|
||||
m.autosave(&inc);
|
||||
|
||||
inc.lfile().zero();
|
||||
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 TString16 datareg = m.get(F_DATAREG);
|
||||
@ -1040,7 +1047,7 @@ void TPrimanota_application::genera_incasso(const char* causimm)
|
||||
r.put("TIPOC", m.get(F_CLIFO));
|
||||
r.put("GRUPPO", m.get(F_GRUPPOCLIFO));
|
||||
r.put("CONTO", m.get(F_CONTOCLIFO));
|
||||
|
||||
|
||||
short clifo_id;
|
||||
switch (m.get(F_CLIFO)[0])
|
||||
{
|
||||
|
@ -631,7 +631,7 @@ SPREADSHEET F_SHEETIVA 0 7
|
||||
BEGIN
|
||||
PROMPT 0 4 ""
|
||||
ITEM "Imponibile@15"
|
||||
ITEM "Iva@4"
|
||||
ITEM "Iva@5"
|
||||
ITEM "Det@1"
|
||||
ITEM "Imposta@15"
|
||||
ITEM "CR@1"
|
||||
|
@ -122,13 +122,13 @@ BEGIN
|
||||
PROMPT 0 11 ""
|
||||
ITEM "Riga"
|
||||
ITEM "Rata"
|
||||
ITEM "Data doc.@10"
|
||||
ITEM "Num. reg."
|
||||
ITEM "Data reg.@10"
|
||||
ITEM "Data scad."
|
||||
ITEM "Data doc.@10"
|
||||
ITEM "Descrizione@20"
|
||||
ITEM "Importo Lire@14"
|
||||
ITEM "Importo Valuta@14"
|
||||
ITEM "Descrizione@50"
|
||||
ITEM "Num. reg."
|
||||
ITEM "Data reg.@10"
|
||||
ITEM "Num. doc."
|
||||
ITEM "Prot. IVA"
|
||||
ITEM "Pagamento"
|
||||
@ -140,11 +140,6 @@ BEGIN
|
||||
PROMPT 1 -1 "Mostra tutte le partite"
|
||||
END
|
||||
|
||||
BUTTON P_SCAMBIO 28
|
||||
BEGIN
|
||||
PROMPT 40 -1 "Num. reg. <-> Num. doc."
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
||||
@ -212,16 +207,16 @@ ENDPAGE
|
||||
ENDMASK
|
||||
|
||||
|
||||
PAGE "Sheet Scadenze" -1 -1 66 10
|
||||
PAGE "Sheet Scadenze" -1 -1 68 10
|
||||
|
||||
NUMBER 101 4
|
||||
STRING 101 4
|
||||
BEGIN
|
||||
PROMPT 1 1 "Numero riga "
|
||||
END
|
||||
|
||||
NUMBER 102 4
|
||||
STRING 102 4
|
||||
BEGIN
|
||||
PROMPT 30 1 "Numero rata "
|
||||
PROMPT 41 1 "Numero rata "
|
||||
END
|
||||
|
||||
NUMBER 112 4
|
||||
@ -229,50 +224,50 @@ BEGIN
|
||||
PROMPT 1 2 "Riga pagamento "
|
||||
END
|
||||
|
||||
DATE 103
|
||||
DATE 104
|
||||
BEGIN
|
||||
PROMPT 30 2 "Data documento "
|
||||
PROMPT 41 2 "Data documento "
|
||||
END
|
||||
|
||||
NUMBER 104 5
|
||||
NUMBER 108 5
|
||||
BEGIN
|
||||
PROMPT 1 3 "Numero reg. "
|
||||
PROMPT 1 3 "Numero reg. "
|
||||
END
|
||||
|
||||
DATE 105
|
||||
DATE 109
|
||||
BEGIN
|
||||
PROMPT 30 3 "Data reg. "
|
||||
PROMPT 41 3 "Data reg. "
|
||||
END
|
||||
|
||||
NUMBER 110 5
|
||||
BEGIN
|
||||
PROMPT 1 4 "Numero doc. "
|
||||
PROMPT 1 4 "Numero doc. "
|
||||
END
|
||||
|
||||
NUMBER 111 5
|
||||
BEGIN
|
||||
PROMPT 30 5 "Protocollo IVA "
|
||||
PROMPT 41 5 "Protocollo IVA "
|
||||
END
|
||||
|
||||
DATE 106
|
||||
DATE 103
|
||||
BEGIN
|
||||
PROMPT 30 4 "Data scad. "
|
||||
PROMPT 41 4 "Data scad. "
|
||||
END
|
||||
|
||||
STRING 109 50
|
||||
STRING 105 50
|
||||
BEGIN
|
||||
PROMPT 1 6 "Descrizione "
|
||||
PROMPT 1 6 "Descrizione "
|
||||
END
|
||||
|
||||
STRING 106 14
|
||||
BEGIN
|
||||
PROMPT 1 7 "Importo Lire "
|
||||
FLAGS "R"
|
||||
END
|
||||
|
||||
STRING 107 14
|
||||
BEGIN
|
||||
PROMPT 1 7 "Importo Lire "
|
||||
FLAGS "R"
|
||||
END
|
||||
|
||||
STRING 108 14
|
||||
BEGIN
|
||||
PROMPT 30 7 "Importo Valuta "
|
||||
PROMPT 37 7 "Importo Valuta "
|
||||
FLAGS "R"
|
||||
END
|
||||
|
||||
|
@ -260,10 +260,16 @@ int TMovimentoPN::remove(TDate&)
|
||||
|
||||
if (err == NOERR)
|
||||
err = _iva.remove();
|
||||
|
||||
|
||||
if (err == NOERR)
|
||||
err = TRelation::remove();
|
||||
|
||||
if (err == NOERR)
|
||||
{
|
||||
const TDate datareg(curr().get("DATAREG"));
|
||||
controlla_liquidazione(datareg, TRUE);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -227,13 +227,14 @@ void TPrimanota_application::set_cgs_imp(int n, const TImporto& imp)
|
||||
TSheet_field& s = cgs();
|
||||
imp.add_to(s.row(n), 0);
|
||||
s.force_update(n);
|
||||
|
||||
TMask& m = s.sheet_mask();
|
||||
if (m.is_running() && s.selected() == n)
|
||||
{
|
||||
m.set(101, imp.sezione() == 'D' ? imp.valore().string() : "");
|
||||
m.set(102, imp.sezione() == 'A' ? imp.valore().string() : "");
|
||||
}
|
||||
/*
|
||||
TMask& m = s.sheet_mask();
|
||||
if (m.is_running() && s.selected() == n)
|
||||
{
|
||||
m.set(101, imp.sezione() == 'D' ? imp.valore().string() : "");
|
||||
m.set(102, imp.sezione() == 'A' ? imp.valore().string() : "");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// 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%
|
||||
bool TPrimanota_application::add_cgs_imp(int n, const TImporto& imp)
|
||||
{
|
||||
TImporto tot;
|
||||
tot = cgs().row(n);
|
||||
tot += imp;
|
||||
set_cgs_imp(n, tot.normalize());
|
||||
TImporto tot(get_cgs_imp(n));
|
||||
tot += imp;
|
||||
tot.normalize();
|
||||
set_cgs_imp(n, tot);
|
||||
return tot.is_zero();
|
||||
}
|
||||
|
||||
// Certified 90%
|
||||
bool TPrimanota_application::sub_cgs_imp(int n, const TImporto& imp)
|
||||
{
|
||||
TImporto tot;
|
||||
tot = cgs().row(n);
|
||||
TImporto tot(get_cgs_imp(n));
|
||||
tot -= imp;
|
||||
tot.normalize();
|
||||
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
|
||||
void TPrimanota_application::disable_cgs_cells(int n, char tipo)
|
||||
{
|
||||
TSheet_field& cg = cgs();
|
||||
|
||||
int first = 0, last = 0;
|
||||
switch(tipo)
|
||||
{
|
||||
@ -315,9 +317,14 @@ void TPrimanota_application::disable_cgs_cells(int n, char tipo)
|
||||
case 'S': // Ritenute Sociali
|
||||
case 'T': // Totale documento
|
||||
last = 3;
|
||||
if (!causale().corrispettivi())
|
||||
{
|
||||
cg.disable_cell(n, 5);
|
||||
cg.disable_cell(n, 6);
|
||||
}
|
||||
break;
|
||||
case 'K': // Riga cliente/fornitore per saldaconto
|
||||
if (get_cgs_imp(n).is_zero())
|
||||
if (n == cg.items()-1)
|
||||
break;
|
||||
first = 2;
|
||||
case 'I':
|
||||
@ -328,17 +335,8 @@ void TPrimanota_application::disable_cgs_cells(int n, char tipo)
|
||||
break;
|
||||
}
|
||||
|
||||
if (last > 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
for (int i = first; i < last; i++)
|
||||
cg.disable_cell(n, i);
|
||||
}
|
||||
|
||||
void TPrimanota_application::reset_sheet_row(TSheet_field& s, int n)
|
||||
@ -506,10 +504,8 @@ real TPrimanota_application::calcola_saldo() const
|
||||
|
||||
if (pag)
|
||||
{
|
||||
const char sez = causale().sezione(1);
|
||||
saldaconto.normalize(sez);
|
||||
real t(m.get(F_TOTALE));
|
||||
t -= saldaconto.valore();
|
||||
t -= saldaconto.normalize().valore();
|
||||
m.set(K_RESIDUO, t.string());
|
||||
}
|
||||
|
||||
@ -575,13 +571,15 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
|
||||
}
|
||||
|
||||
if (paga)
|
||||
{
|
||||
real t(f.mask().get(F_TOTALE));
|
||||
t -= saldaconto.valore();
|
||||
if (!t.is_zero())
|
||||
{
|
||||
const char* ss = saldaconto.valore().string(".");
|
||||
return f.error_box("Il totale documento deve essere %s", ss);
|
||||
{
|
||||
const real totdoc(f.mask().get(F_TOTALE));
|
||||
const real valore = saldaconto.normalize().valore();
|
||||
if (totdoc != valore)
|
||||
{
|
||||
const TString16 td(totdoc.string("."));
|
||||
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
|
||||
app().sub_cgs_imp(s, growth);
|
||||
app().calcola_saldo();
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -768,9 +767,12 @@ bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
|
||||
const int k = tipo == 'K' ? 1 : 10;
|
||||
TBill conto; app().causale().bill(k, conto);
|
||||
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')
|
||||
{
|
||||
{
|
||||
for (int i = 0; i < r; i++)
|
||||
{
|
||||
const TToken_string& row = cg.row(i);
|
||||
@ -778,6 +780,7 @@ bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
|
||||
{
|
||||
cg.swap_rows(r, i);
|
||||
cg.force_update();
|
||||
cg.select(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ protected:
|
||||
void remove_scadenze(const TMask& m, const char* rif);
|
||||
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(int numrig);
|
||||
@ -231,7 +231,7 @@ public:
|
||||
TPartite_array& partite() { return _partite; } // Partite editate
|
||||
bool edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp);
|
||||
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& ivas() const;
|
||||
|
@ -557,7 +557,7 @@ bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k)
|
||||
|
||||
if (k == K_SPACE)
|
||||
{
|
||||
const bool ok = app().edit_partite(riga);
|
||||
const bool ok = app().edit_partite(m, riga);
|
||||
if (ok)
|
||||
k = K_ENTER;
|
||||
}
|
||||
@ -581,8 +581,8 @@ bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k)
|
||||
|
||||
|
||||
// deleting significato
|
||||
// -1 non sto cancellando nulla
|
||||
// 0 sto cancellando tutto
|
||||
// -1 sto cancellando tutto
|
||||
// 0 non sto cancellando nulla
|
||||
// 1 sto cancellando la prima riga contabile
|
||||
// n sto cancellando la ennesima riga contabile
|
||||
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 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 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,
|
||||
new_ap, new_abbuono, new_diffcam);
|
||||
|
||||
if (deleting != 0)
|
||||
if (deleting >= 0)
|
||||
{
|
||||
// Se c'e' differenza negli abbuoni
|
||||
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);
|
||||
}
|
||||
}
|
||||
} // if (deleting != 0)
|
||||
} // if (deleting >= 0)
|
||||
|
||||
return empty;
|
||||
}
|
||||
@ -772,7 +772,7 @@ bool TPrimanota_application::notify_cgline_deletion(int numrig)
|
||||
{
|
||||
bool found = FALSE;
|
||||
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);
|
||||
return found;
|
||||
}
|
208
cg/cg2105.cpp
208
cg/cg2105.cpp
@ -23,14 +23,14 @@
|
||||
|
||||
class TPay_mask : public TMask
|
||||
{
|
||||
real _da_pagare;
|
||||
real _da_pagare, _pagabile;
|
||||
TValuta _valuta;
|
||||
|
||||
protected:
|
||||
static bool importo_handler(TMask_field& f, KEY k);
|
||||
|
||||
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;
|
||||
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
|
||||
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);
|
||||
res.set_decimals(in_valuta ? 2 : 0);
|
||||
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
|
||||
_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 int nrigp = oldpag.get_int(PAGSCA_NRIGP);
|
||||
const TRiga_partite& sum = p.riga(nrigp);
|
||||
_valuta.get(sum);
|
||||
|
||||
const long numreg = sum.get_long(PART_NREG);
|
||||
const int numrig = sum.get_int(PART_NUMRIG);
|
||||
#ifdef __EXTRA__
|
||||
TImporto residuo(app().curr_mask().get(F_TOTALE));
|
||||
#else
|
||||
TImporto residuo(app().get_cgs_imp(numrig-1));
|
||||
#endif
|
||||
residuo -= app().partite().importo_speso(numreg, numrig);
|
||||
set(S_RESIDUOPAG, residuo.valore().string());
|
||||
_valuta.get(sum);
|
||||
|
||||
TReal_field& resp = (TReal_field&)field(S_RESIDUOPAG);
|
||||
resp.set_decimals(in_valuta ? 2 : 0);
|
||||
TImporto r(importo);
|
||||
r -= app().partite().importo_speso(numreg, numrig);
|
||||
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
|
||||
bool sa = oldpag.get_int(PAGSCA_NRIGA) != TPartita::UNASSIGNED;
|
||||
@ -125,8 +129,9 @@ bool TPay_mask::importo_handler(TMask_field& f, KEY k)
|
||||
TPay_mask& m = (TPay_mask&)f.mask();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -138,6 +143,9 @@ bool TPay_mask::importo_handler(TMask_field& f, KEY k)
|
||||
|
||||
const real residuo(m._da_pagare - i);
|
||||
m.set(S_RESIDUORATA, residuo.string());
|
||||
|
||||
const real residuopag(m._pagabile - i);
|
||||
m.set(S_RESIDUOPAG, residuopag.string());
|
||||
|
||||
if (f.dlg() == S_IMPORTOVAL)
|
||||
{
|
||||
@ -158,6 +166,7 @@ class TGame_mask : public TMask
|
||||
const TBill _conto; // Conto fisso del cliente/fornitore
|
||||
long _numreg; // Numero movimento contabile
|
||||
int _numrig; // Riga contabile corrente (prima = 1!)
|
||||
TImporto _importo; // Importo riga contabile
|
||||
int _riga_partite; // Riga corrente delle partite
|
||||
|
||||
protected:
|
||||
@ -165,7 +174,6 @@ protected:
|
||||
static bool numpart_handler(TMask_field& f, 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 scambio_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 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_NUMERO, numpart_handler);
|
||||
set_handler(P_SHOWALL, show_all_handler);
|
||||
set_handler(P_SCAMBIO, scambio_handler);
|
||||
set_handler(P_NUOVO, nuovo_handler);
|
||||
set_handler(P_CAMBIO, cambio_handler);
|
||||
|
||||
@ -277,18 +284,6 @@ bool TGame_mask::show_all_handler(TMask_field& f, KEY k)
|
||||
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)
|
||||
{
|
||||
if (k == K_TAB && f.focusdirty() &&
|
||||
@ -306,15 +301,16 @@ bool TGame_mask::cambio_handler(TMask_field& f, KEY k)
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
real TGame_mask::aggiorna_residuo()
|
||||
{
|
||||
#ifdef __EXTRA__
|
||||
TImporto residuo(app().curr_mask().get(F_TOTALE));
|
||||
{
|
||||
#ifdef EXTRA
|
||||
return ZERO;
|
||||
#else
|
||||
TImporto residuo(app().get_cgs_imp(_numrig-1));
|
||||
#endif
|
||||
_importo = app().get_cgs_imp(_numrig-1);
|
||||
TImporto residuo(_importo);
|
||||
residuo -= app().partite().importo_speso(_numreg, _numrig);
|
||||
set(P_RESIDUO, residuo.valore().string());
|
||||
return residuo.valore();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool TGame_mask::cerca_valuta(TValuta& val) const
|
||||
@ -377,11 +373,10 @@ void TGame_mask::aggiorna_valuta(const TValuta& val)
|
||||
|
||||
if (annorif != 0)
|
||||
{
|
||||
const bool proponi =
|
||||
#ifdef __EXTRA__
|
||||
TRUE;
|
||||
const bool proponi = RUE;
|
||||
#else
|
||||
app().causale().tipomov() == 2;
|
||||
const bool proponi = app().causale().tipomov() == 2;
|
||||
#endif
|
||||
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(""));
|
||||
row.add(ri);
|
||||
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(riga.get(PART_DATADOC));
|
||||
row.add(riga.get(PART_DESCR));
|
||||
add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTO)));
|
||||
if (in_valuta)
|
||||
add_importo(row, TImporto(riga.sezione(), scad.get_real(SCAD_IMPORTOVAL)), 2);
|
||||
else
|
||||
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_PROTIVA));
|
||||
|
||||
@ -457,18 +452,16 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
TToken_string& row = scadenze.row(scadenze.add(""));
|
||||
row.add(ri);
|
||||
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(sum.get(PART_DATADOC));
|
||||
row.add(sum.get(PART_DESCR));
|
||||
add_importo(row, TImporto(sez, pag.get_real(PAGSCA_IMPORTO)));
|
||||
if (in_valuta)
|
||||
add_importo(row, TImporto(sez, pag.get_real(PAGSCA_IMPORTOVAL)), 2);
|
||||
else
|
||||
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("");
|
||||
row.add(pa);
|
||||
@ -478,7 +471,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
if (!abb.is_zero())
|
||||
{
|
||||
TToken_string& rabb = scadenze.row(scadenze.add(""));
|
||||
rabb.add("", 5);
|
||||
rabb.add("Abbuoni rata ", 4); rabb << ra;
|
||||
if (in_valuta)
|
||||
{
|
||||
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);
|
||||
rabb.add("");
|
||||
}
|
||||
rabb.add("Abbuoni rata ", 8); rabb << ra;
|
||||
}
|
||||
|
||||
if (in_valuta)
|
||||
@ -498,17 +490,15 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
if (!diff.is_zero())
|
||||
{
|
||||
TToken_string& rdiff = scadenze.row(scadenze.add(""));
|
||||
rdiff.add("", 5);
|
||||
rdiff.add("Differenza cambio rata ", 4); rdiff << ra;
|
||||
add_importo(rdiff, diff.normalize());
|
||||
rdiff.add("Differenza cambio rata ", 8); rdiff << ra;
|
||||
}
|
||||
}
|
||||
|
||||
TToken_string& rsal = scadenze.row(scadenze.add(""));
|
||||
rsal.add("Saldo rata ", 4); rsal << ra;
|
||||
if (!scad.chiusa())
|
||||
{
|
||||
rsal.add("", 5);
|
||||
|
||||
TImporto sl(scad.residuo(FALSE, 0x7));
|
||||
sl.normalize();
|
||||
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.normalize();
|
||||
tot_val += sl;
|
||||
add_importo(rsal, sl, 2);
|
||||
tot_val += sl;
|
||||
}
|
||||
}
|
||||
rsal.add("Saldo rata ", 8); rsal << ra;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
TToken_string& row = scadenze.row(scadenze.add(""));
|
||||
row.add(pag.get(PAGSCA_NRIGA));
|
||||
row.add(pag.get(PAGSCA_NRATA));
|
||||
row.add("9999|9999| ");
|
||||
row.add(sum.get(PART_DATADOC));
|
||||
row.add(sum.get(PART_NREG));
|
||||
row.add(sum.get(PART_DATAREG));
|
||||
row.add("");
|
||||
|
||||
row.add(sum.get(PART_DESCR));
|
||||
TImporto i(sum.sezione(), pag.get_real(PAGSCA_IMPORTO));
|
||||
i.normalize();
|
||||
tot_lit += i;
|
||||
@ -554,18 +539,21 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
}
|
||||
else
|
||||
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("");
|
||||
row.add(pa);
|
||||
}
|
||||
}
|
||||
|
||||
TToken_string& sp = scadenze.row(scadenze.add(""));
|
||||
sp.add("", 5);
|
||||
add_importo(sp, tot_lit.normalize());
|
||||
add_importo(sp, tot_val.normalize(), 2);
|
||||
sp.add("Saldo partita", 8);
|
||||
if (lastrow > 0)
|
||||
{
|
||||
TToken_string& sp = scadenze.row(scadenze.add(""));
|
||||
sp.add("Saldo partita ", 4); sp << anno << ' ' << num;
|
||||
add_importo(sp, tot_lit.normalize());
|
||||
add_importo(sp, tot_val.normalize(), 2);
|
||||
}
|
||||
|
||||
gm.scadenze().force_update();
|
||||
if (should_delete_game)
|
||||
@ -715,7 +703,7 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
|
||||
}
|
||||
else
|
||||
{
|
||||
const long nreg = m.get_long(104);
|
||||
const long nreg = m.get_long(108);
|
||||
if (nreg != gm._numreg)
|
||||
return f.error_box("Modificare il movimento %ld", nreg);
|
||||
}
|
||||
@ -734,7 +722,12 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
|
||||
bool TGame_mask::nuovo_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
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);
|
||||
new_game.add_number(P_ANNO, 0, "Anno ", 1, 1, 4, "A");
|
||||
new_game.add_string(P_NUMERO, 0, "Partita ", 1, 2, 7, "U");
|
||||
@ -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_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();
|
||||
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);
|
||||
if (game.ok())
|
||||
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);
|
||||
gm.edit_pagamento(game, nriga, nrata, nrigp);
|
||||
if (game.ok())
|
||||
{
|
||||
game.write();
|
||||
gm.fill_partite(anno, numero); // Aggiorna sheet partite
|
||||
}
|
||||
else
|
||||
app().partite().destroy(gm.conto(), anno, numero);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -896,6 +889,13 @@ void TGame_mask::fill_partite(int annorif, const char* numrif)
|
||||
a.destroy();
|
||||
|
||||
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);
|
||||
partita.zero();
|
||||
@ -915,28 +915,20 @@ void TGame_mask::fill_partite(int annorif, const char* numrif)
|
||||
const int anno = partita.get_int(PART_ANNO);
|
||||
const TString16 num(partita.get(PART_NUMPART));
|
||||
|
||||
TPartita* game = NULL;
|
||||
bool should_delete_game = FALSE;
|
||||
if (app().partite().exist(conto(), anno, num))
|
||||
game = &app().partite().partita(conto(), anno, num);
|
||||
else
|
||||
if (!app().partite().exist(conto(), anno, num))
|
||||
{
|
||||
game = new TPartita(conto(), anno, num);
|
||||
should_delete_game = TRUE;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
TPartita game(conto(), anno, num);
|
||||
|
||||
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;
|
||||
}
|
||||
partita.put(PART_NRIGA, 9999); // Forza lettura partita successiva nella prossima read
|
||||
}
|
||||
|
||||
update_saldo_clifo();
|
||||
partite().force_update();
|
||||
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
|
||||
{
|
||||
const TRectype& oldpag = p.pagamento(nriga, nrata, nrigp);
|
||||
TRiga_partite& somma = p.riga(nrigp);
|
||||
TRectype oldpag = p.pagamento(nriga, nrata, nrigp);
|
||||
TRiga_partite& somma = p.riga(nrigp);
|
||||
|
||||
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)
|
||||
{
|
||||
const TRiga_scadenze& scaden = p.rata(nriga, nrata);
|
||||
m.set_pag(oldpag, scaden);
|
||||
m.set_pag(oldpag, scaden, _importo);
|
||||
}
|
||||
else
|
||||
{
|
||||
nriga = p.primo_pagamento();
|
||||
TRiga_partite& riga = p.riga(nriga);
|
||||
TRiga_scadenze& scaden = riga.new_row();
|
||||
m.set_pag(oldpag, scaden);
|
||||
m.set_pag(oldpag, scaden, _importo);
|
||||
riga.destroy_rows();
|
||||
}
|
||||
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
|
||||
somma.put(PART_DESCR, m.get(S_DESCAGG)); // Aggiorna descrizione (comune ai pagamenti)
|
||||
|
||||
TRectype new_pag(oldpag);
|
||||
m.get_pag(new_pag);
|
||||
TRectype newpag(oldpag);
|
||||
m.get_pag(newpag);
|
||||
|
||||
const TValuta val; // Non cambiare valuta!
|
||||
#ifdef __EXTRA__
|
||||
p.modifica_pagamento(new_pag, val);
|
||||
p.modifica_pagamento(newpag, val);
|
||||
#else
|
||||
app().notify_edit_pagamento(p, new_pag, val);
|
||||
app().notify_edit_pagamento(p, newpag, val);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1009,15 +1001,14 @@ else
|
||||
// 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);
|
||||
|
||||
TImporto imp; imp = cgr;
|
||||
const TImporto imp = get_cgs_imp(riga);
|
||||
if (imp.is_zero()) // Esci se 'importo e' nullo
|
||||
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())
|
||||
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);
|
||||
mask.run();
|
||||
cgs().force_update(); // Aggiornamento righe contabili
|
||||
calcola_saldo();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -382,7 +382,6 @@ END
|
||||
BUTTON 100 9 2
|
||||
BEGIN
|
||||
PROMPT -44 -1 "Partite"
|
||||
MESSAGE EXIT,K_DEL
|
||||
END
|
||||
|
||||
|
||||
|
@ -164,7 +164,7 @@ END
|
||||
|
||||
STRING FLD_CODLIN 1
|
||||
BEGIN
|
||||
PROMPT 48 17 "Codice lingua"
|
||||
PROMPT 50 17 "Codice lingua "
|
||||
HELP "Lingua di riferimento per rendiconti contabili"
|
||||
FIELD CodLin
|
||||
USE %LNG
|
||||
|
@ -623,9 +623,9 @@ bool TPartita::read(const TBill& clifo, int year, const char* num)
|
||||
}
|
||||
str.cut(0); str << clifo.sottoconto();
|
||||
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_NUMPART, num); // Numero partita
|
||||
partita->renum_key(PART_NUMPART, _num); // Numero partita
|
||||
_part.read(partita);
|
||||
|
||||
TRectype* unas = new TRectype(LF_PAGSCA); // Record pagamenti non assegnati
|
||||
|
Loading…
x
Reference in New Issue
Block a user