mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-02 08:03:21 +00:00
test: add Delivery Note GL snapshots
Extends the Phase-0 characterization suite with 2 DN scenarios (basic delivery and return) using _Test Company with perpetual inventory so stock accounting GL entries are produced. Uses stock_entry_utils.make_stock_entry directly (avoids importing test_delivery_note and its conflicting test-record deps). Run: bench --site test-erpnext-v17 run-tests --module erpnext.accounts.test_gl_characterization
This commit is contained in:
30
erpnext/accounts/gl_snapshots/dn_basic.json
Normal file
30
erpnext/accounts/gl_snapshots/dn_basic.json
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"account": "Stock Delivered But Not Billed - TCP1",
|
||||||
|
"account_currency": "INR",
|
||||||
|
"against": "Stock In Hand - TCP1",
|
||||||
|
"cost_center": "Main - TCP1",
|
||||||
|
"credit": 0.0,
|
||||||
|
"credit_in_account_currency": 0.0,
|
||||||
|
"debit": 500.0,
|
||||||
|
"debit_in_account_currency": 500.0,
|
||||||
|
"is_opening": "No",
|
||||||
|
"party": null,
|
||||||
|
"party_type": null,
|
||||||
|
"posting_date": "2024-01-15"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account": "Stock In Hand - TCP1",
|
||||||
|
"account_currency": "INR",
|
||||||
|
"against": "Stock Delivered But Not Billed - TCP1",
|
||||||
|
"cost_center": "Main - TCP1",
|
||||||
|
"credit": 500.0,
|
||||||
|
"credit_in_account_currency": 500.0,
|
||||||
|
"debit": 0.0,
|
||||||
|
"debit_in_account_currency": 0.0,
|
||||||
|
"is_opening": "No",
|
||||||
|
"party": null,
|
||||||
|
"party_type": null,
|
||||||
|
"posting_date": "2024-01-15"
|
||||||
|
}
|
||||||
|
]
|
||||||
30
erpnext/accounts/gl_snapshots/dn_return.json
Normal file
30
erpnext/accounts/gl_snapshots/dn_return.json
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"account": "Stock Delivered But Not Billed - TCP1",
|
||||||
|
"account_currency": "INR",
|
||||||
|
"against": "Stock In Hand - TCP1",
|
||||||
|
"cost_center": "Main - TCP1",
|
||||||
|
"credit": 500.0,
|
||||||
|
"credit_in_account_currency": 500.0,
|
||||||
|
"debit": 0.0,
|
||||||
|
"debit_in_account_currency": 0.0,
|
||||||
|
"is_opening": "No",
|
||||||
|
"party": null,
|
||||||
|
"party_type": null,
|
||||||
|
"posting_date": "2024-01-15"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"account": "Stock In Hand - TCP1",
|
||||||
|
"account_currency": "INR",
|
||||||
|
"against": "Stock Delivered But Not Billed - TCP1",
|
||||||
|
"cost_center": "Main - TCP1",
|
||||||
|
"credit": 0.0,
|
||||||
|
"credit_in_account_currency": 0.0,
|
||||||
|
"debit": 500.0,
|
||||||
|
"debit_in_account_currency": 500.0,
|
||||||
|
"is_opening": "No",
|
||||||
|
"party": null,
|
||||||
|
"party_type": null,
|
||||||
|
"posting_date": "2024-01-15"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -26,10 +26,14 @@ from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make
|
|||||||
from erpnext.accounts.doctype.sales_invoice.sales_invoice import make_sales_return
|
from erpnext.accounts.doctype.sales_invoice.sales_invoice import make_sales_return
|
||||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
||||||
from erpnext.accounts.gl_snapshot import assert_gl_snapshot
|
from erpnext.accounts.gl_snapshot import assert_gl_snapshot
|
||||||
|
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
||||||
|
|
||||||
POSTING_DATE = "2024-01-15"
|
POSTING_DATE = "2024-01-15"
|
||||||
COMPANY = "_Test Company"
|
COMPANY = "_Test Company"
|
||||||
CUSTOMER = "_Test Customer"
|
CUSTOMER = "_Test Customer"
|
||||||
|
WAREHOUSE = "_Test Warehouse - _TC"
|
||||||
|
DN_COMPANY = "_Test Company with perpetual inventory"
|
||||||
|
DN_WAREHOUSE = "Stores - TCP1"
|
||||||
|
|
||||||
|
|
||||||
def make_dated_purchase_invoice(**args):
|
def make_dated_purchase_invoice(**args):
|
||||||
@@ -362,3 +366,52 @@ class TestGLCharacterization(IntegrationTestCase):
|
|||||||
jv.insert()
|
jv.insert()
|
||||||
jv.submit()
|
jv.submit()
|
||||||
assert_gl_snapshot(self, "je_against_si", "Journal Entry", jv.name)
|
assert_gl_snapshot(self, "je_against_si", "Journal Entry", jv.name)
|
||||||
|
|
||||||
|
def test_dn_basic(self):
|
||||||
|
make_stock_entry(item_code="_Test Item", target=DN_WAREHOUSE, qty=10, basic_rate=100)
|
||||||
|
dn = _make_dated_delivery_note(qty=5, rate=150)
|
||||||
|
dn.insert()
|
||||||
|
dn.submit()
|
||||||
|
assert_gl_snapshot(self, "dn_basic", "Delivery Note", dn.name)
|
||||||
|
|
||||||
|
def test_dn_return(self):
|
||||||
|
make_stock_entry(item_code="_Test Item", target=DN_WAREHOUSE, qty=10, basic_rate=100)
|
||||||
|
original = _make_dated_delivery_note(qty=5, rate=150)
|
||||||
|
original.insert()
|
||||||
|
original.submit()
|
||||||
|
|
||||||
|
ret = frappe.copy_doc(original)
|
||||||
|
ret.is_return = 1
|
||||||
|
ret.return_against = original.name
|
||||||
|
for item in ret.items:
|
||||||
|
item.qty = -item.qty
|
||||||
|
ret.set_posting_time = 1
|
||||||
|
ret.posting_date = POSTING_DATE
|
||||||
|
ret.insert()
|
||||||
|
ret.submit()
|
||||||
|
assert_gl_snapshot(self, "dn_return", "Delivery Note", ret.name)
|
||||||
|
|
||||||
|
|
||||||
|
def _make_dated_delivery_note(**args) -> frappe.Document:
|
||||||
|
"""Minimal Delivery Note on a fixed posting date using the perpetual-inventory
|
||||||
|
test company.
|
||||||
|
|
||||||
|
Inlined to avoid importing test_delivery_note which drags in conflicting
|
||||||
|
test-record dependencies at discovery time."""
|
||||||
|
dn = frappe.new_doc("Delivery Note")
|
||||||
|
dn.company = DN_COMPANY
|
||||||
|
dn.customer = CUSTOMER
|
||||||
|
dn.posting_date = POSTING_DATE
|
||||||
|
dn.set_posting_time = 1
|
||||||
|
dn.append(
|
||||||
|
"items",
|
||||||
|
{
|
||||||
|
"item_code": args.get("item_code", "_Test Item"),
|
||||||
|
"warehouse": args.get("warehouse", DN_WAREHOUSE),
|
||||||
|
"qty": args.get("qty", 1),
|
||||||
|
"rate": args.get("rate", 100),
|
||||||
|
"expense_account": "Cost of Goods Sold - TCP1",
|
||||||
|
"cost_center": "Main - TCP1",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
return dn
|
||||||
|
|||||||
Reference in New Issue
Block a user