I am looking to implement a different calendar system in ERPNext. Most of the world uses Gregorian calendar system represented by A.D. So, today’s date is 2022-May-02. So its 2022 A.D.
We however in Nepal use a Bikram Sambat (B.S.). Today is 2079-01-19 (yyyy-mm-dd). The conversion is quite simple. We are 56 years 8 months and 16 days ahead of Gregorian calendar. (I don’t know if this conversion breaks at any date in distant past or future.) The BS calendar is not only renaming the months and days in our local language but we have a complete different system. January in Gregorian calendar always has 31 days no matter the year. 2022 had 31 days in January, 2023 will have the same and the year 3023 will have the same. But in BS the number of days might vary. If the third month of 2078 (last year) had 31 days, the third month of this year 2079 has 32 days. Overall we have 365 days in a year like a Gregorian calendar. We also observe leap years. Days distribution across months vary.
I am looking for a way to implement BS system in ERPNext. I found some other users trying to implement similar system for their local calendar system as well.
I believe there is an easier way and a harder way. The easier way I think is to leave database untouched and write script to change the view only. This way, I will pick the date in BS, but the system will store and understand in AD.
The other way would be to make the system understand BS.
However, I am not quite sure if my understandings are right and if yes, how can we achieve the desired result ?
I wish ERPNext had a built in method to switch calendar.
At one point, @dipakthapa reported getting a Bikram calendar to work. It would be great if he shared!
I’ve looked at it a bit but have never been able to put in the time to make it work. I don’t imagine there will ever be a “drop-in” system for changing among any number of arbitrary calendars, since the alternate calendar widgets I’ve seen all have different apis. That said, it should still be pretty simple.
I agree there’s absolutely no reason to touch the database, so it’s really just a matter of customizing the date field widget. You’d need a custom app, but once you have that it’s pretty trivial to override the date-picker widget. My approach would probably be to add a second input field to the DOM. Call it “date-bs” or whatever, then attach one of the many FOSS Bikram Sambat calendar widgets out there. You could put event triggers on both that and the original field so that each updates the other on change. All that can be done here:
It would be a different process for reports. I haven’t really looked into it yet, so I’m not sure if each report would have to be customized individually or if it would be possible to do it all in one swoop.
I actually went through probably all discussions here on calendar system implementations and definitely saw the post where @dipakthapa got a working BS calendar, but he never shared the concept/code.
That would really be simple solution on the front end. What I wish is not just customizing the date field. I think it would be great if the whole system could talk in another calendar system. For example, If someone’s birthday is 1st Jan 2000 AD, it was 18th day of the Nineth month 2056 BS. However, his 22nd birthday on 1st Jan 2022 was on 17th day of the Nineth month of 2078 BS. This could sometimes be on 18th or on 17th. I think it would be great if ERPNext sends birthday remainders on the 18th day of Nineth month every year based on BS calendar, not on 1st Jan.
I don’t mean to say sending birthday remainders is the only important thing but I was highlighting the scope of calendar integration.
I was thinking of similar simpler solution to address calendar integration problem. Could you please tell me which file do I have to modify ?
This would likely require a massive rewrite. This all goes well beyond just ERPNext. Mariadb’s date field is hardwired to the Gregorian calendar, and using another calendar as default would require some fairly low-level code design.
On the ERPNext side, you could definitely do what you’re talking about, but you’d have to handle each issue like birthdays individually.
The best approach here wouldn’t involve modifying core files. Just include a new JS file in your custom app that extends the base class. If you want to see where the class is defined, just run a search for the classname “ControlDate” in github.
Sorry for late reply @anupd and @peterg. Actually I was busy in implementation of ERPNext for a big company that’s the reason I was not able to spend time on forum.
For BS Calendar integration we have made Customized application along IRD Nepal compliance. Hopefully we are gonna published this app for IRD compliance and Nepali calendar on frappe app store soon.