mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-21 05:59:18 +00:00
test: LCV entries after billing
(cherry picked from commit 53642e7417)
# Conflicts:
# erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
This commit is contained in:
@@ -118,7 +118,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):
|
||||||
|
|||||||
@@ -2426,6 +2426,7 @@ class TestPurchaseReceipt(FrappeTestCase):
|
|||||||
pr.reload()
|
pr.reload()
|
||||||
self.assertEqual(pr.per_billed, 100)
|
self.assertEqual(pr.per_billed, 100)
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
def test_purchase_receipt_with_use_serial_batch_field_for_rejected_qty(self):
|
def test_purchase_receipt_with_use_serial_batch_field_for_rejected_qty(self):
|
||||||
batch_item = make_item(
|
batch_item = make_item(
|
||||||
"_Test Purchase Receipt Batch Item For Rejected Qty",
|
"_Test Purchase Receipt Batch Item For Rejected Qty",
|
||||||
@@ -2912,6 +2913,50 @@ class TestPurchaseReceipt(FrappeTestCase):
|
|||||||
"Serial and Batch Bundle", return_pr.items[0].rejected_serial_and_batch_bundle, "total_qty"
|
"Serial and Batch Bundle", return_pr.items[0].rejected_serial_and_batch_bundle, "total_qty"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
=======
|
||||||
|
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)
|
||||||
|
>>>>>>> 53642e7417 (test: LCV entries after billing)
|
||||||
|
|
||||||
|
|
||||||
def prepare_data_for_internal_transfer():
|
def prepare_data_for_internal_transfer():
|
||||||
@@ -2959,14 +3004,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