From 6051e9f71eb83f9a9be09d9b6cd1c6be6d8bb386 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 10 Nov 2020 12:20:54 +0000 Subject: [PATCH] [FIX] payment_paypal: Test paypal_compute_fees Add a test for the computation of the Paypal fees opw:2369557 closes odoo/odoo#61750 X-original-commit: 8bedef042bd7be5830de92ae9a6976c9e17fb792 Signed-off-by: Simon Goffin (sig) --- addons/payment_paypal/tests/test_paypal.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/payment_paypal/tests/test_paypal.py b/addons/payment_paypal/tests/test_paypal.py index a8d173c3ed1..38a50a91c50 100644 --- a/addons/payment_paypal/tests/test_paypal.py +++ b/addons/payment_paypal/tests/test_paypal.py @@ -205,3 +205,15 @@ class PaypalForm(PaypalCommon): self.assertEqual(tx.state, 'done', 'paypal: wrong state after receiving a valid pending notification') self.assertEqual(tx.acquirer_reference, '08D73520KX778924N', 'paypal: wrong txn_id after receiving a valid pending notification') self.assertEqual(fields.Datetime.to_string(tx.date), '2013-11-18 11:21:19', 'paypal: wrong validation date') + + def test_21_paypal_compute_fees(self): + #If the merchant needs to keep 100€, the transaction will be equal to 103.30€. + #In this way, Paypal will take 103.30 * 2.9% + 0.30 = 3.30€ + #And the merchant will take 103.30 - 3.30 = 100€ + self.paypal.write({ + 'fees_active': True, + 'fees_int_fixed': 0.30, + 'fees_int_var': 2.90, + }) + total_fee = self.paypal.paypal_compute_fees(100, False, False) + self.assertEqual(round(total_fee, 2), 3.3, 'Wrong computation of the Paypal fees')