process_sync update invoice_no
This commit is contained in:
parent
6b11f82342
commit
5042a70810
@ -107,6 +107,7 @@ 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
|
||||
for output in loutputs:
|
||||
@ -123,7 +124,7 @@ def merge_sbt_output(loutputs):
|
||||
combined_output[field["label"]].append(field["value"])
|
||||
if output['doc_type'] == "invoice":
|
||||
for field in fields:
|
||||
if field["label"] in ["retailername", "sold_to_party", "purchase_date"] :
|
||||
if field["label"] in ["retailername", "sold_to_party", "purchase_date", "invoice_no"] :
|
||||
if isinstance(combined_output[field["label"]], list):
|
||||
if field["value"] is not None:
|
||||
if isinstance(field["value"], list):
|
||||
|
@ -29,8 +29,8 @@ 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"][3]["value"] = [None for _ in range(doc_types.count("imei"))]
|
||||
des_result["content"]["document"][0]["content"][2]["value"] = []
|
||||
des_result["content"]["document"][0]["content"][4]["value"] = [None for _ in range(doc_types.count("imei"))]
|
||||
des_result["content"]["document"][0]["content"][3]["value"] = []
|
||||
|
||||
imei_count = 0
|
||||
for doc_type, result in sorted_results:
|
||||
@ -38,12 +38,14 @@ def aggregate_result(results):
|
||||
des_result["content"]["ocr_num_pages"] += 1
|
||||
des_result["content"]["document"][0]["end_page"] += 1
|
||||
if doc_type == "imei":
|
||||
des_result["content"]["document"][0]["content"][3]["value"][imei_count] = result["content"]["document"][0]["content"][3]["value"][0]
|
||||
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]
|
||||
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"][2]["value"] = result["content"]["document"][0]["content"][2]["value"]
|
||||
des_result["content"]["document"][0]["content"][3]["value"] += result["content"]["document"][0]["content"][3]["value"]
|
||||
elif doc_type == "all":
|
||||
des_result.update(result)
|
||||
else:
|
||||
@ -151,7 +153,6 @@ def process_invoice_sbt_result(rq_id, result, metadata):
|
||||
index_in_request = metadata.pop("index_to_image_type", 0)
|
||||
result["metadata"] = metadata
|
||||
_update_subscription_rq_file(request_id=rq, index_in_request=index_in_request, doc_type=image_type, result=result)
|
||||
|
||||
status = result.get("status", 200)
|
||||
redis_client.set_cache(rq_id, page_index, result)
|
||||
done = rq.pages == redis_client.get_size(rq_id)
|
||||
@ -194,9 +195,9 @@ def process_invoice_sbt_result(rq_id, result, metadata):
|
||||
|
||||
def _update_subscription_rq_file(request_id, index_in_request, doc_type, result):
|
||||
image = SubscriptionRequestFile.objects.filter(request=request_id, index_in_request=index_in_request, doc_type=doc_type).first()
|
||||
|
||||
retailer_name = None
|
||||
sold_to_party = None
|
||||
invoice_no = None
|
||||
purchase_date = []
|
||||
imei_number = []
|
||||
predicted_res = __get_actual_predict_result(result=result)
|
||||
@ -208,12 +209,15 @@ def _update_subscription_rq_file(request_id, index_in_request, doc_type, result)
|
||||
sold_to_party = elem['value']
|
||||
elif elem["label"] == "purchase_date":
|
||||
purchase_date = elem['value']
|
||||
elif elem["label"] == "invoice_no":
|
||||
invoice_no = elem['value']
|
||||
else:
|
||||
imei_number = elem['value']
|
||||
if doc_type=='invoice':
|
||||
_predict_result = {
|
||||
"retailername": retailer_name,
|
||||
"sold_to_party": sold_to_party,
|
||||
"invoice_no": invoice_no,
|
||||
"purchase_date": purchase_date,
|
||||
"imei_number": []
|
||||
}
|
||||
@ -221,6 +225,7 @@ def _update_subscription_rq_file(request_id, index_in_request, doc_type, result)
|
||||
_predict_result = {
|
||||
"retailername": None,
|
||||
"sold_to_party": None,
|
||||
"invoice_no": None,
|
||||
"purchase_date": [],
|
||||
"imei_number": imei_number
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user