0012-pricing-always-pass-a-pricing_date-in-context-67675.patch
lingo/pricing/forms.py | ||
---|---|---|
433 | 433 |
def compute_for_flat_fee_schedule(self): |
434 | 434 |
if self.agenda_pricing.subscription_required and not self.serialized_subscription: |
435 | 435 |
return |
436 |
pricing_date = self.agenda_pricing.date_start |
|
437 |
if self.cleaned_data.get('billing_date'): |
|
438 |
pricing_date = self.cleaned_data['billing_date'].date_start |
|
436 | 439 |
return self.agenda_pricing.get_pricing_data( |
437 | 440 |
request=self.request, |
441 |
pricing_date=pricing_date, |
|
438 | 442 |
subscription=self.serialized_subscription, |
439 | 443 |
user_external_id=self.cleaned_data['user_external_id'], |
440 | 444 |
adult_external_id=self.cleaned_data['adult_external_id'], |
lingo/pricing/models.py | ||
---|---|---|
16 | 16 | |
17 | 17 |
import copy |
18 | 18 |
import dataclasses |
19 |
import datetime |
|
19 | 20 |
import decimal |
20 | 21 |
from typing import List |
21 | 22 | |
... | ... | |
399 | 400 | |
400 | 401 |
return created, agenda_pricing |
401 | 402 | |
402 |
def get_pricing_data(self, request, user_external_id, adult_external_id, subscription=None): |
|
403 |
def get_pricing_data(self, request, pricing_date, user_external_id, adult_external_id, subscription=None):
|
|
403 | 404 |
# compute pricing for flat_fee_schedule mode |
404 | 405 |
# subscription is None if subscription_required is False |
405 | 406 |
data = { |
407 |
'pricing_date': pricing_date, # date to use for QF |
|
406 | 408 |
'subscription': subscription, |
407 | 409 |
} |
408 | 410 |
context = self.get_pricing_context( |
... | ... | |
425 | 427 |
self, request, agenda, event, subscription, check_status, booking, user_external_id, adult_external_id |
426 | 428 |
): |
427 | 429 |
# compute pricing for an event |
430 |
event_date = datetime.datetime.fromisoformat(event['start_datetime']).date() |
|
428 | 431 |
data = { |
432 |
'pricing_date': event_date, # date to use for QF |
|
429 | 433 |
'event': event, |
430 | 434 |
'subscription': subscription, |
431 | 435 |
'booking': booking, |
tests/pricing/manager/test_agenda_pricing.py | ||
---|---|---|
1135 | 1135 |
assert mock_pricing_data.call_args_list == [ |
1136 | 1136 |
mock.call( |
1137 | 1137 |
request=mock.ANY, |
1138 |
pricing_date=datetime.date(2021, 9, 1), |
|
1138 | 1139 |
subscription={'date_start': '2021-09-02', 'date_end': '2021-09-03'}, |
1139 | 1140 |
user_external_id='user:1', |
1140 | 1141 |
adult_external_id='adult:1', |
... | ... | |
1169 | 1170 |
assert mock_pricing_data.call_args_list == [ |
1170 | 1171 |
mock.call( |
1171 | 1172 |
request=mock.ANY, |
1173 |
pricing_date=datetime.date(2021, 9, 1), |
|
1172 | 1174 |
subscription={'date_start': '2021-09-02', 'date_end': '2021-09-03'}, |
1173 | 1175 |
user_external_id='user:1', |
1174 | 1176 |
adult_external_id='adult:1', |
... | ... | |
1201 | 1203 |
assert mock_pricing_data.call_args_list == [ |
1202 | 1204 |
mock.call( |
1203 | 1205 |
request=mock.ANY, |
1206 |
pricing_date=datetime.date(2021, 9, 15), |
|
1204 | 1207 |
subscription={'date_start': '2021-09-15', 'date_end': '2021-09-16'}, |
1205 | 1208 |
user_external_id='user:1', |
1206 | 1209 |
adult_external_id='adult:1', |
... | ... | |
1218 | 1221 |
assert mock_pricing_data.call_args_list == [ |
1219 | 1222 |
mock.call( |
1220 | 1223 |
request=mock.ANY, |
1224 |
pricing_date=datetime.date(2021, 9, 15), |
|
1221 | 1225 |
subscription={'date_start': '2021-09-30', 'date_end': '2021-10-01'}, |
1222 | 1226 |
user_external_id='user:1', |
1223 | 1227 |
adult_external_id='adult:1', |
... | ... | |
1239 | 1243 |
assert mock_pricing_data.call_args_list == [ |
1240 | 1244 |
mock.call( |
1241 | 1245 |
request=mock.ANY, |
1246 |
pricing_date=datetime.date(2021, 9, 1), |
|
1242 | 1247 |
subscription=None, |
1243 | 1248 |
user_external_id='user:1', |
1244 | 1249 |
adult_external_id='adult:1', |
tests/pricing/test_models.py | ||
---|---|---|
952 | 952 |
for subscription in [None, {'foo': 'bar'}]: |
953 | 953 |
assert agenda_pricing.get_pricing_data( |
954 | 954 |
request=context['request'], |
955 |
pricing_date=datetime.date(year=2021, month=9, day=1), |
|
955 | 956 |
subscription=subscription, |
956 | 957 |
user_external_id='child:42', |
957 | 958 |
adult_external_id='parent:35', |
958 |
- |