File tree Expand file tree Collapse file tree
edocument/edocument/profiles/peppol Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -261,12 +261,18 @@ def parse_peppol_buyer(root, namespaces):
261261 buyer_party , ".//cac:PartyLegalEntity/cbc:RegistrationName" , namespaces
262262 ) or get_xml_text (buyer_party , ".//cac:PartyName/cbc:Name" , namespaces )
263263
264- # Try to find company
264+ # Buyer tax ID
265+ buyer_tax_id = get_xml_text (buyer_party , ".//cac:PartyTaxScheme/cbc:CompanyID" , namespaces )
266+
267+ # Try to find company by tax ID first (more reliable than name)
265268 company = None
266- if buyer_name and frappe .db .exists ("Company" , buyer_name ):
269+ if buyer_tax_id :
270+ company = frappe .db .get_value ("Company" , {"tax_id" : buyer_tax_id }, "name" )
271+
272+ if not company and buyer_name and frappe .db .exists ("Company" , buyer_name ):
267273 company = buyer_name
268274
269- return {"company" : company , "name" : buyer_name }
275+ return {"company" : company , "name" : buyer_name , "tax_id" : buyer_tax_id }
270276
271277
272278def parse_peppol_line_items (
You can’t perform that action at this time.
0 commit comments