2017-07-03 12:53:57 +00:00
frappe . provide ( "erpnext.setup" ) ;
2015-11-09 11:23:11 +00:00
frappe . pages [ 'setup-wizard' ] . on _page _load = function ( wrapper ) {
2017-05-30 07:24:42 +00:00
if ( frappe . sys _defaults . company ) {
2015-11-09 11:23:11 +00:00
frappe . set _route ( "desk" ) ;
return ;
}
2015-11-16 07:28:14 +00:00
} ;
2017-07-03 12:53:57 +00:00
var erpnext _slides = [
{
// Domain
name : 'domain' ,
domains : [ "all" ] ,
title : _ _ ( 'Select your Domain' ) ,
fields : [
{
fieldname : 'domain' , label : _ _ ( 'Domain' ) , fieldtype : 'Select' ,
options : [
{ "label" : _ _ ( "Distribution" ) , "value" : "Distribution" } ,
{ "label" : _ _ ( "Education" ) , "value" : "Education" } ,
{ "label" : _ _ ( "Manufacturing" ) , "value" : "Manufacturing" } ,
{ "label" : _ _ ( "Retail" ) , "value" : "Retail" } ,
{ "label" : _ _ ( "Services" ) , "value" : "Services" }
] , reqd : 1
2016-07-21 10:31:59 +00:00
} ,
2017-07-03 12:53:57 +00:00
] ,
help : _ _ ( 'Select the nature of your business.' ) ,
onload : function ( slide ) {
slide . get _input ( "domain" ) . on ( "change" , function ( ) {
frappe . setup . domain = $ ( this ) . val ( ) ;
frappe . wizard . refresh _slides ( ) ;
} ) ;
2016-07-21 10:31:59 +00:00
} ,
2017-07-03 12:53:57 +00:00
} ,
{
// Brand
name : 'brand' ,
domains : [ "all" ] ,
icon : "fa fa-bookmark" ,
title : _ _ ( "The Brand" ) ,
help : _ _ ( 'Upload your letter head and logo. (you can edit them later).' ) ,
fields : [
{
fieldtype : "Attach Image" , fieldname : "attach_logo" ,
label : _ _ ( "Attach Logo" ) ,
description : _ _ ( "100px by 100px" ) ,
is _private : 0
2015-11-16 07:28:14 +00:00
} ,
2017-07-03 12:53:57 +00:00
{
fieldname : 'company_name' ,
label : frappe . setup . domain === 'Education' ?
_ _ ( 'Institute Name' ) : _ _ ( 'Company Name' ) ,
fieldtype : 'Data' , reqd : 1
2015-11-24 11:36:54 +00:00
} ,
2017-07-03 12:53:57 +00:00
{
fieldname : 'company_abbr' ,
label : frappe . setup . domain === 'Education' ?
_ _ ( 'Institute Abbreviation' ) : _ _ ( 'Company Abbreviation' ) ,
fieldtype : 'Data'
}
] ,
onload : function ( slide ) {
this . bind _events ( slide ) ;
} ,
bind _events : function ( slide ) {
slide . get _input ( "company_name" ) . on ( "change" , function ( ) {
var parts = slide . get _input ( "company_name" ) . val ( ) . split ( " " ) ;
var abbr = $ . map ( parts , function ( p ) { return p ? p . substr ( 0 , 1 ) : null } ) . join ( "" ) ;
slide . get _field ( "company_abbr" ) . set _input ( abbr . slice ( 0 , 5 ) . toUpperCase ( ) ) ;
} ) . val ( frappe . boot . sysdefaults . company _name || "" ) . trigger ( "change" ) ;
slide . get _input ( "company_abbr" ) . on ( "change" , function ( ) {
if ( slide . get _input ( "company_abbr" ) . val ( ) . length > 5 ) {
frappe . msgprint ( "Company Abbreviation cannot have more than 5 characters" ) ;
slide . get _field ( "company_abbr" ) . set _input ( "" ) ;
2015-11-16 07:28:14 +00:00
}
2017-07-03 12:53:57 +00:00
} ) ;
}
} ,
{
// Organisation
name : 'organisation' ,
domains : [ "all" ] ,
title : _ _ ( "Your Organization" ) ,
icon : "fa fa-building" ,
help : ( frappe . setup . domain === 'Education' ?
_ _ ( 'The name of the institute for which you are setting up this system.' ) :
_ _ ( 'The name of your company for which you are setting up this system.' ) ) ,
fields : [
{
fieldname : 'company_tagline' ,
label : _ _ ( 'What does it do?' ) ,
fieldtype : 'Data' ,
placeholder : frappe . setup . domain === 'Education' ?
_ _ ( 'e.g. "Primary School" or "University"' ) :
_ _ ( 'e.g. "Build tools for builders"' ) ,
reqd : 1
2015-11-16 07:28:14 +00:00
} ,
2017-07-03 12:53:57 +00:00
{ fieldname : 'bank_account' , label : _ _ ( 'Bank Name' ) , fieldtype : 'Data' , reqd : 1 } ,
{
fieldname : 'chart_of_accounts' , label : _ _ ( 'Chart of Accounts' ) ,
options : "" , fieldtype : 'Select'
2015-11-16 07:28:14 +00:00
} ,
2017-07-03 12:53:57 +00:00
{ fieldtype : "Section Break" , label : "Financial Year" } ,
{ fieldname : 'fy_start_date' , label : _ _ ( 'Start Date' ) , fieldtype : 'Date' , reqd : 1 } ,
{ fieldtype : "Column Break" } ,
{ fieldname : 'fy_end_date' , label : _ _ ( 'End Date' ) , fieldtype : 'Date' , reqd : 1 } ,
] ,
2015-11-16 07:28:14 +00:00
2017-07-03 12:53:57 +00:00
onload : function ( slide ) {
this . load _chart _of _accounts ( slide ) ;
this . bind _events ( slide ) ;
this . set _fy _dates ( slide ) ;
} ,
2015-11-16 07:28:14 +00:00
2017-07-03 12:53:57 +00:00
validate : function ( ) {
// validate fiscal year start and end dates
if ( this . values . fy _start _date == 'Invalid date' || this . values . fy _end _date == 'Invalid date' ) {
frappe . msgprint ( _ _ ( "Please enter valid Financial Year Start and End Dates" ) ) ;
return false ;
2015-11-09 11:23:11 +00:00
}
2017-07-03 12:53:57 +00:00
if ( ( this . values . company _name || "" ) . toLowerCase ( ) == "company" ) {
frappe . msgprint ( _ _ ( "Company Name cannot be Company" ) ) ;
return false ;
}
2015-11-16 07:28:14 +00:00
2017-07-03 12:53:57 +00:00
return true ;
2015-11-09 11:23:11 +00:00
} ,
2015-11-16 07:28:14 +00:00
2017-07-03 12:53:57 +00:00
set _fy _dates : function ( slide ) {
var country = frappe . wizard . values . country ;
2015-11-16 07:28:14 +00:00
2017-07-03 12:53:57 +00:00
if ( country ) {
var fy = erpnext . setup . fiscal _years [ country ] ;
var current _year = moment ( new Date ( ) ) . year ( ) ;
var next _year = current _year + 1 ;
if ( ! fy ) {
2017-07-05 11:56:34 +00:00
fy = [ "01-01" , "12-31" ] ;
2017-07-03 12:53:57 +00:00
next _year = current _year ;
2015-11-16 07:28:14 +00:00
}
2015-11-09 11:23:11 +00:00
2017-07-03 12:53:57 +00:00
var year _start _date = current _year + "-" + fy [ 0 ] ;
if ( year _start _date > frappe . datetime . get _today ( ) ) {
2017-07-05 12:26:04 +00:00
next _year = current _year ;
2017-07-03 12:53:57 +00:00
current _year -= 1 ;
2015-11-16 07:28:14 +00:00
}
2017-07-05 12:26:04 +00:00
slide . get _field ( "fy_start_date" ) . set _value ( current _year + '-' + fy [ 0 ] ) ;
slide . get _field ( "fy_end_date" ) . set _value ( next _year + '-' + fy [ 1 ] ) ;
2017-07-03 12:53:57 +00:00
}
2015-11-09 11:23:11 +00:00
2015-11-16 07:28:14 +00:00
} ,
2016-07-21 10:31:59 +00:00
2017-07-03 12:53:57 +00:00
load _chart _of _accounts : function ( slide ) {
var country = frappe . wizard . values . country ;
2016-07-21 10:31:59 +00:00
2017-07-03 12:53:57 +00:00
if ( country ) {
frappe . call ( {
method : "erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts.get_charts_for_country" ,
args : { "country" : country } ,
callback : function ( r ) {
if ( r . message ) {
slide . get _input ( "chart_of_accounts" ) . empty ( )
. add _options ( r . message ) ;
2016-07-21 10:31:59 +00:00
2017-07-03 12:53:57 +00:00
if ( r . message . length === 1 ) {
var field = slide . get _field ( "chart_of_accounts" ) ;
field . set _value ( r . message [ 0 ] ) ;
field . df . hidden = 1 ;
field . refresh ( ) ;
}
}
}
} )
}
2016-07-21 10:31:59 +00:00
} ,
2017-07-03 12:53:57 +00:00
bind _events : function ( slide ) {
slide . get _input ( "fy_start_date" ) . on ( "change" , function ( ) {
2017-07-05 12:26:04 +00:00
var start _date = slide . form . fields _dict . fy _start _date . get _value ( ) ;
2017-07-03 12:53:57 +00:00
var year _end _date =
2017-07-05 12:26:04 +00:00
frappe . datetime . add _days ( frappe . datetime . add _months ( start _date , 12 ) , - 1 ) ;
slide . form . fields _dict . fy _end _date . set _value ( year _end _date ) ;
2017-07-03 12:53:57 +00:00
} ) ;
}
} ,
2017-07-11 07:06:34 +00:00
{
// Users
name : 'users' ,
domains : [ "all" ] ,
title : _ _ ( "Add Users" ) ,
help : _ _ ( "Add users to your organization, other than yourself" ) ,
add _more : 1 ,
max _count : 3 ,
fields : [
{ fieldtype : "Section Break" } ,
{ fieldtype : "Data" , fieldname : "user_fullname" ,
label : _ _ ( "Full Name" ) , static : 1 } ,
{ fieldtype : "Data" , fieldname : "user_email" , label : _ _ ( "Email ID" ) ,
placeholder : _ _ ( "user@example.com" ) , options : "Email" , static : 1 } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Check" , fieldname : "user_sales" ,
label : _ _ ( "Sales" ) , "default" : 1 , static : 1 ,
hidden : frappe . setup . domain === 'Education' ? 1 : 0 } ,
{ fieldtype : "Check" , fieldname : "user_purchaser" ,
label : _ _ ( "Purchaser" ) , "default" : 1 , static : 1 ,
hidden : frappe . setup . domain === 'Education' ? 1 : 0 } ,
{ fieldtype : "Check" , fieldname : "user_accountant" ,
label : _ _ ( "Accountant" ) , "default" : 1 , static : 1 ,
hidden : frappe . setup . domain === 'Education' ? 1 : 0 } ,
]
} ,
2017-07-03 12:53:57 +00:00
{
// Taxes
name : 'taxes' ,
domains : [ 'manufacturing' , 'services' , 'retail' , 'distribution' ] ,
icon : "fa fa-money" ,
title : _ _ ( "Add Taxes" ) ,
help : _ _ ( "List your tax heads (e.g. VAT, Customs etc; they should have unique names) and their standard rates. This will create a standard template, which you can edit and add more later." ) ,
add _more : 1 ,
2017-07-11 07:06:34 +00:00
max _count : 3 ,
mandatory _entry : 1 ,
2017-07-03 12:53:57 +00:00
fields : [
{ fieldtype : "Section Break" } ,
{ fieldtype : "Data" , fieldname : "tax" , label : _ _ ( "Tax" ) ,
placeholder : _ _ ( "e.g. VAT" ) } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Float" , fieldname : "tax_rate" , label : _ _ ( "Rate (%)" ) , placeholder : _ _ ( "e.g. 5" ) }
]
} ,
{
// Customers
name : 'customers' ,
domains : [ 'manufacturing' , 'services' , 'retail' , 'distribution' ] ,
icon : "fa fa-group" ,
title : _ _ ( "Add Customers" ) ,
help : _ _ ( "List a few of your customers. They could be organizations or individuals." ) ,
add _more : 1 ,
2017-07-11 07:06:34 +00:00
max _count : 5 ,
mandatory _entry : 1 ,
2017-07-03 12:53:57 +00:00
fields : [
{ fieldtype : "Section Break" } ,
{ fieldtype : "Data" , fieldname : "customer" , label : _ _ ( "Customer" ) ,
placeholder : _ _ ( "Customer Name" ) } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Data" , fieldname : "customer_contact" ,
label : _ _ ( "Contact Name" ) , placeholder : _ _ ( "Contact Name" ) }
] ,
} ,
{
// Suppliers
name : 'suppliers' ,
domains : [ 'manufacturing' , 'services' , 'retail' , 'distribution' ] ,
icon : "fa fa-group" ,
title : _ _ ( "Your Suppliers" ) ,
help : _ _ ( "List a few of your suppliers. They could be organizations or individuals." ) ,
add _more : 1 ,
2017-07-11 07:06:34 +00:00
max _count : 5 ,
mandatory _entry : 1 ,
2017-07-03 12:53:57 +00:00
fields : [
{ fieldtype : "Section Break" } ,
{ fieldtype : "Data" , fieldname : "supplier" , label : _ _ ( "Supplier" ) ,
placeholder : _ _ ( "Supplier Name" ) } ,
{ fieldtype : "Column Break" } ,
{ fieldtype : "Data" , fieldname : "supplier_contact" ,
label : _ _ ( "Contact Name" ) , placeholder : _ _ ( "Contact Name" ) } ,
]
} ,
{
// Products
name : 'products' ,
domains : [ 'manufacturing' , 'services' , 'retail' , 'distribution' ] ,
icon : "fa fa-barcode" ,
title : _ _ ( "Your Products or Services" ) ,
help : _ _ ( "List your products or services that you buy or sell. Make sure to check the Item Group, Unit of Measure and other properties when you start." ) ,
add _more : 1 ,
2017-07-11 07:06:34 +00:00
max _count : 5 ,
mandatory _entry : 1 ,
2017-07-03 12:53:57 +00:00
fields : [
{ fieldtype : "Section Break" , show _section _border : true } ,
{ fieldtype : "Data" , fieldname : "item" , label : _ _ ( "Item" ) ,
placeholder : _ _ ( "A Product or Service" ) } ,
{ fieldtype : "Select" , label : _ _ ( "Group" ) , fieldname : "item_group" ,
options : [ _ _ ( "Products" ) , _ _ ( "Services" ) ,
_ _ ( "Raw Material" ) , _ _ ( "Consumable" ) , _ _ ( "Sub Assemblies" ) ] ,
2017-07-11 07:06:34 +00:00
"default" : _ _ ( "Products" ) , static : 1 } ,
2017-07-03 12:53:57 +00:00
{ fieldtype : "Select" , fieldname : "item_uom" , label : _ _ ( "UOM" ) ,
options : [ _ _ ( "Unit" ) , _ _ ( "Nos" ) , _ _ ( "Box" ) , _ _ ( "Pair" ) , _ _ ( "Kg" ) , _ _ ( "Set" ) ,
_ _ ( "Hour" ) , _ _ ( "Minute" ) , _ _ ( "Litre" ) , _ _ ( "Meter" ) , _ _ ( "Gram" ) ] ,
2017-07-11 07:06:34 +00:00
"default" : _ _ ( "Unit" ) , static : 1 } ,
{ fieldtype : "Check" , fieldname : "is_sales_item" , label : _ _ ( "We sell this Item" ) , default : 1 , static : 1 } ,
{ fieldtype : "Check" , fieldname : "is_purchase_item" , label : _ _ ( "We buy this Item" ) , static : 1 } ,
2017-07-03 12:53:57 +00:00
{ fieldtype : "Column Break" } ,
2017-07-11 07:06:34 +00:00
{ fieldtype : "Currency" , fieldname : "item_price" , label : _ _ ( "Rate" ) , static : 1 } ,
{ fieldtype : "Attach Image" , fieldname : "item_img" , label : _ _ ( "Attach Image" ) , is _private : 0 , static : 1 } ,
2017-07-03 12:53:57 +00:00
] ,
get _item _count : function ( ) {
return this . item _count ;
}
} ,
{
// Program
name : 'program' ,
domains : [ "education" ] ,
title : _ _ ( "Program" ) ,
help : _ _ ( "Example: Masters in Computer Science" ) ,
add _more : 1 ,
2017-07-11 07:06:34 +00:00
max _count : 5 ,
mandatory _entry : 1 ,
2017-07-03 12:53:57 +00:00
fields : [
{ fieldtype : "Section Break" , show _section _border : true } ,
{ fieldtype : "Data" , fieldname : "program" , label : _ _ ( "Program" ) , placeholder : _ _ ( "Program Name" ) } ,
] ,
} ,
{
// Course
name : 'course' ,
domains : [ "education" ] ,
title : _ _ ( "Course" ) ,
help : _ _ ( "Example: Basic Mathematics" ) ,
add _more : 1 ,
2017-07-11 07:06:34 +00:00
max _count : 5 ,
mandatory _entry : 1 ,
2017-07-03 12:53:57 +00:00
fields : [
{ fieldtype : "Section Break" , show _section _border : true } ,
{ fieldtype : "Data" , fieldname : "course" , label : _ _ ( "Course" ) , placeholder : _ _ ( "Course Name" ) } ,
]
} ,
{
// Instructor
name : 'instructor' ,
domains : [ "education" ] ,
title : _ _ ( "Instructor" ) ,
help : _ _ ( "People who teach at your organisation" ) ,
add _more : 1 ,
2017-07-11 07:06:34 +00:00
max _count : 5 ,
mandatory _entry : 1 ,
2017-07-03 12:53:57 +00:00
fields : [
{ fieldtype : "Section Break" , show _section _border : true } ,
{ fieldtype : "Data" , fieldname : "instructor" , label : _ _ ( "Instructor" ) , placeholder : _ _ ( "Instructor Name" ) } ,
]
} ,
{
// Room
name : 'room' ,
domains : [ "education" ] ,
title : _ _ ( "Room" ) ,
help : _ _ ( "Classrooms/ Laboratories etc where lectures can be scheduled." ) ,
add _more : 1 ,
2017-07-11 07:06:34 +00:00
max _count : 3 ,
mandatory _entry : 1 ,
2017-07-03 12:53:57 +00:00
fields : [
{ fieldtype : "Section Break" , show _section _border : true } ,
{ fieldtype : "Data" , fieldname : "room" , label : _ _ ( "Room" ) } ,
{ fieldtype : "Column Break" } ,
2017-07-11 07:06:34 +00:00
{ fieldtype : "Int" , fieldname : "room_capacity" , label : _ _ ( "Room" ) + " Capacity" , static : 1 } ,
2017-07-03 12:53:57 +00:00
]
} ,
{
2017-07-11 07:06:34 +00:00
// last slide: Sample Data
2017-07-03 12:53:57 +00:00
name : 'bootstrap' ,
domains : [ "all" ] ,
2017-07-11 07:06:34 +00:00
title : _ _ ( "Sample Data" ) ,
2017-07-03 12:53:57 +00:00
fields : [ { fieldtype : "Section Break" } ,
{ fieldtype : "Check" , fieldname : "add_sample_data" ,
label : _ _ ( "Add a few sample records" ) , "default" : 1 } ,
{ fieldtype : "Check" , fieldname : "setup_website" ,
label : _ _ ( "Setup a simple website for my organization" ) , "default" : 1 }
]
2016-07-05 16:04:21 +00:00
}
2017-07-03 12:53:57 +00:00
] ;
// Source: https://en.wikipedia.org/wiki/Fiscal_year
// default 1st Jan - 31st Dec
erpnext . setup . fiscal _years = {
2017-07-05 11:56:34 +00:00
"Afghanistan" : [ "12-20" , "12-21" ] ,
"Australia" : [ "07-01" , "06-30" ] ,
"Bangladesh" : [ "07-01" , "06-30" ] ,
"Canada" : [ "04-01" , "03-31" ] ,
"Costa Rica" : [ "10-01" , "09-30" ] ,
"Egypt" : [ "07-01" , "06-30" ] ,
"Hong Kong" : [ "04-01" , "03-31" ] ,
"India" : [ "04-01" , "03-31" ] ,
"Iran" : [ "06-23" , "06-22" ] ,
"Italy" : [ "07-01" , "06-30" ] ,
"Myanmar" : [ "04-01" , "03-31" ] ,
"New Zealand" : [ "04-01" , "03-31" ] ,
"Pakistan" : [ "07-01" , "06-30" ] ,
"Singapore" : [ "04-01" , "03-31" ] ,
"South Africa" : [ "03-01" , "02-28" ] ,
"Thailand" : [ "10-01" , "09-30" ] ,
"United Kingdom" : [ "04-01" , "03-31" ] ,
2017-07-03 12:53:57 +00:00
} ;
frappe . setup . on ( "before_load" , function ( ) {
erpnext _slides . map ( frappe . setup . add _slide ) ;
2016-07-05 16:04:21 +00:00
2017-07-03 12:53:57 +00:00
// change header brand
let $brand = $ ( 'header .setup-wizard-brand' ) ;
if ( $brand . find ( '.erpnext-icon' ) . length === 0 ) {
$brand . find ( '.frappe-icon' ) . hide ( ) ;
$brand . append ( ` <span>
< img src = "/assets/erpnext/images/erp-icon.svg" class = "brand-icon erpnext-icon"
style = "width:36px;" > < span class = "brand-name" > ERPNext < / s p a n > < / s p a n > ` ) ;
2016-07-21 10:31:59 +00:00
}
2015-11-09 11:23:11 +00:00
} ) ;
2016-07-21 10:31:59 +00:00
2017-05-30 07:24:42 +00:00
var test _values _edu = {
2017-07-03 12:53:57 +00:00
"language" : "english" ,
"domain" : "Education" ,
"country" : "India" ,
"timezone" : "Asia/Kolkata" ,
"currency" : "INR" ,
"first_name" : "Tester" ,
"email" : "test@example.com" ,
"password" : "test" ,
"company_name" : "Hogwarts" ,
"company_abbr" : "HS" ,
"company_tagline" : "School for magicians" ,
"bank_account" : "Gringotts Wizarding Bank" ,
"fy_start_date" : "2016-04-01" ,
"fy_end_date" : "2017-03-31"
2016-07-21 10:31:59 +00:00
}