Exemple #1
0
        /// <summary>
        /// Create PM transaction
        /// </summary>
        /// <param name="transaction">Header of PM transaction</param>
        /// <param name="Distribution">Distribution Account of PM Transaction</param>
        /// <param name="Taxes">Taxes of PM transaction</param>
        /// <param name="company">COMPANY SHORT NAME</param>
        /// <returns>Response Class</returns>
        public Response TransactionCreate(PMTransactionHeader transaction, PMTransactionDist[] Distribution, PMTransactionTax[] Taxes, string company)
        {
            Response response;
            string   server         = ConfigKey.ReadSetting("SERVER");
            string   transactionXML = string.Empty;
            //var server = Properties.Settings.Default.SERVER.ToString();
            string            CNX        = "data source=" + server + ";initial catalog=" + company + ";integrated security=SSPI;persist security info=False;packet size=4096";
            var               eConnect   = new eConnectRequest();
            PMTransactionType pmTranType = new PMTransactionType();

            var getnext = new GetNextDocNumbers();

            getnext.RequireServiceProxy = false;

            try
            {
                string VCHRNUMBER = getnext.GetPMNextVoucherNumber(IncrementDecrement.Increment, CNX);
                pmTranType.taPMTransactionInsert = SetTransactionValues(transaction, VCHRNUMBER);

                if (transaction.CREATEDIST == 0)
                {
                    pmTranType.taPMDistribution_Items = SetDistributionValues(Distribution, VCHRNUMBER);
                }
                if (transaction.CreateTaxes == 1)
                {
                    pmTranType.taPMTransactionTaxInsert_Items = SetTaxValues(Taxes, VCHRNUMBER);
                }

                transactionXML = SerializePMTransaction(pmTranType);

                response = eConnect.CreateGPTransaction(CNX, transactionXML);
                return(response);
            }
            catch (Exception ex)
            {
                response         = new Response();
                response.SUCCESS = false;
                response.MESSAGE = ex.Message;
                response.STACK   = ex.StackTrace; //+ " Inner Exception: " + ex.InnerException.Message;
                return(response);
            }
            finally
            {
                getnext.Dispose();
            }
        }
Exemple #2
0
        public string getNum(int metodo)
        {
            GetNextDocNumbers myDocNumbers = new GetNextDocNumbers();
            GetSopNumber      mySopNumber  = new GetSopNumber();

            //n.Add(mySopNumber.GetNextSopNumber(3, "STDINV", connString));

            // Use each method of the GetNextDocNumber object to retrieve the next document number
            // for the available Microsoft Dynamics GP document types
            if (metodo == 1)
            {
                return(myDocNumbers.GetPMNextVoucherNumber(GetNextDocNumbers.IncrementDecrement.Increment, connectionString));
            }
            else
            if (metodo == 2)
            {
                return(myDocNumbers.GetNextPOPReceiptNumber(GetNextDocNumbers.IncrementDecrement.Increment, connectionString));
            }
            else
            {
                return(null);
            }
        }
Exemple #3
0
        /// <summary>
        /// Arma pago PM en objeto econnect pagoPm.
        /// </summary>
        /// <param name="hojaXl"></param>
        /// <param name="fila"></param>
        /// <param name="sTimeStamp"></param>
        /// <param name="param"></param>
        public void armaPagoPmEconn(ExcelWorksheet hojaXl, int fila, string sTimeStamp, Parametros param)
        {
            //Stream outputFile = File.Create(@"C:\gpusuario\traceArmaFActuraPmEconn" + fila.ToString() + ".txt");
            //TextWriterTraceListener textListener = new TextWriterTraceListener(outputFile);
            //TraceSource trace = new TraceSource("trSource", SourceLevels.All);
            try
            {
                //trace.Listeners.Clear();
                //trace.Listeners.Add(textListener);
                //trace.TraceInformation("arma factura pm econn");
                //trace.TraceInformation("fila: " + fila.ToString() + " col vendorid:" +param.facturaPmVENDORID);

                iError = 0;
                GetNextDocNumbers nextDocNumber = new GetNextDocNumbers();

                pagoPm.PMNTNMBR = nextDocNumber.GetPMNextVoucherNumber(IncrementDecrement.Increment, _DatosConexionDB.Elemento.ConnStr);

                pagoPm.PYENTTYP = short.Parse(hojaXl.Cells[fila, param.PagosPmPYENTTYP].Value.ToString().Trim());
                pagoPm.VENDORID = hojaXl.Cells[fila, param.PagosPmVENDORID].Value.ToString().Trim();
                pagoPm.DOCNUMBR = hojaXl.Cells[fila, param.PagosPmDOCNUMBR].Value.ToString().Trim();

                pagoPm.BACHNUMB = sTimeStamp;
                pagoPm.CHEKBKID = hojaXl.Cells[fila, param.PagosPmCHEKBKID].Value.ToString().Trim();

                if (hojaXl.Cells[fila, param.PagosPmTRXDSCRN].Value != null)
                {
                    pagoPm.TRXDSCRN = hojaXl.Cells[fila, param.PagosPmTRXDSCRN].Value.ToString().Trim();
                }

                pagoPm.DOCDATE = DateTime.Parse(hojaXl.Cells[fila, param.PagosPmDOCDATE].Value.ToString().Trim()).ToString(param.FormatoFecha);

                //pagoPm.CURNCYID = hojaXl.Cells[fila, param.facturaPmCURNCYID].Value.ToString();

                pagoPm.DOCAMNT = Decimal.Round(Convert.ToDecimal(hojaXl.Cells[fila, param.PagosPmDOCAMNT].Value.ToString(), CultureInfo.InvariantCulture), 2);
            }

            catch (NullReferenceException nr)
            {
                sMensaje = nr.Message + " " + nr.TargetSite.ToString();
                iError++;
            }
            catch (FormatException fmt)
            {
                sMensaje = "Alguna de las columnas contiene un monto o fecha con formato incorrecto. " + fmt.Message + " " + fmt.TargetSite.ToString();
                iError++;
            }
            catch (OverflowException ovr)
            {
                sMensaje = "Alguna de las columna contiene un número demasiado grande. " + ovr.Message + " " + ovr.TargetSite.ToString();
                iError++;
            }
            catch (Exception errorGral)
            {
                string inner = errorGral.InnerException == null ? "" : errorGral.InnerException.Message;
                sMensaje = "Excepción desconocida al armar el pago pm. " + errorGral.Message + ". " + inner + " " + errorGral.TargetSite.ToString();
                iError++;
            }
            //finally
            //{
            //    trace.Flush();
            //    trace.Close();
            //}
        }
Exemple #4
0
        /// <summary>
        /// Arma factura PM en objeto econnect facturaPm.
        /// </summary>
        /// <param name="hojaXl"></param>
        /// <param name="fila"></param>
        /// <param name="sTimeStamp"></param>
        /// <param name="param"></param>
        public void armaFacturaPmEconn(ExcelWorksheet hojaXl, int fila, string sTimeStamp, Parametros param)
        {
            //Stream outputFile = File.Create(@"C:\gpusuario\traceArmaFActuraPmEconn" + fila.ToString() + ".txt");
            //TextWriterTraceListener textListener = new TextWriterTraceListener(outputFile);
            //TraceSource trace = new TraceSource("trSource", SourceLevels.All);
            try
            {
                //trace.Listeners.Clear();
                //trace.Listeners.Add(textListener);
                //trace.TraceInformation("arma factura pm econn");
                //trace.TraceInformation("fila: " + fila.ToString() + " col vendorid:" +param.facturaPmVENDORID);

                iError = 0;
                string            esf           = hojaXl.Cells[fila, param.facturaPmEsFactura].Value.ToString().Trim().ToUpper();
                short             tipoDocumento = 0;
                GetNextDocNumbers nextDocNumber = new GetNextDocNumbers();

                facturaPm.VCHNUMWK = nextDocNumber.GetPMNextVoucherNumber(IncrementDecrement.Increment, _DatosConexionDB.Elemento.ConnStr);

                if (short.TryParse(esf, out tipoDocumento))
                {
                    facturaPm.DOCTYPE  = tipoDocumento;
                    facturaPm.VENDORID = hojaXl.Cells[fila, param.facturaPmVENDORID].Value.ToString().Trim();
                    facturaPm.DOCNUMBR = hojaXl.Cells[fila, param.facturaPmDOCNUMBR].Value.ToString().Trim();
                }
                else
                if (esf.Equals("SI"))
                {
                    facturaPm.DOCTYPE  = 1; //invoice
                    facturaPm.VENDORID = hojaXl.Cells[fila, param.facturaPmVENDORID].Value.ToString().Trim();
                    facturaPm.DOCNUMBR = hojaXl.Cells[fila, param.facturaPmDOCNUMBR].Value.ToString().Trim();
                }
                else
                {
                    facturaPm.DOCTYPE  = 3; //misc charge
                    facturaPm.VENDORID = param.facturaPmGenericVENDORID;
                    facturaPm.DOCNUMBR = param.facturaPmGenericVENDORID + "-" + hojaXl.Cells[fila, param.facturaPmDOCNUMBR].Value.ToString().Trim();
                }

                facturaPm.BACHNUMB      = sTimeStamp;
                facturaPm.BatchCHEKBKID = param.facturaPmBatchCHEKBKID;

                if (param.FacturaPmLOCALIZACION.Equals("BOL"))
                {
                    if (hojaXl.Cells[fila, param.addCodigoControl].Value != null)
                    {
                        facturaPm.USRDEFND1 = hojaXl.Cells[fila, param.addCodigoControl].Value.ToString().Trim();
                    }

                    if (hojaXl.Cells[fila, param.addNumAutorizacion].Value != null)
                    {
                        facturaPm.USRDEFND2 = hojaXl.Cells[fila, param.addNumAutorizacion].Value.ToString().Trim();
                    }
                }

                if (hojaXl.Cells[fila, param.facturaPmTRXDSCRN].Value != null)
                {
                    facturaPm.TRXDSCRN = hojaXl.Cells[fila, param.facturaPmTRXDSCRN].Value.ToString();
                }

                if (hojaXl.Cells[fila, param.facturaPmRETENCION].Value != null)
                {
                    facturaPm.USRDEFND2 = hojaXl.Cells[fila, param.facturaPmRETENCION].Value.ToString();
                }

                facturaPm.DOCDATE = DateTime.Parse(hojaXl.Cells[fila, param.facturaPmDOCDATE].Value.ToString().Trim()).ToString(param.FormatoFecha);

                if (hojaXl.Cells[fila, param.facturaPmDUEDATE].Value != null)
                {
                    facturaPm.DUEDATE = DateTime.Parse(hojaXl.Cells[fila, param.facturaPmDUEDATE].Value.ToString().Trim()).ToString(param.FormatoFecha);
                }

                facturaPm.CURNCYID = hojaXl.Cells[fila, param.facturaPmCURNCYID].Value.ToString();

                facturaPm.PRCHAMNT = Decimal.Round(Convert.ToDecimal(hojaXl.Cells[fila, param.facturaPmPRCHAMNT].Value.ToString(), CultureInfo.InvariantCulture), 2);

                if (param.DistribucionPmAplica.Equals("SI"))
                {
                    facturaPm.CREATEDIST = 0;               //no crea el asiento contable automáticamente
                }
                else
                {   //armado manual del detalle de los impuestos. El asiento contable se calcula automáticamente
                    facturaPm.TAXSCHID = getDatosProveedor(facturaPm.VENDORID);
                    armaDetalleImpuestos(facturaPm.TAXSCHID);
                    facturaPm.TAXAMNT = taxDetails.Sum(t => t.TAXAMNT);
                }

                facturaPm.DOCAMNT = facturaPm.MSCCHAMT + facturaPm.PRCHAMNT + facturaPm.TAXAMNT + facturaPm.FRTAMNT - facturaPm.TRDISAMT;
                //facturaPm.DOCAMNT = facturaPm.PRCHAMNT;
                facturaPm.CHRGAMNT = facturaPm.DOCAMNT;

                if (hojaXl.Cells[fila, param.facturaPmPAGADO].Value != null && hojaXl.Cells[fila, param.facturaPmPAGADO].Value.ToString() == "SI")
                {
                    facturaPm.CASHAMNT = facturaPm.PRCHAMNT;
                    facturaPm.CAMCBKID = hojaXl.Cells[param.facturaPmrowCHEKBKID, param.facturaPmcolCHEKBKID].Value.ToString().ToUpper().Trim();
                    facturaPm.CDOCNMBR = "R" + facturaPm.DOCNUMBR;
                    facturaPm.CAMPMTNM = "R" + facturaPm.VCHNUMWK;
                    facturaPm.CAMTDATE = facturaPm.DOCDATE;
                }
            }

            catch (NullReferenceException nr)
            {
                sMensaje = nr.Message + " " + nr.TargetSite.ToString();
                iError++;
            }
            catch (FormatException fmt)
            {
                sMensaje = "Alguna de las columnas contiene un monto o fecha con formato incorrecto. " + fmt.Message + " [Excepción en FacturaDeCompraPM.armaFacturaPmEconn]";
                iError++;
            }
            catch (OverflowException ovr)
            {
                sMensaje = "Alguna de las columna contiene un número demasiado grande. " + ovr.Message + " [Excepción en FacturaDeCompraPM.armaFacturaPmEconn]";
                iError++;
            }
            catch (Exception errorGral)
            {
                string inner = errorGral.InnerException == null ? "" : errorGral.InnerException.Message;
                sMensaje = "Excepción desconocida al armar la factura o comprobante. " + errorGral.Message + ". " + inner + " [Excepción en FacturaDeCompraPM.armaFacturaPmEconn]";
                iError++;
            }
            //finally
            //{
            //    trace.Flush();
            //    trace.Close();
            //}
        }