Exemplo n.º 1
0
        public static BE.EntradaAlmacen EntradaAlmacen(JS.EntradaAlmacen jsEntradaAlmacen)
        {
            BE.EntradaAlmacen beEntradaAlmacen = null;
            try
            {
                if (jsEntradaAlmacen != null)
                {
                    beEntradaAlmacen = new BE.EntradaAlmacen();

                    beEntradaAlmacen.Serie         = 0;
                    beEntradaAlmacen.Usuario       = jsEntradaAlmacen.usuario;
                    beEntradaAlmacen.Comentario    = jsEntradaAlmacen.comentario;
                    beEntradaAlmacen.FechaContable = ParseStringToDatetime(jsEntradaAlmacen.FechaContable);
                    beEntradaAlmacen.FechaCreacion = ParseStringToDatetime(jsEntradaAlmacen.FechaCreacion);
                    beEntradaAlmacen.DocEntry      = 0;
                    beEntradaAlmacen.refSap        = jsEntradaAlmacen.docEntryOrden;

                    beEntradaAlmacen.Detalle = new List <BE.EntradaAlmacenDetalle>();

                    int nroLinea = 1;
                    foreach (var jsDetalle in jsEntradaAlmacen.detalle)
                    {
                        var beDetalle = new BE.EntradaAlmacenDetalle();

                        beDetalle.NroLinea          = nroLinea;
                        beDetalle.Codigo            = jsDetalle.codArticulo;
                        beDetalle.Descripcion       = jsDetalle.descripcion;
                        beDetalle.Cantidad          = ParseStringToDouble(jsDetalle.cantidad);
                        beDetalle.Precio            = 0.0;
                        beDetalle.CodAlmacen        = jsDetalle.codAlmacen;
                        beDetalle.CodImpuesto       = jsDetalle.codImpuesto;
                        beDetalle.CodMoneda         = "";
                        beDetalle.CodCuentaContable = "";
                        beDetalle.CodProyecto       = "";
                        beDetalle.CodCentroCosto    = jsDetalle.codCentroCosto;
                        beDetalle.refLineaSap       = int.Parse(jsDetalle.lineNumSap);

                        beEntradaAlmacen.Detalle.Add(beDetalle);

                        nroLinea++;
                    }
                }

                return(beEntradaAlmacen);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public string Enviar(BE.EntradaAlmacen beEntradaAlmacen, out int errCode, out string errMessage)
        {
            string docEntry = "";

            int    errCod = 0;
            string errMsg = "";

            try
            {
                Documents oEntradaAlmacen = oCompany.GetBusinessObject(BoObjectTypes.oInventoryGenEntry);

                oEntradaAlmacen.Series = beEntradaAlmacen.Serie;

                oEntradaAlmacen.DocDate    = beEntradaAlmacen.FechaContable;
                oEntradaAlmacen.TaxDate    = beEntradaAlmacen.FechaContable;
                oEntradaAlmacen.DocDueDate = beEntradaAlmacen.FechaCreacion;

                oEntradaAlmacen.Comments = beEntradaAlmacen.Comentario;

                oEntradaAlmacen.PaymentGroupCode = -1;

                oEntradaAlmacen.UserFields.Fields.Item("U_EXX_NOMBENEFE").Value = beEntradaAlmacen.Usuario;

                int linea = 0;
                foreach (var beEntradaAlmacenDetalle in beEntradaAlmacen.Detalle)
                {
                    if (linea > 0)
                    {
                        oEntradaAlmacen.Add();
                    }

                    oEntradaAlmacen.Lines.ItemCode        = beEntradaAlmacenDetalle.Codigo;
                    oEntradaAlmacen.Lines.ItemDescription = beEntradaAlmacenDetalle.Descripcion;
                    oEntradaAlmacen.Lines.Quantity        = beEntradaAlmacenDetalle.Cantidad;

                    //oEntradaAlmacen.Lines.Price = beEntradaAlmacenDetalle.Precio;
                    //oEntradaAlmacen.Lines.UnitPrice = beEntradaAlmacenDetalle.Precio;

                    //oEntradaAlmacen.Lines.TaxCode = beEntradaAlmacenDetalle.CodImpuesto;
                    //oEntradaAlmacen.Lines.Currency = beEntradaAlmacenDetalle.CodMoneda;

                    oEntradaAlmacen.Lines.WarehouseCode = beEntradaAlmacenDetalle.CodAlmacen;

                    //oEntradaAlmacen.Lines.AccountCode = beEntradaAlmacenDetalle.CodCuentaContable;

                    oEntradaAlmacen.Lines.CostingCode = beEntradaAlmacenDetalle.CodCentroCosto;
                    //oEntradaAlmacen.Lines.ProjectCode = beEntradaAlmacenDetalle.CodProyecto;

                    linea++;
                }


                int retCode = oEntradaAlmacen.Add();
                if (retCode == 0)
                {
                    docEntry = oCompany.GetNewObjectKey();
                }
                else
                {
                    oCompany.GetLastError(out errCod, out errMsg);
                }

                errCode    = errCod;
                errMessage = errMsg;

                return(docEntry);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public string Enviar(BE.EntradaAlmacen beEntradaAlmacen, out int errCode, out string errMessage)
        {
            string docEntry = "";

            int    errCod = 0;
            string errMsg = "";

            try
            {
                Documents oOrdenCompra = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);

                int docNumOC = int.Parse(beEntradaAlmacen.refSap);
                if (oOrdenCompra.GetByKey(docNumOC))
                {
                    Documents oEntradaAlmacenPorCompra = oCompany.GetBusinessObject(BoObjectTypes.oPurchaseDeliveryNotes);

                    oEntradaAlmacenPorCompra.CardCode = oOrdenCompra.CardCode;
                    oEntradaAlmacenPorCompra.CardName = oOrdenCompra.CardName;

                    oEntradaAlmacenPorCompra.Series = beEntradaAlmacen.Serie;

                    oEntradaAlmacenPorCompra.DocDate    = beEntradaAlmacen.FechaContable;
                    oEntradaAlmacenPorCompra.TaxDate    = beEntradaAlmacen.FechaContable;
                    oEntradaAlmacenPorCompra.DocDueDate = beEntradaAlmacen.FechaCreacion;

                    oEntradaAlmacenPorCompra.Comments = beEntradaAlmacen.Comentario;

                    oEntradaAlmacenPorCompra.PaymentGroupCode = -1;

                    oEntradaAlmacenPorCompra.UserFields.Fields.Item("U_EXX_NOMBENEFE").Value = beEntradaAlmacen.Usuario;

                    int linea = 0;
                    foreach (var beEntradaAlmacenDetalle in beEntradaAlmacen.Detalle)
                    {
                        if (linea > 0)
                        {
                            oEntradaAlmacenPorCompra.Lines.Add();
                        }

                        oEntradaAlmacenPorCompra.Lines.ItemCode        = beEntradaAlmacenDetalle.Codigo;
                        oEntradaAlmacenPorCompra.Lines.ItemDescription = beEntradaAlmacenDetalle.Descripcion;
                        oEntradaAlmacenPorCompra.Lines.Quantity        = beEntradaAlmacenDetalle.Cantidad;

                        oEntradaAlmacenPorCompra.Lines.BaseType  = int.Parse(oOrdenCompra.DocObjectCodeEx); // If I comment out this and the next two lines the document will add
                        oEntradaAlmacenPorCompra.Lines.BaseEntry = oOrdenCompra.DocEntry;
                        oEntradaAlmacenPorCompra.Lines.BaseLine  = beEntradaAlmacenDetalle.refLineaSap;

                        //oEntradaAlmacen.Lines.Price = beEntradaAlmacenDetalle.Precio;
                        //oEntradaAlmacen.Lines.UnitPrice = beEntradaAlmacenDetalle.Precio;

                        //oEntradaAlmacen.Lines.TaxCode = beEntradaAlmacenDetalle.CodImpuesto;
                        //oEntradaAlmacen.Lines.Currency = beEntradaAlmacenDetalle.CodMoneda;

                        oEntradaAlmacenPorCompra.Lines.WarehouseCode = beEntradaAlmacenDetalle.CodAlmacen;

                        //oEntradaAlmacen.Lines.AccountCode = beEntradaAlmacenDetalle.CodCuentaContable;

                        oEntradaAlmacenPorCompra.Lines.CostingCode = beEntradaAlmacenDetalle.CodCentroCosto;
                        //oEntradaAlmacen.Lines.ProjectCode = beEntradaAlmacenDetalle.CodProyecto;

                        linea++;
                    }


                    int retCode = oEntradaAlmacenPorCompra.Add();
                    if (retCode == 0)
                    {
                        docEntry = oCompany.GetNewObjectKey();
                    }
                    else
                    {
                        oCompany.GetLastError(out errCod, out errMsg);
                    }
                }
                else
                {
                    errCod = -1;
                    errMsg = "No existe la orden de compra";
                }

                errCode    = errCod;
                errMessage = errMsg;

                return(docEntry);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }