Merge branch 'R_10_00' of http://10.65.20.33/sirio/CAMPO/campo into R_10_00
This commit is contained in:
		
						commit
						20f951ae3e
					
				| @ -191,6 +191,7 @@ protected: | ||||
|   void sync_generici (const TDate& dal , const TDate& al) { sync_mov(4, dal, al);} | ||||
|   void sync_clifo    (int cfmask, const TDate& dal, const TDate& al); | ||||
|   void sync_listino  (const TString& listino); | ||||
|   void sync_fatbol(const TDate& dal, const TDate& al); | ||||
|    | ||||
| public: | ||||
|   virtual bool create(); | ||||
| @ -1408,6 +1409,170 @@ void TBeeStore_sync::sync_corrisp(const TDate&, const TDate&) | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| void TBeeStore_sync::sync_fatbol(const TDate& dal, const TDate& al) | ||||
| { | ||||
| 	 | ||||
| 	const TString8 codcausdef = ini_get_string(CONFIG_DITTA, "bs", MOVMAG_CODCAUS, "", 2); | ||||
|     /*
 | ||||
| 	if (codcausdef.blank()) | ||||
| 	{ | ||||
| 		_log->log(2, "Configurare parametri per movimenti Bee Store"); | ||||
| 		return; | ||||
| 	} | ||||
| 	*/ | ||||
| 
 | ||||
| 	TString str(255); | ||||
| 	str << "SELECT tieDMovMag.*,tieTBolFat.* FROM tieDMovMag,tieTBolFat WHERE tieDMovMag.Origine=1 AND tieDMovMag.TipoTestata=2 AND tieDMovMag.CodTestata=tieTBolFat.Cod_PK"; // verificare
 | ||||
| 	if (dal.ok() || al.ok()) | ||||
| 	{ | ||||
| 		str << " AND DataMov"; | ||||
| 		if (dal.ok() && al.ok()) | ||||
| 			str << " BETWEEN " << date2sql(dal) << " AND " << date2sql(al); | ||||
| 		else | ||||
| 		{ | ||||
| 			if (dal.ok()) | ||||
| 				str << ">=" << date2sql(dal); | ||||
| 			else | ||||
| 				str << "<=" << date2sql(al); | ||||
| 		} | ||||
| 	} | ||||
| 	str << "\nORDER BY NumMov,NumRiga"; | ||||
| 
 | ||||
| 	TODBC_recordset docs(str); | ||||
| 	docs.connect(_dsn, _usr, _psw); | ||||
| 	TProgress_monitor pi(docs.items(), str); | ||||
| 
 | ||||
| 	long num_doc = -1, nd, codcf; | ||||
| 	TString test_doc = "", test_nd; | ||||
| 	TString4 tipocf; | ||||
| 	TDocumento* doc = nullptr; | ||||
| 	int contatore = 0; | ||||
| 	for (bool ok = docs.move_first(); ok; ok = docs.move_next()) | ||||
| 	{ | ||||
| 		TToken_string test(docs.get("CodTestata").as_string(), '\\'); | ||||
| 
 | ||||
| 		test_nd = (docs.get("CodTestata").as_string()); | ||||
| 
 | ||||
| 		nd = atol(test.get()); | ||||
| 		TString wrk = docs.get("CodCliente").as_string(); | ||||
| 
 | ||||
| 		while (wrk[0] >= 'A') | ||||
| 			wrk.ltrim(1); | ||||
| 
 | ||||
| 		codcf = atol(wrk); | ||||
| 		tipocf = docs.get("TipoIntestatario").as_string(); | ||||
| 		if (tipocf != "C") // verificare
 | ||||
| 			tipocf = "F"; | ||||
| 
 | ||||
| 		if (test_nd != test_doc) | ||||
| 			// if (nd != num_doc)
 | ||||
| 		{ | ||||
| 			if (num_doc > 0 && !save_and_delete_doc(doc)) | ||||
| 				break; | ||||
| 			/*
 | ||||
| 			if (test_doc != "") | ||||
| 				if (test_doc != test_nd) | ||||
| 					save_and_delete_doc(doc); | ||||
| 	  */ | ||||
| 			num_doc = nd; | ||||
| 			test_doc = test_nd; | ||||
| 
 | ||||
| 			TString tre = test_doc.right(3); | ||||
| 			const TDate datadoc = docs.get("DataMov").as_date(); | ||||
| 			TString8 numdoc = docs.get("TipoDocCE").as_string(); | ||||
| 			TString8 tipodoc = docs.get("TipoDocCE").as_string(); | ||||
| 			TString origine_dc = docs.get("Origine").as_string(); | ||||
| 			TTipo_documento tipo(tipodoc); | ||||
| 			const TString8 codcaus = tipo.caus_mov().blank() ? codcausdef : tipo.caus_mov(); | ||||
| 
 | ||||
| 			//doc = new TDocumento('D', datadoc.year(), numdoc, nd); //meglio usare TDocumento(char provv, int anno, const char* codnum, long numdoc);
 | ||||
| 			doc = new TDocumento('D', datadoc.year(), numdoc, strtol(tre, nullptr, 0)); | ||||
| 
 | ||||
| 			doc->put(DOC_DATADOC, datadoc); | ||||
| 			doc->put(DOC_TIPODOC, tipodoc); | ||||
| 			doc->put(DOC_TIPOCF, tipocf); | ||||
| 			doc->put(DOC_CODCF, codcf); | ||||
| 			doc->cli2doc(); | ||||
| 
 | ||||
| 			const TString8 codval = docs.get("CodValuta").as_string(); | ||||
| 			const real cambio = docs.get("CambioValuta").as_real(); | ||||
| 			const TString asp = docs.get("AspettoBeni").as_string(); | ||||
| 			const int ncolli = docs.get("NumeroColli").as_int(); | ||||
| 
 | ||||
| 			doc->put(DOC_CODVAL, codval); | ||||
| 			doc->put(DOC_CAMBIO, cambio); | ||||
| 			doc->put(DOC_ASPBENI1, asp.sleft(50)); | ||||
| 			doc->put(DOC_ASPBENI2, asp.smid(50)); | ||||
| 			doc->put(DOC_NCOLLI, ncolli); | ||||
| 			doc->put(DOC_CAUSMAG, codcaus); | ||||
| 			contatore++; | ||||
| 		} | ||||
| 		const int tipoart = docs.get("TipoArticolo").as_int(); | ||||
| 		TString4 tiporiga = tipoart == 2 ? "04" : "02"; | ||||
| 		TRectype& rdoc = doc->new_row("01"); | ||||
| 		const TString80 codart = docs.get("CodArticolo").as_string(); | ||||
| 
 | ||||
| 		rdoc.put(RDOC_CODART, codart); | ||||
| 		if (tipoart == 2) | ||||
| 		{ | ||||
| 			if (cache().get("SPP", codart).not_empty()) | ||||
| 				rdoc.put(RDOC_CODARTMAG, codart); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			if (cache().get(LF_ANAMAG, codart).not_empty()) | ||||
| 				rdoc.put(RDOC_CODARTMAG, codart); | ||||
| 		} | ||||
| 
 | ||||
| 		rdoc.put(RDOC_CODARTMAG, codart); | ||||
| 		//rdoc.check_row();
 | ||||
| 
 | ||||
| 		const TString descr = docs.get("DSRiga").as_string(); | ||||
| 		rdoc.put(RDOC_DESCR, descr.sleft(50)); | ||||
| 		if (descr.len() > 50) | ||||
| 		{ | ||||
| 			rdoc.put(RDOC_DESCLUNGA, "X"); | ||||
| 			rdoc.put(RDOC_DESCEST, descr.smid(50)); | ||||
| 		} | ||||
| 		rdoc.put(RDOC_CODMAG, docs.get("CodMagazzino").as_string().left(5)); | ||||
| 		rdoc.put(RDOC_CODMAGC, docs.get("CodMagazDest").as_string().left(5)); | ||||
| 		rdoc.put(RDOC_UMQTA, docs.get("CodUntMis").as_string()); | ||||
| 		rdoc.put(RDOC_QTA, docs.get("Quantita").as_real()); | ||||
| 		rdoc.put(RDOC_PREZZO, docs.get("PrzNettoSede").as_real()); // o PrzNettoValuta ??
 | ||||
| 
 | ||||
| 		real valsconto1(docs.get("Sconto1").as_real()); | ||||
| 		real valsconto2(docs.get("Sconto2").as_real()); | ||||
| 		real valsconto3(docs.get("Sconto3").as_real()); | ||||
| 		TString80 sconto; | ||||
| 
 | ||||
| 		if (valsconto1 != ZERO) | ||||
| 			sconto << valsconto1.stringa(6, 2); | ||||
| 		if (valsconto2 != ZERO) | ||||
| 		{ | ||||
| 			if (sconto.full()) | ||||
| 				sconto << "+"; | ||||
| 			sconto << valsconto2.stringa(6, 2); | ||||
| 		} | ||||
| 		if (valsconto3 != ZERO) | ||||
| 		{ | ||||
| 			if (sconto.full()) | ||||
| 				sconto << "+"; | ||||
| 			sconto << valsconto3.stringa(6, 2); | ||||
| 		} | ||||
| 		rdoc.put(RDOC_SCONTO, sconto); | ||||
| 		rdoc.put(RDOC_CODIVA, docs.get("CodIva").as_string()); | ||||
| 
 | ||||
| 		if (!pi.add_status()) | ||||
| 			break; | ||||
| 
 | ||||
| 
 | ||||
| 	} | ||||
| 	save_and_delete_doc(doc);  // Salva ultimo documento in sospeso
 | ||||
| 	str.cut(0); | ||||
| 	str.format(TR("Documenti importati %ld record in %s"), contatore, "tieTBolFat"); | ||||
| 	_log->log(0, ""); | ||||
| 	_log->log(0, str); | ||||
| } | ||||
| 
 | ||||
| bool TBeeStore_sync::create() | ||||
| { | ||||
| @ -1481,6 +1646,8 @@ void TBeeStore_sync::main_loop() | ||||
|       sync_carscar(dal, al); | ||||
|     if (mask.get_bool("SyncGenerici")) | ||||
|       sync_generici(dal, al); | ||||
| 	if (mask.get_bool("SyncFatBol")) | ||||
| 		sync_fatbol(dal, al); | ||||
| 
 | ||||
|     _log->preview(); | ||||
|     delete _log; | ||||
|  | ||||
| @ -20,6 +20,8 @@ | ||||
| #define F_BBDAL           121 | ||||
| #define F_BBAL            122 | ||||
| #define F_FATBOL          123 | ||||
| #define F_FFDAL           124 | ||||
| #define F_FFAL            125 | ||||
| 
 | ||||
| #define F_C_CARSCAR       201 | ||||
| #define F_D_CARSCAR       202 | ||||
|  | ||||
| @ -132,37 +132,49 @@ END | ||||
| 
 | ||||
| ENDPAGE | ||||
| 
 | ||||
| PAGE "newpage_Boll_Fatt_Scontrini" 0 2 0 0 | ||||
| PAGE "BeeStore Import:Fatt/Boll/Scon" 0 2 0 0 | ||||
| 
 | ||||
| GROUPBOX DLG_NULL 78 5 | ||||
| GROUPBOX DLG_NULL 78 4 | ||||
| BEGIN | ||||
|   PROMPT 1 1 "@bBolle" | ||||
| END | ||||
| 
 | ||||
| DATE F_BBDAL | ||||
| BEGIN | ||||
|   PROMPT 2 4 "Dalla data di modifica " | ||||
|   FIELD SyncDateFrom | ||||
|   PROMPT 2 3 "Dalla data di modifica " | ||||
|   FIELD SyncDateFromB | ||||
| END | ||||
| 
 | ||||
| DATE F_BBAL | ||||
| BEGIN | ||||
|   PROMPT 42 4 " al " | ||||
|   FIELD SyncDateTo | ||||
|   PROMPT 42 3 " al " | ||||
|   FIELD SyncDateToB | ||||
| END | ||||
| 
 | ||||
| BOOLEAN F_FATBOL | ||||
| BEGIN | ||||
|   PROMPT 2 9 "FATT/BOLL" | ||||
|   PROMPT 2 7 "Importa da BeeStore le Fatture" | ||||
|   FIELD SyncFatBol | ||||
| END | ||||
| 
 | ||||
| GROUPBOX DLG_NULL 78 5 | ||||
| DATE F_FFDAL | ||||
| BEGIN | ||||
|   PROMPT 2 8 "Dalla data di modifica " | ||||
|   FIELD SyncDateFromF | ||||
| END | ||||
| 
 | ||||
| DATE F_FFAL | ||||
| BEGIN | ||||
|   PROMPT 42 8 " al " | ||||
|   FIELD SyncDateToF | ||||
| END | ||||
| 
 | ||||
| GROUPBOX DLG_NULL 78 4 | ||||
| BEGIN | ||||
|   PROMPT 1 6 "@bFatture" | ||||
| END | ||||
| 
 | ||||
| GROUPBOX DLG_NULL 78 5 | ||||
| GROUPBOX DLG_NULL 78 4 | ||||
| BEGIN | ||||
|   PROMPT 1 11 "@bOrdini" | ||||
| END | ||||
|  | ||||
| @ -5,7 +5,7 @@ Module  = bs | ||||
| Flags   = "F" | ||||
| Item_01 = "Configurazione",   "bs0 -0", "F", 9015 | ||||
| Item_02 = "Sincronizzazione", "bs0 -1", "F", 9015 | ||||
| Item_02 = "newpage", "bs0 -1", "F", 9015 | ||||
| Item_02 = "BeeStore Importazione Fatture", "bs0 -1", "F", 9015 | ||||
| Item_02 = "SKNET Importer", "bs0 -2", "F", 9015 | ||||
| Item_03 = "Tabelle di conversione", [BSMENU_002] | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user