Patch level : 12.0 1058

Files correlati     : tf0.exe tf0100a.msk

Commento        :

Il tipo documento non viene più impostato a TD10 e TD11.
La natura IVA non viene esportata.
This commit is contained in:
Alessandro Bonazzi 2021-04-30 17:17:09 +02:00
parent 40cf3c5f39
commit 082f2b22c2
3 changed files with 40 additions and 22 deletions

View File

@ -136,7 +136,8 @@ const char* decod_tipo(TToken_string & strarr)
{
const TString tipodoc = strarr.get(_codnum);
TRectype mov = cache().get(LF_MOV, strarr.get(_numero));
TCausale caus(mov.get("CODCAUS"), mov.get_int("ANNOIVA"));
TCausale caus = cached_causale(mov.get("CODCAUS"), mov.get_int("ANNOIVA"));
// Le autofatture possono essere solo di tipo TDO1 e le bolle doganali nel dubbio pure
if(tipodoc == "AF" || tipodoc == "BD" || tipodoc == "FF" || tipodoc == "FV" || tipodoc == "FS")
return "TD01";
@ -158,36 +159,41 @@ const char* decod_tipo(TToken_string & strarr)
TRectype row = c_moviva.curr();
real importo = row.get_real("IMPONIBILE");
// La chiave deve essere formata da CODIVA, GRUPPO + CONTO + SOTTOCONTO
TString keyAssoc; keyAssoc << row.get("CODIVA") << "|" << row.get("GRUPPO") << "|" << row.get("CONTO") << "|" << row.get("SOTTOCONTO");
if(intraval.is_key(keyAssoc))
{
importo += *(real*)intraval.objptr(keyAssoc);
intraval.add(keyAssoc, importo, true);
}
else
{
intraval.add(keyAssoc, importo);
}
TToken_string keyAssoc = row.get("CODIVA");
keyAssoc.add(row.get("GRUPPO"));
keyAssoc.add(row.get("CONTO"));
keyAssoc.add(row.get("SOTTOCONTO"));
real *imp = (real*) intraval.objptr(keyAssoc);
if (imp == nullptr)
intraval.add(keyAssoc, imp = new real);
*imp += importo;
}
// Adesso che ho tutti i totali divisi per CODIVA e GCS vado a pescare il valore maggiore
TString keyMax = "";
real max = ZERO;
TToken_string keyMax;
real max;
TString_array keys;
intraval.get_keys(keys);
for(int i = 0; i < keys.items(); i++)
{
TString key = *static_cast<TString*>(keys.objptr(i));
real val_item = *static_cast<real*>(intraval.objptr(key));
if(val_item > max)
const TToken_string & key = keys.row(i);
real imp = *((real *) intraval.objptr(key));
if(imp > max)
{
keyMax = key;
max = val_item;
max = imp;
}
}
// Una volta che ho trovato il nostro vincitore vado a prendere il tipo di fattura dal GCS
TString key_p_con = keyMax.ssub(keyMax.find('|') + 1);
TToken_string key_p_con = keyMax;
key_p_con.destroy(0);
if(cache().get(LF_PCON, key_p_con, "RICSER") == "1")
return "TD11";
else

View File

@ -417,6 +417,10 @@ BEGIN
ITEM "TD04|TD04"
ITEM "TD05|TD05"
ITEM "TD06|TD06"
ITEM "TD07|TD07"
ITEM "TD08|TD08"
ITEM "TD10|TD10"
ITEM "TD11|TD11"
ITEM "TD16|TD16"
ITEM "TD17|TD17"
ITEM "TD18|TD18"

View File

@ -695,7 +695,7 @@ void TTrFa_mask::load_sheet()
FOR_EACH_ASSOC_OBJECT(recimposte, h, iva, rec)
{
TRectype movimento = *dynamic_cast<TRectype*>(rec);
const TRectype & movimento = *((TRectype *)rec);
// Controllo che sia un tipo documento da leggere
const int tipo_doc = get_tipo_doc(movimento.get("TIPODOC"));
if (tipo_doc != -1 && !get_bool(tipo_doc)) continue;
@ -737,11 +737,19 @@ void TTrFa_mask::load_sheet()
sheet.set_row_cell(A_IMPOSTA, movimento.get_real("IMPOSTA"), nrow); // Imposta
sheet.set_row_cell(A_REVERSE, rev_charge(movimento.get("NUMREG"), movimento.get_date("DATAREG").year()), nrow); // Rev.Charge
sheet.set_row_cell(A_TIPODOC, movimento.get("TIPODOC"), nrow);
TToken_string & row = sheet.row(nrow);
TString tipodocae = decod_tipo(row);
// Calcolo il tipo documento alla fine per sicurezza
if (is_cust.full())
sheet.set_row_cell(A_TIPODOCAE, movimento.get("TIPODOCAE").blank() ? decod_tipo(sheet.row(nrow)) : movimento.get("TIPODOCAE"), nrow); // Tipo documento
else
sheet.set_row_cell(A_TIPODOCAE, decod_tipo(sheet.row(nrow)), nrow); // Tipo documento
{
const TString & tpdocae = movimento.get("TIPODOCAE");
if (tpdocae.full())
tipodocae = tpdocae;
}
sheet.set_row_cell(A_TIPODOCAE,tipodocae, nrow); // Tipo documento
/*
* Possono esistere movimenti custom dove il cliente ha una partita IVA propria