Skip to content

Commit

Permalink
fix: construct contact's full name
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Dec 15, 2024
1 parent 037f9b0 commit 3e73d6a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions eu_einvoice/european_e_invoice/custom/sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from eu_einvoice.common_codes import CommonCodeRetriever
from eu_einvoice.schematron import get_validation_errors
from eu_einvoice.utils import EInvoiceProfile, get_drafthorse_schema, get_guideline
from eu_einvoice.utils import EInvoiceProfile, get_drafthorse_schema, get_full_name, get_guideline

if TYPE_CHECKING:
from erpnext.accounts.doctype.sales_invoice.sales_invoice import SalesInvoice
Expand Down Expand Up @@ -250,7 +250,7 @@ def _set_seller_electronic_address(self):
def _set_seller_contact(self):
seller_contact_phone = self.company.phone_no
if self.seller_contact:
self.doc.trade.agreement.seller.contact.person_name = self.seller_contact.full_name
self.doc.trade.agreement.seller.contact.person_name = get_full_name(self.seller_contact)
if self.seller_contact.department:
self.doc.trade.agreement.seller.contact.department_name = self.seller_contact.department
if self.seller_contact.email_id:
Expand Down Expand Up @@ -311,7 +311,7 @@ def _set_buyer_address(self):
def _set_buyer_contact(self):
buyer_contact_phone = self.invoice.contact_mobile
if self.buyer_contact:
self.doc.trade.agreement.buyer.contact.person_name = self.buyer_contact.full_name
self.doc.trade.agreement.buyer.contact.person_name = get_full_name(self.buyer_contact)
if self.buyer_contact.department:
self.doc.trade.agreement.buyer.contact.department_name = self.buyer_contact.department
if self.buyer_contact.phone:
Expand Down
8 changes: 8 additions & 0 deletions eu_einvoice/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from enum import Enum
from functools import total_ordering
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from frappe.contacts.doctype.contact.contact import Contact


@total_ordering
Expand Down Expand Up @@ -58,6 +62,10 @@ def get_profile(guideline: str) -> EInvoiceProfile:
return GUIDELINE_TO_PROFILE.get(guideline)


def get_full_name(contact: "Contact") -> str:
return f"{contact.first_name or ''} {contact.last_name or ''}".strip()


def identity(value):
"""Used for dummy translation"""
return value

0 comments on commit 3e73d6a

Please sign in to comment.