mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 11:49:10 +00:00
test: Zero Qty in RFQ and Supplier Quotation
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.tests import IntegrationTestCase, UnitTestCase
|
from frappe.tests import IntegrationTestCase, UnitTestCase, change_settings
|
||||||
from frappe.utils import nowdate
|
from frappe.utils import nowdate
|
||||||
|
|
||||||
from erpnext.buying.doctype.request_for_quotation.request_for_quotation import (
|
from erpnext.buying.doctype.request_for_quotation.request_for_quotation import (
|
||||||
@@ -41,6 +41,15 @@ class TestRequestforQuotation(IntegrationTestCase):
|
|||||||
rfq.save()
|
rfq.save()
|
||||||
self.assertEqual(rfq.items[0].qty, 1)
|
self.assertEqual(rfq.items[0].qty, 1)
|
||||||
|
|
||||||
|
def test_rfq_zero_qty(self):
|
||||||
|
"""
|
||||||
|
Test if RFQ with zero qty (Unit Price Item) is conditionally allowed.
|
||||||
|
"""
|
||||||
|
rfq = make_request_for_quotation(qty=0, do_not_save=True)
|
||||||
|
|
||||||
|
with change_settings("Buying Settings", {"allow_zero_qty_in_request_for_quotation": 1}):
|
||||||
|
rfq.save()
|
||||||
|
|
||||||
def test_quote_status(self):
|
def test_quote_status(self):
|
||||||
rfq = make_request_for_quotation()
|
rfq = make_request_for_quotation()
|
||||||
|
|
||||||
@@ -181,6 +190,15 @@ class TestRequestforQuotation(IntegrationTestCase):
|
|||||||
supplier_doc.reload()
|
supplier_doc.reload()
|
||||||
self.assertTrue(supplier_doc.portal_users[0].user)
|
self.assertTrue(supplier_doc.portal_users[0].user)
|
||||||
|
|
||||||
|
@change_settings("Buying Settings", {"allow_zero_qty_in_request_for_quotation": 1})
|
||||||
|
def test_map_supplier_quotation_from_zero_qty_rfq(self):
|
||||||
|
rfq = make_request_for_quotation(qty=0)
|
||||||
|
sq = make_supplier_quotation_from_rfq(rfq.name, for_supplier=rfq.get("suppliers")[0].supplier)
|
||||||
|
|
||||||
|
self.assertEqual(len(sq.items), 1)
|
||||||
|
self.assertEqual(sq.items[0].qty, 0)
|
||||||
|
self.assertEqual(sq.items[0].item_code, rfq.items[0].item_code)
|
||||||
|
|
||||||
|
|
||||||
def make_request_for_quotation(**args) -> "RequestforQuotation":
|
def make_request_for_quotation(**args) -> "RequestforQuotation":
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
|
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.tests import IntegrationTestCase, UnitTestCase
|
from frappe.tests import IntegrationTestCase, UnitTestCase, change_settings
|
||||||
|
|
||||||
|
from erpnext.buying.doctype.supplier_quotation.supplier_quotation import make_purchase_order
|
||||||
from erpnext.controllers.accounts_controller import InvalidQtyError
|
from erpnext.controllers.accounts_controller import InvalidQtyError
|
||||||
|
|
||||||
|
|
||||||
@@ -29,9 +30,17 @@ class TestPurchaseOrder(IntegrationTestCase):
|
|||||||
sq.save()
|
sq.save()
|
||||||
self.assertEqual(sq.items[0].qty, 1)
|
self.assertEqual(sq.items[0].qty, 1)
|
||||||
|
|
||||||
def test_make_purchase_order(self):
|
def test_supplier_quotation_zero_qty(self):
|
||||||
from erpnext.buying.doctype.supplier_quotation.supplier_quotation import make_purchase_order
|
"""
|
||||||
|
Test if RFQ with zero qty (Unit Price Item) is conditionally allowed.
|
||||||
|
"""
|
||||||
|
sq = frappe.copy_doc(self.globalTestRecords["Supplier Quotation"][0])
|
||||||
|
sq.items[0].qty = 0
|
||||||
|
|
||||||
|
with change_settings("Buying Settings", {"allow_zero_qty_in_supplier_quotation": 1}):
|
||||||
|
sq.save()
|
||||||
|
|
||||||
|
def test_make_purchase_order(self):
|
||||||
sq = frappe.copy_doc(self.globalTestRecords["Supplier Quotation"][0]).insert()
|
sq = frappe.copy_doc(self.globalTestRecords["Supplier Quotation"][0]).insert()
|
||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, make_purchase_order, sq.name)
|
self.assertRaises(frappe.ValidationError, make_purchase_order, sq.name)
|
||||||
@@ -50,3 +59,14 @@ class TestPurchaseOrder(IntegrationTestCase):
|
|||||||
doc.set("schedule_date", "2013-04-12")
|
doc.set("schedule_date", "2013-04-12")
|
||||||
|
|
||||||
po.insert()
|
po.insert()
|
||||||
|
|
||||||
|
@change_settings("Buying Settings", {"allow_zero_qty_in_supplier_quotation": 1})
|
||||||
|
def test_map_purchase_order_from_zero_qty_supplier_quotation(self):
|
||||||
|
sq = frappe.copy_doc(self.globalTestRecords["Supplier Quotation"][0])
|
||||||
|
sq.items[0].qty = 0
|
||||||
|
sq.submit()
|
||||||
|
|
||||||
|
po = make_purchase_order(sq.name)
|
||||||
|
self.assertEqual(len(po.get("items")), 1)
|
||||||
|
self.assertEqual(po.get("items")[0].qty, 0)
|
||||||
|
self.assertEqual(po.get("items")[0].item_code, sq.get("items")[0].item_code)
|
||||||
|
|||||||
Reference in New Issue
Block a user