Ajustes em testes, consultas SQL e divergências de faturas
- Atualizado 4Docs_2025_07.csv com nova fatura e cabeçalho corrigido - Corrigido caminho do CSV e banco de dados nos testes de integração - Ajustada filtragem de valores para considerar aspas duplas - Comentada exclusão de registros TUSD após processamento - Consultas SQL agora usam LIKE para maior flexibilidade - Migrado para xunit v3 e atualizado Faturas.Tests.csproj - Adicionado/atualizado divergencias.csv com resultados de comparação
This commit is contained in:
parent
6848039309
commit
001c467a7c
2
Download Faturas.Tests/divergencias.csv
Normal file
2
Download Faturas.Tests/divergencias.csv
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
FaturaId Distribuidora oldConsumo_P newConsumo_P oldConsumo_FP newConsumo_FP oldDem_Reg_P newDem_Reg_P oldDem_Reg_FP newDem_Reg_FP oldEn_Reativa_Mvarh newEn_Reativa_Mvarh
|
||||||
|
3471939 0 0,46028 0 5,23094 0 8,6592 0 11,4144 0 0,04156
|
||||||
|
@ -1,19 +1,2 @@
|
|||||||
"ID" "Doc" "Status" "Invalidar" "Origin" "Last changed" "Submitted" "JSON" "Name"
|
"ID ""Doc"" ""Status"" ""Invalidar"" ""Origin"" ""Last changed"" ""Submitted"" ""JSON"" ""Name""";;;;;;;;
|
||||||
"3019848" "View | Raw" "SUCCESS" "" "BOT" "2025-11-11 10:31:03" "2025-11-11 10:30:41" "View | Raw" "1114467.pdf"
|
"3471939 ""View | Raw"" ""SUCCESS"" """" ""BOT"" ""2025-11-11 10:31:03"" ""2025-11-11 10:30:41"" ""View | Raw"" ""1114467.pdf""";;;;;;;;
|
||||||
"3001963" "View | Raw" "SUCCESS" "" "BOT" "2025-11-05 07:14:49" "2025-11-05 07:14:33" "View | Raw" "1104802.pdf"
|
|
||||||
"3001801" "View | Raw" "SUCCESS" "" "BOT" "2025-11-05 05:38:54" "2025-11-05 05:38:34" "View | Raw" "1104653.pdf"
|
|
||||||
"3001795" "View | Raw" "SUCCESS" "" "BOT" "2025-11-05 05:36:13" "2025-11-05 05:36:01" "View | Raw" "1104647.pdf"
|
|
||||||
"2993194" "View | Raw" "SUCCESS" "" "BOT" "2025-11-04 06:28:45" "2025-11-04 06:28:29" "View | Raw" "1098537.pdf"
|
|
||||||
"2988061" "View | Raw" "SUCCESS" "" "BOT" "2025-11-03 12:12:41" "2025-11-03 12:12:20" "View | Raw" "1095060.pdf"
|
|
||||||
"2987758" "View | Raw" "SUCCESS" "" "BOT" "2025-11-03 11:07:52" "2025-11-03 11:07:41" "View | Raw" "1094871.pdf"
|
|
||||||
"2987323" "View | Raw" "SUCCESS" "" "BOT" "2025-11-03 09:08:33" "2025-11-03 09:08:18" "View | Raw" "1094470.pdf"
|
|
||||||
"2987073" "View | Raw" "SUCCESS" "" "BOT" "2025-11-03 07:37:46" "2025-11-03 07:37:34" "View | Raw" "1094220.pdf"
|
|
||||||
"2924492" "View | Raw" "SUCCESS" "" "BOT" "2025-10-15 16:15:59" "2025-10-10 08:26:03" "View | Raw" "1062999.pdf"
|
|
||||||
"2906853" "View | Raw" "SUCCESS" "" "BOT" "2025-10-06 12:50:24" "2025-10-06 12:50:08" "View | Raw" "1058041.pdf"
|
|
||||||
"2906573" "View | Raw" "SUCCESS" "" "BOT" "2025-10-06 12:10:55" "2025-10-06 12:10:31" "View | Raw" "1058009.pdf"
|
|
||||||
"2905879" "View | Raw" "SUCCESS" "" "BOT" "2025-10-06 05:58:46" "2025-10-06 05:58:29" "View | Raw" "1057526.pdf"
|
|
||||||
"2903836" "View | Raw" "SUCCESS" "" "BOT" "2025-10-03 11:42:27" "2025-10-03 11:42:09" "View | Raw" "1056838.pdf"
|
|
||||||
"2901834" "View | Raw" "SUCCESS" "" "BOT" "2025-10-02 10:08:21" "2025-10-02 10:08:08" "View | Raw" "1055842.pdf"
|
|
||||||
"2901695" "View | Raw" "SUCCESS" "" "BOT" "2025-10-02 08:56:24" "2025-10-02 08:56:17" "View | Raw" "1055712.pdf"
|
|
||||||
"2901665" "View | Raw" "SUCCESS" "" "BOT" "2025-10-02 08:42:42" "2025-10-02 08:42:34" "View | Raw" "1055684.pdf"
|
|
||||||
"2901319" "View | Raw" "SUCCESS" "" "BOT" "2025-10-02 06:20:25" "2025-10-02 06:20:09" "View | Raw" "1055363.pdf"
|
|
||||||
|
@ -14,13 +14,13 @@ namespace Download_Faturas.Tests
|
|||||||
public async Task CompareFaturaWithFaturaOld_ShouldReportDifferences()
|
public async Task CompareFaturaWithFaturaOld_ShouldReportDifferences()
|
||||||
{
|
{
|
||||||
// Sample fatura IDs to test (replace with real IDs or fetch dynamically)
|
// Sample fatura IDs to test (replace with real IDs or fetch dynamically)
|
||||||
var faturaIds = LoadCsvColumn("../../../../Download Faturas.Tests/4Docs_2025_07.csv", 0);
|
var faturaIds = LoadCsvColumn("../../../../Faturas.Tests/4Docs_2025_07.csv", 0);
|
||||||
var differences = new List<string>
|
var differences = new List<string>
|
||||||
{
|
{
|
||||||
$"FaturaId\tDistribuidora\toldConsumo_P\tnewConsumo_P\toldConsumo_FP\tnewConsumo_FP\toldDem_Reg_P\tnewDem_Reg_P\toldDem_Reg_FP\tnewDem_Reg_FP\toldEn_Reativa_Mvarh\tnewEn_Reativa_Mvarh"
|
$"FaturaId\tDistribuidora\toldConsumo_P\tnewConsumo_P\toldConsumo_FP\tnewConsumo_FP\toldDem_Reg_P\tnewDem_Reg_P\toldDem_Reg_FP\tnewDem_Reg_FP\toldEn_Reativa_Mvarh\tnewEn_Reativa_Mvarh"
|
||||||
};
|
};
|
||||||
|
|
||||||
using (OleDbConnection conn = new (@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=X:/Middle/Informativo Setorial/Modelo Word/BD1_Testes.accdb;Jet OLEDB:Database Password=gds21"))
|
using (OleDbConnection conn = new (@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=X:/Middle/Informativo Setorial/Modelo Word/BD1_dados cadastrais e faturas.accdb;Jet OLEDB:Database Password=gds21"))
|
||||||
{
|
{
|
||||||
// Open the connection to the test database
|
// Open the connection to the test database
|
||||||
conn.Open();
|
conn.Open();
|
||||||
@ -51,7 +51,7 @@ namespace Download_Faturas.Tests
|
|||||||
|
|
||||||
fatura.Processar(conn); // This will also write to DB, but we want to compare without writing
|
fatura.Processar(conn); // This will also write to DB, but we want to compare without writing
|
||||||
var newVal = GetDadosTusd(conn, fatura.CodTusd);
|
var newVal = GetDadosTusd(conn, fatura.CodTusd);
|
||||||
DeleteTusdRecords(conn, fatura.CodTusd); // Delete old TUSD records before processing
|
//DeleteTusdRecords(conn, fatura.CodTusd); // Delete old TUSD records before processing
|
||||||
|
|
||||||
if (!Equals(newVal, oldVal))
|
if (!Equals(newVal, oldVal))
|
||||||
{
|
{
|
||||||
@ -126,7 +126,7 @@ namespace Download_Faturas.Tests
|
|||||||
if (line != null)
|
if (line != null)
|
||||||
{
|
{
|
||||||
var values = line.Split('\t');
|
var values = line.Split('\t');
|
||||||
if (values.Length > columnIndex && (values[4] == "\"API\"" || values[4] == "\"BOT\""))
|
if (values.Length > columnIndex && (values[4] == "\"\"API\"\"" || values[4] == "\"\"BOT\"\""))
|
||||||
{
|
{
|
||||||
columnData.Add(values[columnIndex].Replace("\"", "").Trim());
|
columnData.Add(values[columnIndex].Replace("\"", "").Trim());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,12 +6,18 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<IsTestProject>true</IsTestProject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="coverlet.collector" Version="6.0.2" />
|
<PackageReference Include="coverlet.collector" Version="6.0.2" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
|
||||||
<PackageReference Include="xunit" Version="2.9.3" />
|
<PackageReference Include="xunit.v3" Version="3.2.2" />
|
||||||
|
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -144,11 +144,11 @@ namespace Faturas
|
|||||||
|
|
||||||
dadosTusd.Mes = int.Parse(parsedResult.dates.reading.periodUntil.AddDays(-15).ToString("yMM"));
|
dadosTusd.Mes = int.Parse(parsedResult.dates.reading.periodUntil.AddDays(-15).ToString("yMM"));
|
||||||
|
|
||||||
string uc = new Regex("^0+").Replace(parsedResult.locationNumber, string.Empty).Replace("/", string.Empty).Replace("-", string.Empty).Replace(".", string.Empty);
|
string uc = "%" + new Regex("^0+").Replace(parsedResult.locationNumber, string.Empty).Replace("/", string.Empty).Replace("-", string.Empty).Replace(".", string.Empty) + "%";
|
||||||
|
|
||||||
// Vinculo da fatura com os dados cadastrais
|
// Vinculo da fatura com os dados cadastrais
|
||||||
int? unidades;
|
int? unidades;
|
||||||
string sqlQuery = $"SELECT COUNT (Cod_Smart_unidade) FROM Dados_cadastrais WHERE Codigo_Instalacao = @uc AND unidade_gerenciada";
|
string sqlQuery = $"SELECT COUNT (Cod_Smart_unidade) FROM Dados_cadastrais WHERE Codigo_Instalacao LIKE @uc AND unidade_gerenciada";
|
||||||
using (OleDbCommand cmd = new (sqlQuery, conn))
|
using (OleDbCommand cmd = new (sqlQuery, conn))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("@uc", uc);
|
cmd.Parameters.AddWithValue("@uc", uc);
|
||||||
@ -158,11 +158,12 @@ namespace Faturas
|
|||||||
}
|
}
|
||||||
if (unidades == 1)
|
if (unidades == 1)
|
||||||
{
|
{
|
||||||
sqlQuery = $"SELECT Cod_Smart_unidade, Gestao, Cliente, Unidade, PerfilCCEE, Submercado, Status_unidade, Grupo, Perfil, Distribuidora, ICMS_TUSD, Demanda_P, Demanda_FP, Caminho_NFs, Data_de_Migracao FROM Dados_cadastrais WHERE Codigo_Instalacao = @uc AND unidade_gerenciada";
|
sqlQuery = $"SELECT Cod_Smart_unidade, Gestao, Cliente, Unidade, PerfilCCEE, Submercado, Status_unidade, Grupo, Perfil, Distribuidora, ICMS_TUSD, Demanda_P, Demanda_FP, Caminho_NFs, Data_de_Migracao FROM Dados_cadastrais WHERE Codigo_Instalacao LIKE @uc AND unidade_gerenciada";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sqlQuery = $"SELECT COUNT (Cod_Smart_unidade) FROM Dados_cadastrais WHERE new_number = @uc AND unidade_gerenciada";
|
uc = parsedResult.locationNumber;
|
||||||
|
sqlQuery = $"SELECT COUNT (Cod_Smart_unidade) FROM Dados_cadastrais WHERE new_number LIKE @uc AND unidade_gerenciada";
|
||||||
using (OleDbCommand cmd = new(sqlQuery, conn))
|
using (OleDbCommand cmd = new(sqlQuery, conn))
|
||||||
{
|
{
|
||||||
cmd.Parameters.AddWithValue("@uc", uc);
|
cmd.Parameters.AddWithValue("@uc", uc);
|
||||||
@ -172,7 +173,7 @@ namespace Faturas
|
|||||||
}
|
}
|
||||||
if (unidades == 1)
|
if (unidades == 1)
|
||||||
{
|
{
|
||||||
sqlQuery = $"SELECT Cod_Smart_unidade, Gestao, Cliente, Unidade, PerfilCCEE, Submercado, Status_unidade, Grupo, Perfil, Distribuidora, ICMS_TUSD, Demanda_P, Demanda_FP, Caminho_NFs, Data_de_Migracao FROM Dados_cadastrais WHERE Codigo_Instalacao = @uc AND unidade_gerenciada";
|
sqlQuery = $"SELECT Cod_Smart_unidade, Gestao, Cliente, Unidade, PerfilCCEE, Submercado, Status_unidade, Grupo, Perfil, Distribuidora, ICMS_TUSD, Demanda_P, Demanda_FP, Caminho_NFs, Data_de_Migracao FROM Dados_cadastrais WHERE new_number LIKE @uc AND unidade_gerenciada";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user