From 9769ff0a604aa27a66ca98d70cb2df7d87742e6c Mon Sep 17 00:00:00 2001 From: diePuppe <95628567+diePuppe@users.noreply.github.com> Date: Tue, 18 Jul 2023 16:24:17 +0200 Subject: [PATCH] feat: automatic year in catch log entry(LAN-44 ) (#227) Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com> --- .../doctype/catch_log_entry/catch_log_entry.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/landa/water_body_management/doctype/catch_log_entry/catch_log_entry.js b/landa/water_body_management/doctype/catch_log_entry/catch_log_entry.js index 0f2bf614..fe2727e2 100644 --- a/landa/water_body_management/doctype/catch_log_entry/catch_log_entry.js +++ b/landa/water_body_management/doctype/catch_log_entry/catch_log_entry.js @@ -21,5 +21,12 @@ frappe.ui.form.on("Catch Log Entry", { }); }); } + const today = new Date(); + const current_year = today.getFullYear(); + const current_month = today.getMonth(); + + if (!frm.doc.year) { + frm.set_value("year", current_month < 6 ? current_year - 1 : current_year); + } }, });