Gestione note di credito
git-svn-id: svn://10.65.10.50/trunk@1818 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
662b7d8bba
commit
8d43a014c7
@ -235,24 +235,24 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
|||||||
m->efield(F_DATADOC).check_type(dob ? CHECK_REQUIRED : CHECK_NORMAL); // Data doc. obbligatoria
|
m->efield(F_DATADOC).check_type(dob ? CHECK_REQUIRED : CHECK_NORMAL); // Data doc. obbligatoria
|
||||||
m->enable(F_PROVVISORIO, !_is_saldaconto); // Il saldaconto vieta i movimenti provvisori
|
m->enable(F_PROVVISORIO, !_is_saldaconto); // Il saldaconto vieta i movimenti provvisori
|
||||||
|
|
||||||
|
const bool nota_credito = _is_saldaconto && causale().tipomov() == 2;
|
||||||
|
const bool show_games = is_pagamento() || nota_credito;
|
||||||
|
TMask& cgm = cgs().sheet_mask();
|
||||||
|
cgm.set_handler(100, show_games ? showpartite_handler : NULL); // bottoncino riga
|
||||||
|
cgm.enable(100, show_games);
|
||||||
if (iva == nessuna_iva)
|
if (iva == nessuna_iva)
|
||||||
{
|
{
|
||||||
TMask& cgm = cgs().sheet_mask();
|
m->show(S_TIPORIGA, is_pagamento());
|
||||||
cgm.set_handler(100, _is_saldaconto ? showpartite_handler : NULL); // bottoncino riga
|
|
||||||
cgm.enable(100, _is_saldaconto);
|
|
||||||
m->show(S_TIPORIGA, _is_saldaconto);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// m->enable_page(2, m->get(F_NUMRIF).empty());
|
m->efield(F_CODPAG).check_type(_is_saldaconto ? CHECK_REQUIRED : CHECK_NORMAL);
|
||||||
|
m->efield(F_CODPAG).enable(!nota_credito);
|
||||||
m->efield(F_CODPAG).check_type(_is_saldaconto ? CHECK_REQUIRED : CHECK_NORMAL); // Cod. pag. obbligatorio
|
|
||||||
|
|
||||||
|
m->enable_page(2, _is_saldaconto && !nota_credito);
|
||||||
m->show(F_ANNORIF, _is_saldaconto); // Mostra/nasconde anno e riferimento partita
|
m->show(F_ANNORIF, _is_saldaconto); // Mostra/nasconde anno e riferimento partita
|
||||||
m->show(F_NUMRIF, _is_saldaconto);
|
m->show(F_NUMRIF, _is_saldaconto);
|
||||||
|
|
||||||
// m->enable(F_ANNORIF, ins); // Dis/abilita anno e riferimento partita
|
|
||||||
// m->enable(F_NUMRIF, ins);
|
|
||||||
m->field(F_NUMRIF).set_justify(iva == iva_acquisti ? _num_for : _num_cli);
|
m->field(F_NUMRIF).set_justify(iva == iva_acquisti ? _num_for : _num_cli);
|
||||||
|
|
||||||
const bool av = causale().reg().agenzia_viaggi();
|
const bool av = causale().reg().agenzia_viaggi();
|
||||||
@ -350,13 +350,6 @@ bool TPrimanota_application::changing_mask(int mode)
|
|||||||
#if XVT_OS == XVT_OS_WIN
|
#if XVT_OS == XVT_OS_WIN
|
||||||
if (flag && !_sheet_shown)
|
if (flag && !_sheet_shown)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if (iva() != nessuna_iva)
|
|
||||||
{
|
|
||||||
curr_mask().show_page(2);
|
|
||||||
do_events();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
curr_mask().show_page(1);
|
curr_mask().show_page(1);
|
||||||
do_events();
|
do_events();
|
||||||
_sheet_shown = TRUE;
|
_sheet_shown = TRUE;
|
||||||
@ -652,8 +645,8 @@ int TPrimanota_application::read(TMask& m)
|
|||||||
if (to_swap) imposta = -imposta;
|
if (to_swap) imposta = -imposta;
|
||||||
if (imponibile.sign() * imposta.sign() < 0)
|
if (imponibile.sign() * imposta.sign() < 0)
|
||||||
{
|
{
|
||||||
warning_box("Registrazione con imponibile e imposta con segni discordi:\n"
|
error_box("Registrazione con imponibile e imposta con segni discordi:\n"
|
||||||
"assegnato il segno dell'imponibile");
|
"assegnato il segno dell'imponibile");
|
||||||
imposta = -imposta;
|
imposta = -imposta;
|
||||||
}
|
}
|
||||||
riga.add(imposta.string()); // Imposta 104
|
riga.add(imposta.string()); // Imposta 104
|
||||||
@ -663,10 +656,10 @@ int TPrimanota_application::read(TMask& m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
calcola_imp(); // Calcola totale imponibile ed imposte
|
calcola_imp(); // Calcola totale imponibile ed imposte
|
||||||
TString16 dt(m.get(F_DATAREG));
|
|
||||||
|
|
||||||
if (!m.get(F_NUMRIF).empty())
|
if (is_saldaconto() && causale().tipomov() != 2) // Ci sono scadenze
|
||||||
{
|
{
|
||||||
|
const TString16 dt(m.get(F_DATAREG));
|
||||||
set_numrif(m.get(F_NUMRIF));
|
set_numrif(m.get(F_NUMRIF));
|
||||||
set_pagamento(m.get(F_CODPAG), dt);
|
set_pagamento(m.get(F_CODPAG), dt);
|
||||||
if (!read_scadenze(m))
|
if (!read_scadenze(m))
|
||||||
@ -848,6 +841,8 @@ int TPrimanota_application::write(const TMask& m)
|
|||||||
_saldi.registra();
|
_saldi.registra();
|
||||||
check_saldi();
|
check_saldi();
|
||||||
|
|
||||||
|
bool salvaconto = FALSE;
|
||||||
|
|
||||||
if (iva() != nessuna_iva)
|
if (iva() != nessuna_iva)
|
||||||
{
|
{
|
||||||
causale().reg().reread(); // Aggiorna protocollo IVA
|
causale().reg().reread(); // Aggiorna protocollo IVA
|
||||||
@ -865,15 +860,20 @@ int TPrimanota_application::write(const TMask& m)
|
|||||||
genera_incasso(causimm); // Genera incasso immediato
|
genera_incasso(causimm); // Genera incasso immediato
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (causale().tipomov() == 2)
|
||||||
|
salvaconto = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (is_saldaconto())
|
salvaconto = is_pagamento();
|
||||||
{
|
}
|
||||||
const long old_nreg = numreg - (lasterr == _isreinsert ? 1 : 0);
|
|
||||||
partite().update_reg(_rel->lfile().curr(), old_nreg);
|
if (salvaconto)
|
||||||
partite().rewrite();
|
{
|
||||||
}
|
const long old_nreg = numreg - (lasterr == _isreinsert ? 1 : 0);
|
||||||
|
partite().update_reg(_rel->lfile().curr(), old_nreg);
|
||||||
|
partite().rewrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
link_m770();
|
link_m770();
|
||||||
@ -895,14 +895,23 @@ int TPrimanota_application::rewrite(const TMask& m)
|
|||||||
|
|
||||||
if (_is_saldaconto)
|
if (_is_saldaconto)
|
||||||
{
|
{
|
||||||
|
bool salvaconto = FALSE;
|
||||||
if (iva() != nessuna_iva)
|
if (iva() != nessuna_iva)
|
||||||
{
|
{
|
||||||
write_scadenze(m);
|
if (causale().tipomov() == 2)
|
||||||
|
salvaconto = TRUE;
|
||||||
|
else
|
||||||
|
write_scadenze(m);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_partite.update_reg(_rel->lfile().curr());
|
salvaconto = is_pagamento();
|
||||||
_partite.rewrite();
|
}
|
||||||
|
|
||||||
|
if (salvaconto)
|
||||||
|
{
|
||||||
|
partite().update_reg(_rel->lfile().curr());
|
||||||
|
partite().rewrite();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1164,6 +1173,24 @@ long TPrimanota_application::calcola_m770(int tipo_coll, real& spese, real& comp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tipo_coll == 4)
|
||||||
|
{
|
||||||
|
TBill zio; causale().bill(2, zio);
|
||||||
|
|
||||||
|
TString_array& rcg = cgs().rows_array();
|
||||||
|
for (int i = 0; i < rcg.items(); i++)
|
||||||
|
{
|
||||||
|
TToken_string& r = rcg.row(i);
|
||||||
|
const TBill bill(r, 3, 0x0);
|
||||||
|
if (zio == bill)
|
||||||
|
{
|
||||||
|
TImporto imp; imp = r;
|
||||||
|
ritfis = imp.valore();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return forn;
|
return forn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1212,7 +1239,7 @@ bool TPrimanota_application::link_m770()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
tipo_coll = 4;
|
calcola_m770(tipo_coll = 4, spese, compenso, imposte, ritenute);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
calcola_m770(tipo_coll = 6, spese, compenso, imposte, ritenute);
|
calcola_m770(tipo_coll = 6, spese, compenso, imposte, ritenute);
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#define S_NUMDOC 106
|
#define S_NUMDOC 106
|
||||||
#define S_DESCR 107
|
#define S_DESCR 107
|
||||||
#define S_RATA 108
|
#define S_RATA 108
|
||||||
#define S_DATASCAD 109
|
#define S_DATA_SCAD 109
|
||||||
#define S_IMPORTO_SCAD 110
|
#define S_IMPORTO_SCAD 110
|
||||||
#define S_IMPORTOVAL_SCAD 111
|
#define S_IMPORTOVAL_SCAD 111
|
||||||
#define S_SEZIONE_SCAD 112
|
#define S_SEZIONE_SCAD 112
|
||||||
@ -35,8 +35,7 @@
|
|||||||
#define S_IMPORTOVAL 115
|
#define S_IMPORTOVAL 115
|
||||||
#define S_SALDOACC 116
|
#define S_SALDOACC 116
|
||||||
#define S_RESIDUORATA 117
|
#define S_RESIDUORATA 117
|
||||||
#define S_DATAPAG 118
|
#define S_DATAPAG 119
|
||||||
#define S_CODPAG 119
|
|
||||||
#define S_TIPOPAG 120
|
#define S_TIPOPAG 120
|
||||||
#define S_TIPO 121
|
#define S_TIPO 121
|
||||||
#define S_GRUPPO 122
|
#define S_GRUPPO 122
|
||||||
|
@ -71,7 +71,6 @@ BEGIN
|
|||||||
OUTPUT P_DATACAMBIO D0
|
OUTPUT P_DATACAMBIO D0
|
||||||
OUTPUT P_CAMBIO R10
|
OUTPUT P_CAMBIO R10
|
||||||
GROUP 3
|
GROUP 3
|
||||||
CHECKTYPE NORMAL
|
|
||||||
END
|
END
|
||||||
|
|
||||||
NUMBER P_CAMBIO 15 5
|
NUMBER P_CAMBIO 15 5
|
||||||
@ -93,6 +92,7 @@ END
|
|||||||
STRING P_NUMERO 7
|
STRING P_NUMERO 7
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 21 3 "Numero "
|
PROMPT 21 3 "Numero "
|
||||||
|
FLAGS "U"
|
||||||
END
|
END
|
||||||
|
|
||||||
NUMBER P_RESIDUO 15
|
NUMBER P_RESIDUO 15
|
||||||
@ -236,7 +236,7 @@ END
|
|||||||
|
|
||||||
NUMBER 104 5
|
NUMBER 104 5
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 1 3 "Numero reg. "
|
PROMPT 1 3 "Numero reg. "
|
||||||
END
|
END
|
||||||
|
|
||||||
DATE 105
|
DATE 105
|
||||||
@ -246,7 +246,7 @@ 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
|
||||||
@ -256,7 +256,7 @@ END
|
|||||||
|
|
||||||
DATE 106
|
DATE 106
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 30 4 "Data scad. "
|
PROMPT 30 4 "Data scad. "
|
||||||
END
|
END
|
||||||
|
|
||||||
STRING 109 50
|
STRING 109 50
|
||||||
|
@ -56,7 +56,7 @@ BEGIN
|
|||||||
FIELD NRATA
|
FIELD NRATA
|
||||||
END
|
END
|
||||||
|
|
||||||
DATE S_DATASCAD
|
DATE S_DATA_SCAD
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 57 1 "Scadenza "
|
PROMPT 57 1 "Scadenza "
|
||||||
FLAGS "D"
|
FLAGS "D"
|
||||||
@ -152,6 +152,7 @@ BEGIN
|
|||||||
PROMPT 38 8 "Ritenute professionali "
|
PROMPT 38 8 "Ritenute professionali "
|
||||||
PICTURE "."
|
PICTURE "."
|
||||||
FIELD RITENUTE
|
FIELD RITENUTE
|
||||||
|
GROUP 2
|
||||||
END
|
END
|
||||||
|
|
||||||
LIST S_SALDOACC 1 12
|
LIST S_SALDOACC 1 12
|
||||||
@ -160,6 +161,7 @@ BEGIN
|
|||||||
ITEM "A|Acconto"
|
ITEM "A|Acconto"
|
||||||
ITEM "S|Saldo"
|
ITEM "S|Saldo"
|
||||||
FIELD ACCSAL
|
FIELD ACCSAL
|
||||||
|
GROUP 2
|
||||||
END
|
END
|
||||||
|
|
||||||
LIST S_TIPOPAG 2 35
|
LIST S_TIPOPAG 2 35
|
||||||
@ -178,6 +180,12 @@ BEGIN
|
|||||||
FIELD TIPOPAG
|
FIELD TIPOPAG
|
||||||
END
|
END
|
||||||
|
|
||||||
|
DATE S_DATAPAG
|
||||||
|
BEGIN
|
||||||
|
PROMPT 2 11 "Data pag. "
|
||||||
|
FIELD DATAPAG
|
||||||
|
END
|
||||||
|
|
||||||
TEXT DLG_NULL
|
TEXT DLG_NULL
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 2 12 "@bContropartita"
|
PROMPT 2 12 "@bContropartita"
|
||||||
@ -197,12 +205,14 @@ NUMBER S_GRUPPO 3
|
|||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 24 12 "Gruppo "
|
PROMPT 24 12 "Gruppo "
|
||||||
FIELD GRUPPOC
|
FIELD GRUPPOC
|
||||||
|
GROUP 2
|
||||||
END
|
END
|
||||||
|
|
||||||
NUMBER S_CONTO 3
|
NUMBER S_CONTO 3
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 42 12 "Conto "
|
PROMPT 42 12 "Conto "
|
||||||
FIELD CONTOC
|
FIELD CONTOC
|
||||||
|
GROUP 2
|
||||||
END
|
END
|
||||||
|
|
||||||
NUMBER S_SOTTOCONTO 6
|
NUMBER S_SOTTOCONTO 6
|
||||||
@ -223,6 +233,7 @@ BEGIN
|
|||||||
OUTPUT S_DESCRCONTO DESCR
|
OUTPUT S_DESCRCONTO DESCR
|
||||||
CHECKTYPE NORMAL
|
CHECKTYPE NORMAL
|
||||||
VALIDATE REQIF_FUNC 1 S_IMPORTO
|
VALIDATE REQIF_FUNC 1 S_IMPORTO
|
||||||
|
GROUP 2
|
||||||
END
|
END
|
||||||
|
|
||||||
STRING S_DESCRCONTO 50
|
STRING S_DESCRCONTO 50
|
||||||
@ -236,6 +247,7 @@ BEGIN
|
|||||||
DISPLAY "Sottoconto" SOTTOCONTO
|
DISPLAY "Sottoconto" SOTTOCONTO
|
||||||
COPY OUTPUT S_SOTTOCONTO
|
COPY OUTPUT S_SOTTOCONTO
|
||||||
CHECKTYPE REQUIRED
|
CHECKTYPE REQUIRED
|
||||||
|
GROUP 2
|
||||||
END
|
END
|
||||||
|
|
||||||
STRING S_CODDESC 5
|
STRING S_CODDESC 5
|
||||||
|
@ -417,7 +417,7 @@ HIDDEN bool can_remove(TToken_string& s)
|
|||||||
void TPrimanota_application::cgs_pack()
|
void TPrimanota_application::cgs_pack()
|
||||||
{
|
{
|
||||||
TString_array& rows = cgs().rows_array();
|
TString_array& rows = cgs().rows_array();
|
||||||
const bool pagamento = is_saldaconto() && iva() == nessuna_iva;
|
const bool pagamento = is_pagamento();
|
||||||
|
|
||||||
for (int i = rows.items()-1; i >= 0; i--)
|
for (int i = rows.items()-1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
@ -497,7 +497,9 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const long numreg = f.mask().get_long(F_NUMREG);
|
const long numreg = f.mask().get_long(F_NUMREG);
|
||||||
const bool paga = app().is_saldaconto() && app().iva() == nessuna_iva ;
|
const bool paga = app().is_pagamento();
|
||||||
|
const bool nota = app().is_saldaconto() && app().causale().tipomov() == 2;
|
||||||
|
|
||||||
TImporto saldaconto;
|
TImporto saldaconto;
|
||||||
|
|
||||||
TSheet_field& cg = app().cgs();
|
TSheet_field& cg = app().cgs();
|
||||||
@ -517,13 +519,13 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
|
|||||||
return f.error_box("La contropartita della riga %d non e' completa", i+1);
|
return f.error_box("La contropartita della riga %d non e' completa", i+1);
|
||||||
empty = FALSE;
|
empty = FALSE;
|
||||||
|
|
||||||
if (paga)
|
if (paga || nota)
|
||||||
{
|
{
|
||||||
const char tipo = row_type(r);
|
const char tipo = row_type(r);
|
||||||
if (tipo == 'K')
|
if (tipo == 'K' || tipo == 'T')
|
||||||
{
|
{
|
||||||
const int currig = i+1;
|
const int currig = i+1;
|
||||||
const TImporto speso = app().partite().importo_speso(numreg, currig, TRUE);
|
const TImporto speso = app().partite().importo_speso(numreg, currig);
|
||||||
if (importo != speso)
|
if (importo != speso)
|
||||||
{
|
{
|
||||||
const char* ss = speso.valore().string(".");
|
const char* ss = speso.valore().string(".");
|
||||||
@ -721,7 +723,7 @@ bool TPrimanota_application::cg_notify(TSheet_field& cg, int r, KEY k)
|
|||||||
app().calcola_saldo();
|
app().calcola_saldo();
|
||||||
break;
|
break;
|
||||||
case K_INS:
|
case K_INS:
|
||||||
if (app().iva() == nessuna_iva && app().is_saldaconto())
|
if (app().is_pagamento())
|
||||||
{
|
{
|
||||||
const char tipo = app().curr_mask().get(S_TIPORIGA)[0];
|
const char tipo = app().curr_mask().get(S_TIPORIGA)[0];
|
||||||
if (tipo == 'K' || tipo == 'G')
|
if (tipo == 'K' || tipo == 'G')
|
||||||
@ -779,6 +781,17 @@ bool TPrimanota_application::descr_handler(TMask_field& f, KEY k)
|
|||||||
// Scrivendo qualcosa in dare (101) cancella l'importo in avere (102) e viceversa
|
// Scrivendo qualcosa in dare (101) cancella l'importo in avere (102) e viceversa
|
||||||
bool TPrimanota_application::dareavere_handler(TMask_field& f, KEY k)
|
bool TPrimanota_application::dareavere_handler(TMask_field& f, KEY k)
|
||||||
{
|
{
|
||||||
|
if (k == K_F8 && app().is_pagamento())
|
||||||
|
{
|
||||||
|
const long numreg = app().curr_mask().get_long(F_NUMREG);
|
||||||
|
const int numrig = app().cgs().selected()+1;
|
||||||
|
const TImporto speso = app().partite().importo_speso(numreg, numrig);
|
||||||
|
const char* ss = speso.valore().string();
|
||||||
|
TMask& m = f.mask();
|
||||||
|
m.set(101, speso.sezione() == 'D' ? ss : "");
|
||||||
|
m.set(102, speso.sezione() == 'A' ? ss : "");
|
||||||
|
}
|
||||||
|
|
||||||
if (k == K_TAB && f.focusdirty() && f.get().not_empty())
|
if (k == K_TAB && f.focusdirty() && f.get().not_empty())
|
||||||
{
|
{
|
||||||
const int id = 203-f.dlg(); // Calcola id del campo da resettare
|
const int id = 203-f.dlg(); // Calcola id del campo da resettare
|
||||||
|
@ -163,6 +163,7 @@ protected:
|
|||||||
bool gestione_saldaconto() const { return _ges_sal; }
|
bool gestione_saldaconto() const { return _ges_sal; }
|
||||||
bool is_saldaconto() const { return _is_saldaconto; }
|
bool is_saldaconto() const { return _is_saldaconto; }
|
||||||
void set_saldaconto(bool b) { _is_saldaconto = b; }
|
void set_saldaconto(bool b) { _is_saldaconto = b; }
|
||||||
|
bool is_pagamento() const { return is_saldaconto() && iva() == nessuna_iva; }
|
||||||
bool npart_is_prot() { return _npart_is_prot; }
|
bool npart_is_prot() { return _npart_is_prot; }
|
||||||
|
|
||||||
void fill_sheet(TMask& m) const;
|
void fill_sheet(TMask& m) const;
|
||||||
@ -182,7 +183,6 @@ protected:
|
|||||||
TBill& ivas_bill(TBill& tc);
|
TBill& ivas_bill(TBill& tc);
|
||||||
|
|
||||||
bool read_caus(const char* cod, int year);
|
bool read_caus(const char* cod, int year);
|
||||||
TCausale& causale() { return *_causale; }
|
|
||||||
TLibro_giornale& giornale() { return *_giornale; }
|
TLibro_giornale& giornale() { return *_giornale; }
|
||||||
|
|
||||||
bool test_swap(bool ritsoc);
|
bool test_swap(bool ritsoc);
|
||||||
@ -229,6 +229,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
static char row_type(const TToken_string& s);
|
static char row_type(const TToken_string& s);
|
||||||
|
|
||||||
|
TCausale& causale() { return *_causale; }
|
||||||
TPartite_array& partite() { return _partite; } // Partite editate
|
TPartite_array& partite() { return _partite; } // Partite editate
|
||||||
int nuovo_pagamento(TPartita& p, int nriga, int rata, int rmov);
|
int nuovo_pagamento(TPartita& p, int nriga, int rata, int rmov);
|
||||||
bool edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp);
|
bool edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp);
|
||||||
|
232
cg/cg2105.cpp
232
cg/cg2105.cpp
@ -35,14 +35,14 @@ protected:
|
|||||||
static void add_importo(TToken_string& s, const TImporto& i, int dec = 0);
|
static void add_importo(TToken_string& s, const TImporto& i, int dec = 0);
|
||||||
TImporto get_importo(TToken_string& s, int pos) const;
|
TImporto get_importo(TToken_string& s, int pos) const;
|
||||||
|
|
||||||
void fill_partite() const;
|
void fill_partite(int anno = 0, const char* numero = "");
|
||||||
real aggiorna_residuo();
|
real aggiorna_residuo();
|
||||||
|
|
||||||
void update_partita(const TPartita& game, int prow) const;
|
int update_partita(const TPartita& game, int prow);
|
||||||
void update_saldo_clifo() const;
|
void update_saldo_clifo();
|
||||||
|
|
||||||
bool cerca_valuta(TValuta& val) const;
|
bool cerca_valuta(TValuta& val) const;
|
||||||
void aggiorna_valuta(const TValuta& val) const;
|
void aggiorna_valuta(const TValuta& val);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TSheet_field& partite() const { return (TSheet_field&)field(P_PARTITE); }
|
TSheet_field& partite() const { return (TSheet_field&)field(P_PARTITE); }
|
||||||
@ -54,7 +54,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+1)
|
: TMask("cg2100p"), _conto(bill), _numreg(numreg), _numrig(riga)
|
||||||
{
|
{
|
||||||
const char tipocf[2] = { _conto.tipo(), '\0' };
|
const char tipocf[2] = { _conto.tipo(), '\0' };
|
||||||
set(P_TIPOC, tipocf);
|
set(P_TIPOC, tipocf);
|
||||||
@ -85,8 +85,6 @@ TGame_mask::TGame_mask(const TBill& bill, long numreg, int riga)
|
|||||||
|
|
||||||
partite().set_notify(partite_notify);
|
partite().set_notify(partite_notify);
|
||||||
scadenze().sheet_mask().set_handler(100, edit_scadenza_handler);
|
scadenze().sheet_mask().set_handler(100, edit_scadenza_handler);
|
||||||
|
|
||||||
aggiorna_residuo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
@ -137,7 +135,7 @@ bool TGame_mask::show_all_handler(TMask_field& f, KEY k)
|
|||||||
{
|
{
|
||||||
if (k == K_SPACE)
|
if (k == K_SPACE)
|
||||||
{
|
{
|
||||||
const TGame_mask& gm = (const TGame_mask&)f.mask();
|
TGame_mask& gm = (TGame_mask&)f.mask();
|
||||||
gm.fill_partite();
|
gm.fill_partite();
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -160,7 +158,7 @@ bool TGame_mask::cambio_handler(TMask_field& f, KEY k)
|
|||||||
if (k == K_TAB && f.focusdirty() &&
|
if (k == K_TAB && f.focusdirty() &&
|
||||||
yesno_box("Aggiornare gli importi dei pagamenti?"))
|
yesno_box("Aggiornare gli importi dei pagamenti?"))
|
||||||
{
|
{
|
||||||
const TGame_mask& gm = (const TGame_mask&)f.mask();
|
TGame_mask& gm = (TGame_mask&)f.mask();
|
||||||
TValuta val; val.get(gm, P_VALUTA, P_DATACAMBIO, P_CAMBIO);
|
TValuta val; val.get(gm, P_VALUTA, P_DATACAMBIO, P_CAMBIO);
|
||||||
gm.aggiorna_valuta(val);
|
gm.aggiorna_valuta(val);
|
||||||
}
|
}
|
||||||
@ -174,7 +172,7 @@ bool TGame_mask::cambio_handler(TMask_field& f, KEY k)
|
|||||||
real TGame_mask::aggiorna_residuo()
|
real TGame_mask::aggiorna_residuo()
|
||||||
{
|
{
|
||||||
TImporto residuo(app().get_cgs_imp(_numrig-1));
|
TImporto residuo(app().get_cgs_imp(_numrig-1));
|
||||||
residuo -= app().partite().importo_speso(_numreg, _numrig, TRUE);
|
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();
|
||||||
}
|
}
|
||||||
@ -197,9 +195,10 @@ bool TGame_mask::cerca_valuta(TValuta& val) const
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TGame_mask::aggiorna_valuta(const TValuta& val) const
|
void TGame_mask::aggiorna_valuta(const TValuta& val)
|
||||||
{
|
{
|
||||||
bool found = FALSE;
|
int annorif = 0;
|
||||||
|
TString16 numrif;
|
||||||
|
|
||||||
TPartite_array& pa = app().partite();
|
TPartite_array& pa = app().partite();
|
||||||
for (TPartita* game = pa.first(); game; game = pa.next())
|
for (TPartita* game = pa.first(); game; game = pa.next())
|
||||||
@ -216,7 +215,11 @@ void TGame_mask::aggiorna_valuta(const TValuta& val) const
|
|||||||
if (sum.get_long(PART_NREG) == _numreg &&
|
if (sum.get_long(PART_NREG) == _numreg &&
|
||||||
sum.get_int(PART_NUMRIG) == _numrig)
|
sum.get_int(PART_NUMRIG) == _numrig)
|
||||||
{
|
{
|
||||||
found = TRUE;
|
if (annorif == 0)
|
||||||
|
{
|
||||||
|
annorif = sum.get_int(PART_ANNO);
|
||||||
|
numrif = sum.get(PART_NUMPART);
|
||||||
|
}
|
||||||
TRectype pag(scad.row(p));
|
TRectype pag(scad.row(p));
|
||||||
real imp(pag.get(PAGSCA_IMPORTOVAL));
|
real imp(pag.get(PAGSCA_IMPORTOVAL));
|
||||||
val.val2lit(imp);
|
val.val2lit(imp);
|
||||||
@ -228,8 +231,21 @@ void TGame_mask::aggiorna_valuta(const TValuta& val) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found)
|
if (annorif != 0)
|
||||||
fill_partite();
|
{
|
||||||
|
const bool nota_credito = app().causale().tipomov() == 2;
|
||||||
|
if (nota_credito)
|
||||||
|
{
|
||||||
|
const TMask& cm = app().curr_mask();
|
||||||
|
const int anno = cm.get_int(F_ANNORIF);
|
||||||
|
if (anno != 0)
|
||||||
|
{
|
||||||
|
annorif = anno;
|
||||||
|
numrif = cm.get(F_NUMRIF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fill_partite(annorif, numrif);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||||
@ -430,15 +446,12 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
|
|||||||
int nrigp = m.get_int(112);
|
int nrigp = m.get_int(112);
|
||||||
if (nrigp == 0)
|
if (nrigp == 0)
|
||||||
{
|
{
|
||||||
const int rmov = app().cgs().selected()+1;
|
nrigp = app().nuovo_pagamento(game, nriga, nrata, gm._numrig);
|
||||||
nrigp = app().nuovo_pagamento(game, nriga, nrata, rmov);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const TMask& cm = app().curr_mask();
|
|
||||||
const long cur_reg = cm.get_long(F_NUMREG);
|
|
||||||
const long nreg = m.get_long(104);
|
const long nreg = m.get_long(104);
|
||||||
if (cur_reg != nreg)
|
if (nreg != gm._numreg)
|
||||||
return f.error_box("Modificare il movimento %ld", nreg);
|
return f.error_box("Modificare il movimento %ld", nreg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,7 +461,6 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
|
|||||||
{
|
{
|
||||||
gm.update_partita(game, gm._riga_partite);
|
gm.update_partita(game, gm._riga_partite);
|
||||||
partite_notify(gm.partite(), gm._riga_partite, K_TAB);
|
partite_notify(gm.partite(), gm._riga_partite, K_TAB);
|
||||||
gm.aggiorna_residuo();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -461,11 +473,18 @@ bool TGame_mask::nuovo_handler(TMask_field& f, KEY k)
|
|||||||
{
|
{
|
||||||
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");
|
||||||
new_game.add_string(P_NUMERO, 0, "Partita ", 1, 2, 7);
|
new_game.add_string(P_NUMERO, 0, "Partita ", 1, 2, 7, "U");
|
||||||
new_game.add_button(DLG_OK, 0, "" , -12, 3, 8, 2);
|
new_game.add_button(DLG_OK, 0, "" , -12, 3, 8, 2);
|
||||||
new_game.add_button(DLG_CANCEL, 0, "" , -22, 3, 8, 2);
|
new_game.add_button(DLG_CANCEL, 0, "" , -22, 3, 8, 2);
|
||||||
new_game.first_focus(P_NUMERO);
|
new_game.first_focus(P_NUMERO);
|
||||||
|
|
||||||
|
if (app().causale().tipomov() == 2)
|
||||||
|
{
|
||||||
|
const TMask& cm = app().curr_mask();
|
||||||
|
new_game.set(P_ANNO, cm.get(F_ANNORIF));
|
||||||
|
new_game.set(P_NUMERO, cm.get(F_NUMRIF));
|
||||||
|
}
|
||||||
|
|
||||||
if (new_game.run() == K_ENTER)
|
if (new_game.run() == K_ENTER)
|
||||||
{
|
{
|
||||||
TGame_mask& gm = (TGame_mask&)f.mask();
|
TGame_mask& gm = (TGame_mask&)f.mask();
|
||||||
@ -482,9 +501,7 @@ bool TGame_mask::nuovo_handler(TMask_field& f, KEY k)
|
|||||||
if (game.ok())
|
if (game.ok())
|
||||||
{
|
{
|
||||||
game.write();
|
game.write();
|
||||||
gm.send_key(K_SPACE, P_SHOWALL); // Aggiorna sheet partite
|
gm.fill_partite(anno, numero); // Aggiorna sheet partite
|
||||||
gm.set(P_ANNO, anno);
|
|
||||||
gm.set(P_NUMERO, numero, TRUE); // Selezione nuova partita
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
app().partite().destroy(gm.conto(), anno, numero);
|
app().partite().destroy(gm.conto(), anno, numero);
|
||||||
@ -518,37 +535,53 @@ TImporto TGame_mask::get_importo(TToken_string& s, int pos) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TGame_mask::update_partita(const TPartita& game, int prow) const
|
int TGame_mask::update_partita(const TPartita& game, int prow)
|
||||||
{
|
{
|
||||||
TImporto saldo, doc, pag, imp;
|
TImporto saldo, doc, pag, imp;
|
||||||
game.calcola_saldo(saldo, doc, pag, imp);
|
game.calcola_saldo(saldo, doc, pag, imp);
|
||||||
|
|
||||||
|
TSheet_field& games = partite();
|
||||||
|
|
||||||
int riga_fatt = game.prima_fattura();
|
int riga_fatt = game.prima_fattura();
|
||||||
if (riga_fatt <= 0) riga_fatt = game.first(); // E' un anticipo
|
if (riga_fatt <= 0) riga_fatt = game.first(); // E' un anticipo
|
||||||
const TRiga_partite& riga = game.riga(riga_fatt);
|
|
||||||
|
|
||||||
TToken_string &r = partite().row(prow); // Stringa di lavoro per lo sheet
|
TToken_string &r = games.row(prow); // Stringa di lavoro per lo sheet
|
||||||
r.cut(0);
|
if (game.esiste(riga_fatt)) // Esiste veramente
|
||||||
r.add(riga.get(PART_ANNO));
|
{
|
||||||
r.add(riga.get(PART_NUMPART));
|
const TRiga_partite& riga = game.riga(riga_fatt);
|
||||||
r.add(riga.get(PART_DATADOC));
|
r.cut(0);
|
||||||
r.add(riga.get(PART_NUMDOC));
|
r.add(riga.get(PART_ANNO));
|
||||||
add_importo(r, saldo);
|
r.add(riga.get(PART_NUMPART));
|
||||||
add_importo(r, doc);
|
r.add(riga.get(PART_DATADOC));
|
||||||
add_importo(r, pag);
|
r.add(riga.get(PART_NUMDOC));
|
||||||
add_importo(r, imp);
|
add_importo(r, saldo);
|
||||||
r.add(riga.get(PART_DESCR));
|
add_importo(r, doc);
|
||||||
|
add_importo(r, pag);
|
||||||
|
add_importo(r, imp);
|
||||||
|
r.add(riga.get(PART_DESCR));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
r.add("", 4);
|
||||||
|
r.add("", 5);
|
||||||
|
r.add("", 6);
|
||||||
|
r.add("", 7);
|
||||||
|
}
|
||||||
|
|
||||||
if (prow >= 0)
|
if (prow >= 0)
|
||||||
{
|
{
|
||||||
TSheet_field& games = partite();
|
|
||||||
games.force_update(prow);
|
games.force_update(prow);
|
||||||
update_saldo_clifo();
|
update_saldo_clifo();
|
||||||
games.force_update(games.items()-1);
|
games.force_update(games.items()-1);
|
||||||
|
aggiorna_residuo();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
prow = partite().items()-1;
|
||||||
|
|
||||||
|
return prow;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TGame_mask::update_saldo_clifo() const
|
void TGame_mask::update_saldo_clifo()
|
||||||
{
|
{
|
||||||
TString_array& s = partite().rows_array();
|
TString_array& s = partite().rows_array();
|
||||||
|
|
||||||
@ -584,10 +617,12 @@ void TGame_mask::update_saldo_clifo() const
|
|||||||
r << "fornitore";
|
r << "fornitore";
|
||||||
}
|
}
|
||||||
|
|
||||||
void TGame_mask::fill_partite() const
|
void TGame_mask::fill_partite(int annorif, const char* numrif)
|
||||||
{
|
{
|
||||||
const bool all = get(P_SHOWALL).not_empty();
|
const bool all = get(P_SHOWALL).not_empty();
|
||||||
|
|
||||||
|
int first_game = -1;
|
||||||
|
|
||||||
TString_array& a = partite().rows_array();
|
TString_array& a = partite().rows_array();
|
||||||
a.destroy();
|
a.destroy();
|
||||||
|
|
||||||
@ -602,7 +637,6 @@ void TGame_mask::fill_partite() const
|
|||||||
}
|
}
|
||||||
else conto().put(partita.curr()); // Scrive completamente i conti normali
|
else conto().put(partita.curr()); // Scrive completamente i conti normali
|
||||||
|
|
||||||
const long nreg = app().curr_mask().get_long(F_NUMREG);
|
|
||||||
const TRectype filter(partita.curr()); // Record campione
|
const TRectype filter(partita.curr()); // Record campione
|
||||||
|
|
||||||
for (int err = partita.read(_isgteq);
|
for (int err = partita.read(_isgteq);
|
||||||
@ -622,8 +656,12 @@ void TGame_mask::fill_partite() const
|
|||||||
should_delete_game = TRUE;
|
should_delete_game = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (all || (!game->chiusa() || game->mov2rig(nreg, 0) > 0))
|
int added = -1;
|
||||||
update_partita(*game, -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)
|
if (should_delete_game)
|
||||||
delete game;
|
delete game;
|
||||||
@ -632,9 +670,13 @@ void TGame_mask::fill_partite() const
|
|||||||
}
|
}
|
||||||
update_saldo_clifo();
|
update_saldo_clifo();
|
||||||
partite().force_update();
|
partite().force_update();
|
||||||
|
aggiorna_residuo();
|
||||||
|
|
||||||
if (a.items() > 0)
|
if (a.items() > 0)
|
||||||
partite_notify(partite(), 0, K_TAB);
|
{
|
||||||
|
if (first_game < 0) first_game = 0;
|
||||||
|
partite_notify(partite(), first_game, K_TAB);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
scadenze().destroy();
|
scadenze().destroy();
|
||||||
@ -681,7 +723,7 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad)
|
|||||||
set(S_NUMPROT, fatt.get(PART_PROTIVA)); // Protocollo IVA
|
set(S_NUMPROT, fatt.get(PART_PROTIVA)); // Protocollo IVA
|
||||||
set(S_DESCR, fatt.get(PART_DESCR)); // Descrizione documento
|
set(S_DESCR, fatt.get(PART_DESCR)); // Descrizione documento
|
||||||
|
|
||||||
set(S_DATASCAD, scad.get(SCAD_DATASCAD)); // Data della scadenza
|
set(S_DATA_SCAD, scad.get(SCAD_DATASCAD)); // Data della scadenza
|
||||||
set(S_SEZIONE_SCAD, scad.riga().sezione()); // Sezione della rata
|
set(S_SEZIONE_SCAD, scad.riga().sezione()); // Sezione della rata
|
||||||
set(S_IMPORTO_SCAD, scad.get(SCAD_IMPORTO)); // Importo della rata
|
set(S_IMPORTO_SCAD, scad.get(SCAD_IMPORTO)); // Importo della rata
|
||||||
set(S_IMPORTOVAL_SCAD, scad.get(SCAD_IMPORTOVAL)); // Importo in valuta
|
set(S_IMPORTOVAL_SCAD, scad.get(SCAD_IMPORTOVAL)); // Importo in valuta
|
||||||
@ -704,9 +746,14 @@ 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);
|
_valuta.get(sum);
|
||||||
|
|
||||||
|
const long numreg = sum.get_long(PART_NREG);
|
||||||
|
const int numrig = sum.get_int(PART_NUMRIG);
|
||||||
|
TImporto residuo(app().get_cgs_imp(numrig-1));
|
||||||
|
residuo -= app().partite().importo_speso(numreg, numrig);
|
||||||
|
set(S_RESIDUOPAG, residuo.valore().string());
|
||||||
|
|
||||||
// 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;
|
||||||
if (sa)
|
if (sa)
|
||||||
@ -715,7 +762,15 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad)
|
|||||||
const TDate datapag(sum.get(PART_DATADOC));
|
const TDate datapag(sum.get(PART_DATADOC));
|
||||||
sa = datapag >= datasca;
|
sa = datapag >= datasca;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hide(S_RESIDUORATA);
|
||||||
|
}
|
||||||
enable(S_SALDOACC, sa);
|
enable(S_SALDOACC, sa);
|
||||||
|
|
||||||
|
const bool nota_credito = app().causale().tipomov() == 2;
|
||||||
|
if (nota_credito)
|
||||||
|
send_key(K_CTRL + K_SHIFT + 'c', -2); // Disabilita contropartita e ritenute
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPay_mask::get_pag(TRectype& newpag) const
|
void TPay_mask::get_pag(TRectype& newpag) const
|
||||||
@ -764,31 +819,31 @@ bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k)
|
|||||||
bool ok = TRUE;
|
bool ok = TRUE;
|
||||||
TMask& m = f.mask();
|
TMask& m = f.mask();
|
||||||
|
|
||||||
if (m.get(116) == "K")
|
const char tipo = m.get(116)[0];
|
||||||
|
if (tipo == 'K' || (tipo == 'T' && app().causale().tipomov() == 2))
|
||||||
{
|
{
|
||||||
TSheet_field& s = *m.get_sheet();
|
TSheet_field& s = *m.get_sheet();
|
||||||
const int riga = s.selected();
|
const int riga = s.selected();
|
||||||
|
|
||||||
if (k == K_SPACE)
|
if (k == K_SPACE)
|
||||||
{
|
{
|
||||||
const bool dirty = app().edit_partite(riga);
|
const bool ok = app().edit_partite(riga);
|
||||||
if (dirty)
|
if (ok)
|
||||||
{
|
|
||||||
if (m.field(103).enabled())
|
|
||||||
app().disable_cgs_cells(riga, 'K');
|
|
||||||
k = K_ENTER;
|
k = K_ENTER;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k == K_ENTER)
|
if (k == K_ENTER)
|
||||||
{
|
{
|
||||||
const long curreg = app().curr_mask().get_long(F_NUMREG);
|
const long curreg = app().curr_mask().get_long(F_NUMREG);
|
||||||
const TImporto importo(app().get_cgs_imp(riga));
|
const TImporto importo(app().get_cgs_imp(riga));
|
||||||
const TImporto speso(app().partite().importo_speso(curreg, riga+1, TRUE));
|
const TImporto speso(app().partite().importo_speso(curreg, riga+1));
|
||||||
if (importo != speso)
|
if (importo != speso)
|
||||||
{
|
{
|
||||||
const char* ss = speso.valore().string(".");
|
const char* ss = speso.valore().string(".");
|
||||||
return f.error_box("L'importo deve essere %s %c", ss, speso.sezione());
|
return f.error_box("L'importo deve essere %s %c", ss, speso.sezione());
|
||||||
}
|
}
|
||||||
|
if (tipo == 'K' && !speso.is_zero())
|
||||||
|
app().disable_cgs_cells(riga, 'K');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
@ -798,8 +853,6 @@ bool TPrimanota_application::showpartite_handler(TMask_field& f, KEY k)
|
|||||||
bool TPrimanota_application::edit_partite(int riga)
|
bool TPrimanota_application::edit_partite(int riga)
|
||||||
{
|
{
|
||||||
TToken_string& cgr = cgs().row(riga);
|
TToken_string& cgr = cgs().row(riga);
|
||||||
if (row_type(cgr) != 'K')
|
|
||||||
return FALSE; // Esci se non c'e' nessun importo
|
|
||||||
|
|
||||||
TImporto imp; imp = cgr;
|
TImporto imp; imp = cgr;
|
||||||
if (imp.is_zero()) // Esci se 'importo e' nullo
|
if (imp.is_zero()) // Esci se 'importo e' nullo
|
||||||
@ -814,7 +867,7 @@ bool TPrimanota_application::edit_partite(int riga)
|
|||||||
partite().update_reg(mov);
|
partite().update_reg(mov);
|
||||||
|
|
||||||
// Esecuzione maschera di selezione partite
|
// Esecuzione maschera di selezione partite
|
||||||
TGame_mask mask(b, mov.get_long(MOV_NUMREG), riga);
|
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
|
||||||
|
|
||||||
@ -822,12 +875,12 @@ bool TPrimanota_application::edit_partite(int riga)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int TPrimanota_application::nuovo_pagamento(TPartita& partita, int nriga, int rata, int rmov)
|
int TPrimanota_application::nuovo_pagamento(TPartita& partita, int nriga, int rata, int numrig)
|
||||||
{
|
{
|
||||||
TBill conto; partita.conto(conto); // Legge conto principale
|
TBill conto; partita.conto(conto); // Legge conto principale
|
||||||
|
|
||||||
const long numreg = curr_mask().get_long(F_NUMREG);
|
const long numreg = curr_mask().get_long(F_NUMREG);
|
||||||
int nrigp = partita.mov2rig(numreg, rmov); // Cerca riga partita relativa alla riga rmov
|
int nrigp = partita.mov2rig(numreg, numrig); // Cerca riga partita relativa alla riga rmov
|
||||||
|
|
||||||
if (nrigp <= 0) // Devo creare una nuova riga di partita
|
if (nrigp <= 0) // Devo creare una nuova riga di partita
|
||||||
{
|
{
|
||||||
@ -836,7 +889,7 @@ int TPrimanota_application::nuovo_pagamento(TPartita& partita, int nriga, int ra
|
|||||||
|
|
||||||
// Copia dati movimento corrente
|
// Copia dati movimento corrente
|
||||||
part.put(PART_NREG, numreg); // Numero operazione
|
part.put(PART_NREG, numreg); // Numero operazione
|
||||||
part.put(PART_NUMRIG, rmov); // Riga su cui ho cliccato
|
part.put(PART_NUMRIG, numrig); // Riga su cui ho cliccato
|
||||||
part.put(PART_DATAREG, curr_mask().get(F_DATAREG));
|
part.put(PART_DATAREG, curr_mask().get(F_DATAREG));
|
||||||
part.put(PART_DATADOC, curr_mask().get(F_DATADOC));
|
part.put(PART_DATADOC, curr_mask().get(F_DATADOC));
|
||||||
part.put(PART_NUMDOC, curr_mask().get(F_NUMDOC));
|
part.put(PART_NUMDOC, curr_mask().get(F_NUMDOC));
|
||||||
@ -903,12 +956,14 @@ int TPrimanota_application::nuovo_pagamento(TPartita& partita, int nriga, int ra
|
|||||||
default:
|
default:
|
||||||
caus = 2; break;
|
caus = 2; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pagamento.put(PAGSCA_TIPOPAG, tp);
|
pagamento.put(PAGSCA_TIPOPAG, tp);
|
||||||
pagamento.put(PAGSCA_CODABIPR, scad.get(SCAD_CODABIPR));
|
pagamento.put(PAGSCA_CODABIPR, scad.get(SCAD_CODABIPR));
|
||||||
pagamento.put(PAGSCA_CODCABPR, scad.get(SCAD_CODCABPR));
|
pagamento.put(PAGSCA_CODCABPR, scad.get(SCAD_CODCABPR));
|
||||||
pagamento.put(PAGSCA_CODABI, scad.get(SCAD_CODABI));
|
pagamento.put(PAGSCA_CODABI, scad.get(SCAD_CODABI));
|
||||||
pagamento.put(PAGSCA_CODCAB, scad.get(SCAD_CODCAB));
|
pagamento.put(PAGSCA_CODCAB, scad.get(SCAD_CODCAB));
|
||||||
pagamento.put(PAGSCA_CODAG, scad.get(SCAD_CODAG));
|
pagamento.put(PAGSCA_CODAG, scad.get(SCAD_CODAG));
|
||||||
|
pagamento.put(PAGSCA_DATAPAG, curr_mask().get(F_DATADOC));
|
||||||
}
|
}
|
||||||
|
|
||||||
TBill contro; causale().bill(caus, contro); // Legge conto contropartita
|
TBill contro; causale().bill(caus, contro); // Legge conto contropartita
|
||||||
@ -937,19 +992,25 @@ int TPrimanota_application::nuovo_pagamento(TPartita& partita, int nriga, int ra
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// deleting significato
|
||||||
|
// -1 non sto cancellando nulla
|
||||||
|
// 0 sto cancellando tutto
|
||||||
|
// 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,
|
bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pag,
|
||||||
const TValuta& valuta, int deleting)
|
const TValuta& valuta, int deleting)
|
||||||
{
|
{
|
||||||
|
const int nriga = new_pag.get_int(PAGSCA_NRIGA); // Riga fattura
|
||||||
|
const int nrata = new_pag.get_int(PAGSCA_NRATA); // Numero rata
|
||||||
|
const int nrigp = new_pag.get_int(PAGSCA_NRIGP); // Riga pagamento
|
||||||
|
const TRectype& old_pag = p.pagamento(nriga, nrata, nrigp);
|
||||||
|
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 int nriga = new_pag.get_int(PAGSCA_NRIGA); // Riga fattura
|
const char sez = somma.sezione(); // Sezione importo e ritenute
|
||||||
const int nrata = new_pag.get_int(PAGSCA_NRATA); // Numero rata
|
const char controsez = sez == 'A' ? 'D' : 'A'; // Sezione contropartita
|
||||||
const int nrigp = new_pag.get_int(PAGSCA_NRIGP); // Riga pagamento
|
|
||||||
const TRectype& old_pag = p.pagamento(nriga, nrata, nrigp);
|
|
||||||
const TRiga_partite& somma = p.riga(nrigp);
|
|
||||||
|
|
||||||
const char sez = somma.sezione(); // Sezione importo e ritenute
|
|
||||||
const char controsez = sez == 'A' ? 'D' : 'A'; // Sezione contropartita
|
|
||||||
|
|
||||||
// Aggiornamento contopartita
|
// Aggiornamento contopartita
|
||||||
const TImporto old_importo(controsez, old_pag.get_real(PAGSCA_IMPORTO));
|
const TImporto old_importo(controsez, old_pag.get_real(PAGSCA_IMPORTO));
|
||||||
@ -969,7 +1030,7 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Importo della contropartita
|
// Importo della contropartita
|
||||||
if (!new_importo.is_zero())
|
if (!new_importo.is_zero() && new_conto.ok())
|
||||||
{
|
{
|
||||||
const int new_riga = bill2pos(new_conto, 'I');
|
const int new_riga = bill2pos(new_conto, 'I');
|
||||||
if (new_riga < 0)
|
if (new_riga < 0)
|
||||||
@ -1007,8 +1068,6 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
|
|||||||
|
|
||||||
if (deleting != 0)
|
if (deleting != 0)
|
||||||
{
|
{
|
||||||
const int riga_contabile = app().cgs().selected();
|
|
||||||
|
|
||||||
// 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)
|
||||||
{
|
{
|
||||||
@ -1111,14 +1170,15 @@ bool TPrimanota_application::edit_pagamento(TPartita& p, int nriga, int nrata, i
|
|||||||
m.reset(S_RITENUTE); // Azzera ritenute
|
m.reset(S_RITENUTE); // Azzera ritenute
|
||||||
}
|
}
|
||||||
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 new_pag(oldpag);
|
||||||
m.get_pag(new_pag);
|
m.get_pag(new_pag);
|
||||||
const TValuta val; // Non cambiare valuta!
|
const TValuta val; // Non cambiare valuta!
|
||||||
notify_edit_pagamento(p, new_pag, val);
|
notify_edit_pagamento(p, new_pag, val);
|
||||||
}
|
}
|
||||||
return key != K_ESC;
|
return key != K_ESC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1142,12 +1202,13 @@ bool TPrimanota_application::notify_cgline_deletion(TPartita& partita, long nreg
|
|||||||
if (sum.get_long(PART_NREG) == nreg &&
|
if (sum.get_long(PART_NREG) == nreg &&
|
||||||
(numrig <= 0 || sum.get_int(PART_NUMRIG) == numrig))
|
(numrig <= 0 || sum.get_int(PART_NUMRIG) == numrig))
|
||||||
{
|
{
|
||||||
TRectype pag(scad.row(s));
|
TRectype nul_pag(scad.row(s));
|
||||||
pag.zero(PAGSCA_IMPORTO);
|
nul_pag.zero(PAGSCA_IMPORTO);
|
||||||
pag.zero(PAGSCA_IMPORTOVAL);
|
nul_pag.zero(PAGSCA_IMPORTOVAL);
|
||||||
pag.zero(PAGSCA_RITENUTE);
|
nul_pag.zero(PAGSCA_RITENUTE);
|
||||||
|
nul_pag.put(PAGSCA_ACCSAL, 'A');
|
||||||
const TValuta val; // Non cambiare valuta
|
const TValuta val; // Non cambiare valuta
|
||||||
notify_edit_pagamento(partita, pag, val, numrig);
|
notify_edit_pagamento(partita, nul_pag, val, numrig);
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1167,11 +1228,8 @@ 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);
|
||||||
partite().add_numreg(nreg); // Carica tutte le partite interessate
|
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ END
|
|||||||
|
|
||||||
NUMBER 102 15
|
NUMBER 102 15
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 42 5 "Avere "
|
PROMPT 43 5 "Avere "
|
||||||
HELP "Importo 'avere' del conto della riga"
|
HELP "Importo 'avere' del conto della riga"
|
||||||
FLAGS "RV"
|
FLAGS "RV"
|
||||||
PICTURE "."
|
PICTURE "."
|
||||||
|
@ -149,7 +149,7 @@ void TValuta::set(TMask& m, short v, short d, short c) const
|
|||||||
{
|
{
|
||||||
m.set(v, _cod);
|
m.set(v, _cod);
|
||||||
m.set(d, _dat.string());
|
m.set(d, _dat.string());
|
||||||
m.set(c, _cam.string(2));
|
m.set(c, _cam.string());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TValuta::get(const TMask& m, short v, short d, short c)
|
void TValuta::get(const TMask& m, short v, short d, short c)
|
||||||
@ -311,9 +311,9 @@ TImporto TRiga_scadenze::calcola_differenza_cambio(int p, bool update)
|
|||||||
{
|
{
|
||||||
TImporto diffcam;
|
TImporto diffcam;
|
||||||
|
|
||||||
if (in_valuta())
|
TRectype& pag = row(p);
|
||||||
|
if (pag.get_char(PAGSCA_ACCSAL) == 'S' && in_valuta())
|
||||||
{
|
{
|
||||||
TRectype& pag = row(p);
|
|
||||||
const char sez = partita().riga(p).sezione();
|
const char sez = partita().riga(p).sezione();
|
||||||
|
|
||||||
if (update)
|
if (update)
|
||||||
@ -333,7 +333,7 @@ TImporto TRiga_scadenze::calcola_differenza_cambio(int p, bool update)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (update)
|
if (update)
|
||||||
row(p).zero(PAGSCA_DIFFCAM);
|
pag.zero(PAGSCA_DIFFCAM);
|
||||||
}
|
}
|
||||||
return diffcam;
|
return diffcam;
|
||||||
}
|
}
|
||||||
@ -403,9 +403,8 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag, const TValuta&
|
|||||||
|
|
||||||
partita().chiusa(TRUE); // Aggiorna flag di chiusura
|
partita().chiusa(TRUE); // Aggiorna flag di chiusura
|
||||||
|
|
||||||
const bool empty = new_pag.get(PAGSCA_IMPORTO).empty() &&
|
const bool empty = new_pag.get_char(PAGSCA_ACCSAL) != 'S' &&
|
||||||
new_pag.get(PAGSCA_ABBUONI).empty() &&
|
new_pag.get_real(PAGSCA_IMPORTO).is_zero();
|
||||||
new_pag.get(PAGSCA_DIFFCAM).empty();
|
|
||||||
if (empty)
|
if (empty)
|
||||||
rows_array().destroy_row(nrigp);
|
rows_array().destroy_row(nrigp);
|
||||||
|
|
||||||
@ -628,7 +627,7 @@ bool TPartita::esiste(int nriga, int nrata, int nrigp) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ritorna l'importo in lire speso su di una riga contabile
|
// Ritorna l'importo in lire speso su di una riga contabile
|
||||||
TImporto TPartita::importo_speso(long nreg, int numrig, bool extra) const
|
TImporto TPartita::importo_speso(long nreg, int numrig) const
|
||||||
{
|
{
|
||||||
TImporto imp;
|
TImporto imp;
|
||||||
|
|
||||||
@ -638,17 +637,15 @@ TImporto TPartita::importo_speso(long nreg, int numrig, bool extra) const
|
|||||||
if (nreg == part.get_long(PART_NREG) && numrig == part.get_int(PART_NUMRIG))
|
if (nreg == part.get_long(PART_NREG) && numrig == part.get_int(PART_NUMRIG))
|
||||||
{
|
{
|
||||||
imp += TImporto(part.sezione(), part.get_real(PART_IMPORTO));
|
imp += TImporto(part.sezione(), part.get_real(PART_IMPORTO));
|
||||||
if (extra)
|
|
||||||
|
TImporto abbuoni(part.get_char(PART_SEZABB), part.get_real(PART_ABBUONI));
|
||||||
|
const TValuta valuta(part);
|
||||||
|
if (!valuta.in_lire())
|
||||||
{
|
{
|
||||||
TImporto abbuoni(part.get_char(PART_SEZABB), part.get_real(PART_ABBUONI));
|
valuta.val2lit(abbuoni);
|
||||||
if (part.in_valuta())
|
imp += TImporto(part.get_char(PART_SEZDIFCAM), part.get_real(PART_DIFFCAM));
|
||||||
{
|
|
||||||
abbuoni.valore() *= part.get_real(PART_CAMBIO);
|
|
||||||
abbuoni.valore().round();
|
|
||||||
imp += TImporto(part.get_char(PART_SEZDIFCAM), part.get_real(PART_DIFFCAM));
|
|
||||||
}
|
|
||||||
imp += abbuoni;
|
|
||||||
}
|
}
|
||||||
|
imp += abbuoni;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,7 +703,7 @@ int TPartita::prima_fattura(long nreg) const
|
|||||||
const TRiga_partite& row = riga(r);
|
const TRiga_partite& row = riga(r);
|
||||||
const int tipomov = row.get_int(PART_TIPOMOV);
|
const int tipomov = row.get_int(PART_TIPOMOV);
|
||||||
if (tipomov == 1 || tipomov == 2)
|
if (tipomov == 1 || tipomov == 2)
|
||||||
if (nreg == -1 || nreg == row.get_long(PART_NREG))
|
if (nreg <= 0 || nreg == row.get_long(PART_NREG))
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@ -720,8 +717,8 @@ int TPartita::primo_pagamento(long nreg) const
|
|||||||
{
|
{
|
||||||
const TRiga_partite& row = riga(r);
|
const TRiga_partite& row = riga(r);
|
||||||
const int tipomov = row.get_int(PART_TIPOMOV);
|
const int tipomov = row.get_int(PART_TIPOMOV);
|
||||||
if (tipomov == 3) // TBI controllare per insoluti (tipomov == 6)
|
if (tipomov != 1)
|
||||||
if (nreg == -1 || nreg == row.get_long(PART_NREG))
|
if (nreg <= 0 || nreg == row.get_long(PART_NREG))
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@ -959,12 +956,10 @@ int TPartite_array::add_numreg(long nreg)
|
|||||||
TRelation rel(LF_PARTITE);
|
TRelation rel(LF_PARTITE);
|
||||||
TRectype& part = rel.lfile().curr();
|
TRectype& part = rel.lfile().curr();
|
||||||
|
|
||||||
// Costruzione filtro del cursore
|
// Costruzione cursore filtrato
|
||||||
part.zero();
|
part.zero();
|
||||||
part.put(PART_NREG, nreg);
|
part.put(PART_NREG, nreg);
|
||||||
|
|
||||||
const TRectype filter(part);
|
const TRectype filter(part);
|
||||||
|
|
||||||
TCursor cur(&rel, "", 2, &filter, &filter);
|
TCursor cur(&rel, "", 2, &filter, &filter);
|
||||||
|
|
||||||
for (cur = 0; cur.ok(); ++cur)
|
for (cur = 0; cur.ok(); ++cur)
|
||||||
@ -976,12 +971,12 @@ int TPartite_array::add_numreg(long nreg)
|
|||||||
return items();
|
return items();
|
||||||
}
|
}
|
||||||
|
|
||||||
TImporto TPartite_array::importo_speso(long nreg, int numrig, bool extra)
|
TImporto TPartite_array::importo_speso(long nreg, int numrig)
|
||||||
{
|
{
|
||||||
TImporto imp;
|
TImporto imp;
|
||||||
add_numreg(nreg);
|
add_numreg(nreg);
|
||||||
for (TPartita* game = first(); game; game = next())
|
for (TPartita* game = first(); game; game = next())
|
||||||
imp += game->importo_speso(nreg, numrig, extra);
|
imp += game->importo_speso(nreg, numrig);
|
||||||
return imp;
|
return imp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ public:
|
|||||||
const TString& numero() const { return _part.key().get(PART_NUMPART); }
|
const TString& numero() const { return _part.key().get(PART_NUMPART); }
|
||||||
const TString& descrizione() const { return _part.key().get(PART_DESCR); }
|
const TString& descrizione() const { return _part.key().get(PART_DESCR); }
|
||||||
|
|
||||||
TImporto importo_speso(long numreg, int numrig, bool extra) const;
|
TImporto importo_speso(long numreg, int numrig) const;
|
||||||
void update_reg(long nreg, const TRectype& mov);
|
void update_reg(long nreg, const TRectype& mov);
|
||||||
void calcola_saldo(TImporto& saldo, TImporto& doc, TImporto& pag, TImporto& imp) const;
|
void calcola_saldo(TImporto& saldo, TImporto& doc, TImporto& pag, TImporto& imp) const;
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ public:
|
|||||||
bool rewrite() { return write(TRUE); }
|
bool rewrite() { return write(TRUE); }
|
||||||
|
|
||||||
int add_numreg(long numreg); // Carica tutte le partite relative alla registrazione numreg
|
int add_numreg(long numreg); // Carica tutte le partite relative alla registrazione numreg
|
||||||
TImporto importo_speso(long numreg, int numrig, bool extra);
|
TImporto importo_speso(long numreg, int numrig);
|
||||||
void update_reg(const TRectype& mov, long old_reg = 0);
|
void update_reg(const TRectype& mov, long old_reg = 0);
|
||||||
|
|
||||||
TPartita* first() { restart(); return next(); }
|
TPartita* first() { restart(); return next(); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user