From 8f969fbd666a9db6c934afbb50958e41b4039159 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sat, 21 Aug 2021 23:05:48 +0530 Subject: [PATCH] test: Update test cases for currency change validation (cherry picked from commit 60915e874d9f466618b313be65023a62591d0f97) # Conflicts: # erpnext/accounts/doctype/period_closing_voucher/test_period_closing_voucher.py # erpnext/healthcare/doctype/patient_appointment/patient_appointment.py # erpnext/healthcare/doctype/therapy_plan/therapy_plan.py # erpnext/non_profit/doctype/membership/membership.py --- .../test_period_closing_voucher.py | 8 +++++++ erpnext/controllers/accounts_controller.py | 3 +++ .../patient_appointment.py | 12 ++++++++++ .../doctype/therapy_plan/therapy_plan.py | 11 ++++++++++ .../doctype/membership/membership.py | 22 +++++++++++++++++++ .../doctype/membership/test_membership.py | 2 +- 6 files changed, 57 insertions(+), 1 deletion(-) 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 8e0e62d5f8c..a61f32c3d1e 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 @@ -78,6 +78,10 @@ class TestPeriodClosingVoucher(unittest.TestCase): expense_account="Cost of Goods Sold - TPC", rate=400, debit_to="Debtors - TPC", +<<<<<<< HEAD +======= + currency="USD" +>>>>>>> 60915e874d (test: Update test cases for currency change validation) ) create_sales_invoice( company=company, @@ -86,6 +90,10 @@ class TestPeriodClosingVoucher(unittest.TestCase): expense_account="Cost of Goods Sold - TPC", rate=200, debit_to="Debtors - TPC", +<<<<<<< HEAD +======= + currency="USD" +>>>>>>> 60915e874d (test: Update test cases for currency change validation) ) pcv = self.make_period_closing_voucher(submit=False) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index d821915a4cf..60ff067a91f 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1456,6 +1456,9 @@ class AccountsController(TransactionBase): 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 b6e30060437..131767797db 100755 --- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py +++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py @@ -22,6 +22,7 @@ from erpnext.healthcare.utils import ( manage_fee_validity, ) from erpnext.hr.doctype.employee.employee import is_holiday +<<<<<<< HEAD class MaximumCapacityError(frappe.ValidationError): @@ -31,6 +32,11 @@ class MaximumCapacityError(frappe.ValidationError): class OverlapError(frappe.ValidationError): pass +======= +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 +>>>>>>> 60915e874d (test: Update test cases for currency change validation) class PatientAppointment(Document): def validate(self): @@ -251,7 +257,13 @@ def invoice_appointment(appointment_doc): def create_sales_invoice(appointment_doc): sales_invoice = frappe.new_doc("Sales Invoice") sales_invoice.patient = appointment_doc.patient +<<<<<<< HEAD sales_invoice.customer = frappe.get_value("Patient", appointment_doc.patient, "customer") +======= + 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) +>>>>>>> 60915e874d (test: Update test cases for currency change validation) 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 44f0a9785c4..b82894c366b 100644 --- a/erpnext/healthcare/doctype/therapy_plan/therapy_plan.py +++ b/erpnext/healthcare/doctype/therapy_plan/therapy_plan.py @@ -4,8 +4,13 @@ import frappe from frappe.model.document import Document +<<<<<<< HEAD from frappe.utils import flt +======= +from frappe.utils import flt, today +from erpnext import get_company_currency +>>>>>>> 60915e874d (test: Update test cases for currency change validation) class TherapyPlan(Document): def validate(self): @@ -71,7 +76,13 @@ def make_sales_invoice(reference_name, patient, company, therapy_plan_template): si = frappe.new_doc("Sales Invoice") si.company = company si.patient = patient +<<<<<<< HEAD si.customer = frappe.db.get_value("Patient", patient, "customer") +======= + 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) +>>>>>>> 60915e874d (test: Update test cases for currency change validation) item = frappe.db.get_value("Therapy Plan Template", therapy_plan_template, "linked_item") price_list, price_list_currency = frappe.db.get_values( diff --git a/erpnext/non_profit/doctype/membership/membership.py b/erpnext/non_profit/doctype/membership/membership.py index 835e2db8519..c420a2879b7 100644 --- a/erpnext/non_profit/doctype/membership/membership.py +++ b/erpnext/non_profit/doctype/membership/membership.py @@ -13,8 +13,12 @@ from frappe.model.document import Document from frappe.utils import add_days, add_months, add_years, get_link_to_form, getdate, nowdate import erpnext +<<<<<<< HEAD from erpnext.non_profit.doctype.member.member import create_member +======= +from erpnext import get_company_currency +>>>>>>> 60915e874d (test: Update test cases for currency change validation) class Membership(Document): def validate(self): @@ -198,6 +202,7 @@ class Membership(Document): def make_invoice(membership, member, plan, settings): +<<<<<<< HEAD invoice = frappe.get_doc( { "doctype": "Sales Invoice", @@ -209,6 +214,23 @@ def make_invoice(membership, member, plan, settings): "items": [{"item_code": plan.linked_item, "rate": membership.amount, "qty": 1}], } ) +======= + invoice = frappe.get_doc({ + "doctype": "Sales Invoice", + "customer": member.customer, + "debit_to": settings.membership_debit_account, + "currency": membership.currency or get_company_currency(settings.company), + "company": settings.company, + "is_pos": 0, + "items": [ + { + "item_code": plan.linked_item, + "rate": membership.amount, + "qty": 1 + } + ] + }) +>>>>>>> 60915e874d (test: Update test cases for currency change validation) invoice.set_missing_values() invoice.insert() invoice.submit() diff --git a/erpnext/non_profit/doctype/membership/test_membership.py b/erpnext/non_profit/doctype/membership/test_membership.py index aef34a69606..d73c2bed5f4 100644 --- a/erpnext/non_profit/doctype/membership/test_membership.py +++ b/erpnext/non_profit/doctype/membership/test_membership.py @@ -94,7 +94,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,