def kpi_block(weeks=4, verbose=True, total_period=None, total_title=''): week_numbers, hours_data = operations_data(weeks, total_period, total_title) effectivity_coloring = lambda value: dependent_color( value.effectivity(), EFFECTIVITY_RED, EFFECTIVITY_GREEN) corrections_coloring = lambda value: dependent_color( value.correcties_perc(), CORRECTIONS_RED, CORRECTIONS_GREEN) return kpi_grid( week_numbers, hours_data, verbose=verbose, effectivity_coloring=effectivity_coloring, corrections_coloring=corrections_coloring, )
def render_verzuim_page(output_folder: Path): timesheet = Timesheet() months = 3 period = Period(Day().plus_months(-months)) table = VBlock([ Table( verzuim_list(period), TableConfig( headers=["Naam", "Dag", "soort", "Dagen"], aligns=["left", "left", "left", "right"], formats=[ "", "", "", ".5", ], totals=[0, 0, 0, 1], ), ), ]) verzuim = verzuimpercentage(period) verzuim_color = dependent_color(verzuim, 3, 1.5) page = Page([ TextBlock("Verzuim", HEADER_SIZE), TextBlock(f"De afgelopen {months} maanden", color=GRAY), HBlock([ VBlock([ TextBlock("Geboekte uren", DEF_SIZE, color="gray", padding=5), TextBlock("Verzuim uren", DEF_SIZE, color="gray"), TextBlock("Verzuimopercentage", DEF_SIZE, color="gray"), ]), VBlock([ TextBlock( timesheet.normal_hours(period), DEF_SIZE, text_format=".", padding=5, ), TextBlock(timesheet.absence_hours(period), DEF_SIZE, text_format="."), TextBlock(verzuim, verzuim_color, text_format="%1"), ]), ]), table, ]) page.render(output_folder / "absence.html")
def commerce_block(): minimal_interesting_amount = 20000 sales_waarde_value = sales_waarde() top_sales = top_x_sales(minimal_amount=minimal_interesting_amount) sales_waarde_color = dependent_color(sales_waarde_value, 250000, 350000) commerce = VBlock([ TextBlock("Commerce", HEADER_SIZE), TextBlock("Saleswaarde", MID_SIZE, padding=10), TextBlock( "Verwachte omzet maal kans van alle actieve<br/>salestrajecten.", color=GRAY, ), TextBlock( sales_waarde_value, HEADER_SIZE, text_format="K", color=sales_waarde_color, tooltip="Som van openstaande trajecten<br/>maal hun kans.", ), TrendLines().chart("sales_waarde", 250, 150, min_y_axis=0, x_start=months_ago(6)), VBlock( [ TextBlock(f"Top {len(top_sales)} sales kansen", MID_SIZE), TextBlock( f"Met een verwachte waarde van minimaal € {minimal_interesting_amount}.", color=GRAY, ), Table( top_sales, TableConfig(headers=[], aligns=["left", "right"], formats=["", "€"]), ), ], link="sales.html", ), # klanten_block() travelbase_block(), ]) return commerce
def verzuim_block(): period = Period(Day().plus_months(-3)) verzuim = verzuimpercentage(period) verzuim_color = dependent_color(verzuim, 3, 1.5) return VBlock( [ TextBlock("Verzuim", MID_SIZE), TextBlock("Verzuimpercentage de laatste 3 maanden", DEF_SIZE, color=GRAY), TextBlock( verzuim, MID_SIZE, text_format="%1", color=verzuim_color, tooltip= "Gemiddeld bij DDA in 2019: 3.0%. Groen bij 1,5%, rood bij 3%", ), ], link="absence.html", )
def corrections_percentage_coloring(value): return dependent_color(value, red_treshold=5, green_treshold=3)