Skip to content

Commit

Permalink
fix: Give low priority to SKU (#287)
Browse files Browse the repository at this point in the history
SKU is mutable on Shopify, so not a good first metric.
  • Loading branch information
ankush committed Dec 4, 2023
1 parent e249f05 commit 042c88a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ def is_synced(
integration: shopify,
integration_item_code: TSHIRT
"""

if sku:
return _is_sku_synced(integration, sku)

filter = {"integration": integration, "integration_item_code": integration_item_code}

if variant_id:
filter.update({"variant_id": variant_id})

return bool(frappe.db.exists("Ecommerce Item", filter))
item_exists = bool(frappe.db.exists("Ecommerce Item", filter))

if not item_exists and sku:
return _is_sku_synced(integration, sku)
return item_exists


def _is_sku_synced(integration: str, sku: str) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_is_synced_variant(self):
def test_is_synced_sku(self):
self._create_doc_with_sku()
self.assertTrue(ecommerce_item.is_synced("shopify", "T-SHIRT", sku="TEST_ITEM_1"))
self.assertFalse(ecommerce_item.is_synced("shopify", "T-SHIRT", sku="UNKNOWNSKU"))
self.assertFalse(ecommerce_item.is_synced("shopify", "T-SHIRTX", sku="UNKNOWNSKU"))

def test_get_erpnext_item(self):
self._create_doc()
Expand Down

0 comments on commit 042c88a

Please sign in to comment.