added tax articles, not finished yet
This commit is contained in:
parent
ed2b7af57d
commit
b417083c5b
|
|
@ -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) {
|
||||
|
||||
// },
|
||||
// });
|
||||
|
|
@ -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": []
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
Loading…
Reference in New Issue