mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 12:36:45 +00:00
added test for internal prices
This commit is contained in:
parent
3fb95bea7e
commit
3f04a57452
@ -15,3 +15,37 @@
|
|||||||
part: 3
|
part: 3
|
||||||
quantity: 10
|
quantity: 10
|
||||||
price: 0.10
|
price: 0.10
|
||||||
|
|
||||||
|
|
||||||
|
# Internal price breaks for parts
|
||||||
|
|
||||||
|
# Internal Price breaks for R_2K2_0805
|
||||||
|
|
||||||
|
- model: part.partinternalpricebreak
|
||||||
|
pk: 1
|
||||||
|
fields:
|
||||||
|
part: 3
|
||||||
|
quantity: 1
|
||||||
|
price: 0.08
|
||||||
|
|
||||||
|
- model: part.partinternalpricebreak
|
||||||
|
pk: 2
|
||||||
|
fields:
|
||||||
|
part: 3
|
||||||
|
quantity: 10
|
||||||
|
price: 0.05
|
||||||
|
|
||||||
|
# Internal Price breaks for C_22N_0805
|
||||||
|
- model: part.partinternalpricebreak
|
||||||
|
pk: 3
|
||||||
|
fields:
|
||||||
|
part: 5
|
||||||
|
quantity: 1
|
||||||
|
price: 1
|
||||||
|
|
||||||
|
- model: part.partinternalpricebreak
|
||||||
|
pk: 4
|
||||||
|
fields:
|
||||||
|
part: 5
|
||||||
|
quantity: 24
|
||||||
|
price: 0.5
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
import django.core.exceptions as django_exceptions
|
import django.core.exceptions as django_exceptions
|
||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
from .models import Part, BomItem
|
from .models import Part, BomItem
|
||||||
|
|
||||||
@ -11,11 +12,16 @@ class BomItemTest(TestCase):
|
|||||||
'part',
|
'part',
|
||||||
'location',
|
'location',
|
||||||
'bom',
|
'bom',
|
||||||
|
'company',
|
||||||
|
'supplier_part',
|
||||||
|
'part_pricebreaks',
|
||||||
|
'price_breaks',
|
||||||
]
|
]
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.bob = Part.objects.get(id=100)
|
self.bob = Part.objects.get(id=100)
|
||||||
self.orphan = Part.objects.get(name='Orphan')
|
self.orphan = Part.objects.get(name='Orphan')
|
||||||
|
self.r1 = Part.objects.get(name='R_2K2_0805')
|
||||||
|
|
||||||
def test_str(self):
|
def test_str(self):
|
||||||
b = BomItem.objects.get(id=1)
|
b = BomItem.objects.get(id=1)
|
||||||
@ -111,3 +117,10 @@ class BomItemTest(TestCase):
|
|||||||
item.validate_hash()
|
item.validate_hash()
|
||||||
|
|
||||||
self.assertNotEqual(h1, h2)
|
self.assertNotEqual(h1, h2)
|
||||||
|
|
||||||
|
def test_pricing(self):
|
||||||
|
self.bob.get_price(1)
|
||||||
|
self.assertEqual(self.bob.get_bom_price_range(1, internal=True), (Decimal(84.5), Decimal(89.5)))
|
||||||
|
# remove internal price for R_2K2_0805
|
||||||
|
self.r1.internal_price_breaks.delete()
|
||||||
|
self.assertEqual(self.bob.get_bom_price_range(1, internal=True), (Decimal(82.5), Decimal(87.5)))
|
||||||
|
@ -122,6 +122,14 @@ class PartTest(TestCase):
|
|||||||
self.assertEqual(float(self.r1.get_price(1)), 0.15)
|
self.assertEqual(float(self.r1.get_price(1)), 0.15)
|
||||||
self.assertEqual(float(self.r1.get_price(10)), 1.0)
|
self.assertEqual(float(self.r1.get_price(10)), 1.0)
|
||||||
|
|
||||||
|
def test_internal_pricing(self):
|
||||||
|
# check that the sell pricebreaks were loaded
|
||||||
|
self.assertTrue(self.r1.has_internal_price_breaks)
|
||||||
|
self.assertEqual(self.r1.internal_price_breaks.count(), 2)
|
||||||
|
# check that the sell pricebreaks work
|
||||||
|
self.assertEqual(float(self.r1.get_internal_price(1)), 0.08)
|
||||||
|
self.assertEqual(float(self.r1.get_internal_price(10)), 0.5)
|
||||||
|
|
||||||
class TestTemplateTest(TestCase):
|
class TestTemplateTest(TestCase):
|
||||||
|
|
||||||
fixtures = [
|
fixtures = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user