Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed Dec 7, 2023
2 parents 6790770 + d7db3d0 commit 9554341
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions ecommerce_integrations/shopify/fulfillment.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from copy import deepcopy

import frappe
from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note
from frappe.utils import cint, cstr, getdate
Expand Down Expand Up @@ -62,13 +64,26 @@ def get_fulfillment_items(dn_items, fulfillment_items, location_id=None):
# local import to avoid circular imports
from ecommerce_integrations.shopify.product import get_item_code

fulfillment_items = deepcopy(fulfillment_items)

setting = frappe.get_cached_doc(SETTING_DOCTYPE)
wh_map = setting.get_integration_to_erpnext_wh_mapping()
warehouse = wh_map.get(str(location_id)) or setting.warehouse

return [
dn_item.update({"qty": item.get("quantity"), "warehouse": warehouse})
for item in fulfillment_items
for dn_item in dn_items
if get_item_code(item) == dn_item.item_code
]
final_items = []

def find_matching_fullfilement_item(dn_item):
nonlocal fulfillment_items

for item in fulfillment_items:
if get_item_code(item) == dn_item.item_code:
fulfillment_items.remove(item)
return item

for dn_item in dn_items:
if shopify_item := find_matching_fullfilement_item(dn_item):
final_items.append(
dn_item.update({"qty": shopify_item.get("quantity"), "warehouse": warehouse})
)

return final_items

0 comments on commit 9554341

Please sign in to comment.