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

View File

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

View File

@ -695,7 +695,7 @@ void TTrFa_mask::load_sheet()
FOR_EACH_ASSOC_OBJECT(recimposte, h, iva, rec) 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 // Controllo che sia un tipo documento da leggere
const int tipo_doc = get_tipo_doc(movimento.get("TIPODOC")); const int tipo_doc = get_tipo_doc(movimento.get("TIPODOC"));
if (tipo_doc != -1 && !get_bool(tipo_doc)) continue; 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_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_REVERSE, rev_charge(movimento.get("NUMREG"), movimento.get_date("DATAREG").year()), nrow); // Rev.Charge
sheet.set_row_cell(A_TIPODOC, movimento.get("TIPODOC"), nrow); 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 // Calcolo il tipo documento alla fine per sicurezza
if (is_cust.full()) 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 const TString & tpdocae = movimento.get("TIPODOCAE");
sheet.set_row_cell(A_TIPODOCAE, decod_tipo(sheet.row(nrow)), nrow); // Tipo documento
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 * Possono esistere movimenti custom dove il cliente ha una partita IVA propria