Skip to content

Commit

Permalink
fix: code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vikas8600 committed May 2, 2023
1 parent 4b24fa6 commit be20d74
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
1 change: 0 additions & 1 deletion ecommerce_integrations/unicommerce/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
IS_COD_CHECKBOX = "unicommerce_is_cod"
SHIPPING_METHOD_FIELD = "unicommerce_shipping_method"
SHIPPIND_ID = "unicommerce_shipment_id"

GRN_STOCK_ENTRY_TYPE = "GRN on Unicommerce"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,13 @@
"default": "0",
"fieldname": "delivery_note",
"fieldtype": "Check",
"label": "Generate Delivery Note"
"label": "Import Delivery Notes from Unicommerce on Shipment"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2023-05-02 10:36:07.140401",
"modified": "2023-05-02 14:04:26.684256",
"modified_by": "Administrator",
"module": "unicommerce",
"name": "Unicommerce Settings",
Expand Down
12 changes: 2 additions & 10 deletions ecommerce_integrations/unicommerce/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ def _get_new_orders(
for order in uni_orders:
if order["channel"] not in configured_channels:
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:
yield order
Expand Down Expand Up @@ -122,18 +120,12 @@ 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

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")
return so

#If a sales order already exists, then every time it's executed
if request_id is None:
log = create_unicommerce_log(
method="ecommerce_integrations.unicommerce.order.create_order", request_data=payload
Expand Down
2 changes: 2 additions & 0 deletions ecommerce_integrations/unicommerce/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def upload_items_to_unicommerce(
for item_code in item_codes:
item_data = _build_unicommerce_item(item_code)
sku = item_data.get("skuCode")

item_exists = bool(client.get_unicommerce_item(sku, log_error=False))
_, status = client.create_update_item(item_data, update=item_exists)

Expand Down Expand Up @@ -291,6 +292,7 @@ def _build_unicommerce_item(item_code: ItemCode) -> JsonDict:
item_json["maxRetailPrice"] = item.standard_rate
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 be20d74

Please sign in to comment.