Commit 175eb04a authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_subscription_request: Dont set quantity 0 but price

   Else simulation behaves oddly.
parent dc3afa4f
...@@ -60,12 +60,11 @@ subscription_request = context.subscription_request_module.newContent( ...@@ -60,12 +60,11 @@ subscription_request = context.subscription_request_module.newContent(
subscription_request.setDefaultEmailText(email) subscription_request.setDefaultEmailText(email)
def wrapWithShadow(subscription_request, amount, subscription_reference, def wrapWithShadow(subscription_request, subscription_reference,
subscription_request_id, contract=contract): subscription_request_id, contract=contract):
subscription_request.activate(tag="subscription_condition_%s" % subscription_request_id subscription_request.activate(tag="subscription_condition_%s" % subscription_request_id
).SubscriptionRequest_applyCondition(subscription_reference, target_language) ).SubscriptionRequest_applyCondition(subscription_reference, target_language)
return subscription_request.SubscriptionRequest_requestPaymentTransaction( return subscription_request.SubscriptionRequest_requestPaymentTransaction(
amount=amount,
tag="subscription_%s" % subscription_request_id, tag="subscription_%s" % subscription_request_id,
target_language=target_language, target_language=target_language,
contract=contract contract=contract
...@@ -74,7 +73,7 @@ def wrapWithShadow(subscription_request, amount, subscription_reference, ...@@ -74,7 +73,7 @@ def wrapWithShadow(subscription_request, amount, subscription_reference,
payment = person.Person_restrictMethodAsShadowUser( payment = person.Person_restrictMethodAsShadowUser(
shadow_document=person, shadow_document=person,
callable_object=wrapWithShadow, callable_object=wrapWithShadow,
argument_list=[subscription_request, user_input_dict["amount"], argument_list=[subscription_request,
subscription_reference, subscription_request.getId(), subscription_reference, subscription_request.getId(),
contract]) contract])
......
...@@ -25,7 +25,10 @@ if current_invoice is None: ...@@ -25,7 +25,10 @@ if current_invoice is None:
start_date=payment_transaction.getStartDate(), start_date=payment_transaction.getStartDate(),
stop_date=payment_transaction.getStopDate(), stop_date=payment_transaction.getStopDate(),
) )
current_invoice["1"].setQuantity(amount) if not amount:
# this is supposed to be free, so turn price free.
current_invoice["1"].setPrice(0.0)
current_invoice["1"].setQuantity(context.getQuantity())
comment = "Validation invoice for subscription request %s" % context.getRelativeUrl() comment = "Validation invoice for subscription request %s" % context.getRelativeUrl()
current_invoice.plan(comment=comment) current_invoice.plan(comment=comment)
......
...@@ -23,6 +23,7 @@ if current_invoice is None: ...@@ -23,6 +23,7 @@ if current_invoice is None:
stop_date=DateTime() stop_date=DateTime()
) )
amount = context.getQuantity()
if context.SubscriptionRequest_testSkippedReservationFree(contract): if context.SubscriptionRequest_testSkippedReservationFree(contract):
# Reservation is Free # Reservation is Free
amount = 0 amount = 0
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>amount, tag, target_language, contract=None, REQUEST=None</string> </value> <value> <string>tag, target_language, contract=None, REQUEST=None</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
......
...@@ -715,17 +715,16 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -715,17 +715,16 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
expected_reservation_tax = self.expected_reservation_tax expected_reservation_tax = self.expected_reservation_tax
expected_reservation_fee = self.expected_reservation_fee expected_reservation_fee = self.expected_reservation_fee
self.assertEqual(invoice.getSimulationState(), "stopped") self.assertEqual(invoice.getSimulationState(), "stopped")
self.assertEqual(invoice.getCausalityState(), "solved") self.assertEqual(invoice.getCausalityState(), "solved")
self.assertEqual(invoice.getPriceCurrency(), self.assertEqual(invoice.getPriceCurrency(),
subscription_request.getPriceCurrency()) subscription_request.getPriceCurrency())
for line in invoice.objectValues(): for line in invoice.objectValues():
if line.getResource() == "service_module/slapos_reservation_fee": if line.getResource() == "service_module/slapos_reservation_fee":
self.assertEqual(line.getQuantity(), quantity)
if self.expected_free_reservation: if self.expected_free_reservation:
self.assertEqual(line.getQuantity(), 0) self.assertEqual(round(line.getPrice(), 2), 0.0)
else: else:
self.assertEqual(line.getQuantity(), quantity)
self.assertEqual(round(line.getPrice(), 2), expected_reservation_fee_without_tax) self.assertEqual(round(line.getPrice(), 2), expected_reservation_fee_without_tax)
if line.getResource() == "service_module/slapos_tax": if line.getResource() == "service_module/slapos_tax":
self.assertEqual(round(line.getQuantity(), 2), self.assertEqual(round(line.getQuantity(), 2),
......
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