From 40adea6ee75dfab47719ea1064b9ac5154b87ab9 Mon Sep 17 00:00:00 2001 From: Vikas8600 Date: Mon, 1 May 2023 15:10:30 +0530 Subject: [PATCH] fix: sales invoice getting skip --- ecommerce_integrations/unicommerce/order.py | 23 ++++++++++++------- ecommerce_integrations/unicommerce/product.py | 3 +-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ecommerce_integrations/unicommerce/order.py b/ecommerce_integrations/unicommerce/order.py index 1c7e4824..79fbf629 100644 --- a/ecommerce_integrations/unicommerce/order.py +++ b/ecommerce_integrations/unicommerce/order.py @@ -78,8 +78,9 @@ def _get_new_orders( for order in uni_orders: if order["channel"] not in configured_channels: continue - if frappe.db.exists("Sales Order", {ORDER_CODE_FIELD: order["code"]}): - continue + #In case a sales invoice is not generated for some reason and is skipped, we need to create it manually. Therefore, I have commented out this line of code. + # if frappe.db.exists("Sales Order", {ORDER_CODE_FIELD: order["code"]}): + # continue order = client.get_sales_order(order_code=order["code"]) if order: @@ -121,17 +122,23 @@ def create_order(payload: UnicommerceOrder, request_id: Optional[str] = None, cl order = payload - if request_id is None: - log = create_unicommerce_log( - method="ecommerce_integrations.unicommerce.order.create_order", request_data=payload - ) - request_id = log.name + # if request_id is None: + # log = create_unicommerce_log( + # method="ecommerce_integrations.unicommerce.order.create_order", request_data=payload + # ) + # request_id = log.name existing_so = frappe.db.get_value("Sales Order", {ORDER_CODE_FIELD: order["code"]}) if existing_so: so = frappe.get_doc("Sales Order", existing_so) - create_unicommerce_log(status="Invalid", message="Sales Order already exists, skipped") + # create_unicommerce_log(status="Invalid", message="Sales Order already exists, skipped") return so + + if request_id is None: + log = create_unicommerce_log( + method="ecommerce_integrations.unicommerce.order.create_order", request_data=payload + ) + request_id = log.name if client is None: client = UnicommerceAPIClient() diff --git a/ecommerce_integrations/unicommerce/product.py b/ecommerce_integrations/unicommerce/product.py index ac670fda..971206c1 100644 --- a/ecommerce_integrations/unicommerce/product.py +++ b/ecommerce_integrations/unicommerce/product.py @@ -287,8 +287,7 @@ def _build_unicommerce_item(item_code: ItemCode) -> JsonDict: # append site prefix to image url item_json["imageUrl"] = get_url(item.image) item_json["maxRetailPrice"] = frappe.get_value("Item Price",{"item_code":item_code},"price_list_rate") - item_json["hsnCode"] = frappe.get_value("Item",item.name,"gst_hsn_code") - item_json["description"] = frappe.utils.strip_html_tags(frappe.get_value("Item",item.name,"description")) + item_json["description"] = frappe.utils.strip_html_tags(item.description) item_json["costPrice"] = item.valuation_rate return item_json