Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35919.96 d17.13
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Procesamiento_de_transacciones_bancarias", "Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias.csproj", "{1D6E76A8-4868-456C-96A1-BF186D857D78}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1D6E76A8-4868-456C-96A1-BF186D857D78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D6E76A8-4868-456C-96A1-BF186D857D78}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D6E76A8-4868-456C-96A1-BF186D857D78}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D6E76A8-4868-456C-96A1-BF186D857D78}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4ED08311-A3F1-4DA7-9510-95812FFA996A}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//--Iniciamos el aplicativo preguntando por la ruta del archivo
using System.Globalization;

//-- creamos la clase transaccion para manejar mejor los datos de cada transaccion

class Transaccion
{
public int Id { get; set; }
public string Tipo { get; set; }
public double Monto { get; set; }
}

class Programa
{
static void Main()
{
Console.WriteLine("Introduce la ruta del archivo CSV:");
String ruta = Console.ReadLine(); //-- solicitamos la dirección del archivo CSV

if(string.IsNullOrWhiteSpace(ruta)|| !File.Exists(ruta)) //-- se comprueba que el archivo exista y la ruta no este en blanco
{
Console.WriteLine("Ruta invalida o el archivo no existe.");
return;
}

var lineas = File.ReadAllLines(ruta); //-- lee todas las lineas del archivo y las almacena

if(lineas.Length<=1)
{
Console.WriteLine("El archivo esta vacío o solo contiene encabezados");
}


List<Transaccion> transacciones = new(); //-- creamos una lista para almacenar cada transacción

for (int i = 1; i < lineas.Length; i++)
{
var campos = lineas[i].Split(','); //-- separamos cada campo separado por una coma ','

if(campos.Length < 3)
continue; //-- saltamos lineas que no esten formateadas correctamente

if (!int.TryParse(campos[0].Trim(), out int id)) continue; //-- si el formato del ID no es un numero entero lo saltamos

string tipo = campos[1].Trim();

if (!double.TryParse(campos[2].Trim(), NumberStyles.Any, CultureInfo.InvariantCulture, out double monto)) continue; //- si los numeros estan mal escritos saltamos linea

transacciones.Add(new Transaccion { Id = id, Tipo = tipo, Monto = monto }); //-- etiquetamos y guardamos los datos en la lista

}

var creditos = transacciones.Where(t => t.Tipo.Equals("Crédito", StringComparison.OrdinalIgnoreCase)); //-- filtramos y almacenamos por tipo las transacciones y las almacenamos en una variable
var debitos = transacciones.Where(t => t.Tipo.Equals("Débito", StringComparison.OrdinalIgnoreCase));
var mayor = transacciones.OrderByDescending(t => t.Monto).FirstOrDefault(); //- ordenamos las transsaciones de mayor a menor para obtener la transaación más alta

//-- dentro de las variables antes creadas vamos a sumar todos los montos almacenados para guardarlos en variables para optimizar su manejo
double montoCredito = creditos.Sum(t => t.Monto);
double montoDebito = debitos.Sum(t => t.Monto);
double balanceFinal = montoCredito - montoDebito;


//-- por último imprimimos el reporte final
Console.WriteLine("\nReporte de transacción");
Console.WriteLine("-------------------");
Console.WriteLine($"Balance final: {balanceFinal:F2}");
if (mayor != null)
Console.WriteLine($"Transacción de mayor monto: ID {mayor.Id} - {mayor.Monto:F2}");

Console.WriteLine($"Conteo de transacciones: Crédito: {creditos.Count()}, Débito: {debitos.Count()}");




Console.WriteLine("Presione la tecla (y) si desea generar un archivo CSV con su reporte");
if (Console.ReadLine()=="y")
{
//-- crearemos un reporte en archivo CSV
string[] reporte = new[]
{
"Resumen de transacciones:",
$"Balance final,{balanceFinal:F2}",
$"Mayor transacción,ID {mayor.Id},{mayor.Monto:F2}",
$"Total Créditos,{creditos.Count()},{montoCredito:F2}",
$"Total Débitos,{debitos.Count()},{montoDebito:F2}"
};

File.WriteAllLines("reporte.csv", reporte);
//-- genera el archivo CSV y copia todas las lineas del arreglo reporte
//-- el reporte sera guardado el la carpeta del ejecutable del proyecto
Console.WriteLine("Reporte generado: reporte.csv");
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"Procesamiento_de_transacciones_bancarias/1.0.0": {
"runtime": {
"Procesamiento_de_transacciones_bancarias.dll": {}
}
}
}
},
"libraries": {
"Procesamiento_de_transacciones_bancarias/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Resumen de transacciones:
Balance final,10985.85
Mayor transacción,ID 222,499.69
Total Créditos,508,135415.52
Total Débitos,492,124429.67
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Este código fue generado por una herramienta.
// Versión de runtime:4.0.30319.42000
//
// Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si
// se vuelve a generar el código.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("Procesamiento_de_transacciones_bancarias")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Procesamiento_de_transacciones_bancarias")]
[assembly: System.Reflection.AssemblyTitleAttribute("Procesamiento_de_transacciones_bancarias")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generado por la clase WriteCodeFragment de MSBuild.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
83196cf65e4d04019f7f439d06872ed6eeeb3fc74d882f356a6dd0b57b81e81d
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Procesamiento_de_transacciones_bancarias
build_property.ProjectDir = C:\Users\USUARIO\Downloads\reto tecnico\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 8.0
build_property.EnableCodeStyleSeverity =
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3d126ec64c238589b0b6bb236fa2f6fc4ebdd4a8a2ab5ae9fb553d8605a12ca2
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
C:\Users\USUARIO\Downloads\c#\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\bin\Debug\net8.0\Procesamiento_de_transacciones_bancarias.exe
C:\Users\USUARIO\Downloads\c#\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\bin\Debug\net8.0\Procesamiento_de_transacciones_bancarias.deps.json
C:\Users\USUARIO\Downloads\c#\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\bin\Debug\net8.0\Procesamiento_de_transacciones_bancarias.runtimeconfig.json
C:\Users\USUARIO\Downloads\c#\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\bin\Debug\net8.0\Procesamiento_de_transacciones_bancarias.dll
C:\Users\USUARIO\Downloads\c#\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\bin\Debug\net8.0\Procesamiento_de_transacciones_bancarias.pdb
C:\Users\USUARIO\Downloads\c#\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\Procesamiento_de_transacciones_bancarias.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\USUARIO\Downloads\c#\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\Procesamiento_de_transacciones_bancarias.AssemblyInfoInputs.cache
C:\Users\USUARIO\Downloads\c#\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\Procesamiento_de_transacciones_bancarias.AssemblyInfo.cs
C:\Users\USUARIO\Downloads\c#\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\Procesamiento_de_transacciones_bancarias.csproj.CoreCompileInputs.cache
C:\Users\USUARIO\Downloads\c#\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\Procesamiento_de_transacciones_bancarias.dll
C:\Users\USUARIO\Downloads\c#\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\refint\Procesamiento_de_transacciones_bancarias.dll
C:\Users\USUARIO\Downloads\c#\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\Procesamiento_de_transacciones_bancarias.pdb
C:\Users\USUARIO\Downloads\c#\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\Procesamiento_de_transacciones_bancarias.genruntimeconfig.cache
C:\Users\USUARIO\Downloads\c#\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\ref\Procesamiento_de_transacciones_bancarias.dll
C:\Users\USUARIO\Downloads\reto tecnico\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\bin\Debug\net8.0\Procesamiento_de_transacciones_bancarias.exe
C:\Users\USUARIO\Downloads\reto tecnico\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\bin\Debug\net8.0\Procesamiento_de_transacciones_bancarias.deps.json
C:\Users\USUARIO\Downloads\reto tecnico\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\bin\Debug\net8.0\Procesamiento_de_transacciones_bancarias.runtimeconfig.json
C:\Users\USUARIO\Downloads\reto tecnico\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\bin\Debug\net8.0\Procesamiento_de_transacciones_bancarias.dll
C:\Users\USUARIO\Downloads\reto tecnico\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\bin\Debug\net8.0\Procesamiento_de_transacciones_bancarias.pdb
C:\Users\USUARIO\Downloads\reto tecnico\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\Procesamiento_de_transacciones_bancarias.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\USUARIO\Downloads\reto tecnico\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\Procesamiento_de_transacciones_bancarias.AssemblyInfoInputs.cache
C:\Users\USUARIO\Downloads\reto tecnico\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\Procesamiento_de_transacciones_bancarias.AssemblyInfo.cs
C:\Users\USUARIO\Downloads\reto tecnico\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\Procesamiento_de_transacciones_bancarias.csproj.CoreCompileInputs.cache
C:\Users\USUARIO\Downloads\reto tecnico\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\Procesamiento_de_transacciones_bancarias.dll
C:\Users\USUARIO\Downloads\reto tecnico\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\refint\Procesamiento_de_transacciones_bancarias.dll
C:\Users\USUARIO\Downloads\reto tecnico\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\Procesamiento_de_transacciones_bancarias.pdb
C:\Users\USUARIO\Downloads\reto tecnico\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\Procesamiento_de_transacciones_bancarias.genruntimeconfig.cache
C:\Users\USUARIO\Downloads\reto tecnico\Procesamiento_de_transacciones_bancarias\Procesamiento_de_transacciones_bancarias\obj\Debug\net8.0\ref\Procesamiento_de_transacciones_bancarias.dll
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3cec902a70eebfe898ff270814a8e596a8943f45a43d86452a4ffac22260a7d9
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"format": 1,
"restore": {
"C:\\Users\\USUARIO\\Downloads\\reto tecnico\\Procesamiento_de_transacciones_bancarias\\Procesamiento_de_transacciones_bancarias\\Procesamiento_de_transacciones_bancarias.csproj": {}
},
"projects": {
"C:\\Users\\USUARIO\\Downloads\\reto tecnico\\Procesamiento_de_transacciones_bancarias\\Procesamiento_de_transacciones_bancarias\\Procesamiento_de_transacciones_bancarias.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\USUARIO\\Downloads\\reto tecnico\\Procesamiento_de_transacciones_bancarias\\Procesamiento_de_transacciones_bancarias\\Procesamiento_de_transacciones_bancarias.csproj",
"projectName": "Procesamiento_de_transacciones_bancarias",
"projectPath": "C:\\Users\\USUARIO\\Downloads\\reto tecnico\\Procesamiento_de_transacciones_bancarias\\Procesamiento_de_transacciones_bancarias\\Procesamiento_de_transacciones_bancarias.csproj",
"packagesPath": "C:\\Users\\USUARIO\\.nuget\\packages\\",
"outputPath": "C:\\Users\\USUARIO\\Downloads\\reto tecnico\\Procesamiento_de_transacciones_bancarias\\Procesamiento_de_transacciones_bancarias\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\USUARIO\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net8.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
},
"SdkAnalysisLevel": "9.0.200"
},
"frameworks": {
"net8.0": {
"targetAlias": "net8.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.201/PortableRuntimeIdentifierGraph.json"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\USUARIO\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.13.2</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\USUARIO\.nuget\packages\" />
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
Loading