Gestione rate
git-svn-id: svn://10.65.10.50/trunk@2374 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
1f4b90ec98
commit
090e470352
16
cg/cg0.cpp
16
cg/cg0.cpp
@ -10,14 +10,14 @@ int main(int argc, char** argv)
|
||||
int res = 1;
|
||||
switch (op)
|
||||
{
|
||||
case 1: res = cg0100(argc,argv) ; break;
|
||||
case 2: res = cg0200(argc,argv) ; break;
|
||||
case 3: res = cg0300(argc,argv) ; break;
|
||||
case 4: res = cg0400(argc,argv) ; break;
|
||||
case 5: res = cg0500(argc,argv) ; break;
|
||||
// case 6: res = cg0600(argc,argv) ; break;
|
||||
default: error_box(usage, argv[0]); break;
|
||||
}
|
||||
case 1: res = cg0100(argc,argv) ; break;
|
||||
case 2: res = cg0200(argc,argv) ; break;
|
||||
case 3: res = cg0300(argc,argv) ; break;
|
||||
case 4: res = cg0400(argc,argv) ; break;
|
||||
case 5: res = cg0500(argc,argv) ; break;
|
||||
// case 6: res = cg0600(argc,argv) ; break;
|
||||
default: error_box(usage, argv[0]); break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -575,23 +575,20 @@ void TPrimanota_application::init_insert_mode(TMask& m)
|
||||
m.set(F_DATA74TER, m.get(F_DATAREG));
|
||||
|
||||
if (iva() != nessuna_iva)
|
||||
{
|
||||
occas_mask().reset();
|
||||
|
||||
if (is_fattura())
|
||||
{
|
||||
const TString16 dt(m.get(F_DATADOC));
|
||||
set_pagamento(NULL,dt);
|
||||
set_scadenze(m);
|
||||
}
|
||||
else
|
||||
set_pagamento(NULL,NULL); // Annulla pagamento
|
||||
|
||||
partite().destroy();
|
||||
if (is_fattura())
|
||||
{
|
||||
const TString16 dt(m.get(F_DATADOC));
|
||||
set_pagamento(NULL,dt);
|
||||
set_scadenze(m);
|
||||
}
|
||||
else
|
||||
{
|
||||
partite().destroy();
|
||||
set_pagamento(NULL,NULL); // Annulla pagamento
|
||||
}
|
||||
{
|
||||
set_pagamento(NULL,NULL); // Annulla pagamento
|
||||
}
|
||||
|
||||
_saldi.reset(); // Inizializza saldi
|
||||
}
|
||||
|
||||
@ -987,22 +984,22 @@ bool TPrimanota_application::remove()
|
||||
_saldi.registra();
|
||||
check_saldi();
|
||||
|
||||
if (_is_saldaconto)
|
||||
if (is_saldaconto())
|
||||
{
|
||||
if (iva() == nessuna_iva)
|
||||
{
|
||||
const long nreg = curr_mask().get_long(F_NUMREG);
|
||||
partite().add_numreg(nreg);
|
||||
notify_cgline_deletion(-1); // Notify deletion of all cg lines
|
||||
partite().rewrite();
|
||||
}
|
||||
else
|
||||
TMask& m = curr_mask();
|
||||
if (is_fattura())
|
||||
{
|
||||
TMask& m = curr_mask();
|
||||
m.reset(F_ANNORIF);
|
||||
m.reset(F_NUMRIF);
|
||||
write_scadenze(m);
|
||||
}
|
||||
else
|
||||
{
|
||||
const long nreg = m.get_long(F_NUMREG);
|
||||
partite().add_numreg(nreg);
|
||||
notify_cgline_deletion(-1); // Notify deletion of all cg lines
|
||||
partite().rewrite();
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
|
@ -493,8 +493,7 @@ NUMBER F_ANNORIF 4
|
||||
BEGIN
|
||||
PROMPT 50 15 "Rif.partita "
|
||||
FIELD LF_PARTITE->ANNO
|
||||
VALIDATE REQIF_FUNC 1 F_NUMRIF
|
||||
WARNING "Manca l'anno relativo al numero partita"
|
||||
FLAGS "U"
|
||||
END
|
||||
|
||||
STRING F_NUMRIF 7
|
||||
|
@ -212,7 +212,7 @@ BEGIN
|
||||
PROMPT 41 3 "Data reg. "
|
||||
END
|
||||
|
||||
STRING 110 5
|
||||
STRING 110 7
|
||||
BEGIN
|
||||
PROMPT 1 4 "Numero doc. "
|
||||
END
|
||||
|
@ -103,6 +103,14 @@ BEGIN
|
||||
WARNING "L'importo deve essere specificato"
|
||||
END
|
||||
|
||||
NUMBER S_RITENUTE 15
|
||||
BEGIN
|
||||
PROMPT 38 8 "Ritenute professionali "
|
||||
PICTURE "."
|
||||
FIELD RITENUTE
|
||||
MESSAGE DIRTY,S_IMPORTO|K_TAB,S_IMPORTO
|
||||
END
|
||||
|
||||
NUMBER S_IMPORTOVAL 15 3
|
||||
BEGIN
|
||||
PROMPT 2 9 "Importo in valuta "
|
||||
@ -113,13 +121,37 @@ BEGIN
|
||||
WARNING "L'importo in valuta deve essere specificato"
|
||||
END
|
||||
|
||||
NUMBER S_RITENUTE 15
|
||||
STRING S_VALUTA 3
|
||||
BEGIN
|
||||
PROMPT 38 8 "Ritenute professionali "
|
||||
PICTURE "."
|
||||
FIELD RITENUTE
|
||||
MESSAGE DIRTY,S_IMPORTO|K_TAB,S_IMPORTO
|
||||
END
|
||||
PROMPT 37 8 "Valuta "
|
||||
FLAGS "DHUZ"
|
||||
GROUP 4
|
||||
END
|
||||
|
||||
DATE S_DATACAMBIO
|
||||
BEGIN
|
||||
PROMPT 52 8 "Data cambio "
|
||||
FLAGS "HR"
|
||||
USE CAM
|
||||
INPUT CODTAB[1,3] S_VALUTA SELECT
|
||||
INPUT CODTAB[4,11] S_DATACAMBIO
|
||||
DISPLAY "Valuta" CODTAB[1,3]
|
||||
DISPLAY "Data@10" D0
|
||||
DISPLAY "Cambio@18" R10
|
||||
OUTPUT S_DATACAMBIO D0
|
||||
OUTPUT S_CAMBIO R10
|
||||
GROUP 4
|
||||
CHECKTYPE SEARCH
|
||||
END
|
||||
|
||||
NUMBER S_CAMBIO 15 5
|
||||
BEGIN
|
||||
PROMPT 37 9 "Cambio "
|
||||
FLAGS "HRU"
|
||||
GROUP 4
|
||||
PICTURE ".5"
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
RADIOBUTTON S_SALDOACC 1 24
|
||||
BEGIN
|
||||
@ -218,38 +250,6 @@ BEGIN
|
||||
GROUP 2
|
||||
END
|
||||
|
||||
STRING S_VALUTA 3
|
||||
BEGIN
|
||||
PROMPT 2 12 "Valuta "
|
||||
FLAGS "DHUZ"
|
||||
GROUP 4
|
||||
END
|
||||
|
||||
DATE S_DATACAMBIO
|
||||
BEGIN
|
||||
PROMPT 24 12 "Data cambio "
|
||||
FLAGS "RH"
|
||||
USE CAM
|
||||
INPUT CODTAB[1,3] S_VALUTA SELECT
|
||||
INPUT CODTAB[4,11] S_DATACAMBIO
|
||||
DISPLAY "Valuta" CODTAB[1,3]
|
||||
DISPLAY "Data@10" D0
|
||||
DISPLAY "Cambio@18" R10
|
||||
OUTPUT S_DATACAMBIO D0
|
||||
OUTPUT S_CAMBIO R10
|
||||
GROUP 4
|
||||
CHECKTYPE SEARCH
|
||||
END
|
||||
|
||||
NUMBER S_CAMBIO 15 5
|
||||
BEGIN
|
||||
PROMPT 51 12 "Cambio "
|
||||
FLAGS "HRU"
|
||||
GROUP 4
|
||||
PICTURE ".5"
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
STRING S_CODDESC 5
|
||||
BEGIN
|
||||
PROMPT 2 14 "Descriz. agg. "
|
||||
|
@ -1625,7 +1625,7 @@ bool TPrimanota_application::doc_handler(TMask_field& f, KEY key)
|
||||
if (!app().npart_is_prot())
|
||||
{
|
||||
if (m.get(F_NUMRIF).empty())
|
||||
m.set(F_NUMRIF, val); // copia numero documento
|
||||
m.set(F_NUMRIF, val, TRUE); // copia numero documento
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1725,9 +1725,30 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
|
||||
if (key == K_TAB && f.active())
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
const char cf = app().clifo();
|
||||
|
||||
if (f.focusdirty() && app().is_nota_credito())
|
||||
{
|
||||
TPartite_array& p = app().partite();
|
||||
if (m.edit_mode())
|
||||
p.add_numreg(m.get_long(F_NUMREG));
|
||||
|
||||
const TPartita* game = p.first();
|
||||
if (game != NULL)
|
||||
{
|
||||
const bool del = f.yesno_box("Si desidera cancellare i pagamenti effettuati?");
|
||||
if (!del) // Ripristina codice copiandolo dalla prima partita
|
||||
{
|
||||
TString cod; cod << game->conto().sottoconto();
|
||||
f.set(cod);
|
||||
return TRUE;
|
||||
}
|
||||
app().notify_cgline_deletion(-1);
|
||||
}
|
||||
}
|
||||
|
||||
const char cf = app().clifo();
|
||||
const long codice = atol(f.get());
|
||||
|
||||
if (codice == 0)
|
||||
{
|
||||
m.hide(F_OCCASEDIT); // Spegni bottone occasionali
|
||||
@ -1764,8 +1785,8 @@ bool TPrimanota_application::clifo_handler(TMask_field& f, KEY key)
|
||||
}
|
||||
|
||||
if (app().is_fattura() && f.focusdirty())
|
||||
{
|
||||
if (m.field(SK_VALUTA).active())
|
||||
{
|
||||
if (m.field(SK_VALUTA).active() && m.get(SK_VALUTA).empty())
|
||||
{
|
||||
const TString& valuta = clifo.get(CLI_CODVAL);
|
||||
if (valuta.not_empty())
|
||||
@ -1876,29 +1897,32 @@ bool TPrimanota_application::main_codiva_handler(TMask_field& f, KEY key)
|
||||
// Riempie i campi valuta a zero in base agli altri
|
||||
void TPrimanota_application::gioca_cambi(int force)
|
||||
{
|
||||
TMask& m = curr_mask();
|
||||
TMask& m = curr_mask();
|
||||
const TValuta cambio(m, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO);
|
||||
if (cambio.in_lire())
|
||||
return;
|
||||
|
||||
const real totale = m.get(F_TOTALE);
|
||||
const real totval = m.get(SK_TOTDOCVAL);
|
||||
const real cambio = m.get(SK_CAMBIO);
|
||||
|
||||
if ( (force == 0x1 || totale.is_zero()) && !(totval.is_zero() || cambio.is_zero()) )
|
||||
if ( (force == 0x1 || totale.is_zero()) && !(totval.is_zero() || cambio.cambio() == 1.0) )
|
||||
{
|
||||
real new_totale = totval * cambio; new_totale.round(0);
|
||||
const real new_totale = cambio.val2lit(totval);
|
||||
if (new_totale != totale)
|
||||
m.set(F_TOTALE, new_totale, TRUE);
|
||||
}
|
||||
|
||||
if ( (force == 0x2 || totval.is_zero()) && !(totale.is_zero() || cambio.is_zero()))
|
||||
if ( (force == 0x2 || totval.is_zero()) && !(totale.is_zero() || cambio.cambio() == 1.0) )
|
||||
{
|
||||
real new_totval = totale / cambio; new_totval.round(3);
|
||||
const real new_totval = cambio.lit2val(totale);
|
||||
if (new_totval != totval)
|
||||
m.set(SK_TOTDOCVAL, new_totval, TRUE);
|
||||
}
|
||||
|
||||
if ( (force == 0x4 || cambio.is_zero()) && !(totale.is_zero() || totval.is_zero()))
|
||||
if ( (force == 0x4 || cambio.cambio() == 1.0) && !(totale.is_zero() || totval.is_zero()))
|
||||
{
|
||||
real new_cambio = totale / totval; new_cambio.round(5);
|
||||
if (new_cambio != cambio)
|
||||
if (new_cambio != cambio.cambio())
|
||||
m.set(SK_CAMBIO, new_cambio, TRUE);
|
||||
}
|
||||
}
|
||||
|
164
cg/cg2104.cpp
164
cg/cg2104.cpp
@ -172,8 +172,12 @@ bool TPrimanota_application::pag_sheet_handler(TMask_field& f, KEY key)
|
||||
bool ok = TRUE;
|
||||
if (key == K_TAB || key == K_ENTER)
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
|
||||
TPagamento& pag = app().pagamento();
|
||||
const word err = pag.validate();
|
||||
word err = pag.validate();
|
||||
if (m.edit_mode())
|
||||
err &= ~(P_RSUM | P_TOTNC); // Ignora totale importi e rate
|
||||
if (err != P_OK)
|
||||
{
|
||||
TString s(256);
|
||||
@ -181,21 +185,20 @@ bool TPrimanota_application::pag_sheet_handler(TMask_field& f, KEY key)
|
||||
ok = error_box(s);
|
||||
}
|
||||
|
||||
TMask& m = f.mask();
|
||||
if (key == K_ENTER && m.edit_mode())
|
||||
{
|
||||
const bool valuta = m.get(SK_CAMBIO).not_empty();
|
||||
const real tot = m.get(valuta ? SK_TOTDOCVAL : F_TOTALE);
|
||||
const bool in_valuta = m.get(SK_VALUTA).not_empty();
|
||||
const real tot = m.get(in_valuta ? SK_TOTDOCVAL : F_TOTALE);
|
||||
real imp;
|
||||
for (int r = pag.n_rate()-1; r >= 0; r--)
|
||||
imp += pag.tpay_rata(r);
|
||||
if (imp != tot)
|
||||
{
|
||||
const char* const pic = valuta ? ".3" : ".";
|
||||
const char* const pic = in_valuta ? ".3" : ".";
|
||||
const TString is(imp.string(pic));
|
||||
const TString ts(tot.string(pic));
|
||||
const bool recalc = yesno_box("Il totale delle rate e' %s mentre\n"
|
||||
"il totale del documento e' %s.\n"
|
||||
"il totale del documento in valuta e' %s.\n"
|
||||
"Si desidera ricalcolare le rate e poi\n"
|
||||
"registrare in un secondo momento?",
|
||||
(const char*)is, (const char*)ts);
|
||||
@ -205,6 +208,21 @@ bool TPrimanota_application::pag_sheet_handler(TMask_field& f, KEY key)
|
||||
ok = FALSE; // Permette di guardare il risultato prima di registrare
|
||||
}
|
||||
}
|
||||
|
||||
if (in_valuta)
|
||||
{
|
||||
const real totlit = m.get(F_TOTALE);
|
||||
imp = ZERO;
|
||||
for (int r = pag.n_rate()-1; r >= 0; r--)
|
||||
imp += pag.tlit_rata(r);
|
||||
if (imp != totlit)
|
||||
{
|
||||
const TString is(imp.string("."));
|
||||
const TString ts(totlit.string("."));
|
||||
warning_box("Il totale in lire delle rate e' %s mentre\n"
|
||||
"il totale del documento e' %s.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
@ -263,7 +281,8 @@ bool TPrimanota_application::annorif_handler(TMask_field& f, KEY key)
|
||||
bool ok = TRUE;
|
||||
const TMask& m = f.mask();
|
||||
|
||||
if (f.to_check(key) && f.get().empty() && m.insert_mode())
|
||||
if (f.to_check(key) && f.get().empty() &&
|
||||
(m.insert_mode() || m.get(F_NUMRIF).not_empty()))
|
||||
{
|
||||
const TString& anno = m.get(F_DATADOC).right(4);
|
||||
f.set(anno);
|
||||
@ -277,12 +296,13 @@ bool TPrimanota_application::annorif_handler(TMask_field& f, KEY key)
|
||||
bool TPrimanota_application::numrif_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
bool ok = TRUE;
|
||||
if (f.to_check(key))
|
||||
|
||||
if (f.to_check(key, TRUE))
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
const bool empty = f.get().blank();
|
||||
|
||||
if (empty && m.insert_mode())
|
||||
if (empty && f.focusdirty() && m.insert_mode())
|
||||
{
|
||||
f.set(m.get(app()._npart_is_prot ? F_PROTIVA : F_NUMDOC));
|
||||
if (m.get(F_CODPAG).empty())
|
||||
@ -290,12 +310,13 @@ bool TPrimanota_application::numrif_handler(TMask_field& f, KEY key)
|
||||
TMask_field& clifo = m.field(app().iva() == iva_vendite ? F_CLIENTE : F_FORNITORE);
|
||||
clifo.on_hit();
|
||||
}
|
||||
return error_box("Il numero di riferimento partita e' obbligatorio!\n"
|
||||
"Se possibile esso verra' proposto, ma potra'\n"
|
||||
"essere modificato prima di registrare il movimento.");
|
||||
ok = error_box("Il numero di riferimento partita e' obbligatorio!\n"
|
||||
"Se possibile esso verra' proposto, ma potra'\n"
|
||||
"essere modificato prima di registrare il movimento.");
|
||||
}
|
||||
|
||||
if (m.edit_mode())
|
||||
m.enable_page(2, !f.get().blank());
|
||||
|
||||
if (key == K_ENTER && m.edit_mode())
|
||||
{
|
||||
const TPartita* old = app().partite().first();
|
||||
if (old && empty) // Se esisteva una partita ma ora non piu'
|
||||
@ -317,7 +338,6 @@ bool TPrimanota_application::numrif_handler(TMask_field& f, KEY key)
|
||||
break;
|
||||
}
|
||||
}
|
||||
m.enable_page(2, !f.get().blank());
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
@ -554,9 +574,6 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
const TDate datadoc = testa.get_date(MOV_DATADOC);
|
||||
|
||||
const TRectype& prima = _rel->cg(0);
|
||||
// const char sezione = prima.get_char("SEZIONE"); // Dare/Avere
|
||||
// const int nriga = 1;
|
||||
// const int numrig = 1;
|
||||
|
||||
TBill clifo; clifo.get(prima);
|
||||
const int anno = m.get_int(F_ANNORIF);
|
||||
@ -577,43 +594,26 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
codpag = primarata.get(SCAD_CODPAG);
|
||||
}
|
||||
set_pagamento(codpag, datadoc.string());
|
||||
|
||||
real imponibile, imposta;
|
||||
const real spese(0.0);
|
||||
|
||||
const real cambio(partita.get(PART_CAMBIO));
|
||||
const bool in_valuta = partita.in_valuta();
|
||||
if (in_valuta)
|
||||
{
|
||||
imponibile = m.get_real(SK_TOTDOCVAL);
|
||||
imposta = m.get_real(F_IMPOSTE); imposta /= cambio; imposta.round(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
imposta = m.get_real(F_IMPOSTE);
|
||||
imponibile = m.get_real(F_TOTALE) - imposta;
|
||||
}
|
||||
const TValuta cambio(partita);
|
||||
const bool in_valuta = cambio.in_valuta();
|
||||
|
||||
// se la maschera contiene importi diversi da quelli
|
||||
// registrati si passa la palla al culano/a
|
||||
// TBC controllo se imponibile deve contenere le spese
|
||||
if ((imponibile + imposta) != partita.importo(in_valuta).valore() ||
|
||||
imposta != partita.get_real(PART_IMPOSTA) ||
|
||||
spese != partita.get_real(PART_SPESE))
|
||||
const real totale = m.get(in_valuta ? SK_TOTDOCVAL : F_TOTALE);
|
||||
if (totale != partita.importo(in_valuta).valore() ||
|
||||
m.get_real(F_IMPOSTE) != partita.get_real(PART_IMPOSTA))
|
||||
{
|
||||
warning_box("Gli importi delle scadenze non corrispondono al totale documento");
|
||||
}
|
||||
|
||||
|
||||
real imponibile = partita.importo(in_valuta).valore();
|
||||
real imposta = partita.get_real(PART_IMPOSTA);
|
||||
real spese(0.0);
|
||||
if (in_valuta)
|
||||
{
|
||||
imposta = partita.get_real(PART_IMPOSTA); imposta /= cambio; imposta.round(3);
|
||||
imponibile = partita.importo(TRUE).valore() - imposta;
|
||||
}
|
||||
else
|
||||
{
|
||||
imposta = partita.get_real(PART_IMPOSTA);
|
||||
imponibile = partita.importo(FALSE).valore() - imposta;
|
||||
}
|
||||
cambio.lit2val(imposta);
|
||||
cambio.lit2val(spese);
|
||||
}
|
||||
imponibile -= imposta;
|
||||
|
||||
TPagamento& pag = pagamento();
|
||||
pag.set_total(imponibile, imposta, spese);
|
||||
@ -629,7 +629,7 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
const int tipop = scadenza.get_int(SCAD_TIPOPAG);
|
||||
const bool paid = scadenza.get_bool(SCAD_PAGATA);
|
||||
const TString16 ulc = scadenza.get(SCAD_ULTCLASS);
|
||||
if (scadenza.in_valuta())
|
||||
if (in_valuta)
|
||||
{
|
||||
const real impval(scadenza.get(SCAD_IMPORTOVAL));
|
||||
pag.set_rata(i-1, impval, importo, scad, tipop, ulc, paid);
|
||||
@ -675,10 +675,6 @@ void TPrimanota_application::write_scadenze(const TMask& m)
|
||||
|
||||
if (anno > 0 && !numpart.blank())
|
||||
{
|
||||
real imponibile(0.0);
|
||||
real imposta(0.0);
|
||||
real spese(0.0);
|
||||
|
||||
const TString ndoc(m.get(F_NUMDOC));
|
||||
const int tmov = causale().tipomov();
|
||||
const TDate ddoc(m.get(F_DATADOC));
|
||||
@ -688,50 +684,54 @@ void TPrimanota_application::write_scadenze(const TMask& m)
|
||||
const TString codpag(m.get(F_CODPAG));
|
||||
const long protiva = m.get_long(F_PROTIVA);
|
||||
const TString codcaus(causale().codice());
|
||||
const TString codval (m.get(SK_VALUTA));
|
||||
const real cambio (m.get(SK_CAMBIO));
|
||||
const TValuta cambio (m, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO);
|
||||
const TString agente (m.get(FS_AGENTE));
|
||||
const char sezione = get_cgs_imp(0).sezione(); // Dare/Avere
|
||||
|
||||
const TBill clifo(cgs().row(0), 2, 0x3);
|
||||
newgame = new TPartita(clifo, anno, numpart);
|
||||
|
||||
const int row = newgame->prima_fattura(nreg);
|
||||
const int row = newgame->prima_fattura(nreg); // Riga fattura di questo movimento
|
||||
TRiga_partite& partita = row <= 0 ? newgame->new_row() : newgame->riga(row);
|
||||
TPagamento& pag = pagamento();
|
||||
|
||||
// put data on partita
|
||||
partita.put(PART_TIPOMOV, tmov);
|
||||
partita.put(PART_NREG, nreg);
|
||||
partita.put(PART_NUMRIG, 1);
|
||||
partita.put(PART_DATAREG, dreg);
|
||||
partita.put(PART_DATADOC, ddoc);
|
||||
partita.put(PART_NUMDOC, ndoc);
|
||||
partita.put(PART_DESCR, desc);
|
||||
partita.put(PART_CODCAUS, codcaus);
|
||||
partita.put(PART_REG, reg);
|
||||
partita.put(PART_PROTIVA, protiva);
|
||||
partita.put(PART_SEZ, sezione);
|
||||
partita.put(PART_CODVAL, codval);
|
||||
partita.put(PART_CAMBIO, cambio);
|
||||
|
||||
if (partita.in_valuta())
|
||||
{
|
||||
partita.put(PART_IMPORTO, m.get(F_TOTALE));
|
||||
partita.put(PART_IMPORTOVAL, pag.imponibile());
|
||||
partita.zero(PART_IMPOSTA);
|
||||
partita.put(PART_TIPOMOV, tmov);
|
||||
partita.put(PART_NREG, nreg);
|
||||
partita.put(PART_NUMRIG, 1);
|
||||
partita.put(PART_DATAREG, dreg);
|
||||
partita.put(PART_DATADOC, ddoc);
|
||||
partita.put(PART_NUMDOC, ndoc);
|
||||
partita.put(PART_DESCR, desc);
|
||||
partita.put(PART_CODCAUS, codcaus);
|
||||
partita.put(PART_REG, reg);
|
||||
partita.put(PART_PROTIVA, protiva);
|
||||
partita.put(PART_SEZ, sezione);
|
||||
partita.put(PART_IMPTOTDOC, m.get(F_TOTALE));
|
||||
cambio.put(partita);
|
||||
const bool in_valuta = cambio.in_valuta();
|
||||
|
||||
real imponibile, imponibile_val;
|
||||
for (int i = pag.n_rate()-1; i >= 0; i--)
|
||||
{
|
||||
if (in_valuta)
|
||||
{
|
||||
imponibile_val += pag.tpay_rata(i);
|
||||
imponibile += pag.tlit_rata(i);
|
||||
}
|
||||
else
|
||||
imponibile += pag.tpay_rata(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
partita.put(PART_IMPORTO, real(pag.imponibile()+pag.imposta()));
|
||||
partita.zero(PART_IMPORTOVAL);
|
||||
partita.put(PART_IMPOSTA, pag.imposta());
|
||||
}
|
||||
|
||||
partita.put(PART_IMPORTO, imponibile);
|
||||
partita.put(PART_IMPORTOVAL, imponibile_val);
|
||||
partita.put(PART_IMPOSTA, m.get(F_IMPOSTE));
|
||||
partita.put(PART_SPESE, pag.spese());
|
||||
|
||||
TSheet_field& ps = (TSheet_field&)m.field(FS_RATESHEET);
|
||||
|
||||
partita.elimina_rata(-1);
|
||||
for (int i = 0; i < pag.n_rate(); i++)
|
||||
for (i = 0; i < pag.n_rate(); i++)
|
||||
{
|
||||
TToken_string& row = ps.row(i);
|
||||
|
||||
|
192
cg/cg2105.cpp
192
cg/cg2105.cpp
@ -28,6 +28,8 @@ protected:
|
||||
static bool cambio_handler(TMask_field& f, KEY k);
|
||||
static bool datapag_handler(TMask_field& f, KEY k);
|
||||
|
||||
void gioca_cambi(int force = 0x0);
|
||||
|
||||
public:
|
||||
void set_pag(const TRectype& oldpag, const TRiga_scadenze& scad, const TImporto& importo);
|
||||
void get_pag(TRectype& oldpag) const;
|
||||
@ -77,7 +79,7 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad,
|
||||
_da_pagare = scad.residuo(in_valuta).valore(); // Calcola residuo in valuta
|
||||
|
||||
TReal_field& res = (TReal_field&)field(S_RESIDUORATA);
|
||||
res.set_decimals(in_valuta ? 2 : 0);
|
||||
res.set_decimals(in_valuta ? 3 : 0);
|
||||
if (get(S_SALDOACC)[0] != 'S')
|
||||
res.set(_da_pagare.string());
|
||||
|
||||
@ -136,17 +138,18 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad,
|
||||
enable(S_SALDOACC, sa);
|
||||
|
||||
show(-3, in_valuta); // Attiva campi relativi alla valuta
|
||||
show(-4, in_valuta); // Attiva campi relativi al cambio
|
||||
|
||||
#ifdef __EXTRA__
|
||||
set_handler(S_CAMBIO, cambio_handler);
|
||||
hide(S_RESIDUOPAG);
|
||||
|
||||
const bool mostra_conto = FALSE;
|
||||
show(-4, in_valuta); // Attiva campi relativi al cambio
|
||||
#else
|
||||
disable(-4);
|
||||
|
||||
_datadoc = sum.get_date(PART_DATADOC);
|
||||
set_handler(S_DATAPAG, datapag_handler);
|
||||
|
||||
|
||||
const bool mostra_conto = !sum.is_nota_credito();
|
||||
#endif
|
||||
show(-2, mostra_conto); // mostra/nasconde conto contropartita
|
||||
@ -163,6 +166,36 @@ void TPay_mask::get_pag(TRectype& newpag) const
|
||||
newpag = rel.curr();
|
||||
}
|
||||
|
||||
// Riempie i campi valuta a zero in base agli altri
|
||||
void TPay_mask::gioca_cambi(int force)
|
||||
{
|
||||
const real totale = get(S_IMPORTO);
|
||||
const real totval = get(S_IMPORTOVAL);
|
||||
const TValuta cambio(*this, S_VALUTA, S_DATACAMBIO, S_CAMBIO);
|
||||
|
||||
if ( (force == 0x1 || totale.is_zero()) && !(totval.is_zero() || cambio.in_lire()) )
|
||||
{
|
||||
const real new_totale = cambio.val2lit(totval);
|
||||
if (new_totale != totale)
|
||||
set(S_IMPORTO, new_totale, TRUE);
|
||||
}
|
||||
|
||||
if ( (force == 0x2 || totval.is_zero()) && !(totale.is_zero() || cambio.in_lire()))
|
||||
{
|
||||
const real new_totval = cambio.lit2val(totale);
|
||||
if (new_totval != totval)
|
||||
set(S_IMPORTOVAL, new_totval, TRUE);
|
||||
}
|
||||
|
||||
if ( (force == 0x4 || cambio.in_lire()) && !(totale.is_zero() || totval.is_zero()))
|
||||
{
|
||||
real new_cambio = totale / totval; new_cambio.round(5);
|
||||
if (new_cambio != cambio.cambio())
|
||||
set(S_CAMBIO, new_cambio, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool TPay_mask::importo_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
TPay_mask& m = (TPay_mask&)f.mask();
|
||||
@ -183,7 +216,10 @@ bool TPay_mask::importo_handler(TMask_field& f, KEY k)
|
||||
}
|
||||
|
||||
if (k == K_TAB && f.focusdirty())
|
||||
{
|
||||
{
|
||||
if (m.field(S_IMPORTOVAL).active())
|
||||
m.gioca_cambi();
|
||||
|
||||
real i(f.get());
|
||||
if (m.field(S_RITENUTE).active())
|
||||
i += real(m.get(S_RITENUTE));
|
||||
@ -201,31 +237,20 @@ bool TPay_mask::importo_handler(TMask_field& f, KEY k)
|
||||
|
||||
const real residuopag(m._pagabile - i);
|
||||
m.set(S_RESIDUOPAG, residuopag);
|
||||
|
||||
if (f.dlg() == S_IMPORTOVAL)
|
||||
{
|
||||
const TValuta val(m, 0, 0, S_CAMBIO);
|
||||
val.val2lit(i);
|
||||
m.set(S_IMPORTO, i);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TPay_mask::importolire_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
{
|
||||
TPay_mask& m = (TPay_mask&)f.mask();
|
||||
|
||||
if (k == K_F8)
|
||||
m.send_key(k, S_IMPORTOVAL);
|
||||
|
||||
if (f.to_check(k))
|
||||
{
|
||||
TPay_mask& m = (TPay_mask&)f.mask();
|
||||
const real implit(f.get());
|
||||
if (!implit.is_zero() && m.get(S_IMPORTOVAL).empty())
|
||||
{
|
||||
const TValuta val(m, 0, 0, S_CAMBIO);
|
||||
const real impval = val.lit2val(implit);
|
||||
m.set(S_IMPORTOVAL, impval);
|
||||
}
|
||||
}
|
||||
m.gioca_cambi();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -233,9 +258,8 @@ bool TPay_mask::cambio_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (k == K_TAB && f.focusdirty())
|
||||
{
|
||||
TMask_field& i = f.mask().field(S_IMPORTOVAL);
|
||||
i.set_dirty();
|
||||
i.on_hit();
|
||||
TPay_mask& m = (TPay_mask&)f.mask();
|
||||
m.gioca_cambi(0x1);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -298,8 +322,10 @@ protected:
|
||||
int nuovo_pagamento(TPartita& partita, int nriga, int rata) const;
|
||||
bool edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) const;
|
||||
|
||||
void align_number(TMask_field& f) const;
|
||||
long number_distance(const char* key, const char* num) const;
|
||||
bool same_number(const char* key, const char* num) const;
|
||||
void append_conto(TString& s) const;
|
||||
|
||||
#ifdef __EXTRA__
|
||||
bool edit_fattura(TPartita& p, int nriga);
|
||||
@ -322,18 +348,27 @@ public:
|
||||
virtual ~TGame_mask() {}
|
||||
};
|
||||
|
||||
void TGame_mask::append_conto(TString& s) const
|
||||
{
|
||||
switch (conto().tipo())
|
||||
{
|
||||
case 'C':
|
||||
s << "Cliente"; break;
|
||||
case 'F':
|
||||
s << "Fornitore"; break;
|
||||
default:
|
||||
s << "Conto " << conto().gruppo() << ' ' << conto().conto(); break;
|
||||
}
|
||||
s << ' ' << conto().sottoconto();
|
||||
}
|
||||
|
||||
TGame_mask::TGame_mask(const TBill& bill, long numreg, int riga)
|
||||
: TMask("cg2100p"), _conto(bill), _numreg(numreg), _numrig(riga),
|
||||
_changed(FALSE), _valfirst(FALSE), _causali(LF_CAUSALI, "CODCAUS", "DESCR")
|
||||
{
|
||||
TString descr(80);
|
||||
switch (_conto.tipo())
|
||||
{
|
||||
case 'C': descr = "Cliente"; break;
|
||||
case 'F': descr = "Fornitore"; break;
|
||||
default: descr = "Conto"; break;
|
||||
}
|
||||
descr << ' ' << _conto.sottoconto() << ' ' << ((TBill&)_conto).descrizione();
|
||||
append_conto(descr);
|
||||
descr << ' ' << ((TBill&)_conto).descrizione();
|
||||
set(P_DESCR, descr);
|
||||
|
||||
TValuta val;
|
||||
@ -342,6 +377,14 @@ TGame_mask::TGame_mask(const TBill& bill, long numreg, int riga)
|
||||
val.get(cm, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO);
|
||||
cerca_valuta(val);
|
||||
val.set(*this, P_VALUTA, P_DATACAMBIO, P_CAMBIO);
|
||||
|
||||
const TCausale& causale = app().causale();
|
||||
const tipo_movimento tm = (tipo_movimento)causale.tipomov();
|
||||
if (tm == tm_nota_credito)
|
||||
{
|
||||
set(P_ANNO, cm.get(F_ANNORIF));
|
||||
set(P_NUMERO, cm.get(F_NUMRIF));
|
||||
}
|
||||
#endif
|
||||
enable(-3, val.in_valuta());
|
||||
|
||||
@ -1007,6 +1050,13 @@ bool TGame_mask::edit_scadenza_handler(TMask_field& f, KEY k)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TGame_mask::align_number(TMask_field& f) const
|
||||
{
|
||||
const TPartita game(conto(), 0, "*");
|
||||
const char a = game.allineamento_richiesto();
|
||||
f.set_justify(a == 'R');
|
||||
}
|
||||
|
||||
|
||||
bool TGame_mask::nuovo_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
@ -1016,48 +1066,48 @@ bool TGame_mask::nuovo_handler(TMask_field& f, KEY k)
|
||||
int anno;
|
||||
TString numero;
|
||||
|
||||
// Graffa tattica per distruggere la maschera new_game alla fine del blocco
|
||||
{
|
||||
TMask new_game("cg2100n");
|
||||
new_game.first_focus(P_NUMERO);
|
||||
TMask* new_game = new TMask("cg2100n"); // We must create mask on the heap!
|
||||
gm.align_number(new_game->field(P_NUMERO));
|
||||
new_game->first_focus(P_NUMERO);
|
||||
|
||||
#ifndef __EXTRA__
|
||||
const TMask& cm = app().curr_mask();
|
||||
new_game.disable(-1);
|
||||
new_game->disable(-1);
|
||||
gm._tipomov = (tipo_movimento)app().causale().tipomov();
|
||||
new_game.set(P_NUOVO, gm._tipomov);
|
||||
new_game.set(P_SEZIONE, gm._importo.sezione());
|
||||
new_game.set(P_RESIDUO, gm.get(P_RESIDUO));
|
||||
new_game.set(P_DATADOC, cm.get(F_DATADOC));
|
||||
new_game.set(P_NUMDOC, cm.get(F_NUMDOC));
|
||||
new_game.set(P_DESCR, cm.get(F_DESCR));
|
||||
new_game->set(P_NUOVO, gm._tipomov);
|
||||
new_game->set(P_SEZIONE, gm._importo.sezione());
|
||||
new_game->set(P_RESIDUO, gm.get(P_RESIDUO));
|
||||
new_game->set(P_DATADOC, cm.get(F_DATADOC));
|
||||
new_game->set(P_NUMDOC, cm.get(F_NUMDOC));
|
||||
new_game->set(P_DESCR, cm.get(F_DESCR));
|
||||
if (gm._tipomov < 3)
|
||||
new_game.set(P_CODPAG,cm.get(F_CODPAG));
|
||||
new_game->set(P_CODPAG,cm.get(F_CODPAG));
|
||||
if (gm._tipomov == 2)
|
||||
{
|
||||
new_game.set(P_ANNO, cm.get(F_ANNORIF));
|
||||
new_game.set(P_NUMERO, cm.get(F_NUMRIF));
|
||||
new_game->set(P_ANNO, cm.get(F_ANNORIF));
|
||||
new_game->set(P_NUMERO, cm.get(F_NUMRIF));
|
||||
}
|
||||
#endif
|
||||
|
||||
k = new_game.run();
|
||||
anno = new_game.get_int(P_ANNO);
|
||||
numero = new_game.get(P_NUMERO);
|
||||
k = new_game->run();
|
||||
anno = new_game->get_int(P_ANNO);
|
||||
numero = new_game->get(P_NUMERO);
|
||||
|
||||
gm._tipomov = (tipo_movimento)new_game.get_int(P_NUOVO);
|
||||
gm._codpag = new_game.get(P_CODPAG);
|
||||
gm._sezione = new_game.get(P_SEZIONE)[0];
|
||||
gm._importo.set(gm._sezione, real(new_game.get(P_RESIDUO)));
|
||||
gm._numdoc = new_game.get(P_NUMDOC);
|
||||
gm._datadoc = new_game.get(P_DATADOC);
|
||||
gm._descr = new_game.get(P_DESCR);
|
||||
}
|
||||
gm._tipomov = (tipo_movimento)new_game->get_int(P_NUOVO);
|
||||
gm._codpag = new_game->get(P_CODPAG);
|
||||
gm._sezione = new_game->get(P_SEZIONE)[0];
|
||||
gm._importo.set(gm._sezione, real(new_game->get(P_RESIDUO)));
|
||||
gm._numdoc = new_game->get(P_NUMDOC);
|
||||
gm._datadoc = new_game->get(P_DATADOC);
|
||||
gm._descr = new_game->get(P_DESCR);
|
||||
|
||||
delete new_game; new_game = NULL;
|
||||
|
||||
if (k == K_ENTER)
|
||||
{
|
||||
TPartita& game = app().partite().partita(gm.conto(), anno, numero);
|
||||
|
||||
if (gm._tipomov > 1)
|
||||
if (gm._tipomov != tm_fattura)
|
||||
{
|
||||
if (game.ok())
|
||||
return error_box("La partita %d '%s' esiste gia'.", anno, (const char*)game.numero());
|
||||
@ -1218,12 +1268,7 @@ void TGame_mask::update_saldo_clifo()
|
||||
add_importo(r, pag);
|
||||
add_importo(r, imp);
|
||||
r.add("Saldo ");
|
||||
|
||||
if (conto().tipo() == 'C')
|
||||
r << "cliente";
|
||||
else
|
||||
r << "fornitore";
|
||||
r << ' ' << conto().sottoconto();
|
||||
append_conto(r);
|
||||
}
|
||||
|
||||
long TGame_mask::number_distance(const char* k, const char* n) const
|
||||
@ -1233,12 +1278,12 @@ long TGame_mask::number_distance(const char* k, const char* n) const
|
||||
TString16 num(n); num.upper(); num.trim();
|
||||
const int nl = num.len();
|
||||
long dist = 0;
|
||||
for (int i = max(kl, nl)-1; i >= 0; i--)
|
||||
for (int i = kl-1; i >= 0; i--)
|
||||
{
|
||||
const char kc = i < kl ? key[i] : 0;
|
||||
const char nc = i < nl ? num[i] : 0;
|
||||
const int d = kc - nc;
|
||||
dist += d*d;
|
||||
const long d = abs(kc - nc) * (kl - i) * 32;
|
||||
dist += d;
|
||||
}
|
||||
return dist;
|
||||
}
|
||||
@ -1323,14 +1368,15 @@ bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) co
|
||||
TRectype oldpag = p.pagamento(nriga, nrata, nrigp);
|
||||
TRiga_partite& somma = p.riga(nrigp);
|
||||
|
||||
TPay_mask* pm = new TPay_mask;
|
||||
TPay_mask* pm = new TPay_mask; // We must create maskson the heap
|
||||
TPay_mask& m = *pm;
|
||||
|
||||
|
||||
if (nriga == TPartita::UNASSIGNED)
|
||||
{
|
||||
nriga = p.primo_pagamento();
|
||||
TRiga_partite& riga = p.riga(nriga);
|
||||
const TRiga_scadenze& scaden = riga.new_row(); // Crea una rata falsa
|
||||
TRiga_scadenze& scaden = riga.new_row(); // Crea una rata falsa
|
||||
scaden.put(SCAD_DATASCAD, somma.get(PART_DATADOC));
|
||||
m.set_pag(oldpag, scaden, _importo);
|
||||
riga.destroy_rows(); // Distrugge la rata falsa
|
||||
}
|
||||
@ -1382,10 +1428,10 @@ bool TGame_mask::edit_pagamento(TPartita& p, int nriga, int nrata, int nrigp) co
|
||||
else
|
||||
app().notify_edit_pagamento(p, newpag, val);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
delete pm;
|
||||
|
||||
|
||||
return key != K_ESC;
|
||||
}
|
||||
|
||||
|
@ -134,10 +134,15 @@ TValuta::TValuta() : _cod(""), _dat(TODAY), _cam(1.0)
|
||||
|
||||
void TValuta::adjust()
|
||||
{
|
||||
if (_cam <= 1.0)
|
||||
if (_cod.empty() || _cod == "LIT")
|
||||
{
|
||||
_cod.cut(0);
|
||||
_cam = 1.0;
|
||||
}
|
||||
|
||||
if (_cam <= ZERO)
|
||||
{
|
||||
_cod = "";
|
||||
_dat = TDate(TODAY);
|
||||
_cam = 1.0;
|
||||
}
|
||||
}
|
||||
@ -190,8 +195,8 @@ void TValuta::set(TMask& m, short v, short d, short c) const
|
||||
|
||||
void TValuta::get(const TMask& m, short v, short d, short c)
|
||||
{
|
||||
if (v > 0) _cod = m.get(v);
|
||||
if (d > 0) _dat = m.get(d);
|
||||
_cod = m.get(v);
|
||||
_dat = m.get(d);
|
||||
_cam = m.get_real(c);
|
||||
adjust();
|
||||
}
|
||||
@ -576,12 +581,14 @@ TRiga_scadenze& TRiga_partite::new_row(int r)
|
||||
return scad;
|
||||
}
|
||||
|
||||
// Elimina la rata r ed i suoi pagamenti, se r < 1 allora elimina tutte le rate
|
||||
// Certified 99%
|
||||
void TRiga_partite::elimina_rata(int r)
|
||||
{
|
||||
const int from = r <= 0 ? 1 : r;
|
||||
const int to = r <= 0 ? rate() : r;
|
||||
for (r = from; r <= to; r++)
|
||||
{
|
||||
for (r = to; r >= from; r--) // E' necessario andare all'indietro perche'
|
||||
{ // il metodo rate() funzioni sempre correttamente
|
||||
TRiga_scadenze& scad = rata(r);
|
||||
for (int p = scad.last(); p > 0; p = scad.pred(p))
|
||||
scad.elimina_pagamento(p);
|
||||
@ -589,6 +596,8 @@ void TRiga_partite::elimina_rata(int r)
|
||||
}
|
||||
}
|
||||
|
||||
// Ritorna il numero dell'ultima rata pagata o 0 se non ce ne sono
|
||||
// Certified 100%
|
||||
int TRiga_partite::ultima_ratapagata() const
|
||||
{
|
||||
for (int r = rate(); r > 0; r--)
|
||||
@ -596,6 +605,8 @@ int TRiga_partite::ultima_ratapagata() const
|
||||
return r;
|
||||
}
|
||||
|
||||
// Ritorna il tipo movimento di una riga di partita
|
||||
// Certified 100%
|
||||
tipo_movimento TRiga_partite::tipo() const
|
||||
{
|
||||
const tipo_movimento tm = (tipo_movimento)get_int(PART_TIPOMOV);
|
||||
@ -603,6 +614,8 @@ tipo_movimento TRiga_partite::tipo() const
|
||||
return tm;
|
||||
}
|
||||
|
||||
// Legge le rate relative ad una riga di fattura
|
||||
// Certified 99%
|
||||
int TRiga_partite::read(TBaseisamfile& f, word op)
|
||||
{
|
||||
int err = TRectype::read(f, op);
|
||||
@ -617,30 +630,41 @@ int TRiga_partite::read(TBaseisamfile& f, word op)
|
||||
return err;
|
||||
}
|
||||
|
||||
// Registra una riga e le sue eventuali rate
|
||||
// Certified 100%
|
||||
int TRiga_partite::write(TBaseisamfile& f) const
|
||||
{
|
||||
const int err = is_fattura() ? TTree_rectype::write(f) : TRectype::write(f);
|
||||
return err;
|
||||
}
|
||||
|
||||
// Aggiorna una riga e le sue eventuali rate
|
||||
// Certified 100%
|
||||
int TRiga_partite::rewrite(TBaseisamfile& f) const
|
||||
{
|
||||
const int err = is_fattura() ? TTree_rectype::rewrite(f) : TRectype::rewrite(f);
|
||||
return err;
|
||||
}
|
||||
|
||||
// Elimina una riga e le sue eventuali rate
|
||||
// Certified 100%
|
||||
int TRiga_partite::remove(TBaseisamfile& f) const
|
||||
{
|
||||
const int err = is_fattura() ? TTree_rectype::remove(f) : TRectype::remove(f);
|
||||
return err;
|
||||
}
|
||||
|
||||
// Ritorna l'indice dell'ultimo pagamento della rata r o 0 se non ce ne sono
|
||||
// Certified 100%
|
||||
int TRiga_partite::ultimo_pagamento(int r) const
|
||||
{
|
||||
const TRiga_scadenze& s = rata(r);
|
||||
return s.last();
|
||||
}
|
||||
|
||||
// Aggiorna il campo field contenente un totale sottraendo il corrispondente valore di
|
||||
// un record prima (vec) e dopo la sua modifica (nuo)
|
||||
// Certified 100%
|
||||
bool TRiga_partite::update(const TRectype& vec, const TRectype& nuo, const char* field)
|
||||
{
|
||||
real totale(get(field));
|
||||
@ -671,6 +695,9 @@ bool TRiga_partite::update(const TImporto& vec, const TImporto& nuo,
|
||||
return zero;
|
||||
}
|
||||
|
||||
|
||||
// Cerca una rata con abbuoni o differenze cambio
|
||||
// Certified 99%
|
||||
int TRiga_partite::rata_con_abbuoni_diffcam() const
|
||||
{
|
||||
int found = 0;
|
||||
@ -680,16 +707,21 @@ int TRiga_partite::rata_con_abbuoni_diffcam() const
|
||||
for (int p = scad.last(); p > 0; p = scad.pred(p))
|
||||
{
|
||||
const TRectype& pag = scad.row(p);
|
||||
if (!pag.get_real(PART_ABBUONI).is_zero() || !pag.get_real(PART_DIFFCAM).is_zero())
|
||||
if (pag.get_char(PAGSCA_ACCSAL) == 'S')
|
||||
{
|
||||
found = s;
|
||||
break;
|
||||
if (!pag.get_real(PAGSCA_ABBUONI).is_zero() ||
|
||||
!pag.get_real(PAGSCA_DIFFCAM).is_zero())
|
||||
{
|
||||
found = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
// Determina se una riga e' in valuta in base al codice valuta
|
||||
bool TRiga_partite::in_valuta() const
|
||||
{
|
||||
const TString& cod = get(PART_CODVAL);
|
||||
@ -815,6 +847,7 @@ char TPartita::allineamento_richiesto() const
|
||||
#endif
|
||||
carica_allineamento();
|
||||
}
|
||||
|
||||
switch (conto().tipo())
|
||||
{
|
||||
case 'C': all = _cli_align; break;
|
||||
|
@ -86,8 +86,8 @@ public:
|
||||
real val2lit(const real& val) const;
|
||||
void val2lit(real& val) const;
|
||||
void val2lit(TImporto& imp) const;
|
||||
bool in_lire() const { return _cam == 1.0; }
|
||||
bool in_valuta() const { return _cam != 1.0; }
|
||||
bool in_lire() const { return _cod.empty(); }
|
||||
bool in_valuta() const { return _cod.not_empty(); }
|
||||
|
||||
void get(const TRectype& rec);
|
||||
void put(TRectype& rec) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user