fix: correct type hints

This commit is contained in:
Shllokkk
2026-02-24 14:03:41 +05:30
parent f7ff61be5d
commit 61661a159d
12 changed files with 53 additions and 46 deletions

View File

@@ -99,7 +99,7 @@ def identify_is_group(child):
@frappe.whitelist() @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 = {} chart = {}
if existing_company: if existing_company:
return get_account_tree_from_existing_company(existing_company) return get_account_tree_from_existing_company(existing_company)

View File

@@ -1,8 +1,8 @@
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt # For license information, please see license.txt
import json import json
from datetime import date
import frappe import frappe
from frappe import _ from frappe import _
@@ -47,7 +47,9 @@ class BankReconciliationTool(Document):
@frappe.whitelist() @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 # returns bank transactions for a bank account
filters = [] filters = []
filters.append(["bank_account", "=", bank_account]) 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() @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 # returns account balance till the specified date
account = frappe.db.get_value("Bank Account", bank_account, "account") account = frappe.db.get_value("Bank Account", bank_account, "account")
filters = frappe._dict( filters = frappe._dict(
@@ -140,7 +142,7 @@ def create_journal_entry_bts(
bank_transaction_name: str, bank_transaction_name: str,
reference_number: str | None = None, reference_number: str | None = None,
reference_date: str | None = None, reference_date: str | None = None,
posting_date: str | None = None, posting_date: str | date | None = None,
entry_type: str | None = None, entry_type: str | None = None,
second_account: str | None = None, second_account: str | None = None,
mode_of_payment: str | None = None, mode_of_payment: str | None = None,
@@ -374,10 +376,10 @@ def create_payment_entry_bts(
@frappe.whitelist() @frappe.whitelist()
def auto_reconcile_vouchers( def auto_reconcile_vouchers(
bank_account: str, bank_account: str,
from_date: str | None = None, from_date: str | date | None = None,
to_date: str | None = None, to_date: str | date | None = None,
filter_by_reference_date: str | None = None, filter_by_reference_date: bool | None = None,
from_reference_date: str | None = None, from_reference_date: bool | None = None,
to_reference_date: str | None = None, to_reference_date: str | None = None,
): ):
bank_transactions = get_bank_transactions(bank_account) bank_transactions = get_bank_transactions(bank_account)
@@ -491,10 +493,10 @@ def reconcile_vouchers(bank_transaction_name: str, vouchers: str):
def get_linked_payments( def get_linked_payments(
bank_transaction_name: str, bank_transaction_name: str,
document_types: list[str] | None = None, document_types: list[str] | None = None,
from_date: str | None = None, from_date: str | date | None = None,
to_date: str | None = None, to_date: str | date | None = None,
filter_by_reference_date: str | None = None, filter_by_reference_date: bool | None = None,
from_reference_date: str | None = None, from_reference_date: bool | None = None,
to_reference_date: str | None = None, to_reference_date: str | None = None,
): ):
# get all matching payments for a bank transaction # get all matching payments for a bank transaction

View File

@@ -1,6 +1,7 @@
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt # For license information, please see license.txt
from datetime import date
import frappe import frappe
from frappe import _, qb from frappe import _, qb
@@ -615,7 +616,7 @@ def calculate_exchange_rate_using_last_gle(company, account, party_type, party):
@frappe.whitelist() @frappe.whitelist()
def get_account_details( def get_account_details(
company: str, company: str,
posting_date: str, posting_date: str | date,
account: str, account: str,
party_type: str | None = None, party_type: str | None = None,
party: str | None = None, party: str | None = None,

View File

@@ -1,8 +1,8 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
import json import json
from datetime import date
import frappe import frappe
from frappe import _, msgprint, scrub from frappe import _, msgprint, scrub
@@ -1379,7 +1379,7 @@ def get_payment_entry_against_order(
dt: str, dt: str,
dn: str, dn: str,
amount: float | None = None, amount: float | None = None,
debit_in_account_currency: str | None = None, debit_in_account_currency: str | float | None = None,
journal_entry: bool = False, journal_entry: bool = False,
bank_account: str | None = None, bank_account: str | None = None,
): ):
@@ -1652,9 +1652,9 @@ def get_account_details_and_party_type(
account: str, account: str,
date: str, date: str,
company: str, company: str,
debit: str | None = None, debit: float | str | None = None,
credit: str | None = None, credit: float | str | None = None,
exchange_rate: 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.""" """Returns dict of account details and party type to be set in Journal Entry on selection of account."""
if not frappe.has_permission("Account"): if not frappe.has_permission("Account"):
@@ -1704,7 +1704,7 @@ def get_account_details_and_party_type(
@frappe.whitelist() @frappe.whitelist()
def get_exchange_rate( def get_exchange_rate(
posting_date: str, posting_date: str | date,
account: str | None = None, account: str | None = None,
account_currency: str | None = None, account_currency: str | None = None,
company: str | None = None, company: str | None = None,
@@ -1712,7 +1712,7 @@ def get_exchange_rate(
reference_name: str | None = None, reference_name: str | None = None,
debit: float | str | None = None, debit: float | str | None = None,
credit: 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 # Ensure exchange_rate is always numeric to avoid calculation errors
if isinstance(exchange_rate, str): if isinstance(exchange_rate, str):

View File

@@ -1,6 +1,7 @@
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt # For license information, please see license.txt
from datetime import date
import frappe import frappe
from frappe import _ from frappe import _
@@ -90,7 +91,7 @@ def get_loyalty_details(
def get_loyalty_program_details_with_points( def get_loyalty_program_details_with_points(
customer: str, customer: str,
loyalty_program: str | None = None, loyalty_program: str | None = None,
expiry_date: str | None = None, expiry_date: str | date | None = None,
company: str | None = None, company: str | None = None,
silent: bool = False, silent: bool = False,
include_expired_entry: bool = False, include_expired_entry: bool = False,
@@ -121,7 +122,7 @@ def get_loyalty_program_details_with_points(
def get_loyalty_program_details( def get_loyalty_program_details(
customer: str, customer: str,
loyalty_program: str | None = None, loyalty_program: str | None = None,
expiry_date: str | None = None, expiry_date: str | date | None = None,
company: str | None = None, company: str | None = None,
silent: bool = False, silent: bool = False,
include_expired_entry: bool = False, include_expired_entry: bool = False,

View File

@@ -1,12 +1,13 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt # For license information, please see license.txt
import json import json
from datetime import date
from functools import reduce from functools import reduce
import frappe import frappe
from frappe import ValidationError, _, qb, scrub, throw from frappe import ValidationError, _, qb, scrub, throw
from frappe.model.document import Document
from frappe.model.meta import get_field_precision from frappe.model.meta import get_field_precision
from frappe.query_builder import Tuple from frappe.query_builder import Tuple
from frappe.query_builder.functions import Count 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() @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) frappe.has_permission("Payment Entry", throw=True)
# to check if the passed account is accessible under reference doctype Payment Entry # 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( def get_payment_entry(
dt: str, dt: str,
dn: str, dn: str,
party_amount: str | None = None, party_amount: int | float | None = None,
bank_account: str | None = None, bank_account: str | None = None,
bank_amount: float | None = None, bank_amount: int | float | None = None,
party_type: str | None = None, party_type: str | None = None,
payment_type: str | None = None, payment_type: str | None = None,
reference_date: str | None = None, reference_date: str | date | None = None,
created_from_payment_request: str | None = None, created_from_payment_request: bool | None = None,
): ):
doc = frappe.get_doc(dt, dn) doc = frappe.get_doc(dt, dn)
over_billing_allowance = frappe.get_single_value("Accounts Settings", "over_billing_allowance") 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() @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 from frappe.model.mapper import get_mapped_doc
def set_missing_values(source, target): def set_missing_values(source, target):

View File

@@ -898,7 +898,7 @@ class POSInvoice(SalesInvoice):
@frappe.whitelist() @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"): if frappe.db.get_value("Item", item_code, "is_stock_item"):
is_stock_item = True is_stock_item = True
bin_qty = get_bin_qty(item_code, warehouse) bin_qty = get_bin_qty(item_code, warehouse)
@@ -1084,7 +1084,7 @@ def item_query(
searchfield: str, searchfield: str,
start: int, start: int,
page_len: int, page_len: int,
filters: str | dict, filters: dict,
as_dict: bool = False, as_dict: bool = False,
): ):
if pos_profile := filters.get("pos_profile")[1]: if pos_profile := filters.get("pos_profile")[1]:

View File

@@ -320,7 +320,7 @@ class PricingRule(Document):
@frappe.whitelist() @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 = { args = {
"items": [{"doctype": "", "name": "", "item_code": "", "brand": "", "item_group": ""}, ...], "items": [{"doctype": "", "name": "", "item_code": "", "brand": "", "item_group": ""}, ...],

View File

@@ -1942,7 +1942,7 @@ def make_regional_gl_entries(gl_entries, doc):
@frappe.whitelist() @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 from erpnext.controllers.sales_and_purchase_return import make_return_doc
return make_return_doc("Purchase Invoice", source_name, target_doc) return make_return_doc("Purchase Invoice", source_name, target_doc)

View File

@@ -1,6 +1,7 @@
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt # For license information, please see license.txt
from datetime import date
import frappe import frappe
from dateutil import relativedelta from dateutil import relativedelta
@@ -46,8 +47,8 @@ def get_plan_rate(
plan: str, plan: str,
quantity: int = 1, quantity: int = 1,
customer: str | None = None, customer: str | None = None,
start_date: str | None = None, start_date: str | date | None = None,
end_date: str | None = None, end_date: str | date | None = None,
prorate_factor: float = 1, prorate_factor: float = 1,
party: str | None = None, party: str | None = None,
): ):

View File

@@ -1,6 +1,7 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
from datetime import date
import frappe import frappe
from frappe import _, msgprint, qb, scrub from frappe import _, msgprint, qb, scrub
@@ -64,7 +65,7 @@ def get_party_details(
price_list: str | None = None, price_list: str | None = None,
currency: str | None = None, currency: str | None = None,
doctype: str | None = None, doctype: str | None = None,
ignore_permissions: bool = False, ignore_permissions: bool | None = False,
fetch_payment_terms_template: bool = True, fetch_payment_terms_template: bool = True,
party_address: str | None = None, party_address: str | None = None,
company_address: str | None = None, company_address: str | None = None,
@@ -622,9 +623,9 @@ def validate_party_accounts(doc):
@frappe.whitelist() @frappe.whitelist()
def get_due_date( def get_due_date(
posting_date: str, posting_date: str | date | None,
party_type: str, party_type: str | None,
party: str, party: str | None,
company: str | None = None, company: str | None = None,
bill_date: str | None = None, bill_date: str | None = None,
template_name: str | None = None, template_name: str | None = None,
@@ -730,8 +731,8 @@ def get_address_tax_category(
def set_taxes( def set_taxes(
party: str, party: str,
party_type: str, party_type: str,
posting_date: str | None, posting_date: str | date | None,
company: str, company: str | None,
customer_group: str | None = None, customer_group: str | None = None,
supplier_group: str | None = None, supplier_group: str | None = None,
tax_category: str | None = None, tax_category: str | None = None,

View File

@@ -3,7 +3,7 @@
from collections import defaultdict from collections import defaultdict
from datetime import date from datetime import date, datetime
from json import loads from json import loads
from typing import TYPE_CHECKING, Optional from typing import TYPE_CHECKING, Optional
@@ -61,13 +61,13 @@ OUTSTANDING_DOCTYPES = frozenset(["Sales Invoice", "Purchase Invoice", "Fees"])
@frappe.whitelist() @frappe.whitelist()
def get_fiscal_year( def get_fiscal_year(
date: str | date | None = None, date: str | datetime | None = None,
fiscal_year: str | None = None, fiscal_year: str | None = None,
label: str = "Date", label: str = "Date",
verbose: int = 1, verbose: int = 1,
company: str | None = None, company: str | None = None,
as_dict: bool = False, as_dict: bool = False,
boolean: str | None = None, boolean: str | bool | None = None,
raise_on_missing: bool = True, raise_on_missing: bool = True,
truncate: bool = False, truncate: bool = False,
): ):
@@ -201,7 +201,7 @@ def validate_fiscal_year(date, fiscal_year, company, label="Date", doc=None):
@frappe.whitelist() @frappe.whitelist()
def get_balance_on( def get_balance_on(
account: str | None = None, account: str | None = None,
date: str | None = None, date: str | date | None = None,
party_type: str | None = None, party_type: str | None = None,
party: str | None = None, party: str | None = None,
company: str | None = None, company: str | None = None,