Merge pull request #89 from SDSRV-IDP/trungpt/invoice_no
move invoice_no to the last element of result
This commit is contained in:
commit
5023608372
@ -107,9 +107,9 @@ def merge_sbt_output(loutputs):
|
|||||||
merged_output = []
|
merged_output = []
|
||||||
combined_output = {"retailername": None,
|
combined_output = {"retailername": None,
|
||||||
"sold_to_party": None,
|
"sold_to_party": None,
|
||||||
"invoice_no": None,
|
|
||||||
"purchase_date": [],
|
"purchase_date": [],
|
||||||
"imei_number": []} # place holder for the output
|
"imei_number": [],
|
||||||
|
"invoice_no": None} # place holder for the output
|
||||||
for output in loutputs:
|
for output in loutputs:
|
||||||
fields = output['fields']
|
fields = output['fields']
|
||||||
if "doc_type" not in output: # Should not contain more than 1 page
|
if "doc_type" not in output: # Should not contain more than 1 page
|
||||||
|
@ -29,8 +29,9 @@ def aggregate_result(results):
|
|||||||
des_result["content"]["total_pages"] = 0
|
des_result["content"]["total_pages"] = 0
|
||||||
des_result["content"]["ocr_num_pages"] = 0
|
des_result["content"]["ocr_num_pages"] = 0
|
||||||
des_result["content"]["document"][0]["end_page"] = 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"][2]["value"] = []
|
||||||
des_result["content"]["document"][0]["content"][3]["value"] = []
|
des_result["content"]["document"][0]["content"][3]["value"] = [None for _ in range(doc_types.count("imei"))]
|
||||||
|
|
||||||
|
|
||||||
imei_count = 0
|
imei_count = 0
|
||||||
for doc_type, result in sorted_results:
|
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"]["ocr_num_pages"] += 1
|
||||||
des_result["content"]["document"][0]["end_page"] += 1
|
des_result["content"]["document"][0]["end_page"] += 1
|
||||||
if doc_type == "imei":
|
if doc_type == "imei":
|
||||||
if len(result["content"]["document"][0]["content"][4]["value"]):
|
if len(result["content"]["document"][0]["content"][3]["value"]):
|
||||||
des_result["content"]["document"][0]["content"][4]["value"][imei_count] = result["content"]["document"][0]["content"][4]["value"][0]
|
des_result["content"]["document"][0]["content"][3]["value"][imei_count] = result["content"]["document"][0]["content"][3]["value"][0]
|
||||||
imei_count += 1
|
imei_count += 1
|
||||||
elif doc_type == "invoice":
|
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"][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"][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"][4]["value"] = result["content"]["document"][0]["content"][4]["value"]
|
||||||
des_result["content"]["document"][0]["content"][3]["value"] += result["content"]["document"][0]["content"][3]["value"]
|
des_result["content"]["document"][0]["content"][2]["value"] += result["content"]["document"][0]["content"][2]["value"]
|
||||||
elif doc_type == "all":
|
elif doc_type == "all":
|
||||||
des_result.update(result)
|
des_result.update(result)
|
||||||
else:
|
else:
|
||||||
@ -142,7 +143,6 @@ def process_invoice_sbt_result(rq_id, result, metadata):
|
|||||||
global random_processor_name
|
global random_processor_name
|
||||||
if random_processor_name is None:
|
if random_processor_name is None:
|
||||||
random_processor_name = uuid.uuid4()
|
random_processor_name = uuid.uuid4()
|
||||||
print(rq_id, random_processor_name)
|
|
||||||
print_id(f"[DEBUG]: Received SBT request with id {rq_id}")
|
print_id(f"[DEBUG]: Received SBT request with id {rq_id}")
|
||||||
try:
|
try:
|
||||||
page_index = int(rq_id.split("_sub_")[1])
|
page_index = int(rq_id.split("_sub_")[1])
|
||||||
|
Loading…
Reference in New Issue
Block a user