Skip to content

Commit

Permalink
attendant: move limit for lines and size to plan
Browse files Browse the repository at this point in the history
  • Loading branch information
darakeon committed Oct 12, 2024
1 parent 233bbc8 commit 7e07ccc
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 634 deletions.
4 changes: 2 additions & 2 deletions core/BusinessLogic/Exceptions/Error.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ public enum Error
LogNotFound = 900,

EmptyArchive = 1000,
InvalidArchiveSize = 1002,
InvalidArchiveLines = 1003,
InvalidArchiveColumn = 1001,
ArchiveNotFound = 1004,
LineNotFound = 1005,
Expand All @@ -133,6 +131,8 @@ public enum Error
PlanLimitCategoryEnabledAchieved = 1202,
PlanLimitDetailByParentAchieved = 1205,
PlanLimitArchiveUploadMonthAchieved = 1206,
PlanLimitLineByArchiveAchieved = 1207,
PlanLimitSizeByArchiveAchieved = 1208,
}

public static class ErrorX
Expand Down
6 changes: 3 additions & 3 deletions core/BusinessLogic/Services/AttendantService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ internal AttendantService(ServiceAccess serviceAccess, Repos repos, Valids valid
private readonly IDictionary<ImporterError, Error> importErrors =
new Dictionary<ImporterError, Error>
{
{ ImporterError.Size, Error.InvalidArchiveSize },
{ ImporterError.Lines, Error.InvalidArchiveLines },
{ ImporterError.Size, Error.PlanLimitSizeByArchiveAchieved },
{ ImporterError.Lines, Error.PlanLimitLineByArchiveAchieved },
{ ImporterError.Header, Error.InvalidArchiveColumn },
{ ImporterError.Empty, Error.EmptyArchive },
{ ImporterError.DateRequired, Error.MoveDateRequired },
Expand Down Expand Up @@ -188,7 +188,7 @@ public void ImportMovesFile(String filename, String csv)
private CSVImporter validateArchive(String filename, String csv, User user)
{
using var error = new CoreError();
var importer = new CSVImporter(csv);
var importer = new CSVImporter(user.Control.Plan, csv);

if (!filename.EndsWith(".csv"))
{
Expand Down
2 changes: 0 additions & 2 deletions core/Entities/Bases/MaxLen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public class MaxLen

public const Int16 SettingsLanguage = 5;

public const Int32 ArchiveSize = 352101;
public const Int16 ArchiveLines = 200;
public const Int16 ArchiveFileName = 255;

public const Int16 PlanName = 20;
Expand Down
1 change: 1 addition & 0 deletions core/Entities/Plan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class Plan : IEntityLong
public virtual Int32 DetailByParent { get; set; }
public virtual Int32 ArchiveUploadMonth { get; set; }
public virtual Int32 LineByArchive { get; set; }
public virtual Int32 SizeByArchive { get; set; }
public virtual Int32 OrderByMonth { get; set; }
public virtual Int32 MoveByOrder { get; set; }

Expand Down
8 changes: 4 additions & 4 deletions core/Exchange/Importer/CSVImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
using CsvHelper;
using CsvHelper.Configuration;
using CsvHelper.TypeConversion;
using DFM.Entities.Bases;
using DFM.Entities;

namespace DFM.Exchange.Importer
{
public class CSVImporter
{
public CSVImporter(String content)
public CSVImporter(Plan plan, string content)
{
if (content.Length > MaxLen.ArchiveSize)
if (content.Length > plan.SizeByArchive)
{
ErrorList.Add(0, ImporterError.Size);
return;
Expand Down Expand Up @@ -52,7 +52,7 @@ public CSVImporter(String content)
}
}

if (line > MaxLen.ArchiveLines)
if (line > plan.LineByArchive)
{
ErrorList.Add(0, ImporterError.Lines);
}
Expand Down
8 changes: 4 additions & 4 deletions core/Language/Language/Site/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@
"MoveDetailValueInvalid": "Move detail value is invalid",
"MoveDetailConversionInvalid": "Move detail conversion is invalid",
"EmptyArchive": "Invalid archive",
"InvalidArchiveSize": "Too big file size, try break into files with 300kb or less",
"InvalidArchiveLines": "The allowed amount for import files is 200 lines at most each file",
"InvalidArchiveColumn": "Invalid archive column",
"ArchiveNotFound": "Archive not found",
"LineNotFound": "Line not found",
Expand All @@ -135,6 +133,8 @@
"PlanLimitCategoryEnabledAchieved": "Limit for Categories enabled achieved. To create or enable Categories you need to disable some of the enabled Categories.",
"PlanLimitDetailByParentAchieved": "The Details quantity exceed the allowed limit.",
"PlanLimitArchiveUploadMonthAchieved": "Limit for Archives upload per month achieved. Wait to the next month to upload more Archives.",
"PlanLimitLineByArchiveAchieved": "The Lines quantity exceed the allowed limit",
"PlanLimitSizeByArchiveAchieved": "Too big file size, try break into smaller files",
"": null
},
"pt-BR": {
Expand Down Expand Up @@ -251,8 +251,6 @@
"MoveDetailValueInvalid": "Valor do detalhe da movimentação inválido",
"MoveDetailConversionInvalid": "Conversão do detalhe da movimentação inválida",
"EmptyArchive": "Arquivo inválido",
"InvalidArchiveSize": "Arquivo muito grande, tente quebrar em arquivos de 300kb ou menos",
"InvalidArchiveLines": "A quantidade permitida para importar arquivos é 200 linhas no máximo por arquivo",
"InvalidArchiveColumn": "Coluna inválida no arquivo",
"ArchiveNotFound": "Arquivo não encontrado",
"LineNotFound": "Linha não encontrada",
Expand All @@ -273,6 +271,8 @@
"PlanLimitCategoryEnabledAchieved": "O limite de Categorias ativas atingido. Para criar ou reativar Categorias é necessário desativar alguma das Categorias ativar.",
"PlanLimitDetailByParentAchieved": "A quantidade de Detalhes ultrapassa a quantidade permitida.",
"PlanLimitArchiveUploadMonthAchieved": "O limite de Arquivos subidos atingido. Espere o próximo mês para subir mais Arquivos.",
"PlanLimitLineByArchiveAchieved": "A quantidade de Linhas ultrapassa a quantidade permitida",
"PlanLimitSizeByArchiveAchieved": "Arquivo muito grande, tente quebrar em arquivos menores",
"": null
}
}
201 changes: 0 additions & 201 deletions core/Tests/BusinessLogic/CSVExamples/allowed_file_size_and_lines.csv

This file was deleted.

Loading

0 comments on commit 7e07ccc

Please sign in to comment.