mirror of
https://github.com/inventree/InvenTree.git
synced 2025-12-19 10:43:28 +00:00
Remove get_price_info method
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
"""Unit tests for the models in the 'company' app"""
|
"""Unit tests for the models in the 'company' app"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from decimal import Decimal
|
|
||||||
|
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
@@ -89,24 +88,6 @@ class CompanySimpleTest(TestCase):
|
|||||||
self.assertEqual(p(45), 315)
|
self.assertEqual(p(45), 315)
|
||||||
self.assertEqual(p(55), 68.75)
|
self.assertEqual(p(55), 68.75)
|
||||||
|
|
||||||
def test_part_pricing(self):
|
|
||||||
"""Unit tests for supplier part pricing"""
|
|
||||||
m2x4 = Part.objects.get(name='M2x4 LPHS')
|
|
||||||
|
|
||||||
self.assertEqual(m2x4.get_price_info(5.5), "38.5 - 41.25")
|
|
||||||
self.assertEqual(m2x4.get_price_info(10), "70 - 75")
|
|
||||||
self.assertEqual(m2x4.get_price_info(100), "125 - 350")
|
|
||||||
|
|
||||||
pmin, pmax = m2x4.get_price_range(5)
|
|
||||||
self.assertEqual(pmin, 35)
|
|
||||||
self.assertEqual(pmax, 37.5)
|
|
||||||
|
|
||||||
m3x12 = Part.objects.get(name='M3x12 SHCS')
|
|
||||||
|
|
||||||
self.assertEqual(m3x12.get_price_info(0.3), Decimal('2.4'))
|
|
||||||
self.assertEqual(m3x12.get_price_info(3), Decimal('24'))
|
|
||||||
self.assertIsNotNone(m3x12.get_price_info(50))
|
|
||||||
|
|
||||||
def test_currency_validation(self):
|
def test_currency_validation(self):
|
||||||
"""Test validation for currency selection."""
|
"""Test validation for currency selection."""
|
||||||
# Create a company with a valid currency code (should pass)
|
# Create a company with a valid currency code (should pass)
|
||||||
|
|||||||
@@ -1667,30 +1667,6 @@ class Part(InvenTreeBarcodeMixin, MetadataMixin, MPTTModel):
|
|||||||
except (PartPricing.DoesNotExist, IntegrityError):
|
except (PartPricing.DoesNotExist, IntegrityError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_price_info(self, quantity=1, buy=True, bom=True, internal=False):
|
|
||||||
"""Return a simplified pricing string for this part.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
quantity: Number of units to calculate price for
|
|
||||||
buy: Include supplier pricing (default = True)
|
|
||||||
bom: Include BOM pricing (default = True)
|
|
||||||
internal: Include internal pricing (default = False)
|
|
||||||
"""
|
|
||||||
price_range = self.get_price_range(quantity, buy, bom, internal)
|
|
||||||
|
|
||||||
if price_range is None:
|
|
||||||
return None
|
|
||||||
|
|
||||||
min_price, max_price = price_range
|
|
||||||
|
|
||||||
if min_price == max_price:
|
|
||||||
return min_price
|
|
||||||
|
|
||||||
min_price = normalize(min_price)
|
|
||||||
max_price = normalize(max_price)
|
|
||||||
|
|
||||||
return "{a} - {b}".format(a=min_price, b=max_price)
|
|
||||||
|
|
||||||
def get_supplier_price_range(self, quantity=1):
|
def get_supplier_price_range(self, quantity=1):
|
||||||
"""Return the supplier price range of this part:
|
"""Return the supplier price range of this part:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user