fix: apply travel-day quantity rules
Some checks failed
ERP CI/CD Pipeline / test (push) Has been cancelled
ERP CI/CD Pipeline / Deploy (server git pull + compose) (push) Has been cancelled

Use business-rule based daily quantity for travel expense calculations and cover it with regression tests.
This commit is contained in:
mariomitte
2026-08-08 03:09:24 +02:00
parent 681f73d85a
commit a9ab83c202
2 changed files with 27 additions and 8 deletions

View File

@@ -26,7 +26,7 @@ from modules.fleet.models import (
)
from modules.task_management.models import Task, TaskWorkHoursTable
from modules.fleet.tasks import build_monthly_archive_cached_task
from modules.fleet.views import _build_monthly_servicer_report_rows
from modules.fleet.views import _build_monthly_servicer_report_rows, _calculate_daily_quantity_from_hours
def create_test_image(filename='test.jpg', size=(40, 40), color='red'):
@@ -477,15 +477,15 @@ class WorkOrderImagesEndpointTests(TestCase):
'date': '24.12.2033',
'work_time_from': '08:00',
'work_time_to': '16:00',
'travel_hours': '2',
'travel_hours': '1',
'work_hours': '6',
},
{
'date': '25.12.2033',
'work_time_from': '09:00',
'work_time_to': '15:00',
'travel_hours': '1,5',
'work_hours': '4',
'travel_hours': '0,5',
'work_hours': '2',
},
]
},
@@ -499,8 +499,16 @@ class WorkOrderImagesEndpointTests(TestCase):
text = '\n'.join((page.extract_text() or '') for page in reader.pages)
self.assertIn('24.12.2033.', text)
self.assertIn('25.12.2033.', text)
self.assertIn('13,5', text)
self.assertIn('0,6', text)
self.assertIn('9,5', text)
self.assertIn('0,5', text)
def test_calculate_daily_quantity_from_hours_follows_business_rules(self):
self.assertEqual(_calculate_daily_quantity_from_hours(0), 0.0)
self.assertEqual(_calculate_daily_quantity_from_hours(7), 0.0)
self.assertEqual(_calculate_daily_quantity_from_hours(8), 0.5)
self.assertEqual(_calculate_daily_quantity_from_hours(10.5), 0.5)
self.assertEqual(_calculate_daily_quantity_from_hours(12), 1.0)
self.assertEqual(_calculate_daily_quantity_from_hours(13.5), 1.0)
def test_monthly_servicer_report_rows_use_task_work_hours_table_hours(self):
TaskWorkHoursTable.objects.create(