translator_directory.views.time_report
Functions
|
|
|
|
|
Using just a normal request.warning gets suppressed. |
|
Accept time report. |
|
Calculate accounting values for a time report. |
Generate CSV rows for accounting export in the required format. |
|
|
Export confirmed time reports as CSV for accounting. |
|
|
|
|
|
Module Contents
- translator_directory.views.time_report.view_time_reports(self: onegov.translator_directory.collections.time_report.TimeReportCollection, request: onegov.translator_directory.request.TranslatorAppRequest) onegov.core.types.RenderData[source]
- translator_directory.views.time_report.edit_time_report(self: onegov.translator_directory.models.time_report.TranslatorTimeReport, request: onegov.translator_directory.request.TranslatorAppRequest, form: onegov.translator_directory.forms.time_report.TranslatorTimeReportForm) onegov.core.types.RenderData | webob.Response[source]
- translator_directory.views.time_report.show_warning_for_intercooler(request: onegov.translator_directory.request.TranslatorAppRequest, message: str) webob.Response[source]
Using just a normal request.warning gets suppressed. So we use this.
- translator_directory.views.time_report.accept_time_report(self: onegov.translator_directory.models.ticket.TimeReportTicket, request: onegov.translator_directory.request.TranslatorAppRequest) webob.Response[source]
Accept time report.
- translator_directory.views.time_report.calculate_accounting_values(report: onegov.translator_directory.models.time_report.TranslatorTimeReport) tuple[decimal.Decimal, decimal.Decimal, decimal.Decimal][source]
Calculate accounting values for a time report.
The L001 CSV format supports: hours × rate = compensation But translator compensation is complex:
Night work: +50% surcharge (20:00-06:00)
Weekend/holiday: +25% surcharge (non-night hours only)
Urgent assignments: +25% on all work
Break time: deducted at base rate
We cannot export the breakdown as separate line items because of break time. Break time is negative numbers which are probably not supported by the accounting system.
Instead, we back-calculate an effective hourly rate that, when multiplied by total hours, produces the correct total. We have tests that validate the result is the same in both directions.
- Example:
8h total (6 day + 2 night), CHF 100/h base, weekend work Actual: 6×100 + 2×150 + 6×25 - 0.5×100 = CHF 1’000 Export: 8h × CHF 125/h = CHF 1’000
- Returns:
tuple of (duration_hours, effective_rate, recalculated_subtotal) where recalculated_subtotal = duration_hours * effective_rate
The recalculated_subtotal should match breakdown[‘adjusted_subtotal’] within rounding tolerance.
- translator_directory.views.time_report.generate_accounting_export_rows(reports: list[onegov.translator_directory.models.time_report.TranslatorTimeReport]) collections.abc.Iterator[list[str]][source]
Generate CSV rows for accounting export in the required format.
- translator_directory.views.time_report.export_accounting_csv(self: onegov.translator_directory.collections.time_report.TimeReportCollection, request: onegov.translator_directory.request.TranslatorAppRequest) webob.Response[source]
Export confirmed time reports as CSV for accounting.
- translator_directory.views.time_report.generate_time_report_pdf_bytes(time_report: onegov.translator_directory.models.time_report.TranslatorTimeReport, translator: onegov.translator_directory.models.translator.Translator, request: onegov.translator_directory.request.TranslatorAppRequest) bytes[source]