Skip to content

Commit

Permalink
fix: sales invoice getting skip
Browse files Browse the repository at this point in the history
  • Loading branch information
Vikas8600 committed May 1, 2023
1 parent d56d55e commit 40adea6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
23 changes: 15 additions & 8 deletions ecommerce_integrations/unicommerce/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions ecommerce_integrations/unicommerce/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 40adea6

Please sign in to comment.