Add sales-month planning for crops/products and fix today task label format
This commit is contained in:
@@ -6,14 +6,14 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func buildTasksForDay(plans []Plan, stepMap map[int64][]CropStep, customTasks []CustomTask, doneMap map[string]bool, month, day int) []Task {
|
||||
tasks := collectTasksForDate(plans, stepMap, customTasks, month, day, 0)
|
||||
func buildTasksForDay(plans []Plan, crops []Crop, products []Product, stepMap map[int64][]CropStep, customTasks []CustomTask, doneMap map[string]bool, month, day int) []Task {
|
||||
tasks := collectTasksForDate(plans, crops, products, stepMap, customTasks, month, day, 0)
|
||||
applyCompletion(tasks, doneMap)
|
||||
sortTasks(tasks)
|
||||
return tasks
|
||||
}
|
||||
|
||||
func buildCalendar(plans []Plan, stepMap map[int64][]CropStep, customTasks []CustomTask, doneMap map[string]bool, startMonth, startDay, daysPerMonth, spanMonths int) []CalendarMonth {
|
||||
func buildCalendar(plans []Plan, crops []Crop, products []Product, stepMap map[int64][]CropStep, customTasks []CustomTask, doneMap map[string]bool, startMonth, startDay, daysPerMonth, spanMonths int) []CalendarMonth {
|
||||
var out []CalendarMonth
|
||||
for offset := 0; offset < spanMonths; offset++ {
|
||||
month := wrapMonth(startMonth + offset)
|
||||
@@ -30,7 +30,7 @@ func buildCalendar(plans []Plan, stepMap map[int64][]CropStep, customTasks []Cus
|
||||
|
||||
var days []CalendarDay
|
||||
for d := fromDay; d <= daysPerMonth; d++ {
|
||||
items := collectTasksForDate(plans, stepMap, customTasks, month, d, yearOffset)
|
||||
items := collectTasksForDate(plans, crops, products, stepMap, customTasks, month, d, yearOffset)
|
||||
applyCompletion(items, doneMap)
|
||||
sortTasks(items)
|
||||
days = append(days, CalendarDay{Day: d, Tasks: items})
|
||||
@@ -46,12 +46,42 @@ func buildCalendar(plans []Plan, stepMap map[int64][]CropStep, customTasks []Cus
|
||||
return out
|
||||
}
|
||||
|
||||
func collectTasksForDate(plans []Plan, stepMap map[int64][]CropStep, customTasks []CustomTask, month, day, yearOffset int) []Task {
|
||||
func collectTasksForDate(plans []Plan, crops []Crop, products []Product, stepMap map[int64][]CropStep, customTasks []CustomTask, month, day, yearOffset int) []Task {
|
||||
var tasks []Task
|
||||
|
||||
for _, p := range plans {
|
||||
tasks = append(tasks, expandPlanDayTasks(p, stepMap[p.CropID], month, day, yearOffset)...)
|
||||
}
|
||||
if day == 1 {
|
||||
for _, c := range crops {
|
||||
if c.BestSaleMonth == month {
|
||||
tasks = append(tasks, Task{
|
||||
UID: fmt.Sprintf("sale:crop:%d", c.ID),
|
||||
Type: "Verkauf",
|
||||
Field: "Markt",
|
||||
Message: fmt.Sprintf("Bestpreis Feldfrucht: %s", c.Name),
|
||||
Month: month,
|
||||
Day: day,
|
||||
YearOffset: yearOffset,
|
||||
SortOrder: 35,
|
||||
})
|
||||
}
|
||||
}
|
||||
for _, p := range products {
|
||||
if p.BestSaleMonth == month {
|
||||
tasks = append(tasks, Task{
|
||||
UID: fmt.Sprintf("sale:product:%d", p.ID),
|
||||
Type: "Verkauf",
|
||||
Field: "Markt",
|
||||
Message: fmt.Sprintf("Bestpreis Produktionsgut: %s", p.Name),
|
||||
Month: month,
|
||||
Day: day,
|
||||
YearOffset: yearOffset,
|
||||
SortOrder: 36,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, c := range customTasks {
|
||||
if c.Month == month && c.Day == day && c.YearOffset == yearOffset {
|
||||
field := c.TargetName
|
||||
|
||||
Reference in New Issue
Block a user