Commit 53c60272 authored by dmitry.mashoshin's avatar dmitry.mashoshin
Browse files

Merge branch 'kpn/1211/weekdays_pattern' into 'master'

fix(LLP, LLD, LLE): increased the maximum rental time from 23:59 to 24:00

See merge request !46
parents 030a157e c5ddaf33
Pipeline #25221 passed with stages
in 1 minute and 54 seconds
......@@ -5,7 +5,7 @@ from isodate import parse_duration, ISO8601Error, Duration
from isoweek import Week
from prozorro_sale import tools # type: ignore
from prozorro_sale.billing_service.utils import is_leap_year, weekday_count, str_to_datetime
from prozorro_sale.billing_service.utils import is_leap_year, weekday_count, str_to_datetime, parse_24_time
from .base import ExtensionBase
LOG = tools.logging.get_custom_logger(__name__)
......@@ -92,8 +92,8 @@ class LeaseExtension(ExtensionBase):
count_result_map = {}
count_map = weekday_count(start_date, end_date)
if weekdays:
for days_name in weekdays:
name = days_name.get('uk_UA', '')
for weekday in weekdays:
name = weekday.get('weekday', {}).get('uk_UA', '')
count_result_map[name] = count_map.get(name, 0)
else:
count_result_map = count_map
......@@ -116,10 +116,12 @@ class LeaseExtension(ExtensionBase):
if weekdays:
for weekday in weekdays:
name = weekday.get('weekday', {}).get('uk_UA', '')
start_time = datetime.strptime(weekday.get('startTime'), '%H:%M').time()
end_time = datetime.strptime(weekday.get('endTime'), '%H:%M').time()
timedelta_start_time = timedelta(hours=start_time.hour, minutes=start_time.minute)
timedelta_end_time = timedelta(hours=end_time.hour, minutes=end_time.minute)
start_time = parse_24_time(weekday.get('startTime'))
end_time = parse_24_time(weekday.get('endTime'))
timedelta_start_time = timedelta(days=start_time.day, hours=start_time.hour,
minutes=start_time.minute)
timedelta_end_time = timedelta(days=end_time.day, hours=end_time.hour,
minutes=end_time.minute)
rent_hour = (timedelta_end_time - timedelta_start_time).total_seconds() / 60 / 60
count_result_map[name] = count_map.get(name, 0) * rent_hour
else:
......
......@@ -76,3 +76,9 @@ def str_to_datetime(str_datetime):
else:
if fex:
raise ValueError(fex)
def parse_24_time(value):
if value == '24:00':
return datetime.strptime('00:00', '%H:%M') + timedelta(days=1)
return datetime.strptime(value, '%H:%M')
This diff is collapsed.
This diff is collapsed.
{
"auctionId": "LLE001-UA-20210301-35409",
"registrationFee": {
"amount": 600.0,
"description": "10% мінімальної заробітної плати"
},
"guaranteeFee": {
"withVAT": false,
"amount": 77.84,
"description": "Якщо погодинно/подобово - за формулою \"(5*прожитковий мінімум * 0.12)/360 * загальну площу об'єктів\""
},
"currentTenantGuaranteeFee": {
"withVAT": false,
"amount": 1.5,
"description": "Якщо строк оренди більше місяця - половина місячної орендної плати."
},
"operatorFee": {
"withVAT": false,
"amount": 3000,
"description": "5% від річної вартості оренди"
},
"administratorFee": {
"withVAT": false,
"amount": 900.0,
"description": "30% від винагороди оператора"
},
"feeSharingWinnerOperator": {
"amount": 2100.0,
"description": "100% від винагороди оператора після вирахунку винагороди адміністратора"
},
"feeSharingOrganizerOperator": {
"amount": 0,
"description": "Відсутня"
}
}
\ No newline at end of file
{
"auctionId": "LLE001-UA-20210301-35409",
"registrationFee": {
"amount": 600.0,
"description": "10% мінімальної заробітної плати"
},
"guaranteeFee": {
"withVAT": false,
"amount": 77.84,
"description": "Якщо погодинно/подобово - за формулою \"(5*прожитковий мінімум * 0.12)/360 * загальну площу об'єктів\""
},
"currentTenantGuaranteeFee": {
"withVAT": false,
"amount": 1.5,
"description": "Якщо строк оренди більше місяця - половина місячної орендної плати."
},
"operatorFee": {
"withVAT": false,
"amount": 3000,
"description": "5% від річної вартості оренди"
},
"administratorFee": {
"withVAT": false,
"amount": 900.0,
"description": "30% від винагороди оператора"
},
"feeSharingWinnerOperator": {
"amount": 2100.0,
"description": "100% від винагороди оператора після вирахунку винагороди адміністратора"
},
"feeSharingOrganizerOperator": {
"amount": 0,
"description": "Відсутня"
}
}
\ No newline at end of file
......@@ -346,7 +346,7 @@ class TestLeaseCalculator:
assert 'auctionId' in data
assert data['operatorFee']['amount'] == amount
@pytest.mark.parametrize("fixture_number", [1, 2, 3])
@pytest.mark.parametrize("fixture_number", [1, 2, 3, 4, 5])
async def test_calculator_by_fixtures(self, config_file, fixture_number):
fixture_path = FIXTURE_PATH.joinpath('calculated')
data_set_fixture = fixture_path.joinpath(f'in_{fixture_number}.json')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment