Allow multiple lines of the same SKU at different prices.
parent
cc66d44bd1
commit
3918882d04
|
@ -131,6 +131,7 @@ def process_files(file): #I am assuming I am getting a sorted csv file by order
|
||||||
# shipzip = row[13]
|
# shipzip = row[13]
|
||||||
tracking = row[16]
|
tracking = row[16]
|
||||||
weight = row[18]
|
weight = row[18]
|
||||||
|
#pprint.pprint(order_id)
|
||||||
taxes = shopify_order_info[0]['current_total_tax']#row[22]
|
taxes = shopify_order_info[0]['current_total_tax']#row[22]
|
||||||
ship_charge = shopify_order_info[0]['shipping_lines__price']#row[21]
|
ship_charge = shopify_order_info[0]['shipping_lines__price']#row[21]
|
||||||
discount = shopify_order_info[0]['current_total_discounts']#row[24]
|
discount = shopify_order_info[0]['current_total_discounts']#row[24]
|
||||||
|
@ -148,7 +149,7 @@ def process_files(file): #I am assuming I am getting a sorted csv file by order
|
||||||
line_qty = row[3]
|
line_qty = row[3]
|
||||||
line_lot = row[4]
|
line_lot = row[4]
|
||||||
line_price = row[20]
|
line_price = row[20]
|
||||||
shopify_item_data = get_item_from_shopify_order(shopify_order_info, line_product)
|
shopify_item_data = get_item_from_shopify_order(shopify_order_info, line_product, line_price)
|
||||||
sales_order.append(
|
sales_order.append(
|
||||||
SalesOrderDetail(
|
SalesOrderDetail(
|
||||||
itmref=shopify_item_data['sku'],#line_product,
|
itmref=shopify_item_data['sku'],#line_product,
|
||||||
|
@ -163,9 +164,9 @@ def process_files(file): #I am assuming I am getting a sorted csv file by order
|
||||||
sales_order.output(import_file)
|
sales_order.output(import_file)
|
||||||
|
|
||||||
|
|
||||||
def get_item_from_shopify_order(line_item_list, product):
|
def get_item_from_shopify_order(line_item_list, product, gropri):
|
||||||
for record in line_item_list:
|
for record in line_item_list:
|
||||||
if record['sku'] == product:
|
if record['sku'] == product and str(record['price']).rstrip('0') == gropri:
|
||||||
return record
|
return record
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -402,12 +403,14 @@ class SalesOrderDetailList:
|
||||||
"""
|
"""
|
||||||
itmref = salesorder_detail.itmref
|
itmref = salesorder_detail.itmref
|
||||||
qty = salesorder_detail.qty
|
qty = salesorder_detail.qty
|
||||||
if itmref in self._item_set:
|
gropri = salesorder_detail.gropri
|
||||||
|
set_item = itmref + '_' + str(gropri)
|
||||||
|
if set_item in self._item_set:
|
||||||
for detail in self._details:
|
for detail in self._details:
|
||||||
if detail.itmref == itmref:
|
if detail.itmref+'_'+str(detail.gropri) == set_item:
|
||||||
detail.qty += qty
|
detail.qty += qty
|
||||||
else:
|
else:
|
||||||
self._item_set.add(itmref)
|
self._item_set.add(set_item)
|
||||||
self._details.append(salesorder_detail)
|
self._details.append(salesorder_detail)
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
|
|
|
@ -57,7 +57,7 @@ def find_so_from_po(cust_po):
|
||||||
"""
|
"""
|
||||||
select
|
select
|
||||||
SOHNUM_0
|
SOHNUM_0
|
||||||
from PROD.SORDER
|
from [PROD].SORDER
|
||||||
where
|
where
|
||||||
SOHTYP_0 = 'WEB'
|
SOHTYP_0 = 'WEB'
|
||||||
and BPCORD_0 = 'STSHOPIFY'
|
and BPCORD_0 = 'STSHOPIFY'
|
||||||
|
@ -120,6 +120,7 @@ def process_files(file):
|
||||||
sohnum=sohnum,
|
sohnum=sohnum,
|
||||||
itmref=line_product,
|
itmref=line_product,
|
||||||
qty=int(line_qty),
|
qty=int(line_qty),
|
||||||
|
gropri=line_price,
|
||||||
),
|
),
|
||||||
subdetail,
|
subdetail,
|
||||||
)
|
)
|
||||||
|
@ -176,6 +177,7 @@ class WarehouseShipmentDetail:
|
||||||
subdetails: typing.List[WarehouseShipmentSubDetail] = dataclasses.field(
|
subdetails: typing.List[WarehouseShipmentSubDetail] = dataclasses.field(
|
||||||
default_factory=list
|
default_factory=list
|
||||||
)
|
)
|
||||||
|
gropri: decimal.Decimal = decimal.Decimal() #to match against when multiple of the same skus are used
|
||||||
|
|
||||||
def append(self, subdetail: WarehouseShipmentSubDetail):
|
def append(self, subdetail: WarehouseShipmentSubDetail):
|
||||||
"""
|
"""
|
||||||
|
@ -238,9 +240,11 @@ class WarehouseShipmentDetail:
|
||||||
where
|
where
|
||||||
[SOP].[SOHNUM_0] = :sohnum
|
[SOP].[SOHNUM_0] = :sohnum
|
||||||
and [SOP].[ITMREF_0] = :itmref
|
and [SOP].[ITMREF_0] = :itmref
|
||||||
|
and [SOP].[GROPRI_0] = :gropri
|
||||||
""",
|
""",
|
||||||
sohnum=self.sohnum,
|
sohnum=self.sohnum,
|
||||||
itmref=self.itmref,
|
itmref=self.itmref,
|
||||||
|
gropri=self.gropri,
|
||||||
)
|
)
|
||||||
.first()
|
.first()
|
||||||
.how_many
|
.how_many
|
||||||
|
@ -256,11 +260,13 @@ class WarehouseShipmentDetail:
|
||||||
where
|
where
|
||||||
[SOP].[SOHNUM_0] = :sohnum
|
[SOP].[SOHNUM_0] = :sohnum
|
||||||
and [SOP].[ITMREF_0] = :itmref
|
and [SOP].[ITMREF_0] = :itmref
|
||||||
|
and [SOP].[GROPRI_0] = :gropri
|
||||||
order by
|
order by
|
||||||
[SOP].[SOPLIN_0]
|
[SOP].[SOPLIN_0]
|
||||||
""",
|
""",
|
||||||
sohnum=self.sohnum,
|
sohnum=self.sohnum,
|
||||||
itmref=self.itmref,
|
itmref=self.itmref,
|
||||||
|
gropri=self.gropri,
|
||||||
).first()
|
).first()
|
||||||
else:
|
else:
|
||||||
pprint.pprint(self.sohnum)
|
pprint.pprint(self.sohnum)
|
||||||
|
@ -464,12 +470,13 @@ class WarehouseShipmentDetailList:
|
||||||
Append
|
Append
|
||||||
"""
|
"""
|
||||||
itmref = shipment_detail.itmref
|
itmref = shipment_detail.itmref
|
||||||
if itmref in self._item_set:
|
set_item = itmref+'_'+str(shipment_detail.gropri)
|
||||||
|
if set_item in self._item_set:
|
||||||
for detail in self._details:
|
for detail in self._details:
|
||||||
if detail == itmref:
|
if detail.itmref+'_'+str(detail.gropri) == set_item:
|
||||||
detail.subdetails.append(shipment_subdetail)
|
detail.subdetails.append(shipment_subdetail)
|
||||||
return
|
return
|
||||||
self._item_set.add(itmref)
|
self._item_set.add(set_item)
|
||||||
shipment_detail.fill()
|
shipment_detail.fill()
|
||||||
shipment_detail.append(shipment_subdetail)
|
shipment_detail.append(shipment_subdetail)
|
||||||
self._details.append(shipment_detail)
|
self._details.append(shipment_detail)
|
||||||
|
|
Loading…
Reference in New Issue