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-09-04 05:44:04 +00:00
|
|
|
frappe.setup.on("before_load", function () {
|
|
|
|
erpnext.setup.slides_settings.map(frappe.setup.add_slide);
|
|
|
|
});
|
|
|
|
|
|
|
|
erpnext.setup.slides_settings = [
|
2017-07-03 12:53:57 +00:00
|
|
|
{
|
|
|
|
// Domain
|
|
|
|
name: 'domain',
|
2017-12-06 07:58:06 +00:00
|
|
|
title: __('Select your Domains'),
|
2017-07-03 12:53:57 +00:00
|
|
|
fields: [
|
|
|
|
{
|
2017-12-06 07:58:06 +00:00
|
|
|
fieldname: 'domains',
|
|
|
|
label: __('Domains'),
|
|
|
|
fieldtype: 'MultiCheck',
|
2017-07-03 12:53:57 +00:00
|
|
|
options: [
|
|
|
|
{ "label": __("Distribution"), "value": "Distribution" },
|
2017-12-13 13:20:39 +00:00
|
|
|
{ "label": __("Education"), "value": "Education" },
|
2017-07-03 12:53:57 +00:00
|
|
|
{ "label": __("Manufacturing"), "value": "Manufacturing" },
|
|
|
|
{ "label": __("Retail"), "value": "Retail" },
|
2017-09-04 05:44:04 +00:00
|
|
|
{ "label": __("Services"), "value": "Services" },
|
2017-12-13 13:20:39 +00:00
|
|
|
{ "label": __("Agriculture (beta)"), "value": "Agriculture" },
|
[Agriculture Domain] (#11663)
* created Soil Analysis, Water Analysis, Weather and Fertilizer doctype
* soil doctype edited and crop doctype added
* minor stuff
* Land Unit + Leaflet
* crop cycle added
* Land Unit changes + Crop cycle
* autoname for plant_analysis
* created Agriculture Task
* minor stuff
* - deleted agriculture_task
- current state after the call
* [Agriculture] modified fertilizer doctype to have a link to Item
This was done so that the `Fertilizer` doctype could track the contents exclusive to the fertilizer, whereas the `Fertilizer Item` could be a seperate entity, so as to leverage the existing ERPNext doctypes
* Added fields to `Water Analysis` doctype
- Collection Datetime
- Laboratory Testing Datetime
- Results Datetime (default to Laboratory Testing Datetime)
* Edited the doctypes `Agrivulture Task`, `Pest` and `Soil Texture`
- Created `agriculture task` doctype
- added fields `Common Name`, `Scientific Name`, `Treatment` and `Treatment Options` to `Pest` doctype
- edited `Soil Texture` doctype to contain a soil texture ternary plot diagram made using SnapSVG. The code was put in public folder so as to be accessible by the entire agriculture module
* Recursively reflect child land unit feature changes on parents
* fixed feature repition bug
* added legeneds to ternary plot
* added stuff
* changes
* fix Task
* reverted the Task Doctype to have naming in the form TASK.#####
* fixed modifications made to TASK doctype
* [dirty commit] added auto create Task from Crop on creation of Crop Cycle
* Changed the Crop Cycle Doctype
- Deleted the "Crop Cycly Task" doctype and its link from "Crop Cycle"
- Creation of a new Project with the same name as the Crop Cycle on creation of a new Crop Cycle
- Creation of all the tasks imported from Agriculture Task doctype of the Crop in the Crop Cycle
* [Agriculture Module] Modifications
- Created childtable doctype "Pest Detected"
- Added childtable "Pest Detected" to Pest
- Modified "Agriculture Task" to include "Start Day" and "End Day" of task
- Modified the code in "Crop Cycle" to create a parent task with same name as Crop Cycle
* [Agriculture Module] fixed Pest doctype not saving issue
* [Agrcilture Module] Changes in Crop Cycle
- removed the creation of a master task on creation of a new crop cycle
- temporary fix to add the pest tasks from the pests added in crop cycle
* land_unit_tree.js fields modified to have field objects instead of just field names
* Revert "land_unit_tree.js modified"
* land_unit_tree.js fields modified to have field objects instead of just field names
* [Agriculture Domain] Converted Agriculture Module to a Domain
- Converted into a Domain field from Select to Link field in Company doctype, linked to Domain doctype
- Agriculture (alpha) is now a Domain
* land_unit area aggregation enabled
* land_unit.py checks feature diff for every ancestor and not just the parent
* Removed unnecessary print messages
* agriculture.py modified to include fixtures
* fixtures added to setup.py inside agriculture module
* [Agriculture Domain] UI tests added
- 'materials' table renamed to 'materials_required' in 'Crop'
- wrote UI test for Crop, Fertilizer, Crop Cycle, Pest, Water Analysis, Soil Texture
- moved creation of tasks from client side to server side in Crop Cycle
- Plant Analysis, Water Analysis, Soil Analysis, Soil Texture docs are now autonamed in the format PAnalysis.#####, WAnalysis.#####, SAnalysis.#####, STexture.##### respectively
- company_name changed in domains.py from 'Schrute Farms.' to 'Schrute Farms'
* [Agriculture Domain] Mostly written server side tests and moved client side code to server side
- moved client side code to server side for Crop, Water Analysis, Pest, Soil Texture,
- wrote server side tests for Crop, Crop Cycle, Fertilizer, Soil Texture, Pest
- NOTE: none of the server side codes were tested
* [Agriculture Domain] All server side tests working locally
* [Agriculture Domain] Testing
- added sample test for Land Unit, which needs to be modified to test multiple things
- modified tests to be independant of each other
* Land Units tests added and area aggregation code migrated to server side
* added land_unit server side tests and on_trash added to land_unit
* Changing field location for start date
* [Agriculture Domain] deleted unnecessary comments
* [Agriculture Domain] reverted changes
* [Agriculture Domain] Modified the code to replace Pest doctype with Land Unit doctype
- Deleted the Pest doctype and replaced it with the more generic Disease doctype
- Deleted the Detected Pest doctype and replaced it with Detected Disease doctype
* [Agriculture Domain] resolves #11654, resolves #11653
* [Agriculture] Added links to soil analysis, soil texture, plant analysis in crop cycle and land unit
- not working perfectly yet
- docs are fetched but not appended
* [Agricuture] Crop Cycle modifed to link with relevent analysis docs, not fully functional
* [Agriculture] added seperate stage for client side agriculture tests
* [Agriculture] minor modification to crop_cycle.js test
* [Agriculture] fixed tests
* upgrade chromedriver in .travis.yml from 2.32 to 2.33
* [Agriculture] added land unit ui test
* [Agriculture] added Agriculture server side test as a seperate stage in travis
* tesing travis.yml
* [Agriculture] Crop Cycle is able to fetch linked analysis docs
* Modified travis.yml for modular server side testing
* [minor fix][Agriculture] in soil_texture
- fixed multiple soil_texture ternary plot creation on refresh
- fixed error on soil composition change
* Update .travis.yml
* removed location field from linked doctypes
* minor fixes and cleanup of agri
* minor fix in agriculture and domain patches
* permissions added to agriculture
- Agriculture Manager and Agriculture User roles were added to all Agriculture doctypes
* [Agriculture]
- Created Agiculture Analysis Criteria and added sample records to it
- All the analysis doctypes now fetch their fields inside a child table, form Agriculture Analysis Criteria
- Also Fertilizer does the same
This was introduced so that, new parameters could be added on demand
* minor changes requested in Agriculture
* minor changes
* minor fix
* Update desktop.py
* Update .travis.yml
2017-12-06 13:06:27 +00:00
|
|
|
{ "label": __("Healthcare (beta)"), "value": "Healthcare" },
|
2017-12-13 13:20:39 +00:00
|
|
|
{ "label": __("Non Profit (beta)"), "value": "Non Profit" }
|
2017-07-03 12:53:57 +00:00
|
|
|
], reqd: 1
|
2016-07-21 10:31:59 +00:00
|
|
|
},
|
2017-07-03 12:53:57 +00:00
|
|
|
],
|
2017-09-04 05:44:04 +00:00
|
|
|
// help: __('Select the nature of your business.'),
|
2017-12-06 07:58:06 +00:00
|
|
|
validate: function () {
|
|
|
|
if (this.values.domains.length === 0) {
|
|
|
|
frappe.msgprint(__("Please select at least one domain."));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
frappe.setup.domains = this.values.domains;
|
|
|
|
return true;
|
2016-07-21 10:31:59 +00:00
|
|
|
},
|
2017-07-03 12:53:57 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
// Brand
|
|
|
|
name: 'brand',
|
|
|
|
icon: "fa fa-bookmark",
|
|
|
|
title: __("The Brand"),
|
2017-09-04 05:44:04 +00:00
|
|
|
// help: __('Upload your letter head and logo. (you can edit them later).'),
|
2017-07-03 12:53:57 +00:00
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
fieldtype: "Attach Image", fieldname: "attach_logo",
|
|
|
|
label: __("Attach Logo"),
|
|
|
|
description: __("100px by 100px"),
|
2017-07-26 12:49:41 +00:00
|
|
|
is_private: 0,
|
|
|
|
align: 'center'
|
2015-11-16 07:28:14 +00:00
|
|
|
},
|
2017-07-03 12:53:57 +00:00
|
|
|
{
|
|
|
|
fieldname: 'company_name',
|
2017-12-06 07:58:06 +00:00
|
|
|
label: frappe.setup.domains.includes('Education') ?
|
2017-07-03 12:53:57 +00:00
|
|
|
__('Institute Name') : __('Company Name'),
|
2017-07-26 12:49:41 +00:00
|
|
|
fieldtype: 'Data',
|
|
|
|
reqd: 1
|
2015-11-24 11:36:54 +00:00
|
|
|
},
|
2017-07-03 12:53:57 +00:00
|
|
|
{
|
|
|
|
fieldname: 'company_abbr',
|
2017-12-06 07:58:06 +00:00
|
|
|
label: frappe.setup.domains.includes('Education') ?
|
2017-07-03 12:53:57 +00:00
|
|
|
__('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("");
|
2017-07-11 07:06:57 +00:00
|
|
|
slide.get_field("company_abbr").set_value(abbr.slice(0, 5).toUpperCase());
|
2017-07-03 12:53:57 +00:00
|
|
|
}).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");
|
2017-07-11 07:06:57 +00:00
|
|
|
slide.get_field("company_abbr").set_value("");
|
2015-11-16 07:28:14 +00:00
|
|
|
}
|
2017-07-03 12:53:57 +00:00
|
|
|
});
|
2017-09-04 05:44:04 +00:00
|
|
|
},
|
|
|
|
validate: function() {
|
2017-10-02 06:08:03 +00:00
|
|
|
if ((this.values.company_name || "").toLowerCase() == "company") {
|
|
|
|
frappe.msgprint(__("Company Name cannot be Company"));
|
|
|
|
return false;
|
|
|
|
}
|
2017-09-04 05:44:04 +00:00
|
|
|
if (!this.values.company_abbr) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2017-07-03 12:53:57 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Organisation
|
|
|
|
name: 'organisation',
|
|
|
|
title: __("Your Organization"),
|
|
|
|
icon: "fa fa-building",
|
2017-12-06 07:58:06 +00:00
|
|
|
// help: frappe.setup.domains.includes('Education') ?
|
2017-09-04 05:44:04 +00:00
|
|
|
// __('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.')),
|
2017-07-03 12:53:57 +00:00
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
fieldname: 'company_tagline',
|
|
|
|
label: __('What does it do?'),
|
|
|
|
fieldtype: 'Data',
|
2017-12-06 07:58:06 +00:00
|
|
|
placeholder: frappe.setup.domains.includes('Education') ?
|
2017-07-03 12:53:57 +00:00
|
|
|
__('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-17 06:36:25 +00:00
|
|
|
{ fieldtype: "Section Break", label: __('Financial Year') },
|
2017-07-03 12:53:57 +00:00
|
|
|
{ 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
|
|
|
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-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
|
|
|
});
|
|
|
|
}
|
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-12-12 08:49:35 +00:00
|
|
|
"Afghanistan": ["12-21", "12-20"],
|
2017-07-05 11:56:34 +00:00
|
|
|
"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
|
|
|
};
|