Corretta gestione abbuoni
git-svn-id: svn://10.65.10.50/trunk@1729 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
3efc5de8c8
commit
a7ca6ce82d
106
cg/cg2105.cpp
106
cg/cg2105.cpp
@ -38,7 +38,7 @@ public:
|
||||
};
|
||||
|
||||
TGame_mask::TGame_mask(const TBill& bill)
|
||||
: TMask("cg2100p"), _conto(bill)
|
||||
: TMask("cg2100p"), _conto(bill)
|
||||
{
|
||||
const char tipocf[2] = { bill.tipo(), '\0' };
|
||||
set(P_TIPOC, tipocf);
|
||||
@ -113,8 +113,8 @@ bool TGame_mask::scambio_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
const TGame_mask& gm = (const TGame_mask&)f.mask();
|
||||
const TSheet_field& sheet = gm.scadenze();
|
||||
sheet.swap_columns(103, 109);
|
||||
sheet.swap_columns(104, 110);
|
||||
sheet.swap_columns(103, 110); // Scambia colonne
|
||||
sheet.swap_columns(104, 111);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -402,22 +402,22 @@ int TPrimanota_application::nuovo_pagamento(TPartita& partita, int nriga, int ra
|
||||
int caus = 2; // Calcola riga causale per la contropartita in base al tipo pagamento
|
||||
switch (riga_scad.get_int(SCAD_TIPOPAG))
|
||||
{
|
||||
case 2: // Tratta
|
||||
case 7: // Tratta accettata
|
||||
caus = 3; break;
|
||||
case 3: // Ricevuta bancaria
|
||||
caus = 4; break;
|
||||
case 4: // Cessione
|
||||
caus = 5; break;
|
||||
case 5: // Paghero'
|
||||
caus = 6; break;
|
||||
case 6: // Fattura di credito
|
||||
caus = 7; break;
|
||||
case 1: // Rimessa
|
||||
case 8: // Rapporti interbancari diretti
|
||||
case 9: // Bonifico
|
||||
default:
|
||||
caus = 2; break;
|
||||
case 2: // Tratta
|
||||
case 7: // Tratta accettata
|
||||
caus = 3; break;
|
||||
case 3: // Ricevuta bancaria
|
||||
caus = 4; break;
|
||||
case 4: // Cessione
|
||||
caus = 5; break;
|
||||
case 5: // Paghero'
|
||||
caus = 6; break;
|
||||
case 6: // Fattura di credito
|
||||
caus = 7; break;
|
||||
case 1: // Rimessa
|
||||
case 8: // Rapporti interbancari diretti
|
||||
case 9: // Bonifico
|
||||
default:
|
||||
caus = 2; break;
|
||||
}
|
||||
|
||||
TBill contro; causale().bill(caus, contro); // Legge conto contropartita
|
||||
@ -494,7 +494,11 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
|
||||
{
|
||||
const int old_riga = bill2pos(old_conto, 'I');
|
||||
if (old_riga >= 0)
|
||||
sub_cgs_imp(old_riga, old_importo);
|
||||
{
|
||||
const bool empty = sub_cgs_imp(old_riga, old_importo);
|
||||
if (empty && (new_importo.is_zero() || new_conto != old_conto))
|
||||
reset_cgs_row(old_riga);
|
||||
}
|
||||
|
||||
// Importo della contropartita
|
||||
if (!new_importo.is_zero())
|
||||
@ -510,9 +514,9 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
|
||||
// Aggiornamento ritenute
|
||||
const real old_ritenute(old_pag.get(PAGSCA_RITENUTE));
|
||||
const real new_ritenute(new_pag.get(PAGSCA_RITENUTE));
|
||||
const TImporto grow_ritenute(controsez, new_ritenute-old_ritenute);
|
||||
if (!grow_ritenute.is_zero())
|
||||
if (old_ritenute != new_ritenute)
|
||||
{
|
||||
const TImporto grow_ritenute(controsez, new_ritenute-old_ritenute);
|
||||
const riga = type2pos('F');
|
||||
if (riga < 0)
|
||||
{
|
||||
@ -520,7 +524,10 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
|
||||
set_cgs_row(riga, grow_ritenute, conto_rit, "", 'F');
|
||||
}
|
||||
else
|
||||
add_cgs_imp(riga, grow_ritenute);
|
||||
{
|
||||
const bool empty = add_cgs_imp(riga, grow_ritenute);
|
||||
if (empty) reset_cgs_row(riga);
|
||||
}
|
||||
}
|
||||
|
||||
char old_ap, new_ap;
|
||||
@ -537,7 +544,9 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
|
||||
{
|
||||
const int riga_abb = type2pos(old_ap);
|
||||
CHECK(riga_abb >= 0, "Chiss'e' fregato gli abbuoni?");
|
||||
sub_cgs_imp(riga_abb, old_abbuono);
|
||||
const bool empty = sub_cgs_imp(riga_abb, old_abbuono);
|
||||
if (empty && new_ap != old_ap)
|
||||
reset_cgs_row(riga_abb);
|
||||
|
||||
// Sottrae l'abbuono con la sezione invertita dalla riga contabile
|
||||
add_cgs_imp(riga_contabile, old_abbuono);
|
||||
@ -560,20 +569,17 @@ bool TPrimanota_application::notify_edit_pagamento(TPartita& p, TRectype& new_pa
|
||||
if (old_diffcam != new_diffcam)
|
||||
{
|
||||
const int riga_diffcam = type2pos('C');
|
||||
if (!old_diffcam.is_zero()) // Se c'era una differenza cambi
|
||||
TImporto grow_diffcam(new_diffcam); grow_diffcam -= old_diffcam;
|
||||
|
||||
if (riga_diffcam < 0)
|
||||
{
|
||||
CHECK(riga_diffcam >= 0, "Chiss'e' fregato la differenza cambi?");
|
||||
sub_cgs_imp(riga_diffcam, old_diffcam);
|
||||
TBill conto_diffcam; causale().bill(12, conto_diffcam);
|
||||
set_cgs_row(riga_diffcam, grow_diffcam, conto_diffcam, "", 'C');
|
||||
}
|
||||
if (!new_diffcam.is_zero())
|
||||
else
|
||||
{
|
||||
if (riga_diffcam < 0)
|
||||
{
|
||||
TBill conto_diffcam; causale().bill(12, conto_diffcam);
|
||||
set_cgs_row(riga_diffcam, new_diffcam, conto_diffcam, "", 'C');
|
||||
}
|
||||
else
|
||||
add_cgs_imp(riga_diffcam, new_diffcam);
|
||||
const bool empty = add_cgs_imp(riga_diffcam, grow_diffcam);
|
||||
if (empty) reset_cgs_row(riga_diffcam);
|
||||
}
|
||||
}
|
||||
|
||||
@ -643,20 +649,28 @@ bool TPrimanota_application::notify_cgline_deletion(TPartita& partita, long nreg
|
||||
{
|
||||
bool found = FALSE;
|
||||
|
||||
for (int r = partita.last(); r > 0; r = partita.pred(r))
|
||||
for (int p = partita.last(); p > 0; p = partita.pred(p))
|
||||
{
|
||||
TRiga_partite& part = partita.riga(r);
|
||||
const long reg = part.get_long(PART_NREG);
|
||||
if (reg == nreg) // Se la registrazione corrisponde
|
||||
const TRiga_partite& part = partita.riga(p);
|
||||
if (part.get_int(PART_TIPOMOV) == 1)
|
||||
{
|
||||
const int num = part.get_int(PART_NUMRIG);
|
||||
if (numrig > 0)
|
||||
for (int r = part.rate(); r > 0; r--)
|
||||
{
|
||||
|
||||
}
|
||||
else // numrig == 0
|
||||
{
|
||||
found = TRUE; // usata solo da ::remove
|
||||
const TRiga_scadenze& scad = part.rata(r);
|
||||
for (int s = scad.last(); s > 0; s = scad.pred(s))
|
||||
{
|
||||
const TRiga_partite& sum = partita.riga(s);
|
||||
if (sum.get_long(PART_NREG) == nreg &&
|
||||
(numrig == 0 || sum.get_int(PART_NUMRIG) == numrig))
|
||||
{
|
||||
TRectype pag(scad.row(s));
|
||||
pag.zero(PAGSCA_IMPORTO);
|
||||
pag.zero(PAGSCA_IMPORTOVAL);
|
||||
pag.zero(PAGSCA_RITENUTE);
|
||||
notify_edit_pagamento(partita, pag);
|
||||
found = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1388,27 +1388,10 @@ bool TRiga_scadenze::modifica_pagamento(const TRectype& new_pag,
|
||||
else
|
||||
new_abb.valore() = ZERO;
|
||||
|
||||
if (old_abb != new_abb)
|
||||
{
|
||||
const TImporto old(sum.sezione(), old_pag.get_real(PART_ABBUONI));
|
||||
TImporto abbuoni(sum.get_char(PART_SEZABB), sum.get_real(PART_ABBUONI));
|
||||
abbuoni -= old;
|
||||
abbuoni += imp;
|
||||
abbuoni.normalize();
|
||||
sum.put(PART_SEZABB, abbuoni.sezione());
|
||||
sum.put(PART_ABBUONI, abbuoni.valore());
|
||||
}
|
||||
sum.update(old_abb, new_abb, PART_SEZABB, PART_ABBUONI);
|
||||
|
||||
new_diffcam = calcola_differenza_cambio(TRUE);
|
||||
if (old_diffcam != new_diffcam)
|
||||
{
|
||||
TImporto tot_dc(sum.get_char(PART_SEZDIFCAM), sum.get_real(PART_DIFFCAM));
|
||||
tot_dc -= old_diffcam;
|
||||
tot_dc += new_diffcam;
|
||||
tot_dc.normalize();
|
||||
sum.put(PART_SEZDIFCAM, tot_dc.sezione());
|
||||
sum.put(PART_DIFFCAM, tot_dc.valore());
|
||||
}
|
||||
sum.update(old_diffcam, new_diffcam, PART_SEZDIFCAM, PART_DIFFCAM);
|
||||
|
||||
sum.update(old_pag, new_pag, PART_IMPORTO);
|
||||
sum.update(old_pag, new_pag, PART_IMPORTOVAL);
|
||||
@ -1460,13 +1443,40 @@ int TRiga_partite::ultimo_pagamento(int r) const
|
||||
|
||||
bool TRiga_partite::update(const TRectype& vec, const TRectype& nuo, const char* field)
|
||||
{
|
||||
real totale = get_real(field);
|
||||
real totale(get(field));
|
||||
totale -= vec.get_real(field);
|
||||
totale += nuo.get_real(field);
|
||||
put(field, totale);
|
||||
return !totale.is_zero();
|
||||
return totale.is_zero();
|
||||
}
|
||||
|
||||
bool TRiga_partite::update(const TImporto& vec, const TImporto& nuo,
|
||||
const char* sez, const char* val)
|
||||
{
|
||||
bool zero = FALSE;
|
||||
TImporto grow(nuo); grow -= vec; // Variazione al totale
|
||||
|
||||
if (!grow.is_zero())
|
||||
{
|
||||
const char sezione = get_char(sez); // Sezione del totale
|
||||
TImporto totale;
|
||||
if (sezione > ' ') // Se c'era una sezione (e quindi un importo) ...
|
||||
totale.set(sezione, get_real(val)); // ... inizializza il totale
|
||||
else
|
||||
CHECKS(vec.is_zero(), "Sezione errata per l'importo ", val);
|
||||
totale += grow; // incrementa il totale
|
||||
totale.normalize();
|
||||
put(sez, totale.sezione()); // Aggiorna il totale sul record
|
||||
put(val, totale.valore());
|
||||
zero = totale.is_zero();
|
||||
}
|
||||
else
|
||||
zero = get_real(val).is_zero();
|
||||
|
||||
return zero;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TPartita
|
||||
|
@ -193,6 +193,9 @@ public:
|
||||
const TRectype& row(int r) const { return ((TRecord_array&)_recarr).row(r, FALSE); }
|
||||
TRectype& row(int r, bool create) { return _recarr.row(r, create); }
|
||||
|
||||
int last() const { return _recarr.last_row(); }
|
||||
int pred(int r) const { return _recarr.pred_row(r); }
|
||||
|
||||
TTree_rectype(const TRectype& testata, const TRectype& riga, const char* num);
|
||||
TTree_rectype(int testata, int riga, const char* num);
|
||||
TTree_rectype(const TTree_rectype& t);
|
||||
@ -244,6 +247,7 @@ class TRiga_partite : public TTree_rectype
|
||||
|
||||
protected:
|
||||
bool update(const TRectype& vec, const TRectype& nuo, const char* field);
|
||||
bool update(const TImporto& vec, const TImporto& nuo, const char* sez, const char* val);
|
||||
|
||||
public: // TTree_rectype
|
||||
virtual TObject* dup() const { return new TRiga_partite(*this); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user