added 207.9
This commit is contained in:
parent
e6884d19a8
commit
fa2bfa31c8
|
|
@ -249,6 +249,55 @@ function render_tax_validity_fields(frm, type) {
|
|||
.html('<i class="fa fa-check-circle"></i> <strong>Tam Azadolma</strong>')
|
||||
.appendTo($container);
|
||||
return;
|
||||
} else if (tax_article_name.includes('207.9')) {
|
||||
// Для 207.9 показываем только Date To с особым label
|
||||
frm[`_loading_validity_${type}`] = true;
|
||||
|
||||
let initial_date_to = tax_article.date_to;
|
||||
if (frm._tax_validity_data && frm._tax_validity_data[type]) {
|
||||
initial_date_to = frm._tax_validity_data[type].date_to || initial_date_to;
|
||||
}
|
||||
|
||||
const $row = $('<div class="row">').appendTo($container);
|
||||
const $col = $('<div class="col-sm-12">').appendTo($row);
|
||||
|
||||
const court_date_field = frappe.ui.form.make_control({
|
||||
parent: $col,
|
||||
df: {
|
||||
fieldtype: 'Date',
|
||||
label: __('Məhkəmə qərarının qüvvəyə mindiyi tarix'),
|
||||
fieldname: `${type}_court_date_dynamic`,
|
||||
change: function() {
|
||||
handle_court_date_change(frm, type);
|
||||
}
|
||||
},
|
||||
render_input: true
|
||||
});
|
||||
court_date_field.set_value(initial_date_to);
|
||||
|
||||
$('<div class="text-muted small" style="margin-top: 10px;">')
|
||||
.html('<i class="fa fa-info-circle"></i> ' + __('Changes will be saved to Tax Article when you save this Asset'))
|
||||
.appendTo($container);
|
||||
|
||||
if (!frm._tax_validity_controls) {
|
||||
frm._tax_validity_controls = {};
|
||||
}
|
||||
frm._tax_validity_controls[type] = {
|
||||
court_date: court_date_field
|
||||
};
|
||||
|
||||
if (!frm._tax_validity_data) {
|
||||
frm._tax_validity_data = {};
|
||||
}
|
||||
frm._tax_validity_data[type] = {
|
||||
date_to: initial_date_to
|
||||
};
|
||||
|
||||
setTimeout(() => {
|
||||
frm[`_loading_validity_${type}`] = false;
|
||||
}, 100);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Для всех остальных Tax Articles показываем поля дат
|
||||
|
|
@ -391,6 +440,34 @@ function handle_date_from_change(frm, type) {
|
|||
frm.dirty();
|
||||
}
|
||||
|
||||
function handle_court_date_change(frm, type) {
|
||||
// Игнорируем изменения во время загрузки
|
||||
if (frm[`_loading_validity_${type}`]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!frm._tax_validity_controls || !frm._tax_validity_controls[type]) {
|
||||
return;
|
||||
}
|
||||
|
||||
const controls = frm._tax_validity_controls[type];
|
||||
const court_date = controls.court_date.get_value();
|
||||
|
||||
if (!court_date) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Сохраняем в памяти
|
||||
if (!frm._tax_validity_data) {
|
||||
frm._tax_validity_data = {};
|
||||
}
|
||||
frm._tax_validity_data[type] = {
|
||||
date_to: court_date
|
||||
};
|
||||
|
||||
frm.dirty();
|
||||
}
|
||||
|
||||
function save_tax_validity_data(frm) {
|
||||
if (!frm._tax_validity_data) {
|
||||
return Promise.resolve();
|
||||
|
|
@ -412,17 +489,31 @@ function save_tax_validity_data(frm) {
|
|||
|
||||
const data = frm._tax_validity_data[type];
|
||||
|
||||
promises.push(
|
||||
frappe.call({
|
||||
method: 'jey_erp.asset_events.update_tax_article_from_asset',
|
||||
args: {
|
||||
tax_article_name: tax_article_name,
|
||||
date_from: data.date_from,
|
||||
date_to: data.date_to,
|
||||
duration: data.duration
|
||||
}
|
||||
})
|
||||
);
|
||||
// Для 207.9 сохраняем только date_to
|
||||
if (tax_article_name.includes('207.9')) {
|
||||
promises.push(
|
||||
frappe.call({
|
||||
method: 'jey_erp.asset_events.update_tax_article_from_asset',
|
||||
args: {
|
||||
tax_article_name: tax_article_name,
|
||||
date_to: data.date_to
|
||||
}
|
||||
})
|
||||
);
|
||||
} else {
|
||||
// Для обычных Tax Articles сохраняем все поля
|
||||
promises.push(
|
||||
frappe.call({
|
||||
method: 'jey_erp.asset_events.update_tax_article_from_asset',
|
||||
args: {
|
||||
tax_article_name: tax_article_name,
|
||||
date_from: data.date_from,
|
||||
date_to: data.date_to,
|
||||
duration: data.duration
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue