mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-07 07:02:54 +00:00
test: LCV entries after billing
This commit is contained in:
@@ -105,7 +105,11 @@ class StockController(AccountsController):
|
|||||||
|
|
||||||
if self.docstatus == 1:
|
if self.docstatus == 1:
|
||||||
if not gl_entries:
|
if not gl_entries:
|
||||||
gl_entries = self.get_gl_entries(warehouse_account, via_landed_cost_voucher)
|
gl_entries = (
|
||||||
|
self.get_gl_entries(warehouse_account, via_landed_cost_voucher)
|
||||||
|
if self.doctype == "Purchase Receipt"
|
||||||
|
else self.get_gl_entries(warehouse_account)
|
||||||
|
)
|
||||||
make_gl_entries(gl_entries, from_repost=from_repost)
|
make_gl_entries(gl_entries, from_repost=from_repost)
|
||||||
|
|
||||||
def validate_serialized_batch(self):
|
def validate_serialized_batch(self):
|
||||||
|
|||||||
@@ -2477,6 +2477,49 @@ class TestPurchaseReceipt(FrappeTestCase):
|
|||||||
pr.reload()
|
pr.reload()
|
||||||
self.assertEqual(pr.per_billed, 100)
|
self.assertEqual(pr.per_billed, 100)
|
||||||
|
|
||||||
|
def test_valuation_taxes_lcv_repost_after_billing(self):
|
||||||
|
from erpnext.stock.doctype.landed_cost_voucher.test_landed_cost_voucher import (
|
||||||
|
make_landed_cost_voucher,
|
||||||
|
)
|
||||||
|
|
||||||
|
company = frappe.get_doc("Company", "_Test Company")
|
||||||
|
company.enable_perpetual_inventory = 1
|
||||||
|
company.default_inventory_account = "Stock In Hand - _TC"
|
||||||
|
company.stock_received_but_not_billed = "Stock Received But Not Billed - _TC"
|
||||||
|
company.save()
|
||||||
|
|
||||||
|
pr = make_purchase_receipt(qty=10, rate=1000, do_not_submit=1)
|
||||||
|
pr.append(
|
||||||
|
"taxes",
|
||||||
|
{
|
||||||
|
"category": "Valuation and Total",
|
||||||
|
"charge_type": "Actual",
|
||||||
|
"account_head": "Freight and Forwarding Charges - _TC",
|
||||||
|
"tax_amount": 2000,
|
||||||
|
"description": "Test",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
pr.submit()
|
||||||
|
pi = make_purchase_invoice(pr.name)
|
||||||
|
pi.submit()
|
||||||
|
lcv = make_landed_cost_voucher(
|
||||||
|
company=pr.company,
|
||||||
|
receipt_document_type="Purchase Receipt",
|
||||||
|
receipt_document=pr.name,
|
||||||
|
charges=2000,
|
||||||
|
distribute_charges_based_on="Qty",
|
||||||
|
expense_account="Expenses Included In Valuation - _TC",
|
||||||
|
)
|
||||||
|
|
||||||
|
gl_entries = get_gl_entries("Purchase Receipt", pr.name, skip_cancelled=True, as_dict=False)
|
||||||
|
expected_gle = (
|
||||||
|
("Stock Received But Not Billed - _TC", 0, 10000, "Main - _TC"),
|
||||||
|
("Stock In Hand - _TC", 14000, 0, "Main - _TC"),
|
||||||
|
("Freight and Forwarding Charges - _TC", 0, 2000, "Main - _TC"),
|
||||||
|
("Expenses Included In Valuation - _TC", 0, 2000, "Main - _TC"),
|
||||||
|
)
|
||||||
|
self.assertSequenceEqual(expected_gle, gl_entries)
|
||||||
|
|
||||||
|
|
||||||
def prepare_data_for_internal_transfer():
|
def prepare_data_for_internal_transfer():
|
||||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_internal_supplier
|
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_internal_supplier
|
||||||
@@ -2523,14 +2566,24 @@ def get_sl_entries(voucher_type, voucher_no):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_gl_entries(voucher_type, voucher_no):
|
def get_gl_entries(voucher_type, voucher_no, skip_cancelled=False, as_dict=True):
|
||||||
return frappe.db.sql(
|
gl = frappe.qb.DocType("GL Entry")
|
||||||
"""select account, debit, credit, cost_center, is_cancelled
|
gl_query = (
|
||||||
from `tabGL Entry` where voucher_type=%s and voucher_no=%s
|
frappe.qb.from_(gl)
|
||||||
order by account desc""",
|
.select(
|
||||||
(voucher_type, voucher_no),
|
gl.account,
|
||||||
as_dict=1,
|
gl.debit,
|
||||||
|
gl.credit,
|
||||||
|
gl.cost_center,
|
||||||
|
)
|
||||||
|
.where((gl.voucher_type == voucher_type) & (gl.voucher_no == voucher_no))
|
||||||
|
.orderby(gl.account, order=frappe.qb.desc)
|
||||||
)
|
)
|
||||||
|
if skip_cancelled:
|
||||||
|
gl_query = gl_query.where(gl.is_cancelled == 0)
|
||||||
|
else:
|
||||||
|
gl_query = gl_query.select(gl.is_cancelled)
|
||||||
|
return gl_query.run(as_dict=as_dict)
|
||||||
|
|
||||||
|
|
||||||
def get_taxes(**args):
|
def get_taxes(**args):
|
||||||
|
|||||||
Reference in New Issue
Block a user