Ejemplo n.º 1
0
        public async Task <string> EnviarDTE([FromBody] EnvioDTEpara datos)
        {
            var lista = new List <Detalle>();

            if (datos.detalles != null)
            {
                foreach (Hist_plu venta in datos.detalles)
                {
                    venta.Cantidad = datos.detalles.Count(p => p.CodigoPLU == venta.CodigoPLU);
                }
                var ventas = datos.detalles.GroupBy(p => p.CodigoPLU).Select(y => y.First());


                int i = 0;
                foreach (Hist_plu venta in ventas)
                {
                    i++;
                    lista.Add(PluToDetalle(venta, i));
                }
            }

            EnvioDTE dte = new EnvioDTE();

            EnvioDteApi datosEnvio = new EnvioDteApi {
                detalles         = lista, CmnaDest = datos.CmnaDest,
                tipoDocumento    = datos.tipoDocumento,
                IndTraslado      = datos.IndTraslado, TpoDocLiq = datos.TpoDocLiq, numFolioReferencia = datos.numFolioReferencia,
                tipoDocumentoRef = datos.tipoDocumentoRef, CodRef = datos.CodRef, FmaPago = datos.FmaPago, CdgTraslado = datos.CdgTraslado
            };
            string res = await dte.EnviarDetalles(datosEnvio);

            return(res);
        }
Ejemplo n.º 2
0
        public async Task <string> EnviarDetalles(EnvioDteApi datos)
        {
            var ajustes = _context.Ajustes.FirstOrDefault();

            datos.NumSucursal = ajustes.numSucursal;
            datos.NumCaja     = ajustes.numeroCaja;
            datos.RutCliente  = "77441010-4";

            string res    = string.Empty;
            string urlAPI = this.url + "/enviarDTE";

            var        json    = JsonConvert.SerializeObject(datos);
            var        content = new StringContent(json, Encoding.UTF8, "application/json");
            HttpClient client  = new HttpClient();

            var response = await client.PostAsync(urlAPI, content);

            var RespAdmFolios = await response.Content.ReadAsStringAsync();

            return(RespAdmFolios);
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> AnularVenta(EnvioDteApi datos)
        {
            try
            {
                List <Detalle> ventas = new List <Detalle>();


                EnvioDTE dte = new EnvioDTE();

                EnvioDteApi datosEnvio = new EnvioDteApi
                {
                    detalles           = datos.detalles,
                    CmnaDest           = datos.CmnaDest,
                    tipoDocumento      = datos.tipoDocumento,
                    IndTraslado        = datos.IndTraslado,
                    TpoDocLiq          = datos.TpoDocLiq,
                    numFolioReferencia = datos.numFolioReferencia,
                    tipoDocumentoRef   = datos.tipoDocumentoRef,
                    CodRef             = datos.CodRef,
                    FmaPago            = datos.FmaPago,
                    CdgTraslado        = datos.CdgTraslado
                };
                string res = await dte.EnviarDetalles(datosEnvio);

                //foreach (Hist_fn venta in _context.Hist_fn.Where(p=>p.numeroFolio==datos.numFolio))
                //{
                //    venta.Anulada = true;
                //    await _context.SaveChangesAsync();
                //}
            }
            catch (Exception ex)
            {
                return(BadRequest(new { resStatus = false, mensaje = ex.Message }));
            }
            return(Ok(new { resStatus = true, mensaje = "Venta anulada con exito" }));
        }