Skip to content

Commit

Permalink
Decode Digikey pack codes
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeoLacruz committed Jun 2, 2024
1 parent f97dd00 commit 2c1c3d1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion inventree_supplier_panel/supplier_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ def get_mouser_package(self, part_data):
# The list can easily be transferred into an order in the web interface.

def update_digikey_cart(self, order, list_id):
pack_types = {'TR': 'full reel', 'DKR': 'DigiReel', 'CT': 'cut tape', 'BAG': 'bulk'}
url = f'https://api.digikey.com/mylists/v1/lists/{list_id}/parts'
header = {'Authorization': f"{'Bearer'} {self.get_setting('DIGIKEY_TOKEN')}",
'X-DIGIKEY-Client-Id': self.get_setting('DIGIKEY_CLIENT_ID'),
Expand Down Expand Up @@ -430,13 +431,17 @@ def update_digikey_cart(self, order, list_id):
'Error': 'Minimum order quantity not reached',
})
else:
try:
pack = pack_types[pack_option['PackType']]
except Exception:
pack = pack_option['PackType']
cart_items.append({'SKU': p['DigiKeyPartNumber'],
'IPN': p['CustomerReference'],
'QuantityRequested': p['Quantities'][0]['QuantityRequested'],
'QuantityAvailable': p['QuantityAvailable'],
'UnitPrice': pack_option['CalculatedUnitPrice'],
'ExtendedPrice': pack_option['ExtendedPrice'],
'Error': pack_option['PackType'],
'Error': pack,
})
merchandise_total = merchandise_total + pack_option['ExtendedPrice']
else:
Expand Down

0 comments on commit 2c1c3d1

Please sign in to comment.