mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 04:09:11 +00:00
chore: Update test case
(cherry picked from commit bc34737709)
# Conflicts:
# erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
This commit is contained in:
@@ -898,3 +898,18 @@ def get_default_contact(doctype, name):
|
|||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def add_party_account(party_type, party, company, account):
|
||||||
|
doc = frappe.get_doc(party_type, party)
|
||||||
|
account_exists = False
|
||||||
|
for d in doc.get("accounts"):
|
||||||
|
if d.account == account:
|
||||||
|
account_exists = True
|
||||||
|
|
||||||
|
if not account_exists:
|
||||||
|
accounts = {"company": company, "account": account}
|
||||||
|
|
||||||
|
doc.append("accounts", accounts)
|
||||||
|
|
||||||
|
doc.save()
|
||||||
|
|||||||
@@ -1295,6 +1295,58 @@ class TestPurchaseReceipt(FrappeTestCase):
|
|||||||
self.assertEqual(pr.status, "To Bill")
|
self.assertEqual(pr.status, "To Bill")
|
||||||
self.assertAlmostEqual(pr.per_billed, 50.0, places=2)
|
self.assertAlmostEqual(pr.per_billed, 50.0, places=2)
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
def test_purchase_receipt_with_exchange_rate_difference(self):
|
||||||
|
from erpnext.accounts.doctype.purchase_invoice.purchase_invoice import (
|
||||||
|
make_purchase_receipt as create_purchase_receipt,
|
||||||
|
)
|
||||||
|
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import (
|
||||||
|
make_purchase_invoice as create_purchase_invoice,
|
||||||
|
)
|
||||||
|
from erpnext.accounts.party import add_party_account
|
||||||
|
|
||||||
|
add_party_account(
|
||||||
|
"Supplier",
|
||||||
|
"_Test Supplier USD",
|
||||||
|
"_Test Company with perpetual inventory",
|
||||||
|
"_Test Payable USD - TCP1",
|
||||||
|
)
|
||||||
|
|
||||||
|
pi = create_purchase_invoice(
|
||||||
|
company="_Test Company with perpetual inventory",
|
||||||
|
cost_center="Main - TCP1",
|
||||||
|
warehouse="Stores - TCP1",
|
||||||
|
expense_account="_Test Account Cost for Goods Sold - TCP1",
|
||||||
|
currency="USD",
|
||||||
|
conversion_rate=70,
|
||||||
|
supplier="_Test Supplier USD",
|
||||||
|
)
|
||||||
|
|
||||||
|
pr = create_purchase_receipt(pi.name)
|
||||||
|
pr.conversion_rate = 80
|
||||||
|
pr.items[0].purchase_invoice = pi.name
|
||||||
|
pr.items[0].purchase_invoice_item = pi.items[0].name
|
||||||
|
|
||||||
|
pr.save()
|
||||||
|
pr.submit()
|
||||||
|
|
||||||
|
# Get exchnage gain and loss account
|
||||||
|
exchange_gain_loss_account = frappe.db.get_value(
|
||||||
|
"Company", pr.company, "exchange_gain_loss_account"
|
||||||
|
)
|
||||||
|
|
||||||
|
# fetching the latest GL Entry with exchange gain and loss account account
|
||||||
|
amount = frappe.db.get_value(
|
||||||
|
"GL Entry", {"account": exchange_gain_loss_account, "voucher_no": pr.name}, "credit"
|
||||||
|
)
|
||||||
|
discrepancy_caused_by_exchange_rate_diff = abs(
|
||||||
|
pi.items[0].base_net_amount - pr.items[0].base_net_amount
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(discrepancy_caused_by_exchange_rate_diff, amount)
|
||||||
|
|
||||||
|
>>>>>>> bc34737709 (chore: Update test case)
|
||||||
def test_payment_terms_are_fetched_when_creating_purchase_invoice(self):
|
def test_payment_terms_are_fetched_when_creating_purchase_invoice(self):
|
||||||
from erpnext.accounts.doctype.payment_entry.test_payment_entry import (
|
from erpnext.accounts.doctype.payment_entry.test_payment_entry import (
|
||||||
create_payment_terms_template,
|
create_payment_terms_template,
|
||||||
|
|||||||
Reference in New Issue
Block a user