mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
tests for new methods in #1509
This commit is contained in:
parent
c14478ed1f
commit
7cb858546e
@ -50,6 +50,15 @@
|
|||||||
supplier: 3
|
supplier: 3
|
||||||
status: 40 # Cancelled
|
status: 40 # Cancelled
|
||||||
|
|
||||||
|
# for pricebreaks
|
||||||
|
- model: order.purchaseorder
|
||||||
|
pk: 7
|
||||||
|
fields:
|
||||||
|
reference: '0007'
|
||||||
|
description: 'Another PO'
|
||||||
|
supplier: 2
|
||||||
|
status: 10 # Pending
|
||||||
|
|
||||||
# Add some line items against PO 0001
|
# Add some line items against PO 0001
|
||||||
|
|
||||||
# 100 x ACME0001 (M2x4 LPHS)
|
# 100 x ACME0001 (M2x4 LPHS)
|
||||||
|
@ -21,6 +21,7 @@ class OrderTest(TestCase):
|
|||||||
fixtures = [
|
fixtures = [
|
||||||
'company',
|
'company',
|
||||||
'supplier_part',
|
'supplier_part',
|
||||||
|
'price_breaks',
|
||||||
'category',
|
'category',
|
||||||
'part',
|
'part',
|
||||||
'location',
|
'location',
|
||||||
@ -63,7 +64,7 @@ class OrderTest(TestCase):
|
|||||||
|
|
||||||
next_ref = PurchaseOrder.getNextOrderNumber()
|
next_ref = PurchaseOrder.getNextOrderNumber()
|
||||||
|
|
||||||
self.assertEqual(next_ref, '0007')
|
self.assertEqual(next_ref, '0008')
|
||||||
|
|
||||||
def test_on_order(self):
|
def test_on_order(self):
|
||||||
""" There should be 3 separate items on order for the M2x4 LPHS part """
|
""" There should be 3 separate items on order for the M2x4 LPHS part """
|
||||||
@ -117,6 +118,39 @@ class OrderTest(TestCase):
|
|||||||
with self.assertRaises(django_exceptions.ValidationError):
|
with self.assertRaises(django_exceptions.ValidationError):
|
||||||
order.add_line_item(sku, 99)
|
order.add_line_item(sku, 99)
|
||||||
|
|
||||||
|
def test_pricing(self):
|
||||||
|
""" Test functions for adding line items to an order including price-breaks """
|
||||||
|
|
||||||
|
order = PurchaseOrder.objects.get(pk=7)
|
||||||
|
|
||||||
|
self.assertEqual(order.status, PurchaseOrderStatus.PENDING)
|
||||||
|
self.assertEqual(order.lines.count(), 0)
|
||||||
|
|
||||||
|
sku = SupplierPart.objects.get(SKU='ZERGM312')
|
||||||
|
part = sku.part
|
||||||
|
|
||||||
|
# Order the part
|
||||||
|
self.assertEqual(part.on_order, 0)
|
||||||
|
|
||||||
|
# Order 25 with manually set high value
|
||||||
|
pp = sku.get_price(25)
|
||||||
|
order.add_line_item(sku, 25, purchase_price=pp)
|
||||||
|
self.assertEqual(part.on_order, 25)
|
||||||
|
self.assertEqual(order.lines.count(), 1)
|
||||||
|
self.assertEqual(order.lines.first().purchase_price.amount, 200)
|
||||||
|
|
||||||
|
# Add a few, now the pricebreak should adjust although wrong price given
|
||||||
|
order.add_line_item(sku, 10, purchase_price=sku.get_price(25))
|
||||||
|
self.assertEqual(part.on_order, 35)
|
||||||
|
self.assertEqual(order.lines.count(), 1)
|
||||||
|
self.assertEqual(order.lines.first().purchase_price.amount, 8)
|
||||||
|
|
||||||
|
# Order the same part again (it should be merged)
|
||||||
|
order.add_line_item(sku, 100, purchase_price=sku.get_price(100))
|
||||||
|
self.assertEqual(order.lines.count(), 1)
|
||||||
|
self.assertEqual(part.on_order, 135)
|
||||||
|
self.assertEqual(order.lines.first().purchase_price.amount, 1.25)
|
||||||
|
|
||||||
def test_receive(self):
|
def test_receive(self):
|
||||||
""" Test order receiving functions """
|
""" Test order receiving functions """
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user