jey_erp/jey_erp/asset.py

51 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import frappe
@frappe.whitelist()
def get_tax_exempt_articles(doctype, txt, searchfield, start, page_len, filters):
"""Возвращает список налоговых статей для tax exempt assets"""
# Ключевые части названий для поиска
allowed_patterns = [
'199.1',
'199.4.1',
'199.4.2',
'199.4.3',
'199.4.4',
'199.5',
'199.7',
'199.8',
'199.9',
'199.11',
'199.14',
'199.15',
'199.16',
'199.17',
'199.18',
'199.19',
'199.20',
'227.1',
'Qanunla təsdiq olunmuş hasilatın pay bölgüsü',
'Xüsusi iqtisadi zonalar',
'Azərbaycan Respublikasının tərəfdar çıxdığı beynəlxalq müqavilələr'
]
# Строим условие для поиска
conditions = []
for pattern in allowed_patterns:
conditions.append(f"name LIKE '%{pattern}%'")
# Добавляем поисковый текст если есть
where_clause = f"({' OR '.join(conditions)})"
if txt:
where_clause += f" AND name LIKE '%{txt}%'"
# Выполняем запрос
result = frappe.db.sql(f"""
SELECT name
FROM `tabTax Article`
WHERE {where_clause}
ORDER BY name
LIMIT {start}, {page_len}
""")
return result