From b417083c5be95c034109f4559eb7e8698d2ba724 Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Wed, 27 Aug 2025 12:54:37 +0400 Subject: [PATCH] added tax articles, not finished yet --- .../taxes_az/doctype/tax_article/__init__.py | 0 .../doctype/tax_article/tax_article.js | 8 ++ .../doctype/tax_article/tax_article.json | 102 ++++++++++++++++++ .../doctype/tax_article/tax_article.py | 30 ++++++ .../doctype/tax_article/test_tax_article.py | 30 ++++++ 5 files changed, 170 insertions(+) create mode 100644 taxes_az/taxes_az/doctype/tax_article/__init__.py create mode 100644 taxes_az/taxes_az/doctype/tax_article/tax_article.js create mode 100644 taxes_az/taxes_az/doctype/tax_article/tax_article.json create mode 100644 taxes_az/taxes_az/doctype/tax_article/tax_article.py create mode 100644 taxes_az/taxes_az/doctype/tax_article/test_tax_article.py diff --git a/taxes_az/taxes_az/doctype/tax_article/__init__.py b/taxes_az/taxes_az/doctype/tax_article/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/taxes_az/taxes_az/doctype/tax_article/tax_article.js b/taxes_az/taxes_az/doctype/tax_article/tax_article.js new file mode 100644 index 0000000..f5398cc --- /dev/null +++ b/taxes_az/taxes_az/doctype/tax_article/tax_article.js @@ -0,0 +1,8 @@ +// Copyright (c) 2025, Jey Soft and contributors +// For license information, please see license.txt + +// frappe.ui.form.on("Tax Article", { +// refresh(frm) { + +// }, +// }); diff --git a/taxes_az/taxes_az/doctype/tax_article/tax_article.json b/taxes_az/taxes_az/doctype/tax_article/tax_article.json new file mode 100644 index 0000000..8ae977b --- /dev/null +++ b/taxes_az/taxes_az/doctype/tax_article/tax_article.json @@ -0,0 +1,102 @@ +{ + "actions": [], + "allow_import": 1, + "allow_rename": 1, + "autoname": "Prompt", + "creation": "2025-08-26 13:42:04.102145", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "section_break_rgc0", + "article_name", + "parent_tax_article", + "declaration", + "lft", + "rgt", + "is_group", + "old_parent" + ], + "fields": [ + { + "fieldname": "section_break_rgc0", + "fieldtype": "Section Break" + }, + { + "description": "Name of the tax article", + "fieldname": "article_name", + "fieldtype": "Text", + "in_list_view": 1, + "label": "Article Name", + "reqd": 1, + "unique": 1 + }, + { + "description": "Declaration text for tax article", + "fieldname": "declaration", + "fieldtype": "Text", + "label": "Declaration" + }, + { + "default": "0", + "fieldname": "is_group", + "fieldtype": "Check", + "label": "Is Group" + }, + { + "fieldname": "lft", + "fieldtype": "Int", + "hidden": 1, + "label": "Left", + "no_copy": 1, + "read_only": 1 + }, + { + "fieldname": "rgt", + "fieldtype": "Int", + "hidden": 1, + "label": "Right", + "no_copy": 1, + "read_only": 1 + }, + { + "fieldname": "old_parent", + "fieldtype": "Link", + "label": "Old Parent", + "options": "Tax Article" + }, + { + "fieldname": "parent_tax_article", + "fieldtype": "Link", + "ignore_user_permissions": 1, + "label": "Parent Tax Article", + "options": "Tax Article" + } + ], + "index_web_pages_for_search": 1, + "is_tree": 1, + "links": [], + "modified": "2025-08-26 19:56:54.264329", + "modified_by": "Administrator", + "module": "Taxes Az", + "name": "Tax Article", + "naming_rule": "By script", + "nsm_parent_field": "parent_tax_article", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "creation", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/taxes_az/taxes_az/doctype/tax_article/tax_article.py b/taxes_az/taxes_az/doctype/tax_article/tax_article.py new file mode 100644 index 0000000..0ca126a --- /dev/null +++ b/taxes_az/taxes_az/doctype/tax_article/tax_article.py @@ -0,0 +1,30 @@ +import frappe +from frappe.model.document import Document + +class TaxArticle(Document): + def before_insert(self): + # Принудительно обрезаем при любой вставке + if hasattr(self, 'article_name') and self.article_name: + if len(str(self.article_name)) > 140: + self.article_name = str(self.article_name)[:137] + "..." + + def autoname(self): + if not self.article_name: + return + + name = str(self.article_name) + + # Обрезаем, если длиннее 140 символов + if len(name) > 140: + name = name[:137] + "..." + + # Проверяем уникальность + counter = 1 + original_name = name + while frappe.db.exists("Tax Article", name): + suffix = f"-{counter}" + max_length = 140 - len(suffix) + name = original_name[:max_length] + suffix + counter += 1 + + self.name = name \ No newline at end of file diff --git a/taxes_az/taxes_az/doctype/tax_article/test_tax_article.py b/taxes_az/taxes_az/doctype/tax_article/test_tax_article.py new file mode 100644 index 0000000..9273a0f --- /dev/null +++ b/taxes_az/taxes_az/doctype/tax_article/test_tax_article.py @@ -0,0 +1,30 @@ +# Copyright (c) 2025, Jey Soft and Contributors +# See license.txt + +# import frappe +from frappe.tests import IntegrationTestCase, UnitTestCase + + +# On IntegrationTestCase, the doctype test records and all +# link-field test record depdendencies are recursively loaded +# Use these module variables to add/remove to/from that list +EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] +IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"] + + +class UnitTestTaxArticle(UnitTestCase): + """ + Unit tests for TaxArticle. + Use this class for testing individual functions and methods. + """ + + pass + + +class IntegrationTestTaxArticle(IntegrationTestCase): + """ + Integration tests for TaxArticle. + Use this class for testing interactions between multiple components. + """ + + pass