mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 16:34:46 +00:00
test cases
This commit is contained in:
@@ -5,8 +5,47 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
from erpnext.stock.get_item_details import get_pos_profile
|
||||||
# test_records = frappe.get_test_records('POS Profile')
|
from erpnext.accounts.doctype.sales_invoice.pos import get_items_list, get_customers_list
|
||||||
|
|
||||||
class TestPOSProfile(unittest.TestCase):
|
class TestPOSProfile(unittest.TestCase):
|
||||||
pass
|
def test_pos_profile(self):
|
||||||
|
make_pos_profile()
|
||||||
|
|
||||||
|
pos_profile = get_pos_profile("_Test Company") or {}
|
||||||
|
if pos_profile:
|
||||||
|
doc = frappe.get_doc("POS Profile", pos_profile.get("name"))
|
||||||
|
doc.append('item_groups', {'item_group': '_Test Item Group'})
|
||||||
|
doc.append('customer_groups', {'customer_group': '_Test Customer Group'})
|
||||||
|
doc.save()
|
||||||
|
|
||||||
|
items = get_items_list(doc)
|
||||||
|
customers = get_customers_list(doc)
|
||||||
|
|
||||||
|
products_count = frappe.db.sql(""" select count(name) from tabItem where item_group = '_Test Item Group'""", as_list=1)
|
||||||
|
customers_count = frappe.db.sql(""" select count(name) from tabCustomer where customer_group = '_Test Customer Group'""")
|
||||||
|
|
||||||
|
self.assertEquals(len(items), products_count[0][0])
|
||||||
|
self.assertEquals(len(customers), customers_count[0][0])
|
||||||
|
|
||||||
|
frappe.db.sql("delete from `tabPOS Profile`")
|
||||||
|
|
||||||
|
def make_pos_profile():
|
||||||
|
pos_profile = frappe.get_doc({
|
||||||
|
"company": "_Test Company",
|
||||||
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
"currency": "INR",
|
||||||
|
"doctype": "POS Profile",
|
||||||
|
"expense_account": "_Test Account Cost for Goods Sold - _TC",
|
||||||
|
"income_account": "Sales - _TC",
|
||||||
|
"name": "_Test POS Profile",
|
||||||
|
"naming_series": "_T-POS Profile-",
|
||||||
|
"selling_price_list": "_Test Price List",
|
||||||
|
"territory": "_Test Territory",
|
||||||
|
"warehouse": "_Test Warehouse - _TC",
|
||||||
|
"write_off_account": "_Test Write Off - _TC",
|
||||||
|
"write_off_cost_center": "_Test Write Off Cost Center - _TC"
|
||||||
|
})
|
||||||
|
|
||||||
|
if not frappe.db.exists("POS Profile", "_Test POS Profile"):
|
||||||
|
pos_profile.insert()
|
||||||
@@ -133,6 +133,8 @@ def get_items_list(pos_profile):
|
|||||||
cond = "1=1"
|
cond = "1=1"
|
||||||
item_groups = []
|
item_groups = []
|
||||||
if pos_profile.get('item_groups'):
|
if pos_profile.get('item_groups'):
|
||||||
|
# Get items based on the item groups defined in the POS profile
|
||||||
|
|
||||||
cond = "item_group in (%s)"%(', '.join(['%s']*len(pos_profile.get('item_groups'))))
|
cond = "item_group in (%s)"%(', '.join(['%s']*len(pos_profile.get('item_groups'))))
|
||||||
item_groups = [d.item_group for d in pos_profile.get('item_groups')]
|
item_groups = [d.item_group for d in pos_profile.get('item_groups')]
|
||||||
|
|
||||||
@@ -143,6 +145,8 @@ def get_customers_list(pos_profile):
|
|||||||
cond = "1=1"
|
cond = "1=1"
|
||||||
customer_groups = []
|
customer_groups = []
|
||||||
if pos_profile.get('customer_groups'):
|
if pos_profile.get('customer_groups'):
|
||||||
|
# Get customers based on the customer groups defined in the POS profile
|
||||||
|
|
||||||
cond = "customer_group in (%s)"%(', '.join(['%s']*len(pos_profile.get('customer_groups'))))
|
cond = "customer_group in (%s)"%(', '.join(['%s']*len(pos_profile.get('customer_groups'))))
|
||||||
customer_groups = [d.customer_group for d in pos_profile.get('customer_groups')]
|
customer_groups = [d.customer_group for d in pos_profile.get('customer_groups')]
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import unittest, copy
|
|||||||
from frappe.utils import nowdate, add_days, flt, nowdate
|
from frappe.utils import nowdate, add_days, flt, nowdate
|
||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry, get_qty_after_transaction
|
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry, get_qty_after_transaction
|
||||||
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import unlink_payment_on_cancel_of_invoice
|
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import unlink_payment_on_cancel_of_invoice
|
||||||
|
from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile
|
||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
||||||
from erpnext.exceptions import InvalidAccountCurrency, InvalidCurrency
|
from erpnext.exceptions import InvalidAccountCurrency, InvalidCurrency
|
||||||
from erpnext.stock.doctype.serial_no.serial_no import SerialNoWarehouseError
|
from erpnext.stock.doctype.serial_no.serial_no import SerialNoWarehouseError
|
||||||
@@ -467,7 +468,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
def test_pos_gl_entry_with_perpetual_inventory(self):
|
def test_pos_gl_entry_with_perpetual_inventory(self):
|
||||||
set_perpetual_inventory()
|
set_perpetual_inventory()
|
||||||
self.make_pos_profile()
|
make_pos_profile()
|
||||||
|
|
||||||
self._insert_purchase_receipt()
|
self._insert_purchase_receipt()
|
||||||
pos = copy.deepcopy(test_records[1])
|
pos = copy.deepcopy(test_records[1])
|
||||||
@@ -486,7 +487,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
def test_pos_change_amount(self):
|
def test_pos_change_amount(self):
|
||||||
set_perpetual_inventory()
|
set_perpetual_inventory()
|
||||||
self.make_pos_profile()
|
make_pos_profile()
|
||||||
|
|
||||||
self._insert_purchase_receipt()
|
self._insert_purchase_receipt()
|
||||||
pos = copy.deepcopy(test_records[1])
|
pos = copy.deepcopy(test_records[1])
|
||||||
@@ -508,7 +509,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
set_perpetual_inventory()
|
set_perpetual_inventory()
|
||||||
|
|
||||||
self.make_pos_profile()
|
make_pos_profile()
|
||||||
self._insert_purchase_receipt()
|
self._insert_purchase_receipt()
|
||||||
|
|
||||||
pos = copy.deepcopy(test_records[1])
|
pos = copy.deepcopy(test_records[1])
|
||||||
@@ -572,26 +573,6 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
frappe.db.sql("delete from `tabPOS Profile`")
|
frappe.db.sql("delete from `tabPOS Profile`")
|
||||||
|
|
||||||
def make_pos_profile(self):
|
|
||||||
pos_profile = frappe.get_doc({
|
|
||||||
"company": "_Test Company",
|
|
||||||
"cost_center": "_Test Cost Center - _TC",
|
|
||||||
"currency": "INR",
|
|
||||||
"doctype": "POS Profile",
|
|
||||||
"expense_account": "_Test Account Cost for Goods Sold - _TC",
|
|
||||||
"income_account": "Sales - _TC",
|
|
||||||
"name": "_Test POS Profile",
|
|
||||||
"naming_series": "_T-POS Profile-",
|
|
||||||
"selling_price_list": "_Test Price List",
|
|
||||||
"territory": "_Test Territory",
|
|
||||||
"warehouse": "_Test Warehouse - _TC",
|
|
||||||
"write_off_account": "_Test Write Off - _TC",
|
|
||||||
"write_off_cost_center": "_Test Write Off Cost Center - _TC"
|
|
||||||
})
|
|
||||||
|
|
||||||
if not frappe.db.exists("POS Profile", "_Test POS Profile"):
|
|
||||||
pos_profile.insert()
|
|
||||||
|
|
||||||
def test_sales_invoice_gl_entry_with_perpetual_inventory_no_item_code(self):
|
def test_sales_invoice_gl_entry_with_perpetual_inventory_no_item_code(self):
|
||||||
set_perpetual_inventory()
|
set_perpetual_inventory()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user