diff --git a/src/tf/tf0100.cpp b/src/tf/tf0100.cpp index 5603fec92..285c60e0d 100644 --- a/src/tf/tf0100.cpp +++ b/src/tf/tf0100.cpp @@ -233,6 +233,8 @@ const char* decodTipo(TToken_string* strarr) bool saveRec(TToken_string row, bool esportato) { static TLocalisamfile trasfatt(LF_TRASFATT); + static TLocalisamfile mov(LF_MOV); + TString key = row.get(_numero); key << "|"<< row.get(_aliquota); TRectype rCust = cache().get(LF_TRASFATT, key); @@ -240,6 +242,11 @@ bool saveRec(TToken_string row, bool esportato) if(rCust.empty()) { rCust.put("NUMREG", row.get(_numero)); + // Se il record viene creato al momento svuoto per sicurezza i valori TFINVIO e TFDATA in MOV + TRectype rOrig = cache().get(LF_MOV, row.get(_numero)); + rOrig.put("TFINVIO", ""); + rOrig.put("TFDATA", ""); + rOrig.rewrite(mov); } rCust.put("TIPO", row.get(_tipocf)); rCust.put("CODCF", row.get(_codcf)); @@ -251,6 +258,7 @@ bool saveRec(TToken_string row, bool esportato) rCust.put("IMPONIBILE", row.get(_imponibile)); rCust.put("IMPOSTA", row.get(_importoIVA)); rCust.put("CODIVA", row.get(_aliquota)); + rCust.put("NATURA", row.get(_natura)); rCust.put("AUTOFATT", row.get(_autofatt)); if(esportato) { @@ -258,7 +266,6 @@ bool saveRec(TToken_string row, bool esportato) rCust.put("TFINVIO", invio); rCust.put("TFDATA", TDate(TODAY)); } - return rCust.write_rewrite(trasfatt) == NOERR; } diff --git a/src/tf/tf0101.cpp b/src/tf/tf0101.cpp index 8d629043a..6ac15d73f 100644 --- a/src/tf/tf0101.cpp +++ b/src/tf/tf0101.cpp @@ -630,9 +630,10 @@ void TTrFa_mask::load_sheet() sheet.destroy(); TAssoc_array recimposte; int items = c.updateFilters(tipo, codice, dal, al, get_int(F_FATTSEL)); + TString tipocf, codcf, ocfpi, nat; for(bool ok = true; items > 0 && ok;) { - TString tipocf, codcf, ocfpi; + tipocf.cut(0), codcf.cut(0), ocfpi.cut(0), nat.cut(0); int err = c.next(recimposte, ok, tipocf, codcf, ocfpi); // Carico i clienti @@ -654,6 +655,9 @@ void TTrFa_mask::load_sheet() */ TRectype isCust = getTrasFatt(movimento.get("NUMREG"), iva); + if(isCust.full() && (err < foundcust || err > foundidcust)) + bool tolla = true; + row.add(movimento.get("TFINVIO") == "I" ? "X" : "", _spedita); // Spedita row.add("X"); // Da spedire, sempre! row.add(isCust.full() ? "X" : "", _forzata); // Modificato @@ -668,7 +672,8 @@ void TTrFa_mask::load_sheet() row.add(movimento.get("TIPODOC"), _codnum); // Tipo documento row.add(movimento.get("NUMDOC"), _numdoc); // Numero documento row.add(movimento.get_date("DATADOC"), _datadoc); // Data documento - row.add(natura(iva), _natura); // NATURA! + nat.cut(0) << movimento.get("NATURA"); + row.add(nat.full() ? nat : natura(iva), _natura); // NATURA! row.add(iva, _aliquota); // Codice aliquota! row.add(findDetraib(movimento.get("TIPODET")), _detraibile); // Detraibilità row.add(movimento.get_real("IMPONIBILE"), _imponibile); // Imponibile