Patch level : 10.0
Files correlati : tp0 Ricompilazione Demo : [ ] Commento : Nuova gestione CONAI per PACK git-svn-id: svn://10.65.10.50/trunk@19332 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									348c0344ed
								
							
						
					
					
						commit
						ab17e4d72f
					
				| @ -195,9 +195,23 @@ long TPack_transfer::odbc_exec(const char* cmd) | ||||
|       err = _outset->exec("BEGIN TRANS"); | ||||
|     } | ||||
|     if (err >= 0) | ||||
|     { | ||||
|       err = _outset->exec(cmd); | ||||
|     if (err < 0) | ||||
|       log_error(TR("Errore di connessione al database")); | ||||
|       if (err < 0) | ||||
|       { | ||||
|         log("", 0);                       // Salto una riga
 | ||||
|         TParagraph_string msg(cmd, 100); | ||||
|         FOR_EACH_TOKEN(msg, str)          | ||||
|           log(str, 0);                    // Riporto tutta la query
 | ||||
|         log_error(TR("ERRORE in esecuzione della query.")); | ||||
|       } | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|       TString msg; | ||||
|       msg << TR("ERRORE di connessione a ") << _outset->dsn() << " : BEGIN TRANS"; | ||||
|       log_error(msg); | ||||
|     } | ||||
|   } | ||||
|   return err; | ||||
| } | ||||
|  | ||||
| @ -1,10 +1,10 @@ | ||||
| #include "tp0100.h" | ||||
| 
 | ||||
| #include <expr.h> | ||||
| #include <recarray.h> | ||||
| #include <tabutil.h> | ||||
| 
 | ||||
| #include "..\pr\agenti.h" | ||||
| 
 | ||||
| #include <clifo.h> | ||||
| #include <cfven.h> | ||||
| #include <comuni.h> | ||||
| @ -18,44 +18,45 @@ | ||||
| 
 | ||||
| class TCache_ban : public TCache_tp | ||||
| { | ||||
|   TTable _ban; | ||||
| 
 | ||||
| protected: | ||||
|   virtual TObject* key2obj(const char* key); | ||||
| 
 | ||||
| public: | ||||
|   virtual const TString& decode(const TToken_string& tok); | ||||
|   TCache_ban(TPack_transfer* pt) : TCache_tp(pt) {} | ||||
|   TCache_ban(TPack_transfer* pt) : TCache_tp(pt), _ban("%BAN") {} | ||||
| }; | ||||
| 
 | ||||
| TObject* TCache_ban::key2obj(const char* key) | ||||
| { | ||||
|   TTable ban("%BAN"); | ||||
|   TToken_string code(key); | ||||
|   TString8 abi; code.get(0, abi); | ||||
|   TString8 cab; code.get(1, cab); | ||||
|   ban.put("CODTAB", abi); | ||||
|   if (ban.read() != NOERR) | ||||
|   _ban.put("CODTAB", abi); | ||||
|   if (_ban.read() != NOERR) | ||||
|   { | ||||
|     const TString& desc = get_str("BankName"); | ||||
|     ban.put("CODTAB", abi); | ||||
|     ban.put("S0", desc); | ||||
|     test_write(ban); | ||||
|     _ban.put("CODTAB", abi); | ||||
|     _ban.put("S0", desc); | ||||
|     test_write(_ban); | ||||
|   } | ||||
| 	TString16 str; | ||||
| 	str << abi; str << cab; | ||||
|   ban.put("CODTAB", str); | ||||
|   if (ban.read() != NOERR) | ||||
|   _ban.put("CODTAB", str); | ||||
|   if (_ban.read() != NOERR) | ||||
|   { | ||||
|     const TString& desc = get_str("BankName");   | ||||
|     ban.put("CODTAB", str); | ||||
|     ban.put("S0", desc); | ||||
|     test_write(ban); | ||||
|     _ban.put("CODTAB", str); | ||||
|     _ban.put("S0", desc); | ||||
|     test_write(_ban); | ||||
|   } | ||||
|   return ban.get("S0").dup(); | ||||
|   return _ban.get("S0").dup(); | ||||
| } | ||||
| 
 | ||||
| const TString& TCache_ban::decode(const TToken_string& tok) | ||||
| { | ||||
|   return *(const TString*) objptr(tok); | ||||
|   return *(const TString*)objptr(tok); | ||||
| } | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
|  | ||||
							
								
								
									
										226
									
								
								tp/tp0102.cpp
									
									
									
									
									
								
							
							
						
						
									
										226
									
								
								tp/tp0102.cpp
									
									
									
									
									
								
							| @ -3,10 +3,51 @@ | ||||
| #include "../ve/velib.h" | ||||
| #include "../mg/codcorr.h" | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| //////////////////////////////////////////////////////////
 | ||||
| // Cache articoli
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| class TArticolo_pack : public TRectype | ||||
| { | ||||
|   TString _cust_code, _paper_comp; | ||||
|    | ||||
|   TString4 _conai_scat[CONAI_CLASSES]; | ||||
|   real _conai_peso[CONAI_CLASSES]; | ||||
| 
 | ||||
| public: | ||||
|   void set_customer_code(const TString& cc) { _cust_code = cc; } | ||||
|   const TString& customer_code() const { return _cust_code; } | ||||
|    | ||||
|   void set_paper_composition(const TString& pc) { _paper_comp = pc; } | ||||
|   const TString& paper_composition() const { return _paper_comp; } | ||||
| 
 | ||||
|   const TString& conai_subclass(TCONAI_class cc) const { CHECK_CONAI(cc); return _conai_scat[cc]; } | ||||
|   const real& conai_weight(TCONAI_class cc) const { CHECK_CONAI(cc); return _conai_peso[cc]; } | ||||
|    | ||||
|   TArticolo_pack(const TRectype& anamag); | ||||
|   TArticolo_pack(); | ||||
| }; | ||||
| 
 | ||||
| TArticolo_pack::TArticolo_pack(const TRectype& anamag) : TRectype(anamag) | ||||
| {} | ||||
| 
 | ||||
| TArticolo_pack::TArticolo_pack() : TRectype(LF_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(*this); | ||||
|     const real peso = anamag_weight.read(*this); | ||||
|     if (sotcat.full() && !peso.is_zero()) | ||||
|     { | ||||
|       _conai_scat[cc] = sotcat; | ||||
|       _conai_peso[cc] = peso; | ||||
|     } | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| class TCache_art : public TCache_tp | ||||
| { | ||||
|   TLocalisamfile _anamag; | ||||
| @ -14,17 +55,17 @@ class TCache_art : public TCache_tp | ||||
| protected: | ||||
|   virtual TObject* key2obj(const char* key); | ||||
|   virtual const TString& decode(const TToken_string& tok); | ||||
|   bool get_extra_info(const char* key, TString& pc, TString& cc) const; | ||||
|   bool get_extra_info(const char* key, TArticolo_pack& art) const; | ||||
| 
 | ||||
| public: | ||||
|   const TRectype& articolo(); | ||||
|   const TArticolo_pack& articolo(); | ||||
|   TCache_art(TPack_ddt* ddt) : TCache_tp(ddt), _anamag(LF_ANAMAG) {} | ||||
| }; | ||||
| 
 | ||||
| bool TCache_art::get_extra_info(const char* key, TString& pc, TString& cc) const | ||||
| bool TCache_art::get_extra_info(const char* key, TArticolo_pack& art) const | ||||
| { | ||||
|   TString qry(512); | ||||
|   qry << query_header(); | ||||
|   qry = query_header(); | ||||
|   qry << "SELECT Paper_Composition_Group.CompDesc, Mag_Existing_Article.ArticleCustCode\n" | ||||
|       << "FROM Mag_Existing_Article, Articles_Composition, Paper_Composition_Group\n" | ||||
|       << "WHERE (Mag_Existing_Article.ArtCode='" << key << "') AND " | ||||
| @ -34,8 +75,10 @@ bool TCache_art::get_extra_info(const char* key, TString& pc, TString& cc) const | ||||
|   const bool ok = paperset.move_first(); | ||||
|   if (ok) | ||||
|   { | ||||
|     pc = paperset.get(0u).as_string(); // Paper composition
 | ||||
|     cc = paperset.get(1).as_string();  // Customer code
 | ||||
|     const TString pc = paperset.get(0u).as_string(); // Paper composition
 | ||||
|     const TString cc = paperset.get(1).as_string();  // Customer code
 | ||||
|     art.set_customer_code(cc); | ||||
|     art.set_paper_composition(pc); | ||||
|     if (cc.full()) | ||||
|     { | ||||
|       int righe = 0; | ||||
| @ -59,51 +102,59 @@ bool TCache_art::get_extra_info(const char* key, TString& pc, TString& cc) const | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   qry = query_header(); | ||||
|   qry << "SELECT ClassCode,Weight\n" | ||||
|       << "FROM Mag_Existing_Article, Articles_environmentTax\n" | ||||
|       << "WHERE (Mag_Existing_Article.ArtCode='" << key << "') AND " | ||||
|       << "(Mag_Existing_Article.ArticleCode=Articles_environmentTax.ArticleCode)"; | ||||
|   TODBC_recordset envtax(qry); | ||||
|   for (bool et = envtax.move_first(); et; et = envtax.move_next()) | ||||
|   { | ||||
|     const TString& cc = envtax.get(0u).as_string(); | ||||
|     const real wkg = envtax.get(1).as_real(); | ||||
|   } | ||||
| 
 | ||||
|   return ok; | ||||
| } | ||||
| 
 | ||||
| TObject* TCache_art::key2obj(const char* key) | ||||
| { | ||||
|   if (key && *key > ' ') // Non salvo i codici vuoti presenti nelle righe descrizione
 | ||||
|   // 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.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); | ||||
| 
 | ||||
|       const TString& conai_class = get_str("ClassCode"); | ||||
|       if (conai_class.full()) | ||||
|       { | ||||
|         const TString& conai_field = config().get(conai_class, "CONAI"); | ||||
|         if (conai_field.full()) | ||||
|           _anamag.put(conai_field, get_real_str("WeightETUnit")); | ||||
|       } | ||||
| 
 | ||||
|       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); | ||||
|     } | ||||
| 
 | ||||
|     // Non memorizzo permanentemente questi dati ma li rendo disponibili
 | ||||
|     TString paper_composition, customer_code; | ||||
|     if (get_extra_info(key, paper_composition, customer_code)) | ||||
|     { | ||||
|       _anamag.put(ANAMAG_USER10, paper_composition); | ||||
|       _anamag.put(ANAMAG_USER9, customer_code); | ||||
|     } | ||||
|   } | ||||
|   else | ||||
|     _anamag.zero(); | ||||
|   return _anamag.curr().dup(); | ||||
|     _anamag.put(ANAMAG_CODART, key); | ||||
|     const TString& desc = get_str("ArtDesc"); | ||||
|     _anamag.put(ANAMAG_DESCR, desc); | ||||
| 
 | ||||
|     const TString& conai_class = get_str("ClassCode"); | ||||
|     if (conai_class.full()) | ||||
|     { | ||||
|       const TString& conai_field = config().get(conai_class, "CONAI"); | ||||
|       if (conai_field.full()) | ||||
|         _anamag.put(conai_field, get_real_str("WeightETUnit")); | ||||
|     } | ||||
| 
 | ||||
|     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 e PaperComposition
 | ||||
| 
 | ||||
|   return art; | ||||
| } | ||||
| 
 | ||||
| const TRectype& TCache_art::articolo()  | ||||
| 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
 | ||||
| @ -114,12 +165,12 @@ const TRectype& TCache_art::articolo() | ||||
|       codart << "*" << gruconto << '*' << sottoconto; | ||||
|   } | ||||
| 
 | ||||
|   return *(const TRectype*)objptr(codart);  | ||||
|   return *(const TArticolo_pack*)objptr(codart);  | ||||
| } | ||||
| 
 | ||||
| const TString& TCache_art::decode(const TToken_string& tok) | ||||
| { | ||||
|   const TRectype& rec = *(const TRectype*)objptr(tok);  | ||||
|   const TArticolo_pack& rec = *(const TArticolo_pack*)objptr(tok);  | ||||
|   return rec.get(ANAMAG_CODART); | ||||
| } | ||||
| 
 | ||||
| @ -129,12 +180,14 @@ const TString& TCache_art::decode(const TToken_string& tok) | ||||
| 
 | ||||
| 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) {} | ||||
|   TCache_umart(TPack_transfer* pt) : TCache_tp(pt), _umart(LF_UMART) {} | ||||
| }; | ||||
| 
 | ||||
| TObject* TCache_umart::key2obj(const char* key) | ||||
| @ -153,12 +206,11 @@ TObject* TCache_umart::key2obj(const char* key) | ||||
| 
 | ||||
|   if (!found) | ||||
|   { | ||||
|     TLocalisamfile umart(LF_UMART); | ||||
|     umart.put(UMART_CODART, codart); | ||||
|     umart.put(UMART_NRIGA, i+1); | ||||
|     umart.put(UMART_UM, um); | ||||
|     umart.put(UMART_FC, 1); | ||||
|     test_write(umart); | ||||
|     _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(); | ||||
| @ -249,9 +301,9 @@ const TRectype& TPack_ddt::get_articolo(TString& um, real& qta, TString& custcod | ||||
| { | ||||
|   if (_art == NULL) | ||||
|     _art = new TCache_art(this); | ||||
|   const TRectype& rec = _art->articolo(); | ||||
|   const TArticolo_pack& rec = _art->articolo(); | ||||
|   get_um_qta(um, qta); | ||||
|   custcode = rec.get(ANAMAG_USER9); | ||||
|   custcode = rec.customer_code(); | ||||
| 
 | ||||
|   if (!rec.empty() && um.full()) | ||||
|   { | ||||
| @ -318,11 +370,9 @@ bool TPack_ddt::get_clifo(char& tipocf, long& codcf) | ||||
|   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; | ||||
| @ -580,7 +630,7 @@ bool TPack_ddt::trasferisci() | ||||
|     TString4 um; | ||||
|     real qta; | ||||
|     TString custcode; | ||||
|     const TRectype& art = get_articolo(um, qta, custcode); | ||||
|     const TArticolo_pack& art = get_articolo(um, qta, custcode); | ||||
| 
 | ||||
|     TString4 rowtype = "01"; // Riga merce
 | ||||
|     bool bIsMerce = true; | ||||
| @ -645,31 +695,61 @@ bool TPack_ddt::trasferisci() | ||||
|       rdoc.put(RDOC_SCONTO, sconto); | ||||
|        | ||||
|       rdoc.put(RDOC_PERCPROV, get_real_str("Provv")); | ||||
|       rdoc.put(RDOC_QTAGG1, get_real_str("WeightETUnit")); | ||||
|       rdoc.zero(RDOC_QTAGG2); // Azzera percentuale indetraibilita' CONAI
 | ||||
| 
 | ||||
|       if (bIsSingleSheet) | ||||
|         rdoc.put(RDOC_QTAGG3, get_real_str("Quantity")); | ||||
|         rdoc.put("NUMFOGLI", get_real_str("Quantity")); // Ex QTAGG3
 | ||||
| 
 | ||||
|       const TString& conai_class = get_str("ClassCode"); | ||||
|       rdoc.put(RDOC_CODAGG1, conai_class); | ||||
|       rdoc.put(RDOC_CODAGG2, get_str("SubclassCode")); | ||||
|       rdoc.put("FAMILY", get_str("FamilyCode"));        // Uso campo virtuale RG1:FAMILY
 | ||||
|       TString8 tok;  | ||||
|       tok.format("%c|%ld", doc->get_char(DOC_TIPOCF), doc->get_long(DOC_CODCF)); | ||||
|       const TRectype& cfven = cache().get(LF_CFVEN, tok); | ||||
| 
 | ||||
|       const TString& conai_cfv = config().get(conai_class, "CFV_CONAI"); | ||||
|       if (conai_cfv.full()) | ||||
|       // Copia tutte le sottocategorie CONAI dall'anagrafica alla riga documento
 | ||||
|       real peso_imballo_anamag; | ||||
|       int pesi_anamag = 0; | ||||
|       FOR_EACH_CONAI_CLASS(cc) | ||||
|       { | ||||
|         TString8 tok;  | ||||
|         tok.format("%c|%ld", doc->get_char(DOC_TIPOCF), doc->get_long(DOC_CODCF)); | ||||
|         const TRectype& cfven = cache().get(LF_CFVEN, tok); | ||||
|         const real perc = cfven.get(conai_cfv); | ||||
|         rdoc.put(RDOC_QTAGG2, perc); | ||||
|         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 TString& conai_class = get_str("ClassCode");  | ||||
|       const TCONAI_class ct = conai_str2class(conai_class); | ||||
|       const TString& conai_subclass = get_str("SubclassCode"); | ||||
|       rdoc.put(conai_sottocat_name(ct, LF_RIGHEDOC), conai_subclass);  | ||||
| 
 | ||||
|       const real peso_imballo_ddt = get_real_str("WeightETUnit"); | ||||
|       // Con imballi composti da vari materiali devo riproporzionare
 | ||||
|       if (pesi_anamag > 1 && peso_imballo_ddt != peso_imballo_anamag && !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 | ||||
|       { | ||||
|         // Caso semplice della sola carta
 | ||||
|         rdoc.put(conai_peso_name(ct), peso_imballo_ddt); | ||||
|       } | ||||
| 
 | ||||
|       rdoc.put("FAMILY", get_str("FamilyCode")); // Uso campo virtuale RG1:FAMILY
 | ||||
|     } | ||||
| 
 | ||||
|     TString info; | ||||
|     if (_paper_info) | ||||
|     { | ||||
|       const TString& pap_comp = art.get(ANAMAG_USER10); | ||||
|       const TString& pap_comp = art.paper_composition(); | ||||
|       if (pap_comp.full())  | ||||
|         info << "\n" << pap_comp; | ||||
|     } | ||||
| @ -710,7 +790,7 @@ bool TPack_ddt::trasferisci() | ||||
|       { | ||||
|         const TString& r_ref = get_str("RowCustReference"); // Leggo dalla riga
 | ||||
|         if (r_ref.full()) | ||||
|           ref << '/' << r_ref << '/' << art.get(ANAMAG_USER9);  | ||||
|           ref << '/' << r_ref << '/' << art.customer_code();  | ||||
|         rdoc.put(RDOC_CODCMS, ref); | ||||
|       } | ||||
|     } | ||||
|  | ||||
| @ -74,9 +74,8 @@ public: | ||||
| }; | ||||
| 
 | ||||
| TDichiarazione_CONAI_csv_recordset::TDichiarazione_CONAI_csv_recordset()  | ||||
| : TCSV_recordset("CSV(,)\n") | ||||
| { | ||||
| } | ||||
|                                   : TCSV_recordset("CSV(,)\n") | ||||
| {} | ||||
| 
 | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| @ -86,14 +85,14 @@ TDichiarazione_CONAI_csv_recordset::TDichiarazione_CONAI_csv_recordset() | ||||
| class TDichiarazione_CONAI : public TSkeleton_application | ||||
| { | ||||
| protected: | ||||
|   real clifo_conai(const TCli_for& clifo, const int conai_specie, TString& paiv) const; | ||||
|   real clifo_conai(const TCli_for& clifo, const TCONAI_class conai_specie, TString& paiv) const; | ||||
|   void elabora(const TMask& mask) const; | ||||
|   void scrivi_csv(const TRectype& prima_riga, TDichiarazione_CONAI_csv_recordset& csv,  | ||||
|                   const int conai_specie, const TString& conai_codart) const; | ||||
|                   const TCONAI_class conai_specie, const TString& conai_codart) const; | ||||
|   void scrivi_csv_doc_con_riga_generata(TDocumento& doc, const int n_riga_generata, | ||||
|                                         TDichiarazione_CONAI_csv_recordset& csv, const int conai_specie) const; | ||||
|                                         TDichiarazione_CONAI_csv_recordset& csv, const TCONAI_class conai_specie) const; | ||||
|   void scrivi_csv_doc_speciale(TDocumento& doc, TDichiarazione_CONAI_csv_recordset& csv, | ||||
|                                const int conai_specie, const TString& conai_codart) const; | ||||
|                                const TCONAI_class conai_specie, const TString& conai_codart) const; | ||||
| 
 | ||||
| public: | ||||
| 	virtual bool create(); | ||||
| @ -101,19 +100,13 @@ public: | ||||
| 
 | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
| real TDichiarazione_CONAI::clifo_conai(const TCli_for& clifo, const int conai_specie, TString& paiv) const | ||||
| // Percentuale di esenzione CONAI di clifo
 | ||||
| real TDichiarazione_CONAI::clifo_conai(const TCli_for& clifo, const TCONAI_class conai_specie, TString& paiv) const | ||||
| { | ||||
|   const char* campi[6] = { CFV_ESACC, CFV_ESALL, CFV_ESCAR, CFV_ESPLA, CFV_ESLEG, CFV_ESVET }; | ||||
|   const TRectype& cfven_rec = clifo.vendite(); | ||||
|   real cfven_perc_conai = ZERO; | ||||
|   if (conai_specie >= 0 && conai_specie < 6) | ||||
|     cfven_perc_conai = cfven_rec.get_real(campi[conai_specie]); | ||||
| 
 | ||||
| 	//vecchio modo con piva che fa precedenza a cofi
 | ||||
|   /*paiv = clifo.get(CLI_PAIV);
 | ||||
|   if (paiv.empty()) | ||||
|     paiv = clifo.get(CLI_COFI);*/ | ||||
|   real cfven_perces_conai = ZERO; | ||||
|   if (conai_configured_class(conai_specie)) | ||||
|     cfven_perces_conai = cfven_rec.get_real(conai_esenzione_name(conai_specie, LF_CFVEN)); | ||||
| 
 | ||||
| 	//nuovo metodo con logica rovesciata (fino al prossimo cambio di idea!)
 | ||||
| 	paiv = clifo.get(CLI_COFI); | ||||
| @ -123,12 +116,13 @@ real TDichiarazione_CONAI::clifo_conai(const TCli_for& clifo, const int conai_sp | ||||
| 		paiv << " (PI)"; | ||||
| 	} | ||||
| 
 | ||||
|   return cfven_perc_conai; | ||||
|   return cfven_perces_conai; | ||||
| } | ||||
| 
 | ||||
| //riempie recordset con le righe CONAI del documento che contiene una riga generata CONAI
 | ||||
| void TDichiarazione_CONAI::scrivi_csv_doc_con_riga_generata(TDocumento& doc, const int n_riga_generata, TDichiarazione_CONAI_csv_recordset& csv,  | ||||
|                                       const int conai_specie) const | ||||
| void TDichiarazione_CONAI::scrivi_csv_doc_con_riga_generata(TDocumento& doc, const int n_riga_generata,  | ||||
|                                                             TDichiarazione_CONAI_csv_recordset& csv,  | ||||
|                                                             const TCONAI_class conai_specie) const | ||||
| { | ||||
|   //prende dalla riga i dati che gli servono per fare vari calcoli
 | ||||
|   const TRiga_documento& riga_generata = doc[n_riga_generata]; | ||||
| @ -176,7 +170,7 @@ void TDichiarazione_CONAI::scrivi_csv_doc_con_riga_generata(TDocumento& doc, con | ||||
| 
 | ||||
|     //servono SOLO le righe CONAI!!!!!
 | ||||
|       //se non e' stata definita la sottocategoria conai (maiali!!) va messa uguale a quella generica
 | ||||
|     TString4 sottocat = rdoc.get(get_conai_sottocat_name(conai_specie)); | ||||
|     TString4 sottocat = rdoc.get(conai_sottocat_name(conai_specie)); | ||||
|     //puo' capitare che la sottocategoria sia stata troncata alla categoria
 | ||||
|     if (sottocat.len() == 2) | ||||
|       sottocat << "99"; | ||||
| @ -209,7 +203,7 @@ void TDichiarazione_CONAI::scrivi_csv_doc_con_riga_generata(TDocumento& doc, con | ||||
|     csv.set(11, TVariant(umqta));      | ||||
| 
 | ||||
|     //quantita' totale conai (A + B) sul report (le NAC hanno segno rovesciato)
 | ||||
|     real qta_tot_conai = (real&)qta_AB_conai[i]; | ||||
|     real qta_tot_conai = (const real&)qta_AB_conai[i]; | ||||
|     if (is_nac) | ||||
|       qta_tot_conai = -qta_tot_conai; | ||||
|     csv.set(15, TVariant(qta_tot_conai)); | ||||
| @ -236,9 +230,9 @@ void TDichiarazione_CONAI::scrivi_csv_doc_con_riga_generata(TDocumento& doc, con | ||||
|     const real totale_contrib_conai = qta_assoggettata_conai * prezzo; | ||||
|     csv.set(14, TVariant(totale_contrib_conai)); | ||||
| 
 | ||||
|     //percentuale di esenzione conai in qtagg2
 | ||||
|     const real rdoc_perc_conai = rdoc.get_real(RDOC_QTAGG2); | ||||
|     csv.set(16, TVariant(rdoc_perc_conai)); | ||||
|     //percentuale di esenzione conai
 | ||||
|     const TVariant rdoc_perc_conai = rdoc.get_real(conai_esenzione_name(conai_specie, LF_RIGHEDOC)); | ||||
|     csv.set(16, rdoc_perc_conai); | ||||
| 
 | ||||
|     //percentuale di esenzione conai in cfven
 | ||||
|     csv.set(17, TVariant(cfven_perc_conai)); | ||||
| @ -248,7 +242,7 @@ void TDichiarazione_CONAI::scrivi_csv_doc_con_riga_generata(TDocumento& doc, con | ||||
| //riempie recordset con le righe CONAI del documento che NON ha una riga generata CONAI;trattasi di documenti..
 | ||||
| //..farlocchi costruiti ad arte per correggere le vaccate dei rompiscatolifici
 | ||||
| void TDichiarazione_CONAI::scrivi_csv_doc_speciale(TDocumento& doc, TDichiarazione_CONAI_csv_recordset& csv, | ||||
|                                                    const int conai_specie, const TString& conai_codart) const | ||||
|                                                    const TCONAI_class conai_specie, const TString& conai_codart) const | ||||
| { | ||||
|   //scopre se il doc e' una NAC
 | ||||
|   const bool is_nac = doc.is_nota_credito(); | ||||
| @ -270,7 +264,7 @@ void TDichiarazione_CONAI::scrivi_csv_doc_speciale(TDocumento& doc, TDichiarazio | ||||
|     const TRiga_documento& rdoc = doc[i]; | ||||
| 
 | ||||
|     //se non e' stata definita la sottocategoria conai (maiali!!) va messa uguale a quella generica
 | ||||
|     TString4 sottocat = rdoc.get(get_conai_sottocat_name(conai_specie)); | ||||
|     TString4 sottocat = rdoc.get(conai_sottocat_name(conai_specie)); | ||||
|     //puo' capitare che la sottocategoria sia stata troncata alla categoria
 | ||||
|     if (sottocat.len() == 2) | ||||
|       sottocat << "99"; | ||||
| @ -309,13 +303,13 @@ void TDichiarazione_CONAI::scrivi_csv_doc_speciale(TDocumento& doc, TDichiarazio | ||||
|     csv.set(15, TVariant(qta_tot_conai)); | ||||
| 
 | ||||
|     //percentuale di esenzione conai al 100%?
 | ||||
|     const real rdoc_perc_conai = rdoc.get_real(RDOC_QTAGG2); | ||||
|     const real rdoc_perc_conai = rdoc.get_real(conai_esenzione_name(conai_specie, LF_RIGHEDOC)); // ex QTAGG2
 | ||||
| 
 | ||||
|     //quantita' assoggettata (B) sul report (le NAC hanno segno rovesciato, ma avendolo gia' gia' rovesciato..
 | ||||
| 		//..in precedenza non deve fare nulla!)
 | ||||
|     real qta_assoggettata_conai = qta_tot_conai; | ||||
| 
 | ||||
|     if (rdoc_perc_conai == CENTO) | ||||
|     if (rdoc_perc_conai >= CENTO) // Guy: Mi pare strano gestire solo il caso 100%
 | ||||
|       qta_assoggettata_conai = ZERO; | ||||
| 
 | ||||
|     csv.set(13, TVariant(qta_assoggettata_conai)); | ||||
| @ -328,7 +322,7 @@ void TDichiarazione_CONAI::scrivi_csv_doc_speciale(TDocumento& doc, TDichiarazio | ||||
|     const real totale_contrib_conai = qta_assoggettata_conai * prezzo; | ||||
|     csv.set(14, TVariant(totale_contrib_conai)); | ||||
| 
 | ||||
|     //percentuale di esenzione conai in qtagg2
 | ||||
|     //percentuale di esenzione conai
 | ||||
|     csv.set(16, TVariant(rdoc_perc_conai)); | ||||
| 
 | ||||
|     //percentuale di esenzione conai in cfven
 | ||||
| @ -340,7 +334,7 @@ void TDichiarazione_CONAI::scrivi_csv_doc_speciale(TDocumento& doc, TDichiarazio | ||||
| //crea il documento che contiene la riga che gli viene passata,cerca la riga generata ed in base al risultato della ricerca chiama..
 | ||||
| //..il metodo adatto
 | ||||
| void TDichiarazione_CONAI::scrivi_csv(const TRectype& prima_riga, TDichiarazione_CONAI_csv_recordset& csv,  | ||||
|                                       const int conai_specie, const TString& conai_codart) const | ||||
|                                       const TCONAI_class conai_specie, const TString& conai_codart) const | ||||
| { | ||||
|   //crea la testata delle righedoc per poter fare vari calcoli (e intanto il tempo se ne va...)
 | ||||
|   const int anno = prima_riga.get_int(RDOC_ANNO); | ||||
| @ -479,35 +473,35 @@ void TDichiarazione_CONAI::elabora(const TMask& mask) const | ||||
|   } | ||||
|    | ||||
|   //Adesso tocca al codice articolo in base alla specie CONAI
 | ||||
|   const int conai_specie = mask.get_int(F_SPECIECONAI); | ||||
|   const TCONAI_class conai_specie = (TCONAI_class)mask.get_int(F_SPECIECONAI); | ||||
|   TConfig ditta_ini(CONFIG_DITTA, "ve"); | ||||
| 
 | ||||
|   TVariant codart; | ||||
|   TString nome_report;    //report di tipo 6.1 scelto in base alla specie conai
 | ||||
|   const char* nome_report = "";       //report di tipo 6.1 scelto in base alla specie conai
 | ||||
| 
 | ||||
|   switch (conai_specie) | ||||
|   { | ||||
|   case 0: | ||||
|   case CONAI_ACC: | ||||
|     codart = ditta_ini.get("CODACC"); //acciaio
 | ||||
|     nome_report = "tp0900ac.rep"; | ||||
|     break; | ||||
|   case 1: | ||||
|   case CONAI_ALL: | ||||
|     codart = ditta_ini.get("CODALL"); //alluminio
 | ||||
|     nome_report = "tp0900al.rep"; | ||||
|     break; | ||||
|   case 2: | ||||
|   case CONAI_CAR: | ||||
|     codart = ditta_ini.get("CODCAR"); //carta
 | ||||
|     nome_report = "tp0900ca.rep"; | ||||
|     break; | ||||
|   case 3: | ||||
|   case CONAI_PLA: | ||||
|     codart = ditta_ini.get("CODPLA"); //plastica
 | ||||
|     nome_report = "tp0900pl.rep"; | ||||
|     break; | ||||
|   case 4: | ||||
|   case CONAI_LEG: | ||||
|     codart = ditta_ini.get("CODLEG"); //legno
 | ||||
|     nome_report = "tp0900le.rep"; | ||||
|     break; | ||||
|   case 5: | ||||
|   case CONAI_VET: | ||||
|     codart = ditta_ini.get("CODVET"); //vetro
 | ||||
|     nome_report = "tp0900ve.rep"; | ||||
|     break; | ||||
| @ -543,7 +537,7 @@ void TDichiarazione_CONAI::elabora(const TMask& mask) const | ||||
|   //cerca le righe con numerazione e tipo indicate nello sheet;prende sia le righe che generano CONAI (per avere il codice conai,..
 | ||||
|   //..le quantita' etc) e le righe generate da CONAI (per avere i prezzi)
 | ||||
|   TString query; | ||||
| 	TString scat_fieldname(get_conai_sottocat_name(conai_specie)); | ||||
| 	TString scat_fieldname(conai_sottocat_name(conai_specie)); | ||||
| 
 | ||||
| 	if (scat_fieldname.blank()) | ||||
| 		return; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user