diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..bf4ae11 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module bot-pontos + +go 1.25.0 diff --git a/internal/domain/point.go b/internal/domain/point.go new file mode 100644 index 0000000..0b4d917 --- /dev/null +++ b/internal/domain/point.go @@ -0,0 +1,14 @@ +package domain + +import "time" + +type NotificationType string + +const ( + NotificationEntrada2 NotificationType = "entrada2" + NotificationSaida2 NotificationType = "saida2" +) + +type Point struct { + Time time.Time +} \ No newline at end of file diff --git a/internal/rules/business_day.go b/internal/rules/business_day.go new file mode 100644 index 0000000..8fdc53f --- /dev/null +++ b/internal/rules/business_day.go @@ -0,0 +1,10 @@ +package rules + +import "time" + +type BusinessDayChecker struct{} + +func (b BusinessDayChecker) IsBusinessDay(t time.Time) bool { + weekday := t.Weekday() + return weekday != time.Saturday && weekday != time.Sunday +} \ No newline at end of file diff --git a/internal/rules/schedule_calculator.go b/internal/rules/schedule_calculator.go new file mode 100644 index 0000000..e69de29 diff --git a/tests/rules_test.go b/tests/rules_test.go new file mode 100644 index 0000000..dece8dd --- /dev/null +++ b/tests/rules_test.go @@ -0,0 +1,29 @@ +package tests + +import ( + "testing" + "time" + + "bot-pontos/internal/rules" +) + +func TestCalculosDeJornada(t *testing.T) { + loc, _ := time.LoadLocation("America/Sao_Paulo") + + // Teste Entrada 2 (Saída1 + 55min) + saida1 := time.Date(2026, 8, 15, 12, 0, 0, 0, loc) + esperadoEntrada2 := time.Date(2026, 8, 15, 12, 55, 0, 0, loc) + if res := rules.CalculateEntrada2(saida1); !res.Equal(esperadoEntrada2) { + t.Errorf("Entrada2 incorreta. Esperado: %v, Obtido: %v", esperadoEntrada2, res) + } + + // Teste Saída 2 (Meta 7h55) + entrada1 := time.Date(2026, 8, 15, 8, 0, 0, 0, loc) + entrada2 := time.Date(2026, 8, 15, 13, 0, 0, 0, loc) + // Trabalhou 4h de manhã. Faltam 3h55. Saída2 deve ser 16:55 + esperadoSaida2 := time.Date(2026, 8, 15, 16, 55, 0, 0, loc) + + if res := rules.CalculateSaida2(entrada1, saida1, entrada2); !res.Equal(esperadoSaida2) { + t.Errorf("Saida2 incorreta. Esperado: %v, Obtido: %v", esperadoSaida2, res) + } +} \ No newline at end of file