chore: Resolve conflicts

This commit is contained in:
Deepesh Garg
2022-05-25 19:04:20 +05:30
parent 761669c7ca
commit f724f6d1bb
9 changed files with 48 additions and 376 deletions

View File

@@ -17,7 +17,7 @@ from erpnext.accounts.doctype.invoice_discounting.invoice_discounting import (
from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import (
get_party_tax_withholding_details,
)
from erpnext.accounts.party import get_party_account
from erpnext.accounts.party import get_party_account, get_party_gle_currency
from erpnext.accounts.utils import (
get_account_currency,
get_balance_on,
@@ -26,13 +26,6 @@ from erpnext.accounts.utils import (
)
from erpnext.controllers.accounts_controller import AccountsController
from erpnext.hr.doctype.expense_claim.expense_claim import update_reimbursed_amount
<<<<<<< HEAD
=======
from erpnext.accounts.doctype.invoice_discounting.invoice_discounting \
import get_party_account_based_on_invoice_discounting
from erpnext.accounts.deferred_revenue import get_deferred_booking_accounts
from erpnext.accounts.party import get_party_gle_currency
>>>>>>> 417d6abcf4 (fix: Party account validation in JV)
class StockAccountInvalidTransaction(frappe.ValidationError):
@@ -334,28 +327,25 @@ class JournalEntry(AccountsController):
account_type = frappe.db.get_value("Account", d.account, "account_type")
if account_type in ["Receivable", "Payable"]:
if not (d.party_type and d.party):
<<<<<<< HEAD
frappe.throw(
_("Row {0}: Party Type and Party is required for Receivable / Payable account {1}").format(
d.idx, d.account
)
)
<<<<<<< HEAD
=======
frappe.throw(_("Row {0}: Party Type and Party is required for Receivable / Payable account {1}").format(d.idx, d.account))
def validate_party_account_currency(self):
for d in self.get("accounts"):
if d.party_type in ('Customer', 'Supplier'):
if d.party_type in ("Customer", "Supplier"):
party_gle_currency = get_party_gle_currency(d.party_type, d.party, self.company)
party_account_currency = get_account_currency(d.account)
party_currency = frappe.db.get_value(d.party_type, d.party, 'default_currency')
party_currency = frappe.db.get_value(d.party_type, d.party, "default_currency")
if not party_gle_currency and (party_account_currency != party_currency):
frappe.throw(_("Party Account {0} currency and default party currency should be same").format(frappe.bold(d.account)))
>>>>>>> 417d6abcf4 (fix: Party account validation in JV)
=======
>>>>>>> 5b8726405d (fix: Remove validation from Journal Entry)
frappe.throw(
_("Party Account {0} currency and default party currency should be same").format(
frappe.bold(d.account)
)
)
def check_credit_limit(self):
customers = list(

View File

@@ -78,16 +78,10 @@ class TestPeriodClosingVoucher(unittest.TestCase):
expense_account="Cost of Goods Sold - TPC",
rate=400,
debit_to="Debtors - TPC",
<<<<<<< HEAD
<<<<<<< HEAD
=======
currency="USD"
>>>>>>> 60915e874d (test: Update test cases for currency change validation)
=======
currency="USD",
customer="_Test Customer USD",
>>>>>>> 65232edfd5 (test: Update test cases)
)
create_sales_invoice(
company=company,
cost_center=cost_center2,
@@ -95,15 +89,8 @@ class TestPeriodClosingVoucher(unittest.TestCase):
expense_account="Cost of Goods Sold - TPC",
rate=200,
debit_to="Debtors - TPC",
<<<<<<< HEAD
<<<<<<< HEAD
=======
currency="USD"
>>>>>>> 60915e874d (test: Update test cases for currency change validation)
=======
currency="USD",
customer="_Test Customer USD",
>>>>>>> 65232edfd5 (test: Update test cases)
)
pcv = self.make_period_closing_voucher(submit=False)

View File

@@ -768,41 +768,6 @@ class TestPricingRule(unittest.TestCase):
frappe.get_doc("Item Price", {"item_code": "Water Flask"}).delete()
item.delete()
<<<<<<< HEAD
=======
def test_multiple_pricing_rules_with_min_qty(self):
make_pricing_rule(
discount_percentage=20,
selling=1,
priority=1,
min_qty=4,
apply_multiple_pricing_rules=1,
title="_Test Pricing Rule with Min Qty - 1",
)
make_pricing_rule(
discount_percentage=10,
selling=1,
priority=2,
min_qty=4,
apply_multiple_pricing_rules=1,
title="_Test Pricing Rule with Min Qty - 2",
)
si = create_sales_invoice(do_not_submit=True, customer="_Test Customer 1", qty=1)
item = si.items[0]
item.stock_qty = 1
si.save()
self.assertFalse(item.discount_percentage)
item.qty = 5
item.stock_qty = 5
si.save()
self.assertEqual(item.discount_percentage, 30)
si.delete()
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule with Min Qty - 1")
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule with Min Qty - 2")
>>>>>>> 65232edfd5 (test: Update test cases)
test_dependencies = ["Campaign"]

View File

@@ -35,6 +35,7 @@ from erpnext.accounts.doctype.pricing_rule.utils import (
from erpnext.accounts.party import (
get_party_account,
get_party_account_currency,
get_party_gle_currency,
validate_party_frozen_disabled,
)
from erpnext.accounts.utils import get_account_currency, get_fiscal_years, validate_fiscal_year
@@ -44,12 +45,6 @@ from erpnext.controllers.print_settings import (
set_print_templates_for_taxes,
)
from erpnext.controllers.sales_and_purchase_return import validate_return
<<<<<<< HEAD
=======
from erpnext.accounts.party import get_party_account_currency, validate_party_frozen_disabled, get_party_gle_currency
from erpnext.accounts.doctype.pricing_rule.utils import (apply_pricing_rule_on_transaction,
apply_pricing_rule_for_free_items, get_applied_pricing_rules)
>>>>>>> 80c85dd17c (fix: Account currency validation for first transaction)
from erpnext.exceptions import InvalidCurrency
from erpnext.setup.utils import get_exchange_rate
from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
@@ -1453,20 +1448,25 @@ class AccountsController(TransactionBase):
# from creating a sales invoice if sales order is already created
def validate_party_account_currency(self):
if self.doctype not in ('Sales Invoice', 'Purchase Invoice'):
if self.doctype not in ("Sales Invoice", "Purchase Invoice"):
return
if self.is_opening == 'Yes':
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')
party_account = (
self.get("debit_to") if self.doctype == "Sales Invoice" else self.get("credit_to")
)
party_account_currency = get_account_currency(party_account)
if not party_gle_currency and (party_account_currency != self.currency):
frappe.throw(_("Party Account {0} currency and document currency should be same").format(frappe.bold(party_account)))
frappe.throw(
_("Party Account {0} currency and document currency should be same").format(
frappe.bold(party_account)
)
)
def delink_advance_entries(self, linked_doc_name):
total_allocated_amount = 0

View File

@@ -12,6 +12,7 @@ from frappe.model.document import Document
from frappe.model.mapper import get_mapped_doc
from frappe.utils import flt, get_link_to_form, get_time, getdate
from erpnext import get_company_currency
from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import (
get_income_account,
get_receivable_account,
@@ -22,7 +23,6 @@ from erpnext.healthcare.utils import (
manage_fee_validity,
)
from erpnext.hr.doctype.employee.employee import is_holiday
<<<<<<< HEAD
class MaximumCapacityError(frappe.ValidationError):
@@ -32,11 +32,6 @@ 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):
@@ -257,17 +252,12 @@ 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') \
<<<<<<< HEAD
or get_company_currency(appointment_doc.currency)
>>>>>>> 60915e874d (test: Update test cases for currency change validation)
=======
or get_company_currency(appointment_doc.company)
>>>>>>> c10a22529c (test: fix property name)
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

@@ -235,206 +235,24 @@ class TestPatientAppointment(unittest.TestCase):
)
ip_record1 = frappe.get_doc("Inpatient Record", ip_record.name)
mark_invoiced_inpatient_occupancy(ip_record1)
<<<<<<< HEAD
discharge_patient(ip_record1, now_datetime())
def test_payment_should_be_mandatory_for_new_patient_appointment(self):
frappe.db.set_value("Healthcare Settings", None, "enable_free_follow_ups", 1)
frappe.db.set_value("Healthcare Settings", None, "automate_appointment_invoicing", 1)
frappe.db.set_value("Healthcare Settings", None, "max_visits", 3)
frappe.db.set_value("Healthcare Settings", None, "valid_days", 30)
patient = create_patient()
assert check_is_new_patient(patient)
payment_required = check_payment_fields_reqd(patient)
assert payment_required is True
def test_sales_invoice_should_be_generated_for_new_patient_appointment(self):
patient, practitioner = create_healthcare_docs()
frappe.db.set_value("Healthcare Settings", None, "automate_appointment_invoicing", 1)
invoice_count = frappe.db.count("Sales Invoice")
assert check_is_new_patient(patient)
create_appointment(patient, practitioner, nowdate())
new_invoice_count = frappe.db.count("Sales Invoice")
assert new_invoice_count == invoice_count + 1
def test_overlap_appointment(self):
from erpnext.healthcare.doctype.patient_appointment.patient_appointment import OverlapError
patient, practitioner = create_healthcare_docs(id=1)
patient_1, practitioner_1 = create_healthcare_docs(id=2)
service_unit = create_service_unit(id=0)
service_unit_1 = create_service_unit(id=1)
appointment = create_appointment(
patient, practitioner, nowdate(), service_unit=service_unit
) # valid
# patient and practitioner cannot have overlapping appointments
appointment = create_appointment(
patient, practitioner, nowdate(), service_unit=service_unit, save=0
)
self.assertRaises(OverlapError, appointment.save)
appointment = create_appointment(
patient, practitioner, nowdate(), service_unit=service_unit_1, save=0
) # diff service unit
self.assertRaises(OverlapError, appointment.save)
appointment = create_appointment(
patient, practitioner, nowdate(), save=0
) # with no service unit link
self.assertRaises(OverlapError, appointment.save)
# patient cannot have overlapping appointments with other practitioners
appointment = create_appointment(
patient, practitioner_1, nowdate(), service_unit=service_unit, save=0
)
self.assertRaises(OverlapError, appointment.save)
appointment = create_appointment(
patient, practitioner_1, nowdate(), service_unit=service_unit_1, save=0
)
self.assertRaises(OverlapError, appointment.save)
appointment = create_appointment(patient, practitioner_1, nowdate(), save=0)
self.assertRaises(OverlapError, appointment.save)
# practitioner cannot have overlapping appointments with other patients
appointment = create_appointment(
patient_1, practitioner, nowdate(), service_unit=service_unit, save=0
)
self.assertRaises(OverlapError, appointment.save)
appointment = create_appointment(
patient_1, practitioner, nowdate(), service_unit=service_unit_1, save=0
)
self.assertRaises(OverlapError, appointment.save)
appointment = create_appointment(patient_1, practitioner, nowdate(), save=0)
self.assertRaises(OverlapError, appointment.save)
def test_service_unit_capacity(self):
from erpnext.healthcare.doctype.patient_appointment.patient_appointment import (
MaximumCapacityError,
OverlapError,
)
practitioner = create_practitioner()
capacity = 3
overlap_service_unit_type = create_service_unit_type(
id=10, allow_appointments=1, overlap_appointments=1
)
overlap_service_unit = create_service_unit(
id=100, service_unit_type=overlap_service_unit_type, service_unit_capacity=capacity
)
for i in range(0, capacity):
patient = create_patient(id=i)
create_appointment(patient, practitioner, nowdate(), service_unit=overlap_service_unit) # valid
appointment = create_appointment(
patient, practitioner, nowdate(), service_unit=overlap_service_unit, save=0
) # overlap
self.assertRaises(OverlapError, appointment.save)
patient = create_patient(id=capacity)
appointment = create_appointment(
patient, practitioner, nowdate(), service_unit=overlap_service_unit, save=0
)
self.assertRaises(MaximumCapacityError, appointment.save)
def test_patient_appointment_should_consider_permissions_while_fetching_appointments(self):
patient, practitioner = create_healthcare_docs()
create_appointment(patient, practitioner, nowdate())
patient, new_practitioner = create_healthcare_docs(id=2)
create_appointment(patient, new_practitioner, nowdate())
roles = [{"doctype": "Has Role", "role": "Physician"}]
user = create_user(roles=roles)
new_practitioner = frappe.get_doc("Healthcare Practitioner", new_practitioner)
new_practitioner.user_id = user.email
new_practitioner.save()
frappe.set_user(user.name)
appointments = frappe.get_list("Patient Appointment")
assert len(appointments) == 1
frappe.set_user("Administrator")
appointments = frappe.get_list("Patient Appointment")
assert len(appointments) == 2
def create_healthcare_docs(id=0):
patient = create_patient(id)
practitioner = create_practitioner(id)
return patient, practitioner
def create_patient(
id=0, patient_name=None, email=None, mobile=None, customer=None, create_user=False
):
if frappe.db.exists("Patient", {"firstname": f"_Test Patient {str(id)}"}):
patient = frappe.db.get_value("Patient", {"first_name": f"_Test Patient {str(id)}"}, ["name"])
return patient
patient = frappe.new_doc("Patient")
patient.first_name = patient_name if patient_name else f"_Test Patient {str(id)}"
patient.sex = "Female"
patient.mobile = mobile
patient.email = email
patient.customer = customer
patient.invite_user = create_user
patient.save(ignore_permissions=True)
return patient.name
def create_medical_department(id=0):
if frappe.db.exists("Medical Department", f"_Test Medical Department {str(id)}"):
return f"_Test Medical Department {str(id)}"
medical_department = frappe.new_doc("Medical Department")
medical_department.department = f"_Test Medical Department {str(id)}"
medical_department.save(ignore_permissions=True)
return medical_department.name
def create_practitioner(id=0, medical_department=None):
if frappe.db.exists(
"Healthcare Practitioner", {"firstname": f"_Test Healthcare Practitioner {str(id)}"}
):
practitioner = frappe.db.get_value(
"Healthcare Practitioner", {"firstname": f"_Test Healthcare Practitioner {str(id)}"}, ["name"]
)
return practitioner
practitioner = frappe.new_doc("Healthcare Practitioner")
practitioner.first_name = f"_Test Healthcare Practitioner {str(id)}"
practitioner.gender = "Female"
practitioner.department = medical_department or create_medical_department(id)
practitioner.op_consulting_charge = 500
practitioner.inpatient_visit_charge = 500
practitioner.save(ignore_permissions=True)
return practitioner.name
=======
discharge_patient(ip_record1)
def create_healthcare_docs():
patient = create_patient()
practitioner = frappe.db.exists('Healthcare Practitioner', '_Test Healthcare Practitioner')
medical_department = frappe.db.exists('Medical Department', '_Test Medical Department')
practitioner = frappe.db.exists("Healthcare Practitioner", "_Test Healthcare Practitioner")
medical_department = frappe.db.exists("Medical Department", "_Test Medical Department")
if not medical_department:
medical_department = frappe.new_doc('Medical Department')
medical_department.department = '_Test Medical Department'
medical_department = frappe.new_doc("Medical Department")
medical_department.department = "_Test Medical Department"
medical_department.save(ignore_permissions=True)
medical_department = medical_department.name
if not practitioner:
practitioner = frappe.new_doc('Healthcare Practitioner')
practitioner.first_name = '_Test Healthcare Practitioner'
practitioner.gender = 'Female'
practitioner = frappe.new_doc("Healthcare Practitioner")
practitioner.first_name = "_Test Healthcare Practitioner"
practitioner.gender = "Female"
practitioner.department = medical_department
practitioner.op_consulting_charge = 500
practitioner.inpatient_visit_charge = 500
@@ -443,17 +261,18 @@ def create_healthcare_docs():
return patient, medical_department, practitioner
def create_patient():
patient = frappe.db.exists('Patient', '_Test Patient')
patient = frappe.db.exists("Patient", "_Test Patient")
if not patient:
patient = frappe.new_doc('Patient')
patient.first_name = '_Test Patient'
patient.sex = 'Female'
patient.default_currency = 'INR'
patient = frappe.new_doc("Patient")
patient.first_name = "_Test Patient"
patient.sex = "Female"
patient.default_currency = "INR"
patient.save(ignore_permissions=True)
patient = patient.name
return patient
>>>>>>> 30876a105c (test: Set default currency for patient)
def create_encounter(appointment):
if appointment:

View File

@@ -4,13 +4,10 @@
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):
@@ -76,13 +73,10 @@ 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)
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(

View File

@@ -13,12 +13,9 @@ 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 import get_company_currency
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):
@@ -202,35 +199,17 @@ class Membership(Document):
def make_invoice(membership, member, plan, settings):
<<<<<<< HEAD
invoice = frappe.get_doc(
{
"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": [{"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()

View File

@@ -1295,58 +1295,6 @@ class TestPurchaseReceipt(FrappeTestCase):
self.assertEqual(pr.status, "To Bill")
self.assertAlmostEqual(pr.per_billed, 50.0, places=2)
<<<<<<< HEAD
=======
def test_purchase_receipt_with_exchange_rate_difference(self):
from erpnext.accounts.doctype.purchase_invoice.purchase_invoice import (
make_purchase_receipt as create_purchase_receipt,
)
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import (
make_purchase_invoice as create_purchase_invoice,
)
from erpnext.accounts.party import add_party_account
add_party_account(
"Supplier",
"_Test Supplier USD",
"_Test Company with perpetual inventory",
"_Test Payable USD - TCP1",
)
pi = create_purchase_invoice(
company="_Test Company with perpetual inventory",
cost_center="Main - TCP1",
warehouse="Stores - TCP1",
expense_account="_Test Account Cost for Goods Sold - TCP1",
currency="USD",
conversion_rate=70,
supplier="_Test Supplier USD",
)
pr = create_purchase_receipt(pi.name)
pr.conversion_rate = 80
pr.items[0].purchase_invoice = pi.name
pr.items[0].purchase_invoice_item = pi.items[0].name
pr.save()
pr.submit()
# Get exchnage gain and loss account
exchange_gain_loss_account = frappe.db.get_value(
"Company", pr.company, "exchange_gain_loss_account"
)
# fetching the latest GL Entry with exchange gain and loss account account
amount = frappe.db.get_value(
"GL Entry", {"account": exchange_gain_loss_account, "voucher_no": pr.name}, "credit"
)
discrepancy_caused_by_exchange_rate_diff = abs(
pi.items[0].base_net_amount - pr.items[0].base_net_amount
)
self.assertEqual(discrepancy_caused_by_exchange_rate_diff, amount)
>>>>>>> bc34737709 (chore: Update test case)
def test_payment_terms_are_fetched_when_creating_purchase_invoice(self):
from erpnext.accounts.doctype.payment_entry.test_payment_entry import (
create_payment_terms_template,