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
Pipeline #13874 failed with stage
in 0 seconds
......@@ -60,12 +60,11 @@ subscription_request = context.subscription_request_module.newContent(
subscription_request.setDefaultEmailText(email)
def wrapWithShadow(subscription_request, amount, subscription_reference,
def wrapWithShadow(subscription_request, subscription_reference,
subscription_request_id, contract=contract):
subscription_request.activate(tag="subscription_condition_%s" % subscription_request_id
).SubscriptionRequest_applyCondition(subscription_reference, target_language)
return subscription_request.SubscriptionRequest_requestPaymentTransaction(
amount=amount,
tag="subscription_%s" % subscription_request_id,
target_language=target_language,
contract=contract
......@@ -74,7 +73,7 @@ def wrapWithShadow(subscription_request, amount, subscription_reference,
payment = person.Person_restrictMethodAsShadowUser(
shadow_document=person,
callable_object=wrapWithShadow,
argument_list=[subscription_request, user_input_dict["amount"],
argument_list=[subscription_request,
subscription_reference, subscription_request.getId(),
contract])
......
......@@ -25,7 +25,10 @@ if current_invoice is None:
start_date=payment_transaction.getStartDate(),
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()
current_invoice.plan(comment=comment)
......
......@@ -23,6 +23,7 @@ if current_invoice is None:
stop_date=DateTime()
)
amount = context.getQuantity()
if context.SubscriptionRequest_testSkippedReservationFree(contract):
# Reservation is Free
amount = 0
......
......@@ -50,7 +50,7 @@
</item>
<item>
<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>
<key> <string>_proxy_roles</string> </key>
......
......@@ -714,7 +714,6 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
expected_reservation_quantity_tax = self.expected_reservation_quantity_tax
expected_reservation_tax = self.expected_reservation_tax
expected_reservation_fee = self.expected_reservation_fee
self.assertEqual(invoice.getSimulationState(), "stopped")
self.assertEqual(invoice.getCausalityState(), "solved")
......@@ -722,11 +721,11 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
subscription_request.getPriceCurrency())
for line in invoice.objectValues():
if line.getResource() == "service_module/slapos_reservation_fee":
self.assertEqual(line.getQuantity(), quantity)
if self.expected_free_reservation:
self.assertEqual(line.getQuantity(), 0)
self.assertEqual(round(line.getPrice(), 2), 0.0)
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":
self.assertEqual(round(line.getQuantity(), 2),
round(expected_reservation_quantity_tax*quantity, 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