Patch level : 12.0 888
Files correlati : fp0.exe, fp0112.sql Commento : Esportazione fatture fatturazione differita lavanderie
This commit is contained in:
parent
9e7bbf2269
commit
e1f1927695
@ -290,6 +290,34 @@ public:
|
||||
TRecord_array& bodyof##__rdoc = (__doc).body(); \
|
||||
for (int __r = bodyof##__rdoc.first_row(); bodyof##__rdoc.exist(__r) && (__rdoc=&(TFPRiga_documento&)bodyof##__rdoc.row(__r))!=NULL; __r=bodyof##__rdoc.succ_row(__r))
|
||||
|
||||
class TFPBuono_di_consegna
|
||||
{
|
||||
public:
|
||||
TString20 _numdoc;
|
||||
TDate _datadoc;
|
||||
|
||||
bool already_exist(map<TString20, TDate>& ancestors_s) const;
|
||||
|
||||
|
||||
TFPBuono_di_consegna() { }
|
||||
TFPBuono_di_consegna(const TString20& numdoc, const TDate& datadoc) : _numdoc(numdoc), _datadoc(datadoc) { }
|
||||
};
|
||||
|
||||
inline bool operator==(const TFPBuono_di_consegna& l, const TFPBuono_di_consegna& r)
|
||||
{
|
||||
TToken_string appo(l._numdoc, '/');
|
||||
if(appo.items() == 3)
|
||||
return TString(appo.get(2)) == r._numdoc && l._datadoc == r._datadoc;
|
||||
return l._numdoc == r._numdoc && l._datadoc == r._datadoc;
|
||||
}
|
||||
|
||||
#define FOR_EACH_BUONI(__buoni, __n, __buono) TFPBuono_di_consegna* (buono) = NULL; \
|
||||
map<TString20, TFPBuono_di_consegna>::iterator it; \
|
||||
it = (buoni).begin(); \
|
||||
int(n) = 0; \
|
||||
for (; it != (buoni).end() && ((buono) = &it->second)->_numdoc.full(); ++it, (n)++)
|
||||
|
||||
|
||||
|
||||
/***********************************************************************************************************************************************************************
|
||||
* PERSONALIZZAZIONI FP
|
||||
@ -524,6 +552,7 @@ protected:
|
||||
//void set_rec_clifo(char tipocf, long codcf);
|
||||
|
||||
public:
|
||||
static void fill_buoni(map<TString20, TFPBuono_di_consegna>& buoni, const TString& memo);
|
||||
bool doc_to_paf(TDocumentoEsteso& doc);
|
||||
bool doc_to_paf(const TRectype& rec);
|
||||
bool doc_to_paf(const TDoc_key& key);
|
||||
|
@ -664,6 +664,19 @@ TAncestor::TAncestor(const TRectype& rdoc)
|
||||
_numdoc.format("%d/%s/%s", anno, static_cast<const char*>(codnum), static_cast<const char*>(numdoc));
|
||||
_datadoc = doc.get_date(DOC_DATADOC);
|
||||
}
|
||||
/***************************************************************************
|
||||
* TFPBuono_di_consegna
|
||||
***************************************************************************/
|
||||
bool TFPBuono_di_consegna::already_exist(map<TString20, TDate>& ancestors_s) const
|
||||
{
|
||||
for(auto it = ancestors_s.begin(); it != ancestors_s.end(); ++it)
|
||||
{
|
||||
TFPBuono_di_consegna b(it->first, it->second);
|
||||
if (b == *this)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/***************************************************************************
|
||||
* TDoc_fp
|
||||
***************************************************************************/
|
||||
@ -1413,6 +1426,25 @@ bool TDoc_fp::export_paf3200f()
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void TDoc_fp::fill_buoni(map<TString20, TFPBuono_di_consegna>& buoni, const TString& memo)
|
||||
{
|
||||
if (memo.full())
|
||||
{
|
||||
TToken_string b(memo, 'n');
|
||||
for (int i = 4; i < b.items(); i++)
|
||||
{
|
||||
TToken_string str(b.get(i), ' ');
|
||||
TString20 ndoc = str.get(1);
|
||||
TDate data(str.get(3));
|
||||
if (data == TDate(NULLDATE))
|
||||
data = str.get(2);
|
||||
TFPBuono_di_consegna buono(ndoc, data);
|
||||
buoni.insert({ buono._numdoc, buono });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
{
|
||||
if (!initialize(doc))
|
||||
@ -1679,7 +1711,9 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
TPaf_record& paf1900f = _paf_container.get_paf("PAF1900F");
|
||||
TPaf_record& paf3000f = _paf_container.get_paf("PAF3000F");
|
||||
long riga = 1;
|
||||
|
||||
bool f_buonocons = false;
|
||||
map<TString20, TDate> ancestors_s;
|
||||
TString riga_buoni_cons;
|
||||
FOR_EACH_PHYSICAL_FPRDOC(doc, r, rdoc)
|
||||
{
|
||||
// Controllo la riga
|
||||
@ -1693,6 +1727,15 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
const TString& descrizione_riga = descrizione(*rdoc);
|
||||
if (descrizione_riga.empty())
|
||||
continue;
|
||||
if (!f_buonocons && descrizione_riga.starts_with("Buono di consegna n. "))
|
||||
{
|
||||
TString memo; memo << rdoc->get(RDOC_DESCR);
|
||||
if (rdoc->get_bool(RDOC_DESCLUNGA))
|
||||
memo << rdoc->get(RDOC_DESCEST);
|
||||
riga_buoni_cons = memo;
|
||||
f_buonocons = true;
|
||||
continue;
|
||||
}
|
||||
reset(paf3000f);
|
||||
paf3000f.set("PT_RIFNUMLINEA", riga);
|
||||
paf3000f.set("PT_COMMENTO", descrizione_riga);
|
||||
@ -1734,11 +1777,12 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
* Ogni riga si può rifare a un DDT/Ordine diverso, per questo devo inserire i dati da qua e non in testata
|
||||
*/
|
||||
TArray ancestors;
|
||||
find_ancestors(*rdoc, ancestors);
|
||||
find_ancestors(*rdoc, ancestors);
|
||||
for (int i = ancestors.last(); i > 0; i = ancestors.pred(i))
|
||||
{
|
||||
_has_bolla |= true;
|
||||
const TAncestor& a = dynamic_cast<const TAncestor&>(ancestors[i]);
|
||||
ancestors_s.insert({ a._numdoc, a._datadoc }); // Per i buoni di consegna lavanderie
|
||||
if (i == 1)
|
||||
{
|
||||
// <DatiDDT>
|
||||
@ -1926,6 +1970,31 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
riga++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Se ho una fattura che deriva dalla fatturazione differita delle lavanderie prendo
|
||||
* dalla relativa riga descrizione tutti i riferimenti alle bolle che mancano */
|
||||
if (f_buonocons)
|
||||
{
|
||||
TString& memo = riga_buoni_cons;
|
||||
if (memo.full())
|
||||
{
|
||||
map<TString20, TFPBuono_di_consegna> buoni;
|
||||
fill_buoni(buoni, memo);
|
||||
paf1600f.set("PF_RIFNUMLINEA", "0");
|
||||
FOR_EACH_BUONI(buoni, n, buono)
|
||||
{
|
||||
if (!buono->already_exist(ancestors_s))
|
||||
{
|
||||
reset(paf1600f);
|
||||
paf1600f.set("PF_NUMDDDT", buono->_numdoc);
|
||||
paf1600f.set("PF_DATADDT", buono->_datadoc);
|
||||
paf1600f.set("PF_GESTIONE", "D");
|
||||
ok &= insert(paf1600f);
|
||||
}
|
||||
}
|
||||
f_buonocons = true;
|
||||
}
|
||||
}
|
||||
// Controllo plafond
|
||||
// Riga esenzione?
|
||||
if (doc.is_fattura() && !doc.is_nota_credito())
|
||||
|
2
src/fp/sql/fp0112.sql
Normal file
2
src/fp/sql/fp0112.sql
Normal file
@ -0,0 +1,2 @@
|
||||
ALTER TABLE PAF1600F DROP CONSTRAINT PAF1600Q;
|
||||
ALTER TABLE PAA1600F DROP CONSTRAINT PAA1600Q;
|
Loading…
x
Reference in New Issue
Block a user