To add child nodes, explore tree and click on the node under which you want to add more nodes.
-
Accounting Entries can be made against leaf nodes, called Ledgers. Entries against Groups are not allowed.
-
Please do NOT create Account (Ledgers) for Customers and Suppliers. They are created directly from the Customer / Supplier masters.
-
To create a Bank Account: Go to the appropriate group (usually Application of Funds > Current Assets > Bank Accounts) and create a new Account Ledger (by clicking on Add Child) of type "Bank or Cash"
-
To create a Tax Account: Go to the appropriate group (usually Source of Funds > Current Liabilities > Taxes and Duties) and create a new Account Ledger (by clicking on Add Child) of type "Tax" and do mention the Tax rate.
-
-
Please setup your chart of accounts before you start Accounting Entries
-
-
-
\ No newline at end of file
diff --git a/accounts/page/accounts_browser/accounts_browser.js b/accounts/page/accounts_browser/accounts_browser.js
index 2e8cc820a6..534201afdb 100644
--- a/accounts/page/accounts_browser/accounts_browser.js
+++ b/accounts/page/accounts_browser/accounts_browser.js
@@ -21,9 +21,37 @@
// see ledger
pscript['onload_Accounts Browser'] = function(wrapper){
- wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
- wrapper.appframe.add_home_breadcrumb()
- wrapper.appframe.add_module_breadcrumb("Accounts")
+ wn.ui.make_app_page({
+ parent: wrapper,
+ single_column: true
+ })
+
+ wrapper.appframe.add_module_icon("Accounts");
+
+ var main = $(wrapper).find(".layout-main"),
+ chart_area = $("
To add child nodes, explore tree and click on the node under which you \
+ want to add more nodes.\
+
Accounting Entries can be made against leaf nodes, called Ledgers.\
+ Entries against Groups are not allowed.\
+
Please do NOT create Account (Ledgers) for Customers and Suppliers. \
+ They are created directly from the Customer / Supplier masters.\
+
To create a Bank Account: Go to the appropriate group \
+ (usually Application of Funds > Current Assets > Bank Accounts)\
+ and create a new Account Ledger (by clicking on Add Child) of \
+ type "Bank or Cash"\
+
To create a Tax Account: Go to the appropriate group \
+ (usually Source of Funds > Current Liabilities > Taxes and Duties) \
+ and create a new Account Ledger (by clicking on Add Child) of type\
+ "Tax" and do mention the Tax rate.\
+
\
+
Please setup your chart of accounts before you start Accounting Entries
diff --git a/accounts/page/general_ledger/general_ledger.js b/accounts/page/general_ledger/general_ledger.js
index a462b70e93..6a7d6045ea 100644
--- a/accounts/page/general_ledger/general_ledger.js
+++ b/accounts/page/general_ledger/general_ledger.js
@@ -24,7 +24,7 @@ wn.pages['general-ledger'].onload = function(wrapper) {
erpnext.general_ledger = new erpnext.GeneralLedger(wrapper);
wrapper.appframe.add_home_breadcrumb()
- wrapper.appframe.add_module_breadcrumb("Accounts")
+ wrapper.appframe.add_module_icon("Accounts")
wrapper.appframe.add_breadcrumb("icon-bar-chart")
}
diff --git a/accounts/page/trial_balance/trial_balance.js b/accounts/page/trial_balance/trial_balance.js
index c64075f6b9..9c4c50ad20 100644
--- a/accounts/page/trial_balance/trial_balance.js
+++ b/accounts/page/trial_balance/trial_balance.js
@@ -59,6 +59,6 @@ wn.pages['trial-balance'].onload = function(wrapper) {
erpnext.trial_balance = new TrialBalance(wrapper, 'Trial Balance');
wrapper.appframe.add_home_breadcrumb()
- wrapper.appframe.add_module_breadcrumb("Accounts")
+ wrapper.appframe.add_module_icon("Accounts")
wrapper.appframe.add_breadcrumb("icon-bar-chart")
}
\ No newline at end of file
diff --git a/accounts/report/gross_profit/gross_profit.py b/accounts/report/gross_profit/gross_profit.py
index 9ccd320e6d..798c718ace 100644
--- a/accounts/report/gross_profit/gross_profit.py
+++ b/accounts/report/gross_profit/gross_profit.py
@@ -92,7 +92,7 @@ def get_source_data(filters):
timestamp(si.posting_date, si.posting_time) as posting_datetime
from `tabSales Invoice` si, `tabSales Invoice Item` item
where item.parent = si.name and si.docstatus = 1 %s
- and si.is_pos = 1 and si.update_stock = 1
+ and si.update_stock = 1
order by si.posting_date desc, si.posting_time desc""" % (conditions,), filters, as_dict=1)
source = delivery_note_items + sales_invoice_items
diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js
index dacee80e55..1bb64e592c 100644
--- a/buying/doctype/purchase_common/purchase_common.js
+++ b/buying/doctype/purchase_common/purchase_common.js
@@ -20,131 +20,323 @@
// cur_frm.cscript.fname - Details fieldname
wn.provide("erpnext.buying");
+wn.require("app/js/transaction.js");
-erpnext.buying.BuyingController = wn.ui.form.Controller.extend({
+erpnext.buying.BuyingController = erpnext.TransactionController.extend({
setup: function() {
var me = this;
if(this.frm.fields_dict.price_list_name) {
- this.frm.fields_dict.price_list_name.get_query = function() {
+ this.frm.set_query("price_list_name", function() {
return repl("select distinct price_list_name from `tabItem Price` \
where buying = 1 and price_list_name like \"%s%%\"");
- };
- }
-
- if(this.frm.fields_dict.price_list_currency) {
- this.frm.fields_dict.price_list_currency.get_query = function() {
+ });
+
+ this.frm.set_query("price_list_currency", function() {
return repl("select distinct ref_currency from `tabItem Price` \
where price_list_name=\"%(price_list_name)s\" and buying = 1 \
and ref_currency like \"%s%%\"",
{price_list_name: me.frm.doc.price_list_name});
- };
+ });
}
+
+ if(this.frm.fields_dict.supplier) {
+ this.frm.set_query("supplier", erpnext.utils.supplier_query);
+ }
+
+ this.frm.set_query("item_code", this.frm.cscript.fname, function() {
+ if(me.frm.doc.is_subcontracted == "Yes") {
+ return erpnext.queries.item({'ifnull(tabItem.is_sub_contracted_item, "No")': "Yes"});
+ } else {
+ return erpnext.queries.item({'ifnull(tabItem.is_purchase_item, "No")': "Yes"});
+ }
+ });
},
- refresh: function() {
- this.frm.clear_custom_buttons();
- erpnext.hide_naming_series();
-
- if(this.frm.fields_dict.supplier)
- this.frm.toggle_display("contact_section", this.frm.doc.supplier);
-
- if(this.frm.fields_dict.currency)
- this.set_dynamic_labels();
- },
-
- price_list_name: function(callback_fn) {
- var me = this;
-
- if(this.frm.doc.price_list_name) {
- if(!this.frm.doc.price_list_currency) {
- // set price list currency
+ supplier: function() {
+ if(this.frm.doc.supplier || this.frm.doc.credit_to) {
+ if(!this.frm.doc.company) {
+ this.frm.set_value("supplier", null);
+ msgprint(wn._("Please specify Company"));
+ } else {
+ var me = this;
+ var price_list_name = this.frm.doc.price_list_name;
+
this.frm.call({
- method: "setup.utils.get_price_list_currency",
- args: {args: {
- price_list_name: this.frm.doc.price_list_name,
- use_for: "buying"
- }},
+ doc: this.frm.doc,
+ method: "set_supplier_defaults",
+ freeze: true,
callback: function(r) {
if(!r.exc) {
- me.price_list_currency();
- if (typeof callback_fn === "function")
- callback_fn(me.frm.doc, me.frm.doc.doctype, me.frm.doc.name);
+ me.frm.refresh_fields();
+ if(me.frm.doc.price_list_name !== price_list_name) me.price_list_name();
}
}
});
- } else {
- me.price_list_currency();
- if (typeof callback_fn === "function")
- callback_fn(me.frm.doc, me.frm.doc.doctype, me.frm.doc.name);
}
- }
+ }
},
item_code: function(doc, cdt, cdn) {
var me = this;
- var item = locals[cdt][cdn];
-
+ var item = wn.model.get_doc(cdt, cdn);
if(item.item_code) {
+ if(!this.validate_company_and_party("supplier")) {
+ item.item_code = null;
+ refresh_field("item_code", item.name, item.parentfield);
+ } else {
+ this.frm.call({
+ method: "buying.utils.get_item_details",
+ child: item,
+ args: {
+ args: {
+ item_code: item.item_code,
+ warehouse: item.warehouse,
+ doctype: me.frm.doc.doctype,
+ docname: me.frm.doc.name,
+ supplier: me.frm.doc.supplier,
+ conversion_rate: me.frm.doc.conversion_rate,
+ price_list_name: me.frm.doc.price_list_name,
+ price_list_currency: me.frm.doc.price_list_currency,
+ plc_conversion_rate: me.frm.doc.plc_conversion_rate,
+ is_subcontracted: me.frm.doc.is_subcontracted,
+ company: me.frm.doc.company,
+ currency: me.frm.doc.currency
+ }
+ },
+ callback: function(r) {
+ if(!r.exc) {
+ me.import_ref_rate(me.frm.doc, cdt, cdn);
+ }
+ }
+ });
+ }
+ }
+ },
+
+ price_list_name: function() {
+ this._super("buying");
+ },
+
+ import_ref_rate: function(doc, cdt, cdn) {
+ var item = wn.model.get_doc(cdt, cdn);
+ wn.model.round_floats_in(item, ["import_ref_rate", "discount_rate"]);
+
+ item.import_rate = flt(item.import_ref_rate * (1 - item.discount_rate / 100.0),
+ precision("import_rate", item));
+
+ this.calculate_taxes_and_totals();
+ },
+
+ discount_rate: function(doc, cdt, cdn) {
+ this.import_ref_rate(doc, cdt, cdn);
+ },
+
+ import_rate: function(doc, cdt, cdn) {
+ var item = wn.model.get_doc(cdt, cdn);
+ wn.model.round_floats_in(item, ["import_rate", "discount_rate"]);
+
+ if(item.import_ref_rate) {
+ item.discount_rate = flt((1 - item.import_rate / item.import_ref_rate) * 100.0,
+ precision("discount_rate", item));
+ } else {
+ item.discount_rate = 0.0;
+ }
+
+ this.calculate_taxes_and_totals();
+ },
+
+ uom: function(doc, cdt, cdn) {
+ var me = this;
+ var item = wn.model.get_doc(cdt, cdn);
+ if(item.item_code && item.uom) {
this.frm.call({
- method: "buying.utils.get_item_details",
+ method: "buying.utils.get_conversion_factor",
child: item,
args: {
- args: {
- doctype: me.frm.doc.doctype,
- docname: me.frm.doc.name,
- item_code: item.item_code,
- warehouse: item.warehouse,
- supplier: me.frm.doc.supplier,
- conversion_rate: me.frm.doc.conversion_rate,
- price_list_name: me.frm.doc.price_list_name,
- price_list_currency: me.frm.doc.price_list_currency,
- plc_conversion_rate: me.frm.doc.plc_conversion_rate
- }
+ item_code: item.item_code,
+ uom: item.uom
},
+ callback: function(r) {
+ if(!r.exc) {
+ me.conversion_factor(me.frm.doc, cdt, cdn);
+ }
+ }
});
}
},
- update_item_details: function(doc, dt, dn, callback) {
- if(!this.frm.doc.__islocal) return;
-
- var me = this;
- var children = getchildren(this.tname, this.frm.doc.name, this.fname);
- if(children && children.length) {
- this.frm.call({
- doc: me.frm.doc,
- method: "update_item_details",
- callback: function(r) {
- if(!r.exc) {
- refresh_field(me.fname);
- me.load_defaults(me.frm.doc, dt, dn, callback);
- }
- }
- })
- } else {
- this.load_taxes(doc, dt, dn, callback);
+ qty: function(doc, cdt, cdn) {
+ this._super(doc, cdt, cdn);
+ this.conversion_factor(doc, cdt, cdn);
+ },
+
+ conversion_factor: function(doc, cdt, cdn) {
+ if(wn.meta.get_docfield(cdt, "stock_qty", cdn)) {
+ var item = wn.model.get_doc(cdt, cdn);
+ wn.model.round_floats_in(item, ["qty", "conversion_factor"]);
+ item.stock_qty = flt(item.qty * item.conversion_factor, precision("stock_qty", item));
+ refresh_field("stock_qty", item.name, item.parentfield);
}
},
- currency: function() {
- this.set_dynamic_labels();
+ warehouse: function(doc, cdt, cdn) {
+ var item = wn.model.get_doc(cdt, cdn);
+ if(item.item_code && item.warehouse) {
+ this.frm.call({
+ method: "buying.utils.get_conversion_factor",
+ child: item,
+ args: {
+ item_code: item.item_code,
+ warehouse: item.warehouse
+ }
+ });
+ }
},
- company: function() {
- this.set_dynamic_labels();
+ project_name: function(doc, cdt, cdn) {
+ var item = wn.model.get_doc(cdt, cdn);
+ if(item.project_name) {
+ $.each(wn.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, {parentfield: this.fname}),
+ function(i, other_item) {
+ if(!other_item.project_name) {
+ other_item.project_name = item.project_name;
+ refresh_field("project_name", other_item.name, other_item.parentfield);
+ }
+ });
+ }
},
- price_list_currency: function() {
- this.frm.toggle_reqd("plc_conversion_rate",
- !!(this.frm.doc.price_list_name && this.frm.doc.price_list_currency));
+ category: function(doc, cdt, cdn) {
+ // should be the category field of tax table
+ if(cdt != doc.doctype) {
+ this.calculate_taxes_and_totals();
+ }
+ },
+
+ calculate_taxes_and_totals: function() {
+ this._super();
+ this.calculate_total_advance("Purchase Invoice", "advance_allocation_details");
+ this.frm.refresh_fields();
+ },
+
+ calculate_item_values: function() {
+ var me = this;
- this.set_dynamic_labels();
-
- if(this.frm.doc.price_list_currency === this.get_company_currency())
- this.frm.set_value("plc_conversion_rate", 1.0);
- else if(this.frm.doc.price_list_currency === this.frm.doc.currency)
- this.frm.set_value("plc_conversion_rate", this.frm.doc.conversion_rate || 1.0);
+ if(this.frm.doc.doctype != "Purchase Invoice") {
+ // hack!
+ wn.meta.docfield_copy[this.tname][this.frm.doc.name]["rate"] = $.extend({},
+ wn.meta.docfield_copy[this.tname][this.frm.doc.name]["purchase_rate"]);
+ }
+
+ $.each(this.frm.item_doclist, function(i, item) {
+ if(me.frm.doc.doctype != "Purchase Invoice") {
+ item.rate = item.purchase_rate;
+ }
+
+ wn.model.round_floats_in(item);
+ item.import_amount = flt(item.import_rate * item.qty, precision("import_amount", item));
+ item.item_tax_amount = 0.0;
+
+ me._set_in_company_currency(item, "import_ref_rate", "purchase_ref_rate");
+ me._set_in_company_currency(item, "import_rate", "rate");
+ me._set_in_company_currency(item, "import_amount", "amount");
+ });
+
+ },
+
+ calculate_net_total: function() {
+ var me = this;
+
+ this.frm.doc.net_total = this.frm.doc.net_total_import = 0.0;
+ $.each(this.frm.item_doclist, function(i, item) {
+ me.frm.doc.net_total += item.amount;
+ me.frm.doc.net_total_import += item.import_amount;
+ });
+
+ wn.model.round_floats_in(this.frm.doc, ["net_total", "net_total_import"]);
+ },
+
+ calculate_totals: function() {
+ var tax_count = this.frm.tax_doclist.length;
+ this.frm.doc.grand_total = flt(
+ tax_count ? this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total,
+ precision("grand_total"));
+ this.frm.doc.grand_total_import = flt(this.frm.doc.grand_total / this.frm.doc.conversion_rate,
+ precision("grand_total_import"));
+
+ this.frm.doc.total_tax = flt(this.frm.doc.grand_total - this.frm.doc.net_total,
+ precision("total_tax"));
+
+ // rounded totals
+ if(wn.meta.get_docfield(this.frm.doc.doctype, "rounded_total", this.frm.doc.name)) {
+ this.frm.doc.rounded_total = Math.round(this.frm.doc.grand_total);
+ }
+
+ if(wn.meta.get_docfield(this.frm.doc.doctype, "rounded_total_import", this.frm.doc.name)) {
+ this.frm.doc.rounded_total_import = Math.round(this.frm.doc.grand_total_import);
+ }
+
+ // other charges added/deducted
+ if(tax_count) {
+ this.frm.doc.other_charges_added = wn.utils.sum($.map(this.frm.tax_doclist,
+ function(tax) { return tax.add_deduct_tax == "Add" ? tax.tax_amount : 0.0; }));
+
+ this.frm.doc.other_charges_deducted = wn.utils.sum($.map(this.frm.tax_doclist,
+ function(tax) { return tax.add_deduct_tax == "Deduct" ? tax.tax_amount : 0.0; }));
+
+ wn.model.round_floats_in(this.frm.doc, ["other_charges_added", "other_charges_deducted"]);
+
+ this.frm.doc.other_charges_added_import = flt(this.frm.doc.other_charges_added / this.frm.doc.conversion_rate,
+ precision("other_charges_added_import"));
+ this.frm.doc.other_charges_deducted_import = flt(this.frm.doc.other_charges_deducted / this.frm.doc.conversion_rate,
+ precision("other_charges_deducted_import"));
+ }
+ },
+
+ _cleanup: function() {
+ this._super();
+ this.frm.doc.in_words = this.frm.doc.in_words_import = "";
+
+ // except in purchase invoice, rate field is purchase_rate
+ // reset fieldname of rate
+ if(this.frm.doc.doctype != "Purchase Invoice") {
+ // clear hack
+ delete wn.meta.docfield_copy[this.tname][this.frm.doc.name]["rate"];
+
+ $.each(this.frm.item_doclist, function(i, item) {
+ item.purchase_rate = item.rate;
+ delete item["rate"];
+ });
+ }
+ },
+
+ calculate_outstanding_amount: function() {
+ if(this.frm.doc.doctype == "Purchase Invoice" && this.frm.doc.docstatus < 2) {
+ wn.model.round_floats_in(this.frm.doc, ["grand_total", "total_advance", "write_off_amount"]);
+ this.frm.doc.total_amount_to_pay = flt(this.frm.doc.grand_total - this.frm.doc.write_off_amount,
+ precision("total_amount_to_pay"));
+ this.frm.doc.outstanding_amount = flt(this.frm.doc.total_amount_to_pay - this.frm.doc.total_advance,
+ precision("outstanding_amount"));
+ }
+ },
+
+ set_item_tax_amount: function(item, tax, current_tax_amount) {
+ // item_tax_amount is the total tax amount applied on that item
+ // stored for valuation
+ //
+ // TODO: rename item_tax_amount to valuation_tax_amount
+ if(["Valuation", "Valuation and Total"].indexOf(tax.category) != -1) {
+ // accumulate only if tax is for Valuation / Valuation and Total
+ item.item_tax_amount += flt(current_tax_amount, precision("item_tax_amount", item));
+ }
+ },
+
+ show_item_wise_taxes: function() {
+ if(this.frm.fields_dict.tax_calculation) {
+ $(this.get_item_wise_taxes_html())
+ .appendTo($(this.frm.fields_dict.tax_calculation.wrapper).empty());
+ }
},
set_dynamic_labels: function(doc, dt, dn) {
@@ -162,11 +354,12 @@ erpnext.buying.BuyingController = wn.ui.form.Controller.extend({
$.each(fields_list, function(i, fname) {
var docfield = wn.meta.get_docfield(me.frm.doc.doctype, fname);
if(docfield) {
- var label = wn._((docfield.label || "")).replace(/\([^\)]*\)/g, "");
+ var label = wn._(docfield.label || "").replace(/\([^\)]*\)/g, "");
field_label_map[fname] = label.trim() + " (" + currency + ")";
}
});
- }
+ };
+
setup_field_label_map(["net_total", "total_tax", "grand_total", "in_words",
"other_charges_added", "other_charges_deducted",
@@ -188,6 +381,9 @@ erpnext.buying.BuyingController = wn.ui.form.Controller.extend({
this.frm.toggle_display(["conversion_rate", "net_total", "grand_total",
"in_words", "other_charges_added", "other_charges_deducted"],
this.frm.doc.currency != company_currency);
+
+ this.frm.toggle_display(["plc_conversion_rate"],
+ this.frm.price_list_currency != company_currency);
// set labels
$.each(field_label_map, function(fname, label) {
@@ -204,11 +400,12 @@ erpnext.buying.BuyingController = wn.ui.form.Controller.extend({
$.each(fields_list, function(i, fname) {
var docfield = wn.meta.get_docfield(grid_doctype, fname);
if(docfield) {
+ var label = wn._(docfield.label || "").replace(/\([^\)]*\)/g, "");
field_label_map[grid_doctype + "-" + fname] =
- docfield.label + " (" + currency + ")";
+ label.trim() + " (" + currency + ")";
}
});
- }
+ };
setup_field_label_map(["purchase_rate", "purchase_ref_rate", "amount", "rate"],
company_currency, this.fname);
@@ -216,7 +413,9 @@ erpnext.buying.BuyingController = wn.ui.form.Controller.extend({
setup_field_label_map(["import_rate", "import_ref_rate", "import_amount"],
this.frm.doc.currency, this.fname);
- setup_field_label_map(["tax_amount", "total"], company_currency, this.other_fname);
+ if(this.frm.fields_dict[this.other_fname]) {
+ setup_field_label_map(["tax_amount", "total"], company_currency, this.other_fname);
+ }
if(this.frm.fields_dict["advance_allocation_details"]) {
setup_field_label_map(["advance_amount", "allocated_amount"], company_currency,
@@ -236,10 +435,6 @@ erpnext.buying.BuyingController = wn.ui.form.Controller.extend({
$.each(field_label_map, function(fname, label) {
$wrapper.find('[data-grid-fieldname="'+fname+'"]').text(label);
});
- },
-
- get_company_currency: function() {
- return erpnext.get_currency(this.frm.doc.company);
}
});
@@ -254,547 +449,4 @@ $.extend(cur_frm.cscript, prev_cscript);
var tname = cur_frm.cscript.tname;
-var fname = cur_frm.cscript.fname;
-
-cur_frm.cscript.get_default_schedule_date = function(doc) {
- var ch = getchildren( tname, doc.name, fname);
- if (flt(ch.length) > 0){
- $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_schedule_date', '', function(r, rt) { refresh_field(fname); });
- }
-}
-
-cur_frm.cscript.load_taxes = function(doc, cdt, cdn, callback) {
- // run if this is not executed from dt_map...
- doc = locals[doc.doctype][doc.name];
- if(doc.supplier || getchildren('Purchase Taxes and Charges', doc.name, 'purchase_tax_details', doc.doctype).length) {
- if(callback) {
- callback(doc, cdt, cdn);
- }
- } else {
- $c_obj(make_doclist(doc.doctype, doc.name),'load_default_taxes','',function(r,rt){
- refresh_field('purchase_tax_details');
- if(callback) callback(doc, cdt, cdn);
- });
- }
-}
-
-
-
-// Gets called after existing item details are update to fill in
-// remaining default values
-cur_frm.cscript.load_defaults = function(doc, dt, dn, callback) {
- if(!cur_frm.doc.__islocal) { return; }
-
- doc = locals[doc.doctype][doc.name];
- var fields_to_refresh = wn.model.set_default_values(doc);
- if(fields_to_refresh) { refresh_many(fields_to_refresh); }
-
- fields_to_refresh = null;
- var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
- if(!children) { return; }
- for(var i=0; i Check if qty , uom, conversion_factor
- if (d.qty && d.uom && d.conversion_factor){
- // Step 2:=> Set stock_qty = qty * conversion_factor
- d.stock_qty = flt(flt(d.qty) * flt(d.conversion_factor));
- // Step 3:=> Refer stock_qty field a that particular row.
- refresh_field('stock_qty' , d.name,fname);
- }
-}
-
-//==================== UOM ======================================================================
-cur_frm.cscript.uom = function(doc, cdt, cdn, args) {
- if(!args) args = {};
-
- // args passed can contain conversion_factor
- var d = locals[cdt][cdn];
- $.extend(args, {
- item_code: d.item_code,
- uom: d.uom,
- stock_qty: flt(d.stock_qty),
- });
-
- if(d.item_code && d.uom) {
- cur_frm.call({
- method: "buying.doctype.purchase_common.purchase_common.get_uom_details",
- args: { args: args },
- child: d,
- callback: function(r) {
- cur_frm.cscript.calc_amount(doc, 2);
- }
- });
- }
-}
-
-
-//==================== Conversion factor =========================================================
-cur_frm.cscript.conversion_factor = function(doc, cdt, cdn) {
- var item = locals[cdt][cdn];
-
- cur_frm.cscript.uom(doc, cdt, cdn, { conversion_factor: item.conversion_factor });
-}
-
-//==================== stock qty ======================================================================
-cur_frm.cscript.stock_qty = function(doc, cdt, cdn) {
- var d = locals[cdt][cdn];
- if(d.uom && d.qty){
- d.conversion_factor = flt(d.stock_qty)/flt(d.qty);
- refresh_field('conversion_factor', d.name, fname);
- }
-}
-
-//==================== Warehouse ================================================================
-cur_frm.cscript.warehouse = function(doc, cdt, cdn) {
- var d = locals[cdt][cdn];
- if (d.item_code && d.warehouse) {
- str_arg = "{'item_code':'" + (d.item_code?d.item_code:'') + "', 'warehouse':'" + (d.warehouse?d.warehouse:'') + "'}"
- get_server_fields('get_bin_details', str_arg, fname, doc, cdt, cdn, 1);
- }
-}
-
-//=================== Quantity ===================================================================
-cur_frm.cscript.qty = function(doc, cdt, cdn) {
- var d = locals[cdt][cdn];
- // Step 1: => Update Stock Qty
- cur_frm.cscript.update_stock_qty(doc,cdt,cdn);
- // Step 2: => Calculate Amount
- cur_frm.cscript.calc_amount(doc, 2);
-}
-
-
-//=================== Purchase Rate ==============================================================
-cur_frm.cscript.purchase_rate = function(doc, cdt, cdn) {
- cur_frm.cscript.calc_amount(doc, 2);
-}
-
-//==================== Import Rate ================================================================
-cur_frm.cscript.import_rate = function(doc, cdt, cdn) {
- cur_frm.cscript.calc_amount(doc, 1);
-}
-
-//==================== Discount Rate ================================================================
-cur_frm.cscript.discount_rate = function(doc, cdt, cdn) {
- cur_frm.cscript.calc_amount(doc, 4);
-}
-//==================== Purchase Ref Rate ================================================================
-cur_frm.cscript.purchase_ref_rate = function(doc, cdt, cdn) {
- cur_frm.cscript.calc_amount(doc, 4);
-}
-//==================== Import Ref Rate ================================================================
-cur_frm.cscript.import_ref_rate = function(doc, cdt, cdn) {
- cur_frm.cscript.calc_amount(doc, 5);
-}
-
-//==================== Validate ====================================================================
-cur_frm.cscript.validate = function(doc, cdt, cdn) {
- cur_frm.cscript.calc_amount(doc, 1);
-
- // calculate advances if pv
- if(doc.docstatus == 0 && doc.doctype == 'Purchase Invoice') calc_total_advance(doc, cdt, cdn);
-}
-
-// **************** RE-CALCULATE VALUES ***************************
-
-cur_frm.cscript.recalculate_values = function(doc, cdt, cdn) {
- cur_frm.cscript.calculate_tax(doc,cdt,cdn);
-}
-
-cur_frm.cscript.calculate_tax = function(doc, cdt, cdn) {
- var other_fname = cur_frm.cscript.other_fname;
-
- var cl = getchildren('Purchase Taxes and Charges', doc.name, other_fname, doc.doctype);
- for(var i = 0; i 0) {
- var cl = getchildren('Purchase Taxes and Charges', doc.name, other_fname,doc.doctype);
- for(var i = 0; iCalculation Details for Taxes, Charges and Landed Cost:';
- var cl = getchildren(tname, doc.name, fname);
- var tax = getchildren('Purchase Taxes and Charges', doc.name, other_fname,doc.doctype);
- // make display table
- // ------------------
- var otc = make_table(cur_frm.fields_dict['tax_calculation'].disp_area, cl.length + 1, tax.length + 1, '90%',[],{border:'1px solid #AAA',padding:'2px'});
- $y(otc,{marginTop:'8px'});
-
- var tax_desc = {}; var tax_desc_rates = []; var net_total = 0;
-
-
- for(var i=0;i2) alert("You cannot enter more than 2 nos. for division");
- var id1 = cint(row[0].replace(/^\s+|\s+$/g,""));
- var id2 = cint(row[1].replace(/^\s+|\s+$/g,""));
- tax_amount = flt(tax[id1-1].total_amount) / flt(tax[id2-1].total_amount);
- }
- return tax_amount
- }
- else if(tax[t].charge_type == 'On Previous Row Total') {
- var row = cint(tax[t].row_id);
- if(tax[row-1].add_deduct_tax == 'Add'){
- return tax_amount = flt(rate) * (flt(tax[row-1].total_tax_amount)+flt(tax[row-1].total_amount)) / 100;
- }
- else if(tax[row-1].add_deduct_tax == 'Deduct'){
- return tax_amount = flt(rate) * (flt(tax[row-1].total_tax_amount)-flt(tax[row-1].total_amount)) / 100;
- }
- }
-}
-
-// ******* Calculation of total amounts of document (item amount + other charges)****************
-cur_frm.cscript.calc_doc_values = function(doc, tname, fname, other_fname) {
- doc = locals[doc.doctype][doc.name];
- var net_total = 0; var total_tax = 0; var other_charges_added = 0;
- var other_charges_deducted = 0;
- var cl = getchildren(tname, doc.name, fname);
- for(var i = 0; i now())" % cstr(d.item_code) , as_dict = 1)
- ltd = item and cint(item[0]['lead_time_days']) or 0
- if ltd and obj.doc.transaction_date:
- if d.fields.has_key('lead_time_date') or obj.doc.doctype == 'Material Request':
- d.lead_time_date = cstr(add_days( obj.doc.transaction_date, cint(ltd)))
- if not d.fields.has_key('prevdoc_docname') or (d.fields.has_key('prevdoc_docname') and not d.prevdoc_docname):
- d.schedule_date = cstr( add_days( obj.doc.transaction_date, cint(ltd)))
-
# Client Trigger functions
#------------------------------------------------------------------------------------------------
@@ -447,28 +436,4 @@ class DocType(BuyingController):
for d in getlist(obj.doclist, obj.fname):
if d.prevdoc_doctype and d.prevdoc_docname:
dt = sql("select transaction_date from `tab%s` where name = '%s'" % (d.prevdoc_doctype, d.prevdoc_docname))
- d.prevdoc_date = dt and dt[0][0].strftime('%Y-%m-%d') or ''
-
-@webnotes.whitelist()
-def get_uom_details(args=None):
- """fetches details on change of UOM"""
- if not args:
- return {}
-
- if isinstance(args, basestring):
- import json
- args = json.loads(args)
-
- uom = webnotes.conn.sql("""select conversion_factor
- from `tabUOM Conversion Detail` where parent = %s and uom = %s""",
- (args['item_code'], args['uom']), as_dict=1)
-
- if not uom: return {}
-
- conversion_factor = args.get("conversion_factor") or \
- flt(uom[0]["conversion_factor"])
-
- return {
- "conversion_factor": conversion_factor,
- "qty": flt(args["stock_qty"]) / conversion_factor,
- }
+ d.prevdoc_date = dt and dt[0][0].strftime('%Y-%m-%d') or ''
\ No newline at end of file
diff --git a/buying/doctype/purchase_order/purchase_order.js b/buying/doctype/purchase_order/purchase_order.js
index afe4741c86..64aa9136a4 100644
--- a/buying/doctype/purchase_order/purchase_order.js
+++ b/buying/doctype/purchase_order/purchase_order.js
@@ -21,8 +21,8 @@ cur_frm.cscript.fname = "po_details";
cur_frm.cscript.other_fname = "purchase_tax_details";
wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
-wn.require('app/buying/doctype/purchase_common/purchase_common.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
+wn.require('app/buying/doctype/purchase_common/purchase_common.js');
erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({
refresh: function(doc, cdt, cdn) {
@@ -39,54 +39,10 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
cur_frm.add_custom_button('Unstop Purchase Order', cur_frm.cscript['Unstop Purchase Order']);
},
-
- onload_post_render: function(doc, dt, dn) {
- var me = this;
- var callback1 = function(doc, dt, dn) {
- var callback2 = function(doc, dt, dn) {
- if(doc.__islocal) cur_frm.cscript.get_default_schedule_date(doc);
- }
- me.update_item_details(doc, dt, dn, callback2);
- }
-
- // TODO: improve this
- if(this.frm.doc.__islocal) {
- if (this.frm.fields_dict.price_list_name && this.frm.doc.price_list_name) {
- this.price_list_name(callback1);
- } else {
- callback1(doc, dt, dn);
- }
- }
- }
-
});
-var new_cscript = new erpnext.buying.PurchaseOrderController({frm: cur_frm});
-
// for backward compatibility: combine new and previous states
-$.extend(cur_frm.cscript, new_cscript);
-
-cur_frm.cscript.onload = function(doc, cdt, cdn) {
- // set missing values in parent doc
- set_missing_values(doc, {
- fiscal_year: sys_defaults.fiscal_year,
- conversion_rate: 1,
- currency: sys_defaults.currency,
- status: "Draft",
- transaction_date: get_today(),
- is_subcontracted: "No"
- });
-}
-
-cur_frm.cscript.supplier = function(doc,dt,dn) {
- if (doc.supplier) {
- get_server_fields('get_default_supplier_address',
- JSON.stringify({ supplier: doc.supplier }),'', doc, dt, dn, 1, function() {
- cur_frm.refresh();
- });
- $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true);
- }
-}
+$.extend(cur_frm.cscript, new erpnext.buying.PurchaseOrderController({frm: cur_frm}));
cur_frm.cscript.supplier_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
if(doc.supplier) get_server_fields('get_supplier_address', JSON.stringify({supplier: doc.supplier, address: doc.supplier_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
@@ -111,10 +67,6 @@ cur_frm.fields_dict.contact_person.on_new = function(dn) {
locals['Contact'][dn].supplier_name = locals[cur_frm.doctype][cur_frm.docname].supplier_name;
}
-cur_frm.cscript.transaction_date = function(doc,cdt,cdn){
- if(doc.__islocal){ cur_frm.cscript.get_default_schedule_date(doc); }
-}
-
cur_frm.fields_dict['po_details'].grid.get_field('project_name').get_query = function(doc, cdt, cdn) {
return 'SELECT `tabProject`.name FROM `tabProject` \
WHERE `tabProject`.status not in ("Completed", "Cancelled") \
diff --git a/buying/doctype/purchase_order/purchase_order.py b/buying/doctype/purchase_order/purchase_order.py
index 218d4bfeee..bf59389213 100644
--- a/buying/doctype/purchase_order/purchase_order.py
+++ b/buying/doctype/purchase_order/purchase_order.py
@@ -65,10 +65,6 @@ class DocType(BuyingController):
self.validate_for_subcontracting()
self.update_raw_materials_supplied("po_raw_material_details")
-
- def get_default_schedule_date(self):
- get_obj(dt = 'Purchase Common').get_default_schedule_date(self)
-
def validate_fiscal_year(self):
get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'PO Date')
@@ -101,7 +97,6 @@ class DocType(BuyingController):
"""[['Supplier Quotation', 'Purchase Order'],
['Supplier Quotation Item', 'Purchase Order Item'],
['Purchase Taxes and Charges', 'Purchase Taxes and Charges']]""")
- self.get_default_schedule_date()
for d in getlist(self.doclist, 'po_details'):
if d.prevdoc_detail_docname and not d.schedule_date:
d.schedule_date = webnotes.conn.get_value("Material Request Item",
diff --git a/buying/doctype/purchase_order/purchase_order.txt b/buying/doctype/purchase_order/purchase_order.txt
index 8a56f26e9c..902329b050 100644
--- a/buying/doctype/purchase_order/purchase_order.txt
+++ b/buying/doctype/purchase_order/purchase_order.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-25 16:01:24",
+ "creation": "2013-05-21 16:16:39",
"docstatus": 0,
- "modified": "2013-02-18 13:37:11",
+ "modified": "2013-05-28 12:20:33",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -65,43 +65,48 @@
"search_index": 1
},
{
+ "depends_on": "supplier",
"doctype": "DocField",
"fieldname": "supplier_name",
"fieldtype": "Data",
- "hidden": 1,
+ "hidden": 0,
"in_list_view": 1,
"label": "Name",
"read_only": 1
},
{
+ "depends_on": "supplier",
"doctype": "DocField",
"fieldname": "address_display",
"fieldtype": "Small Text",
- "hidden": 1,
+ "hidden": 0,
"label": "Address",
"read_only": 1
},
{
+ "depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_display",
"fieldtype": "Small Text",
- "hidden": 1,
+ "hidden": 0,
"label": "Contact",
"read_only": 1
},
{
+ "depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_mobile",
"fieldtype": "Text",
- "hidden": 1,
+ "hidden": 0,
"label": "Mobile No",
"read_only": 1
},
{
+ "depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_email",
"fieldtype": "Text",
- "hidden": 1,
+ "hidden": 0,
"label": "Contact Email",
"print_hide": 1,
"read_only": 1
@@ -554,6 +559,7 @@
"oldfieldtype": "Text Editor"
},
{
+ "depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_section",
"fieldtype": "Section Break",
@@ -808,7 +814,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
- "match": "",
"permlevel": 1,
"report": 0,
"role": "Material User",
@@ -831,7 +836,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
- "match": "",
"permlevel": 1,
"report": 0,
"role": "Purchase Manager",
@@ -854,7 +858,6 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
- "match": "",
"permlevel": 0,
"report": 1,
"role": "Purchase User",
@@ -866,7 +869,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
- "match": "",
"permlevel": 1,
"role": "All",
"submit": 0
diff --git a/buying/doctype/purchase_order_item/purchase_order_item.txt b/buying/doctype/purchase_order_item/purchase_order_item.txt
index 01a144a143..5d69fb057d 100755
--- a/buying/doctype/purchase_order_item/purchase_order_item.txt
+++ b/buying/doctype/purchase_order_item/purchase_order_item.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-07 11:42:55",
+ "creation": "2013-05-24 19:29:06",
"docstatus": 0,
- "modified": "2013-05-22 11:59:52",
+ "modified": "2013-05-28 12:13:21",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -361,7 +361,7 @@
"oldfieldtype": "Currency",
"print_hide": 1,
"print_width": "100px",
- "read_only": 0,
+ "read_only": 1,
"width": "100px"
},
{
diff --git a/buying/doctype/supplier_quotation/supplier_quotation.js b/buying/doctype/supplier_quotation/supplier_quotation.js
index 1e4f6cbfb7..20a20ac5a5 100644
--- a/buying/doctype/supplier_quotation/supplier_quotation.js
+++ b/buying/doctype/supplier_quotation/supplier_quotation.js
@@ -26,48 +26,15 @@ wn.require('app/buying/doctype/purchase_common/purchase_common.js');
erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.extend({
refresh: function() {
this._super();
-
if (this.frm.doc.docstatus === 1) {
cur_frm.add_custom_button("Make Purchase Order", cur_frm.cscript.make_purchase_order);
}
- },
-
- onload_post_render: function(doc, dt, dn) {
- var me = this;
- var callback = function(doc, dt, dn) {
- cur_frm.cscript.load_taxes(me.frm.doc);
- }
-
- // TODO: improve this
- if(this.frm.doc.__islocal) {
- if (this.frm.fields_dict.price_list_name && this.frm.doc.price_list_name) {
- this.price_list_name(callback);
- } else {
- callback(doc, dt, dn);
- }
- }
- }
-
+ },
});
-var new_cscript = new erpnext.buying.SupplierQuotationController({frm: cur_frm});
-
// for backward compatibility: combine new and previous states
-$.extend(cur_frm.cscript, new_cscript);
-
-
-cur_frm.cscript.onload = function(doc, dt, dn) {
- // set missing values in parent doc
- set_missing_values(doc, {
- fiscal_year: sys_defaults.fiscal_year,
- conversion_rate: 1,
- currency: sys_defaults.currency,
- status: "Draft",
- transaction_date: get_today(),
- is_subcontracted: "No"
- });
-}
+$.extend(cur_frm.cscript, new erpnext.buying.SupplierQuotationController({frm: cur_frm}));
cur_frm.cscript.make_purchase_order = function() {
var new_po_name = wn.model.make_new_doc_and_get_name("Purchase Order");
@@ -82,15 +49,6 @@ cur_frm.cscript.make_purchase_order = function() {
}, function(r, rt) { loaddoc("Purchase Order", new_po_name) });
}
-cur_frm.cscript.supplier = function(doc, dt, dn) {
- if (doc.supplier) {
- get_server_fields('get_default_supplier_address',
- JSON.stringify({ supplier: doc.supplier }), '', doc, dt, dn, 1,
- function() { cur_frm.refresh(); });
- cur_frm.cscript.toggle_contact_section(doc);
- }
-}
-
cur_frm.cscript.uom = function(doc, cdt, cdn) {
// no need to trigger updation of stock uom, as this field doesn't exist in supplier quotation
}
diff --git a/buying/doctype/supplier_quotation/supplier_quotation.txt b/buying/doctype/supplier_quotation/supplier_quotation.txt
index dace56a43f..37e0e3c01c 100644
--- a/buying/doctype/supplier_quotation/supplier_quotation.txt
+++ b/buying/doctype/supplier_quotation/supplier_quotation.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-25 16:01:25",
+ "creation": "2013-05-21 16:16:45",
"docstatus": 0,
- "modified": "2013-02-18 13:40:17",
+ "modified": "2013-05-28 12:19:41",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -65,43 +65,48 @@
"search_index": 1
},
{
+ "depends_on": "supplier",
"doctype": "DocField",
"fieldname": "supplier_name",
"fieldtype": "Data",
- "hidden": 1,
+ "hidden": 0,
"in_list_view": 1,
"label": "Name",
"read_only": 1
},
{
+ "depends_on": "supplier",
"doctype": "DocField",
"fieldname": "address_display",
"fieldtype": "Small Text",
- "hidden": 1,
+ "hidden": 0,
"label": "Address",
"read_only": 1
},
{
+ "depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_display",
"fieldtype": "Small Text",
- "hidden": 1,
+ "hidden": 0,
"label": "Contact",
"read_only": 1
},
{
+ "depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_mobile",
"fieldtype": "Text",
- "hidden": 1,
+ "hidden": 0,
"label": "Mobile No",
"read_only": 1
},
{
+ "depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_email",
"fieldtype": "Text",
- "hidden": 1,
+ "hidden": 0,
"label": "Contact Email",
"print_hide": 1,
"read_only": 1
@@ -520,6 +525,7 @@
"oldfieldtype": "Text Editor"
},
{
+ "depends_on": "supplier",
"doctype": "DocField",
"fieldname": "contact_section",
"fieldtype": "Section Break",
@@ -723,7 +729,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
- "match": "",
"permlevel": 1,
"report": 0,
"role": "All",
diff --git a/buying/page/buying_home/buying_home.js b/buying/page/buying_home/buying_home.js
index 2070fd4e33..e45e73d291 100644
--- a/buying/page/buying_home/buying_home.js
+++ b/buying/page/buying_home/buying_home.js
@@ -13,7 +13,7 @@ wn.module_page["Buying"] = [
},
{
label: wn._("Supplier Quotation"),
- description: wn._("Track Quotations received from Suppliers."),
+ description: wn._("Quotations received from Suppliers."),
doctype:"Supplier Quotation"
},
{
diff --git a/buying/page/purchase_analytics/purchase_analytics.js b/buying/page/purchase_analytics/purchase_analytics.js
index fc082eae13..96b88b3115 100644
--- a/buying/page/purchase_analytics/purchase_analytics.js
+++ b/buying/page/purchase_analytics/purchase_analytics.js
@@ -24,7 +24,7 @@ wn.pages['purchase-analytics'].onload = function(wrapper) {
new erpnext.PurchaseAnalytics(wrapper);
wrapper.appframe.add_home_breadcrumb()
- wrapper.appframe.add_module_breadcrumb("Buying")
+ wrapper.appframe.add_module_icon("Buying")
wrapper.appframe.add_breadcrumb("icon-bar-chart")
}
@@ -49,7 +49,7 @@ erpnext.PurchaseAnalytics = wn.views.TreeGridReport.extend({
item_key: "supplier",
parent_field: "parent_supplier_type",
formatter: function(item) {
- // return repl('%(value)s', {
+ // return repl('%(value)s', {
// value: item.name,
// enc_value: encodeURIComponent(item.name)
// });
diff --git a/buying/utils.py b/buying/utils.py
index 0431e642cb..1aaa5d11c9 100644
--- a/buying/utils.py
+++ b/buying/utils.py
@@ -16,6 +16,7 @@
from __future__ import unicode_literals
import webnotes
+from webnotes import msgprint, _
from webnotes.utils import getdate, flt, add_days
import json
@@ -29,7 +30,11 @@ def get_item_details(args):
"warehouse": None,
"supplier": None,
"transaction_date": None,
- "conversion_rate": 1.0
+ "conversion_rate": 1.0,
+ "price_list_name": None,
+ "price_list_currency": None,
+ "plc_conversion_rate": 1.0,
+ "is_subcontracted": "Yes" / "No"
}
"""
if isinstance(args, basestring):
@@ -37,86 +42,102 @@ def get_item_details(args):
args = webnotes._dict(args)
- item_wrapper = webnotes.bean("Item", args.item_code)
- item = item_wrapper.doc
+ item_bean = webnotes.bean("Item", args.item_code)
+ item = item_bean.doc
- from stock.utils import validate_end_of_life
- validate_end_of_life(item.name, item.end_of_life)
+ _validate_item_details(args, item)
- # fetch basic values
- out = webnotes._dict()
- out.update({
- "item_name": item.item_name,
- "item_group": item.item_group,
- "brand": item.brand,
- "description": item.description,
- "qty": 0,
- "stock_uom": item.stock_uom,
- "uom": item.stock_uom,
- "conversion_factor": 1.0,
- "warehouse": args.warehouse or item.default_warehouse,
- "item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in
- item_wrapper.doclist.get({"parentfield": "item_tax"})))),
- "batch_no": None,
- "expense_head": item.purchase_account,
- "cost_center": item.cost_center
- })
+ out = _get_basic_details(args, item_bean)
- if args.supplier:
- item_supplier = item_wrapper.doclist.get({"parentfield": "item_supplier_details",
- "supplier": args.supplier})
- if item_supplier:
- out["supplier_part_no"] = item_supplier[0].supplier_part_no
+ out.supplier_part_no = _get_supplier_part_no(args, item_bean)
if out.warehouse:
- out.projected_qty = webnotes.conn.get_value("Bin", {"item_code": item.name,
- "warehouse": out.warehouse}, "projected_qty")
+ out.projected_qty = get_projected_qty(item.name, out.warehouse)
if args.transaction_date and item.lead_time_days:
out.schedule_date = out.lead_time_date = add_days(args.transaction_date,
item.lead_time_days)
- # set zero
- out.purchase_ref_rate = out.discount_rate = out.purchase_rate = \
- out.import_ref_rate = out.import_rate = 0.0
+ meta = webnotes.get_doctype(args.doctype)
+
+ if meta.get_field("currency"):
+ out.purchase_ref_rate = out.discount_rate = out.purchase_rate = \
+ out.import_ref_rate = out.import_rate = 0.0
+ out.update(_get_price_list_rate(args, item_bean, meta))
+
+ if args.doctype == "Material Request":
+ out.min_order_qty = flt(item.min_order_qty)
- if args.doctype in ["Purchase Order", "Purchase Invoice", "Purchase Receipt",
- "Supplier Quotation"]:
- # try fetching from price list
- if args.price_list_name and args.price_list_currency:
- rates_as_per_price_list = get_rates_as_per_price_list(args, item_wrapper.doclist)
- if rates_as_per_price_list:
- out.update(rates_as_per_price_list)
-
- # if not found, fetch from last purchase transaction
- if not out.purchase_rate:
- last_purchase = get_last_purchase_details(item.name, args.docname, args.conversion_rate)
- if last_purchase:
- out.update(last_purchase)
-
return out
-
-def get_rates_as_per_price_list(args, item_doclist=None):
- if not item_doclist:
- item_doclist = webnotes.bean("Item", args.item_code).doclist
- result = item_doclist.get({"parentfield": "ref_rate_details",
- "price_list_name": args.price_list_name, "ref_currency": args.price_list_currency,
- "buying": 1})
+def _get_basic_details(args, item_bean):
+ item = item_bean.doc
+
+ out = webnotes._dict({
+ "description": item.description_html or item.description,
+ "qty": 0.0,
+ "uom": item.stock_uom,
+ "conversion_factor": 1.0,
+ "warehouse": args.warehouse or item.default_warehouse,
+ "item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in
+ item_bean.doclist.get({"parentfield": "item_tax"})))),
+ "batch_no": None,
+ "expense_head": item.purchase_account,
+ "cost_center": item.cost_center
+ })
+
+ for fieldname in ("item_name", "item_group", "brand", "stock_uom"):
+ out[fieldname] = item.fields.get(fieldname)
+
+ return out
+
+def _get_price_list_rate(args, item_bean, meta):
+ from utilities.transaction_base import validate_currency
+ item = item_bean.doc
+ out = webnotes._dict()
+
+ # try fetching from price list
+ if args.price_list_name and args.price_list_currency:
+ price_list_rate = item_bean.doclist.get({
+ "parentfield": "ref_rate_details",
+ "price_list_name": args.price_list_name,
+ "ref_currency": args.price_list_currency,
+ "buying": 1})
+ if price_list_rate:
+ out.import_ref_rate = \
+ flt(price_list_rate[0].ref_rate * args.plc_conversion_rate / args.conversion_rate)
- if result:
- purchase_ref_rate = flt(result[0].ref_rate) * flt(args.plc_conversion_rate)
- conversion_rate = flt(args.conversion_rate) or 1.0
- return webnotes._dict({
- "purchase_ref_rate": purchase_ref_rate,
- "purchase_rate": purchase_ref_rate,
- "rate": purchase_ref_rate,
- "discount_rate": 0,
- "import_ref_rate": purchase_ref_rate / conversion_rate,
- "import_rate": purchase_ref_rate / conversion_rate
- })
- else:
- return webnotes._dict()
+ # if not found, fetch from last purchase transaction
+ if not out.import_ref_rate:
+ last_purchase = get_last_purchase_details(item.name, args.docname, args.conversion_rate)
+ if last_purchase:
+ out.update(last_purchase)
+
+ if out.import_ref_rate or out.import_rate:
+ validate_currency(args, item, meta)
+
+ return out
+
+def _get_supplier_part_no(args, item_bean):
+ item_supplier = item_bean.doclist.get({"parentfield": "item_supplier_details",
+ "supplier": args.supplier})
+
+ return item_supplier and item_supplier[0].supplier_part_no or None
+
+def _validate_item_details(args, item):
+ from utilities.transaction_base import validate_item_fetch
+ validate_item_fetch(args, item)
+
+ # validate if purchase item or subcontracted item
+ if item.is_purchase_item != "Yes":
+ msgprint(_("Item") + (" %s: " % item.name) + _("not a purchase item"),
+ raise_exception=True)
+
+ if args.is_subcontracted == "Yes" and item.is_sub_contracted_item != "Yes":
+ msgprint(_("Item") + (" %s: " % item.name) +
+ _("not a sub-contracted item.") +
+ _("Please select a sub-contracted item or do not sub-contract the transaction."),
+ raise_exception=True)
def get_last_purchase_details(item_code, doc_name, conversion_rate=1.0):
"""returns last purchase details in stock uom"""
@@ -177,4 +198,14 @@ def get_last_purchase_details(item_code, doc_name, conversion_rate=1.0):
"rate": out.purchase_rate
})
- return out
\ No newline at end of file
+ return out
+
+@webnotes.whitelist()
+def get_conversion_factor(item_code, uom):
+ return {"conversion_factor": webnotes.conn.get_value("UOM Conversion Detail",
+ {"parent": item_code, "uom": uom})}
+
+@webnotes.whitelist()
+def get_projected_qty(item_code, warehouse):
+ return webnotes.conn.get_value("Bin", {"item_code": item_code,
+ "warehouse": warehouse}, "projected_qty")
\ No newline at end of file
diff --git a/config.json b/config.json
index cb1a83164b..e0b85b1b8a 100644
--- a/config.json
+++ b/config.json
@@ -2,78 +2,79 @@
"modules": {
"Selling": {
"link": "selling-home",
- "color": "#3f4901",
+ "color": "#1abc9c",
"icon": "icon-tag",
"type": "module"
},
"Accounts": {
"link": "accounts-home",
- "color": "#025770",
+ "color": "#3498db",
"icon": "icon-money",
"type": "module"
},
"Stock": {
"type": "module",
"link": "stock-home",
- "color": "#a66a02",
+ "color": "#f39c12",
"icon": "icon-truck"
},
"Buying": {
"type": "module",
"link": "buying-home",
- "color": "#8F0222",
+ "color": "#c0392b",
"icon": "icon-shopping-cart"
},
"Support": {
"type": "module",
"link": "support-home",
- "color": "#410169",
+ "color": "#2c3e50",
"icon": "icon-phone"
},
"Projects": {
"type": "module",
"link": "projects-home",
- "color": "#473b7f",
+ "color": "#8e44ad",
"icon": "icon-tasks"
},
"Manufacturing": {
"type": "module",
"link": "manufacturing-home",
- "color": "#590116",
- "icon": "icon-magic"
+ "color": "#7f8c8d",
+ "icon": "icon-cogs"
},
"Website": {
"type": "module",
"link": "website-home",
- "color": "#968c00",
+ "color": "#16a085",
"icon": "icon-globe"
},
"HR": {
"type": "module",
"link": "hr-home",
- "color": "#018d6c",
+ "color": "#2ecc71",
"label": "Human Resources",
"icon": "icon-group"
},
"Setup": {
"type": "setup",
"link": "Setup",
- "color": "#484848",
+ "color": "#bdc3c7",
"icon": "icon-wrench"
},
"Activity": {
"type": "page",
"link": "activity",
- "color": "#633501",
+ "color": "#e67e22",
"icon": "icon-play",
"label": "Activity"
},
- "Knowledge Base": {
- "type": "page",
- "link": "questions",
- "color": "#01372b",
- "label": "Knowledge Base",
- "icon": "icon-question-sign"
+ "Notes": {
+ "type": "list",
+ "doctype": "Note",
+ "link": "List/Note",
+ "color": "#95a5a6",
+ "label": "Notes",
+ "icon": "icon-file-alt"
}
},
"web": {
@@ -126,6 +127,10 @@
"profile": {
"no_cache": true,
"template": "app/website/templates/pages/profile"
+ },
+ "cart": {
+ "no_cache": true,
+ "template": "app/website/templates/pages/cart.html"
}
},
"generators": {
diff --git a/controllers/accounts_controller.py b/controllers/accounts_controller.py
index 04e4bbdaee..b3007fe55a 100644
--- a/controllers/accounts_controller.py
+++ b/controllers/accounts_controller.py
@@ -16,14 +16,262 @@
from __future__ import unicode_literals
import webnotes
-from webnotes.utils import flt
-
-from utilities.transaction_base import TransactionBase
+from webnotes import _, msgprint
+from webnotes.utils import flt, cint
+from setup.utils import get_company_currency, get_price_list_currency
+from utilities.transaction_base import TransactionBase, validate_conversion_rate
+import json
class AccountsController(TransactionBase):
def validate(self):
- if self.meta.get_field("grand_total"):
+ self.set_missing_values(for_validate=True)
+
+ if self.meta.get_field("currency"):
+ self.company_currency = get_company_currency(self.doc.company)
+
+ validate_conversion_rate(self.doc.currency, self.doc.conversion_rate,
+ self.meta.get_label("conversion_rate"), self.doc.company)
+
+ self.calculate_taxes_and_totals()
self.validate_value("grand_total", ">=", 0)
+ self.set_total_in_words()
+
+ def set_price_list_currency(self, buying_or_selling):
+ # TODO - change this, since price list now has only one currency allowed
+ if self.meta.get_field("price_list_name") and self.doc.price_list_name and \
+ not self.doc.price_list_currency:
+ self.doc.fields.update(get_price_list_currency({
+ "price_list_name": self.doc.price_list_name,
+ "use_for": buying_or_selling
+ }))
+
+ def set_missing_item_details(self, get_item_details):
+ """set missing item values"""
+ for item in self.doclist.get({"parentfield": self.fname}):
+ if item.fields.get("item_code"):
+ args = item.fields.copy().update(self.doc.fields)
+ ret = get_item_details(args)
+ for fieldname, value in ret.items():
+ if self.meta.get_field(fieldname, parentfield=self.fname) and \
+ not item.fields.get(fieldname):
+ item.fields[fieldname] = value
+
+ def set_taxes(self, tax_doctype, tax_parentfield, tax_master_field):
+ if not self.meta.get_field(tax_parentfield):
+ return
+
+ if not self.doclist.get({"parentfield": tax_parentfield}):
+ if not self.doc.fields.get(tax_master_field):
+ # get the default tax master
+ self.doc.fields[tax_master_field] = \
+ webnotes.conn.get_value(tax_doctype + " Master", {"is_default": 1})
+
+ if self.doc.fields.get(tax_master_field):
+ from webnotes.model import default_fields
+ tax_master = webnotes.bean(tax_doctype, self.doc.fields.get(tax_master_field))
+
+ for i, tax in enumerate(tax_master.doclist.get({"parentfield": tax_parentfield})):
+ for fieldname in default_fields:
+ tax.fields[fieldname] = None
+
+ tax.fields.update({
+ "doctype": tax_doctype,
+ "parentfield": tax_parentfield,
+ "idx": i+1
+ })
+
+ self.doclist.append(tax)
+
+ def calculate_taxes_and_totals(self):
+ self.doc.conversion_rate = flt(self.doc.conversion_rate)
+ self.item_doclist = self.doclist.get({"parentfield": self.fname})
+ self.tax_doclist = self.doclist.get({"parentfield": self.other_fname})
+
+ self.calculate_item_values()
+ self.initialize_taxes()
+
+ if hasattr(self, "determine_exclusive_rate"):
+ self.determine_exclusive_rate()
+
+ self.calculate_net_total()
+ self.calculate_taxes()
+ self.calculate_totals()
+ self._cleanup()
+
+ # TODO
+ # print format: show net_total_export instead of net_total
+
+ def initialize_taxes(self):
+ for tax in self.tax_doclist:
+ tax.item_wise_tax_detail = {}
+ for fieldname in ["tax_amount", "total",
+ "tax_amount_for_current_item", "grand_total_for_current_item",
+ "tax_fraction_for_current_item", "grand_total_fraction_for_current_item"]:
+ tax.fields[fieldname] = 0.0
+
+ self.validate_on_previous_row(tax)
+ self.validate_inclusive_tax(tax)
+ self.round_floats_in(tax)
+
+ def validate_on_previous_row(self, tax):
+ """
+ validate if a valid row id is mentioned in case of
+ On Previous Row Amount and On Previous Row Total
+ """
+ if tax.charge_type in ["On Previous Row Amount", "On Previous Row Total"] and \
+ (not tax.row_id or cint(tax.row_id) >= tax.idx):
+ msgprint((_("Row") + " # %(idx)s [%(taxes_doctype)s]: " + \
+ _("Please specify a valid") + " %(row_id_label)s") % {
+ "idx": tax.idx,
+ "taxes_doctype": tax.doctype,
+ "row_id_label": self.meta.get_label("row_id",
+ parentfield=self.other_fname)
+ }, raise_exception=True)
+
+ def validate_inclusive_tax(self, tax):
+ def _on_previous_row_error(row_range):
+ msgprint((_("Row") + " # %(idx)s [%(doctype)s]: " +
+ _("to be included in Item's rate, it is required that: ") +
+ " [" + _("Row") + " # %(row_range)s] " + _("also be included in Item's rate")) % {
+ "idx": tax.idx,
+ "doctype": tax.doctype,
+ "inclusive_label": self.meta.get_label("included_in_print_rate",
+ parentfield=self.other_fname),
+ "charge_type_label": self.meta.get_label("charge_type",
+ parentfield=self.other_fname),
+ "charge_type": tax.charge_type,
+ "row_range": row_range
+ }, raise_exception=True)
+
+ if cint(tax.included_in_print_rate):
+ if tax.charge_type == "Actual":
+ # inclusive tax cannot be of type Actual
+ msgprint((_("Row")
+ + " # %(idx)s [%(doctype)s]: %(charge_type_label)s = \"%(charge_type)s\" "
+ + "cannot be included in Item's rate") % {
+ "idx": tax.idx,
+ "doctype": tax.doctype,
+ "charge_type_label": self.meta.get_label("charge_type",
+ parentfield=self.other_fname),
+ "charge_type": tax.charge_type,
+ }, raise_exception=True)
+ elif tax.charge_type == "On Previous Row Amount" and \
+ not cint(self.tax_doclist[tax.row_id - 1].included_in_print_rate):
+ # referred row should also be inclusive
+ _on_previous_row_error(tax.row_id)
+ elif tax.charge_type == "On Previous Row Total" and \
+ not all([cint(t.included_in_print_rate) for t in self.tax_doclist[:tax.row_id - 1]]):
+ # all rows about the reffered tax should be inclusive
+ _on_previous_row_error("1 - %d" % (tax.row_id,))
+
+ def calculate_taxes(self):
+ for item in self.item_doclist:
+ item_tax_map = self._load_item_tax_rate(item.item_tax_rate)
+
+ for i, tax in enumerate(self.tax_doclist):
+ # tax_amount represents the amount of tax for the current step
+ current_tax_amount = self.get_current_tax_amount(item, tax, item_tax_map)
+
+ if hasattr(self, "set_item_tax_amount"):
+ self.set_item_tax_amount(item, tax, current_tax_amount)
+
+ # case when net total is 0 but there is an actual type charge
+ # in this case add the actual amount to tax.tax_amount
+ # and tax.grand_total_for_current_item for the first such iteration
+ if tax.charge_type=="Actual" and \
+ not (current_tax_amount or self.doc.net_total or tax.tax_amount):
+ zero_net_total_adjustment = flt(tax.rate, self.precision("tax_amount", tax))
+ current_tax_amount += zero_net_total_adjustment
+
+ # store tax_amount for current item as it will be used for
+ # charge type = 'On Previous Row Amount'
+ tax.tax_amount_for_current_item = current_tax_amount
+
+ # accumulate tax amount into tax.tax_amount
+ tax.tax_amount += current_tax_amount
+
+ if tax.category:
+ # if just for valuation, do not add the tax amount in total
+ # hence, setting it as 0 for further steps
+ current_tax_amount = 0.0 if (tax.category == "Valuation") else current_tax_amount
+
+ current_tax_amount *= -1.0 if (tax.add_deduct_tax == "Deduct") else 1.0
+
+ # Calculate tax.total viz. grand total till that step
+ # note: grand_total_for_current_item contains the contribution of
+ # item's amount, previously applied tax and the current tax on that item
+ if i==0:
+ tax.grand_total_for_current_item = flt(item.amount +
+ current_tax_amount, self.precision("total", tax))
+
+ else:
+ tax.grand_total_for_current_item = \
+ flt(self.tax_doclist[i-1].grand_total_for_current_item +
+ current_tax_amount, self.precision("total", tax))
+
+ # in tax.total, accumulate grand total of each item
+ tax.total += tax.grand_total_for_current_item
+
+ def get_current_tax_amount(self, item, tax, item_tax_map):
+ tax_rate = self._get_tax_rate(tax, item_tax_map)
+ current_tax_amount = 0.0
+
+ if tax.charge_type == "Actual":
+ # distribute the tax amount proportionally to each item row
+ actual = flt(tax.rate, self.precision("tax_amount", tax))
+ current_tax_amount = (self.doc.net_total
+ and ((item.amount / self.doc.net_total) * actual)
+ or 0)
+ elif tax.charge_type == "On Net Total":
+ current_tax_amount = (tax_rate / 100.0) * item.amount
+ elif tax.charge_type == "On Previous Row Amount":
+ current_tax_amount = (tax_rate / 100.0) * \
+ self.tax_doclist[cint(tax.row_id) - 1].tax_amount_for_current_item
+ elif tax.charge_type == "On Previous Row Total":
+ current_tax_amount = (tax_rate / 100.0) * \
+ self.tax_doclist[cint(tax.row_id) - 1].grand_total_for_current_item
+
+ current_tax_amount = flt(current_tax_amount, self.precision("tax_amount", tax))
+
+ # store tax breakup for each item
+ tax.item_wise_tax_detail[item.item_code or item.item_name] = [tax_rate, current_tax_amount]
+
+ return current_tax_amount
+
+ def _load_item_tax_rate(self, item_tax_rate):
+ return json.loads(item_tax_rate) if item_tax_rate else {}
+
+ def _get_tax_rate(self, tax, item_tax_map):
+ if item_tax_map.has_key(tax.account_head):
+ return flt(item_tax_map.get(tax.account_head), self.precision("rate", tax))
+ else:
+ return tax.rate
+
+ def _cleanup(self):
+ for tax in self.tax_doclist:
+ for fieldname in ("grand_total_for_current_item",
+ "tax_amount_for_current_item",
+ "tax_fraction_for_current_item",
+ "grand_total_fraction_for_current_item"):
+ if fieldname in tax.fields:
+ del tax.fields[fieldname]
+
+ tax.item_wise_tax_detail = json.dumps(tax.item_wise_tax_detail)
+
+ def _set_in_company_currency(self, item, print_field, base_field):
+ """set values in base currency"""
+ item.fields[base_field] = flt((flt(item.fields[print_field],
+ self.precision(print_field, item)) * self.doc.conversion_rate),
+ self.precision(base_field, item))
+
+ def calculate_total_advance(self, parenttype, advance_parentfield):
+ if self.doc.doctype == parenttype and self.doc.docstatus < 2:
+ sum_of_allocated_amount = sum([flt(adv.allocated_amount, self.precision("allocated_amount", adv))
+ for adv in self.doclist.get({"parentfield": advance_parentfield})])
+
+ self.doc.total_advance = flt(sum_of_allocated_amount, self.precision("total_advance"))
+
+ self.calculate_outstanding_amount()
def get_gl_dict(self, args, cancel=None):
"""this method populates the common properties of a gl entry record"""
@@ -97,4 +345,4 @@ class AccountsController(TransactionBase):
if not hasattr(self, "_abbr"):
self._abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
- return self._abbr
\ No newline at end of file
+ return self._abbr
diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py
index 3deda0284b..303eef3894 100644
--- a/controllers/buying_controller.py
+++ b/controllers/buying_controller.py
@@ -17,35 +17,45 @@
from __future__ import unicode_literals
import webnotes
from webnotes import _, msgprint
-from webnotes.utils import flt, cint
-import json
+from webnotes.utils import flt
from buying.utils import get_item_details
from setup.utils import get_company_currency
-from webnotes.model.utils import round_floats_in_doc
from controllers.stock_controller import StockController
class WrongWarehouseCompany(Exception): pass
class BuyingController(StockController):
+ def onload_post_render(self):
+ self.set_price_list_currency("buying")
+
+ # contact, address, item details
+ self.set_missing_values()
+
+ self.set_taxes("Purchase Taxes and Charges", "purchase_tax_details", "purchase_other_charges")
+
def validate(self):
super(BuyingController, self).validate()
self.validate_stock_or_nonstock_items()
self.validate_warehouse_belongs_to_company()
- if self.meta.get_field("currency"):
- self.company_currency = get_company_currency(self.doc.company)
- self.validate_conversion_rate("currency", "conversion_rate")
-
- if self.doc.price_list_name and self.doc.price_list_currency:
- self.validate_conversion_rate("price_list_currency", "plc_conversion_rate")
-
- # IMPORTANT: enable this only when client side code is similar to this one
- # self.calculate_taxes_and_totals()
+
+ def set_missing_values(self, for_validate=False):
+ # set contact and address details for supplier, if they are not mentioned
+ if self.doc.supplier and not (self.doc.contact_person and self.doc.supplier_address):
+ for fieldname, val in self.get_default_address_and_contact("supplier").items():
+ if not self.doc.fields.get(fieldname) and self.meta.get_field(fieldname):
+ self.doc.fields[fieldname] = val
+
+ self.set_missing_item_details(get_item_details)
+
+ def set_supplier_defaults(self):
+ self.get_default_supplier_address(self.doc.fields)
- # set total in words
- self.set_total_in_words()
-
+ def get_purchase_tax_details(self):
+ self.doclist = self.doc.clear_table(self.doclist, "purchase_tax_details")
+ self.set_taxes()
+
def validate_warehouse_belongs_to_company(self):
for warehouse, company in webnotes.conn.get_values("Warehouse",
self.doclist.get_distinct_values("warehouse"), "company").items():
@@ -71,46 +81,6 @@ class BuyingController(StockController):
webnotes.msgprint(_("""Tax Category can not be 'Valuation' or 'Valuation and Total'
as all items are non-stock items"""), raise_exception=1)
- def update_item_details(self):
- for item in self.doclist.get({"parentfield": self.fname}):
- ret = get_item_details({
- "doctype": self.doc.doctype,
- "docname": self.doc.name,
- "item_code": item.item_code,
- "warehouse": item.warehouse,
- "supplier": self.doc.supplier,
- "transaction_date": self.doc.posting_date,
- "conversion_rate": self.doc.conversion_rate,
- "price_list_name": self.doc.price_list_name,
- "price_list_currency": self.doc.price_list_currency,
- "plc_conversion_rate": self.doc.plc_conversion_rate
- })
- for r in ret:
- if not item.fields.get(r):
- item.fields[r] = ret[r]
-
- def validate_conversion_rate(self, currency_field, conversion_rate_field):
- """common validation for currency and price list currency"""
-
- currency = self.doc.fields.get(currency_field)
- conversion_rate = flt(self.doc.fields.get(conversion_rate_field))
- conversion_rate_label = self.meta.get_label(conversion_rate_field)
-
- if conversion_rate == 0:
- msgprint(conversion_rate_label + _(' cannot be 0'), raise_exception=True)
-
- # parenthesis for 'OR' are necessary as we want it to evaluate as
- # mandatory valid condition and (1st optional valid condition
- # or 2nd optional valid condition)
- valid_conversion_rate = (conversion_rate and
- ((currency == self.company_currency and conversion_rate == 1.00)
- or (currency != self.company_currency and conversion_rate != 1.00)))
-
- if not valid_conversion_rate:
- msgprint(_('Please enter valid ') + conversion_rate_label + (': ')
- + ("1 %s = [?] %s" % (currency, self.company_currency)),
- raise_exception=True)
-
def set_total_in_words(self):
from webnotes.utils import money_in_words
company_currency = get_company_currency(self.doc.company)
@@ -121,154 +91,54 @@ class BuyingController(StockController):
self.doc.currency)
def calculate_taxes_and_totals(self):
- self.doc.conversion_rate = flt(self.doc.conversion_rate)
- self.item_doclist = self.doclist.get({"parentfield": self.fname})
- self.tax_doclist = self.doclist.get({"parentfield": "purchase_tax_details"})
-
- self.calculate_item_values()
- self.initialize_taxes()
- self.calculate_net_total()
- self.calculate_taxes()
- self.calculate_totals()
- self.calculate_outstanding_amount()
-
- self._cleanup()
+ self.other_fname = "purchase_tax_details"
+ super(BuyingController, self).calculate_taxes_and_totals()
+ self.calculate_total_advance("Purchase Invoice", "advance_allocation_details")
def calculate_item_values(self):
- def _set_base(item, print_field, base_field):
- """set values in base currency"""
- item.fields[base_field] = flt((flt(item.fields[print_field],
- self.precision.item[print_field]) * self.doc.conversion_rate),
- self.precision.item[base_field])
-
- for item in self.item_doclist:
- round_floats_in_doc(item, self.precision.item)
+ # hack! - cleaned up in _cleanup()
+ if self.doc.doctype != "Purchase Invoice":
+ df = self.meta.get_field("purchase_rate", parentfield=self.fname)
+ df.fieldname = "rate"
+ for item in self.item_doclist:
# hack! - cleaned up in _cleanup()
if self.doc.doctype != "Purchase Invoice":
item.rate = item.purchase_rate
- self.precision.item.rate = self.precision.item.purchase_rate
- item.discount = item.discount_rate
- self.precision.item.discount = self.precision.item.discount_rate
+ self.round_floats_in(item)
- if item.discount == 100:
- if not item.import_ref_rate:
- item.import_ref_rate = item.import_rate
- item.import_rate = 0
- else:
- if item.import_ref_rate:
- item.import_rate = flt(item.import_ref_rate *
- (1.0 - (item.discount_rate / 100.0)),
- self.precision.item.import_rate)
- else:
- # assume that print rate and discount are specified
- item.import_ref_rate = flt(item.import_rate /
- (1.0 - (item.discount_rate / 100.0)),
- self.precision.item.import_ref_rate)
+ if item.discount_rate == 100.0:
+ item.import_rate = 0.0
+ elif item.import_ref_rate:
+ item.import_rate = flt(item.import_ref_rate * (1.0 - (item.discount_rate / 100.0)),
+ self.precision("import_rate", item))
item.import_amount = flt(item.import_rate * item.qty,
- self.precision.item.import_amount)
+ self.precision("import_amount", item))
+ item.item_tax_amount = 0.0;
- _set_base(item, "import_ref_rate", "purchase_ref_rate")
- _set_base(item, "import_rate", "rate")
- _set_base(item, "import_amount", "amount")
-
- def initialize_taxes(self):
- for tax in self.tax_doclist:
- # initialize totals to 0
- tax.tax_amount = tax.total = 0.0
+ self._set_in_company_currency(item, "import_ref_rate", "purchase_ref_rate")
+ self._set_in_company_currency(item, "import_rate", "rate")
+ self._set_in_company_currency(item, "import_amount", "amount")
- # temporary fields
- tax.tax_amount_for_current_item = tax.grand_total_for_current_item = 0.0
-
- tax.item_wise_tax_detail = {}
-
- self.validate_on_previous_row(tax)
-
- round_floats_in_doc(tax, self.precision.tax)
-
def calculate_net_total(self):
- self.doc.net_total = 0
- self.doc.net_total_import = 0
+ self.doc.net_total = self.doc.net_total_import = 0.0
for item in self.item_doclist:
self.doc.net_total += item.amount
self.doc.net_total_import += item.import_amount
- self.doc.net_total = flt(self.doc.net_total, self.precision.main.net_total)
- self.doc.net_total_import = flt(self.doc.net_total_import,
- self.precision.main.net_total_import)
-
- def calculate_taxes(self):
- for item in self.item_doclist:
- item_tax_map = self._load_item_tax_rate(item.item_tax_rate)
- item.item_tax_amount = 0
-
- for i, tax in enumerate(self.tax_doclist):
- # tax_amount represents the amount of tax for the current step
- current_tax_amount = self.get_current_tax_amount(item, tax, item_tax_map)
-
- self.set_item_tax_amount(item, tax, current_tax_amount)
-
- # case when net total is 0 but there is an actual type charge
- # in this case add the actual amount to tax.tax_amount
- # and tax.grand_total_for_current_item for the first such iteration
- if not (current_tax_amount or self.doc.net_total or tax.tax_amount) and \
- tax.charge_type=="Actual":
- zero_net_total_adjustment = flt(tax.rate, self.precision.tax.tax_amount)
- current_tax_amount += zero_net_total_adjustment
-
- # store tax_amount for current item as it will be used for
- # charge type = 'On Previous Row Amount'
- tax.tax_amount_for_current_item = current_tax_amount
-
- # accumulate tax amount into tax.tax_amount
- tax.tax_amount += tax.tax_amount_for_current_item
-
- if tax.category == "Valuation":
- # if just for valuation, do not add the tax amount in total
- # hence, setting it as 0 for further steps
- current_tax_amount = 0
- else:
- current_tax_amount *= tax.add_deduct_tax == "Deduct" and -1.0 or 1.0
-
- # Calculate tax.total viz. grand total till that step
- # note: grand_total_for_current_item contains the contribution of
- # item's amount, previously applied tax and the current tax on that item
- if i==0:
- tax.grand_total_for_current_item = flt(item.amount +
- current_tax_amount, self.precision.tax.total)
-
- else:
- tax.grand_total_for_current_item = \
- flt(self.tax_doclist[i-1].grand_total_for_current_item +
- current_tax_amount, self.precision.tax.total)
-
- # in tax.total, accumulate grand total of each item
- tax.total += tax.grand_total_for_current_item
-
- # store tax_breakup for each item
- # DOUBT: should valuation type amount also be stored?
- tax.item_wise_tax_detail[item.item_code] = current_tax_amount
+ self.round_floats_in(self.doc, ["net_total", "net_total_import"])
def calculate_totals(self):
- if self.tax_doclist:
- self.doc.grand_total = flt(self.tax_doclist[-1].total,
- self.precision.main.grand_total)
- self.doc.grand_total_import = flt(
- self.doc.grand_total / self.doc.conversion_rate,
- self.precision.main.grand_total_import)
- else:
- self.doc.grand_total = flt(self.doc.net_total,
- self.precision.main.grand_total)
- self.doc.grand_total_import = flt(
- self.doc.grand_total / self.doc.conversion_rate,
- self.precision.main.grand_total_import)
+ self.doc.grand_total = flt(self.tax_doclist and \
+ self.tax_doclist[-1].total or self.doc.net_total, self.precision("grand_total"))
+ self.doc.grand_total_import = flt(self.doc.grand_total / self.doc.conversion_rate,
+ self.precision("grand_total_import"))
- self.doc.total_tax = \
- flt(self.doc.grand_total - self.doc.net_total,
- self.precision.main.total_tax)
+ self.doc.total_tax = flt(self.doc.grand_total - self.doc.net_total,
+ self.precision("total_tax"))
if self.meta.get_field("rounded_total"):
self.doc.rounded_total = round(self.doc.grand_total)
@@ -277,75 +147,31 @@ class BuyingController(StockController):
self.doc.rounded_total_import = round(self.doc.grand_total_import)
def calculate_outstanding_amount(self):
- if self.doc.doctype == "Purchase Invoice" and self.doc.docstatus == 0:
+ if self.doc.doctype == "Purchase Invoice" and self.doc.docstatus < 2:
self.doc.total_advance = flt(self.doc.total_advance,
- self.precision.main.total_advance)
+ self.precision("total_advance"))
self.doc.total_amount_to_pay = flt(self.doc.grand_total - flt(self.doc.write_off_amount,
- self.precision.main.write_off_amount), self.precision.main.total_amount_to_pay)
+ self.precision("write_off_amount")), self.precision("total_amount_to_pay"))
self.doc.outstanding_amount = flt(self.doc.total_amount_to_pay - self.doc.total_advance,
- self.precision.main.outstanding_amount)
+ self.precision("outstanding_amount"))
def _cleanup(self):
- for tax in self.tax_doclist:
- del tax.fields["grand_total_for_current_item"]
- del tax.fields["tax_amount_for_current_item"]
- tax.item_wise_tax_detail = json.dumps(tax.item_wise_tax_detail)
-
- # except in purchase invoice, rate field is purchase_rate
+ super(BuyingController, self)._cleanup()
+
+ # except in purchase invoice, rate field is purchase_rate
+ # reset fieldname of rate
if self.doc.doctype != "Purchase Invoice":
+ df = self.meta.get_field("rate", parentfield=self.fname)
+ df.fieldname = "purchase_rate"
+
for item in self.item_doclist:
item.purchase_rate = item.rate
del item.fields["rate"]
- item.discount_rate = item.discount
- del item.fields["discount"]
-
- def validate_on_previous_row(self, tax):
- """
- validate if a valid row id is mentioned in case of
- On Previous Row Amount and On Previous Row Total
- """
- if tax.charge_type in ["On Previous Row Amount", "On Previous Row Total"] and \
- (not tax.row_id or cint(tax.row_id) >= tax.idx):
- msgprint((_("Row") + " # %(idx)s [%(taxes_doctype)s]: " + \
- _("Please specify a valid") + " %(row_id_label)s") % {
- "idx": tax.idx,
- "taxes_doctype": tax.parenttype,
- "row_id_label": self.meta.get_label("row_id",
- parentfield="purchase_tax_details")
- }, raise_exception=True)
+ if not self.meta.get_field("item_tax_amount", parentfield=self.fname):
+ for item in self.item_doclist:
+ del item.fields["item_tax_amount"]
- def _load_item_tax_rate(self, item_tax_rate):
- if not item_tax_rate:
- return {}
- return json.loads(item_tax_rate)
-
- def get_current_tax_amount(self, item, tax, item_tax_map):
- tax_rate = self._get_tax_rate(tax, item_tax_map)
-
- if tax.charge_type == "Actual":
- # distribute the tax amount proportionally to each item row
- actual = flt(tax.rate, self.precision.tax.tax_amount)
- current_tax_amount = (self.doc.net_total
- and ((item.amount / self.doc.net_total) * actual)
- or 0)
- elif tax.charge_type == "On Net Total":
- current_tax_amount = (tax_rate / 100.0) * item.amount
- elif tax.charge_type == "On Previous Row Amount":
- current_tax_amount = (tax_rate / 100.0) * \
- self.tax_doclist[cint(tax.row_id) - 1].tax_amount_for_current_item
- elif tax.charge_type == "On Previous Row Total":
- current_tax_amount = (tax_rate / 100.0) * \
- self.tax_doclist[cint(tax.row_id) - 1].grand_total_for_current_item
-
- return flt(current_tax_amount, self.precision.tax.tax_amount)
-
- def _get_tax_rate(self, tax, item_tax_map):
- if item_tax_map.has_key(tax.account_head):
- return flt(item_tax_map.get(tax.account_head), self.precision.tax.rate)
- else:
- return tax.rate
-
def set_item_tax_amount(self, item, tax, current_tax_amount):
"""
item_tax_amount is the total tax amount applied on that item
@@ -353,29 +179,28 @@ class BuyingController(StockController):
TODO: rename item_tax_amount to valuation_tax_amount
"""
- if tax.category in ["Valuation", "Valuation and Total"] and \
- item.item_code in self.stock_items:
- item.item_tax_amount += flt(current_tax_amount,
- self.precision.item.item_tax_amount)
+ if tax.category in ["Valuation", "Valuation and Total"]:
+ item.item_tax_amount += flt(current_tax_amount, self.precision("item_tax_amount", item))
# update valuation rate
def update_valuation_rate(self, parentfield):
- for d in self.doclist.get({"parentfield": parentfield}):
- d.conversion_factor = d.conversion_factor or flt(webnotes.conn.get_value(
- "UOM Conversion Detail", {"parent": d.item_code, "uom": d.uom},
+ for item in self.doclist.get({"parentfield": parentfield}):
+ item.conversion_factor = item.conversion_factor or flt(webnotes.conn.get_value(
+ "UOM Conversion Detail", {"parent": item.item_code, "uom": item.uom},
"conversion_factor")) or 1
- if d.item_code and d.qty:
+
+ if item.item_code and item.qty:
+ self.round_floats_in(item)
+
+ purchase_rate = item.rate if self.doc.doctype == "Purchase Invoice" else item.purchase_rate
+
# if no item code, which is sometimes the case in purchase invoice,
# then it is not possible to track valuation against it
- d.valuation_rate = flt(((flt(d.purchase_rate, self.precision.item.purchase_rate) or
- flt(d.rate, self.precision.item.rate)) +
- (flt(d.item_tax_amount, self.precision.item.item_tax_amount) +
- flt(d.rm_supp_cost, self.precision.item.rm_supp_cost)) /
- flt(d.qty, self.precision.item.qty)) /
- flt(d.conversion_factor, self.precision.item.conversion_factor),
- self.precision.item.valuation_rate)
+ item.valuation_rate = flt((purchase_rate +
+ (item.item_tax_amount + item.rm_supp_cost) / item.qty) / item.conversion_factor,
+ self.precision("valuation_rate", item))
else:
- d.valuation_rate = 0.0
+ item.valuation_rate = 0.0
def validate_for_subcontracting(self):
if not self.doc.is_subcontracted and self.sub_contracted_items:
@@ -437,18 +262,6 @@ class BuyingController(StockController):
return bom_items
-
- @property
- def precision(self):
- if not hasattr(self, "_precision"):
- self._precision = webnotes._dict()
- self._precision.main = self.meta.get_precision_map()
- self._precision.item = self.meta.get_precision_map(parentfield = self.fname)
- if self.meta.get_field("purchase_tax_details"):
- self._precision.tax = self.meta.get_precision_map(parentfield = \
- "purchase_tax_details")
- return self._precision
-
@property
def sub_contracted_items(self):
if not hasattr(self, "_sub_contracted_items"):
diff --git a/controllers/selling_controller.py b/controllers/selling_controller.py
index 80af337031..3adc639271 100644
--- a/controllers/selling_controller.py
+++ b/controllers/selling_controller.py
@@ -16,16 +16,40 @@
from __future__ import unicode_literals
import webnotes
-from webnotes.utils import cint
+from webnotes.utils import cint, flt, comma_or
from setup.utils import get_company_currency
+from selling.utils import get_item_details
from webnotes import msgprint, _
from controllers.stock_controller import StockController
class SellingController(StockController):
- def validate(self):
- super(SellingController, self).validate()
- self.set_total_in_words()
+ def onload_post_render(self):
+ self.set_price_list_currency("selling")
+
+ # contact, address, item details and pos details (if applicable)
+ self.set_missing_values()
+
+ self.set_taxes("Sales Taxes and Charges", "other_charges", "charge")
+
+ def set_missing_values(self, for_validate=False):
+ # set contact and address details for customer, if they are not mentioned
+ if self.doc.customer and not (self.doc.contact_person and self.doc.customer_address):
+ for fieldname, val in self.get_default_address_and_contact("customer").items():
+ if not self.doc.fields.get(fieldname) and self.meta.get_field(fieldname):
+ self.doc.fields[fieldname] = val
+
+ self.set_missing_item_details(get_item_details)
+
+ def get_other_charges(self):
+ self.doclist = self.doc.clear_table(self.doclist, "other_charges")
+ self.set_taxes("Sales Taxes and Charges", "other_charges", "charge")
+
+ def set_customer_defaults(self):
+ self.get_default_customer_address()
+
+ if self.meta.get_field("shipping_address"):
+ self.doc.fields.update(self.get_shipping_address(self.doc.customer))
def set_total_in_words(self):
from webnotes.utils import money_in_words
@@ -71,4 +95,154 @@ class SellingController(StockController):
if item.buying_amount and not item.cost_center:
msgprint(_("""Cost Center is mandatory for item: """) + item.item_code,
- raise_exception=1)
\ No newline at end of file
+ raise_exception=1)
+
+ def calculate_taxes_and_totals(self):
+ self.other_fname = "other_charges"
+
+ super(SellingController, self).calculate_taxes_and_totals()
+
+ self.calculate_total_advance("Sales Invoice", "advance_adjustment_details")
+ self.calculate_commission()
+ self.calculate_contribution()
+
+ def determine_exclusive_rate(self):
+ if not any((cint(tax.included_in_print_rate) for tax in self.tax_doclist)):
+ # no inclusive tax
+ return
+
+ for item in self.item_doclist:
+ item_tax_map = self._load_item_tax_rate(item.item_tax_rate)
+ cumulated_tax_fraction = 0
+ for i, tax in enumerate(self.tax_doclist):
+ tax.tax_fraction_for_current_item = self.get_current_tax_fraction(tax, item_tax_map)
+
+ if i==0:
+ tax.grand_total_fraction_for_current_item = 1 + tax.tax_fraction_for_current_item
+ else:
+ tax.grand_total_fraction_for_current_item = \
+ self.tax_doclist[i-1].grand_total_fraction_for_current_item \
+ + tax.tax_fraction_for_current_item
+
+ cumulated_tax_fraction += tax.tax_fraction_for_current_item
+
+ if cumulated_tax_fraction:
+ item.basic_rate = flt((item.export_rate * self.doc.conversion_rate) /
+ (1 + cumulated_tax_fraction), self.precision("basic_rate", item))
+
+ item.amount = flt(item.basic_rate * item.qty, self.precision("amount", item))
+
+ if item.adj_rate == 100:
+ item.base_ref_rate = item.basic_rate
+ item.basic_rate = 0.0
+ else:
+ item.base_ref_rate = flt(item.basic_rate / (1 - (item.adj_rate / 100.0)),
+ self.precision("base_ref_rate", item))
+
+ def get_current_tax_fraction(self, tax, item_tax_map):
+ """
+ Get tax fraction for calculating tax exclusive amount
+ from tax inclusive amount
+ """
+ current_tax_fraction = 0
+
+ if cint(tax.included_in_print_rate):
+ tax_rate = self._get_tax_rate(tax, item_tax_map)
+
+ if tax.charge_type == "On Net Total":
+ current_tax_fraction = tax_rate / 100.0
+
+ elif tax.charge_type == "On Previous Row Amount":
+ current_tax_fraction = (tax_rate / 100.0) * \
+ self.tax_doclist[cint(tax.row_id) - 1].tax_fraction_for_current_item
+
+ elif tax.charge_type == "On Previous Row Total":
+ current_tax_fraction = (tax_rate / 100.0) * \
+ self.tax_doclist[cint(tax.row_id) - 1].grand_total_fraction_for_current_item
+
+ return current_tax_fraction
+
+ def calculate_item_values(self):
+ for item in self.item_doclist:
+ self.round_floats_in(item)
+
+ if item.adj_rate == 100:
+ item.export_rate = 0
+ elif item.ref_rate:
+ item.export_rate = flt(item.ref_rate * (1.0 - (item.adj_rate / 100.0)),
+ self.precision("export_rate", item))
+
+ item.export_amount = flt(item.export_rate * item.qty,
+ self.precision("export_amount", item))
+
+ self._set_in_company_currency(item, "ref_rate", "base_ref_rate")
+ self._set_in_company_currency(item, "export_rate", "basic_rate")
+ self._set_in_company_currency(item, "export_amount", "amount")
+
+ def calculate_net_total(self):
+ self.doc.net_total = self.doc.net_total_export = 0.0
+
+ for item in self.item_doclist:
+ self.doc.net_total += item.amount
+ self.doc.net_total_export += item.export_amount
+
+ self.round_floats_in(self.doc, ["net_total", "net_total_export"])
+
+ def calculate_totals(self):
+ self.doc.grand_total = flt(self.tax_doclist and \
+ self.tax_doclist[-1].total or self.doc.net_total, self.precision("grand_total"))
+ self.doc.grand_total_export = flt(self.doc.grand_total / self.doc.conversion_rate,
+ self.precision("grand_total_export"))
+
+ self.doc.other_charges_total = flt(self.doc.grand_total - self.doc.net_total,
+ self.precision("other_charges_total"))
+ self.doc.other_charges_total_export = flt(self.doc.grand_total_export - self.doc.net_total_export,
+ self.precision("other_charges_total_export"))
+
+ self.doc.rounded_total = round(self.doc.grand_total)
+ self.doc.rounded_total_export = round(self.doc.grand_total_export)
+
+ def calculate_outstanding_amount(self):
+ # NOTE:
+ # write_off_amount is only for POS Invoice
+ # total_advance is only for non POS Invoice
+ if self.doc.doctype == "Sales Invoice" and self.doc.docstatus < 2:
+ self.round_floats_in(self.doc, ["grand_total", "total_advance", "write_off_amount",
+ "paid_amount"])
+ total_amount_to_pay = self.doc.grand_total - self.doc.write_off_amount
+ self.doc.outstanding_amount = flt(total_amount_to_pay - self.doc.total_advance - self.doc.paid_amount,
+ self.precision("outstanding_amount"))
+
+ def calculate_commission(self):
+ if self.meta.get_field("commission_rate"):
+ self.round_floats_in(self.doc, ["net_total", "commission_rate"])
+ if self.doc.commission_rate > 100.0:
+ msgprint(_(self.meta.get_label("commission_rate")) + " " +
+ _("cannot be greater than 100"), raise_exception=True)
+
+ self.doc.total_commission = flt(self.doc.net_total * self.doc.commission_rate / 100.0,
+ self.precision("total_commission"))
+
+ def calculate_contribution(self):
+ total = 0.0
+ sales_team = self.doclist.get({"parentfield": "sales_team"})
+ for sales_person in sales_team:
+ self.round_floats_in(sales_person)
+
+ sales_person.allocated_amount = flt(
+ self.doc.net_total * sales_person.allocated_percentage / 100.0,
+ self.precision("allocated_amount", sales_person))
+
+ total += sales_person.allocated_percentage
+
+ if sales_team and total != 100.0:
+ msgprint(_("Total") + " " +
+ _(self.meta.get_label("allocated_percentage", parentfield="sales_team")) +
+ " " + _("should be 100%"), raise_exception=True)
+
+ def validate_order_type(self):
+ valid_types = ["Sales", "Maintenance"]
+ if self.doc.order_type not in valid_types:
+ msgprint(_(self.meta.get_label("order_type")) + " " +
+ _("must be one of") + ": " + comma_or(valid_types),
+ raise_exception=True)
diff --git a/docs/docs.dev.md b/docs/docs.dev.md
new file mode 100644
index 0000000000..6c46abffa1
--- /dev/null
+++ b/docs/docs.dev.md
@@ -0,0 +1,15 @@
+---
+{
+ "_label": "Developer API",
+ "_toc": [
+ "docs.dev.quickstart",
+ "docs.dev.framework",
+ "docs.dev.modules"
+ ]
+}
+---
+### Is this for me?
+
+To starting hacking into ERPNext, you must have some understanding of how a dynamic web application works. There are hundreds of architectures and frameworks to make web development easier, but at the core there are a few elements that are important to understand.
+
+ERPNext is built on `wnframework` which is primarily developed for ERPNext but can be extended to make similar database driven applications. wnframework uses Python on the server-side and has a javascript based client for entering data, managing workflow and making reports.
\ No newline at end of file
diff --git a/docs/docs.dev.modules.md b/docs/docs.dev.modules.md
new file mode 100644
index 0000000000..34fea9ab7e
--- /dev/null
+++ b/docs/docs.dev.modules.md
@@ -0,0 +1,6 @@
+---
+{
+ "_label": "Modules"
+}
+---
+The models used in both `wnframework` (**Core** module) and ERPNext are listed here. The basic element of the model is a `DocType`, which is most often also a database table. The model properties are called `DocFields`, which describe the view and the database columns.
\ No newline at end of file
diff --git a/docs/docs.md b/docs/docs.md
new file mode 100644
index 0000000000..7cf47a9531
--- /dev/null
+++ b/docs/docs.md
@@ -0,0 +1,24 @@
+---
+{
+ "_label": "ERPNext",
+ "_no_title": 1,
+ "_toc": [
+ "docs.user",
+ "docs.dev",
+ "docs.download",
+ "docs.community",
+ "docs.blog",
+ "docs.about"
+ ]
+}
+---
+
+
ERPNext
+
Open Source Organization Management Platform
+
+
+### Is this for me?
+
+To starting hacking into ERPNext, you must have some understanding of how a dynamic web application works. There are hundreds of architectures and frameworks to make web development easier, but at the core there are a few elements that are important to understand.
+
+ERPNext is built on `wnframework` which is primarily developed for ERPNext but can be extended to make similar database driven applications. wnframework uses Python on the server-side and has a javascript based client for entering data, managing workflow and making reports.
\ No newline at end of file
diff --git a/docs/docs.user.intro.md b/docs/docs.user.intro.md
new file mode 100644
index 0000000000..4aada627d0
--- /dev/null
+++ b/docs/docs.user.intro.md
@@ -0,0 +1,54 @@
+---
+{
+ "_label": "Introduction",
+ "_title_image": "img/why-erpnext.png"
+}
+---
+## What is an ERP and why should I care?
+
+Small business are not so different from large ones. They contain most of the complexities of a large business but with many more constraints. Small businesses have to communicate with customers, do accounts, pay taxes, do payroll, manage timelines, deliver quality, answer questions and keep everyone happy just like large businesses.
+
+And to it *efficiently*.
+
+Large businesses have the advantage of using advanced data systems to manage their process efficiently. Small businesses typically struggle to keep things organized. They are often using a mix of apps like spreadsheets, accounting software, web CRM etc to manage but not everyone is on the same page. An ERP changes that.
+
+---
+
+## What is ERPNext?
+
+ERPNext helps you to manage all your business information in one application and use it to manage operations and take decisions based on data.
+
+Among other things, ERPNext will help you to:
+
+- Track all Invoices and Payments.
+- Know what quantity of what product is available in stock.
+- Identify open customer queries.
+- Manage payroll.
+- Assign tasks and follow up on them.
+- Maintain a database of all your customers, suppliers and their contacts.
+- Prepare quotes.
+- Get reminders on maintenance schedules.
+- Publish you website.
+
+And a lot lot lot more.
+
+---
+
+## Why Should I Use ERPNext?
+
+ERPNext is a modern accounting plus everything system and has many benefits over both traditional accounting as well as ERP applications.
+
+### Benefits over traditional accounting software:
+
+- Do a lot more than just accounting! Manage inventory, billing, quotes, leads, payroll and much much more.
+- All data safe and in one place. Don’t keep hunting for data when you need it across spreadsheets and different computers.
+- Everyone on the same page. All users get the same update data.
+- Stop repetitive work. Don’t enter the same information from your word processor to your accounting tool. Its all integrated.
+- Keep track. Get the entire history of a customer or a deal in one place.
+
+### Benefits over big ERPs
+
+- $$$ - Save money.
+- Easier to configure. Big ERPs are notoriously hard to setup and will ask you a zillion questions before you can do something meaningful.
+- Easier to use. Modern web like user interface will keep your users happy and in familiar territory.
+- Open Source. This software is always free and you can host it anywhere you like.
\ No newline at end of file
diff --git a/docs/docs.user.md b/docs/docs.user.md
new file mode 100644
index 0000000000..bb32882a90
--- /dev/null
+++ b/docs/docs.user.md
@@ -0,0 +1,10 @@
+---
+{
+ "_label": "User Guide",
+ "_toc": [
+ "docs.user.intro",
+ "docs.user.setup"
+ ]
+}
+---
+This manual covers all the major processes in setting up and using ERPNext. The manual is written in a way that the user can manage a self-implementation of the ERP. We recommend that the manual be read first before starting implementation.
diff --git a/docs/docs.user.setup.accounting.md b/docs/docs.user.setup.accounting.md
new file mode 100644
index 0000000000..b10cf5b466
--- /dev/null
+++ b/docs/docs.user.setup.accounting.md
@@ -0,0 +1,129 @@
+---
+{
+ "_label": "Accounting Setup",
+ "_title_image": "img/setup-accounting.png"
+}
+---
+## Chart of Accounts
+
+The Chart of Accounts forms the blueprint of your organization. The overall structure of your Chart of Accounts is based on a system of double entry accounting that has become a standard all over the world to quantify how a company is doing financially.
+
+The Chart of Accounts helps you answer:
+
+- What is your organization worth?
+- How much debt have you taken?
+- How much profit you are making (and hence paying tax)?
+- How much is are you selling?
+- How are your expenses broken up?
+
+As you can see, it is very valuable to you as a business manager to see how well your business is doing.
+
+> Tip: If you can’t read a Balance Sheet (I confess it took me a long time to figure this out) its a good opportunity to start learning about this. It will be worth the effort. You can also take the help of your accountant to setup your Chart of Accounts.
+
+To edit your Chart of Accounts in ERPNext go to:
+
+> Accounts > Chart of Accounts
+
+Chart of Accounts is a tree view of the names of the Accounts (Ledgers and Groups) that a Company requires to manage its books of accounts. ERPNext sets up a simple chart of accounts for each Company you create, but you have to modify it according to your needs and legal requirements.
+
+For each company, Chart of Accounts signifies the way to classify the accounting entries, mostly based on statutory (tax, compliance to government regulations) requirements.
+
+Let us understand the main groups of the Chart of Accounts.
+
+### Balance Sheet Accounts
+
+The Balance Sheet has Application of Funds (Assets) and Sources of Funds (Liabilities) that signify the net-worth of your company at any given time. When you begin or end a financial period, all the Assets are equal to the Liabilities.
+
+> Accounting: If you are new to accounting, you might be wondering, how can Assets be equal to Liabilities? That would mean the company has nothing of its own. Thats right. All the “investment” made in the company to buy assets (like land, furniture, machines) is made by the owners and is a liability to the company. If the company would to shut down, it would need to sell all the assets and pay back all the liabilities (including profits) to the owners, leaving itself with nothing.
+
+All the accounts under this represent an asset owned by company like "Bank Account", "Land and Property", "Furniture" or a liability (funds that the company owes to others) like "Owners funds", "Debt" etc.
+
+Two special accounts to note here are Accounts Receivable (money you have to collect from your customers) and Accounts Payable (money you have to pay to your suppliers) under Assets and Liabilities respectively.
+
+### Profit and Loss Accounts
+
+Profit and Loss is the group of Income and Expense accounts that represent your accounting transactions over a period.
+
+Unlike Balance sheet accounts, Profit and Loss accounts (or PL accounts) do not represent net worth (assets), but rather the amount of money spent and collected in servicing customers during the period. Hence at the beginning and end of your Fiscal Year, they become zero.
+
+(On the first day of the year you have not made any profit or loss, but you still have assets, hence balance sheet accounts never become zero at the beginning or end of a period)
+
+### Groups and Ledgers
+
+There are two main kinds of Accounts in ERPNext - Group and Ledger. Groups can have sub-groups and ledgers within them, whereas ledgers are the leaf nodes of your chart and cannot be further classified.
+
+Accounting Transactions can only be made against Ledger Accounts (not Groups)
+
+> Info: The term "Ledger" means a page in an accounting book where entries are made. There is usually one ledger for each account (like a Customer or a Supplier).
+
+> Note: An Account “Ledger” is also sometimes called as Account “Head”.
+
+### Other Account Types
+
+In ERPNext, you can also specify more information when you create a new Account, this is there to help you select that particular account in a scenario like Bank Account or a Tax Account and has no affect on the Chart itself.
+
+You can also tag if an account represents a Customer, Supplier or Employee in "Master Type".
+
+### Creating / Editing Accounts
+
+To create new Accounts, explore your Chart of Accounts and click on an Account group under which you want to create the new Account. On the right side, you will see a options to “Edit” or “Add” a new Account.
+
+Option to create will only appear if you click on a Group (folder) type Account.
+
+ERPNext creates a standard structure for you when the Company is created but it is up to you to modify or add or remove accounts.
+
+Typically, you might want to create Accounts for
+
+- Types of Expenses (travel, salaries, telephone etc) under Expenses.
+- Taxes (VAT, Sales Tax etc based on your country) under Current Liabilities.
+- Types of Sales (for example, Product Sales, Service Sales etc.) under Income.
+- Types of Assets (building, machinery, furniture etc.) under Fixed Assets.
+
+---
+
+## Chart of Cost Centers
+
+Your Chart of Accounts is mainly for reporting your information for governmental purposes and less for how you business actually performs. Though you can tweak it a bit to resemble your business.
+
+Most businesses have multiple activities like different product lines, market segments, areas of business that share some common overheads but should ideally have their own structure to report whether they are profitable or not. For this purpose, there is an alternate structure, called the Chart of Cost Centers.
+
+You can create a tree of Cost Centers to represent your business better. Each Income / Expense entry is also tagged against a Cost Center.
+
+For example, if you have two types of sales:
+
+- Walk-in Sales
+- Online Sales
+
+You may not have shipping expenses for your walk-in customers, and no shop-rent for your online customers. If you want to get the profitability of each of these separately, you create the two as Cost Centers and you can mark all sales as either "Walk-in" or "Online" and also all your purchases in the same way.
+
+So when you do your analysis you can get a better idea which side of your business is doing better. Since ERPNext has option to add multiple Companies, you can create Cost Centers for each Company and manage it separately.
+
+To setup your Chart of Cost Centers go to:
+
+> Accounts > Chart of Cost Centers
+
+Cost centers help you in one more activity, budgeting.
+
+### Budgeting
+
+ERPNext will help you set and manage budgets on your Cost Centers. This is useful when, for example, you are doing online sales and you have a budget for search ads and you want ERPNext to stop or warn you from over spending based on that budget.
+
+Budgets are also great for planning purposes. When you are making your plans for the next financial year, you would typically target a revenue and based on that you would set your expenses. Setting a budget will ensure that your expenses do not get out of hand at any point based on your plans.
+
+You can define it in the Cost Center. If you have seasonal sales you can also define a budget distribution that the budget will follow.
+
+#### Budget Actions
+
+ERPNext allows you to either:
+
+- Stop.
+- Warn or,
+- Ignore
+
+if you exceed budgets.
+
+These can be defined from the Company record.
+
+Even if you choose to “ignore” budget overruns, you will get a wealth of information from the “Budget vs Actual” variance report.
+
+> Note: When you set a budget, it has to be set per Account under the Cost Center. For example if you have a Cost Center “Online Sales”, you can restrict “Advertising Budget” by creating a row with that Account and defining the amount.
\ No newline at end of file
diff --git a/docs/docs.user.setup.before.md b/docs/docs.user.setup.before.md
new file mode 100644
index 0000000000..158890f3a8
--- /dev/null
+++ b/docs/docs.user.setup.before.md
@@ -0,0 +1,35 @@
+---
+{
+ "_label": "Before We Start",
+ "_title_image": "img/before-we-start.png"
+}
+---
+## Before We Start
+
+We have seem dozens of ERP implementations over the past few years and we realize that successful implementations are a lot about intangibles and attitude.
+
+> The Benefits come Later
+
+ERPs are not required.
+
+Like exercise.
+
+Human body does not require to be exercised today or maybe tomorrow, but in the long run, if you wish to maintain your body and its health, you should get on the treadmill.
+
+In the same way, ERPs improve the health of your organization over a long run by keep it fit and efficient. The more you delay putting things in order, the more time you lose and the closer you get to a major disaster.
+
+So when you start implementing an ERP, keep your sight on the long term benefits. Like exercise, its painful in the short run, but will do wonders if you stay on course.
+
+---
+
+## The Champion
+
+ERP means organization wide change and it does not happen without effort. Every change requires a champion and its the duty of the champion to organize and energize the entire team towards implementation. The champion is all the fall guy (or fall gal) incase something goes wrong and hence needs to be resilient. Who becomes a champion without putting effort anyways?
+
+In many organizations we have seen, the champion is most often the owner or a senior manager. Occasionally, the champion is an outsider who is hired for the purpose.
+
+In either case, you must identify your champion first.
+
+Most likely its **you!**
+
+Lets Begin!
diff --git a/docs/docs.user.setup.codification.md b/docs/docs.user.setup.codification.md
new file mode 100644
index 0000000000..650e173114
--- /dev/null
+++ b/docs/docs.user.setup.codification.md
@@ -0,0 +1,64 @@
+---
+{
+ "_label": "Item Codification"
+}
+---
+
+> To Codify or Not To Codify, is the question.
+
+If you already have a running business with a number of physical items, you would have probably coded your items. If you have not, you have a choice. We recommend you should codify, but its your call.
+
+Item codification is always a sensitive topic and wars have been fought on this (not joking). In our experience, when you have items that cross a certain size, life without codification is a nightmare.
+
+### Benefits
+
+- Standard way of naming things.
+- Less likely to have duplicates.
+- Explicit definition.
+- Help you quickly find if a similar item exists.
+- Item names get longer and longer as more types get introduced. Codes are shorter.
+
+### Pain
+
+- You have to remember the codes!
+- Harder for new team members to pick up.
+- You have to create new codes all the time.
+
+### Example
+
+You should have a simple manual / cheat-sheet to codify your items instead of just numbering them sequentially. Each letter should mean something. Here is an example:
+
+If your business involves wooden furniture, then you may codify as follows:
+
+Item Codification Summary Sheet
+(SAMPLE)
+
+ First letter: "Material" Third letter: "Size"
+
+ - W - Wood - 0 - less than 1mm
+ - H - Hardware - 1 - 1mm - 5mm
+ - G - Glass - 2 - 5mm - 10mm
+ - U - Upholstery - 3 - 10mm - 10cm
+ - P - Plastic
+
+ Second Letter: "Type"
+
+ For Wood: For Hardware:
+
+ - S - Sheet - S - Screw
+ - B - Bar - N - Nut
+ - L - L-section - W - Washer
+ - M - Molded - B - Bracket
+ - R - Round
+
+The last few letters could be sequential. So by looking at code **WM304** - you know its a wooden molding less than 10cm in size
+
+### Standardization
+
+If you have more than one person naming items, the style of naming items will change for everyone. Sometimes, even for one person, he or she may forget how did they name the item and may create a duplicate name _"Wooden Sheet 3mm" or "3mm Sheet of Wood"?_
+
+### Rationalizing
+
+It is a good practice to have minimum varieties of items so that you keep minimum stock, housekeeping is simpler etc. When you are planning a new product and you want to know if you are already purchasing a part in some other product, the item codes will help you quickly determine if you are using a similar raw material in another product.
+
+We believe if you do this small investment, it will help you rationalize things as your business grows, though its okay not to codify if you have less items.
\ No newline at end of file
diff --git a/docs/docs.user.setup.customer.md b/docs/docs.user.setup.customer.md
new file mode 100644
index 0000000000..829f9439bd
--- /dev/null
+++ b/docs/docs.user.setup.customer.md
@@ -0,0 +1,65 @@
+---
+{
+ "_label": "Foundation: Customer",
+ "_title_image": "img/customers.png"
+}
+---
+You can either directly create your Customers via
+
+> Selling > Customer
+
+or upload it via the Data Import Tool.
+
+In your normal operations, you can also create Customers from Leads.
+
+> Note: Customers are separate from Contacts and Addresses. A Customer can have multiple Contacts and Addresses.
+
+### Contacts and Addresses
+
+Contacts and Addresses in ERPNext are stored separately so that you can attach multiple Contacts or Addresses to Customers and Suppliers.
+
+To add a Contact or Address directly from the Customer record, click on “New Contact” or “New Address”.
+
+> Tip: When you select a Customer in any transaction, one Contact and Address gets pre-selected. This is the “Default Contact or Address”. So make sure you set your defaults correctly!
+
+To Import multiple Contacts and Addresses from a spreadsheet, use the Data Import Tool.
+
+### Integration with Accounts
+
+In ERPNext, there is a separate Account record for each Customer, for each Company.
+
+When you create a new Customer, ERPNext will automatically create an Account Ledger for the Customer under “Accounts Receivable” in the Company set in the Customer record.
+
+> Advanced Tip: If you want to change the Account Group under which the Customer Account is created, you can set it in the Company master.
+
+If you want to create an Account in another Company, just change the Company value and “Save” the Customer again.
+
+### Customer Settings
+
+You can link a Price List to a Customer (select “Default Price List”), so that when you select that Customer, the Price List will be automatically selected.
+
+You can set “Credit Days” so that it is automatically set in the Sales Invoices made against this Customer.
+
+You can set how much credit you want to allow for a Customer by adding the “Credit Limit”. You can also set a global “Credit Limit” in the Company master.Classifying Customers
+
+ERPNext allows you to group your Customers and also divide them into Territories. Grouping will help you get better analysis of your data and identify what Customers are profitable and which are not and Territories will help you set sales targets for the territories.
+
+### Customer Group
+
+You can group your Customers so that you can get trend analysis for each group. Typically Customers are grouped by market segment (that is usually based on your domain).
+
+> Tip: If you think all this is too much effort, you can leave it at “Default Customer Group”. But all this effort, will pay off when you start getting reports.
+
+### Territory
+
+If your business operates in multiple Territories (could be countries, states or cities) it is usually a great idea to build your structure in the system. Once you group your Customers by Territories, you can set annual targets for each Item Group and get reports that will show your actual performance in the territory v/s what you had planned.
+
+### Sales Person
+
+Sales Persons behave exactly like Territories. You can great an organization chart of Sales Persons where each Sales Person’s target can be set individually. Again as in Territory, the target has to be set against Item Group.
+
+### Sales Partner
+
+A Sales Partner is a third party distributor / dealer / commission agent / affiliate / reseller who sells the companies products, for a commission. This is useful if you make the end sale to the Customer, involving your Sales Partner.
+
+If you sell to your Sales Partner who in-turn sells it to the Customer, then you must make a Customer instead.
diff --git a/docs/docs.user.setup.first.md b/docs/docs.user.setup.first.md
new file mode 100644
index 0000000000..759c14c851
--- /dev/null
+++ b/docs/docs.user.setup.first.md
@@ -0,0 +1,14 @@
+---
+{
+ "_label": "Initial Setup"
+}
+---
+After a successful sign-up / installation of ERPNext, on your first sign-in, you will be shown a form to fill.
+
+This form will create your first **Company** and **Fiscal Year** (accounting or financial year) record. You can create other Companies later.
+
+This will also set the default **Currency** and time zone for your account. Once your complete this, your first **Company** and **Chart of Accounts** will be created.
+
+Congrats! You are already on your way.
+
+The next step is to configure your Chart of Accounts or start adding users and setting their permissions.
diff --git a/docs/docs.user.setup.item.md b/docs/docs.user.setup.item.md
new file mode 100644
index 0000000000..e85876ba89
--- /dev/null
+++ b/docs/docs.user.setup.item.md
@@ -0,0 +1,106 @@
+---
+{
+ "_label": "Foundation: Item",
+ "_title_image": "img/items.png"
+}
+---
+Items, Customers and Suppliers form the foundation of any ERP system.
+
+It is very likely you will have your masters ready in another system or a spread sheet and you would just need to import them. Before importing, it might be a good idea to understand how ERPNext treats them a bit first.
+
+---
+
+## Items
+
+An Item is simply a product or service you sell or buy from your Customers or Suppliers. ERPNext is optimized for itemized management of your sales and purchase though you can skip creating Items. If you are in services, you can create an Item for each service that your offer.
+
+> Items are mandatory if you want to track inventory.
+
+There are two main categories of Items in ERPNext
+
+- Stock Items
+- Non Stock Items
+
+As you may have guessed, inventory balances are tracked for stock items and not for
+non-stock items. Non-stock items could be services or consumables that are not tracked.
+
+### Naming Items
+
+This is a complex topic [coming up next]. In ERPNext you can use item codes or names. If you do not want to codify, you can keep the item name and item code as the same.
+
+### Item Groups
+
+ERPNext allows you to classify items into groups. This will help you in getting reports about various classes of items and also help in cataloging your items for the website.
+
+### Warehouses
+
+In ERPNext you can create Warehouses to identify where your Items reside.
+
+There are two main Warehouse Types that are significant in ERPNext.
+
+Stores: These are where your incoming Items are kept before they are consumed or sold. You can have as many “Stores” type Warehouses as you wish. Stores type warehouses are significant because if you set an Item for automatic re-order, ERPNext will check its quantities in all “Stores” type Warehouses when deciding whether to re-order or not.
+
+Asset: Items marked as type “Fixed Asset” are maintained in Asset Type Warehouses. This helps you separate them for the Items that are consumed as a part of your regular operations or “Cost of Goods Sold”.
+
+### Item Taxes
+
+These settings are only required if this particular Item has a different tax rate than what is the rate defined in the standard tax Account.
+
+For example, you have a tax Account, “VAT 10%” and this particular item is exempted from this tax, then you select “VAT 10%” in the first column, and set “0” as the tax rate in the second column.
+
+### Inspection
+
+Inspection Required: If an incoming inspection (at the time of delivery from the Supplier) is mandatory for this Item, mention “Inspection Required” as “Yes”. The system will ensure that a Quality Inspection will be prepared and approved before a Purchase Receipt is submitted.
+
+Inspection Criterial: If a Quality Inspection is prepared for this Item, then this template of criteria can will automatically be updated in the Quality Inspection table of the Quality Inspection. Examples of Criteria are: Weight, Length, Finish etc.
+
+### Item Pricing and Price Lists
+
+ERPNext lets you maintain multiple selling prices for an Item using Price Lists. A Price List is a name you can give to a set of Item prices.
+
+Why would you want Price Lists? You have different prices for different zones (based on the shipping costs), for different currencies, regions etc.
+
+### Item Valuation
+
+How are Items Valued?
+
+One of the major features of any inventory system is that you can find out the value of any item based on its historic or average price. You can also find the value of all your items for your balance sheet. Why is valuation important?
+
+- The buying price fluctuates.
+- The value changes because of some process (value add).
+- The value changes because of decay, loss etc.
+
+You may encounter these terms, so lets clarify:
+
+- Rate: Rate at which the transaction takes place.
+- Valuation Rate: Rate at which the items value is set for your valuation.
+
+There are two major ways in which ERPNext values your items.
+
+- **FIFO (First In First Out):** In this system, ERPNext assumes that you will consume / sell those Items first that you bought first. For example, if you buy an Item at price X and then after a few days at price Y. So when sell your Item, ERPNext will reduce the quantity of the Item priced at X first and then Y.
+
+
+
+- **Moving Average:** In this method, ERPNext assumes that the value of the item at any point is the average price of the units of that Item in stock. For example, if the value of an Item is X in a Warehouse with quantity Y and another quantity Y1 is added to the Warehouse at cost X1, the new value X2 would be:
+
+> New Value X2 = (X * Y + X1 * Y1) / (Y + Y1)
+
+#### Negative Stock
+
+FIFO is the more accurate system of the two but has a disadvantage. You cannot have negative stock in FIFO. This means that you cannot make forward transactions that would make your stock negative. Why is this? Because sequences are so important to FIFO, you cannot track the value of the stock if it does not exist!
+
+In Moving Average, since each item has an “average” value, the value of the negative stock is also based on this “average”.
+
+### Serial Numbers and Batches
+
+In scenarios where you may have to track individual units or batches of Items you sell, ERPNext allows you to manage Serial Numbers and Batches.
+
+Why is this useful?
+
+- To track warranty and returns.
+- To trace individual Items incase they are recalled by the Supplier.
+- To manage expiry.
+
+In ERPNext, Serial Number and Batch are separate entities and all stock transactions for Items that serialized or batches must be tagged with either the Batch or Serial Number.
+
+> Important: Once you mark an item as serialized or batched or neither, you cannot change it after you have make any stock entry.
diff --git a/docs/docs.user.setup.md b/docs/docs.user.setup.md
new file mode 100644
index 0000000000..4bc4aeef12
--- /dev/null
+++ b/docs/docs.user.setup.md
@@ -0,0 +1,19 @@
+---
+{
+ "_label": "Setting Up",
+ "_toc": [
+ "docs.user.setup.before",
+ "docs.user.setup.strategy",
+ "docs.user.setup.first",
+ "docs.user.setup.accounting",
+ "docs.user.setup.item",
+ "docs.user.setup.customer",
+ "docs.user.setup.supplier"
+ ]
+}
+---
+Setting up an ERP system is like starting your business all over again, but in the virtual
+world. Thankfully its not as hard as the real thing and you get to do a trial too.
+
+The important thing to note is that if you really want to take benefit out of this project, then you must take a step back and make sometime to do this right. This is usually not couple-of-hours after work kind of a project.
+
diff --git a/docs/docs.user.setup.strategy.md b/docs/docs.user.setup.strategy.md
new file mode 100644
index 0000000000..66755369bb
--- /dev/null
+++ b/docs/docs.user.setup.strategy.md
@@ -0,0 +1,30 @@
+---
+{
+ "_label": "Implementation Strategy"
+}
+---
+Before you start managing your Operations in EPRNext, you must first become familiar with the system and the terms used. For this we recommend implementation should happen in two phases.
+
+- A Test Phase, where you enter dummy records representing your day to day transactions and a - Live Phase, where we start entering live data.
+
+### Test Phase
+
+- Read the Manual
+- Create your first Customer, Supplier and Item. Add a few more so you get familiar.
+- Create Customer Groups, Item Groups, Warehouses, Supplier Groups so that you can classify your Items.
+- Complete a standard sales cycle - Lead > Opportunity > Quotation > Sales Order > Delivery Note > Sales Invoice > Payment (Journal Voucher)
+- Complete a standard purchase cycle - Purchase Request > Purchase Order > Purchase Receipt > Payment (Journal Voucher).
+- Complete a manufacturing cycle (if applicable) - BOM > Production Planning Tool > Production Order > Stock Entry (issue) > Stock Entry (back-flush)
+
+> Tip: Use the 30-day free trial at [erpnext.com](https://erpnext.com) to do your test drive.
+
+### Live Phase
+
+Once you have made yourself familiar with ERPNext, start entering your live data!
+
+- Clean up the account of test data or better, start a fresh install.
+- Setup all the modules with Customer Groups, Item Groups, Warehouses, BOMs etc.
+- Import Customers, Suppliers, Items, Contacts and Addresses using Data Import Tool.
+- Import opening stock using Stock Reconciliation Tool.
+- Create opening accounting entries via Journal Voucher and create outstanding Sales Invoices and Purchase Invoices.
+
diff --git a/home/page/activity/activity.css b/home/page/activity/activity.css
index f3988b275d..34562cb6a8 100644
--- a/home/page/activity/activity.css
+++ b/home/page/activity/activity.css
@@ -1,20 +1,20 @@
-#activity-list .label {
+#page-activity .label {
display: inline-block;
width: 100px;
margin-right: 7px;
}
-#activity-list .label-info {
+#page-activity .label-info {
cursor: pointer;
}
-#activity-list .user-info {
+#page-activity .user-info {
float: right;
color: #777;
font-size: 10px;
}
-#activity-list .date-sep {
+#page-activity .date-sep {
margin-bottom: 11px;
padding: 5px 0px;
border-bottom: 1px solid #aaa;
diff --git a/home/page/activity/activity.html b/home/page/activity/activity.html
deleted file mode 100644
index 9fb910cab3..0000000000
--- a/home/page/activity/activity.html
+++ /dev/null
@@ -1,7 +0,0 @@
-
\
- Please specify correct value in 'Enter Row' column of Row: "
- + taxes[i].idx + " in Taxes table");
- validated = false;
- taxes[i].included_in_print_rate = 0;
- refresh_field('included_in_print_rate', taxes[i].name, other_fname);
- } else if ((taxes[i].included_in_print_rate && !taxes[taxes[i].row_id-1].included_in_print_rate) ||
- (!taxes[i].included_in_print_rate && taxes[taxes[i].row_id-1].included_in_print_rate)) {
- msgprint("If any row in the tax table depends on 'Previous Row Amount/Total', \
- 'Is this Tax included in Basic Rate?' column should be same for both row \
- i.e for that row and the previous row.
\
- The same is violated for row #"+(i+1)+" and row #"+taxes[i].row_id
- );
- validated = false;
- }
- }
-}
-
-cur_frm.cscript.calculate_charges = function(doc, cdt, cdn) {
- var other_fname = cur_frm.cscript.other_fname;
-
- var cl = getchildren('Sales Taxes and Charges', doc.name, other_fname, doc.doctype);
- for(var i = 0; i 100){
- alert("Commision rate cannot be greater than 100.");
- doc.total_commission = 0;
- doc.commission_rate = 0;
- } else {
- doc.total_commission = doc.net_total * doc.commission_rate / 100;
- }
- refresh_many(['total_commission','commission_rate']);
-
-}
-
-// *******Total Commission Trigger (calculates commission rate)*********
-cur_frm.cscript.total_commission = function(doc, cdt, cdn) {
- if(doc.net_total){
- if(doc.net_total < doc.total_commission){
- alert("Total commission cannot be greater than net total.");
- doc.total_commission = 0;
- doc.commission_rate = 0;
- } else {
- doc.commission_rate = doc.total_commission * 100 / doc.net_total;
- }
- refresh_many(['total_commission','commission_rate']);
- }
-}
-// Sales Person Allocated % trigger
-// ==============================================================================
-cur_frm.cscript.allocated_percentage = function(doc, cdt, cdn) {
- var fname = cur_frm.cscript.sales_team_fname;
- var d = locals[cdt][cdn];
- if (d.allocated_percentage) {
- d.allocated_amount = flt(flt(doc.net_total)*flt(d.allocated_percentage)/100);
- refresh_field('allocated_amount', d.name, fname);
- }
-}
-
-// Client Side Validation
-// =================================================================================
-cur_frm.cscript.validate = function(doc, cdt, cdn) {
- cur_frm.cscript.validate_items(doc);
- var cl = getchildren('Sales Taxes and Charges Master', doc.name, 'other_charges');
- for(var i =0;i now()
- or end_of_life = '0000-00-00') and (is_sales_item = 'Yes'
- or is_service_item = 'Yes')""", args['item_code'], as_dict=1)
-
- tax = webnotes.conn.sql("""select tax_type, tax_rate from `tabItem Tax`
- where parent = %s""", args['item_code'])
- t = {}
- for x in tax: t[x[0]] = flt(x[1])
- ret = {
- 'description': item and item[0]['description_html'] or \
- item[0]['description'],
- 'barcode': item and item[0]['barcode'] or '',
- 'item_group': item and item[0]['item_group'] or '',
- 'item_name': item and item[0]['item_name'] or '',
- 'brand': item and item[0]['brand'] or '',
- 'stock_uom': item and item[0]['stock_uom'] or '',
- 'reserved_warehouse': item and item[0]['default_warehouse'] or '',
- 'warehouse': item and item[0]['default_warehouse'] or \
- args.get('warehouse'),
- 'income_account': item and item[0]['default_income_account'] or \
- args.get('income_account'),
- 'expense_account': item and item[0]['purchase_account'] or \
- args.get('expense_account'),
- 'cost_center': item and item[0]['default_sales_cost_center'] or \
- args.get('cost_center'),
- # this is done coz if item once fetched is fetched again than its qty shld be reset to 1
- 'qty': 1.00,
- 'adj_rate': 0,
- 'amount': 0,
- 'export_amount': 0,
- 'item_tax_rate': json.dumps(t),
- 'batch_no': ''
- }
- if(obj.doc.price_list_name and item): #this is done to fetch the changed BASIC RATE and REF RATE based on PRICE LIST
- base_ref_rate = self.get_ref_rate(args['item_code'], obj.doc.price_list_name, obj.doc.price_list_currency, obj.doc.plc_conversion_rate)
- ret['ref_rate'] = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
- ret['export_rate'] = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
- ret['base_ref_rate'] = flt(base_ref_rate)
- ret['basic_rate'] = flt(base_ref_rate)
-
- if ret['warehouse'] or ret['reserved_warehouse']:
-
- av_qty = self.get_available_qty({'item_code': args['item_code'], 'warehouse': ret['warehouse'] or ret['reserved_warehouse']})
- ret.update(av_qty)
-
- # get customer code for given item from Item Customer Detail
- customer_item_code_row = webnotes.conn.sql("""\
- select ref_code from `tabItem Customer Detail`
- where parent = %s and customer_name = %s""",
- (args['item_code'], obj.doc.customer))
- if customer_item_code_row and customer_item_code_row[0][0]:
- ret['customer_item_code'] = customer_item_code_row[0][0]
-
- return ret
-
-
- def get_item_defaults(self, args):
- item = webnotes.conn.sql("""select default_warehouse, default_income_account,
- default_sales_cost_center, purchase_account from `tabItem` where name = %s
- and (ifnull(end_of_life,'') = '' or end_of_life > now() or end_of_life = '0000-00-00')
- and (is_sales_item = 'Yes' or is_service_item = 'Yes') """,
- (args['item_code']), as_dict=1)
- ret = {
- 'reserved_warehouse': item and item[0]['default_warehouse'] or '',
- 'warehouse': item and item[0]['default_warehouse'] or args.get('warehouse'),
- 'income_account': item and item[0]['default_income_account'] or \
- args.get('income_account'),
- 'expense_account': item and item[0]['purchase_account'] or args.get('expense_account'),
- 'cost_center': item and item[0]['default_sales_cost_center'] or args.get('cost_center'),
- }
-
- return ret
-
- def get_available_qty(self,args):
- tot_avail_qty = webnotes.conn.sql("select projected_qty, actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (args['item_code'], args['warehouse']), as_dict=1)
- ret = {
- 'projected_qty' : tot_avail_qty and flt(tot_avail_qty[0]['projected_qty']) or 0,
- 'actual_qty' : tot_avail_qty and flt(tot_avail_qty[0]['actual_qty']) or 0
- }
- return ret
-
-
- # ***************** Get Ref rate as entered in Item Master ********************
- def get_ref_rate(self, item_code, price_list_name, price_list_currency, plc_conv_rate):
- ref_rate = webnotes.conn.sql("select ref_rate from `tabItem Price` where parent = %s and price_list_name = %s and ref_currency = %s and selling=1",
- (item_code, price_list_name, price_list_currency))
- base_ref_rate = ref_rate and flt(ref_rate[0][0]) * flt(plc_conv_rate) or 0
- return base_ref_rate
-
- def get_barcode_details(self, barcode):
- item = webnotes.conn.sql("select name, end_of_life, is_sales_item, is_service_item \
- from `tabItem` where barcode = %s", barcode, as_dict=1)
- ret = {}
- if not item:
- msgprint("""No item found for this barcode: %s.
- May be barcode not updated in item master. Please check""" % barcode)
- elif item[0]['end_of_life'] and getdate(cstr(item[0]['end_of_life'])) < nowdate():
- msgprint("Item: %s has been expired. Please check 'End of Life' field in item master" % item[0]['name'])
- elif item[0]['is_sales_item'] == 'No' and item[0]['is_service_item'] == 'No':
- msgprint("Item: %s is not a sales or service item" % item[0]['name'])
- elif len(item) > 1:
- msgprint("There are multiple item for this barcode. \nPlease select item code manually")
- else:
- ret = {'item_code': item and item[0]['name'] or ''}
-
- return ret
-
-
- # ****** Re-cancellculates Basic Rate & amount based on Price List Selected ******
- def get_adj_percent(self, obj):
- for d in getlist(obj.doclist, obj.fname):
- base_ref_rate = self.get_ref_rate(d.item_code, obj.doc.price_list_name, obj.doc.price_list_currency, obj.doc.plc_conversion_rate)
- d.adj_rate = 0
- d.ref_rate = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
- d.basic_rate = flt(base_ref_rate)
- d.base_ref_rate = flt(base_ref_rate)
- d.export_rate = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
- d.amount = flt(d.qty)*flt(base_ref_rate)
- d.export_amount = flt(d.qty)*flt(base_ref_rate)/flt(obj.doc.conversion_rate)
-
-
- # Load Default Taxes
- # ====================
- def load_default_taxes(self, obj):
- if cstr(obj.doc.charge):
- return self.get_other_charges(obj)
- else:
- return self.get_other_charges(obj, 1)
-
-
- # Get other charges from Master
- # =================================================================================
- def get_other_charges(self,obj, default=0):
- obj.doclist = obj.doc.clear_table(obj.doclist, 'other_charges')
- if not getlist(obj.doclist, 'other_charges'):
- if default: add_cond = 'ifnull(t2.is_default,0) = 1'
- else: add_cond = 't1.parent = "'+cstr(obj.doc.charge)+'"'
- idx = 0
- other_charge = webnotes.conn.sql("""\
- select t1.*
- from
- `tabSales Taxes and Charges` t1,
- `tabSales Taxes and Charges Master` t2
- where
- t1.parent = t2.name and
- t2.company = '%s' and
- %s
- order by t1.idx""" % (obj.doc.company, add_cond), as_dict=1)
- from webnotes.model import default_fields
- for other in other_charge:
- # remove default fields like parent, parenttype etc.
- # from query results
- for field in default_fields:
- if field in other: del other[field]
-
- d = addchild(obj.doc, 'other_charges', 'Sales Taxes and Charges',
- obj.doclist)
- d.fields.update(other)
- d.rate = flt(d.rate)
- d.tax_amount = flt(d.tax_rate)
- d.included_in_print_rate = cint(d.included_in_print_rate)
- d.idx = idx
- idx += 1
- return obj.doclist
# Get TERMS AND CONDITIONS
# =======================================================================================
@@ -329,23 +116,6 @@ class DocType(TransactionBase):
}
return ret
- # Get Commission rate
- # =======================================================================
- def get_comm_rate(self, sales_partner, obj):
-
- comm_rate = webnotes.conn.sql("select commission_rate from `tabSales Partner` where name = '%s' and docstatus != 2" %(sales_partner), as_dict=1)
- if comm_rate:
- total_comm = flt(comm_rate[0]['commission_rate']) * flt(obj.doc.net_total) / 100
- ret = {
- 'commission_rate' : comm_rate and flt(comm_rate[0]['commission_rate']) or 0,
- 'total_commission' : flt(total_comm)
- }
- return ret
- else:
- msgprint("Business Associate : %s does not exist in the system." % (sales_partner))
- raise Exception
-
-
# To verify whether rate entered in details table does not exceed max discount %
# =======================================================================================
def validate_max_discount(self,obj, detail_table):
@@ -354,16 +124,6 @@ class DocType(TransactionBase):
if discount and discount[0]['max_discount'] and (flt(d.adj_rate)>flt(discount[0]['max_discount'])):
msgprint("You cannot give more than " + cstr(discount[0]['max_discount']) + " % discount on Item Code : "+cstr(d.item_code))
raise Exception
-
-
- # Get sum of allocated % of sales person (it should be 100%)
- # ========================================================================
- # it indicates % contribution of sales person in sales
- def get_allocated_sum(self,obj):
- sales_team_list = obj.doclist.get({"parentfield": "sales_team"})
- total_allocation = sum([flt(d.allocated_percentage) for d in sales_team_list])
- if sales_team_list and total_allocation != 100.0:
- msgprint("Total Allocated % of Sales Persons should be 100%", raise_exception=True)
# Check Conversion Rate (i.e. it will not allow conversion rate to be 1 for Currency other than default currency set in Global Defaults)
# ===========================================================================
diff --git a/selling/doctype/sales_order/sales_order.js b/selling/doctype/sales_order/sales_order.js
index b792754384..ded9c447e8 100644
--- a/selling/doctype/sales_order/sales_order.js
+++ b/selling/doctype/sales_order/sales_order.js
@@ -26,105 +26,54 @@ wn.require('app/selling/doctype/sales_common/sales_common.js');
wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
-
-cur_frm.cscript.onload = function(doc, cdt, cdn) {
- cur_frm.cscript.manage_rounded_total();
-
- if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
- if(!doc.transaction_date) set_multiple(cdt,cdn,{transaction_date:get_today()});
- if(!doc.price_list_currency) set_multiple(cdt, cdn, {price_list_currency: doc.currency, plc_conversion_rate: 1});
- // load default charges
-
- if(doc.__islocal && !doc.customer){
- hide_field(['customer_address','contact_person', 'customer_name',
- 'address_display', 'contact_display', 'contact_mobile',
- 'contact_email', 'territory', 'customer_group']);
- }
-}
-
-cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
- var callback = function(doc, cdt, cdn) {
- if(doc.__islocal) {
- // defined in sales_common.js
- cur_frm.cscript.update_item_details(doc, cdt, cdn);
- }
- }
-
- cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn, callback);
-
-}
-
-
-cur_frm.cscript.refresh = function(doc, cdt, cdn) {
- cur_frm.clear_custom_buttons();
- erpnext.hide_naming_series();
-
- if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn);
-
- cur_frm.toggle_display("contact_info", doc.customer);
-
- if(doc.docstatus==1) {
- if(doc.status != 'Stopped') {
- cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
- // delivery note
- if(flt(doc.per_delivered, 2) < 100 && doc.order_type=='Sales')
- cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
+erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend({
+ refresh: function(doc, dt, dn) {
+ this._super();
+
+ if(doc.docstatus==1) {
+ if(doc.status != 'Stopped') {
+ cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
+ // delivery note
+ if(flt(doc.per_delivered, 2) < 100 && doc.order_type=='Sales')
+ cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
- // maintenance
- if(flt(doc.per_delivered, 2) < 100 && (doc.order_type !='Sales')) {
- cur_frm.add_custom_button('Make Maint. Visit', cur_frm.cscript.make_maintenance_visit);
- cur_frm.add_custom_button('Make Maint. Schedule', cur_frm.cscript['Make Maintenance Schedule']);
+ // maintenance
+ if(flt(doc.per_delivered, 2) < 100 && (doc.order_type !='Sales')) {
+ cur_frm.add_custom_button('Make Maint. Visit', cur_frm.cscript.make_maintenance_visit);
+ cur_frm.add_custom_button('Make Maint. Schedule', cur_frm.cscript['Make Maintenance Schedule']);
+ }
+
+ // indent
+ if(!doc.order_type || (doc.order_type == 'Sales'))
+ cur_frm.add_custom_button('Make ' + wn._('Material Request'), cur_frm.cscript['Make Material Request']);
+
+ // sales invoice
+ if(flt(doc.per_billed, 2) < 100)
+ cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Sales Invoice']);
+
+ // stop
+ if(flt(doc.per_delivered, 2) < 100 || doc.per_billed < 100)
+ cur_frm.add_custom_button('Stop!', cur_frm.cscript['Stop Sales Order']);
+ } else {
+ // un-stop
+ cur_frm.add_custom_button('Unstop', cur_frm.cscript['Unstop Sales Order']);
}
-
- // indent
- if(!doc.order_type || (doc.order_type == 'Sales'))
- cur_frm.add_custom_button('Make ' + wn._('Material Request'), cur_frm.cscript['Make Material Request']);
-
- // sales invoice
- if(flt(doc.per_billed, 2) < 100)
- cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Sales Invoice']);
-
- // stop
- if(flt(doc.per_delivered, 2) < 100 || doc.per_billed < 100)
- cur_frm.add_custom_button('Stop!', cur_frm.cscript['Stop Sales Order']);
- } else {
- // un-stop
- cur_frm.add_custom_button('Unstop', cur_frm.cscript['Unstop Sales Order']);
}
- }
- cur_frm.cscript.order_type(doc);
-}
-
-cur_frm.cscript.order_type = function(doc) {
- if(doc.order_type == "Sales") {
- cur_frm.toggle_reqd("delivery_date", 1);
- } else {
- cur_frm.toggle_reqd("delivery_date", 0);
- }
-}
-
-//customer
-cur_frm.cscript.customer = function(doc,dt,dn) {
- cur_frm.toggle_display("contact_info", doc.customer);
+ this.order_type(doc);
+ },
- var pl = doc.price_list_name;
- var callback = function(r,rt) {
- var callback2 = function(r, rt) {
- if(doc.customer)
- unhide_field(['customer_address', 'contact_person', 'territory','customer_group']);
- cur_frm.refresh();
-
- if(!onload && (pl != doc.price_list_name)) cur_frm.cscript.price_list_name(doc, dt, dn);
+ order_type: function() {
+ this.frm.toggle_reqd("delivery_date", this.frm.doc.order_type == "Sales");
+ },
+
+ reserved_warehouse: function(doc, cdt, cdn) {
+ this.warehouse(doc, cdt, cdn);
+ },
+});
- }
- var doc = locals[cur_frm.doctype][cur_frm.docname];
- get_server_fields('get_shipping_address',doc.customer,'',doc, dt, dn, 0, callback2);
-
- }
- if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name),
- 'get_default_customer_address', '', callback);
-}
+// for backward compatibility: combine new and previous states
+$.extend(cur_frm.cscript, new erpnext.selling.SalesOrderController({frm: cur_frm}));
cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
@@ -180,15 +129,6 @@ cur_frm.fields_dict['quotation_no'].get_query = function(doc) {
ORDER BY `tabQuotation`.`name` DESC LIMIT 50', {cond:cond});
}
-
-cur_frm.cscript.reserved_warehouse = function(doc, cdt , cdn) {
- var d = locals[cdt][cdn];
- if (d.reserved_warehouse) {
- arg = "{'item_code':'" + d.item_code + "','warehouse':'" + d.reserved_warehouse +"'}";
- get_server_fields('get_available_qty',arg,'sales_order_details',doc,cdt,cdn,1);
- }
-}
-
//----------- make maintenance schedule----------
cur_frm.cscript['Make Maintenance Schedule'] = function() {
var doc = cur_frm.doc;
diff --git a/selling/doctype/sales_order/sales_order.py b/selling/doctype/sales_order/sales_order.py
index c8db1f919f..79b37be0e5 100644
--- a/selling/doctype/sales_order/sales_order.py
+++ b/selling/doctype/sales_order/sales_order.py
@@ -58,22 +58,6 @@ class DocType(SellingController):
def get_comm_rate(self, sales_partner):
return get_obj('Sales Common').get_comm_rate(sales_partner, self)
- def get_item_details(self, args=None):
- import json
- args = args and json.loads(args) or {}
- if args.get('item_code'):
- return get_obj('Sales Common').get_item_details(args, self)
- else:
- obj = get_obj('Sales Common')
- for doc in self.doclist:
- if doc.fields.get('item_code'):
- arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'),
- 'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')};
- ret = obj.get_item_defaults(arg)
- for r in ret:
- if not doc.fields.get(r):
- doc.fields[r] = ret[r]
-
def get_adj_percent(self, arg=''):
get_obj('Sales Common').get_adj_percent(self)
@@ -83,12 +67,6 @@ class DocType(SellingController):
def get_rate(self,arg):
return get_obj('Sales Common').get_rate(arg)
- def load_default_taxes(self):
- self.doclist = get_obj('Sales Common').load_default_taxes(self)
-
- def get_other_charges(self):
- self.doclist = get_obj('Sales Common').get_other_charges(self)
-
def get_tc_details(self):
return get_obj('Sales Common').get_tc_details(self)
@@ -194,6 +172,8 @@ class DocType(SellingController):
and current Sales Order""" % (self.doc.order_type, d.prevdoc_docname))
def validate_order_type(self):
+ super(DocType, self).validate_order_type()
+
#validate delivery date
if self.doc.order_type == 'Sales' and not self.doc.delivery_date:
msgprint("Please enter 'Expected Delivery Date'")
@@ -226,7 +206,6 @@ class DocType(SellingController):
sales_com_obj.check_conversion_rate(self)
sales_com_obj.validate_max_discount(self,'sales_order_details')
- sales_com_obj.get_allocated_sum(self)
self.doclist = sales_com_obj.make_packing_list(self,'sales_order_details')
if not self.doc.status:
diff --git a/selling/doctype/sales_order/sales_order.txt b/selling/doctype/sales_order/sales_order.txt
index ba0b1de07c..fb5848f8c3 100644
--- a/selling/doctype/sales_order/sales_order.txt
+++ b/selling/doctype/sales_order/sales_order.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-07 14:48:34",
+ "creation": "2013-05-24 19:29:08",
"docstatus": 0,
- "modified": "2013-01-29 17:14:58",
+ "modified": "2013-05-28 15:05:38",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -76,42 +76,47 @@
"search_index": 1
},
{
+ "depends_on": "customer",
"doctype": "DocField",
"fieldname": "customer_name",
"fieldtype": "Data",
- "hidden": 1,
+ "hidden": 0,
"label": "Name",
"read_only": 1
},
{
+ "depends_on": "customer",
"doctype": "DocField",
"fieldname": "address_display",
"fieldtype": "Small Text",
- "hidden": 1,
+ "hidden": 0,
"label": "Address",
"read_only": 1
},
{
+ "depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_display",
"fieldtype": "Small Text",
- "hidden": 1,
+ "hidden": 0,
"label": "Contact",
"read_only": 1
},
{
+ "depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_mobile",
"fieldtype": "Text",
- "hidden": 1,
+ "hidden": 0,
"label": "Mobile No",
"read_only": 1
},
{
+ "depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_email",
"fieldtype": "Text",
- "hidden": 1,
+ "hidden": 0,
"label": "Contact Email",
"print_hide": 1,
"read_only": 1
@@ -230,7 +235,8 @@
"oldfieldname": "sales_order_details",
"oldfieldtype": "Table",
"options": "Sales Order Item",
- "print_hide": 0
+ "print_hide": 0,
+ "reqd": 1
},
{
"doctype": "DocField",
@@ -251,11 +257,19 @@
"oldfieldname": "net_total",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
- "print_hide": 0,
+ "print_hide": 1,
"read_only": 1,
"reqd": 0,
"width": "150px"
},
+ {
+ "doctype": "DocField",
+ "fieldname": "net_total_export",
+ "fieldtype": "Currency",
+ "label": "Net Total (Export)",
+ "options": "currency",
+ "read_only": 1
+ },
{
"doctype": "DocField",
"fieldname": "recalculate_values",
@@ -426,7 +440,7 @@
"doctype": "DocField",
"fieldname": "other_charges_total",
"fieldtype": "Currency",
- "label": "Taxes and Charges Total*",
+ "label": "Taxes and Charges Total",
"oldfieldname": "other_charges_total",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
@@ -434,6 +448,15 @@
"read_only": 1,
"width": "150px"
},
+ {
+ "doctype": "DocField",
+ "fieldname": "other_charges_total_export",
+ "fieldtype": "Currency",
+ "label": "Taxes and Charges Total (Export)",
+ "options": "currency",
+ "print_hide": 1,
+ "read_only": 1
+ },
{
"doctype": "DocField",
"fieldname": "other_charges_calculation",
@@ -578,6 +601,7 @@
"print_hide": 0
},
{
+ "depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_info",
"fieldtype": "Section Break",
@@ -955,7 +979,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
- "match": "",
"permlevel": 1,
"report": 0,
"role": "Sales Manager",
@@ -978,7 +1001,6 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
- "match": "",
"permlevel": 0,
"report": 1,
"role": "Sales User",
@@ -990,7 +1012,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
- "match": "",
"permlevel": 1,
"report": 0,
"role": "Sales User",
@@ -1013,7 +1034,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
- "match": "",
"permlevel": 1,
"role": "Maintenance Manager",
"submit": 0
@@ -1034,7 +1054,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
- "match": "",
"permlevel": 1,
"role": "Maintenance User",
"submit": 0
diff --git a/selling/doctype/sales_order_item/sales_order_item.txt b/selling/doctype/sales_order_item/sales_order_item.txt
index c65ac0d938..7276fc329c 100644
--- a/selling/doctype/sales_order_item/sales_order_item.txt
+++ b/selling/doctype/sales_order_item/sales_order_item.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-03-07 11:42:58",
"docstatus": 0,
- "modified": "2013-05-22 12:09:03",
+ "modified": "2013-05-22 12:10:03",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -113,7 +113,7 @@
"options": "currency",
"print_hide": 1,
"print_width": "70px",
- "read_only": 0,
+ "read_only": 1,
"reqd": 0,
"width": "70px"
},
@@ -183,7 +183,7 @@
"options": "Company:company:default_currency",
"print_hide": 1,
"print_width": "100px",
- "read_only": 0,
+ "read_only": 1,
"reqd": 0,
"width": "100px"
},
diff --git a/selling/doctype/sales_team/sales_team.txt b/selling/doctype/sales_team/sales_team.txt
index add466c334..29a951eef7 100644
--- a/selling/doctype/sales_team/sales_team.txt
+++ b/selling/doctype/sales_team/sales_team.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-02-22 01:27:53",
+ "creation": "2013-04-19 13:30:51",
"docstatus": 0,
- "modified": "2013-03-07 07:03:31",
+ "modified": "2013-05-21 17:04:45",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -42,6 +42,7 @@
"doctype": "DocField",
"fieldname": "sales_designation",
"fieldtype": "Data",
+ "hidden": 0,
"label": "Designation",
"oldfieldname": "sales_designation",
"oldfieldtype": "Data",
@@ -63,7 +64,7 @@
"doctype": "DocField",
"fieldname": "allocated_percentage",
"fieldtype": "Float",
- "label": "Allocated (%)",
+ "label": "Contribution (%)",
"oldfieldname": "allocated_percentage",
"oldfieldtype": "Currency",
"print_width": "100px",
@@ -74,11 +75,12 @@
"doctype": "DocField",
"fieldname": "allocated_amount",
"fieldtype": "Currency",
- "label": "Allocated Amount",
+ "label": "Contribution to Net Total",
"oldfieldname": "allocated_amount",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_width": "120px",
+ "read_only": 1,
"reqd": 0,
"width": "120px"
},
diff --git a/selling/page/sales_analytics/sales_analytics.js b/selling/page/sales_analytics/sales_analytics.js
index 0b35af5f31..7fdc3ac641 100644
--- a/selling/page/sales_analytics/sales_analytics.js
+++ b/selling/page/sales_analytics/sales_analytics.js
@@ -23,7 +23,7 @@ wn.pages['sales-analytics'].onload = function(wrapper) {
new erpnext.SalesAnalytics(wrapper);
wrapper.appframe.add_home_breadcrumb()
- wrapper.appframe.add_module_breadcrumb("Selling")
+ wrapper.appframe.add_module_icon("Selling")
wrapper.appframe.add_breadcrumb("icon-bar-chart")
}
diff --git a/selling/page/sales_browser/sales_browser.html b/selling/page/sales_browser/sales_browser.html
deleted file mode 100644
index 4683a0781e..0000000000
--- a/selling/page/sales_browser/sales_browser.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
To add child nodes, explore tree and click on the node under which you want to add more nodes.
-
-
-
-
\ No newline at end of file
diff --git a/selling/page/sales_browser/sales_browser.js b/selling/page/sales_browser/sales_browser.js
index 4622f24a43..ed13f9df31 100644
--- a/selling/page/sales_browser/sales_browser.js
+++ b/selling/page/sales_browser/sales_browser.js
@@ -15,14 +15,22 @@
// along with this program. If not, see .
pscript['onload_Sales Browser'] = function(wrapper){
- wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
- wrapper.appframe.add_home_breadcrumb()
- wrapper.appframe.add_module_breadcrumb("Selling")
+ wn.ui.make_app_page({
+ parent: wrapper,
+ })
+
+ wrapper.appframe.add_module_icon("Selling")
wrapper.appframe.add_button('Refresh', function() {
wrapper.make_tree();
}, 'icon-refresh');
+
+ $(wrapper)
+ .find(".layout-side-section")
+ .html('
Click on a link to get options to expand \
+ get options Add / Edit / Delete.
')
+
wrapper.make_tree = function() {
var ctype = wn.get_route()[1] || 'Territory';
wn.call({
@@ -30,7 +38,13 @@ pscript['onload_Sales Browser'] = function(wrapper){
args: {ctype: ctype},
callback: function(r) {
var root = r.message[0]["value"];
- erpnext.sales_chart = new erpnext.SalesChart(ctype, root, wrapper);
+ erpnext.sales_chart = new erpnext.SalesChart(ctype, root,
+ $(wrapper)
+ .find(".layout-main-section")
+ .css({
+ "min-height": "300px",
+ "padding-bottom": "25px"
+ }));
}
});
}
@@ -50,12 +64,12 @@ pscript['onshow_Sales Browser'] = function(wrapper){
};
erpnext.SalesChart = Class.extend({
- init: function(ctype, root, wrapper) {
- $(wrapper).find('.tree-area').empty();
+ init: function(ctype, root, parent) {
+ $(parent).empty();
var me = this;
me.ctype = ctype;
this.tree = new wn.ui.Tree({
- parent: $(wrapper).find('.tree-area'),
+ parent: $(parent),
label: root,
args: {ctype: ctype},
method: 'selling.page.sales_browser.sales_browser.get_children',
diff --git a/selling/utils.py b/selling/utils.py
index 21e94f7234..6901028710 100644
--- a/selling/utils.py
+++ b/selling/utils.py
@@ -16,6 +16,9 @@
from __future__ import unicode_literals
import webnotes
+from webnotes import msgprint, _
+from webnotes.utils import flt, cint, comma_and
+import json
def get_customer_list(doctype, txt, searchfield, start, page_len, filters):
if webnotes.conn.get_default("cust_master_name") == "Customer Name":
@@ -29,4 +32,149 @@ def get_customer_list(doctype, txt, searchfield, start, page_len, filters):
case when customer_name like %s then 0 else 1 end,
name, customer_name limit %s, %s""" %
(", ".join(fields), searchfield, "%s", "%s", "%s", "%s", "%s", "%s"),
- ("%%%s%%" % txt, "%%%s%%" % txt, "%%%s%%" % txt, "%%%s%%" % txt, start, page_len))
\ No newline at end of file
+ ("%%%s%%" % txt, "%%%s%%" % txt, "%%%s%%" % txt, "%%%s%%" % txt, start, page_len))
+
+@webnotes.whitelist()
+def get_item_details(args):
+ """
+ args = {
+ "item_code": "",
+ "warehouse": None,
+ "customer": "",
+ "conversion_rate": 1.0,
+ "price_list_name": None,
+ "price_list_currency": None,
+ "plc_conversion_rate": 1.0
+ }
+ """
+ if isinstance(args, basestring):
+ args = json.loads(args)
+ args = webnotes._dict(args)
+
+ if args.barcode:
+ args.item_code = _get_item_code(args.barcode)
+
+ item_bean = webnotes.bean("Item", args.item_code)
+
+ _validate_item_details(args, item_bean.doc)
+
+ out = _get_basic_details(args, item_bean)
+
+ meta = webnotes.get_doctype(args.doctype)
+ if meta.get_field("currency"):
+ out.base_ref_rate = out.basic_rate = out.ref_rate = out.export_rate = 0.0
+
+ if args.price_list_name and args.price_list_currency:
+ out.update(_get_price_list_rate(args, item_bean, meta))
+
+ if out.warehouse or out.reserved_warehouse:
+ out.update(get_available_qty(args.item_code, out.warehouse or out.reserved_warehouse))
+
+ out.customer_item_code = _get_customer_item_code(args, item_bean)
+
+ if cint(args.is_pos):
+ pos_settings = get_pos_settings(args.company)
+ out.update(apply_pos_settings(pos_settings, out))
+
+ return out
+
+def _get_item_code(barcode):
+ item_code = webnotes.conn.sql_list("""select name from `tabItem` where barcode=%s""", barcode)
+
+ if not item_code:
+ msgprint(_("No Item found with Barcode") + ": %s" % barcode, raise_exception=True)
+
+ elif len(item_code) > 1:
+ msgprint(_("Items") + " %s " % comma_and(item_code) +
+ _("have the same Barcode") + " %s" % barcode, raise_exception=True)
+
+ return item_code[0]
+
+def _validate_item_details(args, item):
+ from utilities.transaction_base import validate_item_fetch
+ validate_item_fetch(args, item)
+
+ # validate if sales item or service item
+ if args.order_type == "Maintenance":
+ if item.is_service_item != "Yes":
+ msgprint(_("Item") + (" %s: " % item.name) +
+ _("not a service item.") +
+ _("Please select a service item or change the order type to Sales."),
+ raise_exception=True)
+
+ elif item.is_sales_item != "Yes":
+ msgprint(_("Item") + (" %s: " % item.name) + _("not a sales item"),
+ raise_exception=True)
+
+def _get_basic_details(args, item_bean):
+ item = item_bean.doc
+ out = webnotes._dict({
+ "item_code": item.name,
+ "description": item.description_html or item.description,
+ "reserved_warehouse": item.default_warehouse,
+ "warehouse": item.default_warehouse or args.warehouse,
+ "income_account": item.default_income_account or args.income_account,
+ "expense_account": item.purchase_account or args.expense_account,
+ "cost_center": item.default_sales_cost_center or args.cost_center,
+ "qty": 1.0,
+ "adj_rate": 0.0,
+ "export_amount": 0.0,
+ "amount": 0.0,
+ "batch_no": None,
+ "item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in
+ item_bean.doclist.get({"parentfield": "item_tax"})))),
+ })
+
+ for fieldname in ("item_name", "item_group", "barcode", "brand", "stock_uom"):
+ out[fieldname] = item.fields.get(fieldname)
+
+ return out
+
+def _get_price_list_rate(args, item_bean, meta):
+ base_ref_rate = item_bean.doclist.get({
+ "parentfield": "ref_rate_details",
+ "price_list_name": args.price_list_name,
+ "price_list_currency": args.price_list_currency,
+ "selling": 1})
+
+ if not base_ref_rate:
+ return {}
+
+ # found price list rate - now we can validate
+ from utilities.transaction_base import validate_currency
+ validate_currency(args, item_bean.doc, meta)
+
+ return {"ref_rate": flt(base_ref_rate[0].ref_rate * args.plc_conversion_rate / args.conversion_rate)}
+
+@webnotes.whitelist()
+def get_available_qty(item_code, warehouse):
+ return webnotes.conn.get_value("Bin", {"item_code": item_code, "warehouse": warehouse},
+ ["projected_qty", "actual_qty"], as_dict=True) or {}
+
+def _get_customer_item_code(args, item_bean):
+ customer_item_code = item_bean.doclist.get({"parentfield": "item_customer_details",
+ "customer_name": args.customer})
+
+ return customer_item_code and customer_item_code[0].ref_code or None
+
+def get_pos_settings(company):
+ pos_settings = webnotes.conn.sql("""select * from `tabPOS Setting` where user = %s
+ and company = %s""", (webnotes.session['user'], company), as_dict=1)
+
+ if not pos_settings:
+ pos_settings = webnotes.conn.sql("""select * from `tabPOS Setting`
+ where ifnull(user,'') = '' and company = %s""", company, as_dict=1)
+
+ return pos_settings and pos_settings[0] or None
+
+def apply_pos_settings(pos_settings, opts):
+ out = {}
+
+ for fieldname in ("income_account", "cost_center", "warehouse", "expense_account"):
+ if not opts.get(fieldname):
+ out[fieldname] = pos_settings.get(fieldname)
+
+ if out.get("warehouse"):
+ out["actual_qty"] = get_available_qty(opts.item_code, out.get("warehouse")).get("actual_qty")
+
+ return out
diff --git a/setup/doctype/global_defaults/global_defaults.py b/setup/doctype/global_defaults/global_defaults.py
index dc7f6b4b73..2d28009650 100644
--- a/setup/doctype/global_defaults/global_defaults.py
+++ b/setup/doctype/global_defaults/global_defaults.py
@@ -46,7 +46,6 @@ keydict = {
'maintain_same_rate' : 'maintain_same_rate',
'session_expiry': 'session_expiry',
'disable_rounded_total': 'disable_rounded_total',
- "update_stock": "update_stock",
"auto_inventory_accounting": "auto_inventory_accounting",
}
diff --git a/setup/doctype/global_defaults/global_defaults.txt b/setup/doctype/global_defaults/global_defaults.txt
index 175ca9414b..16954a0f32 100644
--- a/setup/doctype/global_defaults/global_defaults.txt
+++ b/setup/doctype/global_defaults/global_defaults.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-02 17:53:24",
"docstatus": 0,
- "modified": "2013-05-22 15:57:26",
+ "modified": "2013-05-30 12:23:34",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -27,8 +27,6 @@
"permlevel": 0
},
{
- "amend": 0,
- "cancel": 0,
"create": 1,
"doctype": "DocPerm",
"name": "__common__",
@@ -326,14 +324,6 @@
"fieldtype": "Column Break",
"read_only": 0
},
- {
- "description": "If checked, then in POS Sales Invoice, Update Stock gets checked by default",
- "doctype": "DocField",
- "fieldname": "update_stock",
- "fieldtype": "Check",
- "label": "Update Stock when using POS Sales Invoice",
- "read_only": 0
- },
{
"doctype": "DocField",
"fieldname": "account_info",
@@ -526,6 +516,11 @@
"label": "SMS Sender Name",
"read_only": 0
},
+ {
+ "amend": 0,
+ "cancel": 0,
+ "doctype": "DocPerm"
+ },
{
"doctype": "DocPerm"
}
diff --git a/setup/utils.py b/setup/utils.py
index 1a86921692..33fa3e286e 100644
--- a/setup/utils.py
+++ b/setup/utils.py
@@ -46,4 +46,4 @@ def get_price_list_currency(args):
if result and len(result)==1:
return {"price_list_currency": result[0][0]}
else:
- return {}
\ No newline at end of file
+ return {}
diff --git a/startup/boot.py b/startup/boot.py
index 9ed20ff73a..b202d17697 100644
--- a/startup/boot.py
+++ b/startup/boot.py
@@ -36,9 +36,8 @@ def boot_session(bootinfo):
for key in ['max_users', 'expires_on', 'max_space', 'status', 'developer_mode']:
if hasattr(conf, key): bootinfo[key] = getattr(conf, key)
- bootinfo['docs'] += webnotes.conn.sql("""select name, default_currency, cost_center,
- cost_center as 'cost_center_other_charges' from `tabCompany`""",
- as_dict=1, update={"doctype":":Company"})
+ bootinfo['docs'] += webnotes.conn.sql("""select name, default_currency, cost_center
+ from `tabCompany`""", as_dict=1, update={"doctype":":Company"})
def get_letter_heads():
"""load letter heads with startup"""
diff --git a/stock/Print Format/Delivery Note Classic/Delivery Note Classic.txt b/stock/Print Format/Delivery Note Classic/Delivery Note Classic.txt
index c5beb65b0d..4f6272d773 100644
--- a/stock/Print Format/Delivery Note Classic/Delivery Note Classic.txt
+++ b/stock/Print Format/Delivery Note Classic/Delivery Note Classic.txt
@@ -1,17 +1,18 @@
[
{
- "creation": "2012-04-17 11:29:12",
+ "creation": "2013-04-19 13:31:11",
"docstatus": 0,
- "modified": "2013-01-25 17:19:46",
+ "modified": "2013-05-28 17:20:31",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doc_type": "Delivery Note",
"doctype": "Print Format",
- "html": "\n\n\n\n\n\n\n\n\n\n\n
\ No newline at end of file
diff --git a/utilities/page/question_view/question_view.js b/utilities/page/question_view/question_view.js
deleted file mode 100644
index e479e131c5..0000000000
--- a/utilities/page/question_view/question_view.js
+++ /dev/null
@@ -1,193 +0,0 @@
-// ERPNext - web based ERP (http://erpnext.com)
-// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-
-pscript['onload_question-view'] = function(wrapper) {
- wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.layout-appframe'));
- wrapper.appframe.title('Question');
- wrapper.appframe.add_home_breadcrumb();
- wrapper.appframe.add_module_breadcrumb("Knowledge Base");
- wrapper.appframe.add_breadcrumb("icon-file");
-
- wrapper.add_answer_area = $('.add-answer-area').get(0);
-}
-
-pscript['refresh_question-view'] = function(wrapper) {
- // href
- var qid = window.location.hash.split('/')[1];
- if(qid) {
- pscript.question_view(qid);
- }
-}
-
-pscript.question_view = function(qid, qtext) {
- var w = wn.pages['question-view'];
- new KBQuestionView(w, qid, qtext);
-}
-
-KBQuestionView = function(w, qid, qtext) {
- var me = this;
-
- this.make_question = function() {
- $(w).find('.qv-question-wrapper').empty();
- $(w.add_answer_area).empty();
- new EditableText({
- parent: $(w).find('.qv-question-wrapper').get(0),
- dt: 'Question',
- dn: qid,
- fieldname: 'question',
- text: qtext,
- inp_class: 'qv-input',
- disp_class: 'qv-text'
- });
-
- // show tags
- }
-
- // answer list
- this.make_answer_list = function() {
- $(w).find('.qv-answer-wrapper').empty();
- this.ans_list = new KBAnswerList({
- parent: $(w).find('.qv-answer-wrapper').get(0),
- qid: qid
- })
- }
-
- // check if users has answered
- // (if no) then add a box to add a new answer
- this.make_add_answer = function() {
- $c_page('utilities', 'question_view', 'has_answered', qid, function(r, rt) {
- if(r.message=='No') {
- me.make_answer_box_link();
- }
- });
- }
-
- // add a link to open add answer
- this.make_answer_box_link = function() {
- wn.pages['question-view'].appframe.add_button('Add your answer', function() {
- $(this).toggle(false);
- me.make_answer_box();
- }, 'icon-plus');
- }
-
- // answer box
- // text area + add button
- this.make_answer_box = function() {
- $ds(w.add_answer_area);
- $(w.add_answer_area, '
Add your Answer
\
-
In markdown format
');
- this.input = $a(w.add_answer_area, 'textarea');
- $(this.input).css({width: "90%", height: "200px"});
- //wn.tinymce.add_simple(this.input);
-
- this.btn = $btn($a(w.add_answer_area, 'div'), 'Post', function() {
- var v = $(me.input).val();
- if(!v) { msgprint('Write something!'); return; }
- me.btn.set_working();
- $c_page('utilities', 'question_view', 'add_answer',
- JSON.stringify({qid: qid, "answer":v}),
- function(r, rt) {
- me.btn.done_working();
- me.ans_list.list.run();
- $dh(w.add_answer_area);
- }
- );
- });
- }
-
- this.setup = function() {
- if(qtext) {
- this.make();
- }
- else {
- $c_page('utilities', 'question_view', 'get_question', qid, function(r, rt) {
- qtext = r.message;
- me.make();
- });
- }
- }
-
- this.make = function() {
- set_title(qtext);
- this.make_question();
- this.make_answer_list();
- this.make_add_answer();
- }
-
- this.setup();
-}
-
-
-// kb answer list
-KBAnswerList = function(args) {
- var me = this;
- $.extend(this, args);
-
- this.make_list = function() {
- wn.pages['question-view'].appframe.clear_buttons();
- this.list = new wn.ui.Listing({
- parent: me.parent,
- appframe: wn.pages['question-view'].appframe,
- as_dict: 1,
- no_result_message: 'No answers yet, be the first one to answer!',
- render_row: function(body, data) {
- new KBAnswer(body, data, me)
- },
- get_query: function() {
- return repl("SELECT t1.name, t1.owner, t1.answer, t1._users_voted, t2.first_name, "
- +"t2.last_name, t1.modified from tabAnswer t1, tabProfile t2 "
- +"where question='%(qid)s' and t1.owner = t2.name "
- +"order by t1.modified desc", {qid: me.qid})
- }
- });
-
- this.list.run();
-
- }
-
- this.make_list();
-
-}
-
-// kb answer
-// answer
-// by xxx | on xxx
-KBAnswer = function(body, data, ans_list) {
- body.className = 'qv-answer';
- var edtxt = new EditableText({
- parent: body,
- dt: 'Answer',
- dn: data.name,
- fieldname: 'answer',
- text: data.answer,
- inp_class: 'qv-ans-input',
- disp_class: 'qv-ans-text',
- height: '300px',
- width: '90%'
- });
-
- $(edtxt.wrapper).addClass('well');
-
- var div = $a(body, 'div', '', {})
- new KBItemToolbar({
- parent: div,
- det: data,
- with_tags: 0,
- doctype: 'Answer'
- }, ans_list)
-}
-
-wn.require('app/js/kb_common.js');
\ No newline at end of file
diff --git a/utilities/page/question_view/question_view.py b/utilities/page/question_view/question_view.py
deleted file mode 100644
index 175a8ede1b..0000000000
--- a/utilities/page/question_view/question_view.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-
-from __future__ import unicode_literals
-import webnotes
-from webnotes.utils import load_json, cstr, now
-
-@webnotes.whitelist()
-def update_item(arg):
- args = load_json(arg)
-
- webnotes.conn.sql("update `tab%s` set `%s`=%s, modified=%s where name=%s" \
- % (args['dt'], args['fn'], '%s', '%s', '%s'), (args['text'], now(), args['dn']))
-
-@webnotes.whitelist()
-def has_answered(arg):
- return webnotes.conn.sql("select name from tabAnswer where owner=%s and question=%s", (webnotes.user.name, arg)) and 'Yes' or 'No'
-
-@webnotes.whitelist()
-def get_question(arg):
- return cstr(webnotes.conn.sql("select question from tabQuestion where name=%s", arg)[0][0])
-
-@webnotes.whitelist()
-def add_answer(arg):
- arg = load_json(arg)
-
- from webnotes.model.doc import Document
- a = Document('Answer')
- a.answer = arg['answer']
- a.question = arg['qid']
- a.points = 1
- a.save(1)
-
- webnotes.conn.set_value('Question', arg['qid'], 'modified', now())
\ No newline at end of file
diff --git a/utilities/page/question_view/question_view.txt b/utilities/page/question_view/question_view.txt
deleted file mode 100644
index 87fd053732..0000000000
--- a/utilities/page/question_view/question_view.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-[
- {
- "creation": "2013-04-09 11:45:31",
- "docstatus": 0,
- "modified": "2013-04-09 11:47:24",
- "modified_by": "Administrator",
- "owner": "Administrator"
- },
- {
- "doctype": "Page",
- "module": "Utilities",
- "name": "__common__",
- "page_name": "Question View",
- "standard": "Yes"
- },
- {
- "doctype": "Page Role",
- "name": "__common__",
- "parent": "question-view",
- "parentfield": "roles",
- "parenttype": "Page",
- "role": "All"
- },
- {
- "doctype": "Page",
- "name": "question-view"
- },
- {
- "doctype": "Page Role"
- }
-]
\ No newline at end of file
diff --git a/utilities/page/questions/__init__.py b/utilities/page/questions/__init__.py
deleted file mode 100644
index baffc48825..0000000000
--- a/utilities/page/questions/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/utilities/page/questions/questions.css b/utilities/page/questions/questions.css
deleted file mode 100644
index 779da5505e..0000000000
--- a/utilities/page/questions/questions.css
+++ /dev/null
@@ -1,31 +0,0 @@
-div.kb-search-wrapper textarea {
- height: 2.2em;
- width: 80%;
- font-size: 14px;
- padding: 3px;
- margin-bottom: 7px;
-}
-
-.kb-question-wrapper {
- padding-bottom: 3px;
- margin-bottom: 3px;
-}
-
-.kb-questions {
-}
-
-.un-answered {
- color: #f33;
-}
-
-.kb-question-details {
- margin: 11px 0px 11px 29px;
-}
-
-.kb-tag-filter-area {
- padding: 7px;
- background-color: #F2F2E8;
- color: #222;
- margin: 7px 0px;
- display: none;
-}
\ No newline at end of file
diff --git a/utilities/page/questions/questions.html b/utilities/page/questions/questions.html
deleted file mode 100644
index bec483e09a..0000000000
--- a/utilities/page/questions/questions.html
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
A wiki or Q&A for your organization
-
-
-
\ No newline at end of file
diff --git a/utilities/page/questions/questions.js b/utilities/page/questions/questions.js
deleted file mode 100644
index e7e99b5323..0000000000
--- a/utilities/page/questions/questions.js
+++ /dev/null
@@ -1,221 +0,0 @@
-// ERPNext - web based ERP (http://erpnext.com)
-// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-
-pscript.onload_questions = function(wrapper) {
- body = $(wrapper).find('.layout-main-section').get(0);
-
- wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.layout-appframe'));
- wrapper.appframe.add_home_breadcrumb();
- wrapper.appframe.add_breadcrumb(wn.modules["Knowledge Base"].icon);
- wrapper.appframe.title('Knowledge Base');
-
- // kb
- var kb = new KnowledgeBase(body);
-
- wn.model.with_doctype("Question", function() {
- this.sidebar_stats = new wn.views.SidebarStats({
- doctype: "Question",
- stats: ["_user_tags"],
- parent: $(wrapper).find('.questions-tags'),
- set_filter: function(fieldname, label) {
- kb.set_filter(fieldname, label);
- //me.set_filter(fieldname, label);
- }
- });
- })
-}
-
-// knowledge base object
-// has a box for search or ask a question
-// and list of top rated search results
-//
-function KnowledgeBase(w) {
- var me = this;
- this.sort_by = 'modified';
- this.tag_filter_dict = {};
-
- this.make_search_bar = function() {
- this.search = $(w).find('.kb-search-wrapper textarea').get(0);
-
- $(w).find('.btn.search').click(function() {
- me.run();
- })
- $(w).find('.btn.ask').click(function() {
- me.ask();
- })
- }
-
- // ask a new question
- this.ask = function() {
- if(this.search.value==$(this.search).attr('default_text')) {
- msgprint('Please enter some text'); return;
- }
- this.add_question([]);
- }
-
- // suggest a few users who can answer
- this.suggest = function() {
- this.dialog = new wn.ui.Dialog({
- title: 'Suggest a users',
- width: 400,
- fields: [
- {fieldtype:'HTML', options:'Optional: Suggest a few users who can help you answer this question '},
- {fieldtype:'Link', fieldname:'profile1', label:'1st User',options:'Profile'},
- {fieldtype:'Link', fieldname:'profile2', label:'2nd User',options:'Profile'},
- {fieldtype:'Link', fieldname:'profile3', label:'3rd User',options:'Profile'},
- {fieldtype:'Button', fieldname:'ask', label:'Add the Question'}
- ]
- });
- this.dialog.fields_dict.ask.input.onclick = function() {
- me.dialog.hide();
- me.add_question(values(me.dialog.get_values()));
- }
- this.dialog.show();
- }
-
- // add a new question to the database
- this.add_question = function(suggest_list) {
- $c_page('utilities', 'questions', 'add_question', {
- question: this.search.value,
- suggest: suggest_list
- }, function(r,rt) {
- $(me.search).val('').blur();
- me.run();
- })
- }
-
- // where tags that filter will be displayed
- this.make_tag_filter_area = function() {
- this.tag_filters = $a(w, 'div', 'kb-tag-filter-area');
- $a(this.tag_filters,'span','',{marginRight:'4px',color:'#442'}, 'Showing for:');
- this.tag_area = $a(this.tag_filters, 'span');
- }
-
- // make a list of questions
- this.make_list = function() {
- this.make_tag_filter_area();
- this.list_area = $a(w, 'div', '', {marginRight:'13px'})
- this.no_result = $a(w, 'div','help_box',{display:'none'},'No questions asked yet! Be the first one to ask')
-
- this.list = new wn.ui.Listing({
- parent: this.list_area,
- no_results_message: 'No questions found. Ask a new question!',
- appframe: wn.pages.questions.appframe,
- as_dict: 1,
- method: 'utilities.page.questions.questions.get_questions',
- get_args: function() {
- var args = {};
- if(me.search.value) {
- args.search_text = me.search.value;
- }
- if(me.tag_filter_dict) {
- args.tag_filters = keys(me.tag_filter_dict);
- }
- return args
- },
- render_row: function(parent, data, listing) {
- new KBQuestion(parent, data, me);
- }
- });
-
- this.list.run();
-
- }
-
- this.set_filter = function(fieldname, label) {
- this.set_tag_filter({label:label});
- }
- // add a tag filter to the search in the
- // main page
- this.set_tag_filter = function(tag) {
-
- // check if exists
- if(in_list(keys(me.tag_filter_dict), tag.label)) return;
-
- // create a tag in filters
- var filter_tag = new SingleTag({
- parent: me.tag_area,
- label: tag.label,
- dt: 'Question',
- color: tag.color
- });
-
- // remove tag from filters
- filter_tag.remove = function(tag_remove) {
- $(tag_remove.body).fadeOut();
- delete me.tag_filter_dict[tag_remove.label];
-
- // hide everything?
- if(!keys(me.tag_filter_dict).length) {
- $(me.tag_filters).slideUp(); // hide
- }
-
- // run
- me.run();
- }
-
- // add to dict
- me.tag_filter_dict[tag.label] = filter_tag;
- $ds(me.tag_filters);
-
- // run
- me.run();
- }
- this.run = function() {
- this.list.run();
- }
-
- this.make_search_bar();
- this.make_list();
-
-}
-
-// single kb question
-// "question
-// points | tag list"
-
-KBQuestion = function(parent, det, kb) {
-
- this.make = function() {
- this.wrapper = $a(parent, 'div', 'kb-question-wrapper');
- this.q_area = $a($a(this.wrapper, 'div'), 'h3',
- 'kb-questions link_type', {display:'inline', textDecoration:'none'}, det.question);
- if(det.answers==0) {
- $(this.q_area).addClass('un-answered')
- }
-
- this.q_area.onclick = function() {
- var q = this;
- window.location.href = '#!question-view/' + q.id;
- //loadpage('question-view', function() { pscript.question_view(q.id, q.txt) })
- }
-
- this.q_area.id = det.name; this.q_area.txt = det.question;
-
- new KBItemToolbar({
- parent: this.wrapper,
- det: det,
- with_tags: 1,
- doctype: 'Question'
- }, kb)
-
- }
-
-
- this.make()
-}
-
-wn.require('app/js/kb_common.js');
diff --git a/utilities/page/questions/questions.py b/utilities/page/questions/questions.py
deleted file mode 100644
index 442fb0139a..0000000000
--- a/utilities/page/questions/questions.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-
-from __future__ import unicode_literals
-import webnotes
-
-from webnotes.utils import load_json
-import json
-
-@webnotes.whitelist()
-def get_questions():
- """get list of questions"""
- import json
- conds = ''
-
- if 'search_text' in webnotes.form_dict:
- conds = ' and t1.question like "%'+ webnotes.form_dict['search_text'] + '%"'
-
- if 'tag_filters' in webnotes.form_dict:
- tag_filters = json.loads(webnotes.form_dict['tag_filters'])
- for t in tag_filters:
- conds += ' and t1._user_tags like "%'+ t +'%"'
-
- return webnotes.conn.sql("""select t1.name, t1.owner, t1.question, t1.modified, t1._user_tags,
- (select count(*) from tabAnswer where
- tabAnswer.question = t1.name) as answers
- from tabQuestion t1, tabProfile t2
- where t1.docstatus!=2
- and t1.owner = t2.name
- %(conds)s
- order by t1.modified desc""" % {"conds":conds}, as_dict=1)
-
-# add a new question
-@webnotes.whitelist()
-def add_question(arg):
- args = load_json(arg)
-
- from webnotes.model.doc import Document
- d = Document('Question')
- d.question = args['question']
- d.points = 1
- d.save(1)
-
- if args['suggest']:
- from core.page.messages import messages
- for s in args['suggest']:
- if s:
- messages.post(json.dumps({
- 'contact': s,
- 'txt': 'Please help me and answer the question "%s" in the Knowledge Base' % d.question,
- 'notify': 1
- }))
-
-@webnotes.whitelist()
-def delete(arg):
- """
- delete a question or answer (called from kb toolbar)
- """
- args = load_json(arg)
- from webnotes.model import delete_doc
- delete_doc(args['dt'], args['dn'])
diff --git a/utilities/page/questions/questions.txt b/utilities/page/questions/questions.txt
deleted file mode 100644
index e327ebfd18..0000000000
--- a/utilities/page/questions/questions.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-[
- {
- "creation": "2013-04-09 11:50:08",
- "docstatus": 0,
- "modified": "2013-04-09 11:52:08",
- "modified_by": "Administrator",
- "owner": "Administrator"
- },
- {
- "doctype": "Page",
- "module": "Utilities",
- "name": "__common__",
- "page_name": "Questions",
- "standard": "Yes"
- },
- {
- "doctype": "Page Role",
- "name": "__common__",
- "parent": "questions",
- "parentfield": "roles",
- "parenttype": "Page",
- "role": "All"
- },
- {
- "doctype": "Page",
- "name": "questions"
- },
- {
- "doctype": "Page Role"
- }
-]
\ No newline at end of file
diff --git a/utilities/page/trash/__init__.py b/utilities/page/trash/__init__.py
deleted file mode 100644
index baffc48825..0000000000
--- a/utilities/page/trash/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/utilities/page/trash/trash.html b/utilities/page/trash/trash.html
deleted file mode 100644
index b17e475d0a..0000000000
--- a/utilities/page/trash/trash.html
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/utilities/page/trash/trash.js b/utilities/page/trash/trash.js
deleted file mode 100644
index b30626dc22..0000000000
--- a/utilities/page/trash/trash.js
+++ /dev/null
@@ -1,144 +0,0 @@
-// ERPNext - web based ERP (http://erpnext.com)
-// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-
-pscript['onload_Trash'] = function() {
-
- // header and toolbar
- var h = new PageHeader('trash_header','Trash Bin','Restore the documents that you have trashed')
-
- if(!pscript.trash_bin) pscript.trash_bin = new pscript.Trash();
-}
-
-pscript.Trash = function() {
- // create UI elements
- this.wrapper = $i('trash_div');
-
- this.head = $a(this.wrapper, 'div');
- this.body = $a(this.wrapper, 'div');
- $y(this.body, {margin:'8px'})
-
- this.make_head();
- this.load_masters();
-}
-
-// Make Button
-// ------------
-pscript.Trash.prototype.make_button = function(label, area){
- var me = this;
- var w = $a(area, 'div', '', {margin:'8px'});
- var t = make_table(w,1,1,'400px',['50%','50%']);
- var s = $a($td(t,0,0),'button');
- s.innerHTML = label;
- s.wrapper = w;
- return s;
-}
-
-
-// Make Head
-// -------------
-pscript.Trash.prototype.make_head = function() {
- var me = this;
-
- var make_select = function(label) {
- var w = $a(me.head, 'div', '', {margin:'8px'});
- var t = make_table(w,1,2,'400px',['50%','50%']);
- $td(t,0,0).innerHTML = label;
- var s = $a($td(t,0,1),'select','',{width:'140px'});
- s.wrapper = w;
- return s;
- }
-
- // Select Master Name
- this.master_select = make_select('Select Master');
-
- var me = this;
- // Get Records
- this.get_records_button = me.make_button('Get Records', me.head);
- this.get_records_button.onclick = function() {
- me.get_records();
- }
-}
-
-
-// Load Masters
-// -------------
-pscript.Trash.prototype.load_masters = function(){
- var me = this;
- var callback = function(r, rt){
- // Masters
- empty_select(me.master_select);
- add_sel_options(me.master_select,add_lists(['All'], r.message), 'All');
- }
- $c_obj('Trash Control','get_masters','',callback);
-}
-
-
-// Get Records
-// -----------
-pscript.Trash.prototype.get_records = function(){
- var me = this;
- me.body.innerHTML = '';
- var callback = function(r, rt){
- if(r.message) me.generate_trash_records(r.message);
- else msgprint("No Records Found");
- }
- $c_obj('Trash Control','get_trash_records',sel_val(me.master_select),callback);
-}
-
-
-// Generate Trash Records
-// -----------------------
-pscript.Trash.prototype.generate_trash_records = function(rec_dict){
- var me = this;
- pscript.all_checkboxes = [];
- mnames = keys(rec_dict).sort();
- for(var i = 0; i < mnames.length; i ++){
- var head = $a(me.body, 'h3'); head.innerHTML = mnames[i];
- var rec_table = make_table(me.body,rec_dict[mnames[i]].length,2,'375px',['350px','25px'],{border:'1px solid #AAA',padding:'2px'});
- for(var j = 0; j < rec_dict[mnames[i]].length; j++){
- $a_input($td(rec_table,j,0), 'data');
- $td(rec_table,j,0).innerHTML = rec_dict[mnames[i]][j];
- var chk = $a_input($td(rec_table,j,1), 'checkbox');
- chk.master = mnames[i];
- chk.record = rec_dict[mnames[i]][j];
- pscript.all_checkboxes.push(chk);
- }
- }
- this.restore_button = me.make_button('Restore Selected', me.body);
- this.restore_button.onclick = function() {
- me.restore_records(0);
- }
- this.restore_all_button = me.make_button('Restore All', me.body);
- this.restore_all_button.onclick = function() {
- me.restore_records(1);
- }
-}
-
-
-// Restore Records
-// ---------------
-pscript.Trash.prototype.restore_records = function(restore_all){
- var me = this;
- var out = {};
- for(i in pscript.all_checkboxes) {
- c = pscript.all_checkboxes[i];
- if (restore_all || (!restore_all && c.checked)) {
- if(!out[c.master]) out[c.master] = [c.record];
- else {out[c.master].push(c.record);}
- }
- }
- $c_obj('Trash Control','restore_records',JSON.stringify(out),function(r, rt){me.get_records();})
-}
\ No newline at end of file
diff --git a/utilities/page/trash/trash.txt b/utilities/page/trash/trash.txt
deleted file mode 100644
index a13e1b6ac7..0000000000
--- a/utilities/page/trash/trash.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-[
- {
- "owner": "Administrator",
- "docstatus": 0,
- "creation": "2010-10-12 15:19:32",
- "modified_by": "Administrator",
- "modified": "2010-12-30 11:44:36"
- },
- {
- "name": "__common__",
- "module": "Utilities",
- "page_name": "Trash",
- "doctype": "Page",
- "standard": "Yes"
- },
- {
- "name": "__common__",
- "parent": "Trash",
- "doctype": "Page Role",
- "parenttype": "Page",
- "parentfield": "roles"
- },
- {
- "name": "Trash",
- "doctype": "Page"
- },
- {
- "role": "Administrator",
- "doctype": "Page Role"
- },
- {
- "role": "Sales Master Manager",
- "doctype": "Page Role"
- },
- {
- "role": "Material Master Manager",
- "doctype": "Page Role"
- },
- {
- "role": "Purchase Master Manager",
- "doctype": "Page Role"
- },
- {
- "role": "Accounts Manager",
- "doctype": "Page Role"
- }
-]
\ No newline at end of file
diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py
index 5d7d1a84b1..357121508f 100644
--- a/utilities/transaction_base.py
+++ b/utilities/transaction_base.py
@@ -16,6 +16,7 @@
from __future__ import unicode_literals
import webnotes
+from webnotes import msgprint, _
from webnotes.utils import load_json, cstr, flt, now_datetime
from webnotes.model.doc import addchild
@@ -191,7 +192,8 @@ class TransactionBase(DocListController):
# Get Supplier Default Primary Address - first load
# -----------------------
def get_default_supplier_address(self, args):
- args = load_json(args)
+ if isinstance(args, basestring):
+ args = load_json(args)
address_text, address_name = self.get_address_text(supplier=args['supplier'])
ret = {
'supplier_address' : address_name,
@@ -268,4 +270,58 @@ class TransactionBase(DocListController):
def validate_posting_time(self):
if not self.doc.posting_time:
self.doc.posting_time = now_datetime().strftime('%H:%M:%S')
+
+def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, company):
+ """common validation for currency and price list currency"""
+ if conversion_rate == 0:
+ msgprint(conversion_rate_label + _(' cannot be 0'), raise_exception=True)
+
+ company_currency = webnotes.conn.get_value("Company", company, "default_currency")
+
+ # parenthesis for 'OR' are necessary as we want it to evaluate as
+ # mandatory valid condition and (1st optional valid condition
+ # or 2nd optional valid condition)
+ valid_conversion_rate = (conversion_rate and
+ ((currency == company_currency and conversion_rate == 1.00)
+ or (currency != company_currency and conversion_rate != 1.00)))
+
+ if not valid_conversion_rate:
+ msgprint(_('Please enter valid ') + conversion_rate_label + (': ')
+ + ("1 %s = [?] %s" % (currency, company_currency)),
+ raise_exception=True)
+
+def validate_item_fetch(args, item):
+ from stock.utils import validate_end_of_life
+ validate_end_of_life(item.name, item.end_of_life)
+
+ # validate company
+ if not args.company:
+ msgprint(_("Please specify Company"), raise_exception=True)
+
+def validate_currency(args, item, meta=None):
+ from webnotes.model.meta import get_field_precision
+ if not meta:
+ meta = webnotes.get_doctype(args.doctype)
+
+ # validate conversion rate
+ if meta.get_field("currency"):
+ validate_conversion_rate(args.currency, args.conversion_rate,
+ meta.get_label("conversion_rate"), args.company)
+
+ # round it
+ args.conversion_rate = flt(args.conversion_rate,
+ get_field_precision(meta.get_field("conversion_rate"),
+ webnotes._dict({"fields": args})))
+
+ # validate price list conversion rate
+ if meta.get_field("price_list_currency") and args.price_list_name and \
+ args.price_list_currency:
+ validate_conversion_rate(args.price_list_currency, args.plc_conversion_rate,
+ meta.get_label("plc_conversion_rate"), args.company)
+
+ # round it
+ args.plc_conversion_rate = flt(args.plc_conversion_rate,
+ get_field_precision(meta.get_field("plc_conversion_rate"),
+ webnotes._dict({"fields": args})))
+
\ No newline at end of file
diff --git a/website/css/website.css b/website/css/website.css
index 25e2c91ac2..36e306d5eb 100644
--- a/website/css/website.css
+++ b/website/css/website.css
@@ -1,47 +1,15 @@
-div.outer {
- padding: 30px;
- margin: 30px -30px 10px -30px;
- min-height: 400px;
+h1, h2, h3, h4, h5 {
+ font-weight: bold;
}
-.outer .navbar {
- margin: -30px -30px 20px -30px;
-}
-
-footer {
- text-align: left;
- margin: auto;
- margin-bottom: 20px;
-}
-
-.navbar-inner {
- border: 0px;
- border-bottom: 1px solid #ddd;
- border-radius: 0px;
- padding-right: 30px;
- padding-left: 30px;
-}
-
-p, li {
- line-height: 1.5em;
-}
-
-.layout-wrapper {
- box-shadow: none;
- -webkit-box-shadow: none;
- -moz-box-shadow: none;
- border-radius: 0px 0px 5px 5px;
-}
-
-.layout-main {
- min-height: 400px;
- padding: 30px;
+.content {
+ padding-bottom: 30px;
}
.missing-image {
background-color: #eee;
padding: 40px;
- width: 32px;
+ width: 112px;
font-size: 32px;
color: #888;
}
@@ -129,3 +97,15 @@ p, li {
.avatar-x-large img {
width: 100px;
}
+
+.carousel-control .icon {
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ z-index: 5;
+ display: inline-block;
+ width: 20px;
+ height: 20px;
+ margin-top: -10px;
+ margin-left: -10px;
+}
diff --git a/website/doctype/style_settings/custom_template.css b/website/doctype/style_settings/custom_template.css
index f055b782fe..996774eaea 100644
--- a/website/doctype/style_settings/custom_template.css
+++ b/website/doctype/style_settings/custom_template.css
@@ -66,8 +66,9 @@ div.web-footer, div.web-footer a {
}
/* Bootstrap Navbar */
-.navbar-inverse .navbar-inner {
+.navbar-inverse {
box-shadow: none;
+ border-radius: 0px;
background-color: #{{ doc.top_bar_background or "444444"}};
background-repeat: repeat-x;
background-image: none;
@@ -78,9 +79,9 @@ div.web-footer, div.web-footer a {
{%- endif %}
}
-.navbar-inverse .brand,
-.navbar-inverse .brand:hover,
-.navbar-inverse .brand:focus,
+.navbar-inverse .navbar-brand,
+.navbar-inverse .navbar-brand:hover,
+.navbar-inverse .navbar-brand:focus,
.navbar-inverse .nav > li > a {
color: #{{ doc.top_bar_foreground or "fffffff"}};
text-shadow: none;
@@ -117,8 +118,8 @@ div.web-footer, div.web-footer a {
color: #{{ doc.top_bar_foreground or "fffffff"}};
}
-.navbar-fixed-top .navbar-inner,
-.navbar-static-top .navbar-inner {
+.navbar-fixed-top,
+.navbar-static-top {
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
@@ -190,14 +191,6 @@ div.web-footer, div.web-footer a {
text-shadow: none;
}
-.breadcrumb > li > .divider {
- color: #{{ doc.page_text }};
-}
-
-.breadcrumb > .active {
- color: #{{ doc.page_text }};
-}
-
.table-striped tbody > tr:nth-child(odd) > td,
.table-striped tbody > tr:nth-child(odd) > th {
diff --git a/website/doctype/website_slideshow/website_slideshow.txt b/website/doctype/website_slideshow/website_slideshow.txt
index 2887d4b464..e67e1f8ca1 100644
--- a/website/doctype/website_slideshow/website_slideshow.txt
+++ b/website/doctype/website_slideshow/website_slideshow.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-03-07 14:48:40",
+ "creation": "2013-03-07 15:53:15",
"docstatus": 0,
- "modified": "2012-12-25 16:56:34",
+ "modified": "2013-05-28 16:57:32",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -53,6 +53,7 @@
},
{
"depends_on": "eval:!doc.__islocal",
+ "description": "Note: For best results, images must be of the same size and width must be greater than height.",
"doctype": "DocField",
"fieldname": "sb0",
"fieldtype": "Section Break",
diff --git a/website/helpers/blog.py b/website/helpers/blog.py
index 386c4b7f05..9da2062c24 100644
--- a/website/helpers/blog.py
+++ b/website/helpers/blog.py
@@ -63,15 +63,20 @@ def add_comment(args=None):
"""
import webnotes
import webnotes.utils, markdown2
- import webnotes.widgets.form.comments
if not args: args = webnotes.form_dict
args['comment'] = unicode(markdown2.markdown(args.get('comment') or ''))
+ args['doctype'] = "Comment"
- comment = webnotes.widgets.form.comments.add_comment(args)
+ page_name = args.get("page_name")
+ if "page_name" in args:
+ del args["page_name"]
+
+ comment = webnotes.bean(args)
+ comment.insert()
# since comments are embedded in the page, clear the web cache
- webnotes.webutils.clear_cache(args.get('page_name'))
+ webnotes.webutils.clear_cache(page_name)
comment['comment_date'] = webnotes.utils.global_date_format(comment['creation'])
template_args = { 'comment_list': [comment], 'template': 'app/website/templates/html/comment.html' }
diff --git a/website/templates/css/blog_page.css b/website/templates/css/blog_page.css
index 8f56cd2fec..ffa45b4115 100644
--- a/website/templates/css/blog_page.css
+++ b/website/templates/css/blog_page.css
@@ -1,4 +1,8 @@