invoice_no to the last index of result

This commit is contained in:
PhanThanhTrung 2024-03-14 12:49:47 +07:00
parent b278350cf2
commit 31ffbdefc7
2 changed files with 9 additions and 9 deletions

View File

@ -107,9 +107,9 @@ def merge_sbt_output(loutputs):
merged_output = []
combined_output = {"retailername": None,
"sold_to_party": None,
"invoice_no": None,
"purchase_date": [],
"imei_number": []} # place holder for the output
"imei_number": [],
"invoice_no": None} # place holder for the output
for output in loutputs:
fields = output['fields']
if "doc_type" not in output: # Should not contain more than 1 page

View File

@ -29,8 +29,9 @@ def aggregate_result(results):
des_result["content"]["total_pages"] = 0
des_result["content"]["ocr_num_pages"] = 0
des_result["content"]["document"][0]["end_page"] = 0
des_result["content"]["document"][0]["content"][4]["value"] = [None for _ in range(doc_types.count("imei"))]
des_result["content"]["document"][0]["content"][3]["value"] = []
des_result["content"]["document"][0]["content"][2]["value"] = []
des_result["content"]["document"][0]["content"][3]["value"] = [None for _ in range(doc_types.count("imei"))]
imei_count = 0
for doc_type, result in sorted_results:
@ -38,14 +39,14 @@ def aggregate_result(results):
des_result["content"]["ocr_num_pages"] += 1
des_result["content"]["document"][0]["end_page"] += 1
if doc_type == "imei":
if len(result["content"]["document"][0]["content"][4]["value"]):
des_result["content"]["document"][0]["content"][4]["value"][imei_count] = result["content"]["document"][0]["content"][4]["value"][0]
if len(result["content"]["document"][0]["content"][3]["value"]):
des_result["content"]["document"][0]["content"][3]["value"][imei_count] = result["content"]["document"][0]["content"][3]["value"][0]
imei_count += 1
elif doc_type == "invoice":
des_result["content"]["document"][0]["content"][0]["value"] = result["content"]["document"][0]["content"][0]["value"]
des_result["content"]["document"][0]["content"][1]["value"] = result["content"]["document"][0]["content"][1]["value"]
des_result["content"]["document"][0]["content"][2]["value"] = result["content"]["document"][0]["content"][2]["value"]
des_result["content"]["document"][0]["content"][3]["value"] += result["content"]["document"][0]["content"][3]["value"]
des_result["content"]["document"][0]["content"][4]["value"] = result["content"]["document"][0]["content"][4]["value"]
des_result["content"]["document"][0]["content"][2]["value"] += result["content"]["document"][0]["content"][2]["value"]
elif doc_type == "all":
des_result.update(result)
else:
@ -142,7 +143,6 @@ def process_invoice_sbt_result(rq_id, result, metadata):
global random_processor_name
if random_processor_name is None:
random_processor_name = uuid.uuid4()
print(rq_id, random_processor_name)
print_id(f"[DEBUG]: Received SBT request with id {rq_id}")
try:
page_index = int(rq_id.split("_sub_")[1])