Patch level : 12.0 640

Files correlati     : cg2.exe
Commento            : Corretti errori di calcolo totale documento nel saldaconto
                      Modificata segnalazione relativi alla data di comeptenza inferiore o UGUALE alla
                      data di chiusura.
This commit is contained in:
AlexBonazzi 2018-11-05 20:42:59 +01:00
parent 3535c88e0a
commit f6e8a45d49
3 changed files with 100 additions and 43 deletions

View File

@ -509,7 +509,7 @@ real TPrimanota_application::calcola_saldo() const
if (pag) if (pag)
{ {
const char tipo = row_type(*r); const char tipo = row_type(*r);
if (strchr("ACGKP", tipo) != NULL) // Abbuoni attivi, differenze cambio, spese, ... if (strchr("GK", tipo) != NULL) // Abbuoni attivi, differenze cambio, spese, ... // (A o P) Abbuoni e (C) Differenze cambio perchè c'erano ? non (T) totolae documento perchè pagamento
saldaconto += importo; saldaconto += importo;
} }
} }
@ -580,7 +580,10 @@ HIDDEN bool imptot_error(const TImporto& imptot, const TImporto& impsal, bool va
msg << TR("\nSi desidera correggere il totale documento?"); msg << TR("\nSi desidera correggere il totale documento?");
ok = a.cgs().yesno_box(msg); ok = a.cgs().yesno_box(msg);
if (ok) if (ok)
{
m.set(F_TOTALE, cassa.valore()); m.set(F_TOTALE, cassa.valore());
a.calcola_saldo();
}
} }
return ok; return ok;
} }
@ -671,7 +674,8 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
} }
} }
if (errato)
if (errato)
{ {
TString msg(128); TString msg(128);
const TCurrency euro(speso.valore()); const TCurrency euro(speso.valore());
@ -699,7 +703,7 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k)
return false; return false;
} }
} }
if (strchr("ACGKPT", tipo) != NULL) if (strchr("GKT", tipo) != NULL) // Abbuoni attivi, differenze cambio, spese, ... // (A o P) Abbuoni e (C) Differenze cambio perchè c'erano ?
{ {
saldaconto += importo; saldaconto += importo;
if (in_valuta) if (in_valuta)
@ -2497,13 +2501,20 @@ bool TPrimanota_application::datacomp_handler(TMask_field& f, KEY key)
} }
const TDate chiusura = app()._esercizi[ae].chiusura(); const TDate chiusura = app()._esercizi[ae].chiusura();
if (chiusura.ok() && dc <= chiusura) if (chiusura.ok() && dc < chiusura)
{ {
f.error_box(FR("%s è antecedente al %s,\ndata di chiusura dell'esercizio %d"), f.error_box(FR("%s è antecedente al %s,\ndata di chiusura dell'esercizio %d"),
data, chiusura.stringa(), ae); data, chiusura.stringa(), ae);
// Errore non bloccante // Errore non bloccante
} }
else
if (chiusura.ok() && dc == chiusura)
{
f.error_box(FR("%s è uguale al %s,\ndata di chiusura dell'esercizio %d"),
data, chiusura.stringa(), ae);
// Errore non bloccante
}
} }
else else
{ {
@ -3287,17 +3298,50 @@ bool TPrimanota_application::totdoc_handler(TMask_field& f, KEY key)
if (a.is_pagamento()) if (a.is_pagamento())
a.calcola_saldo(); a.calcola_saldo();
} }
} }
if (key == K_TAB && a.is_pagamento() && !a._as400)
if (key == K_ENTER) {
{ m.show(K_RESIDUO, f.get().full());
const TCurrency totale(real(f.get())); m.show(K_TOTALE, f.get().full());
if (totale.get_num().is_zero())
}
if (key == K_ENTER)
{
if (a.is_pagamento()&& ! a._as400)
{
TImporto importo, totdocsc,tot;
TSheet_field& cgrows = a.cgs();
FOR_EACH_SHEET_ROW_BACK(cgrows, i, r)
{
const char tipo = row_type(*r);
if (strchr("GK", tipo) != NULL) // Abbuoni attivi, differenze cambio, spese, ... // (A o P) Abbuoni e (C) Differenze cambio perchè c'erano ? non (T) totolae documento perchè pagamento
{
TImporto importo;
importo = *r;
totdocsc += importo;
}
}
if (tot.valore().is_zero())
{
totdocsc.normalize(a.causale().sezione_clifo());
tot = totdocsc;
f.set(tot.valore().string());
a.calcola_saldo();
}
}
TCurrency totale(real(f.get()));
if (totale.get_num().is_zero())
ok = yesno_box(TR("Totale documento nullo: continuare ugualmente?")); ok = yesno_box(TR("Totale documento nullo: continuare ugualmente?"));
if (ok) if (ok)
{ {
const TValuta cambio(m, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO); const TValuta cambio(m, SK_VALUTA, SK_DATACAMBIO, SK_CAMBIO);
if (cambio.in_valuta()) if (cambio.in_valuta())
{ {
const real totval(m.get(SK_TOTDOCVAL)); const real totval(m.get(SK_TOTDOCVAL));

View File

@ -34,6 +34,8 @@
#endif #endif
class TDati_mov_auto; class TDati_mov_auto;
enum CGMaskType { _query = 0, _no_iva = 1, _iva = 2, _occas = 3};
class TPrimanota_application : public TRelation_application class TPrimanota_application : public TRelation_application
{ {
TMovimentoPN* _rel; // Relazione principale TMovimentoPN* _rel; // Relazione principale
@ -264,7 +266,6 @@ protected:
void ivas_pack(); void ivas_pack();
void cgs_pack(); void cgs_pack();
bool ci_sono_importi(const TSheet_field& cgs) const; bool ci_sono_importi(const TSheet_field& cgs) const;
real calcola_saldo() const;
real calcola_imp() const; real calcola_imp() const;
void add_cgs_tot(TMask& m); void add_cgs_tot(TMask& m);
@ -324,9 +325,12 @@ public:
static bool iva_notify(TSheet_field& s, int r, KEY key); static bool iva_notify(TSheet_field& s, int r, KEY key);
static bool cg_notify(TSheet_field& s, int r, KEY key); static bool cg_notify(TSheet_field& s, int r, KEY key);
TMask * mask(CGMaskType type) { return _msk[type]; }
void type2colors(char tipor, COLOR& back, COLOR& fore); void type2colors(char tipor, COLOR& back, COLOR& fore);
void set_type_colors(char tipor, COLOR back, COLOR fore); void set_type_colors(char tipor, COLOR back, COLOR fore);
void reset_colors(); void reset_colors();
real calcola_saldo() const;
TCausale& causale() const { return *_causale; } TCausale& causale() const { return *_causale; }
TPartite_array& partite() { return _partite; } // Partite editate TPartite_array& partite() { return _partite; } // Partite editate

View File

@ -256,8 +256,8 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad,
const char sez_fat = fatt.sezione(); const char sez_fat = fatt.sezione();
set(S_SEZIONE_SCAD, sez_fat == 'A' ? "A" : "D"); // Sezione della riga set(S_SEZIONE_SCAD, sez_fat == 'A' ? "A" : "D"); // Sezione della riga
if (assigned()) if (assigned())
{ {
set(S_IMPORTO_SCAD, scad.get(SCAD_IMPORTO)); // Importo della rata set(S_IMPORTO_SCAD, scad.get(SCAD_IMPORTO)); // Importo della rata
if (in_valuta) if (in_valuta)
set(S_IMPORTOVAL_SCAD, scad.get(SCAD_IMPORTOVAL)); // Importo in valuta set(S_IMPORTOVAL_SCAD, scad.get(SCAD_IMPORTOVAL)); // Importo in valuta
@ -309,6 +309,16 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad,
_pagabile += oldimp; _pagabile += oldimp;
#endif #endif
if (_pagabile.is_zero())
{
hide(S_RESIDUOPAG);
hide(S_RESIDUORATA); // Se non assegnato nascondi residuo rata
}
else
{
show(S_RESIDUOPAG);
show(S_RESIDUORATA); // Se non assegnato nascondi residuo rata
}
// Il flag di saldo/acconto e' attivo solo se non ci sono acconti, cioe': // Il flag di saldo/acconto e' attivo solo se non ci sono acconti, cioe':
// pagamento non assegnato o con data documento antecedente quella della fattura // pagamento non assegnato o con data documento antecedente quella della fattura
@ -333,7 +343,7 @@ void TPay_mask::set_pag(const TRectype& oldpag, const TRiga_scadenze& scad,
#else #else
set_handler(S_GRUPPO, conto_handler); set_handler(S_GRUPPO, conto_handler);
set_handler(S_CONTO, conto_handler); set_handler(S_CONTO, conto_handler);
const bool mostra_conto = !sum.is_nota_credito() && app().curr_mask().get_real(F_TOTALE) != ZERO; const bool mostra_conto = !sum.is_nota_credito(); // && app().curr_mask().get_real(F_TOTALE) != ZERO;
show(-2, mostra_conto); // mostra/nasconde conto contropartita show(-2, mostra_conto); // mostra/nasconde conto contropartita
if (!mostra_conto) if (!mostra_conto)
reset(-2); reset(-2);
@ -1032,7 +1042,9 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
if (pag.get_char(PAGSCA_ACCSAL) == 'S') if (pag.get_char(PAGSCA_ACCSAL) == 'S')
{ {
const TImporto abb(sez, pag.get_real(PAGSCA_ABBUONI)); const TImporto abb(sez, pag.get_real(PAGSCA_ABBUONI));
if (!abb.is_zero()) bool is_totdoc = app().mask(_no_iva)->get(F_TOTALE).full();
if (!abb.is_zero())
{ {
const char tipo_abb = pag.get_char(PAGSCA_PASSATT); const char tipo_abb = pag.get_char(PAGSCA_PASSATT);
TToken_string& rabb = gm.add_colored_row(sheet, tipo_abb); TToken_string& rabb = gm.add_colored_row(sheet, tipo_abb);
@ -1040,13 +1052,18 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
if (in_valuta) if (in_valuta)
{ {
TImporto abb_lit = abb; TImporto abb_lit = abb;
prima_valuta.val2eur(abb_lit); prima_valuta.val2eur(abb_lit);
gm.add_importo(rabb, abb_lit); if (is_totdoc)
gm.add_importo(rabb, abb, prima_valuta.codice()); {
gm.add_importo(rabb, abb_lit);
gm.add_importo(rabb, abb, prima_valuta.codice());
}
} }
else else
{ {
gm.add_importo(rabb, abb); if (is_totdoc)
gm.add_importo(rabb, abb);
rabb.add(""); rabb.add("");
} }
rabb.add((int)sum.tipo(), 11); rabb.add((int)sum.tipo(), 11);
@ -1060,7 +1077,8 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
{ {
TToken_string& rdiff = gm.add_colored_row(sheet, 'C'); TToken_string& rdiff = gm.add_colored_row(sheet, 'C');
rdiff.add(TR("Differenza cambio"), 4); rdiff.add(TR("Differenza cambio"), 4);
gm.add_importo(rdiff, diff); if (is_totdoc)
gm.add_importo(rdiff, diff);
rdiff.add((int)sum.tipo(), 11); rdiff.add((int)sum.tipo(), 11);
} }
} }
@ -1152,6 +1170,8 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
if (pag.get_char(PAGSCA_ACCSAL) == 'S' || !pag.get_real(PAGSCA_ABBUONI).is_zero()) if (pag.get_char(PAGSCA_ACCSAL) == 'S' || !pag.get_real(PAGSCA_ABBUONI).is_zero())
{ {
const TImporto abb(sez, pag.get_real(PAGSCA_ABBUONI)); const TImporto abb(sez, pag.get_real(PAGSCA_ABBUONI));
bool is_totdoc = app().mask(_no_iva)->get(F_TOTALE).full();
if (!abb.is_zero()) if (!abb.is_zero())
{ {
const char tipo_abb = pag.get_char(PAGSCA_PASSATT); const char tipo_abb = pag.get_char(PAGSCA_PASSATT);
@ -1161,34 +1181,23 @@ bool TGame_mask::partite_notify(TSheet_field& partite, int r, KEY k)
{ {
TImporto abb_lit = abb; TImporto abb_lit = abb;
prima_valuta.val2eur(abb_lit); prima_valuta.val2eur(abb_lit);
gm.add_importo(rabb, abb_lit); if (is_totdoc)
gm.add_importo(rabb, abb, prima_valuta.codice()); {
gm.add_importo(rabb, abb_lit);
gm.add_importo(rabb, abb, prima_valuta.codice());
}
tot_lit += abb_lit; tot_lit += abb_lit;
tot_val += abb; tot_val += abb;
} }
else else
{ {
gm.add_importo(rabb, abb); if (is_totdoc)
gm.add_importo(rabb, abb);
rabb.add(""); rabb.add("");
tot_lit += abb; tot_lit += abb;
} }
rabb.add((int)sum.tipo(), 11); rabb.add((int)sum.tipo(), 11);
} }
/* Continuo a ritenre impossibile ... per ora
// Le differenze cambio possono esistere solo in valuta
if (in_valuta)
{
const TImporto diff(sez, pag.get_real(PAGSCA_DIFFCAM));
if (!diff.is_zero())
{
TToken_string& rdiff = gm.add_colored_row(sheet, 'C');
rdiff.add(TR("Differenza cambio"), 4);
gm.add_importo(rdiff, diff);
rdiff.add((int)sum.tipo(), 11);
}
}
*/
} // Il pagamento era a saldo } // Il pagamento era a saldo
} // Fine ciclo non assegnati } // Fine ciclo non assegnati