コード例 #1
0
        public async Task <ReciboResponse> GraboRecibo(Vtrrch recibo, string tipoOperacion)
        {
            Vtmclh cliente = await Context.Vtmclh.Where(c => c.VtmclhNrocta == recibo.Vtrmvh_Nrocta).FirstOrDefaultAsync();

            if (cliente == null)
            {
                Logger.Error($"El cliente {recibo.Vtrmvh_Nrocta} no existe.");
                return(new ReciboResponse("Bad Request", 0, $"El cliente {recibo.Vtrmvh_Nrocta} no existe."));
            }


            oVtrrch.instancioObjeto(tipoOperacion);

            oVtrrch.asignoaTMWizard("VIRT_TIPPRC", "M", Logger);

            oVtrrch.MoveNext();

            Type typeRecibo = recibo.GetType();

            IEnumerable <PropertyInfo> listaPropiedades = typeRecibo.GetProperties();


            foreach (PropertyInfo propiedad in listaPropiedades)
            {
                if (propiedad.PropertyType == typeof(List <Vtrrcc01>))
                {
                    foreach (Vtrrcc01 item in recibo.Aplicaciones)
                    {
                        oVtrrch.asignoaTM("VTRRCC01", "", item, 2, Logger);
                    }
                }
                else if (propiedad.PropertyType == typeof(List <Vtrrcc04>))
                {
                    foreach (Vtrrcc04 item in recibo.MediosDeCobro)
                    {
                        oVtrrch.asignoaTM("VTRRCC04", "", item, 2, Logger);
                    }
                }
                else
                {
                    {
                        oVtrrch.asignoaTM("VTRRCH", propiedad.Name, propiedad.GetValue(recibo, null), 1, Logger);
                        //Logger.Information($"Campos {propiedad.Name} asignado con el valor {propiedad.GetValue(recibo, null)}");
                    }
                }
            }
            Save PerformedOperation = oVtrrch.save();

            bool   result       = PerformedOperation.Result;
            string mensajeError = PerformedOperation.errorMessage;

            oVtrrch.closeObjectInstance();

            if (result == false)
            {
                return(new ReciboResponse("Bad Request", 0, mensajeError));
            }

            return(new ReciboResponse("OK", 0, PerformedOperation.ComprobanteGenerado, "Comprobante generado"));
        }
コード例 #2
0
        public async Task <ActionResult <ReciboResponse> > Post([FromBody] RecibosDTO recibo)
        {
            Logger.Information($"Se recibio posteo de nuevo recibo {recibo.CodigoComprobanteAGenerar} - " +
                               $"Id de operacion: {recibo.IdOperacion}");

            int idOperacion = recibo.IdOperacion;

            if (Env.IsProduction())
            {
                if (int.TryParse(recibo.Cliente, out _))
                {
                    recibo.Cliente = string.Format("{0:00000000}", int.Parse(recibo.Cliente));
                }
                ;
                if (int.TryParse(recibo.CodigoSubcuenta, out _))
                {
                    recibo.CodigoSubcuenta = string.Format("{0:00000000}", int.Parse(recibo.CodigoSubcuenta));
                }
            }


            Vtrrch reciboFormat = Mapper.Map <RecibosDTO, Vtrrch>(recibo);

            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("Error", "Error de formato");
            }

            ReciboResponse response = recibo.TipoMovimiento == "R" ? await Repository.GraboRecibo(reciboFormat, "RUN_FOR_SCRIPT") :
                                      await Repository.GraboAnulacion(reciboFormat, "NEW");

            response.IdOperacion = idOperacion;

            if (response.Estado != 200)
            {
                return(BadRequest(response));
            }

            return(Ok(response));
        }
コード例 #3
0
 internal Task <ReciboResponse> GraboAnulacion(Vtrrch reciboFormat, string v)
 {
     throw new NotImplementedException();
 }