Sales invoice during Ramadan

During Ramadan, many companies in Saudi Arabia and other Arab countris works after 12 Midnight, and most of them need to record sales invoice as its on the same day. Use this client script as a work

 · 1 min read

Ramadan office timing from 9:00am to 3:30pm

Use this Client script ,


frappe.ui.form.on('Sales Invoice', {

  onload: function(frm) {

    // Get the current date and time

    var currentDate = new Date();

    var currentHour = currentDate.getHours();


    // Check if the current time is between 12:00 AM and 3:00 AM

    if (currentHour >= 12 && currentHour <= 3) {

      // Subtract one day from the current date

      currentDate.setDate(currentDate.getDate() - 1);

    }


    // Format the date as 'YYYY-MM-DD'

    var formattedDate = currentDate.toISOString().split('T')[0];


    // Set the posting date

    frm.set_value('posting_date', formattedDate);

  }

});



Also , dont forget to tick "Edit posting date and time"


The same script with minor changes can be applied on other doctypes.


Team ERPGulf

The team behind ERPGulf blogs here, expresses their thoughts, shares the experience, often show the frustrations. Contact us on support@ERPGulf.com

No comments yet

No comments yet. Start a new discussion.

Add Comment