test: Update test cases for currency change validation

This commit is contained in:
Deepesh Garg 2021-08-21 23:05:48 +05:30
parent 1435800249
commit 60915e874d
6 changed files with 16 additions and 4 deletions

View File

@ -81,7 +81,8 @@ class TestPeriodClosingVoucher(unittest.TestCase):
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 @@ class TestPeriodClosingVoucher(unittest.TestCase):
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({

View File

@ -1113,6 +1113,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')

View File

@ -14,6 +14,7 @@ from frappe.core.doctype.sms_settings.sms_settings import send_sms
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 @@ 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

View File

@ -6,6 +6,7 @@ from __future__ import unicode_literals
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 @@ 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]

View File

@ -14,6 +14,7 @@ from frappe.utils import add_days, add_years, nowdate, getdate, add_months, get_
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 @@ 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": [

View File

@ -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