Try ERPNext Buy Support Partners Foundation

Calculate last day of month from a date field

Hi all,

i’am trying to calculate last day of month from a date field

while selecting available-for-use -date then depreciation start date auto-set to last of month from available-for-use-date

how do i solve this? i want to do it in js

frappe.ui.form.on('Asset', {

available_for_use_date: function(frm) {

    var depreciation_start_date = moment(frm.doc.available_for_use_date).endOf('month').format('YYYY-MM-DD')

    $.each(frm.doc.finance_books || [], function(i, d) {

        d.depreciation_start_date = depreciation_start_date;