From a8d13ea9e5044958a4263e914e77818ae740027c Mon Sep 17 00:00:00 2001 From: "robin.keunen" Date: Thu, 27 Aug 2020 12:40:56 +0200 Subject: [PATCH] [FIX] emca: return invoice number innstead of name --- .../services/account_payment_service.py | 6 +++++- easy_my_coop_api/tests/test_account_payment.py | 2 +- easy_my_coop_connector/components/emc_adapters.py | 9 +++++---- easy_my_coop_connector/demo/demo.xml | 14 ++++++++------ 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/easy_my_coop_api/services/account_payment_service.py b/easy_my_coop_api/services/account_payment_service.py index d8094e3..391068b 100644 --- a/easy_my_coop_api/services/account_payment_service.py +++ b/easy_my_coop_api/services/account_payment_service.py @@ -76,10 +76,14 @@ class AccountPaymentService(Component): } def _to_dict(self, payment): + invoice = { + "id": payment.invoice_ids.get_api_external_id(), + "name": payment.invoice_ids.number, + } return { "id": payment.get_api_external_id(), "journal": self._one_to_many_to_dict(payment.journal_id), - "invoice": self._one_to_many_to_dict(payment.invoice_ids), + "invoice": invoice, "payment_date": Date.to_string(payment.payment_date), "amount": payment.amount, "communication": payment.communication, diff --git a/easy_my_coop_api/tests/test_account_payment.py b/easy_my_coop_api/tests/test_account_payment.py index d428a75..766b67c 100644 --- a/easy_my_coop_api/tests/test_account_payment.py +++ b/easy_my_coop_api/tests/test_account_payment.py @@ -48,7 +48,7 @@ class TestAccountPaymentController(BaseEMCRestCase): "communication": invoice.reference, "invoice": { "id": invoice.get_api_external_id(), - "name": invoice.name, + "name": invoice.number, }, "amount": self.demo_request_1.subscription_amount, "payment_date": Date.to_string(Date.today()), diff --git a/easy_my_coop_connector/components/emc_adapters.py b/easy_my_coop_connector/components/emc_adapters.py index 2fb4fcc..1bad91d 100644 --- a/easy_my_coop_connector/components/emc_adapters.py +++ b/easy_my_coop_connector/components/emc_adapters.py @@ -86,13 +86,14 @@ class SubscriptionRequestAdapter(AbstractEMCAdapter): data = {} try: invoice_dict = self.backend.http_post_content(url, data) - except BadRequest: + except BadRequest as bad_request: raise ValidationError( _( - "The request was already validated on the " - "platform. Please check data consistency " - "with your system administrator." + "The Synergie platform replied with this error message:" + "\n\n %s \n\n" + "Please contact your system administrator." ) + % bad_request.description ) ai_adapter = AccountInvoiceAdapter(backend=self.backend) return ai_adapter.to_write_values(invoice_dict) diff --git a/easy_my_coop_connector/demo/demo.xml b/easy_my_coop_connector/demo/demo.xml index e240535..4f05c41 100644 --- a/easy_my_coop_connector/demo/demo.xml +++ b/easy_my_coop_connector/demo/demo.xml @@ -5,16 +5,18 @@ --> + + + IWP backend + http://localhost:9876 + cbd07f57-c903-43b4-b668-436b3bec5f15 + + + emc_api - - IWP backend - http://localhost:9876 - cbd07f57-c903-43b4-b668-436b3bec5f15 - -