/// <summary> /// /// </summary> /// <param name="applytran"></param> /// <returns></returns> private taRMApply SetApplyValues(RMApply applytran) { try { var rmapplytransaction = new taRMApply { APTODCNM = applytran.APTODCNM, APFRDCNM = applytran.APFRDCNM, APPTOAMT = applytran.APPTOAMT, APFRDCTY = applytran.APFRDCTY, APTODCTY = applytran.APTODCTY, DISTKNAM = applytran.DISTKNAM.GetValueOrDefault(), WROFAMNT = applytran.WROFAMNT.GetValueOrDefault(), APPLYDATE = applytran.APPLYDATE.ToString("yyyy-MM-dd"), GLPOSTDT = applytran.GLPOSTDT.ToString("yyyy-MM-dd") }; return(rmapplytransaction); } catch (Exception) { throw; } }
/// <summary> /// Integra nc de AR y aplica facturas /// </summary> /// <param name="worker"></param> /// <param name="e"></param> private void IntegraRMNotaCreditoYAplicaciones(BackgroundWorker worker, DoWorkEventArgs e) { string mensajeOk = ""; string mensajeError = ""; Model.RMFactura docGP = null; Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); string nroLote = DateTime.Now.ToString("yyyyMMdd.HHmmss"); worker.ReportProgress(0, new string[] { "Credit memo batch " + nroLote, "Credit memo Batch " + nroLote }); cantidad = 0; foreach (var dato in _cobros.LBoletosBrasil) { mensajeOk = ""; mensajeError = ""; DateTime fechaCobro = dato.FechaTotalLiquidado.AddDays(parametrosCobrosXL.FechaTotalLiquidadoAddDays); using (eConnectMethods eConnectMethods = new eConnectMethods()) { eConnectMethods.RequireProxyService = true; List <RMTransactionType> masterRMTransactionType = new List <RMTransactionType>(); List <RMApplyType> masterRMApplyType = new List <RMApplyType>(); try { bool error = false; decimal valorBoleto = decimal.Round(dato.ValorBoleto, 2); decimal valorPago = decimal.Round(dato.ValorPago, 2); decimal juros = decimal.Round(dato.Juros, 2); //RMCashReceiptsType RMCashReceiptsTypeEntry = new RMCashReceiptsType(); RMTransactionType RMTransactionTypeEntry = new RMTransactionType(); taRMTransaction rmTransactionItem = new taRMTransaction(); //el número de la planilla puede venir así: B-10201, B-10201., B-10201 01, B-10201. 01 //string numFactura = dato.NumeroFactura.Trim().Length > 7 ? Model.Utiles.Izquierda(dato.NumeroFactura, 8) : Model.Utiles.Izquierda( dato.NumeroFactura, 7); docGP = this.getCustnmbrDocnumbr(dato.NumeroFactura.Trim(), dato.FechaVencimientoPago); rmTransactionItem.CUSTNMBR = docGP.Custnmbr; // custData["custnmbr"].ToString(); //_custnmbr; rmTransactionItem.DOCNUMBR = "CC" + dato.NumeroCobro; rmTransactionItem.DOCDATE = fechaCobro.ToString(parametrosCobrosXL.FormatoFecha); //System.Configuration.ConfigurationManager.AppSettings[_pre + "_FormatoFecha"]); rmTransactionItem.RMDTYPAL = 7; rmTransactionItem.DOCAMNT = juros; rmTransactionItem.SLSAMNT = juros; rmTransactionItem.BACHNUMB = nroLote; rmTransactionItem.DOCDESCR = dato.NumeroFacturaYCuota; rmTransactionItem.CSTPONBR = dato.NombrePagador; RMApplyType RMApplyTypeEntry = new RMApplyType(); taRMApply ApplyItem = new taRMApply(); ApplyItem.APTODCNM = docGP.Docnmbr; // custData["docnumbr"].ToString(); // _docnmbr.Trim(); ApplyItem.APFRDCNM = "CC" + dato.NumeroCobro; ApplyItem.APPTOAMT = juros - Convert.ToDecimal(docGP.Amount) > 0 ? Convert.ToDecimal(docGP.Amount) : juros; ApplyItem.APFRDCTY = 7; ApplyItem.APTODCTY = 1; ApplyItem.APPLYDATE = fechaCobro.ToString(parametrosCobrosXL.FormatoFecha); // System.Configuration.ConfigurationManager.AppSettings[_pre + "_FormatoFecha"]); ApplyItem.GLPOSTDT = fechaCobro.ToString(parametrosCobrosXL.FormatoFecha); // System.Configuration.ConfigurationManager.AppSettings[_pre + "_FormatoFecha"]); cantidad++; if (!error) { eConnectType eConnDoc = new eConnectType(); RMTransactionTypeEntry.taRMTransaction = rmTransactionItem; masterRMTransactionType.Add(RMTransactionTypeEntry); eConnDoc.RMTransactionType = masterRMTransactionType.ToArray(); RMApplyTypeEntry.taRMApply = ApplyItem; masterRMApplyType.Add(RMApplyTypeEntry); eConnDoc.RMApplyType = masterRMApplyType.ToArray(); XmlDocument xmlDoc = Serializa(eConnDoc); eConnectMethods.CreateEntity(parametrosCobrosXL.ConnStringTarget, xmlDoc.OuterXml); mensajeOk = dato.NumeroFactura + " - " + dato.NumeroCobro + ": Credit Memo OK" + Environment.NewLine; } else { mensajeError = dato.NumeroFactura + " - " + dato.NumeroCobro + ": Error" + Environment.NewLine; } System.Threading.Thread.Sleep(100); } catch (eConnectException ec) { mensajeError = dato.NumeroFactura + " - " + dato.NumeroCobro + " eConn: " + ec.Message + Environment.NewLine + ec.StackTrace; } catch (Exception ex) { mensajeError = dato.NumeroFactura + " - " + dato.NumeroCobro + ": " + ex.Message + Environment.NewLine + ex.StackTrace; } finally { eConnectMethods.Dispose(); worker.ReportProgress(0, new string[] { mensajeError, mensajeOk }); } } } worker.ReportProgress(0, new string[] { "Credit memo uploading finished.", "Credit memo uploading finished." }); }