test: Update test cases for currency change validation
diff --git a/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py
index f17a5c5..18f9549 100644
--- a/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py
+++ b/erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py
@@ -81,7 +81,8 @@
income_account="Sales - TPC",
expense_account="Cost of Goods Sold - TPC",
rate=400,
- debit_to="Debtors - TPC"
+ debit_to="Debtors - TPC",
+ currency="USD"
)
create_sales_invoice(
company=company,
@@ -89,7 +90,8 @@
income_account="Sales - TPC",
expense_account="Cost of Goods Sold - TPC",
rate=200,
- debit_to="Debtors - TPC"
+ debit_to="Debtors - TPC",
+ currency="USD"
)
pcv = frappe.get_doc({
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index a801245..654e0eb 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -1113,6 +1113,9 @@
if self.doctype not in ('Sales Invoice', 'Purchase Invoice'):
return
+ if self.is_opening == 'Yes':
+ return
+
party_type, party = self.get_party()
party_gle_currency = get_party_gle_currency(party_type, party, self.company)
party_account = self.get('debit_to') if self.doctype == 'Sales Invoice' else self.get('credit_to')
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
index cdd4ad3..12f2fe1 100755
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
@@ -14,6 +14,7 @@
from erpnext.hr.doctype.employee.employee import is_holiday
from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account, get_income_account
from erpnext.healthcare.utils import check_fee_validity, get_service_item_and_practitioner_charge, manage_fee_validity
+from erpnext import get_company_currency
class PatientAppointment(Document):
def validate(self):
@@ -164,6 +165,8 @@
sales_invoice = frappe.new_doc('Sales Invoice')
sales_invoice.patient = appointment_doc.patient
sales_invoice.customer = frappe.get_value('Patient', appointment_doc.patient, 'customer')
+ sales_invoice.currency = frappe.get_value('Customer', sales_invoice.customer, 'default_currency') \
+ or get_company_currency(appointment_doc.currency)
sales_invoice.appointment = appointment_doc.name
sales_invoice.due_date = getdate()
sales_invoice.company = appointment_doc.company
diff --git a/erpnext/healthcare/doctype/therapy_plan/therapy_plan.py b/erpnext/healthcare/doctype/therapy_plan/therapy_plan.py
index e209660..c29f6a0 100644
--- a/erpnext/healthcare/doctype/therapy_plan/therapy_plan.py
+++ b/erpnext/healthcare/doctype/therapy_plan/therapy_plan.py
@@ -6,6 +6,7 @@
import frappe
from frappe.model.document import Document
from frappe.utils import flt, today
+from erpnext import get_company_currency
class TherapyPlan(Document):
def validate(self):
@@ -73,6 +74,8 @@
si.company = company
si.patient = patient
si.customer = frappe.db.get_value('Patient', patient, 'customer')
+ si.currency = frappe.get_value('Customer', si.customer, 'default_currency') \
+ or get_company_currency(si.company)
item = frappe.db.get_value('Therapy Plan Template', therapy_plan_template, 'linked_item')
price_list, price_list_currency = frappe.db.get_values('Price List', {'selling': 1}, ['name', 'currency'])[0]
diff --git a/erpnext/non_profit/doctype/membership/membership.py b/erpnext/non_profit/doctype/membership/membership.py
index b584116..88284f8 100644
--- a/erpnext/non_profit/doctype/membership/membership.py
+++ b/erpnext/non_profit/doctype/membership/membership.py
@@ -14,6 +14,7 @@
from erpnext.non_profit.doctype.member.member import create_member
from frappe import _
import erpnext
+from erpnext import get_company_currency
class Membership(Document):
def validate(self):
@@ -176,7 +177,7 @@
"doctype": "Sales Invoice",
"customer": member.customer,
"debit_to": settings.membership_debit_account,
- "currency": membership.currency,
+ "currency": membership.currency or get_company_currency(settings.company),
"company": settings.company,
"is_pos": 0,
"items": [
diff --git a/erpnext/non_profit/doctype/membership/test_membership.py b/erpnext/non_profit/doctype/membership/test_membership.py
index 5ad2088..5c876df 100644
--- a/erpnext/non_profit/doctype/membership/test_membership.py
+++ b/erpnext/non_profit/doctype/membership/test_membership.py
@@ -80,7 +80,7 @@
"member": member,
"membership_status": "Current",
"membership_type": "_rzpy_test_milythm",
- "currency": "INR",
+ "currency": "USD",
"paid": 1,
"from_date": nowdate(),
"amount": 100