Browse Source

[FIX] emca: return invoice number innstead of name

pull/115/head
robin.keunen 4 years ago
parent
commit
a8d13ea9e5
  1. 6
      easy_my_coop_api/services/account_payment_service.py
  2. 2
      easy_my_coop_api/tests/test_account_payment.py
  3. 9
      easy_my_coop_connector/components/emc_adapters.py
  4. 10
      easy_my_coop_connector/demo/demo.xml

6
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,

2
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()),

9
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)

10
easy_my_coop_connector/demo/demo.xml

@ -5,15 +5,17 @@
-->
<odoo>
<record id="easy_my_coop.subscription_request_1_demo" model="subscription.request">
<field name="source">emc_api</field>
</record>
<data noupdate="1">
<record id="emc_backend_demo" model="emc.backend">
<field name="name">IWP backend</field>
<field name="location">http://localhost:9876</field>
<field name="api_key">cbd07f57-c903-43b4-b668-436b3bec5f15</field>
</record>
</data>
<record id="easy_my_coop.subscription_request_1_demo" model="subscription.request">
<field name="source">emc_api</field>
</record>
<record id="emc_binding_product_template_A_demo" model="emc.binding.product.template">
<field name="backend_id" ref="emc_backend_demo"/>

Loading…
Cancel
Save