PageRenderTime 68ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 1ms

/Interfaz/MSSInterfazRecaudacion/MSSCargarClientes/ManejadorEconnect.cs

https://github.com/dyland30/interfaz_covi
C# | 1470 lines | 961 code | 235 blank | 274 comment | 83 complexity | c33632a8c33e9576297136268b26f508 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Microsoft.Dynamics.GP.eConnect;
  6. using System.Xml;
  7. using Microsoft.Dynamics.GP.eConnect.Serialization;
  8. using System.Xml.Serialization;
  9. using System.IO;
  10. using System.Globalization;
  11. using System.Configuration;
  12. using MSSCargarClientes.BE;
  13. using MSSCargarClientes.BL;
  14. namespace MSSCargarClientes
  15. {
  16. public static class ManejadorEconnect
  17. {
  18. static string sDocumento;
  19. static string sConnectionString;
  20. static string EconnectConnectionString = ConfigurationManager.ConnectionStrings["CadenaConexionGP"].ConnectionString;
  21. static string EconnectDateFormat = ConfigurationManager.AppSettings.Get("FormatoFechaEconnect").ToString();
  22. static String tipoDocTicketFactura = ConfigurationManager.AppSettings.Get("tip_doc_ticket_factura");
  23. static String tipoDocTicketBoleta = ConfigurationManager.AppSettings.Get("tip_doc_ticket_boleta");
  24. static string tipDocFacturaManual = ConfigurationManager.AppSettings.Get("tip_doc_factura_manual");
  25. static string tipDocBoletaManual = ConfigurationManager.AppSettings.Get("tip_doc_boleta_manual");
  26. static string tipoDocSobrantes = ConfigurationManager.AppSettings.Get("idTipDocSobrantes");
  27. static string tipoDocDiscrepancias = ConfigurationManager.AppSettings.Get("idTipDocDiscrepancias");
  28. static string tipoDocBoletaSobrantes = ConfigurationManager.AppSettings.Get("idTipDocBoletaDiscrepancias");
  29. static string tipoDocBoletaDiscrepancias = ConfigurationManager.AppSettings.Get("idTipDocBoletaSobrantes");
  30. static string tipoDocumentoVenta = ConfigurationManager.AppSettings.Get("tip_doc_venta");
  31. static string tipoDocumentoDetraccion = ConfigurationManager.AppSettings.Get("tip_doc_detraccion");
  32. static Int32 Jrnentry = 0;
  33. static string tipoDocConsumoVale = ConfigurationManager.AppSettings.Get("consumoVale");
  34. static string tipoDocConsumoTelepass = ConfigurationManager.AppSettings.Get("consumoTelepass");
  35. static CultureInfo culturaInvariante = CultureInfo.InvariantCulture;
  36. static List<DetalleVentaBE> listaDetracciones = new List<DetalleVentaBE>();
  37. static string nroArticulo;
  38. static string nroDocDetraccion;
  39. static string nroPago;
  40. static string SopNum;
  41. static string nroDocVenta;
  42. static string codDestinoOperacion="";
  43. static string numero_vale_tag="";
  44. static string placa = "";
  45. public static string enviarClientesGP(List<ClienteBE> listaClientes, string idUsuario)
  46. {
  47. int ok = 0;
  48. int err = 0;
  49. foreach (ClienteBE cli in listaClientes)
  50. {
  51. using (eConnectMethods e = new eConnectMethods())
  52. {
  53. try
  54. {
  55. //crear archivo xml
  56. sDocumento = SerializarCliente(cli);
  57. // asignar cadena de conexion
  58. sConnectionString = EconnectConnectionString;
  59. e.CreateEntity(sConnectionString, sDocumento);
  60. ClienteBL.insertarClienteGP(cli, idUsuario);
  61. // obtener cliente de la tabla intermedia para actualizarlo
  62. ClienteBL.modificarEstadoCliente(cli.IdCliente, "P", "");
  63. ok++;
  64. }
  65. catch (eConnectException ex)
  66. {
  67. // establecer error en cada cliente
  68. ClienteBL.modificarEstadoCliente(cli.IdCliente, "E", ex.Message);
  69. err++;
  70. }
  71. catch (Exception ex)
  72. {
  73. // establecer error en cada cliente
  74. ClienteBL.modificarEstadoCliente(cli.IdCliente, "E", ex.Message);
  75. err++;
  76. }
  77. }
  78. }
  79. return "Se han enviado " + ok.ToString() + " registros, se han encontrado " + err.ToString() + " errores ";
  80. }
  81. public static string SerializarCliente(ClienteBE client)
  82. {
  83. string cadenaXML = "";
  84. try
  85. {
  86. // Instantiate an eConnectType schema object
  87. eConnectType eConnect = new eConnectType();
  88. // Instantiate a RMCustomerMasterType schema object
  89. RMCustomerMasterType customertype = new RMCustomerMasterType();
  90. // Instantiate a taUpdateCreateCustomerRcd XML node object
  91. taUpdateCreateCustomerRcd customer = new taUpdateCreateCustomerRcd();
  92. // Create an XML serializer object
  93. XmlSerializer serializer = new XmlSerializer(eConnect.GetType());
  94. // Populate elements of the taUpdateCreateCustomerRcd XML node object
  95. customer.CUSTNMBR = client.IdCliente;
  96. customer.CUSTNAME = client.NomCliente;
  97. customer.SHRTNAME = client.NombreCorto;
  98. customer.ADDRESS1 = client.Direccion;
  99. customer.ADRSCODE = ConfigurationManager.AppSettings.Get("idDireccion");
  100. //customer.CITY = ;
  101. //customer.ZIPCODE = client.codigozip;
  102. // crear stored procedure para cargar los demas datos
  103. customer.CUSTCLAS = ConfigurationManager.AppSettings.Get("claseCliente");
  104. //obtener clase de cliente
  105. ClaseClienteBE claseCliente = ClaseClienteBL.obtenerClaseCliente(customer.CUSTCLAS);
  106. // llenar los parametros de la clase de cliente
  107. customer.TAXSCHID = claseCliente.PlanImpuestos;
  108. customer.SHIPMTHD = claseCliente.MetodoEnvio;
  109. customer.PYMTRMID = claseCliente.CondicionPago;
  110. customer.CURNCYID = claseCliente.IdMoneda;
  111. customer.RMCSHACTNUMST = claseCliente.CuentaEfectivo;
  112. customer.RMARACTNUMST = claseCliente.CuentaxCobrar;
  113. customer.RMSLSACTNUMST = claseCliente.CuentaVentas;
  114. customer.RMCOSACTNUMST = claseCliente.CuentaCostoVenta;
  115. customer.RMIVACTNUMST = claseCliente.CuentaInventario;
  116. customer.RMTAKACTNUMST = claseCliente.CuentaCondicionesDtosTomados;
  117. customer.RMAVACTNUMST = claseCliente.CuentaCondicionesDtosDisponibles;
  118. customer.RMFCGACTNUMST = claseCliente.CuentaCargosFinancieros;
  119. customer.RMSORACTNUMST = claseCliente.CuentaDevolucionesPedidosVenta;
  120. customer.RMWRACTNUMST = claseCliente.CuentaCancelaciones;
  121. customer.RMOvrpymtWrtoffACTNUMST = claseCliente.CuentaCancelacionesSobrepago;
  122. customer.SLPRSNID = claseCliente.IdVendedor;
  123. customer.SALSTERR = claseCliente.IdTerritorio;
  124. customer.STMTCYCL = claseCliente.CicloEstado;
  125. // Populate the RMCustomerMasterType schema with the taUpdateCreateCustomerRcd XML node
  126. customertype.taUpdateCreateCustomerRcd = customer;
  127. RMCustomerMasterType[] mySMCustomerMaster = { customertype };
  128. // Populate the eConnectType object with the RMCustomerMasterType schema object
  129. eConnect.RMCustomerMasterType = mySMCustomerMaster;
  130. MemoryStream xmlMemoria = new MemoryStream();
  131. serializer.Serialize(xmlMemoria, eConnect);
  132. XmlDocument xmlDoc = new XmlDocument();
  133. xmlMemoria.Position = 0;
  134. xmlDoc.Load(xmlMemoria);
  135. xmlMemoria.Close();
  136. cadenaXML = xmlDoc.OuterXml;
  137. }
  138. // catch any errors that occur and display them to the console
  139. catch (System.Exception ex)
  140. {
  141. Console.Write(ex.ToString());
  142. }
  143. return cadenaXML;
  144. }
  145. public static string enviarDocumentosVentaGP(List<CabeceraVentaBE> listaCabeceras, string nroLote, string codEstacion, string turno)
  146. {
  147. int ok = 0;
  148. int err = 0;
  149. listaDetracciones = new List<DetalleVentaBE>();
  150. foreach (CabeceraVentaBE cabeceraDoc in listaCabeceras)
  151. {
  152. using (eConnectMethods e = new eConnectMethods())
  153. {
  154. try
  155. {
  156. // inicializar entrada de diario en 0
  157. Jrnentry = 0;
  158. //crear archivo xml
  159. // determinar de que caso se trata,
  160. if (cabeceraDoc.TipDoc.Equals(tipoDocTicketFactura) || cabeceraDoc.TipDoc.Equals(tipoDocTicketBoleta)
  161. || cabeceraDoc.TipDoc.Equals(tipDocFacturaManual) || cabeceraDoc.TipDoc.Equals(tipDocBoletaManual) )
  162. {
  163. // tickets boleta y tickets factura pagados
  164. sDocumento = SerializarTicket(cabeceraDoc, nroLote);
  165. }
  166. if (cabeceraDoc.TipDoc.Equals(tipoDocSobrantes) || cabeceraDoc.TipDoc.Equals(tipoDocBoletaSobrantes))
  167. {
  168. // serializar sobrantes
  169. sDocumento = SerializarSobrantes(cabeceraDoc, nroLote);
  170. }
  171. if (cabeceraDoc.TipDoc.Equals(tipoDocDiscrepancias) || cabeceraDoc.TipDoc.Equals(tipoDocBoletaDiscrepancias))
  172. {
  173. // serializar discrepancias
  174. sDocumento = SerializarDiscrepancias(cabeceraDoc,nroLote);
  175. }
  176. if (cabeceraDoc.TipDoc.ToUpper().Equals(tipoDocConsumoVale))
  177. {
  178. // consumo de vales
  179. // sDocumento = SerializarConsumoVale(cabeceraDoc, nroLote);
  180. enviarConsumosVale(cabeceraDoc, nroLote);
  181. }
  182. else if (cabeceraDoc.TipDoc.ToUpper().Equals(tipoDocConsumoTelepass))
  183. {
  184. // consumo de telepass
  185. //sDocumento = SerializarConsumoTelepass(cabeceraDoc, nroLote);
  186. enviarConsumosTelepass(cabeceraDoc, nroLote);
  187. }
  188. // asignar cadena de conexion
  189. sConnectionString = EconnectConnectionString;
  190. if (!cabeceraDoc.TipDoc.ToUpper().Equals(tipoDocConsumoVale) && !cabeceraDoc.TipDoc.ToUpper().Equals(tipoDocConsumoTelepass))
  191. {
  192. e.CreateTransactionEntity(sConnectionString, sDocumento);
  193. }
  194. // obtener los detalles de la tabla intermedia para actualizarlo
  195. if (cabeceraDoc.TipDoc.Equals(tipoDocTicketFactura) || cabeceraDoc.TipDoc.Equals(tipoDocTicketBoleta)
  196. || cabeceraDoc.TipDoc.Equals(tipoDocDiscrepancias) || cabeceraDoc.TipDoc.Equals(tipoDocSobrantes)
  197. || cabeceraDoc.TipDoc.Equals(tipDocFacturaManual) || cabeceraDoc.TipDoc.Equals(tipDocBoletaManual)
  198. || cabeceraDoc.TipDoc.Equals(tipoDocBoletaDiscrepancias) || cabeceraDoc.TipDoc.Equals(tipoDocBoletaSobrantes))
  199. {
  200. //almacenar en variable temporal
  201. string nroDocAux = cabeceraDoc.NroDoc;
  202. cabeceraDoc.NroDoc = nroDocVenta;
  203. // tickets boleta y tickets factura pagados
  204. CabeceraVentaBL.crearDistribucionesCliente(cabeceraDoc);
  205. // guardar valores definidos por el usuario
  206. CabeceraVentaBL.InsertarValoresDefinidosUsuario(3, SopNum, cabeceraDoc.FecProceso.Value, "", "", cabeceraDoc.Turno, cabeceraDoc.CodEstacion, "");
  207. CabeceraVentaBL.InsertarFechaProcesoVentanaPago(ConfigurationManager.AppSettings.Get("ExtPagoVentaWindowID"), SopNum, nroPago, 1, cabeceraDoc.FecProceso.Value);
  208. // insertar fecha de proceso en el lote de venta
  209. CabeceraVentaBL.InsertarFechaProcesoLote(cabeceraDoc.FecProceso.Value, nroLote, ConfigurationManager.AppSettings.Get("OrigenLoteVenta"));
  210. // insertar datos tributarios
  211. string serie=cabeceraDoc.TipDoc.Trim()+cabeceraDoc.SerieDoc.Trim();
  212. if (cabeceraDoc.TipDoc.Equals(tipoDocTicketFactura) || cabeceraDoc.TipDoc.Equals(tipoDocTicketBoleta))
  213. {
  214. serie = cabeceraDoc.TipDoc.Trim() + "-" + cabeceraDoc.SerieDoc.Trim();
  215. }
  216. CabeceraVentaBL.InsertarDatosLocalizacion(SopNum,cabeceraDoc.NroDoc,cabeceraDoc.IdCliente,cabeceraDoc.TipoDocSunat,
  217. cabeceraDoc.DestinoOperacion, cabeceraDoc.CodEstacion,serie , cabeceraDoc.Fecdoc.Value, ConfigurationManager.AppSettings.Get("idMoneda"), "sa");
  218. // regresamos el nro de documento original
  219. cabeceraDoc.NroDoc = nroDocAux;
  220. }
  221. // ASIGNAR DISTRIBUCION CONTABLE DE LOS CONSUMOS EN SOP Y RM
  222. if (Jrnentry > 0)
  223. {
  224. string tipoDistribucionDefecto = ConfigurationManager.AppSettings.Get("tipoDistribucionDefecto");
  225. Int16 nroTipoDistribucion = Int16.Parse(tipoDistribucionDefecto);
  226. CabeceraVentaBL.crearDistribucionesSOPRM(Jrnentry, nroTipoDistribucion);
  227. //agregar turno y codigo de estacion
  228. // turno
  229. /*
  230. CabeceraVentaBL.InsertarAdicionalesConsumos(ConfigurationManager.AppSettings.Get("ExtConsumoWindowID"), Jrnentry.ToString(), 1, cabeceraDoc.Turno);
  231. //codigo de estacion
  232. CabeceraVentaBL.InsertarAdicionalesConsumos(ConfigurationManager.AppSettings.Get("ExtConsumoWindowID"), Jrnentry.ToString(), 2, cabeceraDoc.CodEstacion);
  233. CabeceraVentaBL.InsertarAdicionalesConsumos(ConfigurationManager.AppSettings.Get("ExtConsumoWindowID"), Jrnentry.ToString(), 3, nroArticulo);
  234. CabeceraVentaBL.InsertarAdicionalesConsumos(ConfigurationManager.AppSettings.Get("ExtConsumoWindowID"), Jrnentry.ToString(), 4, numero_vale_tag);
  235. CabeceraVentaBL.InsertarAdicionalesConsumos(ConfigurationManager.AppSettings.Get("ExtConsumoWindowID"), Jrnentry.ToString(), 5, placa);
  236. CabeceraVentaBL.InsertarAdicionalesConsumos(ConfigurationManager.AppSettings.Get("ExtConsumoWindowID"), Jrnentry.ToString(), 6, cabeceraDoc.NroDocAsociado);
  237. */
  238. //INSERTAR DATOS EN ADDIN
  239. CabeceraVentaBL.guardarDatosAdicionales(Jrnentry, cabeceraDoc.Turno, cabeceraDoc.CodEstacion, nroArticulo, numero_vale_tag, placa, cabeceraDoc.NroDocAsociado);
  240. // insertar fecha de proceso en el lote de financiero general
  241. CabeceraVentaBL.InsertarFechaProcesoLote(cabeceraDoc.FecProceso.Value, nroLote, ConfigurationManager.AppSettings.Get("OrigenLoteFinGeneral"));
  242. }
  243. List<DetalleVentaBE> detallesEnviados = DetalleVentaBL.obtenerDetalleDocumentos(cabeceraDoc.TipDoc, cabeceraDoc.SerieDoc, cabeceraDoc.NroDoc);
  244. foreach (DetalleVentaBE d in detallesEnviados)
  245. {
  246. // modificar el estado del detalle
  247. // DetalleVentaBL.modificarDetalleDocumento(d.TipDoc, d.Nrodoc, d.Seriedoc, d.Codarticulo, "P", nroLote, "", Jrnentry);
  248. //para debug
  249. DetalleVentaBL.modificarDetalleDocumento(d.TipDoc, d.Nrodoc, d.Seriedoc, d.Codarticulo, "P", nroLote, "", Jrnentry);
  250. }
  251. ok++;
  252. }
  253. catch (eConnectException exp)
  254. {
  255. // capturar error de econect
  256. List<DetalleVentaBE> detallesEnviados = DetalleVentaBL.obtenerDetalleDocumentos(cabeceraDoc.TipDoc, cabeceraDoc.SerieDoc, cabeceraDoc.NroDoc);
  257. foreach (DetalleVentaBE d in detallesEnviados)
  258. {
  259. // modificar el estado del detalle
  260. DetalleVentaBL.modificarDetalleDocumento(d.TipDoc, d.Nrodoc, d.Seriedoc, d.Codarticulo, "E", nroLote, exp.Message + exp.StackTrace, Jrnentry);
  261. // Console.Write(exp.Message +" "+exp.StackTrace);
  262. }
  263. err++;
  264. }
  265. catch (Exception ex)
  266. {
  267. // capturar error de econect
  268. List<DetalleVentaBE> detallesEnviados = DetalleVentaBL.obtenerDetalleDocumentos(cabeceraDoc.TipDoc, cabeceraDoc.SerieDoc, cabeceraDoc.NroDoc);
  269. foreach (DetalleVentaBE d in detallesEnviados)
  270. {
  271. // modificar el estado del detalle
  272. DetalleVentaBL.modificarDetalleDocumento(d.TipDoc, d.Nrodoc, d.Seriedoc, d.Codarticulo, "E", nroLote, ex.Message + ex.StackTrace + "", Jrnentry);
  273. // Console.Write(ex.Message + " " + ex.StackTrace);
  274. }
  275. err++;
  276. }
  277. }
  278. }
  279. // VERIFICAR SI HAY DETRACCIONES
  280. // crear funcion serializar detracciones
  281. //eliminar duplicados en caso haya
  282. var listaDet = listaDetracciones.Distinct(new ComparadorDetalleVenta());
  283. listaDetracciones = listaDet.ToList<DetalleVentaBE>();
  284. if (listaDetracciones.Count > 0)
  285. {
  286. // almacenar en el historico todas las detracciones generadas
  287. // y guardar su estado para poder verificar si se han enviado correctamente
  288. foreach (DetalleVentaBE det in listaDetracciones)
  289. {
  290. try
  291. {
  292. eConnectMethods e = new eConnectMethods();
  293. nroDocDetraccion = "";
  294. string docDetraccion;
  295. docDetraccion = SerializarDetraccion(det, nroLote);
  296. e.CreateTransactionEntity(EconnectConnectionString, docDetraccion);
  297. // guardar detraccion en tabla detalle con estado P
  298. det.Estado = "P";
  299. det.Observacion = "";
  300. det.Nrodoc = nroDocDetraccion;
  301. DetalleVentaBL.insertarDetalleDocumento(det);
  302. // crear distribucion contable cliente
  303. CabeceraVentaBE cab = new CabeceraVentaBE();
  304. cab.NroDoc = det.Nrodoc;
  305. cab.NomCliente = ConfigurationManager.AppSettings.Get("clienteDetraccion");
  306. cab.IdCliente = ConfigurationManager.AppSettings.Get("clienteDetraccion");
  307. cab.Turno = det.Turno;
  308. cab.CodEstacion = det.Codestacion;
  309. cab.FecProceso = det.FecProceso;
  310. cab.TipoDocSunat = ConfigurationManager.AppSettings.Get("DOC_TRIBUTARIO_DETRACCION");
  311. cab.DestinoOperacion = ConfigurationManager.AppSettings.Get("DETRACCION_DESTINO_OPERACION");
  312. cab.SerieDoc = det.Seriedetraccion + det.Seriecaseta;
  313. CabeceraVentaBL.crearDistribucionesCliente(cab);
  314. CabeceraVentaBL.InsertarValoresDefinidosUsuario(3, nroDocDetraccion, cab.FecProceso.Value, "", "", cab.Turno, cab.CodEstacion, det.Nrodocasociado);
  315. CabeceraVentaBL.InsertarFechaProcesoVentanaPago(ConfigurationManager.AppSettings.Get("ExtPagoVentaWindowID"), det.Nrodoc, nroPago, 1, cab.FecProceso.Value);
  316. // insertar fecha de proceso en el lote de venta de detraccion
  317. CabeceraVentaBL.InsertarFechaProcesoLote(cab.FecProceso.Value, nroLote, ConfigurationManager.AppSettings.Get("OrigenLoteVenta"));
  318. //insertar datos de localizacion para la detraccion
  319. CabeceraVentaBL.InsertarDatosLocalizacion(nroDocDetraccion, det.Nrodetraccion, cab.IdCliente, cab.TipoDocSunat,
  320. cab.DestinoOperacion, cab.CodEstacion,cab.SerieDoc, cab.FecProceso.Value, ConfigurationManager.AppSettings.Get("idMoneda"), "sa");
  321. }
  322. catch (eConnectException exp)
  323. {
  324. // guardar detraccion en tabla detalle_old con estado E y la descripcion del error
  325. det.Estado = "E";
  326. det.Observacion = exp.Message;
  327. DetalleVentaBL.insertarDetalleDocumento(det);
  328. }
  329. catch (Exception ex)
  330. {
  331. // guardar detraccion en tabla detalle_old con estado E y la descripcion del error
  332. //det.Estado = "E";
  333. //det.Observacion = ex.Message;
  334. //DetalleVentaBL.insertarDetalleDocumento(det);
  335. Console.WriteLine(ex.Message);
  336. }
  337. }
  338. }
  339. DetalleVentaBL.almacenarHistorico();
  340. // insertar resumen
  341. ResumenBE resumen = new ResumenBE();
  342. resumen.CodEstacion = codEstacion;
  343. resumen.SerieCaseta = "";
  344. resumen.Turno = turno;
  345. resumen.Errores = err;
  346. resumen.Procesados = ok;
  347. resumen.Lote = nroLote;
  348. ResumenBL.InsertarResumen(resumen);
  349. string mensaje = "Nro Lote " + nroLote + ": Se han enviado " + ok.ToString() + " registros, se han encontrado " + err.ToString() + " errores";
  350. if (err > 0)
  351. {
  352. mensaje = "Nro Lote " + nroLote + ": Se han enviado " + ok.ToString() + " registros, se han encontrado " + err.ToString() + " errores. Revisar el informe de errores";
  353. }
  354. return mensaje;
  355. }
  356. public static string SerializarTicket(CabeceraVentaBE cabeceraDoc, string nroLote)
  357. {
  358. string cadenaXML = "";
  359. String idMoneda = ConfigurationManager.AppSettings.Get("idMoneda");
  360. Int32 cantidadDecimalesMoneda = CompanyGPBE.ObtenerCantidadDecimalesPorMoneda(idMoneda);
  361. try
  362. {
  363. // obtener detalles de cabecera
  364. List<DetalleVentaBE> listaDetalles = DetalleVentaBL.obtenerDetalleDocumentos(cabeceraDoc.TipDoc, cabeceraDoc.SerieDoc, cabeceraDoc.NroDoc);
  365. // crear un array para almacenar las lineas del documento
  366. taSopLineIvcInsert_ItemsTaSopLineIvcInsert[] detallesGP = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert[listaDetalles.Count];
  367. int i = 0;
  368. decimal total = 0;
  369. foreach (DetalleVentaBE det in listaDetalles)
  370. {
  371. // enviar solamente el precio unitario y la cantidad, dejar a gp que haga el calculo
  372. taSopLineIvcInsert_ItemsTaSopLineIvcInsert lineaVenta = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert();
  373. // crear numero de articulo
  374. string codArticulo = det.Codestacion.Trim().ToUpper() + "." + det.Codarticulo.PadLeft(2, '0');
  375. //salesLine.ADDRESS1 = "2345 Main St.";
  376. lineaVenta.CUSTNMBR = det.Idcliente;
  377. lineaVenta.SOPTYPE = 3;
  378. //if (det.TipDoc.Trim().Equals(tipDocBoletaManual) || det.TipDoc.Trim().Equals(tipDocFacturaManual))
  379. //{
  380. // lineaVenta.DOCID = det.TipDoc + det.Seriedoc;
  381. //}
  382. //else {
  383. // lineaVenta.DOCID = det.TipDoc + "-" + det.Seriedoc;
  384. //}
  385. lineaVenta.DOCID = tipoDocumentoVenta;
  386. lineaVenta.ITEMNMBR = codArticulo;
  387. lineaVenta.UOFM = ConfigurationManager.AppSettings.Get("unidad");
  388. lineaVenta.CURNCYID = idMoneda;
  389. // obtener cantidad de decimales de GP
  390. lineaVenta.QUANTITY = Math.Round(det.Cantidad.Value, 0, MidpointRounding.AwayFromZero);
  391. lineaVenta.UNITPRCE = det.Preuni.Value;
  392. lineaVenta.XTNDPRCE = Math.Round(det.Preuni.Value*det.Cantidad.Value, cantidadDecimalesMoneda, MidpointRounding.AwayFromZero);
  393. // el sitio va a ser por cada estacion
  394. // tendra la siguiente nomenclatura
  395. lineaVenta.LOCNCODE = det.Codestacion.Trim().ToUpper();
  396. //NIVEL DE PRECIO
  397. lineaVenta.PRCLEVEL = "PEA." + det.Codestacion.Trim().ToUpper();
  398. lineaVenta.DOCDATE = DarFormatoFecha(det.Fecdoc.Value);
  399. // verificar si tiene detraccion
  400. if (det.TotalDetraccion != null && det.Seriedetraccion != null
  401. && det.Nrodetraccion != null && det.Seriedetraccion.Trim() != String.Empty
  402. && det.Nrodetraccion.Trim() != String.Empty)
  403. {
  404. // tiene detraccion
  405. // crear otra linea de documento para detracciones
  406. DetalleVentaBE detraccion = new DetalleVentaBE();
  407. detraccion.Codarticulo = ConfigurationManager.AppSettings.Get("articuloDetraccion");
  408. detraccion.Nrodetraccion = det.Nrodetraccion;
  409. detraccion.Seriedetraccion = det.Seriedetraccion;
  410. detraccion.Cantidad = 1;
  411. detraccion.Codestacion = det.Codestacion;
  412. detraccion.CodLote = nroLote;
  413. detraccion.Igv = (Decimal)0;
  414. // detraccion.Mtotal = det.TotalDetraccion;
  415. detraccion.Preuni = det.TotalDetraccion;
  416. detraccion.Total = det.TotalDetraccion;
  417. detraccion.TotalDetraccion = det.TotalDetraccion;
  418. detraccion.Idcliente = det.Idcliente;
  419. detraccion.Fecdoc = det.Fecdoc;
  420. detraccion.FecProceso = det.FecProceso;
  421. detraccion.TipDoc = ConfigurationManager.AppSettings.Get("DOC_TRIBUTARIO_DETRACCION"); ;
  422. detraccion.Nrodocasociado = det.Nrodoc;
  423. detraccion.Nrodoc = det.Nrodetraccion;
  424. detraccion.Seriedoc = det.Seriedetraccion;
  425. detraccion.Idcliente = det.Idcliente;
  426. detraccion.Nomcliente = det.Nomcliente;
  427. detraccion.Seriecaseta = det.Seriecaseta;
  428. if (det.Sentido != null && det.Sentido != String.Empty)
  429. detraccion.Sentido = det.Sentido;
  430. else
  431. detraccion.Sentido = "";
  432. if (det.Placa != null && det.Placa != String.Empty)
  433. detraccion.Placa = det.Placa;
  434. else
  435. detraccion.Placa = "";
  436. if (det.Turno != null && det.Turno != String.Empty)
  437. detraccion.Turno = det.Turno;
  438. else
  439. detraccion.Turno = "";
  440. if (det.TipoDocsunat != null && det.TipoDocsunat != String.Empty)
  441. detraccion.TipoDocsunat = det.TipoDocsunat;
  442. else
  443. detraccion.TipoDocsunat = "";
  444. detraccion.CodLote = nroLote;
  445. if (det.FechaVencimientoVale != null)
  446. detraccion.FechaVencimientoVale = det.FechaVencimientoVale;
  447. else
  448. detraccion.FechaVencimientoVale = DateTime.ParseExact(ConfigurationManager.AppSettings.Get("FechaCero"), EconnectDateFormat, culturaInvariante);
  449. if (det.NroTag != null && det.NroTag != String.Empty)
  450. detraccion.NroTag = det.NroTag;
  451. else
  452. detraccion.NroTag = "";
  453. if (det.DestinoOperacion != null && det.DestinoOperacion != String.Empty)
  454. detraccion.DestinoOperacion = det.DestinoOperacion;
  455. else
  456. detraccion.DestinoOperacion = "";
  457. detraccion.NroAsientoCont = 0;
  458. // agregar detraccion a la lista de detracciones
  459. listaDetracciones.Add(detraccion);
  460. }
  461. detallesGP[i] = lineaVenta;
  462. i++;
  463. total += lineaVenta.XTNDPRCE;
  464. }
  465. // se debe agregar la información de los impuestos?
  466. // crear cabecera de documento
  467. taSopHdrIvcInsert salesHdr = new taSopHdrIvcInsert();
  468. salesHdr.CREATEDIST = 1;
  469. salesHdr.SOPTYPE = 3;
  470. //if (cabeceraDoc.TipDoc.Trim().Equals(tipDocBoletaManual) || cabeceraDoc.TipDoc.Trim().Equals(tipDocFacturaManual))
  471. //{
  472. // salesHdr.DOCID = cabeceraDoc.TipDoc + cabeceraDoc.SerieDoc;
  473. //}
  474. //else
  475. //{
  476. // salesHdr.DOCID = cabeceraDoc.TipDoc + "-" + cabeceraDoc.SerieDoc;// de tipo ticket
  477. //}
  478. salesHdr.DOCID = tipoDocumentoVenta;
  479. // obtener número de documento correlativo de gp
  480. GetNextDocNumbers nextDoc = new GetNextDocNumbers();
  481. salesHdr.SOPNUMBE = nextDoc.GetNextSOPNumber(IncrementDecrement.Increment, salesHdr.DOCID, SopType.SOPInvoice, EconnectConnectionString);
  482. //salesHdr.SOPNUMBE = cabeceraDoc.NroDoc; // serie + nro Correlativo
  483. SopNum = salesHdr.SOPNUMBE;
  484. salesHdr.BACHNUMB = nroLote; // numero de lote
  485. salesHdr.LOCNCODE = cabeceraDoc.CodEstacion.Trim().ToUpper(); ;
  486. salesHdr.DOCDATE = DarFormatoFecha(cabeceraDoc.Fecdoc.Value);
  487. salesHdr.CUSTNMBR = cabeceraDoc.IdCliente;
  488. if(cabeceraDoc.NomCliente!=null && cabeceraDoc.NomCliente.Trim()!=String.Empty){
  489. salesHdr.CUSTNAME = cabeceraDoc.NomCliente;
  490. }
  491. salesHdr.CURNCYID = idMoneda;
  492. salesHdr.CREATETAXES = 1;
  493. salesHdr.SUBTOTAL = total;
  494. salesHdr.DOCAMNT = total;
  495. salesHdr.USINGHEADERLEVELTAXES = 0;
  496. //salesHdr.CREATEDIST = 1; //
  497. //AGREGAR MONTO COBRADO
  498. salesHdr.PYMTRCVD = total;
  499. // agregar turno
  500. salesHdr.USRDEFND3 = cabeceraDoc.Turno;
  501. // agregar codigo de estacion
  502. salesHdr.USRDEFND4 = cabeceraDoc.CodEstacion;
  503. // referencia de contabilidad
  504. String str_nro_doc;
  505. if (cabeceraDoc.NroDoc.Trim().Length < 8)
  506. {
  507. str_nro_doc = cabeceraDoc.NroDoc.Trim();
  508. }
  509. else {
  510. str_nro_doc = cabeceraDoc.NroDoc.Trim().Substring(cabeceraDoc.NroDoc.Trim().Length - 8);
  511. }
  512. salesHdr.REFRENCE = cabeceraDoc.SerieDoc + "-" + str_nro_doc + "-" + cabeceraDoc.CodEstacion;
  513. //almacenar nroDocVenta
  514. nroDocVenta = cabeceraDoc.NroDoc;
  515. //salesHdr.PYMTRMID = "Net 30";
  516. /*
  517. sopHdrTrx.SUBTOTAL = Math.Round(facturaBE.SubTotal, cantidadDecimalesPorMoneda, MidpointRounding.AwayFromZero);
  518. sopHdrTrx.TAXAMNT = Math.Round(facturaBE.Impuesto, cantidadDecimalesPorMoneda, MidpointRounding.AwayFromZero);
  519. sopHdrTrx.DOCAMNT = Math.Round(facturaBE.Total, cantidadDecimalesPorMoneda, MidpointRounding.AwayFromZero);
  520. */
  521. var myNextNumber = new GetNextDocNumbers();
  522. //agregar pagos
  523. var pagos = new taCreateSopPaymentInsertRecord_ItemsTaCreateSopPaymentInsertRecord[1];
  524. taCreateSopPaymentInsertRecord_ItemsTaCreateSopPaymentInsertRecord pago = new taCreateSopPaymentInsertRecord_ItemsTaCreateSopPaymentInsertRecord();
  525. pago.SOPTYPE = 3;
  526. pago.SOPNUMBE = salesHdr.SOPNUMBE;
  527. pago.CUSTNMBR = salesHdr.CUSTNMBR;
  528. pago.DOCNUMBR = myNextNumber.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMPayments, EconnectConnectionString);
  529. pago.DOCDATE = salesHdr.DOCDATE;
  530. pago.PYMTTYPE = 4;
  531. pago.DOCAMNT = salesHdr.DOCAMNT;
  532. // crear idChequera
  533. //ASIGNAR VARIABLE NROPAGO
  534. nroPago = pago.DOCNUMBR;
  535. pago.CHEKBKID = cabeceraDoc.CodEstacion.Trim().ToUpper() + "_EF"; ;
  536. // agregar el pago al array de pagos
  537. pagos[0] = pago;
  538. // crear la transaccion de orden de venta
  539. SOPTransactionType OrdenVenta = new SOPTransactionType();
  540. // poblar la orden de venta
  541. // Populate the schema object with the SOP header and SOP line item objects
  542. OrdenVenta.taSopLineIvcInsert_Items = detallesGP;
  543. OrdenVenta.taSopHdrIvcInsert = salesHdr;
  544. OrdenVenta.taCreateSopPaymentInsertRecord_Items = pagos;
  545. // Create an array that holds SOPTransactionType objects
  546. // Populate the array with the SOPTransactionType schema object
  547. SOPTransactionType[] MySopTransactionType = { OrdenVenta };
  548. // Create an eConnect XML document object and populate it
  549. // with the SOPTransactionType schema object
  550. eConnectType eConnect = new eConnectType();
  551. eConnect.SOPTransactionType = MySopTransactionType;
  552. XmlSerializer serializer = new XmlSerializer(eConnect.GetType());
  553. MemoryStream xmlMemoria = new MemoryStream();
  554. serializer.Serialize(xmlMemoria, eConnect);
  555. XmlDocument xmlDoc = new XmlDocument();
  556. xmlMemoria.Position = 0;
  557. xmlDoc.Load(xmlMemoria);
  558. xmlMemoria.Close();
  559. cadenaXML = xmlDoc.OuterXml;
  560. }
  561. catch (eConnectException ex)
  562. {
  563. //notificar de cualquier error de econnect
  564. Console.WriteLine("ERROR " + ex);
  565. }
  566. catch (Exception ex)
  567. {
  568. //notificar de cualquier error de econnect
  569. Console.WriteLine("ERROR " + ex);
  570. }
  571. return cadenaXML;
  572. }
  573. public static string SerializarDetraccion(DetalleVentaBE det, string nroLote)
  574. {
  575. string cadenaXML = "";
  576. String idMoneda = ConfigurationManager.AppSettings.Get("idMoneda");
  577. Int32 cantidadDecimalesMoneda = CompanyGPBE.ObtenerCantidadDecimalesPorMoneda(idMoneda);
  578. try
  579. {
  580. // obtener detalles de cabecera
  581. taSopLineIvcInsert_ItemsTaSopLineIvcInsert[] detallesGP = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert[1];
  582. taSopLineIvcInsert_ItemsTaSopLineIvcInsert lineaVenta = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert();
  583. // crear numero de articulo
  584. string codArticulo = det.Codarticulo;
  585. //salesLine.ADDRESS1 = "2345 Main St.";
  586. lineaVenta.CUSTNMBR = ConfigurationManager.AppSettings.Get("clienteDetraccion");
  587. lineaVenta.SOPTYPE = 3;
  588. // lineaVenta.DOCID = ConfigurationManager.AppSettings.Get("idTipDocDetraccion") + det.Seriecaseta.Trim();
  589. lineaVenta.DOCID = tipoDocumentoDetraccion;
  590. lineaVenta.ITEMNMBR = codArticulo;
  591. lineaVenta.UOFM = ConfigurationManager.AppSettings.Get("unidad");
  592. lineaVenta.CURNCYID = idMoneda;
  593. // obtener cantidad de decimales de GP
  594. lineaVenta.QUANTITY = Math.Round(det.Cantidad.Value, 0, MidpointRounding.AwayFromZero);
  595. lineaVenta.UNITPRCE = det.Total.Value;
  596. lineaVenta.XTNDPRCE = Math.Round(det.Total.Value, cantidadDecimalesMoneda, MidpointRounding.AwayFromZero);
  597. // el sitio va a ser por cada estacion
  598. // tendra la siguiente nomenclatura
  599. //lineaVenta.LOCNCODE = ConfigurationManager.AppSettings.Get("sitio");
  600. lineaVenta.LOCNCODE = det.Codestacion.Trim().ToUpper();
  601. lineaVenta.DOCDATE = DarFormatoFecha(det.Fecdoc.Value);
  602. // verificar si tiene detraccion
  603. lineaVenta.PRCLEVEL = "PEA." + det.Codestacion.Trim().ToUpper();
  604. detallesGP[0] = lineaVenta;
  605. // crear cabecera de documento
  606. // nivel de precio
  607. taSopHdrIvcInsert salesHdr = new taSopHdrIvcInsert();
  608. GetNextDocNumbers nextNumber = new GetNextDocNumbers();
  609. salesHdr.SOPNUMBE = nextNumber.GetNextSOPNumber(IncrementDecrement.Increment,tipoDocumentoDetraccion,SopType.SOPInvoice,EconnectConnectionString);
  610. //salesHdr.SOPNUMBE = det.Nrodetraccion;
  611. //CREAR NUMERO CORRELATIVO DE DOCUMENTO
  612. //salesHdr.SOPNUMBE
  613. // guardar ese numero correlativo en una variable para asignarlo luego
  614. nroDocDetraccion = salesHdr.SOPNUMBE;
  615. salesHdr.CREATEDIST = 1;
  616. salesHdr.SOPTYPE = 3;
  617. salesHdr.DOCID = tipoDocumentoDetraccion;
  618. salesHdr.BACHNUMB = nroLote; // numero de lote
  619. salesHdr.LOCNCODE = det.Codestacion.Trim().ToUpper(); ;
  620. salesHdr.DOCDATE = DarFormatoFecha(det.Fecdoc.Value);
  621. salesHdr.CUSTNMBR = ConfigurationManager.AppSettings.Get("clienteDetraccion");
  622. salesHdr.CUSTNAME = ConfigurationManager.AppSettings.Get("clienteDetraccion");
  623. salesHdr.CURNCYID = idMoneda;
  624. //salesHdr.CREATETAXES = 1;
  625. salesHdr.SUBTOTAL = det.Total.Value;
  626. salesHdr.DOCAMNT = det.Total.Value;
  627. salesHdr.USINGHEADERLEVELTAXES = 0;
  628. //salesHdr.CREATEDIST = 1; //
  629. //AGREGAR MONTO COBRADO
  630. salesHdr.PYMTRCVD = det.Total.Value;
  631. salesHdr.ORIGNUMB = det.Nrodocasociado; // numero de documento asociado
  632. salesHdr.USRDEFND1 = det.Idcliente;// guardar id de cliente
  633. salesHdr.USRDEFND2 = det.Seriedetraccion + det.Seriedoc; // guardar serie de detraccion
  634. // agregar turno
  635. salesHdr.USRDEFND3 = det.Turno;
  636. // agregar codigo de estacion
  637. salesHdr.USRDEFND4 = det.Codestacion;
  638. // agregar referencia de contabilidad
  639. String str_nro_doc;
  640. if (det.Nrodetraccion.Trim().Length < 8)
  641. {
  642. str_nro_doc = det.Nrodetraccion.Trim();
  643. }
  644. else
  645. {
  646. str_nro_doc = det.Nrodetraccion.Trim().Substring(det.Nrodetraccion.Trim().Length - 8);
  647. }
  648. salesHdr.REFRENCE = det.Seriedetraccion + det.Seriecaseta + "-" + str_nro_doc + "-" + det.Codestacion;
  649. //salesHdr.PYMTRMID = "Net 30";
  650. /*
  651. sopHdrTrx.SUBTOTAL = Math.Round(facturaBE.SubTotal, cantidadDecimalesPorMoneda, MidpointRounding.AwayFromZero);
  652. sopHdrTrx.TAXAMNT = Math.Round(facturaBE.Impuesto, cantidadDecimalesPorMoneda, MidpointRounding.AwayFromZero);
  653. sopHdrTrx.DOCAMNT = Math.Round(facturaBE.Total, cantidadDecimalesPorMoneda, MidpointRounding.AwayFromZero);
  654. */
  655. var myNextNumber = new GetNextDocNumbers();
  656. //agregar pagos
  657. var pagos = new taCreateSopPaymentInsertRecord_ItemsTaCreateSopPaymentInsertRecord[1];
  658. taCreateSopPaymentInsertRecord_ItemsTaCreateSopPaymentInsertRecord pago = new taCreateSopPaymentInsertRecord_ItemsTaCreateSopPaymentInsertRecord();
  659. pago.SOPTYPE = 3;
  660. pago.SOPNUMBE = salesHdr.SOPNUMBE;
  661. pago.CUSTNMBR = salesHdr.CUSTNMBR;
  662. pago.DOCNUMBR = myNextNumber.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMPayments, EconnectConnectionString);
  663. pago.DOCDATE = salesHdr.DOCDATE;
  664. pago.PYMTTYPE = 4;
  665. pago.DOCAMNT = salesHdr.DOCAMNT;
  666. // crear idChequera
  667. //ASIGNAR VARIABLE NRO PAGO
  668. nroPago = pago.DOCNUMBR;
  669. pago.CHEKBKID = det.Codestacion.Trim().ToUpper() + "_EF_DET"; ;
  670. // agregar el pago al array de pagos
  671. pagos[0] = pago;
  672. // crear la transaccion de orden de venta
  673. SOPTransactionType OrdenVenta = new SOPTransactionType();
  674. // poblar la orden de venta
  675. // Populate the schema object with the SOP header and SOP line item objects
  676. OrdenVenta.taSopLineIvcInsert_Items = detallesGP;
  677. OrdenVenta.taSopHdrIvcInsert = salesHdr;
  678. OrdenVenta.taCreateSopPaymentInsertRecord_Items = pagos;
  679. // Create an array that holds SOPTransactionType objects
  680. // Populate the array with the SOPTransactionType schema object
  681. SOPTransactionType[] MySopTransactionType = { OrdenVenta };
  682. // Create an eConnect XML document object and populate it
  683. // with the SOPTransactionType schema object
  684. eConnectType eConnect = new eConnectType();
  685. eConnect.SOPTransactionType = MySopTransactionType;
  686. XmlSerializer serializer = new XmlSerializer(eConnect.GetType());
  687. MemoryStream xmlMemoria = new MemoryStream();
  688. serializer.Serialize(xmlMemoria, eConnect);
  689. XmlDocument xmlDoc = new XmlDocument();
  690. xmlMemoria.Position = 0;
  691. xmlDoc.Load(xmlMemoria);
  692. xmlMemoria.Close();
  693. cadenaXML = xmlDoc.OuterXml;
  694. }
  695. catch (eConnectException ex)
  696. {
  697. //notificar de cualquier error de econnect
  698. Console.WriteLine("ERROR " + ex);
  699. }
  700. catch (Exception ex)
  701. {
  702. //notificar de cualquier error de econnect
  703. Console.WriteLine("ERROR " + ex);
  704. }
  705. return cadenaXML;
  706. }
  707. public static void enviarConsumosVale(CabeceraVentaBE cabeceraDoc, string nroLote)
  708. {
  709. // enviar asientos contables por stored procedure
  710. String idMoneda = ConfigurationManager.AppSettings.Get("idMoneda");
  711. Int32 cantidadDecimalesMoneda = CompanyGPBE.ObtenerCantidadDecimalesPorMoneda(idMoneda);
  712. AsientoContable asiento = new AsientoContable();
  713. string nroDocAsociado = "";
  714. if (cabeceraDoc.NroDocAsociado != null)
  715. {
  716. nroDocAsociado = cabeceraDoc.NroDocAsociado;
  717. }
  718. try
  719. {
  720. List<DetalleVentaBE> listaDetalles = DetalleVentaBL.obtenerDetalleDocumentos(cabeceraDoc.TipDoc, cabeceraDoc.SerieDoc, cabeceraDoc.NroDoc);
  721. foreach (DetalleVentaBE det in listaDetalles)
  722. {
  723. asiento.nroLote = nroLote;
  724. asiento.REFRENCE = "CONS. VAL: " + nroDocAsociado;
  725. asiento.TRXDATE = cabeceraDoc.FecProceso.Value;
  726. asiento.EXCHDATE = DateTime.ParseExact("01/01/1900", "dd/MM/yyyy", CultureInfo.InvariantCulture);
  727. asiento.EXPNDATE = DateTime.ParseExact("01/01/1900", "dd/MM/yyyy", CultureInfo.InvariantCulture);
  728. asiento.RVRSNGDT = DateTime.ParseExact("01/01/1900", "dd/MM/yyyy", CultureInfo.InvariantCulture);
  729. asiento.CURNCYID = idMoneda;
  730. asiento.cuentaCredito = ConfigurationManager.AppSettings.Get(det.Codestacion.ToUpper().Trim() + "_CUENTA_VAL_CRED");
  731. asiento.cuentaDebito = ConfigurationManager.AppSettings.Get(det.Codestacion.ToUpper().Trim() + "_CUENTA_VAL_DEB");
  732. asiento.SOURCDOC = ConfigurationManager.AppSettings.Get("SOURCDOC");
  733. asiento.DSCRIPTN = det.Seriedoc + "-" + det.Nrodoc;
  734. asiento.monto = det.Total.Value;
  735. numero_vale_tag = asiento.DSCRIPTN;
  736. Jrnentry= AsientosContablesBL.crearAsientosContables(asiento);
  737. nroArticulo = det.Codarticulo.Trim().PadLeft(2,'0');
  738. }
  739. }
  740. catch (Exception ex)
  741. {
  742. throw ex;
  743. }
  744. }
  745. public static void enviarConsumosTelepass(CabeceraVentaBE cabeceraDoc, string nroLote)
  746. {
  747. // enviar asientos contables por estored procedure
  748. // enviar asientos contables por stored procedure
  749. String idMoneda = ConfigurationManager.AppSettings.Get("idMoneda");
  750. Int32 cantidadDecimalesMoneda = CompanyGPBE.ObtenerCantidadDecimalesPorMoneda(idMoneda);
  751. AsientoContable asiento = new AsientoContable();
  752. string nroDocAsociado = "";
  753. if (cabeceraDoc.NroDocAsociado != null)
  754. {
  755. nroDocAsociado = cabeceraDoc.NroDocAsociado;
  756. }
  757. try
  758. {
  759. List<DetalleVentaBE> listaDetalles = DetalleVentaBL.obtenerDetalleDocumentos(cabeceraDoc.TipDoc, cabeceraDoc.SerieDoc, cabeceraDoc.NroDoc);
  760. foreach (DetalleVentaBE det in listaDetalles)
  761. {
  762. asiento.nroLote = nroLote;
  763. asiento.REFRENCE = "CONS.TEL: " + nroDocAsociado;
  764. asiento.TRXDATE = cabeceraDoc.FecProceso.Value;
  765. asiento.EXCHDATE = DateTime.ParseExact("01/01/1900", "dd/MM/yyyy", CultureInfo.InvariantCulture);
  766. asiento.EXPNDATE = DateTime.ParseExact("01/01/1900", "dd/MM/yyyy", CultureInfo.InvariantCulture);
  767. asiento.RVRSNGDT = DateTime.ParseExact("01/01/1900", "dd/MM/yyyy", CultureInfo.InvariantCulture);
  768. asiento.CURNCYID = idMoneda;
  769. asiento.cuentaDebito = ConfigurationManager.AppSettings.Get(det.Codestacion.ToUpper().Trim() + "_CUENTA_TELEPASS_DEB");
  770. asiento.cuentaCredito = ConfigurationManager.AppSettings.Get(det.Codestacion.ToUpper().Trim() + "_CUENTA_TELEPASS_CRED");
  771. asiento.SOURCDOC = ConfigurationManager.AppSettings.Get("SOURCDOC");
  772. asiento.DSCRIPTN = "PLACA: " + det.Placa + " TAG: " + det.NroTag;
  773. asiento.monto = det.Total.Value;
  774. numero_vale_tag = det.NroTag;
  775. placa = det.Placa;
  776. Jrnentry = AsientosContablesBL.crearAsientosContables(asiento);
  777. nroArticulo = det.Codarticulo.Trim().PadLeft(2, '0'); ;
  778. }
  779. }
  780. catch (Exception ex)
  781. {
  782. throw ex;
  783. }
  784. }
  785. public static string SerializarConsumoVale(CabeceraVentaBE cabeceraDoc, string nroLote)
  786. {
  787. string cadenaXML = "";
  788. String idMoneda = ConfigurationManager.AppSettings.Get("idMoneda");
  789. Int32 cantidadDecimalesMoneda = CompanyGPBE.ObtenerCantidadDecimalesPorMoneda(idMoneda);
  790. try
  791. {
  792. // obtener detalle de consumos
  793. List<DetalleVentaBE> listaDetalles = DetalleVentaBL.obtenerDetalleDocumentos(cabeceraDoc.TipDoc, cabeceraDoc.SerieDoc, cabeceraDoc.NroDoc);
  794. //CREAR TRANSACCION FINANCIERA
  795. taGLTransacti

Large files files are truncated, but you can click here to view the full file