mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-12 11:25:09 +00:00
test: add unit test for inter company transaction rate validation
This commit is contained in:
@@ -64,6 +64,28 @@ class TestSalesInvoice(FrappeTestCase):
|
||||
)
|
||||
frappe.db.set_single_value("Accounts Settings", "acc_frozen_upto", None)
|
||||
|
||||
@change_settings(
|
||||
"Accounts Settings",
|
||||
{"maintain_same_internal_transaction_rate": 1, "maintain_same_rate_action": "Stop"},
|
||||
)
|
||||
def test_invalid_rate_without_override(self):
|
||||
from frappe import ValidationError
|
||||
|
||||
from erpnext.accounts.doctype.sales_invoice.sales_invoice import make_inter_company_purchase_invoice
|
||||
|
||||
# frappe.get_cached_doc("Company", "_Test Company")
|
||||
si = create_sales_invoice(
|
||||
customer="_Test Internal Customer 3", company="_Test Company", is_internal_customer=1, rate=100
|
||||
)
|
||||
frappe.get_cached_doc("Customer", "_Test Internal Customer 3")
|
||||
pi = make_inter_company_purchase_invoice(si)
|
||||
pi.items[0].rate = 120
|
||||
|
||||
with self.assertRaises(ValidationError) as e:
|
||||
pi.insert()
|
||||
pi.submit()
|
||||
self.assertIn("Rate must be same", str(e.exception))
|
||||
|
||||
def tearDown(self):
|
||||
frappe.db.rollback()
|
||||
|
||||
@@ -4441,6 +4463,7 @@ def create_sales_invoice(**args):
|
||||
si.conversion_rate = args.conversion_rate or 1
|
||||
si.naming_series = args.naming_series or "T-SINV-"
|
||||
si.cost_center = args.parent_cost_center
|
||||
si.is_internal_customer = args.is_internal_customer or 0
|
||||
|
||||
bundle_id = None
|
||||
if si.update_stock and (args.get("batch_no") or args.get("serial_no")):
|
||||
@@ -4643,6 +4666,12 @@ def create_internal_parties():
|
||||
allowed_to_interact_with="_Test Company with perpetual inventory",
|
||||
)
|
||||
|
||||
create_internal_supplier(
|
||||
supplier_name="_Test Internal Supplier 3",
|
||||
represents_company="_Test Company",
|
||||
allowed_to_interact_with="_Test Company",
|
||||
)
|
||||
|
||||
|
||||
def create_internal_supplier(supplier_name, represents_company, allowed_to_interact_with):
|
||||
if not frappe.db.exists("Supplier", supplier_name):
|
||||
|
||||
Reference in New Issue
Block a user