test: Internal transfer using purchase receipt

This commit is contained in:
Deepesh Garg 2024-01-26 18:42:29 +05:30
parent 99b839d2b6
commit dbd4dae3d9
2 changed files with 25 additions and 6 deletions

View File

@ -1597,8 +1597,8 @@ def create_delivery_note(**args):
{
"item_code": args.item or args.item_code or "_Test Item",
"warehouse": args.warehouse or "_Test Warehouse - _TC",
"qty": args.qty if args.get("qty") is not None else 1,
"rate": args.rate if args.get("rate") is not None else 100,
"qty": args.get("qty", 1),
"rate": args.get("rate", 100),
"conversion_factor": 1.0,
"serial_and_batch_bundle": bundle_id,
"allow_zero_valuation_rate": args.allow_zero_valuation_rate or 1,

View File

@ -21,9 +21,7 @@ from erpnext.stock.doctype.serial_and_batch_bundle.test_serial_and_batch_bundle
get_serial_nos_from_bundle,
make_serial_batch_bundle,
)
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse
from erpnext.stock.stock_ledger import SerialNoExistsInFutureTransaction
class TestPurchaseReceipt(FrappeTestCase):
@ -735,7 +733,6 @@ class TestPurchaseReceipt(FrappeTestCase):
po.cancel()
def test_serial_no_against_purchase_receipt(self):
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
item_code = "Test Manual Created Serial No"
if not frappe.db.exists("Item", item_code):
@ -1020,6 +1017,11 @@ class TestPurchaseReceipt(FrappeTestCase):
def test_stock_transfer_from_purchase_receipt_with_valuation(self):
from erpnext.stock.doctype.delivery_note.delivery_note import make_inter_company_purchase_receipt
from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note
from erpnext.stock.doctype.stock_reconciliation.test_stock_reconciliation import (
create_stock_reconciliation,
)
from erpnext.stock.get_item_details import get_valuation_rate
from erpnext.stock.utils import get_stock_balance
prepare_data_for_internal_transfer()
@ -1034,6 +1036,22 @@ class TestPurchaseReceipt(FrappeTestCase):
company="_Test Company with perpetual inventory",
)
if (
get_valuation_rate(
pr1.items[0].item_code, "_Test Company with perpetual inventory", warehouse="Stores - TCP1"
)
!= 50
):
balance = get_stock_balance(item_code=pr1.items[0].item_code, warehouse="Stores - TCP1")
create_stock_reconciliation(
item_code=pr1.items[0].item_code,
company="_Test Company with perpetual inventory",
warehouse="Stores - TCP1",
qty=balance,
rate=50,
do_not_save=True,
)
customer = "_Test Internal Customer 2"
company = "_Test Company with perpetual inventory"
@ -1071,7 +1089,8 @@ class TestPurchaseReceipt(FrappeTestCase):
sl_entries = get_sl_entries("Purchase Receipt", pr.name)
expected_gle = [
["Stock In Hand - TCP1", 272.5, 0.0],
["Stock In Hand - TCP1", 250.0, 0.0],
["Cost of Goods Sold - TCP1", 22.5, 0.0],
["_Test Account Stock In Hand - TCP1", 0.0, 250.0],
["_Test Account Shipping Charges - TCP1", 0.0, 22.5],
]