Patch level : 2.2
Files correlati : ve1.exe Ricompilazione Demo : [ ] Commento : Corretta stampa della lista documenti: calcolava male, anzi maliissimo, gli imponibili e le imposte git-svn-id: svn://10.65.10.50/trunk@13743 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
79e78194d2
commit
f5c3668c4d
@ -26,45 +26,30 @@
|
||||
|
||||
class TDocisamfile : public TLocalisamfile
|
||||
{
|
||||
TDocumentoEsteso *_doc;
|
||||
TDocumentoEsteso* _doc;
|
||||
|
||||
public:
|
||||
virtual TRectype& curr() const { return (TRectype&) *_doc; }
|
||||
virtual int readat(TRecnotype nrec, word lockop = _nolock);
|
||||
TDocisamfile(TDocumentoEsteso* doc) : TLocalisamfile(LF_DOC) { _doc = doc;}
|
||||
TDocisamfile(TDocumentoEsteso* doc) : TLocalisamfile(LF_DOC), _doc(doc)
|
||||
{ CHECK(_doc, "Invalid document"); }
|
||||
virtual ~TDocisamfile() {};
|
||||
};
|
||||
|
||||
int TDocisamfile::readat(TRecnotype nrec, word lockop)
|
||||
{
|
||||
int err = TBaseisamfile::readat(nrec, _nolock);
|
||||
if (err == NOERR)
|
||||
{
|
||||
err = _doc->read(curr());
|
||||
if (err == NOERR)
|
||||
{
|
||||
_doc->summary_reset(TRUE); // forza il ricalcolo perche' trattasi di documento diverso
|
||||
_doc->summary_filter(1);
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
class TRDocisamfile : public TLocalisamfile
|
||||
{
|
||||
TDocumento *_doc;
|
||||
bool _normal_next;
|
||||
int _row;
|
||||
bool _normal_next;
|
||||
|
||||
protected:
|
||||
TDocumento& doc() const { return *_doc;}
|
||||
|
||||
public:
|
||||
void set_normal_next(const bool b = TRUE) { _normal_next = TRUE; }
|
||||
void set_normal_next(bool b = true) { _normal_next = b; }
|
||||
virtual int next(word lockop = _nolock) { return _normal_next ? TLocalisamfile::next(lockop) : NOERR; }
|
||||
virtual TRectype& curr() const ;
|
||||
void set_row(int r) { _row = r;}
|
||||
TRDocisamfile(TDocumento* doc) : TLocalisamfile(LF_RIGHEDOC) { _doc = doc; _row = 1; _normal_next = FALSE;}
|
||||
TRDocisamfile(TDocumento* doc) : TLocalisamfile(LF_RIGHEDOC), _doc(doc), _row(1), _normal_next(false) {}
|
||||
virtual ~TRDocisamfile() {};
|
||||
};
|
||||
|
||||
@ -949,17 +934,16 @@ bool TDocumento_form::validate(TForm_item &cf, TToken_string &s)
|
||||
|
||||
if (s.items() == 4)
|
||||
{
|
||||
byte selector = byte(atoi(s.get())); // il primo parametro e' il selettore del tipo di codice
|
||||
byte selector = byte(s.get_int()); // il primo parametro e' il selettore del tipo di codice
|
||||
if (selector != 0)
|
||||
{
|
||||
_doc->summary_filter(selector);
|
||||
|
||||
TString16 what = s.get(); // cosa deve stampare ?
|
||||
TString value(_doc->summary_get(what)); // Piglia il valore dalla riga selezionata sulla tabellina
|
||||
const TString4 what = s.get(); // cosa deve stampare ?
|
||||
const TString value(_doc->summary_get(what)); // Piglia il valore dalla riga selezionata sulla tabellina
|
||||
|
||||
what = s.get();
|
||||
const bool next = what == "1"; // deve cambiare elemento ?
|
||||
if (next) _doc->summary_set_next();
|
||||
if (s.get_int() == 1) // deve cambiare elemento ?
|
||||
_doc->summary_set_next();
|
||||
|
||||
cf.set(value);
|
||||
}
|
||||
@ -975,11 +959,11 @@ bool TDocumento_form::validate(TForm_item &cf, TToken_string &s)
|
||||
// dove: <selettore> funge da filtro per la somma degli imponibili
|
||||
// se selettore vale 0 restituisce il tot. imponibili con le spese
|
||||
// vedi _RIEPILOGOIVA per la spiegazione dei filtri selettivi
|
||||
byte sel = atoi(s.get());
|
||||
real x = sel == 0 ? _doc->imponibile(TRUE) : _doc->tot_imponibili(sel);
|
||||
const byte sel = (byte)s.get_int();
|
||||
const real x = sel == 0 ? _doc->imponibile(true) : _doc->tot_imponibili(sel);
|
||||
|
||||
cf.set(x.string());
|
||||
return (TRUE);
|
||||
return TRUE;
|
||||
} // fine _TOTIMPONIBILI
|
||||
|
||||
if (code== "_SCADENZE")
|
||||
@ -2022,9 +2006,8 @@ void TStampaDoc_application::on_firm_change()
|
||||
|
||||
bool TStampaDoc_application::select()
|
||||
{
|
||||
TMask & m = * _selection_mask;
|
||||
TMask& m = *_selection_mask;
|
||||
|
||||
|
||||
m.reset();
|
||||
if (_is_lista)
|
||||
reset_choices(m);
|
||||
@ -2038,7 +2021,7 @@ bool TStampaDoc_application::select()
|
||||
_dalnum= m.get_long(F_DA_NDOC);
|
||||
_alnum= m.get_long(F_A_NDOC);
|
||||
_ncopie = m.get_int(F_NCOPIE);
|
||||
if (_alnum == 0)
|
||||
if (_alnum <= 0)
|
||||
_alnum = 9999999L;
|
||||
/* Per ora disabilitamo questa feature, che forse deve essere studiata meglio
|
||||
TString16 config; config << "NUM" << _codnum;
|
||||
|
@ -340,7 +340,7 @@ public:
|
||||
const bool save_and_new() const { return get_bool("B4"); }
|
||||
const bool test_eser() const { return ! get_bool("B5"); }
|
||||
|
||||
const TString & tipo_doc(int i) const;
|
||||
const TString& tipo_doc(int i) const;
|
||||
int ntipi_doc() const;
|
||||
|
||||
void complete_num(long num, TString& codnum) const;
|
||||
@ -878,6 +878,9 @@ class TDocumentoEsteso : public TDocumento
|
||||
TString_array _scadenze_array; // Array che contiene le scadenze ("<data>|<importo>")
|
||||
int _scadenze_current; // indice per identificare l'elementi corrente sull'array (-1 se non ha ancora calcolato)
|
||||
|
||||
protected:
|
||||
virtual int readat(TBaseisamfile& file, TRecnotype nrec, word lockop);
|
||||
|
||||
public:
|
||||
// Funzioni per il riepilogo IVA
|
||||
const bool summary_compiled() { return _sum_filter > -1; }
|
||||
|
@ -623,7 +623,7 @@ real TRiga_documento::imponibile_omaggio(int tipo_iva_calc) const
|
||||
real TRiga_documento::imponibile(bool lordo) const
|
||||
{
|
||||
const TString& field = tipo().imponibile();
|
||||
if (field.not_empty())
|
||||
if (field.full())
|
||||
{
|
||||
real r;
|
||||
if (is_omaggio() && _iva_calc_mode > 0)
|
||||
|
@ -1443,12 +1443,15 @@ long TDocumento::get_next_key(char provv, int anno, const char* codnum) const
|
||||
return n;
|
||||
}
|
||||
|
||||
const TTipo_documento& TDocumento::tipo(const char * tipodoc)
|
||||
const TTipo_documento& TDocumento::tipo(const char* tipodoc)
|
||||
{
|
||||
CHECK(tipodoc && *tipodoc, "Tipo documento nullo");
|
||||
TTipo_documento * o = (TTipo_documento*)_tipi.objptr(tipodoc);
|
||||
TTipo_documento* o = (TTipo_documento*)_tipi.objptr(tipodoc);
|
||||
if (o == NULL)
|
||||
{
|
||||
#ifdef DBG
|
||||
if (tipodoc == NULL || *tipodoc == '\0')
|
||||
NFCHECK("Tipo documento nullo");
|
||||
#endif
|
||||
o = new TTipo_documento(tipodoc);
|
||||
_tipi.add(tipodoc, o);
|
||||
}
|
||||
@ -1457,11 +1460,21 @@ const TTipo_documento& TDocumento::tipo(const char * tipodoc)
|
||||
|
||||
const TTipo_documento& TDocumento::tipo() const
|
||||
{
|
||||
const TString4 tipodoc(get(DOC_TIPODOC));
|
||||
TString4 tipodoc(get(DOC_TIPODOC));
|
||||
#ifdef DBG
|
||||
if (tipodoc.blank()) // Test necessario per lavorare anche su dati rovinati
|
||||
{
|
||||
const TCodice_numerazione& codnum = codice_numerazione();
|
||||
tipodoc = codnum.tipo_doc(0);
|
||||
yesnofatal_box("Tipo documento nullo su %d %s %ld\nforzato a %s",
|
||||
get_int(DOC_ANNO), (const char*)get(DOC_CODNUM), get_long(DOC_NDOC), (const char*)tipodoc);
|
||||
((TDocumento*)this)->set_tipo(tipodoc);
|
||||
}
|
||||
#endif
|
||||
return tipo(tipodoc);
|
||||
}
|
||||
|
||||
const TCodice_numerazione& TDocumento::codice_numerazione(const char * numerazione)
|
||||
const TCodice_numerazione& TDocumento::codice_numerazione(const char* numerazione)
|
||||
{
|
||||
TCodice_numerazione* o = (TCodice_numerazione*)_numerazioni.objptr(numerazione);
|
||||
if (o == NULL)
|
||||
@ -2262,33 +2275,32 @@ void TDocumento::update_spese_aut(TString_array & spese_aut, bool preserve_old,
|
||||
|
||||
real TDocumento::calc_conai_qta(int type)
|
||||
{
|
||||
const char * const __conai_art_names[] = {"CONACC", "CONALL", "CONCAR", "CONPLA", "CONLEG", "CONVET"};
|
||||
const char * const __conai_cf_names[] = {"ESACC", "ESALL", "ESCAR", "ESPLA", "ESLEG", "ESVET"};
|
||||
const char* const __conai_art_names[] = { "CONACC", "CONALL", "CONCAR", "CONPLA", "CONLEG", "CONVET" };
|
||||
const char* const __conai_cf_names[] = { "ESACC", "ESALL", "ESCAR", "ESPLA", "ESLEG", "ESVET" };
|
||||
real perc_esenz = clifor().vendite().get_real(__conai_cf_names[type]);
|
||||
real qta = ZERO;
|
||||
const TDate datadoc = get_date(DOC_DATADOC);
|
||||
const TDate dataes = clifor().vendite().get_date(CFV_DATAECONAI);
|
||||
const TDate datadoc = get(DOC_DATADOC);
|
||||
const TDate dataes = clifor().vendite().get(CFV_DATAECONAI);
|
||||
|
||||
if (dataes.ok() && datadoc > dataes)
|
||||
perc_esenz = ZERO;
|
||||
|
||||
if (perc_esenz < 100.0)
|
||||
if (perc_esenz < CENTO)
|
||||
{
|
||||
const int nrows = physical_rows();
|
||||
for (int i = nrows; i > 0; i--)
|
||||
{
|
||||
TRiga_documento & r = row(i);
|
||||
TArticolo_giacenza * art = r.articolo();
|
||||
const TRiga_documento& r = row(i);
|
||||
TArticolo_giacenza* art = r.articolo();
|
||||
if (art != NULL)
|
||||
{
|
||||
const TString4 um = r.get(RDOC_UMQTA);
|
||||
const real row_qta = art->convert_to_um(r.get_real(RDOC_QTA), NULL, um);
|
||||
|
||||
qta += row_qta*art->get_real(__conai_art_names[type]);
|
||||
if (row_qta > ZERO)
|
||||
qta += row_qta * art->get_real(__conai_art_names[type]);
|
||||
}
|
||||
}
|
||||
if (qta > ZERO)
|
||||
qta = qta * (100 - perc_esenz) / 100.0; // More precise!
|
||||
qta = qta * (CENTO - perc_esenz) / CENTO; // More precise!
|
||||
}
|
||||
return qta;
|
||||
}
|
||||
@ -2485,4 +2497,4 @@ int TDocumento::tipo_riclassificato() const
|
||||
tipo_riclassificato = TTipo_documento::_fattura;
|
||||
}
|
||||
return tipo_riclassificato;
|
||||
}
|
||||
}
|
||||
|
@ -81,13 +81,13 @@ void TDocumentoEsteso::summary_filter(byte selector)
|
||||
|
||||
void TDocumentoEsteso::summary_reset(bool force)
|
||||
{
|
||||
const int items = _order_array.items();
|
||||
if (force) _sum_filter = -1;
|
||||
for (int i = 0; i < items; i++)
|
||||
if (force)
|
||||
{
|
||||
TToken_string& codici = _order_array.row(i);
|
||||
codici = "";
|
||||
_sum_filter = -1;
|
||||
_sum_selected = false;
|
||||
}
|
||||
FOR_EACH_ARRAY_ROW(_order_array, i, row)
|
||||
row->cut(0);
|
||||
}
|
||||
|
||||
void TDocumentoEsteso::summary_set_next()
|
||||
@ -239,6 +239,16 @@ real TDocumentoEsteso::tot_imponibili(byte selector)
|
||||
return number;
|
||||
}
|
||||
|
||||
int TDocumentoEsteso::readat(TBaseisamfile& file, TRecnotype nrec, word lockop)
|
||||
{
|
||||
int err = TDocumento::readat(file, nrec, lockop);
|
||||
dirty_tabella_iva();
|
||||
summary_reset(true);
|
||||
scadenze_reset();
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
TDocumentoEsteso::TDocumentoEsteso(const TRectype& rec)
|
||||
: TDocumento(rec), _sum_filter(-1), _sum_selected(FALSE), _scadenze_current(-1)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user