Bug fix, über Präferenz hinazs besetzen
This commit is contained in:
1 parent
a5d4251868
commit
4b88aca958
9 files changed
+162
-48
No files matched your search
@@ -515,8 +515,8 @@ func CandidateSuggestions(
|
||||
}
|
||||
used := dayServices[person.ID+"|"+service.DateKey()]
|
||||
if len(used) > 0 && !subsetOfSingle(used, service.ID) {
|
||||
// Only explicit absences are hard blocks for manual assignments.
|
||||
warnings = append(warnings, "bereits an diesem Tag")
|
||||
blocked = true
|
||||
}
|
||||
|
||||
total := totalCounts[person.ID]
|
||||
|
||||
@@ -159,6 +159,55 @@ func TestCandidateSuggestionsAllowPreferenceOverrides(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCandidateSuggestionsAllowMaxLimitOverride(t *testing.T) {
|
||||
service := ServiceOccurrence{
|
||||
ID: "s2", ChurchID: "c1", Date: MustDate("2026-11-17"),
|
||||
TimeMinutes: 18 * 60, Title: "Abendmesse", LectorsNeeded: 1,
|
||||
}
|
||||
earlier := ServiceOccurrence{
|
||||
ID: "s1", ChurchID: "c1", Date: MustDate("2026-11-16"),
|
||||
TimeMinutes: 18 * 60, Title: "Abendmesse", LectorsNeeded: 1,
|
||||
}
|
||||
person := Person{
|
||||
ID: "p1", FirstName: "Anna", LastName: "Berg", Roles: []Role{RoleLector},
|
||||
Active: true, MaxPerMonth: 1,
|
||||
}
|
||||
existing := []Assignment{{
|
||||
ID: "a1", ServiceID: earlier.ID, PersonID: person.ID, Role: RoleLector,
|
||||
}}
|
||||
suggestions := CandidateSuggestions(service, RoleLector,
|
||||
[]Person{person}, nil, existing, []ServiceOccurrence{earlier, service}, nil, nil)
|
||||
if len(suggestions) != 1 || suggestions[0].Blocked || !suggestions[0].BeyondPreferences {
|
||||
t.Fatalf("manual suggestions should allow exceeding the monthly limit with a warning, got %#v", suggestions)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCandidateSuggestionsAllowSameDayConflict(t *testing.T) {
|
||||
service := ServiceOccurrence{
|
||||
ID: "s2", ChurchID: "c1", Date: MustDate("2026-11-16"),
|
||||
TimeMinutes: 18 * 60, Title: "Abendmesse", LectorsNeeded: 1,
|
||||
}
|
||||
earlier := ServiceOccurrence{
|
||||
ID: "s1", ChurchID: "c1", Date: MustDate("2026-11-16"),
|
||||
TimeMinutes: 9 * 60, Title: "Frühmesse", LectorsNeeded: 1,
|
||||
}
|
||||
person := Person{
|
||||
ID: "p1", FirstName: "Anna", LastName: "Berg", Roles: []Role{RoleLector},
|
||||
Active: true, MaxPerMonth: 6,
|
||||
}
|
||||
existing := []Assignment{{
|
||||
ID: "a1", ServiceID: earlier.ID, PersonID: person.ID, Role: RoleLector,
|
||||
}}
|
||||
suggestions := CandidateSuggestions(service, RoleLector,
|
||||
[]Person{person}, nil, existing, []ServiceOccurrence{earlier, service}, nil, nil)
|
||||
if len(suggestions) != 1 || suggestions[0].Blocked {
|
||||
t.Fatalf("only absences should hard-block manual suggestions, got %#v", suggestions)
|
||||
}
|
||||
if !StringContains(suggestions[0].Warnings, "bereits an diesem Tag") {
|
||||
t.Fatalf("same-day conflict should still be warned about, got %#v", suggestions[0].Warnings)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCandidateSuggestionsBlockAbsences(t *testing.T) {
|
||||
service := ServiceOccurrence{
|
||||
ID: "s1", ChurchID: "c1", Date: MustDate("2026-11-16"),
|
||||
|
||||
+7
-5
@@ -291,7 +291,7 @@ func FullPlan(w io.Writer, r domain.DayRange, rows []domain.DayPlanRow, churches
|
||||
columns = columns[:4]
|
||||
}
|
||||
|
||||
drawHeader := func() {
|
||||
drawHeader := func(showTitle bool) {
|
||||
setColor(pdf, colors.accent)
|
||||
pdf.SetFont("Helvetica", "B", 6.4)
|
||||
pdf.SetXY(margin, margin)
|
||||
@@ -299,8 +299,10 @@ func FullPlan(w io.Writer, r domain.DayRange, rows []domain.DayPlanRow, churches
|
||||
|
||||
setColor(pdf, colors.ink)
|
||||
pdf.SetFont("Times", "B", 15.5)
|
||||
pdf.SetXY(margin, margin+4.6)
|
||||
pdf.CellFormat(150, 7, tr("Gottesdienstplan"), "", 0, "L", false, 0, "")
|
||||
if showTitle {
|
||||
pdf.SetXY(margin, margin+4.6)
|
||||
pdf.CellFormat(150, 7, tr("Gottesdienstplan"), "", 0, "L", false, 0, "")
|
||||
}
|
||||
|
||||
setColor(pdf, colors.secondary)
|
||||
pdf.SetFont("Helvetica", "", 8.2)
|
||||
@@ -370,7 +372,7 @@ func FullPlan(w io.Writer, r domain.DayRange, rows []domain.DayPlanRow, churches
|
||||
}
|
||||
|
||||
pdf.AddPage()
|
||||
drawHeader()
|
||||
drawHeader(true)
|
||||
drawColumnHeader()
|
||||
page := 1
|
||||
y := contentTop
|
||||
@@ -388,7 +390,7 @@ func FullPlan(w io.Writer, r domain.DayRange, rows []domain.DayPlanRow, churches
|
||||
drawFooter(page)
|
||||
page++
|
||||
pdf.AddPage()
|
||||
drawHeader()
|
||||
drawHeader(false)
|
||||
drawColumnHeader()
|
||||
y = contentTop
|
||||
}
|
||||
|
||||
@@ -222,6 +222,9 @@ func TestFullPlanPaginatesWithTotalPageCount(t *testing.T) {
|
||||
if strings.Contains(content, "Fortsetzung") {
|
||||
t.Fatal("continuation title must not appear on later pages")
|
||||
}
|
||||
if got := strings.Count(content, "Gottesdienstplan"); got != 1 {
|
||||
t.Fatalf("large title appears %d times, want only on the first page", got)
|
||||
}
|
||||
match := regexp.MustCompile(`Seite 1 von (\d+)`).FindStringSubmatch(content)
|
||||
if match == nil {
|
||||
t.Fatalf("first page footer is missing the total page count:\n%s", content)
|
||||
|
||||
Reference in new issue
Block a user