Skip to content

Commit

Permalink
Fix bug in Mouser price calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeoLacruz committed Dec 8, 2024
1 parent cf9b96d commit b58d92c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion inventree_supplier_panel/mouser.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,16 @@ def get_mouser_package(self, part_data):
# --------------------------- reformat_mouser_price --------------------------
# We need a Mouser specific modification to the price answer because they put
# funny things inside like an EURO sign and they use , instead of .

def reformat_mouser_price(self, price):
price = price.replace('.', '')
price = price.replace(',', '.')
non_decimal = re.compile(r'[^\d.]+')
price = float(non_decimal.sub('', price))
price = non_decimal.sub('', price)
if price == '':
price = 0
else:
price = float(price)
return price

# ------------------------ create_cart -------------------------------------------
Expand Down

1 comment on commit b58d92c

@SergeoLacruz
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closes #8

Please sign in to comment.