Files correlati : tp0.exe Ricompilazione Demo : [ ] Commento : Corretto trasferimento IBAN git-svn-id: svn://10.65.10.50/branches/R_10_00@22445 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			920 lines
		
	
	
		
			30 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			920 lines
		
	
	
		
			30 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include "tp0100.h"
 | 
						||
 | 
						||
#include "../cg/cfban.h"
 | 
						||
#include "../mg/codcorr.h"
 | 
						||
 | 
						||
// Assegna sottocategoria e peso di una classe CONAI solo se non vuoti
 | 
						||
bool TArticolo_pack::set_conai(TCONAI_class cc, const TString& scat, const real& weight)
 | 
						||
{
 | 
						||
  const bool ok = conai_configured_class(cc) && scat.full() && !weight.is_zero();
 | 
						||
  if (ok)
 | 
						||
  {
 | 
						||
    _conai_scat[cc] = scat;
 | 
						||
    _conai_peso[cc] = weight;
 | 
						||
  }
 | 
						||
  return ok;
 | 
						||
}
 | 
						||
 | 
						||
TArticolo_pack::TArticolo_pack(const TRectype& anamag) : TRectype(anamag)
 | 
						||
{
 | 
						||
  FOR_EACH_CONFIGURED_CONAI_CLASS(cc)
 | 
						||
  {
 | 
						||
    const TFieldref anamag_sotcat(conai_sottocat_name(cc, LF_ANAMAG), LF_ANAMAG);
 | 
						||
    const TFieldref anamag_weight(conai_peso_name(cc, LF_ANAMAG), LF_ANAMAG);
 | 
						||
 | 
						||
    const TString4 sotcat = anamag_sotcat.read(anamag); // Usually CA40
 | 
						||
    const real peso = anamag_weight.read(anamag);       // Should be > 0
 | 
						||
    set_conai(cc, sotcat, peso);                        // Validates all parameters
 | 
						||
  }
 | 
						||
}
 | 
						||
 | 
						||
TArticolo_pack::TArticolo_pack() : TRectype(LF_ANAMAG)
 | 
						||
{ }
 | 
						||
 | 
						||
class TCache_art : public TCache_tp
 | 
						||
{
 | 
						||
  TLocalisamfile _anamag;
 | 
						||
 | 
						||
protected:
 | 
						||
  virtual TObject* key2obj(const char* key);
 | 
						||
  virtual const TString& decode(const TToken_string& tok);
 | 
						||
 | 
						||
  bool update_paper_composition(const char* key, TArticolo_pack& art);
 | 
						||
  int get_extra_info(const char* key, TArticolo_pack& art);
 | 
						||
 | 
						||
public:
 | 
						||
  const TArticolo_pack& articolo();
 | 
						||
  TCache_art(TPack_ddt* ddt) : TCache_tp(ddt), _anamag(LF_ANAMAG) {}
 | 
						||
};
 | 
						||
 | 
						||
bool TCache_art::update_paper_composition(const char* key, TArticolo_pack& art)
 | 
						||
{
 | 
						||
  TString qry(512);
 | 
						||
  qry = query_header();
 | 
						||
  qry << "SELECT Paper_Composition_Group.CompDesc\n"
 | 
						||
      << "FROM Mag_Existing_Article, Articles_Composition, Paper_Composition_Group\n"
 | 
						||
      << "WHERE (Mag_Existing_Article.ArtCode='" << key << "') AND "
 | 
						||
      << "(Mag_Existing_Article.ArticleCode=Articles_composition.ArticleCode) AND "
 | 
						||
      << "(Articles_Composition.CompCode=Paper_Composition_Group.CompCode);";
 | 
						||
  TODBC_recordset paperset(qry);
 | 
						||
  bool done = paperset.move_first();
 | 
						||
  if (done)
 | 
						||
  {
 | 
						||
    const TString& pc = paperset.get(0u).as_string(); // Paper composition
 | 
						||
    art.set_paper_composition(pc);
 | 
						||
  }
 | 
						||
  return done;
 | 
						||
}
 | 
						||
 | 
						||
 | 
						||
int TCache_art::get_extra_info(const char* key, TArticolo_pack& art)
 | 
						||
{
 | 
						||
  TString qry(512), article_code;
 | 
						||
  qry = query_header();
 | 
						||
  qry << "SELECT Mag_Existing_Article.ArticleCustCode, Mag_Existing_Article.ArticleCode\n"
 | 
						||
      << "FROM Mag_Existing_Article\n"
 | 
						||
      << "WHERE Mag_Existing_Article.ArtCode='" << key << "';"; 
 | 
						||
  TODBC_recordset artset(qry);
 | 
						||
  int info = artset.move_first() ? 1 : 0;
 | 
						||
  if (info)
 | 
						||
  {
 | 
						||
    const TString cc = artset.get(0u).as_string(); // Customer code
 | 
						||
    article_code     = artset.get(1).as_string();  // ArticleCode for Articles_environmentTax
 | 
						||
    article_code.trim();
 | 
						||
    art.set_customer_code(cc);
 | 
						||
    update_paper_composition(key, art);
 | 
						||
 | 
						||
    if (cc.full())
 | 
						||
    {
 | 
						||
      int righe = 0;
 | 
						||
      bool found = false;
 | 
						||
      { //per far chiudere il file CODCORR
 | 
						||
        TISAM_recordset alternative("USE CODCORR\nFROM CODART=#COD\nTO CODART=#COD");
 | 
						||
        alternative.set_var("#COD", TVariant(key));
 | 
						||
        righe = alternative.items();
 | 
						||
        for (bool ok = alternative.move_first(); ok && !found; ok = alternative.move_next())
 | 
						||
          found = alternative.get(CODCORR_CODARTALT).as_string() == cc;
 | 
						||
      }
 | 
						||
      if (!found)
 | 
						||
      {
 | 
						||
        TLocalisamfile codcorr(LF_CODCORR);
 | 
						||
        codcorr.zero();
 | 
						||
        codcorr.put(CODCORR_CODART, key);
 | 
						||
        codcorr.put(CODCORR_NRIGA, righe+1);
 | 
						||
        codcorr.put(CODCORR_TIPO, 'C');
 | 
						||
        codcorr.put(CODCORR_CODARTALT, cc);
 | 
						||
        test_write(codcorr);
 | 
						||
      }
 | 
						||
    }
 | 
						||
  }
 | 
						||
 | 
						||
  if (article_code.full()) // Ho trovato un articolo di magazzino, carico CONAI info
 | 
						||
  {
 | 
						||
    qry = query_header();
 | 
						||
    qry << "SELECT SubclassCode,Weight\n"
 | 
						||
        << "FROM Articles_environmentTax\n"
 | 
						||
        << "WHERE Articles_environmentTax.ArticleCode=" << article_code << ';';
 | 
						||
    TODBC_recordset envtax(qry);
 | 
						||
    for (bool et = envtax.move_first(); et; et = envtax.move_next())
 | 
						||
    {
 | 
						||
      const TString& sc = envtax.get(0u).as_string();
 | 
						||
      const real wkg = envtax.get(1).as_real();
 | 
						||
      const TCONAI_class cc = conai_str2class(sc);
 | 
						||
      if (art.set_conai(cc, sc, wkg))
 | 
						||
        info = 2;
 | 
						||
    }
 | 
						||
 | 
						||
    if (info == 2) // Ho trovato dati sul CONAI
 | 
						||
    {
 | 
						||
      bool update = false;
 | 
						||
      FOR_EACH_CONFIGURED_CONAI_CLASS(cc)
 | 
						||
      {
 | 
						||
        const TFieldref anamag_sotcat(conai_sottocat_name(cc, LF_ANAMAG), LF_ANAMAG);
 | 
						||
        const TFieldref anamag_weight(conai_peso_name(cc, LF_ANAMAG), LF_ANAMAG);
 | 
						||
        const TString4 sotcat = anamag_sotcat.read(art);
 | 
						||
        const TString8 peso = anamag_weight.read(art); // Faccio i confronti su stringa per evitare decimali impazziti
 | 
						||
        if (sotcat != art.conai_subclass(cc) || peso != art.conai_weight(cc).string())
 | 
						||
        {
 | 
						||
          anamag_sotcat.write(art.conai_subclass(cc), art);
 | 
						||
          anamag_weight.write(art.conai_weight(cc).string(), art);
 | 
						||
          update = true;
 | 
						||
        }
 | 
						||
      }
 | 
						||
      if (update) // Aggiorno anagrafica se necessario
 | 
						||
      {
 | 
						||
        _anamag.curr() = art;
 | 
						||
        test_rewrite(_anamag);
 | 
						||
      }
 | 
						||
    }
 | 
						||
  }
 | 
						||
  
 | 
						||
  return info;
 | 
						||
}
 | 
						||
 | 
						||
TObject* TCache_art::key2obj(const char* key)
 | 
						||
{
 | 
						||
  // Non salvo i codici vuoti presenti nelle righe descrizione
 | 
						||
  if (key == NULL || *key <= ' ')
 | 
						||
    return new TArticolo_pack; // Articolo nullo
 | 
						||
 | 
						||
  _anamag.put(ANAMAG_CODART, key);
 | 
						||
 | 
						||
  if (_anamag.read() != NOERR)
 | 
						||
  {
 | 
						||
    _anamag.zero();
 | 
						||
    _anamag.put(ANAMAG_CODART, key);
 | 
						||
    const TString& desc = get_str("ArtDesc");
 | 
						||
    _anamag.put(ANAMAG_DESCR, desc);
 | 
						||
 | 
						||
    TString4 conai_class = get_str("SubclassCode");
 | 
						||
    if (conai_class.blank())
 | 
						||
    {
 | 
						||
      conai_class = get_str("ClassCode");
 | 
						||
      if (conai_class.full())
 | 
						||
        conai_class << 99;
 | 
						||
    }
 | 
						||
 | 
						||
    // Basic CONAI info
 | 
						||
    const TCONAI_class cc = conai_str2class(conai_class);
 | 
						||
    if (conai_configured_class(cc))
 | 
						||
    {
 | 
						||
      const TFieldref fld_sc(conai_sottocat_name(cc, LF_ANAMAG), LF_ANAMAG);
 | 
						||
      fld_sc.write(conai_class, _anamag.curr());
 | 
						||
 | 
						||
      const TFieldref fld_wt(conai_peso_name(cc, LF_ANAMAG), LF_ANAMAG);
 | 
						||
      fld_wt.write(get_real_str("WeightETUnit"), _anamag.curr());
 | 
						||
    }
 | 
						||
 | 
						||
    const long gruconto = get_long("AccountCode");
 | 
						||
    const long sottoconto = get_long("AccountSubCode");
 | 
						||
    _anamag.put(ANAMAG_GRUPPOV, gruconto / 1000);
 | 
						||
    _anamag.put(ANAMAG_CONTOV,  gruconto % 1000);
 | 
						||
    _anamag.put(ANAMAG_SOTTOCV, sottoconto);
 | 
						||
    test_write(_anamag);
 | 
						||
  }
 | 
						||
 | 
						||
  TArticolo_pack* art = new TArticolo_pack(_anamag.curr());
 | 
						||
  get_extra_info(key, *art); // CustomerCode, PaperComposition, CONAI infos
 | 
						||
 | 
						||
  return art;
 | 
						||
}
 | 
						||
 | 
						||
const TArticolo_pack& TCache_art::articolo() 
 | 
						||
{ 
 | 
						||
  TString80 codart = get_str("ArtCode"); 
 | 
						||
  if (codart.empty()) // Se non ho un codice articolo lo creo in base al conto
 | 
						||
  {
 | 
						||
    const long gruconto = get_long("AccountCode");
 | 
						||
    const long sottoconto = get_long("AccountSubCode");
 | 
						||
    if (gruconto > 0 && sottoconto > 0)
 | 
						||
      codart << "*" << gruconto << '*' << sottoconto;
 | 
						||
  }
 | 
						||
 | 
						||
  return *(const TArticolo_pack*)objptr(codart); 
 | 
						||
}
 | 
						||
 | 
						||
const TString& TCache_art::decode(const TToken_string& tok)
 | 
						||
{
 | 
						||
  const TArticolo_pack& rec = *(const TArticolo_pack*)objptr(tok); 
 | 
						||
  return rec.get(ANAMAG_CODART);
 | 
						||
}
 | 
						||
 | 
						||
///////////////////////////////////////////////////////////
 | 
						||
// Cache unita' di misura degli articoli
 | 
						||
///////////////////////////////////////////////////////////
 | 
						||
 | 
						||
class TCache_umart : public TCache_tp
 | 
						||
{
 | 
						||
  TLocalisamfile _umart;
 | 
						||
 | 
						||
protected:
 | 
						||
  virtual TObject* key2obj(const char* key);
 | 
						||
 | 
						||
public:
 | 
						||
  const TString& decode(const TToken_string& key) { return *(const TString*)objptr(key); }
 | 
						||
  TCache_umart(TPack_transfer* pt) : TCache_tp(pt), _umart(LF_UMART) {}
 | 
						||
};
 | 
						||
 | 
						||
TObject* TCache_umart::key2obj(const char* key)
 | 
						||
{
 | 
						||
  TToken_string code(key);
 | 
						||
  TString80 codart; code.get(0, codart);
 | 
						||
  TString4 um;      code.get(1, um);
 | 
						||
  
 | 
						||
  TISAM_recordset umart("USE UMART\nFROM CODART=#COD\nTO CODART=#COD");
 | 
						||
  umart.set_var("#COD", TVariant(codart));
 | 
						||
 | 
						||
  bool found = false;
 | 
						||
  TRecnotype i = 0;
 | 
						||
  for (i = 0; umart.move_to(i) && !found; i++)
 | 
						||
    found = umart.get("UM").as_string() == um;
 | 
						||
 | 
						||
  if (!found)
 | 
						||
  {
 | 
						||
    _umart.put(UMART_CODART, codart);
 | 
						||
    _umart.put(UMART_NRIGA, i+1);
 | 
						||
    _umart.put(UMART_UM, um);
 | 
						||
    _umart.put(UMART_FC, 1);
 | 
						||
    test_write(_umart);
 | 
						||
  }
 | 
						||
 | 
						||
  return code.dup();
 | 
						||
}
 | 
						||
 | 
						||
///////////////////////////////////////////////////////////
 | 
						||
// TPack_ddt
 | 
						||
///////////////////////////////////////////////////////////
 | 
						||
 | 
						||
bool TPack_ddt::signal_row_error(const char* m)
 | 
						||
{
 | 
						||
  const long numdoc = get_long("DocCode");
 | 
						||
  const long numrig = get_long("DocRow");
 | 
						||
  TString msg; msg << m << TR(" DocCode:Row=") << numdoc << ':' << numrig;
 | 
						||
  return log_error(msg);
 | 
						||
}
 | 
						||
 | 
						||
bool TPack_ddt::get_tipodoc(TString& codnum, TString& tipodoc)
 | 
						||
{
 | 
						||
  bool ok = true;
 | 
						||
 | 
						||
  const TString& book = get_str("ReceiptBook");
 | 
						||
  if (book.full())
 | 
						||
  {
 | 
						||
    codnum = config().get(book, "CODNUM");
 | 
						||
    if (codnum.blank())
 | 
						||
    {
 | 
						||
      TString msg; 
 | 
						||
      msg << TR("Non esite una numerazione corrispondente al codice ") << book;
 | 
						||
      ok = log_error(msg);
 | 
						||
    }
 | 
						||
  }
 | 
						||
  else
 | 
						||
    ok = log_error("Impossibile determinare la numerazione");
 | 
						||
  if (codnum.blank())
 | 
						||
    codnum = "B01"; // Uso la prima numerazione che mi viene in mente
 | 
						||
  
 | 
						||
  const TString& tipo = get_str("StoreDocType");
 | 
						||
  if (tipo.full())
 | 
						||
  {
 | 
						||
    tipodoc = config().get(tipo, "TIPODOC");
 | 
						||
    if (tipodoc.blank())
 | 
						||
    {
 | 
						||
      TString msg; 
 | 
						||
      msg << TR("Non esite un tipo documento corrispondente al codice ") << tipo;
 | 
						||
      ok = log_error(msg);
 | 
						||
    }
 | 
						||
  }
 | 
						||
  else
 | 
						||
    ok = log_error("Impossibile determinare il tipo del documento");
 | 
						||
 | 
						||
  if (tipodoc.blank())
 | 
						||
    tipodoc = codnum;
 | 
						||
  
 | 
						||
  return ok;
 | 
						||
}
 | 
						||
 | 
						||
bool TPack_ddt::get_um_qta(TString& um, real& qta)
 | 
						||
{
 | 
						||
  const long flag_um = get_long("FlagUMPrice");
 | 
						||
 | 
						||
  const char* field_um = NULL;
 | 
						||
  const char* field_qta = NULL;
 | 
						||
  switch (flag_um)
 | 
						||
  {
 | 
						||
  case 0:
 | 
						||
    field_qta = "Quantity1";
 | 
						||
    field_um  = "UMDesc1";
 | 
						||
    break;
 | 
						||
  case 2:
 | 
						||
    field_qta = "Quantity2";
 | 
						||
    field_um  = "UMDesc2";
 | 
						||
    break;
 | 
						||
  default:
 | 
						||
    field_qta = "Quantity";
 | 
						||
    field_um  = "UMDesc";
 | 
						||
    break;
 | 
						||
  }
 | 
						||
  um = decode_field("%UMS", field_um);
 | 
						||
  qta = recordset().get(field_qta).as_real();
 | 
						||
 | 
						||
  const bool ok = um.full();
 | 
						||
  if (!ok)
 | 
						||
  {
 | 
						||
    TString msg;
 | 
						||
    msg << TR("Impossibile decodificare l'unit<69> di misura ") << '"' << get_str(field_um) << '"';
 | 
						||
    signal_row_error(msg);
 | 
						||
  }
 | 
						||
  return ok;
 | 
						||
}
 | 
						||
 | 
						||
const TArticolo_pack& TPack_ddt::get_articolo(TString& um, real& qta, TString& custcode)
 | 
						||
{
 | 
						||
  if (_art == NULL)
 | 
						||
    _art = new TCache_art(this);
 | 
						||
  const TArticolo_pack& rec = _art->articolo();
 | 
						||
  get_um_qta(um, qta);
 | 
						||
  custcode = rec.customer_code();
 | 
						||
 | 
						||
  if (!rec.empty() && um.full())
 | 
						||
  {
 | 
						||
    if (_umart == NULL)
 | 
						||
      _umart = new TCache_umart(this);
 | 
						||
 | 
						||
    TToken_string key;
 | 
						||
    key = rec.get(ANAMAG_CODART);
 | 
						||
    key.add(um);
 | 
						||
    _umart->decode(key);
 | 
						||
  }
 | 
						||
  
 | 
						||
  return rec;
 | 
						||
}
 | 
						||
 | 
						||
bool TPack_ddt::save_doc(TDocumento* &doc, const int doccode)
 | 
						||
{
 | 
						||
  bool ok = false;
 | 
						||
  if (doc != NULL)
 | 
						||
  {
 | 
						||
    if (write_enabled())
 | 
						||
    {
 | 
						||
      CHECK(doccode != 0, "Codice documento nullo");
 | 
						||
      const int err = doc->write();
 | 
						||
      if (err == NOERR)
 | 
						||
      {
 | 
						||
        ok = true;
 | 
						||
        TString cmd;
 | 
						||
        cmd << "UPDATE PDdT_Header SET StatusFlag=0 WHERE DocCode=" << doccode;
 | 
						||
        odbc_exec(cmd);
 | 
						||
      }
 | 
						||
      else
 | 
						||
      {
 | 
						||
        TString msg; msg.format("Errore %d durante la scrittura del documento", err);
 | 
						||
        ok = log_error(msg);
 | 
						||
      }
 | 
						||
    }
 | 
						||
    delete doc;
 | 
						||
    doc = NULL;
 | 
						||
  }
 | 
						||
  return ok;
 | 
						||
}
 | 
						||
 | 
						||
bool TPack_ddt::get_clifo(char& tipocf, long& codcf)
 | 
						||
{
 | 
						||
  tipocf = ' ';
 | 
						||
  codcf = 0;
 | 
						||
 | 
						||
  const char flag = get_str("FlagCustSupp")[0];
 | 
						||
  TToken_string code = get_str("CodContab");
 | 
						||
  switch (flag)
 | 
						||
  {
 | 
						||
  case 'D': 
 | 
						||
  case 'C': tipocf = 'C';
 | 
						||
            code.get(0, codcf); 
 | 
						||
            break;
 | 
						||
  case 'N': 
 | 
						||
  case 'S': tipocf = 'F';
 | 
						||
            code.get(0, codcf); 
 | 
						||
            break;
 | 
						||
  default : break;
 | 
						||
  }
 | 
						||
 | 
						||
  if (codcf > 0 && (tipocf == 'C' || tipocf == 'F'))
 | 
						||
	{
 | 
						||
		const int err = _cli.read(tipocf, codcf);
 | 
						||
		if (err != NOERR)
 | 
						||
		{
 | 
						||
			TString msg; msg.format("Errore %d durante la lettura del %s %ld ", err, tipocf == 'C' ? "Cliente" : "Fornitore", codcf);
 | 
						||
			return log_error(msg);
 | 
						||
		}
 | 
						||
    return true;
 | 
						||
	}
 | 
						||
  
 | 
						||
  return log_error(TR("Impossibile determinare il codice del cliente/fornitore"));
 | 
						||
}
 | 
						||
 | 
						||
const TString& TPack_ddt::get_indsped() const
 | 
						||
{
 | 
						||
  TToken_string cod_ind = get_str("DestCodContab");
 | 
						||
  return get_tmp_string() = cod_ind.get(1);
 | 
						||
}
 | 
						||
 | 
						||
void TPack_ddt::activate_customer_code(bool cc)
 | 
						||
{
 | 
						||
   _cust_code = cc && !cache().get("%TRI", "14").empty();
 | 
						||
}
 | 
						||
 | 
						||
const TString& TPack_ddt::get_codice_iva(const TDate& datadoc)
 | 
						||
{
 | 
						||
	if (_cli.use_lettere() && _cli.read_lettera(datadoc))
 | 
						||
  {
 | 
						||
		const TString& codiva = _cli.vendite().get(CFV_ASSFIS);
 | 
						||
    if (codiva.full())
 | 
						||
      return codiva;  // Codice IVA di Campo gia' decodificato!
 | 
						||
  }
 | 
						||
 | 
						||
  TString8 codiva; // Codice IVA di PACK da decodificare!
 | 
						||
  
 | 
						||
  TString qry(256);
 | 
						||
  qry << query_header() << "SELECT * FROM IVA WHERE IVACode=#CODIVA";
 | 
						||
  TODBC_recordset iva(qry);
 | 
						||
 | 
						||
  const TString& codivani = get_str("CodIvaNI");
 | 
						||
  if (atoi(codivani) > 0)
 | 
						||
  {
 | 
						||
    iva.set_var("#CODIVA", TVariant(codivani));
 | 
						||
    if (iva.move_first())
 | 
						||
    {
 | 
						||
      const TVariant& percent = iva.get("IVAValue");
 | 
						||
      if (percent.is_empty())
 | 
						||
        codiva = codivani;
 | 
						||
    }
 | 
						||
  }
 | 
						||
 | 
						||
  if (codiva.blank())
 | 
						||
  {
 | 
						||
    codiva = get_str("IVACode");
 | 
						||
    iva.set_var("#CODIVA", TVariant(codiva));
 | 
						||
    if (iva.move_first())
 | 
						||
    {
 | 
						||
      const TVariant& v = iva.get("xCode");
 | 
						||
      if (v.as_int() > 0)
 | 
						||
        v.as_string(codiva);
 | 
						||
    }
 | 
						||
  }
 | 
						||
  const TString& campiva = decode_value("%TPI", codiva);
 | 
						||
  return campiva;
 | 
						||
}
 | 
						||
 | 
						||
const TString& TPack_ddt::get_customer_reference() const
 | 
						||
{
 | 
						||
  const TString& rcr = get_str("RowCustReference"); // Provo a leggerlo dalla riga
 | 
						||
  if (rcr.full())
 | 
						||
    return rcr;
 | 
						||
  const TString& hcr = get_str("CustReference");    // Provo a leggerlo dalla testata
 | 
						||
  return hcr;
 | 
						||
}
 | 
						||
 | 
						||
bool TPack_ddt::get_paper_from_order(TString& desc) const
 | 
						||
{
 | 
						||
  const TString16 ndoc = get_str("CDocNumber");
 | 
						||
  const long nrow = get_long("CDocRow");
 | 
						||
  if (ndoc.blank() || nrow <= 0)
 | 
						||
    return false;
 | 
						||
 | 
						||
  TString qry(256);
 | 
						||
  qry << query_header();
 | 
						||
  qry << "SELECT Paper_Composition_Group.CompDesc\n"
 | 
						||
    "FROM CDoc_Rows, Paper_Composition_Group\n"
 | 
						||
    "WHERE (CDoc_Rows.DocNumber=#NDOC)AND(CDoc_Rows.RowNumber=#NROW)"
 | 
						||
    "AND(CDoc_Rows.CompCode=Paper_Composition_Group.CompCode)";
 | 
						||
 | 
						||
  TODBC_recordset paper(qry);
 | 
						||
  paper.set_var("#NDOC", TVariant(ndoc));
 | 
						||
  paper.set_var("#NROW", TVariant(nrow));
 | 
						||
 | 
						||
  if (paper.move_first())
 | 
						||
    desc = paper.get(0u).as_string();
 | 
						||
 | 
						||
  return desc.full();
 | 
						||
}
 | 
						||
 | 
						||
const TString& TPack_ddt::get_iban(const TRectype& clifo) const
 | 
						||
{
 | 
						||
  TString16 key; 
 | 
						||
  key.format("%c|%ld|V|1", clifo.get_char(CLI_TIPOCF), clifo.get_char(CLI_CODCF));
 | 
						||
  const TString& iban = cache().get(LF_CFBAN, key, CFBAN_IBAN);
 | 
						||
  if (iban.len() > 20)
 | 
						||
    return iban;
 | 
						||
  return clifo.get(CLI_IBAN);
 | 
						||
}
 | 
						||
 | 
						||
bool TPack_ddt::trasferisci()
 | 
						||
{
 | 
						||
  TString query = 
 | 
						||
    "SELECT DISTINCT "
 | 
						||
    "PDdT_Header.DocCode, PDdT_Header.StoreDocType, PDdT_Header.DocRefNumber, "
 | 
						||
    "PDdT_Header.DocDate, Store_Year.SyReferenceYear, PDdT_Header.CustSuppCode, "
 | 
						||
    "Customers_Suppliers.FlagCustSupp, Customers_Suppliers.CodContab, Customers_Suppliers.CategoryCode, Customers_Suppliers.ZoneCode, "
 | 
						||
    "Customers_Suppliers_1.CodContab AS AgentCode, "
 | 
						||
    "PDdT_Header.Change, CAMPOCurrencies.UMDesc AS Currency, "
 | 
						||
    "PDdT_Header.PaymentCode, PDdT_Header.ApplyEnvTax, PDdT_Header.DiscountOnPayment, "
 | 
						||
    "CausaliTrasporto.Code AS CodTrasporto, Porto.Code AS CodResa, CausaliTrasporto.Description1 AS TipoTrasporto, "
 | 
						||
    "Porto.Description1 AS TipoResa, PDdT_Header.Appearance, PDdT_Header.GrossWeight, PDdT_Header.NetWeight, "
 | 
						||
    "PDdT_Header.ShiverNumber, (select case when PDdT_Header.BankDesc is null Or [PDdT_Header].[BankDesc]<>''then "
 | 
						||
    "PDdT_Header.BankDesc else customers_suppliers.bankname end) AS BankDesc, PDdT_Header.CodIvaNI, "
 | 
						||
    "Customers_Suppliers_2.CustSuppCode AS DestCode, Customers_Suppliers_2.FlagCustSupp AS FlagDestCode, "
 | 
						||
    "Customers_Suppliers_2.CodContab AS DestCodContab, "
 | 
						||
    "Customers_Suppliers_2.TradeName1, Customers_Suppliers_2.Address, Customers_Suppliers_2.Locality, "
 | 
						||
    "Customers_Suppliers_2.ZipCode, Customers_Suppliers_2.Region, PDdT_Row.DocRow, PDdT_Row.ArtCode, "
 | 
						||
    "PDdT_Row.ArtDesc, PDdT_Row.CDocNumber, PDdT_Row.CDocRow, CDoc_Rows.CustReference AS RowCustReference, CDoc_Header.CustReference, PDdT_Row.Provv, "
 | 
						||
    "PDdT_Row.DiscountRowDesc, CDoc_Header.DocDate AS OrderDate, " /* "PDdT_Row.Discount2, PDdT_Row.Discount3, " */
 | 
						||
    "PDdT_Row.Quantity, Unit_Measure.UMDesc, PDdT_Row.Quantity1, Unit_Measure_1.UMDesc AS UMDesc1, "
 | 
						||
    "PDdT_Row.Quantity2, Unit_Measure_2.UMDesc AS UMDesc2, PDdT_Row.AdvanceSale, PDdT_Row.Price, "
 | 
						||
    "PDdT_Row.DefPrice, PDdT_Row.PriceNet, PDdT_Row.PriceNetDef, PDdT_Row.AmountNet, PDdT_Row.AmountNetDef, "
 | 
						||
    "PDdT_Row.Amount, PDdT_Row.AmountDef, PDdT_Row.FlagUMPrice, IVA.IVACode, PDdT_Row.AccountCode, "
 | 
						||
    "PDdT_Row.AccountSubCode, PDdT_Row.WeightETUnit, PDdT_Row.ClassCode, PDdT_Row.SubclassCode, "
 | 
						||
    "PDdT_Row.DDTRowType, PDdT_Header.StatusFlag, PDdT_Row.Report, PDdT_Row.FamilyCode,"
 | 
						||
    "Mag_Existing_Article.ArtType, Mag_Existing_Article.Height, Mag_Existing_Article.Width, Mag_Existing_Article.Lenght, "
 | 
						||
    "(select case when [Modalit<69> Fornitura Bancali].[Value1] is null then 1 else [Modalit<69> Fornitura Bancali].[Value1] end) AS FornituraBancali, "
 | 
						||
    "PDdT_Header.InvoicingType, PDdT_Header.DocProvv, PDdT_Header.ReceiptBook\n"
 | 
						||
    "FROM ((((((PDdT_Header LEFT JOIN Customers_Suppliers ON PDdT_Header.CustSuppCode = Customers_Suppliers.CustSuppCode) "
 | 
						||
    "LEFT JOIN Unit_Measure AS CAMPOCurrencies ON (CAMPOCurrencies.UMcode=PDdT_Header.CurrencyCode AND CAMPOCurrencies.UMType='9') "  
 | 
						||
    "LEFT JOIN Customers_Suppliers AS Customers_Suppliers_1 ON PDdT_Header.AgentCode = Customers_Suppliers_1.CustSuppCode) "
 | 
						||
    "LEFT JOIN Porto ON PDdT_Header.PortCode = Porto.Code) "
 | 
						||
    "LEFT JOIN Store_Year ON PDdT_Header.DocYear = Store_Year.SyCode) "
 | 
						||
    "LEFT JOIN Customers_Suppliers AS Customers_Suppliers_2 ON PDdT_Header.DestCode = Customers_Suppliers_2.CustSuppCode) "
 | 
						||
    "LEFT JOIN CausaliTrasporto ON PDdT_Header.DocCausalCode = CausaliTrasporto.Code) "
 | 
						||
    "RIGHT JOIN (Mag_Existing_Article RIGHT JOIN ((CDoc_Header "
 | 
						||
    "RIGHT JOIN (((IVA RIGHT JOIN (((CDoc_Rows RIGHT JOIN PDdT_Row ON (CDoc_Rows.DocNumber = PDdT_Row.CDocNumber) "
 | 
						||
    "AND (CDoc_Rows.RowNumber = PDdT_Row.CDocRow)) "
 | 
						||
    "LEFT JOIN Unit_Measure ON PDdT_Row.UMQty = Unit_Measure.UMCode) "
 | 
						||
    "LEFT JOIN [Modalit<69> Fornitura Bancali] ON PDdT_Row.DeliveryPalletType = [Modalit<69> Fornitura Bancali].Code) "
 | 
						||
    "ON IVA.IVACode = PDdT_Row.IVACode) LEFT JOIN Unit_Measure AS Unit_Measure_1 ON PDdT_Row.UMQta1 = Unit_Measure_1.UMCode) "
 | 
						||
    "LEFT JOIN Unit_Measure AS Unit_Measure_2 ON PDdT_Row.UMQta2 = Unit_Measure_2.UMCode) "
 | 
						||
    "ON CDoc_Header.DocNumber = CDoc_Rows.DocNumber) "
 | 
						||
    "LEFT JOIN CDoc_Rows_Detail ON (CDoc_Rows.RowNumber = CDoc_Rows_Detail.RowNumber) AND "
 | 
						||
    "(CDoc_Rows.DocNumber = CDoc_Rows_Detail.DocNumber)) "
 | 
						||
    "ON Mag_Existing_Article.ArtCode = PDdT_Row.ArtCode) ON PDdT_Header.DocCode = PDdT_Row.DocCode\n"
 | 
						||
    "WHERE (((PDdT_Row.DDTRowType)='0' Or (PDdT_Row.DDTRowType)='2') AND "
 | 
						||
    "((PDdT_Header.StatusFlag)='1' OR (PDdT_Header.StatusFlag)='2' Or (PDdT_Header.StatusFlag)='3') AND "
 | 
						||
    "((select case when [Modalit<69> Fornitura Bancali].[Value1] is null then 1 else [Modalit<69> Fornitura Bancali].[Value1] end)=1) AND "
 | 
						||
    "((PDdT_Header.InvoicingType) Is Not Null) AND ((PDdT_Header.DocProvv)<>-1))"
 | 
						||
    "\nORDER BY PDdT_Header.DocRefNumber, PDdT_Row.DocRow"
 | 
						||
    ;
 | 
						||
 | 
						||
	if (_extended_discount)
 | 
						||
	{
 | 
						||
		const TFixed_string discount("PDdT_Row.DiscountRowDesc, ");
 | 
						||
		const int pos = query.find(discount);
 | 
						||
    query.insert("PDdT_Row.Discount2, PDdT_Row.Discount3, ", pos+discount.len());
 | 
						||
	}
 | 
						||
  TRecordset& recset = create_recordset(query);
 | 
						||
 | 
						||
  TDocumento* doc = NULL;
 | 
						||
  long curr_ndoc = 0; // Numero in Campo
 | 
						||
  long curr_code = 0; // Numero in Pack
 | 
						||
  TString str;        // jolly
 | 
						||
 | 
						||
  TString last_custref;
 | 
						||
 | 
						||
  TPack_iterator ri(this);
 | 
						||
  while (++ri)
 | 
						||
  {
 | 
						||
    const long code = get_long("DocCode");
 | 
						||
    const long ndoc = get_long("DocRefNumber");
 | 
						||
    const TDate datadoc = recset.get("DocDate").as_date();
 | 
						||
    
 | 
						||
    if (_data_limite.ok() && datadoc > _data_limite)
 | 
						||
      continue;
 | 
						||
 | 
						||
    if (ndoc != curr_ndoc)
 | 
						||
    {
 | 
						||
      log("");
 | 
						||
      str.format(FR("Importazione documento %ld del %s"), ndoc, datadoc.string());
 | 
						||
      log(str);
 | 
						||
    
 | 
						||
      save_doc(doc, curr_code);
 | 
						||
      curr_ndoc = ndoc;
 | 
						||
      curr_code = code;
 | 
						||
      last_custref.cut(0); // Azzera documento di riferimento
 | 
						||
 | 
						||
      TString4 codnum, tipodoc;
 | 
						||
      get_tipodoc(codnum, tipodoc);
 | 
						||
 | 
						||
      doc = new TDocumento('D', datadoc.year(), codnum, ndoc);
 | 
						||
      const bool isnew = doc->rows() == 0;
 | 
						||
      if (isnew)
 | 
						||
      {
 | 
						||
        doc->put(DOC_TIPODOC, tipodoc);
 | 
						||
        doc->put(DOC_STATO,   1);
 | 
						||
        doc->put(DOC_DATADOC, datadoc);
 | 
						||
      }
 | 
						||
      else
 | 
						||
      {
 | 
						||
        doc->body().destroy_rows();
 | 
						||
        
 | 
						||
        // Aggiunto a malincuore supporto per cambio data documento ID=00011323
 | 
						||
        if (doc->get_date(DOC_DATADOC) != datadoc)
 | 
						||
        {
 | 
						||
          doc->put(DOC_DATADOC, datadoc); // Aggiorno la data documento
 | 
						||
 | 
						||
          TToken_string key;              // Cerco il documento precedente
 | 
						||
          key.add(doc->get(DOC_PROVV));
 | 
						||
          key.add(doc->get(DOC_ANNO));
 | 
						||
          key.add(doc->get(DOC_CODNUM));
 | 
						||
          key.add(ndoc-1);
 | 
						||
          const TRectype& prev = cache().get(LF_DOC, key); 
 | 
						||
          if (!prev.empty())              // Se lo trovo ...
 | 
						||
          {
 | 
						||
            const TDate prevdate = prev.get_date(DOC_DATADOC);
 | 
						||
            if (datadoc < prevdate)       // ... controllo la congruenza delle date
 | 
						||
            {
 | 
						||
              TString msg; 
 | 
						||
              msg.format("La data del documento %ld del %s precede quella del documento %ld del %s", 
 | 
						||
                         ndoc, datadoc.string(), ndoc-1, prevdate.string());
 | 
						||
              log(msg, 1);          // Segnalo un warning se non congruente
 | 
						||
            }
 | 
						||
          }
 | 
						||
        }
 | 
						||
      }
 | 
						||
 | 
						||
      char tipocf = ' ';
 | 
						||
      long codcf  = 0;
 | 
						||
      if (get_clifo(tipocf, codcf))
 | 
						||
      {
 | 
						||
        doc->put(DOC_TIPOCF, tipocf);
 | 
						||
        doc->put(DOC_CODCF,  codcf);
 | 
						||
        doc->put(DOC_CODINDSP, get_indsped());
 | 
						||
        if (isnew)
 | 
						||
        {
 | 
						||
          TToken_string tok; tok.add(tipocf); tok.add(codcf);
 | 
						||
          const TRectype& cfven = cache().get(LF_CFVEN, tok);
 | 
						||
          doc->put(DOC_RAGGR,     cfven.get(CFV_RAGGDOC));
 | 
						||
          doc->put(DOC_RAGGREFF,  cfven.get(CFV_RAGGEFF));
 | 
						||
          doc->put(DOC_ADDBOLLI,  cfven.get(CFV_ADDBOLLI));
 | 
						||
          doc->put(DOC_PERCSPINC, cfven.get(CFV_PERCSPINC));
 | 
						||
 | 
						||
          const TRectype& clifo = cache().get(LF_CLIFO, tok);
 | 
						||
          doc->put(DOC_CODABIA, clifo.get(CLI_CODABI));
 | 
						||
          doc->put(DOC_CODCABA, clifo.get(CLI_CODCAB));
 | 
						||
          doc->put(DOC_IBAN, get_iban(clifo));
 | 
						||
        }
 | 
						||
      }
 | 
						||
      doc->put(DOC_ZONA, decode_field("ZON", "ZoneCode")); // Crea anche la zona se necessario 
 | 
						||
 | 
						||
      TToken_string forn_age = get_str("AgentCode");
 | 
						||
      doc->put(DOC_CODAG, forn_age.get(1)); 
 | 
						||
      doc->put(DOC_SCONTOPERC, get_real_str("DiscountOnPayment"));
 | 
						||
 | 
						||
      const TString& codval = get_str("Currency");
 | 
						||
      if (is_firm_value(codval))
 | 
						||
      {
 | 
						||
        doc->zero(DOC_CODVAL);
 | 
						||
        doc->zero(DOC_CAMBIO);
 | 
						||
      }
 | 
						||
      else
 | 
						||
      {
 | 
						||
        doc->put(DOC_CODVAL, codval);
 | 
						||
        doc->put(DOC_CAMBIO, get_real_str("Change"));
 | 
						||
      }
 | 
						||
      
 | 
						||
      doc->put(DOC_CODPAG,     get_str("PaymentCode"));               // Il codice pagamento va' gia' bene cosi'
 | 
						||
      doc->put(DOC_CODPORTO,   decode_field("%TPP", "PortCode"));     // Codice porto decodificato tremite %TPP 
 | 
						||
      doc->put(DOC_CODSPMEZZO, decode_field("%TPM", "CodTrasporto")); // Codice porto decodificato tremite %TPM 
 | 
						||
    }
 | 
						||
 | 
						||
    if (_cust_ref)
 | 
						||
    {
 | 
						||
      const TString& custref = get_customer_reference();
 | 
						||
      // Aggiungi una riga di descrizione col riferimento cliente se e' cambiato
 | 
						||
      if (custref.full() && custref != last_custref)
 | 
						||
      {
 | 
						||
        last_custref = custref;
 | 
						||
        TRiga_documento& rdoc = doc->new_row("05"); // Crea una riga descrizione
 | 
						||
        rdoc.put(RDOC_DESCR, custref);
 | 
						||
      }
 | 
						||
    }
 | 
						||
 | 
						||
    TString4 um;
 | 
						||
    real qta;
 | 
						||
    TString custcode;
 | 
						||
    const TArticolo_pack& art = get_articolo(um, qta, custcode);
 | 
						||
 | 
						||
    TString4 rowtype = "01"; // Riga merce
 | 
						||
    bool bIsMerce = true;
 | 
						||
    if (qta.is_zero()) 
 | 
						||
    {
 | 
						||
      rowtype = "05";        // Se la qta e' nulla allora e' una descrizione
 | 
						||
      bIsMerce = false;
 | 
						||
    }
 | 
						||
    else
 | 
						||
    {
 | 
						||
      if (_cust_code && custcode.full())
 | 
						||
        rowtype = "14";          
 | 
						||
    }
 | 
						||
    TRiga_documento& rdoc = doc->new_row(rowtype); // Crea una riga del tipo appropriato
 | 
						||
		TString descr = get_str("ArtDesc");
 | 
						||
 | 
						||
    const bool bIsSingleSheet = bIsMerce && get_long("ArtType") == 4; // Foglio singolo?
 | 
						||
    if (bIsSingleSheet)
 | 
						||
    {
 | 
						||
      if (_order_paper_info)
 | 
						||
        get_paper_from_order(descr);
 | 
						||
 | 
						||
      if (bIsSingleSheet && descr.find('(') < 0) // E' un foglio singolo senza dimensioni?
 | 
						||
      {
 | 
						||
        TString80 misure;
 | 
						||
        misure << get_str("Height") << " x " << get_str("Width");
 | 
						||
        if (misure[0] > '0')
 | 
						||
          descr << " (" << misure << ')';
 | 
						||
      }
 | 
						||
    }
 | 
						||
 | 
						||
		if (descr.len() <= 50)
 | 
						||
			rdoc.put(RDOC_DESCR, descr);
 | 
						||
		else
 | 
						||
		{
 | 
						||
			rdoc.put(RDOC_DESCR, descr.left(50));
 | 
						||
			rdoc.put(RDOC_DESCLUNGA, "X");
 | 
						||
			rdoc.put(RDOC_DESCEST, descr.mid(50));
 | 
						||
		}
 | 
						||
 | 
						||
    if (bIsMerce) // Ho creato una riga articolo?
 | 
						||
    {
 | 
						||
      const TString& codart = art.get(ANAMAG_CODART);      
 | 
						||
      if (codart.full()) // Esistono righe merce senza articolo
 | 
						||
      {
 | 
						||
        rdoc.put(RDOC_CODART, rowtype == "01" ? codart : custcode);
 | 
						||
        rdoc.put(RDOC_CODARTMAG, codart);
 | 
						||
      }
 | 
						||
      rdoc.put(RDOC_CHECKED, "X");
 | 
						||
      rdoc.put(RDOC_UMQTA,  um);
 | 
						||
      rdoc.put(RDOC_QTA,    qta);
 | 
						||
      rdoc.put(RDOC_CODIVA, get_codice_iva(datadoc));
 | 
						||
      rdoc.put(RDOC_PREZZO, get_real_str("Price"));
 | 
						||
      
 | 
						||
      TString sconto = get_real_str("DiscountRowDesc");
 | 
						||
			if (_extended_discount)
 | 
						||
			{
 | 
						||
        sconto << ' ' << get_real_str("Discount2");
 | 
						||
        sconto << ' ' << get_real_str("Discount3");
 | 
						||
        sconto.trim(); sconto.replace(' ', '+');
 | 
						||
			}
 | 
						||
      rdoc.put(RDOC_SCONTO, sconto);
 | 
						||
      
 | 
						||
      rdoc.put(RDOC_PERCPROV, get_real_str("Provv"));
 | 
						||
 | 
						||
      if (bIsSingleSheet)
 | 
						||
        rdoc.put("NUMFOGLI", get_real_str("Quantity")); // Ex QTAGG3
 | 
						||
 | 
						||
      TString8 tok; 
 | 
						||
      tok.format("%c|%ld", doc->get_char(DOC_TIPOCF), doc->get_long(DOC_CODCF));
 | 
						||
      const TRectype& cfven = cache().get(LF_CFVEN, tok);
 | 
						||
 | 
						||
      // Copia tutte le sottocategorie CONAI dall'anagrafica alla riga documento
 | 
						||
      real peso_imballo_anamag;
 | 
						||
      int pesi_anamag = 0;
 | 
						||
      FOR_EACH_CONFIGURED_CONAI_CLASS(cc)
 | 
						||
      {
 | 
						||
        const TString& cs = art.conai_subclass(cc);  // Codice sottocategoria su ANAMAG
 | 
						||
        if (cs.full()) // la presenza della sottoclasse implica anche un peso positivo
 | 
						||
        {
 | 
						||
          const real& weight = art.conai_weight(cc); // Peso imballo su ANAMAG
 | 
						||
          rdoc.put(conai_sottocat_name(cc, LF_RIGHEDOC), cs);
 | 
						||
          rdoc.put(conai_peso_name(cc, LF_RIGHEDOC), weight);      // ex QTAGG1  
 | 
						||
          rdoc.put(conai_esenzione_name(cc, LF_RIGHEDOC), 
 | 
						||
                   cfven.get(conai_esenzione_name(cc, LF_CFVEN))); // ex QTAGG2
 | 
						||
          peso_imballo_anamag += weight;
 | 
						||
          pesi_anamag++;
 | 
						||
        }
 | 
						||
      }
 | 
						||
 | 
						||
      // La sottocategoria della bolla prevale su quella anagrafica impostata sopra
 | 
						||
      const TString4 conai_subclass = get_str("SubclassCode");
 | 
						||
      const TCONAI_class ct = conai_str2class(conai_subclass);
 | 
						||
      if (ct == CONAI_CARTA && conai_subclass.len() == 4)
 | 
						||
        rdoc.put(conai_sottocat_name(ct, LF_RIGHEDOC), conai_subclass);
 | 
						||
 | 
						||
      real peso_imballo_ddt = get_real_str("WeightETUnit");
 | 
						||
      if (peso_imballo_ddt.is_zero())
 | 
						||
        peso_imballo_ddt = peso_imballo_anamag;
 | 
						||
 | 
						||
      if (pesi_anamag > 1) // Con imballi composti da vari materiali devo riportare o riproporzionare
 | 
						||
      {
 | 
						||
        // Arrotondo la eventuale differenza di pesi al grammo
 | 
						||
        real diff = peso_imballo_ddt - peso_imballo_anamag; diff.round(3);
 | 
						||
        // Il peso in bolla e' diverso da quello in anagrafica: devo riproporzionarli
 | 
						||
        if (!diff.is_zero() && !peso_imballo_ddt.is_zero())
 | 
						||
        {
 | 
						||
          TGeneric_distrib d(peso_imballo_ddt, 3);
 | 
						||
          FOR_EACH_CONFIGURED_CONAI_CLASS(cc)
 | 
						||
            d.add(art.conai_weight(cc));
 | 
						||
          FOR_EACH_CONFIGURED_CONAI_CLASS(cc)
 | 
						||
            rdoc.put(conai_peso_name(cc), d.get());
 | 
						||
        }
 | 
						||
        else
 | 
						||
        {
 | 
						||
          // Il peso in bolla coincide con quello in anagrafica: devo riportarli
 | 
						||
          FOR_EACH_CONFIGURED_CONAI_CLASS(cc)
 | 
						||
            rdoc.put(conai_peso_name(cc), art.conai_weight(cc));
 | 
						||
        }
 | 
						||
      }
 | 
						||
      else
 | 
						||
      {
 | 
						||
        // Caso semplice della sola carta
 | 
						||
        rdoc.put(conai_peso_name(CONAI_CARTA), peso_imballo_ddt);
 | 
						||
      }
 | 
						||
      
 | 
						||
      rdoc.put("FAMILY", get_str("FamilyCode")); // Uso campo virtuale RG1:FAMILY
 | 
						||
    }
 | 
						||
 | 
						||
    TString info;
 | 
						||
    if (_paper_info)
 | 
						||
    {
 | 
						||
      const TString& pap_comp = art.paper_composition();
 | 
						||
      if (pap_comp.full()) 
 | 
						||
        info << "\n" << pap_comp;
 | 
						||
    }
 | 
						||
 | 
						||
    if (_paper_size)
 | 
						||
    {
 | 
						||
      TString80 misure;
 | 
						||
      misure << get_str("Height") << 'x' << get_str("Width") << 'x' << get_str("Lenght");
 | 
						||
      if (misure[0] > '0')
 | 
						||
        info << "\nMISURE: " << misure;
 | 
						||
    }
 | 
						||
 | 
						||
    if (_ref_info)
 | 
						||
    {
 | 
						||
      const TString& custref = get_customer_reference();
 | 
						||
      if (custref.full())
 | 
						||
        info << '\n' << custrif() << " " << custref;
 | 
						||
 | 
						||
      TString80 docnum = get_str("CDocNumber"); docnum.trim();
 | 
						||
      if (docnum.full())
 | 
						||
			{
 | 
						||
        info << '\n' << ordrif() << " " << docnum << '.' << get_str("CDocRow") ;
 | 
						||
				if (order_date())
 | 
						||
          info << " del " << get_str("OrderDate"); 
 | 
						||
			}
 | 
						||
    }
 | 
						||
    
 | 
						||
    if (info.full())
 | 
						||
    {
 | 
						||
      TString descest;
 | 
						||
      descest << rdoc.get(RDOC_DESCEST) << info;
 | 
						||
      descest.rtrim();
 | 
						||
      rdoc.put(RDOC_DESCLUNGA, "X");
 | 
						||
      rdoc.put(RDOC_DESCEST, descest);
 | 
						||
    }
 | 
						||
    
 | 
						||
    if (_cms_ref)
 | 
						||
    {
 | 
						||
      TString ref = get_str("CustReference").before(' '); // Leggo inizio testata es: "1203 DEL 16 02 2006"
 | 
						||
      if (ref.full())
 | 
						||
      {
 | 
						||
        const TString& r_ref = get_str("RowCustReference"); // Leggo dalla riga
 | 
						||
        if (r_ref.full())
 | 
						||
          ref << '/' << r_ref << '/' << art.customer_code(); 
 | 
						||
        rdoc.put(RDOC_CODCMS, ref);
 | 
						||
      }
 | 
						||
    }
 | 
						||
  }
 | 
						||
 | 
						||
  save_doc(doc, curr_code); // Salva l'eventuale ultimo documento pendente
 | 
						||
 | 
						||
  return write_enabled();
 | 
						||
}
 | 
						||
 | 
						||
TPack_ddt::TPack_ddt() 
 | 
						||
         : _art(NULL), _umart(NULL), 
 | 
						||
           _cust_ref(false), _paper_info(false), _ref_info(true), _cust_code(false)
 | 
						||
{ }
 | 
						||
 | 
						||
TPack_ddt::~TPack_ddt()
 | 
						||
{ 
 | 
						||
  if (_umart != NULL)
 | 
						||
    delete _umart;
 | 
						||
  if (_art != NULL)
 | 
						||
    delete _art;
 | 
						||
}
 |