diff --git a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py index 35aaf0c84af..1ee409a290c 100644 --- a/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py +++ b/erpnext/accounts/doctype/account/chart_of_accounts/chart_of_accounts.py @@ -99,7 +99,7 @@ def identify_is_group(child): @frappe.whitelist() -def get_chart(chart_template: str, existing_company: str | None = None): +def get_chart(chart_template: str | None, existing_company: str | None = None): chart = {} if existing_company: return get_account_tree_from_existing_company(existing_company) diff --git a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py index f5485c44d7a..86970d53edf 100644 --- a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py +++ b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py @@ -1,8 +1,8 @@ # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors # For license information, please see license.txt - import json +from datetime import date import frappe from frappe import _ @@ -47,7 +47,9 @@ class BankReconciliationTool(Document): @frappe.whitelist() -def get_bank_transactions(bank_account: str, from_date: str | None = None, to_date: str | None = None): +def get_bank_transactions( + bank_account: str, from_date: str | date | None = None, to_date: str | date | None = None +): # returns bank transactions for a bank account filters = [] filters.append(["bank_account", "=", bank_account]) @@ -80,7 +82,7 @@ def get_bank_transactions(bank_account: str, from_date: str | None = None, to_da @frappe.whitelist() -def get_account_balance(bank_account: str, till_date: str, company: str): +def get_account_balance(bank_account: str, till_date: str | date, company: str): # returns account balance till the specified date account = frappe.db.get_value("Bank Account", bank_account, "account") filters = frappe._dict( @@ -140,7 +142,7 @@ def create_journal_entry_bts( bank_transaction_name: str, reference_number: str | None = None, reference_date: str | None = None, - posting_date: str | None = None, + posting_date: str | date | None = None, entry_type: str | None = None, second_account: str | None = None, mode_of_payment: str | None = None, @@ -374,10 +376,10 @@ def create_payment_entry_bts( @frappe.whitelist() def auto_reconcile_vouchers( bank_account: str, - from_date: str | None = None, - to_date: str | None = None, - filter_by_reference_date: str | None = None, - from_reference_date: str | None = None, + from_date: str | date | None = None, + to_date: str | date | None = None, + filter_by_reference_date: bool | None = None, + from_reference_date: bool | None = None, to_reference_date: str | None = None, ): bank_transactions = get_bank_transactions(bank_account) @@ -491,10 +493,10 @@ def reconcile_vouchers(bank_transaction_name: str, vouchers: str): def get_linked_payments( bank_transaction_name: str, document_types: list[str] | None = None, - from_date: str | None = None, - to_date: str | None = None, - filter_by_reference_date: str | None = None, - from_reference_date: str | None = None, + from_date: str | date | None = None, + to_date: str | date | None = None, + filter_by_reference_date: bool | None = None, + from_reference_date: bool | None = None, to_reference_date: str | None = None, ): # get all matching payments for a bank transaction diff --git a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py index 9342b0e99e9..69da27d5c68 100644 --- a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py +++ b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py @@ -1,6 +1,7 @@ # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors # For license information, please see license.txt +from datetime import date import frappe from frappe import _, qb @@ -615,7 +616,7 @@ def calculate_exchange_rate_using_last_gle(company, account, party_type, party): @frappe.whitelist() def get_account_details( company: str, - posting_date: str, + posting_date: str | date, account: str, party_type: str | None = None, party: str | None = None, diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index ec537a61ce2..4f6e8b7507e 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -1,8 +1,8 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt - import json +from datetime import date import frappe from frappe import _, msgprint, scrub @@ -1379,7 +1379,7 @@ def get_payment_entry_against_order( dt: str, dn: str, amount: float | None = None, - debit_in_account_currency: str | None = None, + debit_in_account_currency: str | float | None = None, journal_entry: bool = False, bank_account: str | None = None, ): @@ -1652,9 +1652,9 @@ def get_account_details_and_party_type( account: str, date: str, company: str, - debit: str | None = None, - credit: str | None = None, - exchange_rate: str | None = None, + debit: float | str | None = None, + credit: float | str | None = None, + exchange_rate: float | str | None = None, ): """Returns dict of account details and party type to be set in Journal Entry on selection of account.""" if not frappe.has_permission("Account"): @@ -1704,7 +1704,7 @@ def get_account_details_and_party_type( @frappe.whitelist() def get_exchange_rate( - posting_date: str, + posting_date: str | date, account: str | None = None, account_currency: str | None = None, company: str | None = None, @@ -1712,7 +1712,7 @@ def get_exchange_rate( reference_name: str | None = None, debit: float | str | None = None, credit: float | str | None = None, - exchange_rate: str | None = None, + exchange_rate: str | float | None = None, ): # Ensure exchange_rate is always numeric to avoid calculation errors if isinstance(exchange_rate, str): diff --git a/erpnext/accounts/doctype/loyalty_program/loyalty_program.py b/erpnext/accounts/doctype/loyalty_program/loyalty_program.py index 010d5b8017f..543feb89fa1 100644 --- a/erpnext/accounts/doctype/loyalty_program/loyalty_program.py +++ b/erpnext/accounts/doctype/loyalty_program/loyalty_program.py @@ -1,6 +1,7 @@ # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors # For license information, please see license.txt +from datetime import date import frappe from frappe import _ @@ -90,7 +91,7 @@ def get_loyalty_details( def get_loyalty_program_details_with_points( customer: str, loyalty_program: str | None = None, - expiry_date: str | None = None, + expiry_date: str | date | None = None, company: str | None = None, silent: bool = False, include_expired_entry: bool = False, @@ -121,7 +122,7 @@ def get_loyalty_program_details_with_points( def get_loyalty_program_details( customer: str, loyalty_program: str | None = None, - expiry_date: str | None = None, + expiry_date: str | date | None = None, company: str | None = None, silent: bool = False, include_expired_entry: bool = False, diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 77164bd7a9f..9cb2fdd8823 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -1,12 +1,13 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors # For license information, please see license.txt - import json +from datetime import date from functools import reduce import frappe from frappe import ValidationError, _, qb, scrub, throw +from frappe.model.document import Document from frappe.model.meta import get_field_precision from frappe.query_builder import Tuple from frappe.query_builder.functions import Count @@ -2698,7 +2699,7 @@ def get_party_details(company: str, party_type: str, party: str, date: str, cost @frappe.whitelist() -def get_account_details(account: str, date: str, cost_center: str | None = None): +def get_account_details(account: str, date: str | date, cost_center: str | None = None): frappe.has_permission("Payment Entry", throw=True) # to check if the passed account is accessible under reference doctype Payment Entry @@ -2854,13 +2855,13 @@ def get_reference_details( def get_payment_entry( dt: str, dn: str, - party_amount: str | None = None, + party_amount: int | float | None = None, bank_account: str | None = None, - bank_amount: float | None = None, + bank_amount: int | float | None = None, party_type: str | None = None, payment_type: str | None = None, - reference_date: str | None = None, - created_from_payment_request: str | None = None, + reference_date: str | date | None = None, + created_from_payment_request: bool | None = None, ): doc = frappe.get_doc(dt, dn) over_billing_allowance = frappe.get_single_value("Accounts Settings", "over_billing_allowance") @@ -3526,7 +3527,7 @@ def get_paid_amount(dt, dn, party_type, party, account, due_date): @frappe.whitelist() -def make_payment_order(source_name: str, target_doc: str | None = None): +def make_payment_order(source_name: str, target_doc: str | Document | None = None): from frappe.model.mapper import get_mapped_doc def set_missing_values(source, target): diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py index 46628a25576..53c1d75db4e 100644 --- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py +++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py @@ -898,7 +898,7 @@ class POSInvoice(SalesInvoice): @frappe.whitelist() -def get_stock_availability(item_code: str, warehouse: str): +def get_stock_availability(item_code: str | None, warehouse: str): if frappe.db.get_value("Item", item_code, "is_stock_item"): is_stock_item = True bin_qty = get_bin_qty(item_code, warehouse) @@ -1084,7 +1084,7 @@ def item_query( searchfield: str, start: int, page_len: int, - filters: str | dict, + filters: dict, as_dict: bool = False, ): if pos_profile := filters.get("pos_profile")[1]: diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 59380a12026..7f46a0159a7 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -320,7 +320,7 @@ class PricingRule(Document): @frappe.whitelist() -def apply_pricing_rule(args: str | dict, doc: str | None = None): +def apply_pricing_rule(args: str | dict, doc: str | dict | Document | None = None): """ args = { "items": [{"doctype": "", "name": "", "item_code": "", "brand": "", "item_group": ""}, ...], diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 60d7a24a33b..2134578efac 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -1942,7 +1942,7 @@ def make_regional_gl_entries(gl_entries, doc): @frappe.whitelist() -def make_debit_note(source_name: str, target_doc: Document | None = None): +def make_debit_note(source_name: str, target_doc: str | Document | None = None): from erpnext.controllers.sales_and_purchase_return import make_return_doc return make_return_doc("Purchase Invoice", source_name, target_doc) diff --git a/erpnext/accounts/doctype/subscription_plan/subscription_plan.py b/erpnext/accounts/doctype/subscription_plan/subscription_plan.py index 776c82e165e..932caaa2db2 100644 --- a/erpnext/accounts/doctype/subscription_plan/subscription_plan.py +++ b/erpnext/accounts/doctype/subscription_plan/subscription_plan.py @@ -1,6 +1,7 @@ # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors # For license information, please see license.txt +from datetime import date import frappe from dateutil import relativedelta @@ -46,8 +47,8 @@ def get_plan_rate( plan: str, quantity: int = 1, customer: str | None = None, - start_date: str | None = None, - end_date: str | None = None, + start_date: str | date | None = None, + end_date: str | date | None = None, prorate_factor: float = 1, party: str | None = None, ): diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index de16db50850..a6173f432e2 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -1,6 +1,7 @@ # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt +from datetime import date import frappe from frappe import _, msgprint, qb, scrub @@ -64,7 +65,7 @@ def get_party_details( price_list: str | None = None, currency: str | None = None, doctype: str | None = None, - ignore_permissions: bool = False, + ignore_permissions: bool | None = False, fetch_payment_terms_template: bool = True, party_address: str | None = None, company_address: str | None = None, @@ -622,9 +623,9 @@ def validate_party_accounts(doc): @frappe.whitelist() def get_due_date( - posting_date: str, - party_type: str, - party: str, + posting_date: str | date | None, + party_type: str | None, + party: str | None, company: str | None = None, bill_date: str | None = None, template_name: str | None = None, @@ -730,8 +731,8 @@ def get_address_tax_category( def set_taxes( party: str, party_type: str, - posting_date: str | None, - company: str, + posting_date: str | date | None, + company: str | None, customer_group: str | None = None, supplier_group: str | None = None, tax_category: str | None = None, diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index d6f031dca70..701f1a40ba5 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -3,7 +3,7 @@ from collections import defaultdict -from datetime import date +from datetime import date, datetime from json import loads from typing import TYPE_CHECKING, Optional @@ -61,13 +61,13 @@ OUTSTANDING_DOCTYPES = frozenset(["Sales Invoice", "Purchase Invoice", "Fees"]) @frappe.whitelist() def get_fiscal_year( - date: str | date | None = None, + date: str | datetime | None = None, fiscal_year: str | None = None, label: str = "Date", verbose: int = 1, company: str | None = None, as_dict: bool = False, - boolean: str | None = None, + boolean: str | bool | None = None, raise_on_missing: bool = True, truncate: bool = False, ): @@ -201,7 +201,7 @@ def validate_fiscal_year(date, fiscal_year, company, label="Date", doc=None): @frappe.whitelist() def get_balance_on( account: str | None = None, - date: str | None = None, + date: str | date | None = None, party_type: str | None = None, party: str | None = None, company: str | None = None,