Corretta gestione modifica rata in prima nota
git-svn-id: svn://10.65.10.50/trunk@1942 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
a57f4d2b69
commit
919e99206f
@ -552,6 +552,11 @@ void TPrimanota_application::init_modify_mode(TMask& m)
|
||||
{
|
||||
const long numreg = m.get_long(F_NUMREG);
|
||||
partite().add_numreg(numreg);
|
||||
if (iva() != nessuna_iva)
|
||||
{
|
||||
const TPartita* game = partite().first();
|
||||
m.enable(DLG_DELREC, game == NULL || !game->esistono_abbuoni_diffcam());
|
||||
}
|
||||
}
|
||||
|
||||
calcola_saldo(); // Verifica eventuali sbilanci contabili
|
||||
|
@ -1864,14 +1864,14 @@ bool TPrimanota_application::totdocval_handler(TMask_field& f, KEY key)
|
||||
if (totale.is_zero())
|
||||
{
|
||||
totval *= cambio;
|
||||
m.set(F_TOTALE, totval.string());
|
||||
m.set(F_TOTALE, totval.string(), TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cambio.is_zero())
|
||||
{
|
||||
totale /= totval;
|
||||
m.set(S_CAMBIO, totale.string());
|
||||
m.set(S_CAMBIO, totale.string(), TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -162,6 +162,10 @@ bool TPrimanota_application::cambio_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
const real ex(f.get());
|
||||
pag->set_cambio(ex);
|
||||
|
||||
TSheet_field& ps = app().pags();
|
||||
pag->set_sheet(ps);
|
||||
ps.force_update();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
@ -292,11 +296,14 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
const real spese(0.0);
|
||||
|
||||
TPagamento& pag = *pagamento();
|
||||
|
||||
bool in_valuta = FALSE;
|
||||
if (cambio.sign() > 0)
|
||||
{
|
||||
pag.set_cambio(cambio);
|
||||
imponibile = real(m.get(S_TOTDOCVAL));
|
||||
imposta = ZERO;
|
||||
in_valuta = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -335,7 +342,9 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
// se invece la maschera contiene importi diversi da quelli
|
||||
// registrati si passa la palla al culano/a
|
||||
// TBC controllo se imponibile deve contenere le spese
|
||||
else if ((imponibile + imposta) != partita.get_real(PART_IMPORTO) ||
|
||||
else
|
||||
{
|
||||
if ((imponibile + imposta) != partita.get_real(in_valuta ? PART_IMPORTOVAL : PART_IMPORTO) ||
|
||||
imposta != partita.get_real(PART_IMPOSTA) ||
|
||||
spese != partita.get_real(PART_SPESE))
|
||||
{
|
||||
@ -345,6 +354,8 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
// nel qual caso, of course, si disabilitano gli automatismi
|
||||
if(!fromscratch) m.field(FS_RECALC).set("");
|
||||
}
|
||||
}
|
||||
|
||||
if (fromscratch)
|
||||
{
|
||||
pag.set_rate_auto();
|
||||
@ -382,6 +393,12 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
m.set(FS_AGENTE, scadenza.get(SCAD_CODAG));
|
||||
}
|
||||
}
|
||||
m.set(FS_RDIFFER, pag.rate_differenziate() ? "1" : "2");
|
||||
m.set(FS_NAMEPAG, pag.name());
|
||||
m.set(FS_TIPOPR, pag.desc_tpr());
|
||||
m.set(FS_MCOMM, pag.mese_commerciale() ? "X" : "");
|
||||
m.set(FS_RECALC, "X", TRUE);
|
||||
m.set(FS_NRATE, pag.n_rate());
|
||||
} //else
|
||||
}
|
||||
else
|
||||
@ -400,14 +417,10 @@ bool TPrimanota_application::read_scadenze(TMask& m)
|
||||
m.disable(-2); // Disabilita fornitore
|
||||
m.disable(-3); // Disabilita cambio
|
||||
m.disable(F_CODPAG); // Disabilita codice pagamento
|
||||
// m.disable(F_ANNORIF); // Disabilita anno partita
|
||||
// m.disable(F_NUMRIF); // Disabilita numero partita
|
||||
m.disable(FS_RESET); // Disabilita tasto di reset
|
||||
m.set(FS_RECALC, "", TRUE); // Disabilita ricalcolo automatico
|
||||
m.disable(FS_RECALC);
|
||||
}
|
||||
else
|
||||
m.set(FS_RECALC, "X");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ 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("Differenza cambio rata ", 4); rdiff << ra;
|
||||
rdiff.add("Differ. cambio rata ", 4); rdiff << ra;
|
||||
add_importo(rdiff, diff.normalize());
|
||||
}
|
||||
}
|
||||
@ -550,7 +550,7 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
|
||||
if (lastrow > 0)
|
||||
{
|
||||
TToken_string& sp = scadenze.row(scadenze.add(""));
|
||||
sp.add("Saldo partita ", 4); sp << anno << ' ' << num;
|
||||
sp.add("Saldo ", 4); sp << anno << ' ' << num;
|
||||
add_importo(sp, tot_lit.normalize());
|
||||
add_importo(sp, tot_val.normalize(), 2);
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ NUMBER 102 15
|
||||
BEGIN
|
||||
PROMPT 1 3 "Importo "
|
||||
PICTURE "."
|
||||
FLAGS "R"
|
||||
END
|
||||
|
||||
BOOLEAN 111
|
||||
@ -22,14 +21,12 @@ NUMBER 103 15 2
|
||||
BEGIN
|
||||
PROMPT 1 4 "Importo valuta "
|
||||
PICTURE ".2"
|
||||
FLAGS "R"
|
||||
END
|
||||
|
||||
NUMBER 104 8 3
|
||||
NUMBER 104 6 2
|
||||
BEGIN
|
||||
PROMPT 1 2 "Percentuale "
|
||||
PICTURE ".3"
|
||||
FLAGS "R"
|
||||
PICTURE ".2"
|
||||
END
|
||||
|
||||
NUMBER 105 2 0
|
||||
|
@ -36,7 +36,7 @@ BEGIN
|
||||
ITEM "4|Uguali finche' possibile" MESSAGE DISABLE,FS_NRATE
|
||||
END
|
||||
|
||||
NUMBER FS_NRATE 3 0
|
||||
NUMBER FS_NRATE 3
|
||||
BEGIN
|
||||
PROMPT 36 6 "Numero di rate "
|
||||
END
|
||||
@ -165,7 +165,7 @@ BEGIN
|
||||
ITEM "Scadenza@10"
|
||||
ITEM "Importo@15"
|
||||
ITEM "In Valuta@15"
|
||||
ITEM "Percentuale@12"
|
||||
ITEM "%@6"
|
||||
ITEM "Tipo"
|
||||
ITEM "Pagamento@32"
|
||||
ITEM "Ns.ABI"
|
||||
|
@ -348,7 +348,7 @@ void TPagamento::remove_rata(int i)
|
||||
|
||||
TToken_string& TPagamento::add_rata(real perc, int day, int type, const char* ulc)
|
||||
{
|
||||
TToken_string* tt = new TToken_string(16);
|
||||
TToken_string* tt = new TToken_string(64);
|
||||
|
||||
tt->add(day); // scadenza
|
||||
tt->add(perc.string()); // percentuale
|
||||
@ -437,9 +437,9 @@ TToken_string& TPagamento::set_rata(int index, const real& howmuch, const real&
|
||||
|
||||
if (nwr) tt = new TToken_string(64);
|
||||
|
||||
TDate oldd = index > 0 ? data_rata(index -1) : _inizio;
|
||||
int day = date - oldd;
|
||||
real toshare(_tpr < 4 ? _firstr : _secndr);
|
||||
const TDate oldd = index > 0 ? data_rata(index -1) : _inizio;
|
||||
const long day = date - oldd;
|
||||
const real toshare(_tpr < 4 ? _firstr : _secndr);
|
||||
|
||||
real hm = howmuch;
|
||||
if (index == first && _tpr > 0 && _tpr < 4)
|
||||
@ -608,6 +608,13 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
|
||||
// calcola defaults per tipo pagamento e scadenza
|
||||
// nel caso di rate nuove
|
||||
oldscad = scad_rata(1);
|
||||
if (_mcomm)
|
||||
{
|
||||
int mesi = oldscad / 30;
|
||||
if (mesi == 0) mesi = 1;
|
||||
oldscad = 30 * mesi;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (oldscad <= 0) oldscad = 30;
|
||||
@ -765,18 +772,16 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
|
||||
int type = oldtype;
|
||||
int nscd = oldscad;
|
||||
|
||||
int frs = (rdiff == 3 || rdiff == 4) ? row+1 : first;
|
||||
real mx = (rdiff == 3 || rdiff == 4) ? remainder : rmax;
|
||||
const int frs = (rdiff == 3 || rdiff == 4) ? row+1 : first;
|
||||
const real mx = (rdiff == 3 || rdiff == 4) ? remainder : rmax;
|
||||
|
||||
// cancelliamo tutto, va'
|
||||
for (int j = frs; j < srate.items(); j++)
|
||||
_rate.destroy(j);
|
||||
for (int j = srate.items()-1; j >= frs; j--) _rate.destroy(j);
|
||||
|
||||
if (rdiff == 2 && srate.items() > 1)
|
||||
const int n = srate.items(); // questo rimane per forza costante
|
||||
if (rdiff == 2 && n > 1)
|
||||
{
|
||||
// HERE
|
||||
|
||||
int n = srate.items(); // questo rimane per forza costante
|
||||
real tot = is_perc_modified ? real(100.0) : (_tpr < 4 ? _firstr : _secndr);
|
||||
real delta = is_perc_modified ? ZERO :
|
||||
((_tpr > 0 && _tpr) < 4 ? _secndr : ZERO);
|
||||
@ -791,7 +796,7 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
|
||||
if (nimp.sign() < 0) { _rate = srate; return P_NEG; }
|
||||
real remainder = tot - nimp;
|
||||
real div = remainder / real(n - 1);
|
||||
div.round(is_perc_modified ? 3 : _round);
|
||||
div.round(is_perc_modified ? 2 : _round);
|
||||
nimp = tot - (div * real(n-1));
|
||||
|
||||
for (int k = first; k < n; k++)
|
||||
@ -806,7 +811,7 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
|
||||
next_scad(dd,nscd,mcomm,k);
|
||||
|
||||
set_rata(k, is_perc_modified ? (k == first ? nimp : div) : ZERO,
|
||||
nscd, type);
|
||||
nscd, type, NULL, NULL, _inited ? dd.string() : NULL);
|
||||
if (!is_perc_modified)
|
||||
set_imprata (k, k == first ? (nimp + delta) : div);
|
||||
}
|
||||
@ -981,7 +986,7 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
|
||||
{
|
||||
real reminder = toshare - rfirst;
|
||||
real rdiv = reminder / real(_rate.items() - (1+first));
|
||||
rdiv.round( is_perc_modified ? _round : 3);
|
||||
rdiv.round( is_perc_modified ? _round : 2);
|
||||
rfirst += reminder - (rdiv * real(_rate.items() - (1+first)));
|
||||
rvl = rdiv;
|
||||
}
|
||||
@ -991,6 +996,14 @@ word TPagamento::recalc_rate(int row, bool is_perc_modified,
|
||||
rfirst += _secndr;
|
||||
|
||||
tr.add((j == first ? rfirst.string() : rvl.string()), is_perc_modified ? 4 : 1);
|
||||
|
||||
if (_cambio != 1.0)
|
||||
{
|
||||
real implit(tpay_rata(j));
|
||||
implit *= _cambio;
|
||||
implit.round();
|
||||
tr.add(implit.string(), 7);
|
||||
}
|
||||
}
|
||||
|
||||
// se e' il caso aggiungi l'importo fisso sulla prima rata
|
||||
@ -1283,8 +1296,6 @@ void TPagamento::set_sheet(TSheet_field& sf, int sscad)
|
||||
const bool in_valuta = _cambio != 1.0;
|
||||
|
||||
// si istanzia uno sheet di primanota
|
||||
// sf.destroy();
|
||||
|
||||
for (int i = 0; i < n_rate(); i++)
|
||||
{
|
||||
TToken_string& ts = sf.row(i);
|
||||
|
@ -877,6 +877,19 @@ bool TPartita::utilizzata(int nrigp) const
|
||||
return _unassigned.exist(nrigp);
|
||||
}
|
||||
|
||||
|
||||
bool TPartita::esistono_abbuoni_diffcam() const
|
||||
{
|
||||
for (int r = last(); r > 0; r = pred(r))
|
||||
{
|
||||
const TRiga_partite& row = riga(r);
|
||||
if (!row.get_real(PART_ABBUONI).is_zero() || !row.get_real(PART_DIFFCAM).is_zero())
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
bool TPartita::modifica_pagamento(const TRectype& new_pag, const TValuta& valuta,
|
||||
char& old_ap, TImporto& old_abb, TImporto& old_diffcam,
|
||||
char& new_ap, TImporto& new_abb, TImporto& new_diffcam)
|
||||
@ -1094,6 +1107,13 @@ void TPartita::scollega_pagamenti(int r, int s)
|
||||
pag.put(PAGSCA_ACCSAL, 'A');
|
||||
pag.put(PAGSCA_NRIGA, (int)TPartita::UNASSIGNED);
|
||||
pag.put(PAGSCA_NRATA, (int)TPartita::UNASSIGNED);
|
||||
if (_unassigned.exist(j))
|
||||
{
|
||||
TRectype& unas = _unassigned.row(j, FALSE);
|
||||
somma(pag, unas, PAGSCA_IMPORTO);
|
||||
somma(pag, unas, PAGSCA_IMPORTOVAL);
|
||||
}
|
||||
else
|
||||
_unassigned.add_row(pag);
|
||||
sc.rows_array().destroy_row(j);
|
||||
}
|
||||
|
@ -202,6 +202,7 @@ public:
|
||||
TRectype& pagamento(int nriga, int nrata, int nrigp);
|
||||
bool rata_chiusa(int nriga, int nrata) const;
|
||||
bool esiste(int nriga, int nrata = 0, int nrigp = 0) const;
|
||||
bool esistono_abbuoni_diffcam() const;
|
||||
|
||||
// assegna riga e figli ad altra partita
|
||||
void sposta_riga(int r, TPartita& part);
|
||||
|
Loading…
x
Reference in New Issue
Block a user