Skip to content

Commit

Permalink
test: Update test cases for currency change validation
Browse files Browse the repository at this point in the history
  • Loading branch information
deepeshgarg007 committed Aug 21, 2021
1 parent 1435800 commit 60915e8
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,17 @@ def test_cost_center_wise_posting(self):
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,
cost_center=cost_center2,
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({
Expand Down
3 changes: 3 additions & 0 deletions erpnext/controllers/accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,9 @@ def validate_party_account_currency(self):
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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -164,6 +165,8 @@ def create_sales_invoice(appointment_doc):
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
Expand Down
3 changes: 3 additions & 0 deletions erpnext/healthcare/doctype/therapy_plan/therapy_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -73,6 +74,8 @@ def make_sales_invoice(reference_name, patient, company, therapy_plan_template):
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]
Expand Down
3 changes: 2 additions & 1 deletion erpnext/non_profit/doctype/membership/membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -176,7 +177,7 @@ def make_invoice(membership, member, plan, settings):
"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": [
Expand Down
2 changes: 1 addition & 1 deletion erpnext/non_profit/doctype/membership/test_membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def make_membership(member, payload={}):
"member": member,
"membership_status": "Current",
"membership_type": "_rzpy_test_milythm",
"currency": "INR",
"currency": "USD",
"paid": 1,
"from_date": nowdate(),
"amount": 100
Expand Down

0 comments on commit 60915e8

Please sign in to comment.