mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 16:34:46 +00:00
Merge pull request #53032 from diptanilsaha/setup_ta
This commit is contained in:
@@ -656,7 +656,11 @@ def set_gl_entries_by_account(
|
|||||||
query = query.where(Criterion.all(additional_conditions))
|
query = query.where(Criterion.all(additional_conditions))
|
||||||
gl_entries = query.run(as_dict=True)
|
gl_entries = query.run(as_dict=True)
|
||||||
|
|
||||||
if filters and filters.get("presentation_currency") != d.default_currency:
|
if (
|
||||||
|
filters
|
||||||
|
and filters.get("presentation_currency")
|
||||||
|
and filters.get("presentation_currency") != d.default_currency
|
||||||
|
):
|
||||||
currency_info["company"] = d.name
|
currency_info["company"] = d.name
|
||||||
currency_info["company_currency"] = d.default_currency
|
currency_info["company_currency"] = d.default_currency
|
||||||
convert_to_presentation_currency(gl_entries, currency_info)
|
convert_to_presentation_currency(gl_entries, currency_info)
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ class TestReactivity(AccountsTestMixin, IntegrationTestCase):
|
|||||||
"debit_to": self.debit_to,
|
"debit_to": self.debit_to,
|
||||||
"posting_date": today(),
|
"posting_date": today(),
|
||||||
"cost_center": self.cost_center,
|
"cost_center": self.cost_center,
|
||||||
|
"currency": "INR",
|
||||||
"conversion_rate": 1,
|
"conversion_rate": 1,
|
||||||
"selling_price_list": self.price_list,
|
"selling_price_list": self.price_list,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1612,12 +1612,14 @@ def make_purchase_order(
|
|||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
target.supplier = supplier
|
target.supplier = supplier
|
||||||
target.currency = frappe.db.get_value(
|
|
||||||
"Supplier", filters={"name": supplier}, fieldname=["default_currency"]
|
|
||||||
)
|
|
||||||
company_currency = frappe.db.get_value(
|
company_currency = frappe.db.get_value(
|
||||||
"Company", filters={"name": target.company}, fieldname=["default_currency"]
|
"Company", filters={"name": target.company}, fieldname=["default_currency"]
|
||||||
)
|
)
|
||||||
|
supplier_currency = frappe.db.get_value(
|
||||||
|
"Supplier", filters={"name": supplier}, fieldname=["default_currency"]
|
||||||
|
)
|
||||||
|
|
||||||
|
target.currency = supplier_currency if supplier_currency else company_currency
|
||||||
|
|
||||||
target.conversion_rate = get_exchange_rate(target.currency, company_currency, args="for_buying")
|
target.conversion_rate = get_exchange_rate(target.currency, company_currency, args="for_buying")
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
from typing import Literal
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
import frappe.defaults
|
import frappe.defaults
|
||||||
@@ -938,7 +939,7 @@ def cache_companies_monthly_sales_history():
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_children(doctype, parent=None, company=None, is_root=False):
|
def get_children(doctype: str, parent: str | None = None, company: str | None = None, is_root: bool = False):
|
||||||
if parent is None or parent == "All Companies":
|
if parent is None or parent == "All Companies":
|
||||||
parent = ""
|
parent = ""
|
||||||
|
|
||||||
@@ -1045,10 +1046,11 @@ def get_timeline_data(doctype, name):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_default_company_address(name, sort_key="is_primary_address", existing_address=None):
|
def get_default_company_address(
|
||||||
if sort_key not in ["is_shipping_address", "is_primary_address"]:
|
name: str,
|
||||||
return None
|
sort_key: Literal["is_shipping_address", "is_primary_address"] = "is_primary_address",
|
||||||
|
existing_address: str | None = None,
|
||||||
|
):
|
||||||
out = frappe.db.sql(
|
out = frappe.db.sql(
|
||||||
""" SELECT
|
""" SELECT
|
||||||
addr.name, addr.{}
|
addr.name, addr.{}
|
||||||
@@ -1072,7 +1074,9 @@ def get_default_company_address(name, sort_key="is_primary_address", existing_ad
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_billing_shipping_address(name, billing_address=None, shipping_address=None):
|
def get_billing_shipping_address(
|
||||||
|
name: str, billing_address: str | None = None, shipping_address: str | None = None
|
||||||
|
):
|
||||||
primary_address = get_default_company_address(name, "is_primary_address", billing_address)
|
primary_address = get_default_company_address(name, "is_primary_address", billing_address)
|
||||||
shipping_address = get_default_company_address(name, "is_shipping_address", shipping_address)
|
shipping_address = get_default_company_address(name, "is_shipping_address", shipping_address)
|
||||||
|
|
||||||
@@ -1080,7 +1084,7 @@ def get_billing_shipping_address(name, billing_address=None, shipping_address=No
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def create_transaction_deletion_request(company):
|
def create_transaction_deletion_request(company: str):
|
||||||
frappe.only_for("System Manager")
|
frappe.only_for("System Manager")
|
||||||
|
|
||||||
from erpnext.setup.doctype.transaction_deletion_record.transaction_deletion_record import (
|
from erpnext.setup.doctype.transaction_deletion_record.transaction_deletion_record import (
|
||||||
|
|||||||
@@ -70,7 +70,13 @@ def get_abbreviated_name(name, company):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_children(doctype, parent=None, company=None, is_root=False, include_disabled=False):
|
def get_children(
|
||||||
|
doctype: str,
|
||||||
|
parent: str | None = None,
|
||||||
|
company: str | None = None,
|
||||||
|
is_root: bool = False,
|
||||||
|
include_disabled: str | dict | None = None,
|
||||||
|
):
|
||||||
if isinstance(include_disabled, str):
|
if isinstance(include_disabled, str):
|
||||||
include_disabled = json.loads(include_disabled)
|
include_disabled = json.loads(include_disabled)
|
||||||
fields = ["name as value", "is_group as expandable"]
|
fields = ["name as value", "is_group as expandable"]
|
||||||
|
|||||||
@@ -900,7 +900,7 @@ def send():
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_digest_msg(name):
|
def get_digest_msg(name: str):
|
||||||
return frappe.get_doc("Email Digest", name).get_msg_html()
|
return frappe.get_doc("Email Digest", name).get_msg_html()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ def is_holiday(employee, date=None, raise_exception=True, only_non_weekly=False,
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def deactivate_sales_person(status=None, employee=None):
|
def deactivate_sales_person(status: str | None = None, employee: str | None = None):
|
||||||
if status == "Left":
|
if status == "Left":
|
||||||
sales_person = frappe.db.get_value("Sales Person", {"Employee": employee})
|
sales_person = frappe.db.get_value("Sales Person", {"Employee": employee})
|
||||||
if sales_person:
|
if sales_person:
|
||||||
@@ -312,7 +312,7 @@ def deactivate_sales_person(status=None, employee=None):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def create_user(employee, user=None, email=None):
|
def create_user(employee: str, email: str | None = None):
|
||||||
emp = frappe.get_doc("Employee", employee)
|
emp = frappe.get_doc("Employee", employee)
|
||||||
|
|
||||||
employee_name = emp.employee_name.split(" ")
|
employee_name = emp.employee_name.split(" ")
|
||||||
@@ -384,7 +384,13 @@ def get_employee_emails(employee_list):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_children(doctype, parent=None, company=None, is_root=False, is_tree=False):
|
def get_children(
|
||||||
|
doctype: str,
|
||||||
|
parent: str | None = None,
|
||||||
|
company: str | None = None,
|
||||||
|
is_root: bool = False,
|
||||||
|
is_tree: bool = False,
|
||||||
|
):
|
||||||
filters = [["status", "=", "Active"]]
|
filters = [["status", "=", "Active"]]
|
||||||
if company and company != "All Companies":
|
if company and company != "All Companies":
|
||||||
filters.append(["company", "=", company])
|
filters.append(["company", "=", company])
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from datetime import date
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _, throw
|
from frappe import _, throw
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import formatdate, getdate, today
|
from frappe.utils import DateTimeLikeObject, formatdate, getdate, today
|
||||||
|
|
||||||
|
|
||||||
class OverlapError(frappe.ValidationError):
|
class OverlapError(frappe.ValidationError):
|
||||||
@@ -168,7 +168,7 @@ class HolidayList(Document):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_events(start, end, filters=None):
|
def get_events(start: DateTimeLikeObject, end: DateTimeLikeObject, filters: str | dict | None = None):
|
||||||
"""Returns events for Gantt / Calendar view rendering.
|
"""Returns events for Gantt / Calendar view rendering.
|
||||||
|
|
||||||
:param start: Start date-time.
|
:param start: Start date-time.
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class PartyType(Document):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
@frappe.validate_and_sanitize_search_inputs
|
@frappe.validate_and_sanitize_search_inputs
|
||||||
def get_party_type(doctype, txt, searchfield, start, page_len, filters):
|
def get_party_type(doctype: str, txt: str, searchfield: str, start: int, page_len: int, filters: dict):
|
||||||
cond = ""
|
cond = ""
|
||||||
account_type = None
|
account_type = None
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class TermsandConditions(Document):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_terms_and_conditions(template_name, doc):
|
def get_terms_and_conditions(template_name: str, doc: str | dict):
|
||||||
if isinstance(doc, str):
|
if isinstance(doc, str):
|
||||||
doc = json.loads(doc)
|
doc = json.loads(doc)
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ def get_protected_doctypes():
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_company_link_fields(doctype_name):
|
def get_company_link_fields(doctype_name: str):
|
||||||
"""Get all Company Link field names for a DocType (whitelisted for frontend autocomplete)
|
"""Get all Company Link field names for a DocType (whitelisted for frontend autocomplete)
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -428,7 +428,9 @@ class TransactionDeletionRecord(Document):
|
|||||||
return {"count": len(self.doctypes_to_delete)}
|
return {"count": len(self.doctypes_to_delete)}
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def populate_doctype_details(self, doctype_name, company=None, company_field=None):
|
def populate_doctype_details(
|
||||||
|
self, doctype_name: str, company: str | None = None, company_field: str | None = None
|
||||||
|
):
|
||||||
"""Get child DocTypes and document count for specified DocType
|
"""Get child DocTypes and document count for specified DocType
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -1035,7 +1037,7 @@ def get_doctypes_to_be_ignored():
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def export_to_delete_template(name):
|
def export_to_delete_template(name: str):
|
||||||
"""Export To Delete list as CSV via URL access"""
|
"""Export To Delete list as CSV via URL access"""
|
||||||
frappe.only_for("System Manager")
|
frappe.only_for("System Manager")
|
||||||
doc = frappe.get_doc("Transaction Deletion Record", name)
|
doc = frappe.get_doc("Transaction Deletion Record", name)
|
||||||
@@ -1044,7 +1046,7 @@ def export_to_delete_template(name):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def process_import_template(transaction_deletion_record_name, file_url):
|
def process_import_template(transaction_deletion_record_name: str, file_url: str):
|
||||||
"""Import CSV template and populate To Delete list"""
|
"""Import CSV template and populate To Delete list"""
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import add_days, flt, get_datetime_str, nowdate
|
from frappe.utils import add_days, flt, get_datetime_str, nowdate
|
||||||
from frappe.utils.data import now_datetime
|
from frappe.utils.data import DateTimeLikeObject, now_datetime
|
||||||
from frappe.utils.nestedset import get_root_of
|
from frappe.utils.nestedset import get_root_of
|
||||||
|
|
||||||
from erpnext import get_default_company
|
from erpnext import get_default_company
|
||||||
@@ -92,7 +92,12 @@ def get_pegged_rate(pegged_map, from_currency, to_currency, transaction_date=Non
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_exchange_rate(from_currency, to_currency, transaction_date=None, args=None):
|
def get_exchange_rate(
|
||||||
|
from_currency: str,
|
||||||
|
to_currency: str,
|
||||||
|
transaction_date: DateTimeLikeObject | None = None,
|
||||||
|
args: str | None = None,
|
||||||
|
):
|
||||||
if not (from_currency and to_currency):
|
if not (from_currency and to_currency):
|
||||||
# manqala 19/09/2016: Should this be an empty return or should it throw and exception?
|
# manqala 19/09/2016: Should this be an empty return or should it throw and exception?
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ class TestGetItemDetail(IntegrationTestCase):
|
|||||||
args = frappe._dict(
|
args = frappe._dict(
|
||||||
{
|
{
|
||||||
"item_code": "_Test Item",
|
"item_code": "_Test Item",
|
||||||
"company": "_Test Company",
|
"company": "_Test Company 1",
|
||||||
"customer": "_Test Customer",
|
"customer": "_Test Customer",
|
||||||
|
"currency": "USD",
|
||||||
"conversion_rate": 1.0,
|
"conversion_rate": 1.0,
|
||||||
"price_list_currency": "USD",
|
"price_list_currency": "USD",
|
||||||
"plc_conversion_rate": 1.0,
|
"plc_conversion_rate": 1.0,
|
||||||
|
|||||||
Reference in New Issue
Block a user