Merge branch 'R_10_00' of http://10.65.20.17:7990/scm/campo/campo into R_10_00

# Conflicts:
#	src/fp/fplib01.cpp
This commit is contained in:
Mattia Tollari 2018-12-05 12:05:05 +01:00
commit 6a66d1620b
7 changed files with 71 additions and 20 deletions

View File

@ -4,6 +4,7 @@
#include "fplib01.h"
#include <progind.h>
#include <cfven.h>
#include <doc.h>
#include "../ve/velib05.h"
#include "../cg/cglib03.h"
@ -219,7 +220,10 @@ void TPA_mask::fill()
row.add(rec.get(DOC_ANNO).as_int(), 1);
row.add(rec.get(DOC_CODNUM).as_string());
row.add(rec.get(DOC_TIPODOC).as_string());
row.add(td.tipo_doc_sdi());
if (!rec.get(DOC_TIPODOCSDI).is_empty())
row.add(rec.get(DOC_TIPODOCSDI).as_string());
else
row.add(td.tipo_doc_sdi());
row.add(rec.get(DOC_NDOC).as_int());
row.add(rec.get(DOC_DATADOC).as_date());
row.add(rec.get(CFV_CODCF).as_int());
@ -434,6 +438,8 @@ void TDoc2Paf::main_loop()
{
int ndocs = 0;
TPA_mask mask;
TLocalisamfile doc(LF_DOC);
static const int col_cod_sdi = mask.sfield(F_DOCS).cid2index(S_CODSDI);
while (mask.run() == K_ENTER)
{
TString_array& sht = mask.sfield(F_DOCS).rows_array();
@ -451,8 +457,20 @@ void TDoc2Paf::main_loop()
const long ndoc = riga->get_long(mask.sfield(F_DOCS).cid2index(S_NDOC));
const TFixed_string codnum(riga->get(mask.sfield(F_DOCS).cid2index(S_CODNUM))); // lascio sapientemente per ultima la get di una stringa
const TDoc_key key(anno, codnum, ndoc);
if (elab.doc_to_paf(key))
ndocs++;
// Verifico che il codice sdi nello sheet sia lo stesso sulla testata del documento in caso contrario lo aggiorno
TRectype rec_doc = elab.key_to_doc(key);
if(rec_doc.read(doc) == NOERR)
{
if(rec_doc.get(DOC_TIPODOCSDI).compare(riga->get(col_cod_sdi)) != 0)
{
rec_doc.put(DOC_TIPODOCSDI, riga->get(col_cod_sdi));
rec_doc.rewrite(doc);
}
if (elab.doc_to_paf(key))
ndocs++;
}
}
if (!pi.add_status(1))
break;

View File

@ -177,10 +177,16 @@ BEGIN
FLAGS "D"
END
STRING S_CODSDI 4
LIST S_CODSDI 35
BEGIN
PROMPT 41 2 "Tipo SDI "
FLAGS "D"
PROMPT 41 2 "Tipo Doc SDI"
ITEM "TD01|TD01 Fattura"
ITEM "TD02|TD02 Acconto/Anticipo su fattura"
ITEM "TD03|TD03 Acconto/Anticipo su parcella"
ITEM "TD04|TD04 Nota di credito"
ITEM "TD05|TD05 Nota di debito"
ITEM "TD06|TD06 Parcella"
ITEM "TD20|TD20 Autofattura"
END
NUMBER S_NDOC 7

View File

@ -153,8 +153,7 @@ bool chiave_paf(const TDocumento& doc, TString& hfatt, TString& bfatt)
const long ndoc = doc.numero();
TString16 fullnumdoc;
codnum.complete_num(ndoc, fullnumdoc);
bfatt.cut(0) << doc.get_date(DOC_DATADOC).date2ansi() << '_' << doc.tipo().tipo_doc_sdi() << '_' << fullnumdoc;
bfatt.cut(0) << doc.get_date(DOC_DATADOC).date2ansi() << '_' << tipo_doc_sdi(doc) << '_' << fullnumdoc;
return hfatt.full() && bfatt.full();
}
@ -220,6 +219,11 @@ inline const TString& no_special(char a)
return r;
}
const TString& tipo_doc_sdi(const TDocumento& doc)
{
return doc.get(DOC_TIPODOCSDI).full() ? doc.get(DOC_TIPODOCSDI) : doc.tipo().tipo_doc_sdi();
}
/***************************************************************************
* TPaf_record
***************************************************************************/
@ -1027,8 +1031,8 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
paf0700f.set("P7_KEYHEADERFATT", _hfatt);
paf0700f.set("P7_KEYBODYFATT", _bfatt);
remove(paf0700f);
paf0700f.set("P7_TIPODOC", doc.tipo().tipo_doc_sdi());
paf0700f.set("P7_DIVISA", ); // Aggiungere codice ISO 4217 a tabella divise (%VAL)
paf0700f.set("P7_TIPODOC", tipo_doc_sdi(doc));
paf0700f.set("P7_DIVISA", "EUR"); // Aggiungere codice ISO 4217 a tabella divise (%VAL)
paf0700f.set("P7_DATA", doc.data());
const TCodice_numerazione& codnum = doc.codice_numerazione();
@ -1753,12 +1757,7 @@ bool TDoc_fp::doc_to_paf(const TRectype& rec)
bool TDoc_fp::doc_to_paf(const TDoc_key& key)
{
TRectype rec(LF_DOC);
rec.put(DOC_PROVV, key.provv());
rec.put(DOC_ANNO, key.anno());
rec.put(DOC_CODNUM, key.codnum());
rec.put(DOC_NDOC, key.ndoc());
return doc_to_paf(rec);
return doc_to_paf(key_to_doc(key));
}
bool TDoc_fp::doc_to_paf(const TFilename& ini)
@ -1771,7 +1770,25 @@ bool TDoc_fp::doc_to_paf(const TFilename& ini)
return doc_to_paf(key);
}
TDoc_fp::TDoc_fp() : _log(nullptr), _cache_insert(false)
bool TDoc_fp::doc_to_paf()
{
return _doc_rec != nullptr ? doc_to_paf(*_doc_rec) : false;
}
TRectype& TDoc_fp::key_to_doc(const TDoc_key& key)
{
if(_doc_rec != nullptr)
delete _doc_rec;
_doc_rec = new TRectype(LF_DOC);
_doc_rec->put(DOC_PROVV, key.provv());
_doc_rec->put(DOC_ANNO, key.anno());
_doc_rec->put(DOC_CODNUM, key.codnum());
_doc_rec->put(DOC_NDOC, key.ndoc());
return *_doc_rec;
}
TDoc_fp::TDoc_fp() : _doc_rec(nullptr), _log(nullptr), _cache_insert(false)
{
_ditta.init(LF_NDITTE, prefix().get_codditta());
_cofi = ini_get_string(CONFIG_DITTA, "fp", "cofitras");
@ -1806,4 +1823,6 @@ TDoc_fp::TDoc_fp() : _log(nullptr), _cache_insert(false)
TDoc_fp::~TDoc_fp()
{
commit();
if (_doc_rec != nullptr)
delete _doc_rec;
}

View File

@ -22,6 +22,7 @@ bool chiave_paf(const TDocumento& doc, TString& hfatt, TString& bfatt);
bool chiave_paf(const TRectype& doc, TString& hfatt, TString& bfatt);
bool get_coddest(const char tipocf, const long codcf, TString& coddest, TString& pec);
inline const TString& no_special(char a);
const TString& tipo_doc_sdi(const TDocumento& doc);
// Contenitore di campi di un record di database MSSQLServer
class TPaf_record : public TObject
@ -76,6 +77,7 @@ public:
class TDoc_fp
{
private:
TRectype *_doc_rec;
TAnagrafica _ditta;
TString16 _cofi;
TFilename _dbname;
@ -99,6 +101,7 @@ private:
bool insert(TPaf_record& p);
bool remove(TPaf_record& p);
bool save_paf();
protected:
bool parse_sconto(const TString& formula, TToken_string& sconti) const;
@ -120,10 +123,13 @@ public:
bool doc_to_paf(const TRectype& rec);
bool doc_to_paf(const TDoc_key& key);
bool doc_to_paf(const TFilename& ini);
bool doc_to_paf();
TRectype& key_to_doc(const TDoc_key& key);
// Mostra il log a fine esecuzione
bool show_log();
const int commit();
void set_cache_insert(const bool v) { _cache_insert = v; }
TDoc_fp();
~TDoc_fp();

View File

@ -100,6 +100,7 @@
#define DOC_MANDATO "MANDATO"
#define DOC_COMMPREL "COMMPREL"
#define DOC_FASEPREL "FASEPREL"
#define DOC_TIPODOCSDI "TIPODOCSDI"
// Virtuali

View File

@ -1,3 +1,3 @@
33
0
$doc|0|0|723|0|Testate documenti|||
$doc|41368|42328|727|0|Testate documenti|NDOC||

View File

@ -1,5 +1,5 @@
33
97
98
CODNUM|1|4|0|Codice della numerazione
ANNO|2|4|0|Anno
PROVV|1|1|0|Tipo numerazione <P>rovvisorio <D>efinitivo
@ -97,9 +97,10 @@ CONTSEP|1|6|0|Contabilit
NOLEGGIO|1|1|0|Tipo noleggio (pe)
COMMPREL|1|20|0|Commessa di prelievo (ci)
FASEPREL|1|10|0|Fase di prelievo (ci)
TIPODOCSDI|1|4|0|Tido documento secondo Agenzia delle Entrate
5
PROVV+ANNO+CODNUM+NDOC|
TIPOCF+CODCF+PROVV+ANNO+DATADOC+CODNUM+NDOC|X
DATADOC+PROVV+ANNO+CODNUM+NDOC|X
TIPOCF+CODCF+PROVV+ANNO+CODNUM+NDOC|X
PROVV+CODNUM+ANNO+NDOC
PROVV+CODNUM+ANNO+NDOC|