Skip to content

Instantly share code, notes, and snippets.

View rmehta's full-sized avatar

Rushabh Mehta rmehta

View GitHub Profile
cur_frm.cscript.custom_entries_add = function(doc, cdt, cdn) {
var row = frappe.model.get_doc(cdt, cdn);
row.start_date_of_accounting_period = doc.start_date_of_accounting_period;
row.end_date_of_accounting_period = doc.end_date_of_accounting_period;
row.number_of_days = new Date(row.end_date_of_accounting_period) - new Date(row.start_date_of_accounting_period); // milliseconds
row.number_of_days = Math.round(row.number_of_days / 86400000);
refresh_field("start_date_of_accounting_period");
refresh_field("end_date_of_accounting_period");
refresh_field("number_of_days");
}
// refactored by Rushabh Mehta
// original script https://gist.github.com/rmehta/5a7dbf05494990b838f8
cur_frm.add_fetch('item_code','amount_allocated_on_permit',
'amount_allocated_on_permit');
window.naivasha = {
recalculate: function(doc, child_doctype, child_name) {
if(!doc) {
doc = cur_frm.doc;
# Usage:
# Make sure all files are in current folder
# Run `python convert.py`
#
# Output:
# Output file in `out.csv`
# Ignored rows in `ignored.csv`
cols = ['Voter`s Slip', 'AC Number', 'Part Number', 'Section Number', 'SerialNo. in Part ',
'Name in English', ' Name in Hindi', 'Relation FirstName in English', 'Relation FirstName in Hindi',
@rmehta
rmehta / import_jobs.py
Last active August 29, 2015 14:02
Import Jobs From CSV
import csv
NAME = 2
EMAIL = 3
INTRODUCTION = 4
THOUGHTS_ON_COMPANY = 5
LIKES = 6
LINKS = 7
PHONE = 8
@rmehta
rmehta / calc_total.js
Created July 6, 2014 07:01
Calcualate Total Quantity: ERPNext Custom Script Example
cur_frm.cscript.custom_validate = function() {
var sum = 0;
$.each(doc.entries, function(i, d) { sum += d.qty });
cur_frm.set_value(doc, "total_qty", sum);
}
@rmehta
rmehta / fixed_delivery_date.js
Created July 16, 2014 08:31
Allow fixed delivery dates: ERPNext Custom Script Example
cur_frm.cscript.custom_validate = function(doc) {
var date = doc.delivery_date.split("-")[2];
if(["15", "30"].indexOf(date)===-1) {
msgprint("Delivery date must be on 15th or 30th of the month");
throw "Wrong Delivery Date";
}
return false;
}
<!--
Sample Print Format for ERPNext
Please use at your own discretion
For suggestions and contributions:
https://github.com/frappe/erpnext-print-templates
Freely usable under MIT license
-->
<!-- Style Settings -->

D.3 Creating New Classes

The S2S is an extensible framework in which new classes can be created when models with objects describing specific behavior are required. Each new class has to be integrated into the modeling front end and with the rest of the model so that objects of other classes can interact with objects created from the new class.

In order to be integrated with the modeling front-end and the simulation object, it has to implement the interface IModelObject. By implementing this interface, the new class will contain a ModelNode that will keep track of its position in the modeling tree and will also allow other objects to navigate through it.

Creating a new class involves the following steps:

  1. Decide the position of the class in the model tree.
  2. Identify how a new object of the class will be created
Attribute VB_Name = "ForwardSchedule"
Option Explicit
Public Sub FwdSchedule(ORD As clsOrders, PRD() As clsProducts, RES() As clsResources, TM As clsTimeScale)
Dim RMax&, OMax&, OrderID&
OMax = ORD.Max
frmProgress.lblProgress.Caption = "Forward Scheduling..."
frmProgress.Refresh

I have known Pratik over 3 years now, first when he joined us as an intern and then as a full time colleague since Sept 2013. In my experience of over 10 years in the software development business, I have found that people are usually specialists (more depth than breadth) or generalists (more breadth than depth), but Pratik is one of those rare persons who combines both breadth and depth. Specially when it comes to computers, operating systems, programming languages and data structures. Not only is he strong in the theory but also has skills to read manuals and install and play with complex technology.

I think this quality will set him apart as a researcher in Computer Science in whichever field he chooses to pursue. At Web Notes, Pratik manages our infrastructure and builds tools for deployment of our product. Our company publishes a cloud based ERP system based on Maria DB and Python and Pratik has been instrumental in making its architecture extremely efficient and robust based on the latest available to