mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-27 10:38:30 +00:00
test: auto-filling of basic details on items
This commit is contained in:
@@ -207,3 +207,23 @@ class AccountsTestMixin:
|
||||
]
|
||||
for doctype in doctype_list:
|
||||
qb.from_(qb.DocType(doctype)).delete().where(qb.DocType(doctype).company == self.company).run()
|
||||
|
||||
def create_price_list(self):
|
||||
pl_name = "Mixin Price List"
|
||||
if not frappe.db.exists("Price List", pl_name):
|
||||
self.price_list = (
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Price List",
|
||||
"currency": "INR",
|
||||
"enabled": True,
|
||||
"selling": True,
|
||||
"buying": True,
|
||||
"price_list_name": pl_name,
|
||||
}
|
||||
)
|
||||
.insert()
|
||||
.name
|
||||
)
|
||||
else:
|
||||
self.price_list = frappe.get_doc("Price List", pl_name).name
|
||||
|
||||
50
erpnext/utilities/test_transaction_base.py
Normal file
50
erpnext/utilities/test_transaction_base.py
Normal file
@@ -0,0 +1,50 @@
|
||||
import frappe
|
||||
from frappe import qb
|
||||
from frappe.tests import IntegrationTestCase
|
||||
from frappe.utils import getdate, today
|
||||
|
||||
from erpnext.accounts.test.accounts_mixin import AccountsTestMixin
|
||||
|
||||
|
||||
class TestAccountsController(AccountsTestMixin, IntegrationTestCase):
|
||||
def setUp(self):
|
||||
self.create_company()
|
||||
self.create_customer()
|
||||
self.create_item()
|
||||
self.create_usd_receivable_account()
|
||||
self.create_price_list()
|
||||
self.clear_old_entries()
|
||||
|
||||
def tearDown(self):
|
||||
frappe.db.rollback()
|
||||
|
||||
def test_01_basic_item_details(self):
|
||||
# set Item Price
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Item Price",
|
||||
"item_code": self.item,
|
||||
"price_list": self.price_list,
|
||||
"price_list_rate": 90,
|
||||
"selling": True,
|
||||
"rate": 90,
|
||||
"valid_from": today(),
|
||||
}
|
||||
).insert()
|
||||
|
||||
si = frappe.get_doc(
|
||||
{
|
||||
"doctype": "Sales Invoice",
|
||||
"company": self.company,
|
||||
"customer": self.customer,
|
||||
"debit_to": self.debit_to,
|
||||
"posting_date": today(),
|
||||
"cost_center": self.cost_center,
|
||||
"conversion_rate": 1,
|
||||
"selling_price_list": self.price_list,
|
||||
}
|
||||
)
|
||||
itm = si.append("items")
|
||||
itm.item_code = self.item
|
||||
si.process_item_selection(si.items[0].name)
|
||||
self.assertEqual(itm.rate, 90)
|
||||
Reference in New Issue
Block a user