Patch level : 4.0 448
Files correlati : ve0 ve6 Ricompilazione Demo : [ ] Commento : Migliorata la contabilizzazione analitica (forse) Corretta copy_data in modo da azzerare i movimenti collegati alla testata del documento git-svn-id: svn://10.65.10.50/trunk@14141 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
16ee7506d4
commit
84f60d00da
@ -1,7 +1,6 @@
|
||||
#include <applicat.h>
|
||||
#include "vereplib.h"
|
||||
|
||||
#include "../ba/ba8400.h"
|
||||
#include "../ba/ba8500.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
@ -193,7 +193,6 @@ public:
|
||||
|
||||
class TTipo_documento : public TRectype // velib03
|
||||
{
|
||||
|
||||
static TAssoc_array _formule_documento;
|
||||
TToken_string _formule;
|
||||
TString_array _keys_descrs; // Tipi riga per listbox
|
||||
@ -293,7 +292,7 @@ public:
|
||||
bool is_ricavo() const ;
|
||||
|
||||
TFormula_documento* first_formula() { return succ_formula(true); }
|
||||
TFormula_documento* succ_formula(bool restart = FALSE);
|
||||
TFormula_documento* succ_formula(bool restart = false);
|
||||
|
||||
const int ncopie() const { return get_int("I0"); }
|
||||
const int additional_ncopie() const { return get_int("I2"); }
|
||||
|
@ -298,7 +298,7 @@ real TDocumento::spese_incasso(int ndec, TTipo_importo t) const
|
||||
{
|
||||
if (pag.importo_rata(i) >= impmineff) // Se la rata supera il minimo contrattuale
|
||||
{
|
||||
const TTipo_pag tp = pag.tipo_rata(i);
|
||||
const TTipo_pag tp = (TTipo_pag)pag.tipo_rata(i);
|
||||
imp_spese += (const real&)spese_inc[tp];
|
||||
}
|
||||
}
|
||||
@ -589,19 +589,21 @@ void TDocumento::set_key(TRectype& rec, char provv, int anno, const char* codnum
|
||||
// Funzione statica utile a tutti gli utenti di LF_DOC e LF_RIGHEDOC
|
||||
void TDocumento::copy_data(TRectype& dst, const TRectype& src)
|
||||
{
|
||||
const bool is_riga = dst.num() == LF_RIGHEDOC;
|
||||
|
||||
// Memorizza tutti i campi chiave
|
||||
const char provv = dst.get_char(RDOC_PROVV);
|
||||
const int anno = dst.get_int(RDOC_ANNO);
|
||||
const TString4 codnum = dst.get(RDOC_CODNUM);
|
||||
const long numdoc = dst.get_long(RDOC_NDOC);
|
||||
const int nriga = dst.num() == LF_RIGHEDOC ? dst.get_int(RDOC_NRIGA) : 0;
|
||||
const long idriga = dst.num() == LF_RIGHEDOC ? dst.get_long(RDOC_IDRIGA) : 0;
|
||||
const int nriga = is_riga ? dst.get_int(RDOC_NRIGA) : 0;
|
||||
const long idriga = is_riga ? dst.get_long(RDOC_IDRIGA) : 0;
|
||||
// Copia tutto il record
|
||||
dst = src;
|
||||
// Ripristina tutti i campi chiave
|
||||
set_key(dst, provv, anno, codnum, numdoc);
|
||||
dst.init_memo(RECORD_NON_FISICO);
|
||||
if (nriga > 0)
|
||||
if (is_riga)
|
||||
{
|
||||
dst.put(RDOC_NRIGA, nriga);
|
||||
dst.put(RDOC_IDRIGA, idriga);
|
||||
@ -610,7 +612,11 @@ void TDocumento::copy_data(TRectype& dst, const TRectype& src)
|
||||
dst.put(RDOC_DESCEST, memo);
|
||||
}
|
||||
else
|
||||
{
|
||||
dst.zero(DOC_MOVMAG);
|
||||
dst.zero(DOC_NUMREG);
|
||||
dst.zero(DOC_NUMREGCA);
|
||||
}
|
||||
}
|
||||
|
||||
// Funzione statica utile a tutti gli utenti di LF_RIGHEDOC
|
||||
@ -859,7 +865,7 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const
|
||||
{
|
||||
TString16 name("CODSP0");
|
||||
TString_array spese;
|
||||
TRectype & ven_rec = clifor().vendite();
|
||||
const TRectype & ven_rec = clifor().vendite();
|
||||
for (int i = 1; i <= 4; i++)
|
||||
{
|
||||
name.rtrim(1); name << i;
|
||||
@ -951,7 +957,7 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const
|
||||
mov.put(MOVMAG_CODCONT, get("CODCONT"));
|
||||
mov.put(MOVMAG_CODCAMP, get("CODCAMP"));
|
||||
mov.put(MOVMAG_CODCAUS, get("CAUSMAG"));
|
||||
TString8 codnum(numerazione());
|
||||
const TString4 codnum(numerazione());
|
||||
mov.put(MOVMAG_DESCR, format("%s %s n. %ld del %s", (const char *) tipo().get("S1"),(const char *)codnum, numdoc, (const char *) d.string()));
|
||||
mov.put(MOVMAG_TIPOCF, get("TIPOCF"));
|
||||
mov.put(MOVMAG_CODCF, get("CODCF"));
|
||||
|
@ -475,8 +475,16 @@ public:
|
||||
virtual ~TConsuntivazione_produzione() { }
|
||||
};
|
||||
|
||||
class TCache_causali; // Internal use only
|
||||
|
||||
class TContabilizzazione_analitica : public TElaborazione // velib04f
|
||||
{
|
||||
TCache_ripartizioni _rip;
|
||||
|
||||
TToken_string _search_seq;
|
||||
TBill _sco_perc_bill_an, _sco_imp_bill_an;
|
||||
TCache_causali* _caus;
|
||||
|
||||
error_type _error; // Errore rilevato durante l'elaborazione
|
||||
bool _usepdcc;
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
#include <automask.h>
|
||||
|
||||
#include "velib04.h"
|
||||
#include "velib04d.h"
|
||||
|
||||
#include <automask.h>
|
||||
#include <doc.h>
|
||||
#include <rdoc.h>
|
||||
|
||||
|
@ -10,7 +10,9 @@
|
||||
#include "../cg/cg2103.h"
|
||||
#include "../mg/anamag.h"
|
||||
|
||||
TBill _sco_perc_bill_an, _sco_imp_bill_an;
|
||||
///////////////////////////////////////////////////////////
|
||||
// TCache_causali
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TCache_causali : public TCache
|
||||
{
|
||||
@ -34,14 +36,10 @@ const TCausale& TCache_causali::causale(const TDocumento& doc)
|
||||
// Cerca il codice causale sul cliente
|
||||
const char* const fld = doc.is_nota_credito() ? CFV_CODCAUSNC : CFV_CODCAUS;
|
||||
|
||||
TToken_string key;
|
||||
key.add(doc.get(DOC_TIPOCF));
|
||||
key.add(doc.get(DOC_CODCF));
|
||||
const TRectype& cfven = cache().get(LF_CFVEN, key);
|
||||
TString16 codcaus = cfven.get(fld);
|
||||
|
||||
// Se non lo trova guarda sul tipo documento
|
||||
if (codcaus.empty())
|
||||
TString16 key;
|
||||
key.format("%c|%ld", doc.get_char(DOC_TIPOCF), doc.get_long(DOC_CODCF));
|
||||
TString4 codcaus = cache().get(LF_CFVEN, key, fld);
|
||||
if (codcaus.blank()) // Se non lo trova guarda sul tipo documento
|
||||
{
|
||||
const TTipo_documento& tipo = doc.tipo();
|
||||
codcaus = tipo.causale();
|
||||
@ -49,24 +47,19 @@ const TCausale& TCache_causali::causale(const TDocumento& doc)
|
||||
|
||||
//Assegna l'anno della causale
|
||||
const int year = doc.get_date(DOC_DATADOC).year();
|
||||
TString16 chiave;
|
||||
chiave.format("%s|%4d", (const char *) codcaus, year);
|
||||
key.format("%4s|%4d", (const char*)codcaus, year);
|
||||
// Trasforma il codice in causale vera e propria
|
||||
return (const TCausale&)*objptr(chiave);
|
||||
return (const TCausale&)*objptr(key);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TContabilizzazione_analitica
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
static TCache_ripartizioni _rip;
|
||||
static TToken_string _search_seq;
|
||||
|
||||
const TCausale& TContabilizzazione_analitica::doc2caus(const TDocumento& doc)
|
||||
{
|
||||
static TCache_causali _caus;
|
||||
return _caus.causale(doc);
|
||||
CHECK(_caus, "Cache nulla");
|
||||
return _caus->causale(doc);
|
||||
}
|
||||
|
||||
const TCausale& TContabilizzazione_analitica::rdoc2caus(const TRiga_documento& rdoc)
|
||||
@ -77,13 +70,6 @@ const TCausale& TContabilizzazione_analitica::rdoc2caus(const TRiga_documento& r
|
||||
// Copiata dalla contabilizzazione ed eliminati riferimenti a tutte le variabili globali del cazzo
|
||||
bool TContabilizzazione_analitica::search_costo_ricavo(const TRiga_documento& r, TBill& conto)
|
||||
{
|
||||
if (_search_seq.blank())
|
||||
{
|
||||
TConfig conf(CONFIG_DITTA, "ve");
|
||||
_search_seq = conf.get("RICERCACR");
|
||||
}
|
||||
const int items = _search_seq.items();
|
||||
|
||||
TString16 clifo_key;
|
||||
clifo_key.format("%c|%ld", r.doc().get_char(DOC_TIPOCF), r.doc().get_long(DOC_CODCF));
|
||||
|
||||
@ -108,6 +94,7 @@ bool TContabilizzazione_analitica::search_costo_ricavo(const TRiga_documento& r,
|
||||
|
||||
TString4 tok;
|
||||
// Scorre la stringa di ricerca
|
||||
const int items = _search_seq.items();
|
||||
for (int i=0; i < items;i++)
|
||||
{
|
||||
_search_seq.get(i, tok);
|
||||
@ -224,6 +211,7 @@ bool TContabilizzazione_analitica::search_costo_ricavo(const TRiga_documento& r,
|
||||
{
|
||||
TString4 tok;
|
||||
// Scorre la stringa di ricerca ma solo per causale o CLI/FO
|
||||
const int items = _search_seq.items();
|
||||
for (int i=0; i<items;i++)
|
||||
{
|
||||
_search_seq.get(i, tok);
|
||||
@ -237,8 +225,7 @@ bool TContabilizzazione_analitica::search_costo_ricavo(const TRiga_documento& r,
|
||||
conto.set(gr,co,so);
|
||||
if (conto.ok())
|
||||
break;
|
||||
}
|
||||
else
|
||||
} else
|
||||
if (tok == "CA")
|
||||
{
|
||||
const TCausale& caus = rdoc2caus(r);
|
||||
@ -284,13 +271,12 @@ bool TContabilizzazione_analitica::find_conti_iva_indetraibile(const TRiga_docum
|
||||
const TString80 riga_cos = riga.codice_costo();
|
||||
const TString80 riga_cms = riga.codice_commessa();
|
||||
const TString16 riga_fsc = riga.fase_commessa();
|
||||
const bool riga_any = riga_cos.not_empty() || riga_cms.not_empty() || riga_fsc.not_empty();
|
||||
const bool riga_any = riga_cos.full() || riga_cms.full() || riga_fsc.full();
|
||||
|
||||
TToken_string conto;
|
||||
if (_usepdcc)
|
||||
{
|
||||
TToken_string conto;
|
||||
|
||||
conto.format("%03d%03d%06ld", bill.gruppo(), bill.conto(), bill.sottoconto());
|
||||
conto = bill.string(0x8); // format("%03d%03d%06ld", bill.gruppo(), bill.conto(), bill.sottoconto());
|
||||
if (riga_any)
|
||||
{
|
||||
conto.add(riga_cos, 1);
|
||||
@ -304,7 +290,6 @@ bool TContabilizzazione_analitica::find_conti_iva_indetraibile(const TRiga_docum
|
||||
{
|
||||
// Cerca la ripartizione del conto
|
||||
const TRecord_array& rip = _rip.righe(bill);
|
||||
TToken_string conto;
|
||||
for (int i = 1; i <= rip.rows(); i++)
|
||||
{
|
||||
const TRectype& rigarip = rip.row(i);
|
||||
@ -325,8 +310,6 @@ bool TContabilizzazione_analitica::find_conti_iva_indetraibile(const TRiga_docum
|
||||
conti.add(conto);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return !conti.empty();
|
||||
}
|
||||
|
||||
@ -340,20 +323,6 @@ bool TContabilizzazione_analitica::find_conti(const TRiga_documento& riga, TStri
|
||||
|
||||
if (riga.is_sconto())
|
||||
{
|
||||
if (!_sco_perc_bill_an.ok())
|
||||
{
|
||||
TConfig conf(CONFIG_DITTA, "ve");
|
||||
int gr = conf.get_int("SCOPRCODCON","ve",1);
|
||||
int co = conf.get_int("SCOPRCODCON","ve",2);
|
||||
long so = conf.get_long("SCOPRCODCON","ve",3);
|
||||
|
||||
_sco_perc_bill_an.set(gr,co,so);
|
||||
|
||||
gr = conf.get_int("SCOIMCODCON","ve",1);
|
||||
co = conf.get_int("SCOIMCODCON","ve",2);
|
||||
so = conf.get_long("SCOIMCODCON","ve",3);
|
||||
_sco_imp_bill_an.set(gr,co,so);
|
||||
}
|
||||
if (riga.is_sconto_perc())
|
||||
bill = _sco_perc_bill_an;
|
||||
else
|
||||
@ -361,7 +330,7 @@ bool TContabilizzazione_analitica::find_conti(const TRiga_documento& riga, TStri
|
||||
if (!bill.is_analitico())
|
||||
return true;
|
||||
if (_usepdcc)
|
||||
contanal.format("%03d%03d%06ld", bill.gruppo(), bill.conto(), bill.sottoconto());
|
||||
contanal = bill.string(0x8); // format("%03d%03d%06ld", bill.gruppo(), bill.conto(), bill.sottoconto());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -375,7 +344,7 @@ bool TContabilizzazione_analitica::find_conti(const TRiga_documento& riga, TStri
|
||||
const TRectype& anamag = cache().get(LF_ANAMAG, riga.get(RDOC_CODARTMAG));
|
||||
bArcticleFound = !anamag.empty();
|
||||
if (_usepdcc)
|
||||
contanal.format("%03d%03d%06ld", bill.gruppo(), bill.conto(), bill.sottoconto());
|
||||
contanal = bill.string(0x8); // format("%03d%03d%06ld", bill.gruppo(), bill.conto(), bill.sottoconto());
|
||||
else
|
||||
contanal = anamag.get(tipocf == 'F' ? ANAMAG_CONTOINDA : ANAMAG_CONTOINDV);
|
||||
}
|
||||
@ -717,19 +686,37 @@ void TContabilizzazione_analitica::init()
|
||||
{
|
||||
TConfig& cfg = ca_config();
|
||||
_usepdcc = cfg.get_bool("UsePdcc");
|
||||
|
||||
TConfig conf(CONFIG_DITTA, "ve");
|
||||
_search_seq = conf.get("RICERCACR");
|
||||
|
||||
int gr = conf.get_int("SCOPRCODCON","ve",1);
|
||||
int co = conf.get_int("SCOPRCODCON","ve",2);
|
||||
long so = conf.get_long("SCOPRCODCON","ve",3);
|
||||
_sco_perc_bill_an.set(gr,co,so);
|
||||
|
||||
gr = conf.get_int("SCOIMCODCON","ve",1);
|
||||
co = conf.get_int("SCOIMCODCON","ve",2);
|
||||
so = conf.get_long("SCOIMCODCON","ve",3);
|
||||
_sco_imp_bill_an.set(gr,co,so);
|
||||
|
||||
_caus = new TCache_causali;
|
||||
}
|
||||
|
||||
TContabilizzazione_analitica::TContabilizzazione_analitica()
|
||||
: TElaborazione(NULL), _error(no_error)
|
||||
: TElaborazione(NULL), _error(no_error), _caus(NULL)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
TContabilizzazione_analitica::TContabilizzazione_analitica(const TRectype& rec)
|
||||
: TElaborazione(rec), _error(no_error)
|
||||
: TElaborazione(rec), _error(no_error), _caus(NULL)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
TContabilizzazione_analitica::~TContabilizzazione_analitica()
|
||||
{ }
|
||||
{
|
||||
if (_caus != NULL)
|
||||
delete _caus;
|
||||
}
|
||||
|
@ -916,7 +916,7 @@ void TDocumento_mask::spese2mask()
|
||||
|
||||
TString16 name("CODSP0");
|
||||
TString_array spese;
|
||||
TRectype & ven_rec = c.vendite();
|
||||
const TRectype & ven_rec = c.vendite();
|
||||
for (int i = 1; i <= 4; i++)
|
||||
{
|
||||
name.rtrim(1); name << i;
|
||||
@ -1321,7 +1321,7 @@ bool TDocumento_mask::ss_notify( TSheet_field& ss, int r, KEY key )
|
||||
if (key == K_CTRL + K_INS)
|
||||
{
|
||||
TRiga_documento & riga = doc[r + 1];
|
||||
TRectype & ven_rec = doc.clifor().vendite();
|
||||
const TRectype & ven_rec = doc.clifor().vendite();
|
||||
TString16 s(ven_rec.get(CFV_CODMAG));
|
||||
const TTipo_riga_documento & t = riga.tipo();
|
||||
|
||||
@ -2380,11 +2380,11 @@ bool TElabora_mask::elabora()
|
||||
{
|
||||
const char provv = get(F_PROVV_ELAB)[0];
|
||||
const int anno = get_int(F_ANNO_ELAB);
|
||||
const TString16 codnum(get(F_CODNUM_ELAB));
|
||||
const TString16 tipo(get(F_TIPODOC_ELAB));
|
||||
const TString16 stato(get(F_STATODOC_ELAB));
|
||||
const TString& codnum = get(F_CODNUM_ELAB);
|
||||
const TString& tipo = get(F_TIPODOC_ELAB);
|
||||
const TString& stato = get(F_STATODOC_ELAB);
|
||||
|
||||
if (anno == 0 || codnum.empty() || tipo.empty() || stato.empty())
|
||||
if (anno <= 0 || codnum.blank() || tipo.blank() || stato.blank())
|
||||
return false;
|
||||
|
||||
TDocumento* newdoc = new TDocumento(provv, anno, codnum, numdoc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user