Merge pull request #4189 from nabinhait/dn_target_wh_testcase
Test case fixed for swtiching valuation method
This commit is contained in:
commit
c52a601e87
@ -16,7 +16,8 @@ from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_invoice
|
|||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry \
|
from erpnext.stock.doctype.stock_entry.test_stock_entry \
|
||||||
import make_stock_entry, make_serialized_item, get_qty_after_transaction
|
import make_stock_entry, make_serialized_item, get_qty_after_transaction
|
||||||
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos, SerialNoWarehouseError
|
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos, SerialNoWarehouseError
|
||||||
from erpnext.stock.doctype.stock_reconciliation.test_stock_reconciliation import create_stock_reconciliation
|
from erpnext.stock.doctype.stock_reconciliation.test_stock_reconciliation \
|
||||||
|
import create_stock_reconciliation, set_valuation_method
|
||||||
|
|
||||||
class TestDeliveryNote(unittest.TestCase):
|
class TestDeliveryNote(unittest.TestCase):
|
||||||
def test_over_billing_against_dn(self):
|
def test_over_billing_against_dn(self):
|
||||||
@ -57,7 +58,7 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
def test_delivery_note_gl_entry(self):
|
def test_delivery_note_gl_entry(self):
|
||||||
set_perpetual_inventory()
|
set_perpetual_inventory()
|
||||||
self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
||||||
frappe.db.set_value("Item", "_Test Item", "valuation_method", "FIFO")
|
set_valuation_method("_Test Item", "FIFO")
|
||||||
|
|
||||||
make_stock_entry(target="_Test Warehouse - _TC", qty=5, basic_rate=100)
|
make_stock_entry(target="_Test Warehouse - _TC", qty=5, basic_rate=100)
|
||||||
|
|
||||||
@ -326,13 +327,15 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
|
|
||||||
def test_delivery_of_bundled_items_to_target_warehouse(self):
|
def test_delivery_of_bundled_items_to_target_warehouse(self):
|
||||||
set_perpetual_inventory()
|
set_perpetual_inventory()
|
||||||
frappe.db.set_value("Item", "_Test Item", "valuation_method", "FIFO")
|
|
||||||
|
set_valuation_method("_Test Item", "FIFO")
|
||||||
|
set_valuation_method("_Test Item Home Desktop 100", "FIFO")
|
||||||
|
|
||||||
for warehouse in ("_Test Warehouse - _TC", "_Test Warehouse 1 - _TC"):
|
for warehouse in ("_Test Warehouse - _TC", "_Test Warehouse 1 - _TC"):
|
||||||
create_stock_reconciliation(item_code="_Test Item", target=warehouse,
|
create_stock_reconciliation(item_code="_Test Item", target=warehouse,
|
||||||
qty=50, rate=100)
|
qty=100, rate=100)
|
||||||
create_stock_reconciliation(item_code="_Test Item Home Desktop 100",
|
create_stock_reconciliation(item_code="_Test Item Home Desktop 100",
|
||||||
target=warehouse, qty=50, rate=100)
|
target=warehouse, qty=100, rate=100)
|
||||||
|
|
||||||
opening_qty_test_warehouse_1 = get_qty_after_transaction(warehouse="_Test Warehouse 1 - _TC")
|
opening_qty_test_warehouse_1 = get_qty_after_transaction(warehouse="_Test Warehouse 1 - _TC")
|
||||||
|
|
||||||
@ -343,19 +346,36 @@ class TestDeliveryNote(unittest.TestCase):
|
|||||||
|
|
||||||
# qty after delivery
|
# qty after delivery
|
||||||
actual_qty = get_qty_after_transaction(warehouse="_Test Warehouse - _TC")
|
actual_qty = get_qty_after_transaction(warehouse="_Test Warehouse - _TC")
|
||||||
self.assertEquals(actual_qty, 25)
|
self.assertEquals(actual_qty, 75)
|
||||||
|
|
||||||
actual_qty = get_qty_after_transaction(warehouse="_Test Warehouse 1 - _TC")
|
actual_qty = get_qty_after_transaction(warehouse="_Test Warehouse 1 - _TC")
|
||||||
self.assertEquals(actual_qty, opening_qty_test_warehouse_1 + 25)
|
self.assertEquals(actual_qty, opening_qty_test_warehouse_1 + 25)
|
||||||
|
|
||||||
# stock value diff for source warehouse
|
# stock value diff for source warehouse
|
||||||
stock_value_difference = frappe.db.get_value("Stock Ledger Entry", {"voucher_type": "Delivery Note",
|
# for "_Test Item"
|
||||||
"voucher_no": dn.name, "item_code": "_Test Item Home Desktop 100", "warehouse": "_Test Warehouse - _TC"},
|
stock_value_difference = frappe.db.get_value("Stock Ledger Entry",
|
||||||
|
{"voucher_type": "Delivery Note", "voucher_no": dn.name,
|
||||||
|
"item_code": "_Test Item", "warehouse": "_Test Warehouse - _TC"},
|
||||||
"stock_value_difference")
|
"stock_value_difference")
|
||||||
|
|
||||||
# stock value diff for target warehouse
|
# stock value diff for target warehouse
|
||||||
stock_value_difference1 = frappe.db.get_value("Stock Ledger Entry", {"voucher_type": "Delivery Note",
|
stock_value_difference1 = frappe.db.get_value("Stock Ledger Entry",
|
||||||
"voucher_no": dn.name, "item_code": "_Test Item Home Desktop 100", "warehouse": "_Test Warehouse 1 - _TC"},
|
{"voucher_type": "Delivery Note", "voucher_no": dn.name,
|
||||||
|
"item_code": "_Test Item", "warehouse": "_Test Warehouse 1 - _TC"},
|
||||||
|
"stock_value_difference")
|
||||||
|
|
||||||
|
self.assertEquals(abs(stock_value_difference), stock_value_difference1)
|
||||||
|
|
||||||
|
# for "_Test Item Home Desktop 100"
|
||||||
|
stock_value_difference = frappe.db.get_value("Stock Ledger Entry",
|
||||||
|
{"voucher_type": "Delivery Note", "voucher_no": dn.name,
|
||||||
|
"item_code": "_Test Item Home Desktop 100", "warehouse": "_Test Warehouse - _TC"},
|
||||||
|
"stock_value_difference")
|
||||||
|
|
||||||
|
# stock value diff for target warehouse
|
||||||
|
stock_value_difference1 = frappe.db.get_value("Stock Ledger Entry",
|
||||||
|
{"voucher_type": "Delivery Note", "voucher_no": dn.name,
|
||||||
|
"item_code": "_Test Item Home Desktop 100", "warehouse": "_Test Warehouse 1 - _TC"},
|
||||||
"stock_value_difference")
|
"stock_value_difference")
|
||||||
|
|
||||||
self.assertEquals(abs(stock_value_difference), stock_value_difference1)
|
self.assertEquals(abs(stock_value_difference), stock_value_difference1)
|
||||||
|
@ -36,7 +36,7 @@ class TestStockReconciliation(unittest.TestCase):
|
|||||||
]
|
]
|
||||||
|
|
||||||
for d in input_data:
|
for d in input_data:
|
||||||
repost_stock_as_per_valuation_method(valuation_method)
|
set_valuation_method("_Test Item", valuation_method)
|
||||||
|
|
||||||
last_sle = get_previous_sle({
|
last_sle = get_previous_sle({
|
||||||
"item_code": "_Test Item",
|
"item_code": "_Test Item",
|
||||||
@ -114,11 +114,13 @@ def create_stock_reconciliation(**args):
|
|||||||
pass
|
pass
|
||||||
return sr
|
return sr
|
||||||
|
|
||||||
def repost_stock_as_per_valuation_method(valuation_method):
|
def set_valuation_method(item_code, valuation_method):
|
||||||
frappe.db.set_value("Item", "_Test Item", "valuation_method", valuation_method)
|
frappe.db.set_value("Item", item_code, "valuation_method", valuation_method)
|
||||||
|
|
||||||
|
for warehouse in frappe.get_all("Warehouse", filters={"company": "_Test Company"}):
|
||||||
update_entries_after({
|
update_entries_after({
|
||||||
"item_code": "_Test Item",
|
"item_code": item_code,
|
||||||
"warehouse": "_Test Warehouse - _TC",
|
"warehouse": warehouse.name
|
||||||
}, allow_negative_stock=1)
|
}, allow_negative_stock=1)
|
||||||
|
|
||||||
test_dependencies = ["Item", "Warehouse"]
|
test_dependencies = ["Item", "Warehouse"]
|
||||||
|
Loading…
Reference in New Issue
Block a user