mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-03 05:28:27 +00:00
[fixed conflict]
This commit is contained in:
39
setup/doctype/currency_exchange/currency_exchange.js
Normal file
39
setup/doctype/currency_exchange/currency_exchange.js
Normal file
@@ -0,0 +1,39 @@
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
$.extend(cur_frm.cscript, {
|
||||
refresh: function() {
|
||||
cur_frm.cscript.set_exchange_rate_label();
|
||||
},
|
||||
|
||||
from_currency: function() {
|
||||
cur_frm.cscript.set_exchange_rate_label();
|
||||
},
|
||||
|
||||
to_currency: function() {
|
||||
cur_frm.cscript.set_exchange_rate_label();
|
||||
},
|
||||
|
||||
set_exchange_rate_label: function() {
|
||||
if(cur_frm.doc.from_currency && cur_frm.doc.to_currency) {
|
||||
var default_label = wn._(wn.meta.docfield_map[cur_frm.doctype]["exchange_rate"].label);
|
||||
console.log(default_label +
|
||||
repl(" (1 %(from_currency)s = [?] %(to_currency)s)", cur_frm.doc));
|
||||
cur_frm.fields_dict.exchange_rate.set_label(default_label +
|
||||
repl(" (1 %(from_currency)s = [?] %(to_currency)s)", cur_frm.doc));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-06-20 15:40:29",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-06-20 15:40:29",
|
||||
"modified": "2013-07-03 17:11:40",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -23,6 +23,16 @@
|
||||
"permlevel": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Currency Exchange",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"report": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Currency Exchange"
|
||||
@@ -46,5 +56,24 @@
|
||||
"fieldname": "exchange_rate",
|
||||
"fieldtype": "Float",
|
||||
"label": "Exchange Rate"
|
||||
},
|
||||
{
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"role": "Accounts Manager",
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"role": "Accounts User"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"role": "Sales User"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"role": "Purchase User"
|
||||
}
|
||||
]
|
||||
14
setup/doctype/currency_exchange/test_currency_exchange.py
Normal file
14
setup/doctype/currency_exchange/test_currency_exchange.py
Normal file
@@ -0,0 +1,14 @@
|
||||
test_records = [
|
||||
[{
|
||||
"doctype": "Currency Exchange",
|
||||
"from_currency": "USD",
|
||||
"to_currency": "INR",
|
||||
"exchange_rate": 1
|
||||
}],
|
||||
[{
|
||||
"doctype": "Currency Exchange",
|
||||
"from_currency": "USD",
|
||||
"to_currency": "EUR",
|
||||
"exchange_rate": 0.773
|
||||
}]
|
||||
]
|
||||
@@ -17,7 +17,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import msgprint, _
|
||||
from webnotes.utils import comma_or
|
||||
from webnotes.utils import comma_or, cint
|
||||
from webnotes.model.controller import DocListController
|
||||
|
||||
class DocType(DocListController):
|
||||
@@ -30,6 +30,14 @@ class DocType(DocListController):
|
||||
msgprint(_(self.meta.get_label("buying_or_selling")) + " " + _("must be one of") + " " +
|
||||
comma_or(["Buying", "Selling"]), raise_exception=True)
|
||||
|
||||
# at least one territory
|
||||
self.validate_table_has_rows("valid_for_territories")
|
||||
|
||||
def on_update(self):
|
||||
cart_settings = webnotes.get_obj("Shopping Cart Settings")
|
||||
if cint(cart_settings.doc.enabled):
|
||||
cart_settings.validate_price_lists()
|
||||
|
||||
def on_trash(self):
|
||||
webnotes.conn.sql("""delete from `tabItem Price` where price_list_name = %s""",
|
||||
self.doc.name)
|
||||
@@ -1,8 +1,59 @@
|
||||
test_records = [
|
||||
[{
|
||||
"doctype": "Price List",
|
||||
"price_list_name": "_Test Price List",
|
||||
"currency": "INR",
|
||||
"buying_or_selling": "Selling"
|
||||
}]
|
||||
[
|
||||
{
|
||||
"doctype": "Price List",
|
||||
"price_list_name": "_Test Price List",
|
||||
"currency": "INR",
|
||||
"buying_or_selling": "Selling"
|
||||
},
|
||||
{
|
||||
"doctype": "For Territory",
|
||||
"parentfield": "valid_for_territories",
|
||||
"territory": "All Territories"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"doctype": "Price List",
|
||||
"price_list_name": "_Test Price List 2",
|
||||
"currency": "INR",
|
||||
"buying_or_selling": "Selling"
|
||||
},
|
||||
{
|
||||
"doctype": "For Territory",
|
||||
"parentfield": "valid_for_territories",
|
||||
"territory": "_Test Territory Rest of the World"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"doctype": "Price List",
|
||||
"price_list_name": "_Test Price List India",
|
||||
"currency": "INR",
|
||||
"buying_or_selling": "Selling"
|
||||
},
|
||||
{
|
||||
"doctype": "For Territory",
|
||||
"parentfield": "valid_for_territories",
|
||||
"territory": "_Test Territory India"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"doctype": "Price List",
|
||||
"price_list_name": "_Test Price List Rest of the World",
|
||||
"currency": "USD",
|
||||
"buying_or_selling": "Selling"
|
||||
},
|
||||
{
|
||||
"doctype": "For Territory",
|
||||
"parentfield": "valid_for_territories",
|
||||
"territory": "_Test Territory Rest of the World"
|
||||
},
|
||||
{
|
||||
"doctype": "For Territory",
|
||||
"parentfield": "valid_for_territories",
|
||||
"territory": "_Test Territory United States"
|
||||
}
|
||||
],
|
||||
]
|
||||
@@ -87,18 +87,20 @@ class DocType:
|
||||
self.curr_fiscal_year = curr_fiscal_year
|
||||
|
||||
def create_price_lists(self, args):
|
||||
webnotes.bean({
|
||||
'doctype': 'Price List',
|
||||
'price_list_name': 'Standard Selling',
|
||||
"buying_or_selling": "Selling",
|
||||
"currency": args["currency"]
|
||||
}).insert(),
|
||||
webnotes.bean({
|
||||
'doctype': 'Price List',
|
||||
'price_list_name': 'Standard Buying',
|
||||
"buying_or_selling": "Buying",
|
||||
"currency": args["currency"]
|
||||
}).insert(),
|
||||
for pl_type in ["Selling", "Buying"]:
|
||||
webnotes.bean([
|
||||
{
|
||||
"doctype": "Price List",
|
||||
"price_list_name": "Standard " + pl_type,
|
||||
"buying_or_selling": pl_type,
|
||||
"currency": args["currency"]
|
||||
},
|
||||
{
|
||||
"doctype": "For Territory",
|
||||
"parentfield": "valid_for_territories",
|
||||
"territory": "All Territories"
|
||||
}
|
||||
]).insert()
|
||||
|
||||
def set_defaults(self, args):
|
||||
# enable default currency
|
||||
@@ -207,15 +209,18 @@ class DocType:
|
||||
# ------------------------
|
||||
def get_fy_details(self, fy_start, last_year=False):
|
||||
st = {'1st Jan':'01-01','1st Apr':'04-01','1st Jul':'07-01', '1st Oct': '10-01'}
|
||||
curr_year = getdate(nowdate()).year
|
||||
if last_year:
|
||||
curr_year = curr_year - 1
|
||||
if cint(getdate(nowdate()).month) < cint((st[fy_start].split('-'))[0]):
|
||||
curr_year = getdate(nowdate()).year - 1
|
||||
else:
|
||||
curr_year = getdate(nowdate()).year
|
||||
|
||||
if last_year:
|
||||
curr_year = curr_year - 1
|
||||
|
||||
stdt = cstr(curr_year)+'-'+cstr(st[fy_start])
|
||||
|
||||
if(fy_start == '1st Jan'):
|
||||
fy = cstr(getdate(nowdate()).year)
|
||||
fy = cstr(curr_year)
|
||||
abbr = cstr(fy)[-2:]
|
||||
else:
|
||||
fy = cstr(curr_year) + '-' + cstr(curr_year+1)
|
||||
|
||||
@@ -4,5 +4,29 @@ test_records = [
|
||||
"territory_name": "_Test Territory",
|
||||
"parent_territory": "All Territories",
|
||||
"is_group": "No",
|
||||
}]
|
||||
}],
|
||||
[{
|
||||
"doctype": "Territory",
|
||||
"territory_name": "_Test Territory India",
|
||||
"parent_territory": "All Territories",
|
||||
"is_group": "Yes",
|
||||
}],
|
||||
[{
|
||||
"doctype": "Territory",
|
||||
"territory_name": "_Test Territory Maharashtra",
|
||||
"parent_territory": "_Test Territory India",
|
||||
"is_group": "No",
|
||||
}],
|
||||
[{
|
||||
"doctype": "Territory",
|
||||
"territory_name": "_Test Territory Rest of the World",
|
||||
"parent_territory": "All Territories",
|
||||
"is_group": "No",
|
||||
}],
|
||||
[{
|
||||
"doctype": "Territory",
|
||||
"territory_name": "_Test Territory United States",
|
||||
"parent_territory": "All Territories",
|
||||
"is_group": "No",
|
||||
}],
|
||||
]
|
||||
@@ -91,6 +91,8 @@ items = [
|
||||
},
|
||||
{ "doctype": "Sales Taxes and Charges Master" },
|
||||
{ "doctype": "Purchase Taxes and Charges Master" },
|
||||
{ "doctype": "Shipping Rule" },
|
||||
{ "doctype": "Currency Exchange" },
|
||||
{
|
||||
"type": "Section",
|
||||
"title": "Opening Accounts and Stock",
|
||||
|
||||
@@ -40,8 +40,8 @@ def get_ancestors_of(doctype, name):
|
||||
"""Get ancestor elements of a DocType with a tree structure"""
|
||||
lft, rgt = webnotes.conn.get_value(doctype, name, ["lft", "rgt"])
|
||||
result = webnotes.conn.sql_list("""select name from `tab%s`
|
||||
where lft<%s and rgt>%s and docstatus < 2""" % (doctype, "%s", "%s"), (lft, rgt))
|
||||
return result or None
|
||||
where lft<%s and rgt>%s order by lft desc""" % (doctype, "%s", "%s"), (lft, rgt))
|
||||
return result or []
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_price_list_currency(args):
|
||||
|
||||
Reference in New Issue
Block a user