/* * public static ResAcc<int> GenerarNotaDeCredito(int iClienteID, decimal mImporte, string sObservacion) * { * return VentasProc.GenerarNotaDeCredito(iClienteID, mImporte, sObservacion, null); * } * * public static ResAcc<int> GenerarNotaDeCredito(int iClienteID, decimal mImporte, string sObservacion, int? iOrigenVentaID) * { * DateTime dAhora = DateTime.Now; * * // Se revisa si existen otras notas de crédito que se puedan usar para afectar ésta * bool bNegativa = (mImporte < 0); * var oNotas = General.GetListOf<NotaDeCredito>(q => q.ClienteID == iClienteID && q.Valida && q.Estatus).OrderByDescending(q => q.FechaDeEmision); * foreach (var oNota in oNotas) * { * if ((bNegativa && oNota.Importe < 0) || (!bNegativa && oNota.Importe > 0)) * continue; * * mImporte += oNota.Importe; * * if ((bNegativa && mImporte <= 0) || (!bNegativa && mImporte >= 0)) * // * { * oNota.Valida = false; * oNota.FechaDeUso = dAhora; * oNota.Observacion += ("\n\n" + DateTime.Now.ToString() + "Nota cancelada por ser descontada al agregar otra nota con un importe mayor."); * Datos.Guardar<NotaDeCredito>(oNota); * // Se debe imprimir algo aquí ? * * // Si ya se emparejó la cantidad, se sale * if (mImporte == 0) * return new ResAcc<int>(true, ""); * } * else * // * { * oNota.Importe += (mImporte * -1); * Datos.Guardar<NotaDeCredito>(oNota); * // Se debe imprimir algo aquí ? * * // Se sale, pues ya no hay importe para afectar * return new ResAcc<int>(true, ""); * } * } * * // Se crea la nota * var oNotaNueva = new NotaDeCredito() * { * FechaDeEmision = DateTime.Now, * Importe = mImporte, * ClienteID = iClienteID, * Valida = true, * Observacion = sObservacion, * OrigenVentaID = iOrigenVentaID * }; * Datos.Guardar<NotaDeCredito>(oNotaNueva); * * // Se imprime el ticket correspondiente * * * return new ResAcc<int>(true, oNotaNueva.NotaDeCreditoID); * } */ #region [ Vales ] public static ResAcc <int> GenerarNotaDeCredito(int iClienteID, decimal mImporte, string sObservacion, int iOrigenID, int iRelacionID) { DateTime dAhora = DateTime.Now; // Se revisa si existen otras notas de crédito que se puedan usar para afectar ésta bool bNegativa = (mImporte < 0); var oNotas = Datos.GetListOf <NotaDeCredito>(q => q.ClienteID == iClienteID && q.Valida && q.Estatus).OrderByDescending(q => q.FechaDeEmision); foreach (var oNota in oNotas) { if ((bNegativa && oNota.Importe < 0) || (!bNegativa && oNota.Importe > 0)) { continue; } mImporte += oNota.Importe; if ((bNegativa && mImporte <= 0) || (!bNegativa && mImporte >= 0)) // { oNota.Valida = false; oNota.FechaDeUso = dAhora; oNota.Observacion += ("\n\n" + DateTime.Now.ToString() + "Nota cancelada por ser descontada al agregar otra nota con un importe mayor."); Datos.Guardar <NotaDeCredito>(oNota); // Se debe imprimir algo aquí ? // Si ya se emparejó la cantidad, se sale if (mImporte == 0) { return(new ResAcc <int>(true, "")); } } else // { oNota.Importe += (mImporte * -1); Datos.Guardar <NotaDeCredito>(oNota); // Se debe imprimir algo aquí ? // Se sale, pues ya no hay importe para afectar return(new ResAcc <int>(true, "")); } } // Se crea la nota var oNotaNueva = new NotaDeCredito() { FechaDeEmision = DateTime.Now, SucursalID = Theos.SucursalID, Importe = mImporte, ClienteID = iClienteID, Valida = true, Observacion = sObservacion, OrigenID = iOrigenID, RelacionID = iRelacionID }; Datos.Guardar <NotaDeCredito>(oNotaNueva); // Se imprime el ticket correspondiente return(new ResAcc <int>(true, oNotaNueva.NotaDeCreditoID)); }
static void Main(string[] args) { // Ejercicio para el hogar // Hacer una funcion Division() // que divida dos numeros enteros // SIN USAR EL OPERADOR / // Un hongo -> con una iteracion // Dos hongos -> recursivo var divide = Division(5, 2); Console.WriteLine(divide); int sueldo = 101; int empleados = 4; int transferencia; int[] sueldos = new int[10]; transferencia = sueldo * empleados; int c = Suma(1, Suma(2, 3)); int cap; var r = HacerAlgo(1, 2, out cap); var sumatoria = Sumatoria(3); //ImprimirSiEsPar(1); //ImprimirSiEsPar(2); //ImprimirSiEsPar(3); //ImprimirSiEsPar(transferencia); //Console.WriteLine("Monto: " + transferencia); Persona p = new Persona(); p.Nombre = "Luciano"; p.Apellido = "Zinik"; p.Sueldo = 100; p.Tipo = TipoEmpleado.LU; var otraP = new Persona { Nombre = "Luciano", Apellido = "Zinik", Sueldo = 100, Tipo = TipoEmpleado.LU }; //ImprimirPersona(p); if (otraP.Tipo == TipoEmpleado.Contratado) { } var fc = new Factura(1); var nc = new NotaDeCredito(1); var nc2 = new NotaDeCredito(2); nc.Imprimir(); nc2.Imprimir(); bool si = (fc is Factura); si = (fc is DocumentoLegal); HacerAlgoConDocumentos(nc); HacerAlgoConDocumentos(fc); var nnc = NotaDeCredito.LeerDeBaseDeDatos(); NotaDeCredito onc = null; HacerAlgoConDocumentos(onc); onc.Imprimir(); }
public void mostrarClientesMinoristas() { _clientesMinoristas = NotaDeCredito.mostrarDatosColeccionMinorista(); }
static void Main(string[] args) { /* int sueldo = 101; * int empleados = 3; * int transferencia; * int[] sueldos = new int[5]; * * sueldos[0] = 100; * sueldos[1] = 200; * transferencia= sueldo*empleados; * if (0 == (transferencia % 2)) { * Console.WriteLine("Par"); * } else { * Console.WriteLine("Impar"); * } * Console.WriteLine("Monto: " + transferencia); * * * int[] sumar = new int[10]; * int sumtotal = 0; * for(int i = 0; i<10; i++) { * sumar[i] = i; * } * * for(int i = 0; i<10; i++) { * sumtotal = sumar[i] + sumtotal; * } * Console.WriteLine(sumtotal); * if(0 == (sumtotal % 3)) { * Console.WriteLine("Número divisible por 3"); } * * * static int Division(int dividendo, int divisor) { * * int cociente = 0; * int resto = 0; * resto = dividendo - divisor * * return (resto < divisor) ? cociente : cociente++ */ int cociente = 0; var respuesta = Division(25, 3, cociente); // cociente = Division(19, 5, cociente); Console.WriteLine(respuesta.cociente2); Console.WriteLine(respuesta.resto2); // var dl = new DocumentoLegal(3); // "dl" y "fc" son objetos - update: agrego el 3 por el método constructor // update: no tengo más documento legal por no tener el método // var fc = new Factura(1); var nc = new NotaDeCredito(1); var nc2 = new NotaDeCredito(2); // Puedo tener X cantidad de instancias nc.Imprimir(); nc2.Imprimir(); // bool si = (dl is DocumentoLegal); //si = (dl is Factura); // si = (fc is Factura); // si = (fc is DocumentoLegal); HacerAlgoConDocumentos(nc); // es igual a decir "var algo = (DocumentoLegal)nc; try { var oncc = NotaDeCredito.LeerDeBaseDeDatos(); NotaDeCredito onc = null; HacerAlgoConDocumentos(onc); onc.Imprimir(); } catch (NoHayPapelException) { Console.WriteLine("Mica comprá papel."); } catch { Console.WriteLine("Error 2"); } Dictionary <int, string> ds = new Dictionary <int, string>; ds.Add(1, "Diego"); ds.Add(2, "Julian"); ds.Add(3, "Maximiliano"); string s = ds[9]; DateTime fecha = new DateTime(2019, 2, 28); fecha.AddDays(1); List <string> nombres = new List <string>(); nombres.Add("Diego"); nombres.Add("Julian"); nombres.Add("Maximiliano"); for (int idx = 0; idx < nombres.Count; idx++) { var nom = nombres[idx]; Console.WriteLine(nom); } foreach (var nom in nombres.Where((nn) => nn[0] == 'D')) //va a haber un parámetro nn de la lista string nombres { // el where devuelve un IEnumerable Console.WriteLine(nom); } string diego = "Diego"; foreach (var ch in diego) { Console.WriteLine(ch); } // Ejercicio: hacer un programa que escriba en un archivo de texto un listado de eprsonas y teléfonos. // El programa tiene que también poder leer el archivo y cargarlo en una colección //Si modifico el archivo, tengo que poder leerlo nuevamente object algo = (DocumentoLegal)nc; // object puedo referenciar cualquier cosa y 4 métodos algo = nc; algo = "Diego"; algo = 3; var facturas = new Factura[3]; facturas[0] = new Factura(1); facturas[1] = new Factura(2); facturas[2] = new Factura(3); ListaDeFacturas ListaF = new ListaDeFacturas(facturas); ListaF.Total(); var lista = new Lista <DocumentoLegal>(null); var list = new List <DocumentoLegal>(); list.Sort(); Func <int, int> f = delegate(int i){ // forma genérica de llamar a cualquier función return(i + 1); }; f(4); Func <DocumentoLegal, bool> siEsPar = delegate(DocumentoLegal dl){ // hago consulta partiendo de si el valor a revisar es par o no return((dl.Monto % 2) == 0); }; list.Where(siEsPar); // devuelve otra lista donde todos son pares Func <int, int, int> f2 = delegate(int i, int j){ return(i + 1); }; f(4); var nnc = NotaDeCredito.LeerDeBaseDeDatos(); // agrego NotaDeCredito para identificar de dónde sale el método //NotaDeCredito onc = null; // estoy generando un objeto con las propiedades de su clase, pero nula (rompe) //onc.Imprimir(); - Error más común. onc está generado con herencia pero no tiene ningún valor }
public static ResAcc<int> GenerarNotaDeCredito(int iClienteID, decimal mImporte, string sObservacion, int iOrigenID, int iRelacionID) { DateTime dAhora = DateTime.Now; // Se revisa si existen otras notas de crédito que se puedan usar para afectar ésta bool bNegativa = (mImporte < 0); var oNotas = Datos.GetListOf<NotaDeCredito>(q => q.ClienteID == iClienteID && q.Valida && q.Estatus).OrderByDescending(q => q.FechaDeEmision); foreach (var oNota in oNotas) { if ((bNegativa && oNota.Importe < 0) || (!bNegativa && oNota.Importe > 0)) continue; mImporte += oNota.Importe; if ((bNegativa && mImporte <= 0) || (!bNegativa && mImporte >= 0)) // { oNota.Valida = false; oNota.FechaDeUso = dAhora; oNota.Observacion += ("\n\n" + DateTime.Now.ToString() + "Nota cancelada por ser descontada al agregar otra nota con un importe mayor."); Datos.Guardar<NotaDeCredito>(oNota); // Se debe imprimir algo aquí ? // Si ya se emparejó la cantidad, se sale if (mImporte == 0) return new ResAcc<int>(true, ""); } else // { oNota.Importe += (mImporte * -1); Datos.Guardar<NotaDeCredito>(oNota); // Se debe imprimir algo aquí ? // Se sale, pues ya no hay importe para afectar return new ResAcc<int>(true, ""); } } // Se crea la nota var oNotaNueva = new NotaDeCredito() { FechaDeEmision = DateTime.Now, SucursalID = Theos.SucursalID, Importe = mImporte, ClienteID = iClienteID, Valida = true, Observacion = sObservacion, OrigenID = iOrigenID, RelacionID = iRelacionID }; Datos.Guardar<NotaDeCredito>(oNotaNueva); // Se imprime el ticket correspondiente return new ResAcc<int>(true, oNotaNueva.NotaDeCreditoID); }
static void Main_(string[] args) { string datilApiNotaCreditoUrl = "https://link.datil.co/credit-notes/"; // Credenciales del requerimiento string myApiKey = "xxxx"; string myPassword = "******"; // Crear requerimiento var requestOptions = new RequestOptions(); requestOptions.ApiKey = myApiKey; requestOptions.Password = myPassword; requestOptions.Url = datilApiNotaCreditoUrl + "issue"; // Información del comprador Comprador comprador = new Comprador("Juan Pérez", "0989898921001", "04", "*****@*****.**", "Calle única Numero 987", "046029400"); // Información del establecimiento Establecimiento establecimiento = new Establecimiento("001", "002", "Av. Primera 234 y calle 5ta"); // Información del emisor. Necesita de un Establecimiento. Emisor emisor = new Emisor("0910000000001", "GUGA S.A. ", "XYZ Corp", "Av.Primera 234 y calle 5ta", "12345", true, establecimiento); // Detalle de la nota de crédito y sus impuestos. var items = new List <Item>(); Item item = new Item("ZNC", "050", "Zanahoria granel 50 Kg.", 622.0, 7.01, 4360.22, 0.0); var detallesAdicionales = new Dictionary <string, string>(); detallesAdicionales.Add("Peso", "5000"); // agregar más detalles al item de ser necesario item.DetallesAdicionales = detallesAdicionales; var impuestos = new List <ImpuestoItem>(); impuestos.Add(new ImpuestoItem("2", "2", 4359.54, 523.14, 12.0)); // agregar más impuestos al item de ser necesario item.Impuestos = impuestos; items.Add(item); //agregar más items a la lista de ser necesario // Total de la nota de crédito con sus impuestos, no necesita propina. var totales = new TotalesNotaDeCredito(4359.54, 4882.68); var impuestosDeTotal = new List <Impuesto>(); impuestosDeTotal.Add(new Impuesto("2", "0", 0.0, 0.0)); impuestosDeTotal.Add(new Impuesto("2", "2", 4359.54, 523.14)); // agregar más impuestos a la lista de ser necesario. totales.Impuestos = impuestosDeTotal; // Crear nota de crédito NotaDeCredito notaDeCredito = new NotaDeCredito(); // Cabecera notaDeCredito.Secuencial = "610"; notaDeCredito.Moneda = "USD"; DateTime today = DateTime.Today; var offset = TimeZoneInfo.Local.GetUtcOffset(today); notaDeCredito.FechaEmision = new DateTimeOffset(today, offset); notaDeCredito.Ambiente = 1; notaDeCredito.TipoEmision = 1; notaDeCredito.FechaEmisionDocumentoModificado = new DateTimeOffset(today, offset); notaDeCredito.NumeroDocumentoModificado = "001-001-000012345"; notaDeCredito.TipoDocumentoModificado = "01"; notaDeCredito.Motivo = "Devolución"; //notaDeCredito.Version = //notaDeCredito.ClaveAcceso = // Informaciòn de la nota de crédito notaDeCredito.Emisor = emisor; notaDeCredito.Comprador = comprador; notaDeCredito.Totales = totales; notaDeCredito.Items = items; // Informaciòn adicional var infoAdicionalFactura = new Dictionary <string, string>(); infoAdicionalFactura.Add("Tiempo de entrega", "5 días"); notaDeCredito.InformacionAdicional = infoAdicionalFactura; // Enviar nota de crédito var respuesta = notaDeCredito.Enviar(requestOptions); Console.WriteLine("RESPUESTA:" + respuesta); // Obtener el id externo, para luego consultar el estado JObject json = JObject.Parse(respuesta); string idExterno = (string)json["id"]; Console.WriteLine("ID EXTERNO: " + idExterno); //5832e2c370414663a1bea71938a65bf0 //Consultar estado de la nota de crédito var requestOptions2 = new RequestOptions(); requestOptions2.ApiKey = myApiKey; requestOptions2.Password = myPassword; requestOptions2.Url = datilApiNotaCreditoUrl + idExterno; respuesta = NotaDeCredito.Consultar(requestOptions2); json = JObject.Parse(respuesta); string estado = (string)json["estado"]; Console.WriteLine("ESTADO: " + estado); // RECIBIDO }
static void Main(string[] args) { // Ejercicio para el hogar // Hacer una funcion Division() // que divida dos numeros enteros // SIN USAR EL OPERADOR / // Un hongo -> con una iteracion // Dos hongos -> recursivo var divide = Division(5, 2); Console.WriteLine(divide); int sueldo = 101; int empleados = 4; int transferencia; int[] sueldos = new int[10]; transferencia = sueldo * empleados; int c = Suma(1, Suma(2, 3)); int cap; var r = HacerAlgo(1, 2, out cap); var sumatoria = Sumatoria(3); //ImprimirSiEsPar(1); //ImprimirSiEsPar(2); //ImprimirSiEsPar(3); //ImprimirSiEsPar(transferencia); //Console.WriteLine("Monto: " + transferencia); Persona p = new Persona(); p.Nombre = "Luciano"; p.Apellido = "Zinik"; p.Sueldo = 100; p.Tipo = TipoEmpleado.LU; var otraP = new Persona { Nombre = "Luciano", Apellido = "Zinik", Sueldo = 100, Tipo = TipoEmpleado.LU }; //ImprimirPersona(p); if (otraP.Tipo == TipoEmpleado.Contratado) { } var fc = new Factura(1); var nc = new NotaDeCredito(1); var nc2 = new NotaDeCredito(2); nc.Imprimir(); nc2.Imprimir(); bool si = (fc is Factura); si = (fc is DocumentoLegal); var facturas = new Factura[3]; facturas[0] = new Factura(1); facturas[1] = new Factura(2); facturas[2] = new Factura(3); ListaDeFacturas listaF = new ListaDeFacturas(facturas); listaF.Total(); var lista = new Lista <DocumentoLegal>(null); var list = new List <DocumentoLegal>(); list.Sort(new CompraradorMontoDL()); var dic = new Dictionary <string, Factura>(); dic.Add("lagash#1", new Factura(1)); dic.Add("lagash#2", new Factura(2)); var fact = dic["lagash#1"]; list.Add(facturas[0]); HacerAlgoConDocumentos(nc); HacerAlgoConDocumentos(fc); Func <int, int> f = delegate(int i) { return(i + 1); }; f(4); Func <DocumentoLegal, bool> siEsPar = delegate(DocumentoLegal dl){ return((dl.Monto % 2) == 0); }; list.Where(siEsPar); list.Where(delegate(DocumentoLegal dl){ return((dl.Monto % 2) == 0); }); list.Where((dl) => (dl.Monto % 2) == 0); Func <int, int, int> f1 = delegate(int i, int j) { return(i + 1); }; Func <int> f2 = delegate() { return(1); }; object algo = (DocumentoLegal)fc; algo = nc; algo = "Diego"; algo = 3; var nnc = NotaDeCredito.LeerDeBaseDeDatos(); NotaDeCredito onc = null; HacerAlgoConDocumentos(onc); try{ onc.Imprimir(); }catch (NoHayPapelException) { Console.WriteLine("Comprar papel."); }catch { Console.WriteLine("Seguí participando."); } Dictionary <int, string> ds = new Dictionary <int, string>(); ds.Add(1, "Luciano"); ds.Add(2, "Julian"); ds.Add(9, "Martin"); string s = ds[9]; DateTime fecha = new DateTime(2019, 2, 28); fecha.AddDays(1); List <string> nombres = new List <string>(); nombres.Add("Luciano"); nombres.Add("Diego"); nombres.Add("Martin"); for (int idx = 0; idx < nombres.Count; idx++) { var nom = nombres[idx]; Console.WriteLine(nom); } foreach (var nom in nombres.Where((nn) => nn[0] == 'D')) { Console.WriteLine(nom); } // Ejercicio: // Hagan un programa que escriba en un archivo de texto // un listado de personas y telefonos // El programa tiene que tambien poder leer el archivo y cargarlo en una coleccion. // Si modifico el archivo, tengo que poder leerlo nuevamente. }