From 67087bce1ff05a8e647ea7df2cef529704ea2a42 Mon Sep 17 00:00:00 2001 From: Eduardo Lopes <155753879+eduardolopesx03@users.noreply.github.com> Date: Mon, 2 Feb 2026 14:57:15 -0300 Subject: [PATCH 1/3] Fix parcelamento detail dto inheritance --- Dtos/ParcelamentosDtos.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dtos/ParcelamentosDtos.cs b/Dtos/ParcelamentosDtos.cs index 53d73b6..a1238fa 100644 --- a/Dtos/ParcelamentosDtos.cs +++ b/Dtos/ParcelamentosDtos.cs @@ -1,6 +1,6 @@ namespace line_gestao_api.Dtos; -public sealed class ParcelamentoListDto +public class ParcelamentoListDto { public Guid Id { get; set; } public int? AnoRef { get; set; } From fa669f9332982171f068bd66aeef0ed55e4e8ccf Mon Sep 17 00:00:00 2001 From: Eduardo Lopes <155753879+eduardolopesx03@users.noreply.github.com> Date: Mon, 2 Feb 2026 15:26:21 -0300 Subject: [PATCH 2/3] Require auth for Excel import --- Controllers/LinesController.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Controllers/LinesController.cs b/Controllers/LinesController.cs index ed8ce63..d9269d1 100644 --- a/Controllers/LinesController.cs +++ b/Controllers/LinesController.cs @@ -3,6 +3,7 @@ using line_gestao_api.Data; using line_gestao_api.Dtos; using line_gestao_api.Models; using line_gestao_api.Services; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -503,6 +504,7 @@ namespace line_gestao_api.Controllers // ✅ 8. IMPORT EXCEL // ========================================================== [HttpPost("import-excel")] + [Authorize] [Consumes("multipart/form-data")] [RequestSizeLimit(50_000_000)] public async Task> ImportExcel([FromForm] ImportExcelForm form) From 2500278b1fbeb0ba4c76c829a18adc5a0310b0ea Mon Sep 17 00:00:00 2001 From: Eduardo Lopes <155753879+eduardolopesx03@users.noreply.github.com> Date: Mon, 2 Feb 2026 15:47:25 -0300 Subject: [PATCH 3/3] Harden parcelamentos import column detection --- Services/ParcelamentosImportService.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Services/ParcelamentosImportService.cs b/Services/ParcelamentosImportService.cs index c1a5671..c4f6f2f 100644 --- a/Services/ParcelamentosImportService.cs +++ b/Services/ParcelamentosImportService.cs @@ -62,13 +62,15 @@ public sealed class ParcelamentosImportService var map = BuildHeaderMap(headerRow); var colLinha = GetCol(map, "LINHA"); + var colAnoRef = GetColAny(map, "ANO REF", "ANOREF", "ANO REF.", "ANO REFERENCIA", "ANO REFERÊNCIA"); + var colItem = GetCol(map, "ITEM"); var colCliente = GetCol(map, "CLIENTE"); var colQtParcelas = GetColAny(map, "QT PARCELAS", "QT. PARCELAS", "QT PARCELAS (NN/TT)", "QTDE PARCELAS"); var colValorCheio = GetColAny(map, "VALOR CHEIO"); var colDesconto = GetColAny(map, "DESCONTO"); var colValorComDesconto = GetColAny(map, "VALOR C/ DESCONTO", "VALOR COM DESCONTO"); - if (colLinha == 0 || colValorComDesconto == 0) + if (colLinha == 0 || colValorComDesconto == 0 || colAnoRef == 0 || colItem == 0) { return new ParcelamentosImportSummaryDto { @@ -77,7 +79,7 @@ public sealed class ParcelamentosImportService new ParcelamentosImportErrorDto { LinhaExcel = headerRowIndex, - Motivo = "Colunas obrigatórias não encontradas (LINHA / VALOR C/ DESCONTO)." + Motivo = "Colunas obrigatórias não encontradas (LINHA / ANO REF / ITEM / VALOR C/ DESCONTO)." } } }; @@ -99,7 +101,7 @@ public sealed class ParcelamentosImportService for (int row = headerRowIndex + 1; row <= lastRow; row++) { var linhaValue = GetCellString(ws, row, colLinha); - var itemStr = GetCellString(ws, row, 4); + var itemStr = GetCellString(ws, row, colItem); if (string.IsNullOrWhiteSpace(itemStr) && string.IsNullOrWhiteSpace(linhaValue)) { break; @@ -107,7 +109,7 @@ public sealed class ParcelamentosImportService summary.Lidos++; - var anoRef = TryNullableInt(GetCellString(ws, row, 3)); + var anoRef = TryNullableInt(GetCellString(ws, row, colAnoRef)); var item = TryNullableInt(itemStr); if (!item.HasValue) @@ -127,7 +129,7 @@ public sealed class ParcelamentosImportService { LinhaExcel = row, Motivo = "AnoRef inválido ou vazio.", - Valor = GetCellString(ws, row, 3) + Valor = GetCellString(ws, row, colAnoRef) }); continue; } @@ -201,7 +203,12 @@ public sealed class ParcelamentosImportService private static IXLWorksheet? FindWorksheet(XLWorkbook wb) { return wb.Worksheets.FirstOrDefault(w => NormalizeHeader(w.Name) == NormalizeHeader("PARCELAMENTOS DE APARELHOS")) - ?? wb.Worksheets.FirstOrDefault(w => NormalizeHeader(w.Name) == NormalizeHeader("PARCELAMENTOS")); + ?? wb.Worksheets.FirstOrDefault(w => NormalizeHeader(w.Name) == NormalizeHeader("PARCELAMENTOS")) + ?? wb.Worksheets.FirstOrDefault(w => + { + var normalized = NormalizeHeader(w.Name); + return normalized.Contains("PARCELAMENTO") || normalized.Contains("PARCELAMENTOS") || normalized.Contains("PARECALEMENTO"); + }); } private static int FindHeaderRow(IXLWorksheet ws)