fixed bugs

This commit is contained in:
Ali 2025-12-02 16:16:40 +04:00
parent 2a496a6658
commit c4b02cf35a
2 changed files with 68 additions and 18 deletions

View File

@ -256,7 +256,7 @@ def create_custom_fields():
fieldname='taxable_asset_type', fieldname='taxable_asset_type',
label='Taxable Asset Type', label='Taxable Asset Type',
fieldtype='Select', fieldtype='Select',
options='\nBinalar, tikililər və qurğular\nÇoxmərtəbəli (çoxmənzilli) yaşayış binalar\nQeyri-yaşayış binaları (sahələri)\nƏmlak kompleksi kimi müəssisələr\nQurğular\nMənzillər\nFərdi yaşayış və bağ evləri\nMaşınlar və avadanlıqlar\nYüksək texnologiyalar məhsulu olan hesablama texnikası\nNəqliyyat vasitələri\nDigər əsas vəsaitlər', options='\nÇoxmərtəbəli (çoxmənzilli) yaşayış binalar\nQeyri-yaşayış binaları (sahələri)\nƏmlak kompleksi kimi müəssisələr\nQurğular\nMənzillər\nFərdi yaşayış və bağ evləri\nMaşınlar və avadanlıqlar\nYüksək texnologiyalar məhsulu olan hesablama texnikası\nNəqliyyat vasitələri\nDigər əsas vəsaitlər',
insert_after='taxable_settlements', insert_after='taxable_settlements',
depends_on='eval:doc.custom_asset_type == "Vergiyə cəlb olunan əsas vəsaitlər"', depends_on='eval:doc.custom_asset_type == "Vergiyə cəlb olunan əsas vəsaitlər"',
reqd=0 reqd=0

View File

@ -175,10 +175,15 @@ frappe.ui.form.on('Asset', {
} }
if (frm.doc.custom_asset_type === "Vergiyə cəlb olunan əsas vəsaitlər") { if (frm.doc.custom_asset_type === "Vergiyə cəlb olunan əsas vəsaitlər") {
const required_fields = [ const required_fields = [];
['taxable_settlements', 'Settlements'],
['taxable_asset_type', 'Taxable Asset Type'] // taxable_settlements обязателен только для Land
]; if (frm.doc.land) {
required_fields.push(['taxable_settlements', 'Settlements']);
}
// taxable_asset_type обязателен всегда
required_fields.push(['taxable_asset_type', 'Taxable Asset Type']);
for (let [field, label] of required_fields) { for (let [field, label] of required_fields) {
if (!frm.doc[field]) { if (!frm.doc[field]) {
@ -257,6 +262,39 @@ function render_tax_validity_fields(frm, type) {
const tax_article = r.message; const tax_article = r.message;
const tax_article_name = frm.doc[tax_article_field]; const tax_article_name = frm.doc[tax_article_field];
// ===== НОВАЯ ПРОВЕРКА: Показываем поля только для определенных Tax Articles =====
const allowed_tax_articles = [
'199.7',
'199.9',
'199.11',
'199.14',
'199.15',
'199.16',
'199.17',
'199.19',
'199.20',
'227.1',
'207.4',
'207.8',
'207.9'
];
// Проверяем, содержит ли название Tax Article один из разрешенных номеров
const is_allowed = allowed_tax_articles.some(pattern => tax_article_name.includes(pattern));
if (!is_allowed) {
// Если Tax Article не в списке - очищаем контролы и выходим
const $wrapper = frm.fields_dict[html_field].$wrapper;
$wrapper.html('');
if (frm._tax_validity_controls && frm._tax_validity_controls[type]) {
delete frm._tax_validity_controls[type];
}
return;
}
// ===== КОНЕЦ НОВОЙ ПРОВЕРКИ =====
// Очищаем старые контролы // Очищаем старые контролы
const $wrapper = frm.fields_dict[html_field].$wrapper; const $wrapper = frm.fields_dict[html_field].$wrapper;
$wrapper.html(''); $wrapper.html('');
@ -663,9 +701,16 @@ function setup_asset_type_options(frm) {
function show_common_fields(frm) { function show_common_fields(frm) {
frm.set_df_property('common_land_section', 'hidden', 0); frm.set_df_property('common_land_section', 'hidden', 0);
// Показываем tax_exempt_area только для Land, скрываем для Property
if (frm.doc.land) {
frm.set_df_property('tax_exempt_area', 'hidden', 0); frm.set_df_property('tax_exempt_area', 'hidden', 0);
frm.set_df_property('tax_exempt_area', 'description', frm.set_df_property('tax_exempt_area', 'description',
'Enter the tax-exempt area in square meters'); 'Enter the tax-exempt area in square meters');
} else if (frm.doc.property) {
frm.set_df_property('tax_exempt_area', 'hidden', 1);
frm.set_df_property('tax_exempt_area', 'description', '');
}
} }
function hide_all_conditional_fields(frm) { function hide_all_conditional_fields(frm) {
@ -857,17 +902,22 @@ function setup_taxable_fields(frm) {
frm.set_df_property(fieldname, 'hidden', 0); frm.set_df_property(fieldname, 'hidden', 0);
}); });
const required_taxable_fields = [ // Скрываем taxable_settlements для Property
'taxable_settlements', if (frm.doc.property) {
'taxable_asset_type' frm.set_df_property('taxable_settlements', 'hidden', 1);
]; frm.set_df_property('taxable_settlements', 'reqd', 0);
required_taxable_fields.forEach(fieldname => { // Только taxable_asset_type обязателен для Property
frm.set_df_property(fieldname, 'reqd', 1); frm.set_df_property('taxable_asset_type', 'reqd', 1);
}); } else {
// Для Land оба поля обязательны
frm.set_df_property('taxable_settlements', 'reqd', 1);
frm.set_df_property('taxable_asset_type', 'reqd', 1);
frm.set_df_property('taxable_settlements', 'description', frm.set_df_property('taxable_settlements', 'description',
'Select the settlement type'); 'Select the settlement type');
}
frm.set_df_property('taxable_asset_type', 'description', frm.set_df_property('taxable_asset_type', 'description',
'Select the type of taxable asset'); 'Select the type of taxable asset');
} }