test commit
This commit is contained in:
parent
a761c46202
commit
ea76b90848
|
|
@ -1905,7 +1905,7 @@ def match_similar_parties():
|
|||
'etaxes_party_type', 'erp_party_type'])
|
||||
|
||||
# Log parties
|
||||
frappe.log_error(f"E-Taxes parties with status New: {etaxes_parties}", "Match Parties Log")
|
||||
# frappe.log_error(f"E-Taxes parties with status New: {etaxes_parties}", "Match Parties Log")
|
||||
|
||||
# Get existing mappings
|
||||
existing_mappings = {}
|
||||
|
|
@ -1913,7 +1913,7 @@ def match_similar_parties():
|
|||
existing_mappings[mapping.etaxes_party_name] = mapping.erp_party
|
||||
|
||||
# Log existing mappings
|
||||
frappe.log_error(f"Existing mappings: {existing_mappings}", "Match Parties Log")
|
||||
# frappe.log_error(f"Existing mappings: {existing_mappings}", "Match Parties Log")
|
||||
|
||||
# Filter only those that are not in mappings or have empty mappings
|
||||
parties_to_process = []
|
||||
|
|
@ -1922,7 +1922,7 @@ def match_similar_parties():
|
|||
parties_to_process.append(party)
|
||||
|
||||
# Log final list of parties to process
|
||||
frappe.log_error(f"Parties to process: {parties_to_process}", "Match Parties Log")
|
||||
# frappe.log_error(f"Parties to process: {parties_to_process}", "Match Parties Log")
|
||||
|
||||
matched_count = 0
|
||||
total_processed = len(parties_to_process)
|
||||
|
|
@ -1936,7 +1936,7 @@ def match_similar_parties():
|
|||
erp_party_type = etaxes_party.erp_party_type
|
||||
|
||||
# Log party being processed
|
||||
frappe.log_error(f"Processing party: {etaxes_party.etaxes_party_name} (Type: {erp_party_type})", "Match Parties Log")
|
||||
# frappe.log_error(f"Processing party: {etaxes_party.etaxes_party_name} (Type: {erp_party_type})", "Match Parties Log")
|
||||
|
||||
# Get all parties of corresponding type from system
|
||||
system_parties = frappe.get_all(erp_party_type,
|
||||
|
|
@ -1960,9 +1960,9 @@ def match_similar_parties():
|
|||
# Calculate similarity coefficient
|
||||
name_score = SequenceMatcher(None, etaxes_name, party_name_normalized).ratio()
|
||||
|
||||
# Log high matches (more than 0.8)
|
||||
if name_score > 0.8:
|
||||
frappe.log_error(f"High score: '{etaxes_party.etaxes_party_name}' vs '{party_name}' = {name_score}", "Match Parties Log")
|
||||
# # Log high matches (more than 0.8)
|
||||
# if name_score > 0.8:
|
||||
# frappe.log_error(f"High score: '{etaxes_party.etaxes_party_name}' vs '{party_name}' = {name_score}", "Match Parties Log")
|
||||
|
||||
# Check if this is a better match
|
||||
if name_score > best_score and name_score >= similarity_threshold:
|
||||
|
|
@ -1971,7 +1971,7 @@ def match_similar_parties():
|
|||
|
||||
if best_match:
|
||||
# Log found match
|
||||
frappe.log_error(f"Match found: '{etaxes_party.etaxes_party_name}' matches with '{best_match.name}' (score: {best_score})", "Match Parties Log")
|
||||
# frappe.log_error(f"Match found: '{etaxes_party.etaxes_party_name}' matches with '{best_match.name}' (score: {best_score})", "Match Parties Log")
|
||||
|
||||
# IMPORTANT: check if there is already a record for this party in mappings
|
||||
existing_row = None
|
||||
|
|
@ -2004,17 +2004,17 @@ def match_similar_parties():
|
|||
party_doc.mapped_party = best_match.name
|
||||
party_doc.save()
|
||||
except Exception as e:
|
||||
frappe.log_error(f"Error updating party status: {str(e)}", "Match Parties Log")
|
||||
return
|
||||
else:
|
||||
# For parties that have no match, DO NOT change status
|
||||
frappe.log_error(f"No match found for '{etaxes_party.etaxes_party_name}', keeping status as 'New'", "Match Parties Log")
|
||||
return
|
||||
|
||||
# Save settings after adding all mappings
|
||||
if matched_count > 0:
|
||||
doc.save()
|
||||
|
||||
# Log final result
|
||||
frappe.log_error(f"Final result: matched {matched_count} out of {total_processed} parties", "Match Parties Log")
|
||||
# frappe.log_error(f"Final result: matched {matched_count} out of {total_processed} parties", "Match Parties Log")
|
||||
|
||||
return {
|
||||
'success': True,
|
||||
|
|
@ -2024,7 +2024,7 @@ def match_similar_parties():
|
|||
}
|
||||
|
||||
except Exception as e:
|
||||
frappe.log_error(frappe.get_traceback(), f"Error in match_similar_parties: {str(e)}")
|
||||
# frappe.log_error(frappe.get_traceback(), f"Error in match_similar_parties: {str(e)}")
|
||||
return {
|
||||
'success': False,
|
||||
'message': "An unknown error occurred, please try again in a few minutes."
|
||||
|
|
|
|||
Loading…
Reference in New Issue