mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-21 11:15:10 +00:00
* fix: Purchase Receipt Provisional Accounting GL Entries (cherry picked from commit6bab0eeaa1) * test: Purchase Receipt Provisional Accounting GL Entries (cherry picked from commit1c78a5a9aa) * fix(test): PR Provisional Accounting --------- Co-authored-by: s-aga-r <sagarsharma.s312@gmail.com>
This commit is contained in:
@@ -195,6 +195,9 @@ class TestSupplier(FrappeTestCase):
|
|||||||
def create_supplier(**args):
|
def create_supplier(**args):
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
|
|
||||||
|
if not args.supplier_name:
|
||||||
|
args.supplier_name = frappe.generate_hash()
|
||||||
|
|
||||||
if frappe.db.exists("Supplier", args.supplier_name):
|
if frappe.db.exists("Supplier", args.supplier_name):
|
||||||
return frappe.get_doc("Supplier", args.supplier_name)
|
return frappe.get_doc("Supplier", args.supplier_name)
|
||||||
|
|
||||||
@@ -202,6 +205,7 @@ def create_supplier(**args):
|
|||||||
{
|
{
|
||||||
"doctype": "Supplier",
|
"doctype": "Supplier",
|
||||||
"supplier_name": args.supplier_name,
|
"supplier_name": args.supplier_name,
|
||||||
|
"default_currency": args.default_currency,
|
||||||
"supplier_group": args.supplier_group or "Services",
|
"supplier_group": args.supplier_group or "Services",
|
||||||
"supplier_type": args.supplier_type or "Company",
|
"supplier_type": args.supplier_type or "Company",
|
||||||
"tax_withholding_category": args.tax_withholding_category,
|
"tax_withholding_category": args.tax_withholding_category,
|
||||||
|
|||||||
@@ -605,7 +605,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
account=provisional_account,
|
account=provisional_account,
|
||||||
cost_center=item.cost_center,
|
cost_center=item.cost_center,
|
||||||
debit=0.0,
|
debit=0.0,
|
||||||
credit=multiplication_factor * item.amount,
|
credit=multiplication_factor * item.base_amount,
|
||||||
remarks=remarks,
|
remarks=remarks,
|
||||||
against_account=expense_account,
|
against_account=expense_account,
|
||||||
account_currency=credit_currency,
|
account_currency=credit_currency,
|
||||||
@@ -619,7 +619,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
gl_entries=gl_entries,
|
gl_entries=gl_entries,
|
||||||
account=expense_account,
|
account=expense_account,
|
||||||
cost_center=item.cost_center,
|
cost_center=item.cost_center,
|
||||||
debit=multiplication_factor * item.amount,
|
debit=multiplication_factor * item.base_amount,
|
||||||
credit=0.0,
|
credit=0.0,
|
||||||
remarks=remarks,
|
remarks=remarks,
|
||||||
against_account=provisional_account,
|
against_account=provisional_account,
|
||||||
|
|||||||
@@ -2024,6 +2024,49 @@ class TestPurchaseReceipt(FrappeTestCase):
|
|||||||
ste7.reload()
|
ste7.reload()
|
||||||
self.assertEqual(ste7.items[0].valuation_rate, valuation_rate)
|
self.assertEqual(ste7.items[0].valuation_rate, valuation_rate)
|
||||||
|
|
||||||
|
def test_purchase_receipt_provisional_accounting(self):
|
||||||
|
# Step - 1: Create Supplier with Default Currency as USD
|
||||||
|
from erpnext.buying.doctype.supplier.test_supplier import create_supplier
|
||||||
|
|
||||||
|
supplier = create_supplier(default_currency="USD")
|
||||||
|
|
||||||
|
# Step - 2: Setup Company for Provisional Accounting
|
||||||
|
from erpnext.accounts.doctype.account.test_account import create_account
|
||||||
|
|
||||||
|
provisional_account = create_account(
|
||||||
|
account_name="Provision Account",
|
||||||
|
parent_account="Current Liabilities - _TC",
|
||||||
|
company="_Test Company",
|
||||||
|
)
|
||||||
|
company = frappe.get_doc("Company", "_Test Company")
|
||||||
|
company.enable_provisional_accounting_for_non_stock_items = 1
|
||||||
|
company.default_provisional_account = provisional_account
|
||||||
|
company.save()
|
||||||
|
|
||||||
|
# Step - 3: Create Non-Stock Item
|
||||||
|
item = make_item(properties={"is_stock_item": 0})
|
||||||
|
|
||||||
|
# Step - 4: Create Purchase Receipt
|
||||||
|
pr = make_purchase_receipt(
|
||||||
|
qty=2,
|
||||||
|
item_code=item.name,
|
||||||
|
company=company.name,
|
||||||
|
supplier=supplier.name,
|
||||||
|
currency=supplier.default_currency,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test - 1: Total and Base Total should not be the same as the currency is different
|
||||||
|
self.assertNotEqual(flt(pr.total, 2), flt(pr.base_total, 2))
|
||||||
|
self.assertEqual(flt(pr.total * pr.conversion_rate, 2), flt(pr.base_total, 2))
|
||||||
|
|
||||||
|
# Test - 2: Sum of Debit or Credit should be equal to Purchase Receipt Base Total
|
||||||
|
amount = frappe.db.get_value("GL Entry", {"docstatus": 1, "voucher_no": pr.name}, ["sum(debit)"])
|
||||||
|
expected_amount = pr.base_total
|
||||||
|
self.assertEqual(amount, expected_amount)
|
||||||
|
|
||||||
|
company.enable_provisional_accounting_for_non_stock_items = 0
|
||||||
|
company.save()
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user