Commit b10ff9a5 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_subscription_request&accounting: Reservation refund is Taxable

   This change was requested by the accountant
parent 574b660d
......@@ -85,6 +85,7 @@
<string>quantity_unit/unit/piece</string>
<string>product_line/cloud/subscription</string>
<string>use/trade/sale</string>
<string>base_contribution/base_amount/invoicing/taxable</string>
</tuple>
</value>
</item>
......@@ -514,6 +515,51 @@
</value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>988.64728.51101.34167</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass> <reference id="6.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1619807004.05</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
......
......@@ -37,6 +37,13 @@ if payment_transaction is None or payment_transaction.getSimulationState() != "s
# Nothing to do bug wait the payment
return
price_without_tax = None
for invoice_line in sale_invoice_transaction.objectValues(portal_type="Invoice Line"):
if invoice_line.getResource() == "service_module/slapos_reservation_fee":
price_without_tax = invoice_line.getTotalPrice()
assert price_without_tax is not None, "Something is wrong since price wasn't found"
# Time to create the PL
person = sale_invoice_transaction.getDestinationValue(portal_type="Person")
delivery_template = portal.restrictedTraverse(
......@@ -65,7 +72,7 @@ line = delivery.newContent(
destination_section_value=person,
resource_value=service,
quantity_unit=service.getQuantityUnit(),
price=-sale_invoice_transaction.getTotalPrice(),
price=-price_without_tax,
causality_uid=context.getUid()
)
......
......@@ -151,9 +151,9 @@ class testSlapOSSubscriptionDualOrganisationScenario(TestSlapOSSubscriptionScena
"sale_trade_condition_module/slapos_reservation_refund_trade_condition")
if subscription_request.getPriceCurrency() == "currency_module/CNY":
expected_reservation_fee = self.expected_zh_reservation_fee
expected_reservation_fee = self.expected_zh_reservation_fee_without_tax
else:
expected_reservation_fee = self.expected_reservation_fee
expected_reservation_fee = self.expected_reservation_fee_without_tax
self.assertEqual(round(sale_packing_list.getTotalPrice(), 2),
-round(expected_reservation_fee*amount, 2))
......
......@@ -52,10 +52,12 @@ class testSlapOSSubscriptionCloudInvitationTokenScenario(TestSlapOSSubscriptionC
def _init_test_with_valid_invitation(self):
self.expected_reservation_fee = 0.0
self.expected_reservation_fee_without_tax = 0.0
self.expected_reservation_quantity_tax = 0.0
self.expected_reservation_tax = 0.0
self.expected_free_reservation = 1
self.expected_zh_reservation_fee = 0.0
self.expected_zh_reservation_fee_without_tax = 0.0
self.expected_zh_reservation_quantity_tax = 0.0
self.expected_zh_reservation_tax = 0.0
self.expected_zh_free_reservation = 1
......@@ -79,10 +81,12 @@ class testSlapOSSubscriptionCloudInvitationTokenScenario(TestSlapOSSubscriptionC
def test_two_subscription_scenario_with_invitation(self):
self.expected_reservation_fee = 0.0
self.expected_reservation_fee_without_tax = 0.0
self.expected_reservation_quantity_tax = 0.0
self.expected_reservation_tax = 0.0
self.expected_free_reservation = 1
self.expected_zh_reservation_fee = 0.0
self.expected_zh_reservation_fee_without_tax = 0.0
self.expected_zh_reservation_quantity_tax = 0.0
self.expected_zh_reservation_tax = 0.0
self.expected_zh_free_reservation = 1
......
......@@ -51,6 +51,7 @@ class testSlapOSSubscriptionCloudInvitationTokenScenario(TestSlapOSSubscriptionS
self._test_subscription_scenario_with_existing_user(amount=1, language="en")
def _init_test_with_valid_invitation(self):
self.expected_reservation_fee_without_tax = 0.0
self.expected_reservation_fee = 0.0
self.expected_reservation_quantity_tax = 0.0
self.expected_reservation_tax = 0.0
......@@ -74,6 +75,7 @@ class testSlapOSSubscriptionCloudInvitationTokenScenario(TestSlapOSSubscriptionS
self._test_subscription_scenario_with_reversal_transaction(amount=1)
def test_two_subscription_scenario_with_invitation(self):
self.expected_reservation_fee_without_tax = 0.0
self.expected_reservation_fee = 0.0
self.expected_reservation_quantity_tax = 0.0
self.expected_reservation_tax = 0.0
......
......@@ -1050,10 +1050,10 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
quantity = subscription_request.getQuantity()
if subscription_request.getPriceCurrency() == "currency_module/CNY":
expected_individual_price_without_tax = self.expected_zh_individual_price_without_tax
expected_reservation_fee = self.expected_zh_reservation_fee
expected_reservation_fee = self.expected_zh_reservation_fee_without_tax
else:
expected_individual_price_without_tax = self.expected_individual_price_without_tax
expected_reservation_fee = self.expected_reservation_fee
expected_reservation_fee = self.expected_reservation_fee_without_tax
# The values are without tax
self.assertEqual(sale_packing_list_line.getQuantity(), 1*quantity)
......@@ -1072,9 +1072,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
# The values are without tax
self.assertEqual(sale_packing_list_line.getQuantity(), 1)
self.assertEqual(round(sale_packing_list_line.getPrice(), 2),
-int(expected_reservation_fee*quantity))
-round(expected_reservation_fee*quantity, 2))
self.assertEqual(round(sale_packing_list_line.getTotalPrice(), 2),
-int(expected_reservation_fee*quantity))
-round(expected_reservation_fee*quantity, 2))
self.assertEqual(sale_packing_list.getCausality(),
subscription_request.getRelativeUrl())
......@@ -1272,11 +1272,11 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
if subscription_request.getPriceCurrency() == "currency_module/CNY":
self.assertEqual(round(sale_packing_list.getTotalPrice(), 2),
-round(self.expected_zh_reservation_fee*amount, 2))
-round(self.expected_zh_reservation_fee_without_tax*amount, 2))
else:
self.assertEqual(round(sale_packing_list.getTotalPrice(), 2),
-round(self.expected_reservation_fee*amount, 2))
-round(self.expected_reservation_fee_without_tax*amount, 2))
return subscription_request
......
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