Compare commits
74 Commits
4.0.0-beta
...
v4-beta2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb7fea673b | ||
|
|
4b2692182a | ||
|
|
76f330ca66 | ||
|
|
2134d24b36 | ||
|
|
9d1e8640ef | ||
|
|
49e0a687b3 | ||
|
|
54106807e4 | ||
|
|
a8dbb0dd41 | ||
|
|
65e8676f8b | ||
|
|
5c81f9c44e | ||
|
|
7c932003ed | ||
|
|
c379c78fec | ||
|
|
09a9f4c0c9 | ||
|
|
ec621194fc | ||
|
|
c12ccdb6ea | ||
|
|
d8de921c40 | ||
|
|
73f0bf36c1 | ||
|
|
2e7ad8980c | ||
|
|
4541875c81 | ||
|
|
0fabc6a841 | ||
|
|
2a45e1cfd0 | ||
|
|
2d5727b17b | ||
|
|
b2c2fca8a5 | ||
|
|
9472247b6e | ||
|
|
ebdac5db5c | ||
|
|
7ea8528d50 | ||
|
|
74d0e40bdc | ||
|
|
2d57b0aa52 | ||
|
|
0c4ef64b32 | ||
|
|
e30511d315 | ||
|
|
64f2ccd9e1 | ||
|
|
6b12b07b33 | ||
|
|
f5794f1c07 | ||
|
|
8e4640f464 | ||
|
|
f976143063 | ||
|
|
177b86a15b | ||
|
|
e7e615cf18 | ||
|
|
13b93ebed8 | ||
|
|
3319170805 | ||
|
|
ed5f423e65 | ||
|
|
311079a311 | ||
|
|
08222150f2 | ||
|
|
7e8e8ba714 | ||
|
|
c65a0c7197 | ||
|
|
bc34f3edae | ||
|
|
615d342056 | ||
|
|
8462a7691b | ||
|
|
063141d152 | ||
|
|
fb21ce3893 | ||
|
|
1ee5675750 | ||
|
|
e9baaa68e7 | ||
|
|
901f4434fd | ||
|
|
0936ae6dca | ||
|
|
4362443b6e | ||
|
|
201dbbd977 | ||
|
|
a6628eee56 | ||
|
|
a1c96de9fc | ||
|
|
6fbda08583 | ||
|
|
cda83bba59 | ||
|
|
2f8d4451f5 | ||
|
|
0f2310690e | ||
|
|
33f36c3462 | ||
|
|
a08855a0de | ||
|
|
3197767650 | ||
|
|
28da7523be | ||
|
|
ce64afaa51 | ||
|
|
f5bb9ae1b1 | ||
|
|
22831563ff | ||
|
|
32f168617c | ||
|
|
74bbd24b1d | ||
|
|
9d1f077922 | ||
|
|
e0e3f92019 | ||
|
|
05b28eb161 | ||
|
|
36a4db69b8 |
@@ -12,9 +12,10 @@ install:
|
||||
|
||||
script:
|
||||
cd ./test_sites/ &&
|
||||
frappe --reinstall -v test_site &&
|
||||
frappe --install_app erpnext -v test_site &&
|
||||
frappe --run_tests -v test_site --app erpnext
|
||||
frappe --reinstall test_site &&
|
||||
frappe --install_app erpnext test_site &&
|
||||
frappe --request '?cmd=erpnext.setup.page.setup_wizard.setup_wizard.setup_account¤cy=USD&first_name=Test&last_name=User&company_name=Wind+Power+LLC&timezone=America/New_York&company_abbr=WP&industry=Manufacturing&country=United states&fy_start_date=2014-01-01&fy_end_date=2014-12-31' test_site &&
|
||||
frappe --run_tests test_site --app erpnext
|
||||
|
||||
before_script:
|
||||
- mysql -e 'create database travis' &&
|
||||
|
||||
58
README.md
58
README.md
@@ -1,4 +1,4 @@
|
||||
# ERPNext - Open Source ERP for small, medium sized businesses
|
||||
# ERPNext - Open Source ERP for small, medium sized businesses [](https://travis-ci.org/frappe/erpnext)
|
||||
|
||||
[https://erpnext.com](https://erpnext.com)
|
||||
|
||||
@@ -15,61 +15,9 @@ ERPNext is built on [frappe](https://github.com/frappe/frappe)
|
||||
|
||||
### Development install
|
||||
|
||||
#### Pre-requisites
|
||||
Use the bench, https://github.com/frappe/frappe-bench.
|
||||
|
||||
1. MySQL
|
||||
1. Python-2.7
|
||||
1. Python Setuptools (Python Package Manager)
|
||||
1. Memcache
|
||||
1. libxslt
|
||||
|
||||
#### Steps
|
||||
|
||||
1. Start MySQL and memcache
|
||||
1. Setup Python Virtualenv (optional - only if you are running multiple python projects requiring different versions of libraries)
|
||||
1. Install pip: `sudo easy_install pip`
|
||||
1. Create a `bench` directory
|
||||
1. Clone `frappe` in the `bench` : `git clone https://github.com/frappe/frappe`
|
||||
1. Install python libraries `sudo pip install webnotes/requirements.txt`
|
||||
1. Clone `erpnext` in the `bench`: `git clone https://github.com/frappe/erpnext.git`
|
||||
1. Clone `shopping-cart` in the `bench`: `git clone https://github.com/frappe/shopping-cart.git`
|
||||
1. Install the packages: `pip install -e frappe/ erpnext/ shopping-cart/`
|
||||
1. Create `sites` directory
|
||||
1. Create `apps.txt`: `echo erpnext\nshopping_cart >> sites/apps.txt`
|
||||
1. Change to `sites` directory
|
||||
1. Setup a site: `frappe erpnext.local --install erpnext`
|
||||
1. Install erpnext app: `frappe erpnext.local --install_app erpnext`
|
||||
1. Start serving: `frappe erpnext.local --serve`
|
||||
1. Start a browser and go to `http://localhost:8000`
|
||||
|
||||
Putting it all together:
|
||||
|
||||
```
|
||||
sudo easy_install pip
|
||||
mkdir bench
|
||||
cd bench
|
||||
git clone https://github.com/frappe/frappe.git
|
||||
git clone https://github.com/frappe/erpnext.git
|
||||
git clone https://github.com/frappe/shopping-cart.git
|
||||
sudo pip install -e frappe/ erpnext/ shopping-cart/
|
||||
mkdir sites
|
||||
echo erpnext\nshopping_cart >> sites/apps.txt
|
||||
cd sites
|
||||
frappe erpnext.local --install erpnext
|
||||
frappe erpnext.local --install_app erpnext
|
||||
frappe erpnext.local --install_app shopping-cart
|
||||
frappe erpnext.local --serve
|
||||
```
|
||||
|
||||
#### Pulling Latest Updates
|
||||
|
||||
1. Update your git repositories
|
||||
1. Go to `bench/sites` directory
|
||||
1. Run `frappe erpnext.local --latest`
|
||||
1. Run `frappe erpnext.local --build`
|
||||
1. Run `frappe erpnext.local --flush`
|
||||
|
||||
#### Admin Login
|
||||
### Admin Login
|
||||
|
||||
1. go to "/login"
|
||||
1. Administrator user name: "Administrator"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{%- if doc.letter_head -%}
|
||||
{{ frappe.conn.get_value("Letter Head", doc.letter_head, "content") }}
|
||||
{{ frappe.db.get_value("Letter Head", doc.letter_head, "content") }}
|
||||
{%- endif -%}
|
||||
<!-- Page Layout Settings -->
|
||||
<div class='common page-header'>
|
||||
|
||||
@@ -7,7 +7,7 @@ import frappe
|
||||
from frappe.utils import flt, fmt_money, cstr, cint
|
||||
from frappe import msgprint, throw, _
|
||||
|
||||
get_value = frappe.conn.get_value
|
||||
get_value = frappe.db.get_value
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
@@ -16,11 +16,11 @@ class DocType:
|
||||
|
||||
def autoname(self):
|
||||
self.doc.name = self.doc.account_name.strip() + ' - ' + \
|
||||
frappe.conn.get_value("Company", self.doc.company, "abbr")
|
||||
frappe.db.get_value("Company", self.doc.company, "abbr")
|
||||
|
||||
def get_address(self):
|
||||
return {
|
||||
'address': frappe.conn.get_value(self.doc.master_type,
|
||||
'address': frappe.db.get_value(self.doc.master_type,
|
||||
self.doc.master_name, "address")
|
||||
}
|
||||
|
||||
@@ -41,14 +41,14 @@ class DocType:
|
||||
if self.doc.master_type in ('Customer', 'Supplier') or self.doc.account_type == "Warehouse":
|
||||
if not self.doc.master_name:
|
||||
msgprint(_("Please enter Master Name once the account is created."))
|
||||
elif not frappe.conn.exists(self.doc.master_type or self.doc.account_type,
|
||||
elif not frappe.db.exists(self.doc.master_type or self.doc.account_type,
|
||||
self.doc.master_name):
|
||||
throw(_("Invalid Master Name"))
|
||||
|
||||
def validate_parent(self):
|
||||
"""Fetch Parent Details and validation for account not to be created under ledger"""
|
||||
if self.doc.parent_account:
|
||||
par = frappe.conn.sql("""select name, group_or_ledger, is_pl_account, debit_or_credit
|
||||
par = frappe.db.sql("""select name, group_or_ledger, is_pl_account, debit_or_credit
|
||||
from tabAccount where name =%s""", self.doc.parent_account)
|
||||
if not par:
|
||||
throw(_("Parent account does not exists"))
|
||||
@@ -72,15 +72,15 @@ class DocType:
|
||||
|
||||
def validate_max_root_accounts(self):
|
||||
"""Raise exception if there are more than 4 root accounts"""
|
||||
if frappe.conn.sql("""select count(*) from tabAccount where
|
||||
if frappe.db.sql("""select count(*) from tabAccount where
|
||||
company=%s and ifnull(parent_account,'')='' and docstatus != 2""",
|
||||
self.doc.company)[0][0] > 4:
|
||||
throw(_("One company cannot have more than 4 root Accounts"))
|
||||
|
||||
def validate_duplicate_account(self):
|
||||
if self.doc.fields.get('__islocal') or not self.doc.name:
|
||||
company_abbr = frappe.conn.get_value("Company", self.doc.company, "abbr")
|
||||
if frappe.conn.sql("""select name from tabAccount where name=%s""",
|
||||
company_abbr = frappe.db.get_value("Company", self.doc.company, "abbr")
|
||||
if frappe.db.sql("""select name from tabAccount where name=%s""",
|
||||
(self.doc.account_name + " - " + company_abbr)):
|
||||
throw("{name}: {acc_name} {exist}, {rename}".format(**{
|
||||
"name": _("Account Name"),
|
||||
@@ -91,14 +91,14 @@ class DocType:
|
||||
|
||||
def validate_root_details(self):
|
||||
#does not exists parent
|
||||
if frappe.conn.exists("Account", self.doc.name):
|
||||
if not frappe.conn.get_value("Account", self.doc.name, "parent_account"):
|
||||
if frappe.db.exists("Account", self.doc.name):
|
||||
if not frappe.db.get_value("Account", self.doc.name, "parent_account"):
|
||||
throw(_("Root cannot be edited."))
|
||||
|
||||
def validate_frozen_accounts_modifier(self):
|
||||
old_value = frappe.conn.get_value("Account", self.doc.name, "freeze_account")
|
||||
old_value = frappe.db.get_value("Account", self.doc.name, "freeze_account")
|
||||
if old_value and old_value != self.doc.freeze_account:
|
||||
frozen_accounts_modifier = frappe.conn.get_value( 'Accounts Settings', None,
|
||||
frozen_accounts_modifier = frappe.db.get_value( 'Accounts Settings', None,
|
||||
'frozen_accounts_modifier')
|
||||
if not frozen_accounts_modifier or \
|
||||
frozen_accounts_modifier not in frappe.user.get_roles():
|
||||
@@ -131,10 +131,10 @@ class DocType:
|
||||
|
||||
# Check if any previous balance exists
|
||||
def check_gle_exists(self):
|
||||
return frappe.conn.get_value("GL Entry", {"account": self.doc.name})
|
||||
return frappe.db.get_value("GL Entry", {"account": self.doc.name})
|
||||
|
||||
def check_if_child_exists(self):
|
||||
return frappe.conn.sql("""select name from `tabAccount` where parent_account = %s
|
||||
return frappe.db.sql("""select name from `tabAccount` where parent_account = %s
|
||||
and docstatus != 2""", self.doc.name)
|
||||
|
||||
def validate_mandatory(self):
|
||||
@@ -148,7 +148,7 @@ class DocType:
|
||||
return
|
||||
|
||||
if self.doc.account_type == "Warehouse":
|
||||
old_warehouse = cstr(frappe.conn.get_value("Account", self.doc.name, "master_name"))
|
||||
old_warehouse = cstr(frappe.db.get_value("Account", self.doc.name, "master_name"))
|
||||
if old_warehouse != cstr(self.doc.master_name):
|
||||
if old_warehouse:
|
||||
self.validate_warehouse(old_warehouse)
|
||||
@@ -158,7 +158,7 @@ class DocType:
|
||||
throw(_("Master Name is mandatory if account type is Warehouse"))
|
||||
|
||||
def validate_warehouse(self, warehouse):
|
||||
if frappe.conn.get_value("Stock Ledger Entry", {"warehouse": warehouse}):
|
||||
if frappe.db.get_value("Stock Ledger Entry", {"warehouse": warehouse}):
|
||||
throw(_("Stock transactions exist against warehouse ") + warehouse +
|
||||
_(" .You can not assign / modify / remove Master Name"))
|
||||
|
||||
@@ -174,7 +174,7 @@ class DocType:
|
||||
|
||||
def get_authorized_user(self):
|
||||
# Check logged-in user is authorized
|
||||
if frappe.conn.get_value('Accounts Settings', None, 'credit_controller') \
|
||||
if frappe.db.get_value('Accounts Settings', None, 'credit_controller') \
|
||||
in frappe.user.get_roles():
|
||||
return 1
|
||||
|
||||
@@ -182,11 +182,11 @@ class DocType:
|
||||
# Get credit limit
|
||||
credit_limit_from = 'Customer'
|
||||
|
||||
cr_limit = frappe.conn.sql("""select t1.credit_limit from tabCustomer t1, `tabAccount` t2
|
||||
cr_limit = frappe.db.sql("""select t1.credit_limit from tabCustomer t1, `tabAccount` t2
|
||||
where t2.name=%s and t1.name = t2.master_name""", self.doc.name)
|
||||
credit_limit = cr_limit and flt(cr_limit[0][0]) or 0
|
||||
if not credit_limit:
|
||||
credit_limit = frappe.conn.get_value('Company', self.doc.company, 'credit_limit')
|
||||
credit_limit = frappe.db.get_value('Company', self.doc.company, 'credit_limit')
|
||||
credit_limit_from = 'Company'
|
||||
|
||||
# If outstanding greater than credit limit and not authorized person raise exception
|
||||
@@ -219,10 +219,10 @@ class DocType:
|
||||
|
||||
# Validate properties before merging
|
||||
if merge:
|
||||
if not frappe.conn.exists("Account", new):
|
||||
if not frappe.db.exists("Account", new):
|
||||
throw(_("Account ") + new +_(" does not exists"))
|
||||
|
||||
val = list(frappe.conn.get_value("Account", new_account,
|
||||
val = list(frappe.db.get_value("Account", new_account,
|
||||
["group_or_ledger", "debit_or_credit", "is_pl_account", "company"]))
|
||||
|
||||
if val != [self.doc.group_or_ledger, self.doc.debit_or_credit, self.doc.is_pl_account, self.doc.company]:
|
||||
@@ -234,7 +234,7 @@ class DocType:
|
||||
|
||||
def after_rename(self, old, new, merge=False):
|
||||
if not merge:
|
||||
frappe.conn.set_value("Account", new, "account_name",
|
||||
frappe.db.set_value("Account", new, "account_name",
|
||||
" - ".join(new.split(" - ")[:-1]))
|
||||
else:
|
||||
from frappe.utils.nestedset import rebuild_tree
|
||||
@@ -243,13 +243,13 @@ class DocType:
|
||||
def get_master_name(doctype, txt, searchfield, start, page_len, filters):
|
||||
conditions = (" and company='%s'"% filters["company"]) if doctype == "Warehouse" else ""
|
||||
|
||||
return frappe.conn.sql("""select name from `tab%s` where %s like %s %s
|
||||
return frappe.db.sql("""select name from `tab%s` where %s like %s %s
|
||||
order by name limit %s, %s""" %
|
||||
(filters["master_type"], searchfield, "%s", conditions, "%s", "%s"),
|
||||
("%%%s%%" % txt, start, page_len), as_list=1)
|
||||
|
||||
def get_parent_account(doctype, txt, searchfield, start, page_len, filters):
|
||||
return frappe.conn.sql("""select name from tabAccount
|
||||
return frappe.db.sql("""select name from tabAccount
|
||||
where group_or_ledger = 'Group' and docstatus != 2 and company = %s
|
||||
and %s like %s order by name limit %s, %s""" %
|
||||
("%s", searchfield, "%s", "%s", "%s"),
|
||||
|
||||
@@ -13,15 +13,15 @@ class DocType:
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def on_update(self):
|
||||
frappe.conn.set_default("auto_accounting_for_stock", self.doc.auto_accounting_for_stock)
|
||||
frappe.db.set_default("auto_accounting_for_stock", self.doc.auto_accounting_for_stock)
|
||||
|
||||
if cint(self.doc.auto_accounting_for_stock):
|
||||
# set default perpetual account in company
|
||||
for company in frappe.conn.sql("select name from tabCompany"):
|
||||
for company in frappe.db.sql("select name from tabCompany"):
|
||||
frappe.bean("Company", company[0]).save()
|
||||
|
||||
# Create account head for warehouses
|
||||
warehouse_list = frappe.conn.sql("select name, company from tabWarehouse", as_dict=1)
|
||||
warehouse_list = frappe.db.sql("select name, company from tabWarehouse", as_dict=1)
|
||||
warehouse_with_no_company = [d.name for d in warehouse_list if not d.company]
|
||||
if warehouse_with_no_company:
|
||||
frappe.throw(_("Company is missing in following warehouses") + ": \n" +
|
||||
|
||||
@@ -22,7 +22,7 @@ class DocType:
|
||||
msgprint("Bank Account, From Date and To Date are Mandatory")
|
||||
return
|
||||
|
||||
dl = frappe.conn.sql("select t1.name, t1.cheque_no, t1.cheque_date, t2.debit, t2.credit, t1.posting_date, t2.against_account from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t2.parent = t1.name and t2.account = %s and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '') and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1", (self.doc.bank_account, self.doc.from_date, self.doc.to_date))
|
||||
dl = frappe.db.sql("select t1.name, t1.cheque_no, t1.cheque_date, t2.debit, t2.credit, t1.posting_date, t2.against_account from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t2.parent = t1.name and t2.account = %s and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '') and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1", (self.doc.bank_account, self.doc.from_date, self.doc.to_date))
|
||||
|
||||
self.doclist = self.doc.clear_table(self.doclist, 'entries')
|
||||
self.doc.total_amount = 0.0
|
||||
@@ -46,7 +46,7 @@ class DocType:
|
||||
msgprint("Clearance Date can not be before Cheque Date (Row #%s)" %
|
||||
d.idx, raise_exception=1)
|
||||
|
||||
frappe.conn.sql("""update `tabJournal Voucher`
|
||||
frappe.db.sql("""update `tabJournal Voucher`
|
||||
set clearance_date = %s, modified = %s where name=%s""",
|
||||
(d.clearance_date, nowdate(), d.voucher_id))
|
||||
vouchers.append(d.voucher_id)
|
||||
|
||||
@@ -16,7 +16,7 @@ class DocType:
|
||||
|
||||
for d in getlist(self.doclist, 'invoice_details'):
|
||||
if d.invoice_no:
|
||||
inv = frappe.conn.sql("""select c_form_applicable, c_form_no from
|
||||
inv = frappe.db.sql("""select c_form_applicable, c_form_no from
|
||||
`tabSales Invoice` where name = %s and docstatus = 1""", d.invoice_no)
|
||||
|
||||
if not inv:
|
||||
@@ -42,17 +42,17 @@ class DocType:
|
||||
|
||||
def before_cancel(self):
|
||||
# remove cform reference
|
||||
frappe.conn.sql("""update `tabSales Invoice` set c_form_no=null
|
||||
frappe.db.sql("""update `tabSales Invoice` set c_form_no=null
|
||||
where c_form_no=%s""", self.doc.name)
|
||||
|
||||
def set_cform_in_sales_invoices(self):
|
||||
inv = [d.invoice_no for d in getlist(self.doclist, 'invoice_details')]
|
||||
if inv:
|
||||
frappe.conn.sql("""update `tabSales Invoice` set c_form_no=%s, modified=%s
|
||||
frappe.db.sql("""update `tabSales Invoice` set c_form_no=%s, modified=%s
|
||||
where name in (%s)""" % ('%s', '%s', ', '.join(['%s'] * len(inv))),
|
||||
tuple([self.doc.name, self.doc.modified] + inv))
|
||||
|
||||
frappe.conn.sql("""update `tabSales Invoice` set c_form_no = null, modified = %s
|
||||
frappe.db.sql("""update `tabSales Invoice` set c_form_no = null, modified = %s
|
||||
where name not in (%s) and ifnull(c_form_no, '') = %s""" %
|
||||
('%s', ', '.join(['%s']*len(inv)), '%s'),
|
||||
tuple([self.doc.modified] + inv + [self.doc.name]))
|
||||
@@ -61,12 +61,12 @@ class DocType:
|
||||
|
||||
def set_total_invoiced_amount(self):
|
||||
total = sum([flt(d.grand_total) for d in getlist(self.doclist, 'invoice_details')])
|
||||
frappe.conn.set(self.doc, 'total_invoiced_amount', total)
|
||||
frappe.db.set(self.doc, 'total_invoiced_amount', total)
|
||||
|
||||
def get_invoice_details(self, invoice_no):
|
||||
""" Pull details from invoices for referrence """
|
||||
|
||||
inv = frappe.conn.sql("""select posting_date, territory, net_total, grand_total
|
||||
inv = frappe.db.sql("""select posting_date, territory, net_total, grand_total
|
||||
from `tabSales Invoice` where name = %s""", invoice_no)
|
||||
return {
|
||||
'invoice_date' : inv and getdate(inv[0][0]).strftime('%Y-%m-%d') or '',
|
||||
@@ -79,7 +79,7 @@ def get_invoice_nos(doctype, txt, searchfield, start, page_len, filters):
|
||||
from erpnext.utilities import build_filter_conditions
|
||||
conditions, filter_values = build_filter_conditions(filters)
|
||||
|
||||
return frappe.conn.sql("""select name from `tabSales Invoice` where docstatus = 1
|
||||
return frappe.db.sql("""select name from `tabSales Invoice` where docstatus = 1
|
||||
and c_form_applicable = 'Yes' and ifnull(c_form_no, '') = '' %s
|
||||
and %s like %s order by name limit %s, %s""" %
|
||||
(conditions, searchfield, "%s", "%s", "%s"),
|
||||
|
||||
@@ -14,7 +14,7 @@ class DocType(DocTypeNestedSet):
|
||||
self.nsm_parent_field = 'parent_cost_center'
|
||||
|
||||
def autoname(self):
|
||||
company_abbr = frappe.conn.sql("select abbr from tabCompany where name=%s",
|
||||
company_abbr = frappe.db.sql("select abbr from tabCompany where name=%s",
|
||||
self.doc.company)[0][0]
|
||||
self.doc.name = self.doc.cost_center_name.strip() + ' - ' + company_abbr
|
||||
|
||||
@@ -46,10 +46,10 @@ class DocType(DocTypeNestedSet):
|
||||
return 1
|
||||
|
||||
def check_gle_exists(self):
|
||||
return frappe.conn.get_value("GL Entry", {"cost_center": self.doc.name})
|
||||
return frappe.db.get_value("GL Entry", {"cost_center": self.doc.name})
|
||||
|
||||
def check_if_child_exists(self):
|
||||
return frappe.conn.sql("select name from `tabCost Center` where \
|
||||
return frappe.db.sql("select name from `tabCost Center` where \
|
||||
parent_cost_center = %s and docstatus != 2", self.doc.name)
|
||||
|
||||
def validate_budget_details(self):
|
||||
@@ -67,7 +67,7 @@ class DocType(DocTypeNestedSet):
|
||||
"""
|
||||
Cost Center name must be unique
|
||||
"""
|
||||
if (self.doc.fields.get("__islocal") or not self.doc.name) and frappe.conn.sql("select name from `tabCost Center` where cost_center_name = %s and company=%s", (self.doc.cost_center_name, self.doc.company)):
|
||||
if (self.doc.fields.get("__islocal") or not self.doc.name) and frappe.db.sql("select name from `tabCost Center` where cost_center_name = %s and company=%s", (self.doc.cost_center_name, self.doc.company)):
|
||||
msgprint("Cost Center Name already exists, please rename", raise_exception=1)
|
||||
|
||||
self.validate_mandatory()
|
||||
@@ -85,7 +85,7 @@ class DocType(DocTypeNestedSet):
|
||||
|
||||
def after_rename(self, olddn, newdn, merge=False):
|
||||
if not merge:
|
||||
frappe.conn.set_value("Cost Center", newdn, "cost_center_name",
|
||||
frappe.db.set_value("Cost Center", newdn, "cost_center_name",
|
||||
" - ".join(newdn.split(" - ")[:-1]))
|
||||
else:
|
||||
super(DocType, self).after_rename(olddn, newdn, merge)
|
||||
|
||||
@@ -11,7 +11,7 @@ class DocType:
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def set_as_default(self):
|
||||
frappe.conn.set_value("Global Defaults", None, "current_fiscal_year", self.doc.name)
|
||||
frappe.db.set_value("Global Defaults", None, "current_fiscal_year", self.doc.name)
|
||||
frappe.get_obj("Global Defaults").on_update()
|
||||
|
||||
# clear cache
|
||||
@@ -21,7 +21,7 @@ class DocType:
|
||||
Please refresh your browser for the change to take effect."""))
|
||||
|
||||
def validate(self):
|
||||
year_start_end_dates = frappe.conn.sql("""select year_start_date, year_end_date
|
||||
year_start_end_dates = frappe.db.sql("""select year_start_date, year_end_date
|
||||
from `tabFiscal Year` where name=%s""", (self.doc.name))
|
||||
|
||||
if year_start_end_dates:
|
||||
@@ -36,7 +36,7 @@ class DocType:
|
||||
if (getdate(self.doc.year_end_date) - getdate(self.doc.year_start_date)).days > 366:
|
||||
frappe.throw(_("Year Start Date and Year End Date are not within Fiscal Year."))
|
||||
|
||||
year_start_end_dates = frappe.conn.sql("""select name, year_start_date, year_end_date
|
||||
year_start_end_dates = frappe.db.sql("""select name, year_start_date, year_end_date
|
||||
from `tabFiscal Year` where name!=%s""", (self.doc.name))
|
||||
|
||||
for fiscal_year, ysd, yed in year_start_end_dates:
|
||||
|
||||
@@ -42,7 +42,7 @@ class DocType:
|
||||
self.doc.account)
|
||||
|
||||
def pl_must_have_cost_center(self):
|
||||
if frappe.conn.get_value("Account", self.doc.account, "is_pl_account") == "Yes":
|
||||
if frappe.db.get_value("Account", self.doc.account, "is_pl_account") == "Yes":
|
||||
if not self.doc.cost_center and self.doc.voucher_type != 'Period Closing Voucher':
|
||||
frappe.throw(_("Cost Center must be specified for PL Account: ") +
|
||||
self.doc.account)
|
||||
@@ -55,13 +55,13 @@ class DocType:
|
||||
|
||||
def check_pl_account(self):
|
||||
if self.doc.is_opening=='Yes' and \
|
||||
frappe.conn.get_value("Account", self.doc.account, "is_pl_account") == "Yes":
|
||||
frappe.db.get_value("Account", self.doc.account, "is_pl_account") == "Yes":
|
||||
frappe.throw(_("For opening balance entry account can not be a PL account"))
|
||||
|
||||
def validate_account_details(self, adv_adj):
|
||||
"""Account must be ledger, active and not freezed"""
|
||||
|
||||
ret = frappe.conn.sql("""select group_or_ledger, docstatus, company
|
||||
ret = frappe.db.sql("""select group_or_ledger, docstatus, company
|
||||
from tabAccount where name=%s""", self.doc.account, as_dict=1)[0]
|
||||
|
||||
if ret.group_or_ledger=='Group':
|
||||
@@ -80,7 +80,7 @@ class DocType:
|
||||
|
||||
def _get_cost_center_company():
|
||||
if not self.cost_center_company.get(self.doc.cost_center):
|
||||
self.cost_center_company[self.doc.cost_center] = frappe.conn.get_value(
|
||||
self.cost_center_company[self.doc.cost_center] = frappe.db.get_value(
|
||||
"Cost Center", self.doc.cost_center, "company")
|
||||
|
||||
return self.cost_center_company[self.doc.cost_center]
|
||||
@@ -91,10 +91,10 @@ class DocType:
|
||||
|
||||
def check_negative_balance(account, adv_adj=False):
|
||||
if not adv_adj and account:
|
||||
account_details = frappe.conn.get_value("Account", account,
|
||||
account_details = frappe.db.get_value("Account", account,
|
||||
["allow_negative_balance", "debit_or_credit"], as_dict=True)
|
||||
if not account_details["allow_negative_balance"]:
|
||||
balance = frappe.conn.sql("""select sum(debit) - sum(credit) from `tabGL Entry`
|
||||
balance = frappe.db.sql("""select sum(debit) - sum(credit) from `tabGL Entry`
|
||||
where account = %s""", account)
|
||||
balance = account_details["debit_or_credit"] == "Debit" and \
|
||||
flt(balance[0][0]) or -1*flt(balance[0][0])
|
||||
@@ -108,9 +108,9 @@ def check_freezing_date(posting_date, adv_adj=False):
|
||||
except authorized person
|
||||
"""
|
||||
if not adv_adj:
|
||||
acc_frozen_upto = frappe.conn.get_value('Accounts Settings', None, 'acc_frozen_upto')
|
||||
acc_frozen_upto = frappe.db.get_value('Accounts Settings', None, 'acc_frozen_upto')
|
||||
if acc_frozen_upto:
|
||||
bde_auth_role = frappe.conn.get_value( 'Accounts Settings', None,'bde_auth_role')
|
||||
bde_auth_role = frappe.db.get_value( 'Accounts Settings', None,'bde_auth_role')
|
||||
if getdate(posting_date) <= getdate(acc_frozen_upto) \
|
||||
and not bde_auth_role in frappe.user.get_roles():
|
||||
frappe.throw(_("You are not authorized to do/modify back dated entries before ")
|
||||
@@ -118,7 +118,7 @@ def check_freezing_date(posting_date, adv_adj=False):
|
||||
|
||||
def update_outstanding_amt(account, against_voucher_type, against_voucher, on_cancel=False):
|
||||
# get final outstanding amt
|
||||
bal = flt(frappe.conn.sql("""select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||
bal = flt(frappe.db.sql("""select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||
from `tabGL Entry`
|
||||
where against_voucher_type=%s and against_voucher=%s and account = %s""",
|
||||
(against_voucher_type, against_voucher, account))[0][0] or 0.0)
|
||||
@@ -126,7 +126,7 @@ def update_outstanding_amt(account, against_voucher_type, against_voucher, on_ca
|
||||
if against_voucher_type == 'Purchase Invoice':
|
||||
bal = -bal
|
||||
elif against_voucher_type == "Journal Voucher":
|
||||
against_voucher_amount = flt(frappe.conn.sql("""
|
||||
against_voucher_amount = flt(frappe.db.sql("""
|
||||
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||
from `tabGL Entry` where voucher_type = 'Journal Voucher' and voucher_no = %s
|
||||
and account = %s and ifnull(against_voucher, '') = ''""",
|
||||
@@ -143,13 +143,13 @@ def update_outstanding_amt(account, against_voucher_type, against_voucher, on_ca
|
||||
|
||||
# Update outstanding amt on against voucher
|
||||
if against_voucher_type in ["Sales Invoice", "Purchase Invoice"]:
|
||||
frappe.conn.sql("update `tab%s` set outstanding_amount=%s where name='%s'" %
|
||||
frappe.db.sql("update `tab%s` set outstanding_amount=%s where name='%s'" %
|
||||
(against_voucher_type, bal, against_voucher))
|
||||
|
||||
def validate_frozen_account(account, adv_adj=None):
|
||||
frozen_account = frappe.conn.get_value("Account", account, "freeze_account")
|
||||
frozen_account = frappe.db.get_value("Account", account, "freeze_account")
|
||||
if frozen_account == 'Yes' and not adv_adj:
|
||||
frozen_accounts_modifier = frappe.conn.get_value( 'Accounts Settings', None,
|
||||
frozen_accounts_modifier = frappe.db.get_value( 'Accounts Settings', None,
|
||||
'frozen_accounts_modifier')
|
||||
|
||||
if not frozen_accounts_modifier:
|
||||
|
||||
@@ -75,7 +75,7 @@ class DocType(AccountsController):
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
if not d.is_advance and not d.against_voucher and \
|
||||
not d.against_invoice and not d.against_jv:
|
||||
master_type = frappe.conn.get_value("Account", d.account, "master_type")
|
||||
master_type = frappe.db.get_value("Account", d.account, "master_type")
|
||||
if (master_type == 'Customer' and flt(d.credit) > 0) or \
|
||||
(master_type == 'Supplier' and flt(d.debit) > 0):
|
||||
msgprint("Message: Please check Is Advance as 'Yes' against \
|
||||
@@ -87,7 +87,7 @@ class DocType(AccountsController):
|
||||
if d.against_jv == self.doc.name:
|
||||
msgprint("You can not enter current voucher in 'Against JV' column",
|
||||
raise_exception=1)
|
||||
elif not frappe.conn.sql("""select name from `tabJournal Voucher Detail`
|
||||
elif not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||
where account = '%s' and docstatus = 1 and parent = '%s'""" %
|
||||
(d.account, d.against_jv)):
|
||||
msgprint("Against JV: %s is not valid." % d.against_jv, raise_exception=1)
|
||||
@@ -125,12 +125,12 @@ class DocType(AccountsController):
|
||||
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
if d.against_invoice and d.credit:
|
||||
currency = frappe.conn.get_value("Sales Invoice", d.against_invoice, "currency")
|
||||
currency = frappe.db.get_value("Sales Invoice", d.against_invoice, "currency")
|
||||
r.append('%s %s against Invoice: %s' %
|
||||
(cstr(currency), fmt_money(flt(d.credit)), d.against_invoice))
|
||||
|
||||
if d.against_voucher and d.debit:
|
||||
bill_no = frappe.conn.sql("""select bill_no, bill_date, currency
|
||||
bill_no = frappe.db.sql("""select bill_no, bill_date, currency
|
||||
from `tabPurchase Invoice` where name=%s""", d.against_voucher)
|
||||
if bill_no and bill_no[0][0] and bill_no[0][0].lower().strip() \
|
||||
not in ['na', 'not applicable', 'none']:
|
||||
@@ -153,7 +153,7 @@ class DocType(AccountsController):
|
||||
# check account type whether supplier or customer
|
||||
exists = False
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
account_type = frappe.conn.get_value("Account", d.account, "account_type")
|
||||
account_type = frappe.db.get_value("Account", d.account, "account_type")
|
||||
if account_type in ["Supplier", "Customer"]:
|
||||
exists = True
|
||||
break
|
||||
@@ -166,12 +166,12 @@ class DocType(AccountsController):
|
||||
|
||||
def set_print_format_fields(self):
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
account_type, master_type = frappe.conn.get_value("Account", d.account,
|
||||
account_type, master_type = frappe.db.get_value("Account", d.account,
|
||||
["account_type", "master_type"])
|
||||
|
||||
if master_type in ['Supplier', 'Customer']:
|
||||
if not self.doc.pay_to_recd_from:
|
||||
self.doc.pay_to_recd_from = frappe.conn.get_value(master_type,
|
||||
self.doc.pay_to_recd_from = frappe.db.get_value(master_type,
|
||||
' - '.join(d.account.split(' - ')[:-1]),
|
||||
master_type == 'Customer' and 'customer_name' or 'supplier_name')
|
||||
|
||||
@@ -190,7 +190,7 @@ class DocType(AccountsController):
|
||||
if date_diff <= 0: return
|
||||
|
||||
# Get List of Customer Account
|
||||
acc_list = filter(lambda d: frappe.conn.get_value("Account", d.account,
|
||||
acc_list = filter(lambda d: frappe.db.get_value("Account", d.account,
|
||||
"master_type")=='Customer', getlist(self.doclist,'entries'))
|
||||
|
||||
for d in acc_list:
|
||||
@@ -202,11 +202,11 @@ class DocType(AccountsController):
|
||||
|
||||
def get_credit_days_for(self, ac):
|
||||
if not self.credit_days_for.has_key(ac):
|
||||
self.credit_days_for[ac] = cint(frappe.conn.get_value("Account", ac, "credit_days"))
|
||||
self.credit_days_for[ac] = cint(frappe.db.get_value("Account", ac, "credit_days"))
|
||||
|
||||
if not self.credit_days_for[ac]:
|
||||
if self.credit_days_global==-1:
|
||||
self.credit_days_global = cint(frappe.conn.get_value("Company",
|
||||
self.credit_days_global = cint(frappe.db.get_value("Company",
|
||||
self.doc.company, "credit_days"))
|
||||
|
||||
return self.credit_days_global
|
||||
@@ -218,7 +218,7 @@ class DocType(AccountsController):
|
||||
self.is_approving_authority = 0
|
||||
|
||||
# Fetch credit controller role
|
||||
approving_authority = frappe.conn.get_value("Global Defaults", None,
|
||||
approving_authority = frappe.db.get_value("Global Defaults", None,
|
||||
"credit_controller")
|
||||
|
||||
# Check logged-in user is authorized
|
||||
@@ -229,12 +229,12 @@ class DocType(AccountsController):
|
||||
|
||||
def check_account_against_entries(self):
|
||||
for d in self.doclist.get({"parentfield": "entries"}):
|
||||
if d.against_invoice and frappe.conn.get_value("Sales Invoice",
|
||||
if d.against_invoice and frappe.db.get_value("Sales Invoice",
|
||||
d.against_invoice, "debit_to") != d.account:
|
||||
frappe.throw(_("Row #") + cstr(d.idx) + ": " +
|
||||
_("Account is not matching with Debit To account of Sales Invoice"))
|
||||
|
||||
if d.against_voucher and frappe.conn.get_value("Purchase Invoice",
|
||||
if d.against_voucher and frappe.db.get_value("Purchase Invoice",
|
||||
d.against_voucher, "credit_to") != d.account:
|
||||
frappe.throw(_("Row #") + cstr(d.idx) + ": " +
|
||||
_("Account is not matching with Credit To account of Purchase Invoice"))
|
||||
@@ -267,7 +267,7 @@ class DocType(AccountsController):
|
||||
|
||||
def check_credit_limit(self):
|
||||
for d in self.doclist.get({"parentfield": "entries"}):
|
||||
master_type, master_name = frappe.conn.get_value("Account", d.account,
|
||||
master_type, master_name = frappe.db.get_value("Account", d.account,
|
||||
["master_type", "master_name"])
|
||||
if master_type == "Customer" and master_name:
|
||||
super(DocType, self).check_credit_limit(d.account)
|
||||
@@ -328,18 +328,18 @@ class DocType(AccountsController):
|
||||
cond = (flt(self.doc.write_off_amount) > 0) and \
|
||||
' and outstanding_amount <= '+ self.doc.write_off_amount or ''
|
||||
if self.doc.write_off_based_on == 'Accounts Receivable':
|
||||
return frappe.conn.sql("""select name, debit_to, outstanding_amount
|
||||
return frappe.db.sql("""select name, debit_to, outstanding_amount
|
||||
from `tabSales Invoice` where docstatus = 1 and company = %s
|
||||
and outstanding_amount > 0 %s""" % ('%s', cond), self.doc.company)
|
||||
elif self.doc.write_off_based_on == 'Accounts Payable':
|
||||
return frappe.conn.sql("""select name, credit_to, outstanding_amount
|
||||
return frappe.db.sql("""select name, credit_to, outstanding_amount
|
||||
from `tabPurchase Invoice` where docstatus = 1 and company = %s
|
||||
and outstanding_amount > 0 %s""" % ('%s', cond), self.doc.company)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_default_bank_cash_account(company, voucher_type):
|
||||
from erpnext.accounts.utils import get_balance_on
|
||||
account = frappe.conn.get_value("Company", company,
|
||||
account = frappe.db.get_value("Company", company,
|
||||
voucher_type=="Bank Voucher" and "default_bank_account" or "default_cash_account")
|
||||
if account:
|
||||
return {
|
||||
@@ -412,27 +412,27 @@ def get_payment_entry(doc):
|
||||
def get_opening_accounts(company):
|
||||
"""get all balance sheet accounts for opening entry"""
|
||||
from erpnext.accounts.utils import get_balance_on
|
||||
accounts = frappe.conn.sql_list("""select name from tabAccount
|
||||
accounts = frappe.db.sql_list("""select name from tabAccount
|
||||
where group_or_ledger='Ledger' and is_pl_account='No' and company=%s""", company)
|
||||
|
||||
return [{"account": a, "balance": get_balance_on(a)} for a in accounts]
|
||||
|
||||
def get_against_purchase_invoice(doctype, txt, searchfield, start, page_len, filters):
|
||||
return frappe.conn.sql("""select name, credit_to, outstanding_amount, bill_no, bill_date
|
||||
return frappe.db.sql("""select name, credit_to, outstanding_amount, bill_no, bill_date
|
||||
from `tabPurchase Invoice` where credit_to = %s and docstatus = 1
|
||||
and outstanding_amount > 0 and %s like %s order by name desc limit %s, %s""" %
|
||||
("%s", searchfield, "%s", "%s", "%s"),
|
||||
(filters["account"], "%%%s%%" % txt, start, page_len))
|
||||
|
||||
def get_against_sales_invoice(doctype, txt, searchfield, start, page_len, filters):
|
||||
return frappe.conn.sql("""select name, debit_to, outstanding_amount
|
||||
return frappe.db.sql("""select name, debit_to, outstanding_amount
|
||||
from `tabSales Invoice` where debit_to = %s and docstatus = 1
|
||||
and outstanding_amount > 0 and `%s` like %s order by name desc limit %s, %s""" %
|
||||
("%s", searchfield, "%s", "%s", "%s"),
|
||||
(filters["account"], "%%%s%%" % txt, start, page_len))
|
||||
|
||||
def get_against_jv(doctype, txt, searchfield, start, page_len, filters):
|
||||
return frappe.conn.sql("""select jv.name, jv.posting_date, jv.user_remark
|
||||
return frappe.db.sql("""select jv.name, jv.posting_date, jv.user_remark
|
||||
from `tabJournal Voucher` jv, `tabJournal Voucher Detail` jv_detail
|
||||
where jv_detail.parent = jv.name and jv_detail.account = %s and jv.docstatus = 1
|
||||
and jv.%s like %s order by jv.name desc limit %s, %s""" %
|
||||
@@ -443,7 +443,7 @@ def get_against_jv(doctype, txt, searchfield, start, page_len, filters):
|
||||
def get_outstanding(args):
|
||||
args = eval(args)
|
||||
if args.get("doctype") == "Journal Voucher" and args.get("account"):
|
||||
against_jv_amount = frappe.conn.sql("""
|
||||
against_jv_amount = frappe.db.sql("""
|
||||
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||
from `tabJournal Voucher Detail` where parent=%s and account=%s
|
||||
and ifnull(against_invoice, '')='' and ifnull(against_voucher, '')=''
|
||||
@@ -457,11 +457,11 @@ def get_outstanding(args):
|
||||
|
||||
elif args.get("doctype") == "Sales Invoice":
|
||||
return {
|
||||
"credit": flt(frappe.conn.get_value("Sales Invoice", args["docname"],
|
||||
"credit": flt(frappe.db.get_value("Sales Invoice", args["docname"],
|
||||
"outstanding_amount"))
|
||||
}
|
||||
elif args.get("doctype") == "Purchase Invoice":
|
||||
return {
|
||||
"debit": flt(frappe.conn.get_value("Purchase Invoice", args["docname"],
|
||||
"debit": flt(frappe.db.get_value("Purchase Invoice", args["docname"],
|
||||
"outstanding_amount"))
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class TestJournalVoucher(unittest.TestCase):
|
||||
jv_invoice.insert()
|
||||
jv_invoice.submit()
|
||||
|
||||
self.assertTrue(not frappe.conn.sql("""select name from `tabJournal Voucher Detail`
|
||||
self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||
where against_jv=%s""", jv_invoice.doc.name))
|
||||
|
||||
jv_payment = frappe.bean(copy=test_records[0])
|
||||
@@ -21,16 +21,16 @@ class TestJournalVoucher(unittest.TestCase):
|
||||
jv_payment.insert()
|
||||
jv_payment.submit()
|
||||
|
||||
self.assertTrue(frappe.conn.sql("""select name from `tabJournal Voucher Detail`
|
||||
self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||
where against_jv=%s""", jv_invoice.doc.name))
|
||||
|
||||
self.assertTrue(frappe.conn.sql("""select name from `tabJournal Voucher Detail`
|
||||
self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||
where against_jv=%s and credit=400""", jv_invoice.doc.name))
|
||||
|
||||
# cancel jv_invoice
|
||||
jv_invoice.cancel()
|
||||
|
||||
self.assertTrue(not frappe.conn.sql("""select name from `tabJournal Voucher Detail`
|
||||
self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||
where against_jv=%s""", jv_invoice.doc.name))
|
||||
|
||||
def test_jv_against_stock_account(self):
|
||||
@@ -47,7 +47,7 @@ class TestJournalVoucher(unittest.TestCase):
|
||||
set_perpetual_inventory(0)
|
||||
|
||||
def test_monthly_budget_crossed_ignore(self):
|
||||
frappe.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore")
|
||||
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore")
|
||||
self.clear_account_balance()
|
||||
|
||||
jv = frappe.bean(copy=test_records[0])
|
||||
@@ -57,12 +57,12 @@ class TestJournalVoucher(unittest.TestCase):
|
||||
jv.doclist[1].credit = 20000.0
|
||||
jv.insert()
|
||||
jv.submit()
|
||||
self.assertTrue(frappe.conn.get_value("GL Entry",
|
||||
self.assertTrue(frappe.db.get_value("GL Entry",
|
||||
{"voucher_type": "Journal Voucher", "voucher_no": jv.doc.name}))
|
||||
|
||||
def test_monthly_budget_crossed_stop(self):
|
||||
from erpnext.accounts.utils import BudgetError
|
||||
frappe.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop")
|
||||
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop")
|
||||
self.clear_account_balance()
|
||||
|
||||
jv = frappe.bean(copy=test_records[0])
|
||||
@@ -74,14 +74,14 @@ class TestJournalVoucher(unittest.TestCase):
|
||||
|
||||
self.assertRaises(BudgetError, jv.submit)
|
||||
|
||||
frappe.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore")
|
||||
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore")
|
||||
|
||||
def test_yearly_budget_crossed_stop(self):
|
||||
from erpnext.accounts.utils import BudgetError
|
||||
self.clear_account_balance()
|
||||
self.test_monthly_budget_crossed_ignore()
|
||||
|
||||
frappe.conn.set_value("Company", "_Test Company", "yearly_bgt_flag", "Stop")
|
||||
frappe.db.set_value("Company", "_Test Company", "yearly_bgt_flag", "Stop")
|
||||
|
||||
jv = frappe.bean(copy=test_records[0])
|
||||
jv.doc.posting_date = "2013-08-12"
|
||||
@@ -93,11 +93,11 @@ class TestJournalVoucher(unittest.TestCase):
|
||||
|
||||
self.assertRaises(BudgetError, jv.submit)
|
||||
|
||||
frappe.conn.set_value("Company", "_Test Company", "yearly_bgt_flag", "Ignore")
|
||||
frappe.db.set_value("Company", "_Test Company", "yearly_bgt_flag", "Ignore")
|
||||
|
||||
def test_monthly_budget_on_cancellation(self):
|
||||
from erpnext.accounts.utils import BudgetError
|
||||
frappe.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop")
|
||||
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop")
|
||||
self.clear_account_balance()
|
||||
|
||||
jv = frappe.bean(copy=test_records[0])
|
||||
@@ -107,7 +107,7 @@ class TestJournalVoucher(unittest.TestCase):
|
||||
jv.doclist[2].debit = 30000.0
|
||||
jv.submit()
|
||||
|
||||
self.assertTrue(frappe.conn.get_value("GL Entry",
|
||||
self.assertTrue(frappe.db.get_value("GL Entry",
|
||||
{"voucher_type": "Journal Voucher", "voucher_no": jv.doc.name}))
|
||||
|
||||
jv1 = frappe.bean(copy=test_records[0])
|
||||
@@ -117,15 +117,15 @@ class TestJournalVoucher(unittest.TestCase):
|
||||
jv1.doclist[1].credit = 40000.0
|
||||
jv1.submit()
|
||||
|
||||
self.assertTrue(frappe.conn.get_value("GL Entry",
|
||||
self.assertTrue(frappe.db.get_value("GL Entry",
|
||||
{"voucher_type": "Journal Voucher", "voucher_no": jv1.doc.name}))
|
||||
|
||||
self.assertRaises(BudgetError, jv.cancel)
|
||||
|
||||
frappe.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore")
|
||||
frappe.db.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore")
|
||||
|
||||
def clear_account_balance(self):
|
||||
frappe.conn.sql("""delete from `tabGL Entry`""")
|
||||
frappe.db.sql("""delete from `tabGL Entry`""")
|
||||
|
||||
|
||||
test_records = [
|
||||
|
||||
@@ -33,7 +33,7 @@ class DocType:
|
||||
ret['company'] = get_companies()
|
||||
|
||||
#--- to get fiscal year and start_date of that fiscal year -----
|
||||
res = frappe.conn.sql("select name, year_start_date from `tabFiscal Year`")
|
||||
res = frappe.db.sql("select name, year_start_date from `tabFiscal Year`")
|
||||
ret['fiscal_year'] = [r[0] for r in res]
|
||||
ret['start_dates'] = {}
|
||||
for r in res:
|
||||
@@ -41,7 +41,7 @@ class DocType:
|
||||
|
||||
#--- from month and to month (for MIS - Comparison Report) -------
|
||||
month_list = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
|
||||
fiscal_start_month = frappe.conn.sql("select MONTH(year_start_date) from `tabFiscal Year` where name = %s",(frappe.defaults.get_global_default("fiscal_year")))
|
||||
fiscal_start_month = frappe.db.sql("select MONTH(year_start_date) from `tabFiscal Year` where name = %s",(frappe.defaults.get_global_default("fiscal_year")))
|
||||
fiscal_start_month = fiscal_start_month and fiscal_start_month[0][0] or 1
|
||||
mon = ['']
|
||||
for i in range(fiscal_start_month,13): mon.append(month_list[i-1])
|
||||
@@ -76,7 +76,7 @@ class DocType:
|
||||
return self.return_data
|
||||
|
||||
def get_children(self, parent_account, level, pl, company, fy):
|
||||
cl = frappe.conn.sql("select distinct account_name, name, debit_or_credit, lft, rgt from `tabAccount` where ifnull(parent_account, '') = %s and ifnull(is_pl_account, 'No')=%s and company=%s and docstatus != 2 order by name asc", (parent_account, pl, company))
|
||||
cl = frappe.db.sql("select distinct account_name, name, debit_or_credit, lft, rgt from `tabAccount` where ifnull(parent_account, '') = %s and ifnull(is_pl_account, 'No')=%s and company=%s and docstatus != 2 order by name asc", (parent_account, pl, company))
|
||||
level0_diff = [0 for p in self.period_list]
|
||||
if pl=='Yes' and level==0: # switch for income & expenses
|
||||
cl = [c for c in cl]
|
||||
@@ -123,7 +123,7 @@ class DocType:
|
||||
self.return_data.append([4, 'Total '+c[0]] + totals)
|
||||
|
||||
def define_periods(self, year, period):
|
||||
ysd = frappe.conn.sql("select year_start_date from `tabFiscal Year` where name=%s", year)
|
||||
ysd = frappe.db.sql("select year_start_date from `tabFiscal Year` where name=%s", year)
|
||||
ysd = ysd and ysd[0][0] or ''
|
||||
|
||||
self.ysd = ysd
|
||||
|
||||
@@ -16,17 +16,17 @@ class DocType:
|
||||
|
||||
def set_account_type(self):
|
||||
self.doc.account_type = self.doc.account and \
|
||||
frappe.conn.get_value("Account", self.doc.account, "debit_or_credit").lower() or ""
|
||||
frappe.db.get_value("Account", self.doc.account, "debit_or_credit").lower() or ""
|
||||
|
||||
def get_voucher_details(self):
|
||||
total_amount = frappe.conn.sql("""select sum(%s) from `tabGL Entry`
|
||||
total_amount = frappe.db.sql("""select sum(%s) from `tabGL Entry`
|
||||
where voucher_type = %s and voucher_no = %s
|
||||
and account = %s""" %
|
||||
(self.doc.account_type, '%s', '%s', '%s'),
|
||||
(self.doc.voucher_type, self.doc.voucher_no, self.doc.account))
|
||||
|
||||
total_amount = total_amount and flt(total_amount[0][0]) or 0
|
||||
reconciled_payment = frappe.conn.sql("""
|
||||
reconciled_payment = frappe.db.sql("""
|
||||
select sum(ifnull(%s, 0)) - sum(ifnull(%s, 0)) from `tabGL Entry` where
|
||||
against_voucher = %s and voucher_no != %s
|
||||
and account = %s""" %
|
||||
@@ -63,7 +63,7 @@ class DocType:
|
||||
cond += self.doc.amt_less_than and \
|
||||
' and t2.' + dc+' <= ' + self.doc.amt_less_than or ''
|
||||
|
||||
gle = frappe.conn.sql("""
|
||||
gle = frappe.db.sql("""
|
||||
select t1.name as voucher_no, t1.posting_date, t1.total_debit as total_amt,
|
||||
sum(ifnull(t2.credit, 0)) - sum(ifnull(t2.debit, 0)) as amt_due, t1.remark,
|
||||
t2.against_account, t2.name as voucher_detail_no
|
||||
@@ -99,7 +99,7 @@ class DocType:
|
||||
2. split into multiple rows if partially adjusted, assign against voucher
|
||||
3. submit payment voucher
|
||||
"""
|
||||
if not self.doc.voucher_no or not frappe.conn.sql("""select name from `tab%s`
|
||||
if not self.doc.voucher_no or not frappe.db.sql("""select name from `tab%s`
|
||||
where name = %s""" % (self.doc.voucher_type, '%s'), self.doc.voucher_no):
|
||||
msgprint("Please select valid Voucher No to proceed", raise_exception=1)
|
||||
|
||||
@@ -130,7 +130,7 @@ class DocType:
|
||||
def gl_entry_details(doctype, txt, searchfield, start, page_len, filters):
|
||||
from erpnext.controllers.queries import get_match_cond
|
||||
|
||||
return frappe.conn.sql("""select gle.voucher_no, gle.posting_date,
|
||||
return frappe.db.sql("""select gle.voucher_no, gle.posting_date,
|
||||
gle.%(account_type)s from `tabGL Entry` gle
|
||||
where gle.account = '%(acc)s'
|
||||
and gle.voucher_type = '%(dt)s'
|
||||
@@ -153,7 +153,7 @@ def gl_entry_details(doctype, txt, searchfield, start, page_len, filters):
|
||||
"dt":filters["dt"],
|
||||
"acc":filters["acc"],
|
||||
"account_type": filters['account_type'],
|
||||
'mcond':get_match_cond(doctype, searchfield),
|
||||
'mcond':get_match_cond(doctype),
|
||||
'txt': "%%%s%%" % txt,
|
||||
"start": start,
|
||||
"page_len": page_len
|
||||
|
||||
@@ -21,11 +21,11 @@ class DocType(AccountsController):
|
||||
self.make_gl_entries()
|
||||
|
||||
def on_cancel(self):
|
||||
frappe.conn.sql("""delete from `tabGL Entry`
|
||||
frappe.db.sql("""delete from `tabGL Entry`
|
||||
where voucher_type = 'Period Closing Voucher' and voucher_no=%s""", self.doc.name)
|
||||
|
||||
def validate_account_head(self):
|
||||
debit_or_credit, is_pl_account = frappe.conn.get_value("Account",
|
||||
debit_or_credit, is_pl_account = frappe.db.get_value("Account",
|
||||
self.doc.closing_account_head, ["debit_or_credit", "is_pl_account"])
|
||||
|
||||
if debit_or_credit != 'Credit' or is_pl_account != 'No':
|
||||
@@ -36,7 +36,7 @@ class DocType(AccountsController):
|
||||
from erpnext.accounts.utils import get_fiscal_year
|
||||
self.year_start_date = get_fiscal_year(self.doc.posting_date, self.doc.fiscal_year)[1]
|
||||
|
||||
pce = frappe.conn.sql("""select name from `tabPeriod Closing Voucher`
|
||||
pce = frappe.db.sql("""select name from `tabPeriod Closing Voucher`
|
||||
where posting_date > %s and fiscal_year = %s and docstatus = 1""",
|
||||
(self.doc.posting_date, self.doc.fiscal_year))
|
||||
if pce and pce[0][0]:
|
||||
@@ -44,7 +44,7 @@ class DocType(AccountsController):
|
||||
_("has been made after posting date") + ": " + self.doc.posting_date)
|
||||
|
||||
def validate_pl_balances(self):
|
||||
income_bal = frappe.conn.sql("""
|
||||
income_bal = frappe.db.sql("""
|
||||
select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0))
|
||||
from `tabGL Entry` t1, tabAccount t2
|
||||
where t1.account = t2.name and t1.posting_date between %s and %s
|
||||
@@ -52,7 +52,7 @@ class DocType(AccountsController):
|
||||
and t2.docstatus < 2 and t2.company = %s""",
|
||||
(self.year_start_date, self.doc.posting_date, self.doc.company))
|
||||
|
||||
expense_bal = frappe.conn.sql("""
|
||||
expense_bal = frappe.db.sql("""
|
||||
select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0))
|
||||
from `tabGL Entry` t1, tabAccount t2
|
||||
where t1.account = t2.name and t1.posting_date between %s and %s
|
||||
@@ -68,7 +68,7 @@ class DocType(AccountsController):
|
||||
|
||||
def get_pl_balances(self):
|
||||
"""Get balance for pl accounts"""
|
||||
return frappe.conn.sql("""
|
||||
return frappe.db.sql("""
|
||||
select t1.account, sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) as balance
|
||||
from `tabGL Entry` t1, `tabAccount` t2
|
||||
where t1.account = t2.name and ifnull(t2.is_pl_account, 'No') = 'Yes'
|
||||
|
||||
@@ -9,7 +9,7 @@ import frappe
|
||||
class TestPeriodClosingVoucher(unittest.TestCase):
|
||||
def test_closing_entry(self):
|
||||
# clear GL Entries
|
||||
frappe.conn.sql("""delete from `tabGL Entry`""")
|
||||
frappe.db.sql("""delete from `tabGL Entry`""")
|
||||
|
||||
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher import test_records as jv_records
|
||||
jv = frappe.bean(copy=jv_records[2])
|
||||
@@ -27,7 +27,7 @@ class TestPeriodClosingVoucher(unittest.TestCase):
|
||||
pcv.insert()
|
||||
pcv.submit()
|
||||
|
||||
gl_entries = frappe.conn.sql("""select account, debit, credit
|
||||
gl_entries = frappe.db.sql("""select account, debit, credit
|
||||
from `tabGL Entry` where voucher_type='Period Closing Voucher' and voucher_no=%s
|
||||
order by account asc, debit asc""", pcv.doc.name, as_dict=1)
|
||||
|
||||
|
||||
@@ -74,5 +74,5 @@ cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn)
|
||||
|
||||
|
||||
cur_frm.fields_dict.user.get_query = function(doc,cdt,cdn) {
|
||||
return{ query:"frappe.core.doctype.profile.profile.profile_query"}
|
||||
return{ query:"frappe.core.doctype.user.user.user_query"}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class DocType:
|
||||
self.validate_all_link_fields()
|
||||
|
||||
def check_for_duplicate(self):
|
||||
res = frappe.conn.sql("""select name, user from `tabPOS Setting`
|
||||
res = frappe.db.sql("""select name, user from `tabPOS Setting`
|
||||
where ifnull(user, '') = %s and name != %s and company = %s""",
|
||||
(self.doc.user, self.doc.name, self.doc.company))
|
||||
if res:
|
||||
@@ -46,14 +46,14 @@ class DocType:
|
||||
|
||||
for link_dt, dn_list in accounts.items():
|
||||
for link_dn in dn_list:
|
||||
if link_dn and not frappe.conn.exists({"doctype": link_dt,
|
||||
if link_dn and not frappe.db.exists({"doctype": link_dt,
|
||||
"company": self.doc.company, "name": link_dn}):
|
||||
frappe.throw(link_dn +_(" does not belong to ") + self.doc.company)
|
||||
|
||||
def on_update(self):
|
||||
frappe.defaults.clear_default("is_pos")
|
||||
|
||||
pos_view_users = frappe.conn.sql_list("""select user from `tabPOS Setting`""")
|
||||
pos_view_users = frappe.db.sql_list("""select user from `tabPOS Setting`""")
|
||||
for user in pos_view_users:
|
||||
if user:
|
||||
frappe.defaults.set_user_default("is_pos", 1, user)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-24 12:15:51",
|
||||
"docstatus": 0,
|
||||
"modified": "2014-01-29 13:08:24",
|
||||
"modified": "2014-01-29 13:08:25",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -48,7 +48,7 @@
|
||||
"label": "User",
|
||||
"oldfieldname": "user",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Profile",
|
||||
"options": "User",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
|
||||
38
erpnext/accounts/doctype/pricing_rule/pricing_rule.py
Normal file
38
erpnext/accounts/doctype/pricing_rule/pricing_rule.py
Normal file
@@ -0,0 +1,38 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# MIT License. See license.txt
|
||||
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import throw, _
|
||||
from frappe.model.controller import DocListController
|
||||
|
||||
class DocType(DocListController):
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def validate(self):
|
||||
self.validate_mandatory()
|
||||
self.cleanup_fields_value()
|
||||
|
||||
def validate_mandatory(self):
|
||||
for field in ["apply_on", "applicable_for", "price_or_discount"]:
|
||||
val = self.doc.fields.get("applicable_for")
|
||||
if val and not self.doc.fields.get(frappe.scrub(val)):
|
||||
throw("{fname} {msg}".format(fname = _(val), msg = _(" is mandatory")),
|
||||
frappe.MandatoryError)
|
||||
|
||||
def cleanup_fields_value(self):
|
||||
for logic_field in ["apply_on", "applicable_for", "price_or_discount"]:
|
||||
fieldname = frappe.scrub(self.doc.fields.get(logic_field) or "")
|
||||
|
||||
# reset all values except for the logic field
|
||||
options = (self.meta.get_options(logic_field) or "").split("\n")
|
||||
for f in options:
|
||||
if not f: continue
|
||||
|
||||
f = frappe.scrub(f)
|
||||
if f!=fieldname:
|
||||
self.doc.fields[f] = None
|
||||
|
||||
261
erpnext/accounts/doctype/pricing_rule/pricing_rule.txt
Normal file
261
erpnext/accounts/doctype/pricing_rule/pricing_rule.txt
Normal file
@@ -0,0 +1,261 @@
|
||||
[
|
||||
{
|
||||
"creation": "2014-02-21 15:02:51",
|
||||
"docstatus": 0,
|
||||
"modified": "2014-03-05 18:23:34",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"autoname": "PRULE.#####",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Master",
|
||||
"icon": "icon-gift",
|
||||
"istable": 0,
|
||||
"module": "Accounts",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"name": "__common__",
|
||||
"parent": "Pricing Rule",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Pricing Rule",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Pricing Rule"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "basic_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Basic Section"
|
||||
},
|
||||
{
|
||||
"default": "Today",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "valid_from",
|
||||
"fieldtype": "Date",
|
||||
"label": "Valid From"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "valid_upto",
|
||||
"fieldtype": "Date",
|
||||
"label": "Valid Upto"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "col_break1",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "priority",
|
||||
"fieldtype": "Select",
|
||||
"label": "Priority",
|
||||
"options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "disable",
|
||||
"fieldtype": "Check",
|
||||
"label": "Disable"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "price_discount_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Price / Discount"
|
||||
},
|
||||
{
|
||||
"default": "Discount Percentage",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "price_or_discount",
|
||||
"fieldtype": "Select",
|
||||
"label": "Price or Discount",
|
||||
"options": "\nPrice\nDiscount Percentage",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "col_break2",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.price_or_discount==\"Price\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "price",
|
||||
"fieldtype": "Float",
|
||||
"label": "Price"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.price_or_discount==\"Discount Percentage\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "discount_percentage",
|
||||
"fieldtype": "Float",
|
||||
"label": "Discount Percentage"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.price_or_discount==\"Discount Percentage\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "for_price_list",
|
||||
"fieldtype": "Link",
|
||||
"label": "For Price List",
|
||||
"options": "Price List"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "applicability_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Applicability"
|
||||
},
|
||||
{
|
||||
"default": "Item Code",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "apply_on",
|
||||
"fieldtype": "Select",
|
||||
"label": "Apply On",
|
||||
"options": "\nItem Code\nItem Group\nBrand",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.apply_on==\"Item Code\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "item_code",
|
||||
"fieldtype": "Link",
|
||||
"label": "Item Code",
|
||||
"options": "Item",
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.apply_on==\"Item Group\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "item_group",
|
||||
"fieldtype": "Link",
|
||||
"label": "Item Group",
|
||||
"options": "Item Group"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.apply_on==\"Brand\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "brand",
|
||||
"fieldtype": "Link",
|
||||
"label": "Brand",
|
||||
"options": "Brand"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "col_break3",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "applicable_for",
|
||||
"fieldtype": "Select",
|
||||
"label": "Applicable For",
|
||||
"options": "\nCustomer\nCustomer Group\nTerritory\nSales Partner\nCampaign\nSupplier\nSupplier Type"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.applicable_for==\"Customer\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "customer",
|
||||
"fieldtype": "Link",
|
||||
"label": "Customer",
|
||||
"options": "Customer"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.applicable_for==\"Customer Group\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "customer_group",
|
||||
"fieldtype": "Link",
|
||||
"label": "Customer Group",
|
||||
"options": "Customer Group"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.applicable_for==\"Territory\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "territory",
|
||||
"fieldtype": "Link",
|
||||
"label": "Territory",
|
||||
"options": "Territory"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.applicable_for==\"Sales Partner\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "sales_partner",
|
||||
"fieldtype": "Link",
|
||||
"label": "Sales Partner",
|
||||
"options": "Sales Partner"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.applicable_for==\"Campaign\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "campaign",
|
||||
"fieldtype": "Link",
|
||||
"label": "Campaign",
|
||||
"options": "Campaign"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.applicable_for==\"Supplier\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "supplier",
|
||||
"fieldtype": "Link",
|
||||
"label": "Supplier",
|
||||
"options": "Supplier"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.applicable_for==\"Supplier Type\"",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "supplier_type",
|
||||
"fieldtype": "Link",
|
||||
"label": "Supplier Type",
|
||||
"options": "Supplier Type"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "min_qty",
|
||||
"fieldtype": "Float",
|
||||
"label": "Min Qty"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "max_qty",
|
||||
"fieldtype": "Float",
|
||||
"label": "Max Qty"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"role": "Accounts Manager"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"role": "Sales Manager"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"role": "Purchase Manager"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"role": "Website Manager"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"role": "System Manager"
|
||||
}
|
||||
]
|
||||
79
erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
Normal file
79
erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
Normal file
@@ -0,0 +1,79 @@
|
||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import unittest
|
||||
import frappe
|
||||
|
||||
class TestPricingRule(unittest.TestCase):
|
||||
def test_pricing_rule_for_discount(self):
|
||||
from erpnext.stock.get_item_details import get_item_details
|
||||
from frappe import MandatoryError
|
||||
|
||||
test_record = [{
|
||||
"doctype": "Pricing Rule",
|
||||
"apply_on": "Item Code",
|
||||
"item_code": "_Test Item",
|
||||
"price_or_discount": "Discount Percentage",
|
||||
"price": 0,
|
||||
"discount_percentage": 10,
|
||||
}]
|
||||
frappe.bean(copy=test_record).insert()
|
||||
|
||||
args = frappe._dict({
|
||||
"item_code": "_Test Item",
|
||||
"company": "_Test Company",
|
||||
"price_list": "_Test Price List",
|
||||
"currency": "_Test Currency",
|
||||
"doctype": "Sales Order",
|
||||
"conversion_rate": 1,
|
||||
"price_list_currency": "_Test Currency",
|
||||
"plc_conversion_rate": 1,
|
||||
"order_type": "Sales",
|
||||
"transaction_type": "selling",
|
||||
"customer": "_Test Customer",
|
||||
})
|
||||
|
||||
details = get_item_details(args)
|
||||
self.assertEquals(details.get("discount_percentage"), 10)
|
||||
|
||||
prule = frappe.bean(copy=test_record)
|
||||
prule.doc.applicable_for = "Customer"
|
||||
self.assertRaises(MandatoryError, prule.insert)
|
||||
prule.doc.customer = "_Test Customer"
|
||||
prule.doc.discount_percentage = 20
|
||||
prule.insert()
|
||||
details = get_item_details(args)
|
||||
self.assertEquals(details.get("discount_percentage"), 20)
|
||||
|
||||
prule = frappe.bean(copy=test_record)
|
||||
prule.doc.apply_on = "Item Group"
|
||||
prule.doc.item_group = "All Item Groups"
|
||||
prule.doc.discount_percentage = 15
|
||||
prule.insert()
|
||||
|
||||
args.customer = None
|
||||
details = get_item_details(args)
|
||||
self.assertEquals(details.get("discount_percentage"), 10)
|
||||
|
||||
prule = frappe.bean(copy=test_record)
|
||||
prule.doc.applicable_for = "Campaign"
|
||||
prule.doc.campaign = "_Test Campaign"
|
||||
prule.doc.discount_percentage = 5
|
||||
prule.doc.priority = 8
|
||||
prule.insert()
|
||||
|
||||
args.campaign = "_Test Campaign"
|
||||
details = get_item_details(args)
|
||||
self.assertEquals(details.get("discount_percentage"), 5)
|
||||
|
||||
frappe.db.sql("update `tabPricing Rule` set priority=NULL where campaign='_Test Campaign'")
|
||||
details = get_item_details(args)
|
||||
self.assertEquals(details.get("discount_percentage"), 15)
|
||||
|
||||
args.item_code = "_Test Item 2"
|
||||
details = get_item_details(args)
|
||||
self.assertEquals(details.get("discount_percentage"), 15)
|
||||
|
||||
frappe.db.sql("delete from `tabPricing Rule`")
|
||||
@@ -73,7 +73,7 @@ class DocType(BuyingController):
|
||||
def check_active_purchase_items(self):
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
if d.item_code: # extra condn coz item_code is not mandatory in PV
|
||||
valid_item = frappe.conn.sql("select docstatus,is_purchase_item from tabItem where name = %s",d.item_code)
|
||||
valid_item = frappe.db.sql("select docstatus,is_purchase_item from tabItem where name = %s",d.item_code)
|
||||
if valid_item[0][0] == 2:
|
||||
msgprint("Item : '%s' is Inactive, you can restore it from Trash" %(d.item_code))
|
||||
raise Exception
|
||||
@@ -93,7 +93,7 @@ class DocType(BuyingController):
|
||||
def validate_bill_no(self):
|
||||
if self.doc.bill_no and self.doc.bill_no.lower().strip() \
|
||||
not in ['na', 'not applicable', 'none']:
|
||||
b_no = frappe.conn.sql("""select bill_no, name, ifnull(is_opening,'') from `tabPurchase Invoice`
|
||||
b_no = frappe.db.sql("""select bill_no, name, ifnull(is_opening,'') from `tabPurchase Invoice`
|
||||
where bill_no = %s and credit_to = %s and docstatus = 1 and name != %s""",
|
||||
(self.doc.bill_no, self.doc.credit_to, self.doc.name))
|
||||
if b_no and cstr(b_no[0][2]) == cstr(self.doc.is_opening):
|
||||
@@ -109,7 +109,7 @@ class DocType(BuyingController):
|
||||
self.doc.remarks = "No Remarks"
|
||||
|
||||
def validate_credit_acc(self):
|
||||
acc = frappe.conn.sql("select debit_or_credit, is_pl_account from tabAccount where name = %s",
|
||||
acc = frappe.db.sql("select debit_or_credit, is_pl_account from tabAccount where name = %s",
|
||||
self.doc.credit_to)
|
||||
if not acc:
|
||||
msgprint("Account: "+ self.doc.credit_to + "does not exist")
|
||||
@@ -125,7 +125,7 @@ class DocType(BuyingController):
|
||||
# ------------------------------------------------------------
|
||||
def check_for_acc_head_of_supplier(self):
|
||||
if self.doc.supplier and self.doc.credit_to:
|
||||
acc_head = frappe.conn.sql("select master_name from `tabAccount` where name = %s", self.doc.credit_to)
|
||||
acc_head = frappe.db.sql("select master_name from `tabAccount` where name = %s", self.doc.credit_to)
|
||||
|
||||
if (acc_head and cstr(acc_head[0][0]) != cstr(self.doc.supplier)) or (not acc_head and (self.doc.credit_to != cstr(self.doc.supplier) + " - " + self.company_abbr)):
|
||||
msgprint("Credit To: %s do not match with Supplier: %s for Company: %s.\n If both correctly entered, please select Master Type and Master Name in account master." %(self.doc.credit_to,self.doc.supplier,self.doc.company), raise_exception=1)
|
||||
@@ -137,7 +137,7 @@ class DocType(BuyingController):
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
if d.purchase_order and not d.purchase_order in check_list and not d.purchase_receipt:
|
||||
check_list.append(d.purhcase_order)
|
||||
stopped = frappe.conn.sql("select name from `tabPurchase Order` where status = 'Stopped' and name = '%s'" % d.purchase_order)
|
||||
stopped = frappe.db.sql("select name from `tabPurchase Order` where status = 'Stopped' and name = '%s'" % d.purchase_order)
|
||||
if stopped:
|
||||
msgprint("One cannot do any transaction against 'Purchase Order' : %s, it's status is 'Stopped'" % (d.purhcase_order))
|
||||
raise Exception
|
||||
@@ -218,14 +218,14 @@ class DocType(BuyingController):
|
||||
self.doc.against_expense_account = ",".join(against_accounts)
|
||||
|
||||
def po_required(self):
|
||||
if frappe.conn.get_value("Buying Settings", None, "po_required") == 'Yes':
|
||||
if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes':
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
if not d.purchase_order:
|
||||
msgprint("Purchse Order No. required against item %s"%d.item_code)
|
||||
raise Exception
|
||||
|
||||
def pr_required(self):
|
||||
if frappe.conn.get_value("Buying Settings", None, "pr_required") == 'Yes':
|
||||
if frappe.db.get_value("Buying Settings", None, "pr_required") == 'Yes':
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
if not d.purchase_receipt:
|
||||
msgprint("Purchase Receipt No. required against item %s"%d.item_code)
|
||||
@@ -238,11 +238,11 @@ class DocType(BuyingController):
|
||||
def check_prev_docstatus(self):
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
if d.purchase_order:
|
||||
submitted = frappe.conn.sql("select name from `tabPurchase Order` where docstatus = 1 and name = '%s'" % d.purchase_order)
|
||||
submitted = frappe.db.sql("select name from `tabPurchase Order` where docstatus = 1 and name = '%s'" % d.purchase_order)
|
||||
if not submitted:
|
||||
frappe.throw("Purchase Order : "+ cstr(d.purchase_order) +" is not submitted")
|
||||
if d.purchase_receipt:
|
||||
submitted = frappe.conn.sql("select name from `tabPurchase Receipt` where docstatus = 1 and name = '%s'" % d.purchase_receipt)
|
||||
submitted = frappe.db.sql("select name from `tabPurchase Receipt` where docstatus = 1 and name = '%s'" % d.purchase_receipt)
|
||||
if not submitted:
|
||||
frappe.throw("Purchase Receipt : "+ cstr(d.purchase_receipt) +" is not submitted")
|
||||
|
||||
@@ -414,12 +414,12 @@ class DocType(BuyingController):
|
||||
def update_raw_material_cost(self):
|
||||
if self.sub_contracted_items:
|
||||
for d in self.doclist.get({"parentfield": "entries"}):
|
||||
rm_cost = frappe.conn.sql("""select raw_material_cost / quantity
|
||||
rm_cost = frappe.db.sql("""select raw_material_cost / quantity
|
||||
from `tabBOM` where item = %s and is_default = 1 and docstatus = 1
|
||||
and is_active = 1 """, (d.item_code,))
|
||||
rm_cost = rm_cost and flt(rm_cost[0][0]) or 0
|
||||
|
||||
d.conversion_factor = d.conversion_factor or flt(frappe.conn.get_value(
|
||||
d.conversion_factor = d.conversion_factor or flt(frappe.db.get_value(
|
||||
"UOM Conversion Detail", {"parent": d.item_code, "uom": d.uom},
|
||||
"conversion_factor")) or 1
|
||||
|
||||
@@ -432,7 +432,7 @@ def get_expense_account(doctype, txt, searchfield, start, page_len, filters):
|
||||
# expense account can be any Debit account,
|
||||
# but can also be a Liability account with account_type='Expense Account' in special circumstances.
|
||||
# Hence the first condition is an "OR"
|
||||
return frappe.conn.sql("""select tabAccount.name from `tabAccount`
|
||||
return frappe.db.sql("""select tabAccount.name from `tabAccount`
|
||||
where (tabAccount.debit_or_credit="Debit"
|
||||
or tabAccount.account_type = "Expense Account")
|
||||
and tabAccount.group_or_ledger="Ledger"
|
||||
@@ -442,4 +442,4 @@ def get_expense_account(doctype, txt, searchfield, start, page_len, filters):
|
||||
and tabAccount.company = '%(company)s'
|
||||
and tabAccount.%(key)s LIKE '%(txt)s'
|
||||
%(mcond)s""" % {'company': filters['company'], 'key': searchfield,
|
||||
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield)})
|
||||
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype)})
|
||||
|
||||
@@ -20,7 +20,6 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
self.assertTrue(not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")))
|
||||
|
||||
wrapper = frappe.bean(copy=test_records[0])
|
||||
wrapper.run_method("calculate_taxes_and_totals")
|
||||
wrapper.insert()
|
||||
wrapper.submit()
|
||||
wrapper.load_from_db()
|
||||
@@ -37,7 +36,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
"_Test Account VAT - _TC": [156.25, 0],
|
||||
"_Test Account Discount - _TC": [0, 168.03],
|
||||
}
|
||||
gl_entries = frappe.conn.sql("""select account, debit, credit from `tabGL Entry`
|
||||
gl_entries = frappe.db.sql("""select account, debit, credit from `tabGL Entry`
|
||||
where voucher_type = 'Purchase Invoice' and voucher_no = %s""", dl[0].name, as_dict=1)
|
||||
for d in gl_entries:
|
||||
self.assertEqual([d.debit, d.credit], expected_gl_entries.get(d.account))
|
||||
@@ -47,11 +46,10 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1)
|
||||
|
||||
pi = frappe.bean(copy=test_records[1])
|
||||
pi.run_method("calculate_taxes_and_totals")
|
||||
pi.insert()
|
||||
pi.submit()
|
||||
|
||||
gl_entries = frappe.conn.sql("""select account, debit, credit
|
||||
gl_entries = frappe.db.sql("""select account, debit, credit
|
||||
from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s
|
||||
order by account asc""", pi.doc.name, as_dict=1)
|
||||
self.assertTrue(gl_entries)
|
||||
@@ -80,11 +78,10 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
pi.doclist[1].expense_account = "_Test Account Cost for Goods Sold - _TC"
|
||||
pi.doclist.pop(2)
|
||||
pi.doclist.pop(3)
|
||||
pi.run_method("calculate_taxes_and_totals")
|
||||
pi.insert()
|
||||
pi.submit()
|
||||
|
||||
gl_entries = frappe.conn.sql("""select account, debit, credit
|
||||
gl_entries = frappe.db.sql("""select account, debit, credit
|
||||
from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s
|
||||
order by account asc""", pi.doc.name, as_dict=1)
|
||||
self.assertTrue(gl_entries)
|
||||
@@ -103,7 +100,6 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
|
||||
def test_purchase_invoice_calculation(self):
|
||||
wrapper = frappe.bean(copy=test_records[0])
|
||||
wrapper.run_method("calculate_taxes_and_totals")
|
||||
wrapper.insert()
|
||||
wrapper.load_from_db()
|
||||
|
||||
@@ -138,7 +134,6 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
def test_purchase_invoice_with_subcontracted_item(self):
|
||||
wrapper = frappe.bean(copy=test_records[0])
|
||||
wrapper.doclist[1].item_code = "_Test FG Item"
|
||||
wrapper.run_method("calculate_taxes_and_totals")
|
||||
wrapper.insert()
|
||||
wrapper.load_from_db()
|
||||
|
||||
@@ -188,22 +183,21 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
"allocated_amount": 300,
|
||||
"remarks": jv.doc.remark
|
||||
})
|
||||
pi.run_method("calculate_taxes_and_totals")
|
||||
pi.insert()
|
||||
pi.submit()
|
||||
pi.load_from_db()
|
||||
|
||||
self.assertTrue(frappe.conn.sql("""select name from `tabJournal Voucher Detail`
|
||||
self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||
where against_voucher=%s""", pi.doc.name))
|
||||
|
||||
self.assertTrue(frappe.conn.sql("""select name from `tabJournal Voucher Detail`
|
||||
self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||
where against_voucher=%s and debit=300""", pi.doc.name))
|
||||
|
||||
self.assertEqual(pi.doc.outstanding_amount, 1212.30)
|
||||
|
||||
pi.cancel()
|
||||
|
||||
self.assertTrue(not frappe.conn.sql("""select name from `tabJournal Voucher Detail`
|
||||
self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||
where against_voucher=%s""", pi.doc.name))
|
||||
|
||||
test_records = [
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-22 12:43:10",
|
||||
"docstatus": 0,
|
||||
"modified": "2014-02-10 17:29:13",
|
||||
"modified": "2014-02-28 11:27:53",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -213,6 +213,22 @@
|
||||
"read_only": 1,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "pricing_rule_for_price",
|
||||
"fieldtype": "Link",
|
||||
"label": "Pricing Rule For Price",
|
||||
"options": "Pricing Rule",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "pricing_rule_for_discount",
|
||||
"fieldtype": "Link",
|
||||
"label": "Pricing Rule For Discount",
|
||||
"options": "Pricing Rule",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "accounting",
|
||||
|
||||
@@ -19,7 +19,7 @@ erpnext.POS = Class.extend({
|
||||
<table class="table table-condensed table-hover" id="cart" style="table-layout: fixed;">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th style="width: 40%">Item</th>\
|
||||
<th style="width: 40%">'+__("Item")+'</th>\
|
||||
<th style="width: 9%"></th>\
|
||||
<th style="width: 17%; text-align: right;">Qty</th>\
|
||||
<th style="width: 9%"></th>\
|
||||
@@ -35,7 +35,7 @@ erpnext.POS = Class.extend({
|
||||
<div class="net-total-area">\
|
||||
<table class="table table-condensed">\
|
||||
<tr>\
|
||||
<td><b>Net Total</b></td>\
|
||||
<td><b>'+__("Net Total")+'</b></td>\
|
||||
<td style="text-align: right;" class="net-total"></td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
@@ -44,7 +44,7 @@ erpnext.POS = Class.extend({
|
||||
<table class="table table-condensed">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th style="width: 60%">Taxes</th>\
|
||||
<th style="width: 60%">'+__("Taxes")+'</th>\
|
||||
<th style="width: 40%; text-align: right;"></th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
@@ -55,7 +55,7 @@ erpnext.POS = Class.extend({
|
||||
<div class="discount-amount-area">\
|
||||
<table class="table table-condensed">\
|
||||
<tr>\
|
||||
<td style="vertical-align: middle;" width="50%"><b>Discount Amount</b></td>\
|
||||
<td style="vertical-align: middle;" width="50%"><b>'+__("Discount Amount")+'</b></td>\
|
||||
<td width="20%"></td>\
|
||||
<td style="text-align: right;">\
|
||||
<input type="text" class="form-control discount-amount" \
|
||||
@@ -67,23 +67,32 @@ erpnext.POS = Class.extend({
|
||||
<div class="grand-total-area">\
|
||||
<table class="table table-condensed">\
|
||||
<tr>\
|
||||
<td style="vertical-align: middle;"><b>Grand Total</b></td>\
|
||||
<td style="vertical-align: middle;"><b>'+__("Grand Total")+'</b></td>\
|
||||
<td style="text-align: right; font-size: 200%; \
|
||||
font-size: bold;" class="grand-total"></td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
</div>\
|
||||
<div class="paid-amount-area">\
|
||||
<table class="table table-condensed">\
|
||||
<tr>\
|
||||
<td style="vertical-align: middle;">'+__("Amount Paid")+'</td>\
|
||||
<td style="text-align: right; \
|
||||
font-size: bold;" class="paid-amount"></td>\
|
||||
</tr>\
|
||||
</table>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<br><br>\
|
||||
<div class="row">\
|
||||
<div class="col-sm-9">\
|
||||
<button class="btn btn-success btn-lg make-payment">\
|
||||
<i class="icon-money"></i> Make Payment</button>\
|
||||
<i class="icon-money"></i> '+__("Make Payment")+'</button>\
|
||||
</div>\
|
||||
<div class="col-sm-3">\
|
||||
<button class="btn btn-default btn-lg remove-items" style="display: none;">\
|
||||
<i class="icon-trash"></i> Del</button>\
|
||||
<i class="icon-trash"></i> '+__("Del")+'</button>\
|
||||
</div>\
|
||||
</div>\
|
||||
<br><br>\
|
||||
@@ -439,6 +448,12 @@ erpnext.POS = Class.extend({
|
||||
me.frm.doc.currency));
|
||||
this.wrapper.find(".grand-total").text(format_currency(this.frm.doc[this.grand_total],
|
||||
me.frm.doc.currency));
|
||||
|
||||
$(".paid-amount-area").toggle(!!this.frm.doc.paid_amount);
|
||||
if(this.frm.doc.paid_amount) {
|
||||
this.wrapper.find(".paid-amount").text(format_currency(this.frm.doc.paid_amount,
|
||||
me.frm.doc.currency));
|
||||
}
|
||||
},
|
||||
call_when_local: function() {
|
||||
var me = this;
|
||||
@@ -484,25 +499,16 @@ erpnext.POS = Class.extend({
|
||||
disable_text_box_and_button: function() {
|
||||
var me = this;
|
||||
// if form is submitted & cancelled then disable all input box & buttons
|
||||
if (this.frm.doc.docstatus>=1) {
|
||||
$(this.wrapper).find('input, button').each(function () {
|
||||
$(this).prop('disabled', true);
|
||||
});
|
||||
$(this.wrapper).find(".remove-items").hide();
|
||||
$(this.wrapper).find(".make-payment").hide();
|
||||
}
|
||||
else {
|
||||
$(this.wrapper).find('input, button').each(function () {
|
||||
$(this).prop('disabled', false);
|
||||
});
|
||||
$(this.wrapper).find(".make-payment").show();
|
||||
}
|
||||
$(this.wrapper)
|
||||
.find(".remove-items, .make-payment, .increase-qty, .decrease-qty")
|
||||
.toggle(this.frm.doc.docstatus===0);
|
||||
|
||||
$(this.wrapper).find('input, button').prop("disabled", !(this.frm.doc.docstatus===0));
|
||||
},
|
||||
hide_payment_button: function() {
|
||||
var me = this;
|
||||
// Show Make Payment button only in Sales Invoice
|
||||
if (this.frm.doctype != "Sales Invoice")
|
||||
$(this.wrapper).find(".make-payment").hide();
|
||||
$(this.wrapper)
|
||||
.find(".make-payment")
|
||||
.toggle(this.frm.doctype == "Sales Invoice" && this.frm.doc.is_pos);
|
||||
},
|
||||
refresh_delete_btn: function() {
|
||||
$(this.wrapper).find(".remove-items").toggle($(".item-cart .warning").length ? true : false);
|
||||
@@ -568,6 +574,9 @@ erpnext.POS = Class.extend({
|
||||
frappe.call({
|
||||
method: 'erpnext.accounts.doctype.sales_invoice.pos.get_mode_of_payment',
|
||||
callback: function(r) {
|
||||
if(!r.message.length) {
|
||||
msgprint(__("Please add to Modes of Payment from Setup."))
|
||||
}
|
||||
for (x=0; x<=r.message.length - 1; x++) {
|
||||
mode_of_payment.push(r.message[x].name);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ def get_items(price_list, sales_or_purchase, item=None, item_group=None):
|
||||
condition += " and CONCAT(i.name, i.item_name) like %(name)s"
|
||||
args["name"] = "%%%s%%" % item
|
||||
|
||||
return frappe.conn.sql("""select i.name, i.item_name, i.image,
|
||||
return frappe.db.sql("""select i.name, i.item_name, i.image,
|
||||
item_det.price_list_rate, item_det.currency
|
||||
from `tabItem` i LEFT JOIN
|
||||
(select item_code, price_list_rate, currency from
|
||||
@@ -34,12 +34,12 @@ def get_items(price_list, sales_or_purchase, item=None, item_group=None):
|
||||
@frappe.whitelist()
|
||||
def get_item_code(barcode_serial_no):
|
||||
input_via = "serial_no"
|
||||
item_code = frappe.conn.sql("""select name, item_code from `tabSerial No` where
|
||||
item_code = frappe.db.sql("""select name, item_code from `tabSerial No` where
|
||||
name=%s""", (barcode_serial_no), as_dict=1)
|
||||
|
||||
if not item_code:
|
||||
input_via = "barcode"
|
||||
item_code = frappe.conn.sql("""select name from `tabItem` where barcode=%s""",
|
||||
item_code = frappe.db.sql("""select name from `tabItem` where barcode=%s""",
|
||||
(barcode_serial_no), as_dict=1)
|
||||
|
||||
if item_code:
|
||||
@@ -49,4 +49,4 @@ def get_item_code(barcode_serial_no):
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_mode_of_payment():
|
||||
return frappe.conn.sql("""select name from `tabMode of Payment`""", as_dict=1)
|
||||
return frappe.get_list("Mode of Payment")
|
||||
|
||||
@@ -184,8 +184,6 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
this.frm.set_value("write_off_amount",
|
||||
flt(this.frm.doc.grand_total - this.frm.doc.paid_amount), precision("write_off_amount"));
|
||||
}
|
||||
|
||||
this.frm.script_manager.trigger("write_off_amount");
|
||||
},
|
||||
|
||||
write_off_amount: function() {
|
||||
|
||||
@@ -167,7 +167,7 @@ class DocType(SellingController):
|
||||
def validate_time_logs_are_submitted(self):
|
||||
for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
|
||||
if d.time_log_batch:
|
||||
status = frappe.conn.get_value("Time Log Batch", d.time_log_batch, "status")
|
||||
status = frappe.db.get_value("Time Log Batch", d.time_log_batch, "status")
|
||||
if status!="Submitted":
|
||||
frappe.msgprint(_("Time Log Batch status must be 'Submitted'") + ":" + d.time_log_batch,
|
||||
raise_exception=True)
|
||||
@@ -196,13 +196,15 @@ class DocType(SellingController):
|
||||
# set pos values in items
|
||||
for item in self.doclist.get({"parentfield": "entries"}):
|
||||
if item.fields.get('item_code'):
|
||||
for fname, val in get_pos_settings_item_details(pos, item.fields, pos).items():
|
||||
for fname, val in get_pos_settings_item_details(pos,
|
||||
frappe._dict(item.fields), pos).items():
|
||||
|
||||
if (not for_validate) or (for_validate and not item.fields.get(fname)):
|
||||
item.fields[fname] = val
|
||||
|
||||
# fetch terms
|
||||
if self.doc.tc_name and not self.doc.terms:
|
||||
self.doc.terms = frappe.conn.get_value("Terms and Conditions", self.doc.tc_name, "terms")
|
||||
self.doc.terms = frappe.db.get_value("Terms and Conditions", self.doc.tc_name, "terms")
|
||||
|
||||
# fetch charges
|
||||
if self.doc.charge and not len(self.doclist.get({"parentfield": "other_charges"})):
|
||||
@@ -213,7 +215,7 @@ class DocType(SellingController):
|
||||
"Sales Invoice Advance", "advance_adjustment_details", "credit")
|
||||
|
||||
def get_company_abbr(self):
|
||||
return frappe.conn.sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0]
|
||||
return frappe.db.sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0]
|
||||
|
||||
def update_against_document_in_jv(self):
|
||||
"""
|
||||
@@ -246,7 +248,7 @@ class DocType(SellingController):
|
||||
def validate_customer_account(self):
|
||||
"""Validates Debit To Account and Customer Matches"""
|
||||
if self.doc.customer and self.doc.debit_to and not cint(self.doc.is_pos):
|
||||
acc_head = frappe.conn.sql("select master_name from `tabAccount` where name = %s and docstatus != 2", self.doc.debit_to)
|
||||
acc_head = frappe.db.sql("select master_name from `tabAccount` where name = %s and docstatus != 2", self.doc.debit_to)
|
||||
|
||||
if (acc_head and cstr(acc_head[0][0]) != cstr(self.doc.customer)) or \
|
||||
(not acc_head and (self.doc.debit_to != cstr(self.doc.customer) + " - " + self.get_company_abbr())):
|
||||
@@ -255,7 +257,7 @@ class DocType(SellingController):
|
||||
|
||||
|
||||
def validate_debit_acc(self):
|
||||
acc = frappe.conn.sql("select debit_or_credit, is_pl_account from tabAccount where name = '%s' and docstatus != 2" % self.doc.debit_to)
|
||||
acc = frappe.db.sql("select debit_or_credit, is_pl_account from tabAccount where name = '%s' and docstatus != 2" % self.doc.debit_to)
|
||||
if not acc:
|
||||
msgprint("Account: "+ self.doc.debit_to + " does not exist")
|
||||
raise Exception
|
||||
@@ -270,8 +272,8 @@ class DocType(SellingController):
|
||||
def validate_fixed_asset_account(self):
|
||||
"""Validate Fixed Asset Account and whether Income Account Entered Exists"""
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
item = frappe.conn.sql("select name,is_asset_item,is_sales_item from `tabItem` where name = '%s' and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())"% d.item_code)
|
||||
acc = frappe.conn.sql("select account_type from `tabAccount` where name = '%s' and docstatus != 2" % d.income_account)
|
||||
item = frappe.db.sql("select name,is_asset_item,is_sales_item from `tabItem` where name = '%s' and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())"% d.item_code)
|
||||
acc = frappe.db.sql("select account_type from `tabAccount` where name = '%s' and docstatus != 2" % d.income_account)
|
||||
if not acc:
|
||||
msgprint("Account: "+d.income_account+" does not exist in the system", raise_exception=True)
|
||||
elif item and item[0][1] == 'Yes' and not acc[0][0] == 'Fixed Asset Account':
|
||||
@@ -332,9 +334,9 @@ class DocType(SellingController):
|
||||
"""check in manage account if sales order / delivery note required or not."""
|
||||
dic = {'Sales Order':'so_required','Delivery Note':'dn_required'}
|
||||
for i in dic:
|
||||
if frappe.conn.get_value('Selling Settings', None, dic[i]) == 'Yes':
|
||||
if frappe.db.get_value('Selling Settings', None, dic[i]) == 'Yes':
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
if frappe.conn.get_value('Item', d.item_code, 'is_stock_item') == 'Yes' \
|
||||
if frappe.db.get_value('Item', d.item_code, 'is_stock_item') == 'Yes' \
|
||||
and not d.fields[i.lower().replace(' ','_')]:
|
||||
msgprint("%s is mandatory for stock item which is not mentioed against item: %s"%(i,d.item_code), raise_exception=1)
|
||||
|
||||
@@ -342,7 +344,7 @@ class DocType(SellingController):
|
||||
def validate_proj_cust(self):
|
||||
"""check for does customer belong to same project as entered.."""
|
||||
if self.doc.project_name and self.doc.customer:
|
||||
res = frappe.conn.sql("select name from `tabProject` where name = '%s' and (customer = '%s' or ifnull(customer,'')='')"%(self.doc.project_name, self.doc.customer))
|
||||
res = frappe.db.sql("select name from `tabProject` where name = '%s' and (customer = '%s' or ifnull(customer,'')='')"%(self.doc.project_name, self.doc.customer))
|
||||
if not res:
|
||||
msgprint("Customer - %s does not belong to project - %s. \n\nIf you want to use project for multiple customers then please make customer details blank in that project."%(self.doc.customer,self.doc.project_name))
|
||||
raise Exception
|
||||
@@ -377,28 +379,28 @@ class DocType(SellingController):
|
||||
def validate_c_form(self):
|
||||
""" Blank C-form no if C-form applicable marked as 'No'"""
|
||||
if self.doc.amended_from and self.doc.c_form_applicable == 'No' and self.doc.c_form_no:
|
||||
frappe.conn.sql("""delete from `tabC-Form Invoice Detail` where invoice_no = %s
|
||||
frappe.db.sql("""delete from `tabC-Form Invoice Detail` where invoice_no = %s
|
||||
and parent = %s""", (self.doc.amended_from, self.doc.c_form_no))
|
||||
|
||||
frappe.conn.set(self.doc, 'c_form_no', '')
|
||||
frappe.db.set(self.doc, 'c_form_no', '')
|
||||
|
||||
def update_current_stock(self):
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
if d.item_code and d.warehouse:
|
||||
bin = frappe.conn.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
|
||||
bin = frappe.db.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
|
||||
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
|
||||
|
||||
for d in getlist(self.doclist, 'packing_details'):
|
||||
bin = frappe.conn.sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
|
||||
bin = frappe.db.sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
|
||||
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
|
||||
d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0
|
||||
|
||||
|
||||
def get_warehouse(self):
|
||||
w = frappe.conn.sql("select warehouse from `tabPOS Setting` where ifnull(user,'') = '%s' and company = '%s'" % (frappe.session['user'], self.doc.company))
|
||||
w = frappe.db.sql("select warehouse from `tabPOS Setting` where ifnull(user,'') = '%s' and company = '%s'" % (frappe.session['user'], self.doc.company))
|
||||
w = w and w[0][0] or ''
|
||||
if not w:
|
||||
ps = frappe.conn.sql("select name, warehouse from `tabPOS Setting` where ifnull(user,'') = '' and company = '%s'" % self.doc.company)
|
||||
ps = frappe.db.sql("select name, warehouse from `tabPOS Setting` where ifnull(user,'') = '' and company = '%s'" % self.doc.company)
|
||||
if not ps:
|
||||
msgprint("To make POS entry, please create POS Setting from Accounts --> POS Setting page and refresh the system.", raise_exception=True)
|
||||
elif not ps[0][1]:
|
||||
@@ -425,25 +427,25 @@ class DocType(SellingController):
|
||||
if cint(self.doc.is_pos) == 1:
|
||||
if flt(self.doc.paid_amount) == 0:
|
||||
if self.doc.cash_bank_account:
|
||||
frappe.conn.set(self.doc, 'paid_amount',
|
||||
frappe.db.set(self.doc, 'paid_amount',
|
||||
(flt(self.doc.grand_total) - flt(self.doc.write_off_amount)))
|
||||
else:
|
||||
# show message that the amount is not paid
|
||||
frappe.conn.set(self.doc,'paid_amount',0)
|
||||
frappe.db.set(self.doc,'paid_amount',0)
|
||||
frappe.msgprint("Note: Payment Entry will not be created since 'Cash/Bank Account' was not specified.")
|
||||
else:
|
||||
frappe.conn.set(self.doc,'paid_amount',0)
|
||||
frappe.db.set(self.doc,'paid_amount',0)
|
||||
|
||||
def check_prev_docstatus(self):
|
||||
for d in getlist(self.doclist,'entries'):
|
||||
if d.sales_order:
|
||||
submitted = frappe.conn.sql("select name from `tabSales Order` where docstatus = 1 and name = '%s'" % d.sales_order)
|
||||
submitted = frappe.db.sql("select name from `tabSales Order` where docstatus = 1 and name = '%s'" % d.sales_order)
|
||||
if not submitted:
|
||||
msgprint("Sales Order : "+ cstr(d.sales_order) +" is not submitted")
|
||||
raise Exception , "Validation Error."
|
||||
|
||||
if d.delivery_note:
|
||||
submitted = frappe.conn.sql("select name from `tabDelivery Note` where docstatus = 1 and name = '%s'" % d.delivery_note)
|
||||
submitted = frappe.db.sql("select name from `tabDelivery Note` where docstatus = 1 and name = '%s'" % d.delivery_note)
|
||||
if not submitted:
|
||||
msgprint("Delivery Note : "+ cstr(d.delivery_note) +" is not submitted")
|
||||
raise Exception , "Validation Error."
|
||||
@@ -451,11 +453,11 @@ class DocType(SellingController):
|
||||
def update_stock_ledger(self):
|
||||
sl_entries = []
|
||||
for d in self.get_item_list():
|
||||
if frappe.conn.get_value("Item", d.item_code, "is_stock_item") == "Yes" \
|
||||
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == "Yes" \
|
||||
and d.warehouse:
|
||||
sl_entries.append(self.get_sl_entries(d, {
|
||||
"actual_qty": -1*flt(d.qty),
|
||||
"stock_uom": frappe.conn.get_value("Item", d.item_code, "stock_uom")
|
||||
"stock_uom": frappe.db.get_value("Item", d.item_code, "stock_uom")
|
||||
}))
|
||||
|
||||
self.make_sl_entries(sl_entries)
|
||||
@@ -584,7 +586,7 @@ class DocType(SellingController):
|
||||
def update_c_form(self):
|
||||
"""Update amended id in C-form"""
|
||||
if self.doc.c_form_no and self.doc.amended_from:
|
||||
frappe.conn.sql("""update `tabC-Form Invoice Detail` set invoice_no = %s,
|
||||
frappe.db.sql("""update `tabC-Form Invoice Detail` set invoice_no = %s,
|
||||
invoice_date = %s, territory = %s, net_total = %s,
|
||||
grand_total = %s where invoice_no = %s and parent = %s""",
|
||||
(self.doc.name, self.doc.amended_from, self.doc.c_form_no))
|
||||
@@ -613,13 +615,13 @@ class DocType(SellingController):
|
||||
def convert_to_recurring(self):
|
||||
if self.doc.convert_into_recurring_invoice:
|
||||
if not self.doc.recurring_id:
|
||||
frappe.conn.set(self.doc, "recurring_id",
|
||||
frappe.db.set(self.doc, "recurring_id",
|
||||
make_autoname("RECINV/.#####"))
|
||||
|
||||
self.set_next_date()
|
||||
|
||||
elif self.doc.recurring_id:
|
||||
frappe.conn.sql("""update `tabSales Invoice`
|
||||
frappe.db.sql("""update `tabSales Invoice`
|
||||
set convert_into_recurring_invoice = 0
|
||||
where recurring_id = %s""", (self.doc.recurring_id,))
|
||||
|
||||
@@ -649,7 +651,7 @@ class DocType(SellingController):
|
||||
next_date = get_next_date(self.doc.posting_date,
|
||||
month_map[self.doc.recurring_type], cint(self.doc.repeat_on_day_of_month))
|
||||
|
||||
frappe.conn.set(self.doc, 'next_date', next_date)
|
||||
frappe.db.set(self.doc, 'next_date', next_date)
|
||||
|
||||
def get_next_date(dt, mcount, day=None):
|
||||
dt = getdate(dt)
|
||||
@@ -665,14 +667,14 @@ def manage_recurring_invoices(next_date=None, commit=True):
|
||||
and notify the concerned people
|
||||
"""
|
||||
next_date = next_date or nowdate()
|
||||
recurring_invoices = frappe.conn.sql("""select name, recurring_id
|
||||
recurring_invoices = frappe.db.sql("""select name, recurring_id
|
||||
from `tabSales Invoice` where ifnull(convert_into_recurring_invoice, 0)=1
|
||||
and docstatus=1 and next_date=%s
|
||||
and next_date <= ifnull(end_date, '2199-12-31')""", next_date)
|
||||
|
||||
exception_list = []
|
||||
for ref_invoice, recurring_id in recurring_invoices:
|
||||
if not frappe.conn.sql("""select name from `tabSales Invoice`
|
||||
if not frappe.db.sql("""select name from `tabSales Invoice`
|
||||
where posting_date=%s and recurring_id=%s and docstatus=1""",
|
||||
(next_date, recurring_id)):
|
||||
try:
|
||||
@@ -680,21 +682,21 @@ def manage_recurring_invoices(next_date=None, commit=True):
|
||||
new_invoice_wrapper = make_new_invoice(ref_wrapper, next_date)
|
||||
send_notification(new_invoice_wrapper)
|
||||
if commit:
|
||||
frappe.conn.commit()
|
||||
frappe.db.commit()
|
||||
except:
|
||||
if commit:
|
||||
frappe.conn.rollback()
|
||||
frappe.db.rollback()
|
||||
|
||||
frappe.conn.begin()
|
||||
frappe.conn.sql("update `tabSales Invoice` set \
|
||||
frappe.db.begin()
|
||||
frappe.db.sql("update `tabSales Invoice` set \
|
||||
convert_into_recurring_invoice = 0 where name = %s", ref_invoice)
|
||||
notify_errors(ref_invoice, ref_wrapper.doc.customer, ref_wrapper.doc.owner)
|
||||
frappe.conn.commit()
|
||||
frappe.db.commit()
|
||||
|
||||
exception_list.append(frappe.get_traceback())
|
||||
finally:
|
||||
if commit:
|
||||
frappe.conn.begin()
|
||||
frappe.db.begin()
|
||||
|
||||
if exception_list:
|
||||
exception_message = "\n\n".join([cstr(d) for d in exception_list])
|
||||
@@ -744,9 +746,9 @@ def send_notification(new_rv):
|
||||
message = get_html(new_rv.doc, new_rv.doclist, "SalesInvoice"))
|
||||
|
||||
def notify_errors(inv, customer, owner):
|
||||
from frappe.profile import get_system_managers
|
||||
from frappe.utils.user import get_system_managers
|
||||
|
||||
frappe.sendmail(recipients=get_system_managers() + [frappe.conn.get_value("Profile", owner, "email")],
|
||||
frappe.sendmail(recipients=get_system_managers() + [frappe.db.get_value("User", owner, "email")],
|
||||
subject="[Urgent] Error while creating recurring invoice for %s" % inv,
|
||||
message = frappe.get_template("template/emails/recurring_invoice_failed.html").render({
|
||||
"name": inv,
|
||||
@@ -769,7 +771,7 @@ def assign_task_to_owner(inv, msg, users):
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_bank_cash_account(mode_of_payment):
|
||||
val = frappe.conn.get_value("Mode of Payment", mode_of_payment, "default_account")
|
||||
val = frappe.db.get_value("Mode of Payment", mode_of_payment, "default_account")
|
||||
if not val:
|
||||
frappe.msgprint("Default Bank / Cash Account not set in Mode of Payment: %s. Please add a Default Account in Mode of Payment master." % mode_of_payment)
|
||||
return {
|
||||
@@ -783,7 +785,7 @@ def get_income_account(doctype, txt, searchfield, start, page_len, filters):
|
||||
# income account can be any Credit account,
|
||||
# but can also be a Asset account with account_type='Income Account' in special circumstances.
|
||||
# Hence the first condition is an "OR"
|
||||
return frappe.conn.sql("""select tabAccount.name from `tabAccount`
|
||||
return frappe.db.sql("""select tabAccount.name from `tabAccount`
|
||||
where (tabAccount.debit_or_credit="Credit"
|
||||
or tabAccount.account_type = "Income Account")
|
||||
and tabAccount.group_or_ledger="Ledger"
|
||||
@@ -793,7 +795,7 @@ def get_income_account(doctype, txt, searchfield, start, page_len, filters):
|
||||
and tabAccount.company = '%(company)s'
|
||||
and tabAccount.%(key)s LIKE '%(txt)s'
|
||||
%(mcond)s""" % {'company': filters['company'], 'key': searchfield,
|
||||
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield)})
|
||||
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype)})
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
|
||||
@@ -210,7 +210,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
si.insert()
|
||||
si.submit()
|
||||
|
||||
gl_entries = frappe.conn.sql("""select account, debit, credit
|
||||
gl_entries = frappe.db.sql("""select account, debit, credit
|
||||
from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
|
||||
order by account asc""", si.doc.name, as_dict=1)
|
||||
|
||||
@@ -238,7 +238,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
# cancel
|
||||
si.cancel()
|
||||
|
||||
gle = frappe.conn.sql("""select * from `tabGL Entry`
|
||||
gle = frappe.db.sql("""select * from `tabGL Entry`
|
||||
where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name)
|
||||
|
||||
self.assertFalse(gle)
|
||||
@@ -363,7 +363,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self.assertEquals(w.doc.outstanding_amount, w.doc.grand_total)
|
||||
|
||||
def test_payment(self):
|
||||
frappe.conn.sql("""delete from `tabGL Entry`""")
|
||||
frappe.db.sql("""delete from `tabGL Entry`""")
|
||||
w = self.make()
|
||||
|
||||
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
|
||||
@@ -374,11 +374,11 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
jv.insert()
|
||||
jv.submit()
|
||||
|
||||
self.assertEquals(frappe.conn.get_value("Sales Invoice", w.doc.name, "outstanding_amount"),
|
||||
self.assertEquals(frappe.db.get_value("Sales Invoice", w.doc.name, "outstanding_amount"),
|
||||
161.8)
|
||||
|
||||
jv.cancel()
|
||||
self.assertEquals(frappe.conn.get_value("Sales Invoice", w.doc.name, "outstanding_amount"),
|
||||
self.assertEquals(frappe.db.get_value("Sales Invoice", w.doc.name, "outstanding_amount"),
|
||||
561.8)
|
||||
|
||||
def test_time_log_batch(self):
|
||||
@@ -390,18 +390,18 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
si.insert()
|
||||
si.submit()
|
||||
|
||||
self.assertEquals(frappe.conn.get_value("Time Log Batch", "_T-Time Log Batch-00001",
|
||||
self.assertEquals(frappe.db.get_value("Time Log Batch", "_T-Time Log Batch-00001",
|
||||
"status"), "Billed")
|
||||
|
||||
self.assertEquals(frappe.conn.get_value("Time Log", "_T-Time Log-00001", "status"),
|
||||
self.assertEquals(frappe.db.get_value("Time Log", "_T-Time Log-00001", "status"),
|
||||
"Billed")
|
||||
|
||||
si.cancel()
|
||||
|
||||
self.assertEquals(frappe.conn.get_value("Time Log Batch", "_T-Time Log Batch-00001",
|
||||
self.assertEquals(frappe.db.get_value("Time Log Batch", "_T-Time Log Batch-00001",
|
||||
"status"), "Submitted")
|
||||
|
||||
self.assertEquals(frappe.conn.get_value("Time Log", "_T-Time Log-00001", "status"),
|
||||
self.assertEquals(frappe.db.get_value("Time Log", "_T-Time Log-00001", "status"),
|
||||
"Batched for Billing")
|
||||
|
||||
def test_sales_invoice_gl_entry_without_aii(self):
|
||||
@@ -411,7 +411,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
si.insert()
|
||||
si.submit()
|
||||
|
||||
gl_entries = frappe.conn.sql("""select account, debit, credit
|
||||
gl_entries = frappe.db.sql("""select account, debit, credit
|
||||
from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
|
||||
order by account asc""", si.doc.name, as_dict=1)
|
||||
|
||||
@@ -432,7 +432,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
# cancel
|
||||
si.cancel()
|
||||
|
||||
gle = frappe.conn.sql("""select * from `tabGL Entry`
|
||||
gle = frappe.db.sql("""select * from `tabGL Entry`
|
||||
where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name)
|
||||
|
||||
self.assertFalse(gle)
|
||||
@@ -456,7 +456,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
si.submit()
|
||||
|
||||
# check stock ledger entries
|
||||
sle = frappe.conn.sql("""select * from `tabStock Ledger Entry`
|
||||
sle = frappe.db.sql("""select * from `tabStock Ledger Entry`
|
||||
where voucher_type = 'Sales Invoice' and voucher_no = %s""",
|
||||
si.doc.name, as_dict=1)[0]
|
||||
self.assertTrue(sle)
|
||||
@@ -464,12 +464,12 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
["_Test Item", "_Test Warehouse - _TC", -1.0])
|
||||
|
||||
# check gl entries
|
||||
gl_entries = frappe.conn.sql("""select account, debit, credit
|
||||
gl_entries = frappe.db.sql("""select account, debit, credit
|
||||
from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
|
||||
order by account asc, debit asc""", si.doc.name, as_dict=1)
|
||||
self.assertTrue(gl_entries)
|
||||
|
||||
stock_in_hand = frappe.conn.get_value("Account", {"master_name": "_Test Warehouse - _TC"})
|
||||
stock_in_hand = frappe.db.get_value("Account", {"master_name": "_Test Warehouse - _TC"})
|
||||
|
||||
expected_gl_entries = sorted([
|
||||
[si.doc.debit_to, 630.0, 0.0],
|
||||
@@ -487,7 +487,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self.assertEquals(expected_gl_entries[i][2], gle.credit)
|
||||
|
||||
si.cancel()
|
||||
gle = frappe.conn.sql("""select * from `tabGL Entry`
|
||||
gle = frappe.db.sql("""select * from `tabGL Entry`
|
||||
where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name)
|
||||
|
||||
self.assertFalse(gle)
|
||||
@@ -520,7 +520,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
si.submit()
|
||||
|
||||
# check stock ledger entries
|
||||
sle = frappe.conn.sql("""select * from `tabStock Ledger Entry`
|
||||
sle = frappe.db.sql("""select * from `tabStock Ledger Entry`
|
||||
where voucher_type = 'Sales Invoice' and voucher_no = %s""",
|
||||
si.doc.name, as_dict=1)[0]
|
||||
self.assertTrue(sle)
|
||||
@@ -528,7 +528,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
["_Test Item", "_Test Warehouse No Account - _TC", -1.0])
|
||||
|
||||
# check gl entries
|
||||
gl_entries = frappe.conn.sql("""select account, debit, credit
|
||||
gl_entries = frappe.db.sql("""select account, debit, credit
|
||||
from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
|
||||
order by account asc, debit asc""", si.doc.name, as_dict=1)
|
||||
self.assertTrue(gl_entries)
|
||||
@@ -545,7 +545,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self.assertEquals(expected_gl_entries[i][2], gle.credit)
|
||||
|
||||
si.cancel()
|
||||
gle = frappe.conn.sql("""select * from `tabGL Entry`
|
||||
gle = frappe.db.sql("""select * from `tabGL Entry`
|
||||
where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name)
|
||||
|
||||
self.assertFalse(gle)
|
||||
@@ -561,7 +561,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
si.insert()
|
||||
si.submit()
|
||||
|
||||
gl_entries = frappe.conn.sql("""select account, debit, credit
|
||||
gl_entries = frappe.db.sql("""select account, debit, credit
|
||||
from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
|
||||
order by account asc""", si.doc.name, as_dict=1)
|
||||
self.assertTrue(gl_entries)
|
||||
@@ -588,7 +588,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
si.insert()
|
||||
si.submit()
|
||||
|
||||
gl_entries = frappe.conn.sql("""select account, debit, credit
|
||||
gl_entries = frappe.db.sql("""select account, debit, credit
|
||||
from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
|
||||
order by account asc""", si.doc.name, as_dict=1)
|
||||
self.assertTrue(gl_entries)
|
||||
@@ -626,7 +626,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
def _insert_pos_settings(self):
|
||||
from erpnext.accounts.doctype.pos_setting.test_pos_setting \
|
||||
import test_records as pos_setting_test_records
|
||||
frappe.conn.sql("""delete from `tabPOS Setting`""")
|
||||
frappe.db.sql("""delete from `tabPOS Setting`""")
|
||||
|
||||
ps = frappe.bean(copy=pos_setting_test_records[0])
|
||||
ps.insert()
|
||||
@@ -653,17 +653,17 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
si.submit()
|
||||
si.load_from_db()
|
||||
|
||||
self.assertTrue(frappe.conn.sql("""select name from `tabJournal Voucher Detail`
|
||||
self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||
where against_invoice=%s""", si.doc.name))
|
||||
|
||||
self.assertTrue(frappe.conn.sql("""select name from `tabJournal Voucher Detail`
|
||||
self.assertTrue(frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||
where against_invoice=%s and credit=300""", si.doc.name))
|
||||
|
||||
self.assertEqual(si.doc.outstanding_amount, 261.8)
|
||||
|
||||
si.cancel()
|
||||
|
||||
self.assertTrue(not frappe.conn.sql("""select name from `tabJournal Voucher Detail`
|
||||
self.assertTrue(not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||
where against_invoice=%s""", si.doc.name))
|
||||
|
||||
def test_recurring_invoice(self):
|
||||
@@ -762,7 +762,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
no_of_months = ({"Monthly": 1, "Quarterly": 3, "Yearly": 12})[base_si.doc.recurring_type]
|
||||
|
||||
def _test(i):
|
||||
self.assertEquals(i+1, frappe.conn.sql("""select count(*) from `tabSales Invoice`
|
||||
self.assertEquals(i+1, frappe.db.sql("""select count(*) from `tabSales Invoice`
|
||||
where recurring_id=%s and docstatus=1""", base_si.doc.recurring_id)[0][0])
|
||||
|
||||
next_date = get_next_date(base_si.doc.posting_date, no_of_months,
|
||||
@@ -770,7 +770,7 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
|
||||
manage_recurring_invoices(next_date=next_date, commit=False)
|
||||
|
||||
recurred_invoices = frappe.conn.sql("""select name from `tabSales Invoice`
|
||||
recurred_invoices = frappe.db.sql("""select name from `tabSales Invoice`
|
||||
where recurring_id=%s and docstatus=1 order by name desc""",
|
||||
base_si.doc.recurring_id)
|
||||
|
||||
@@ -805,9 +805,9 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
base_si = _test(i)
|
||||
|
||||
def clear_stock_account_balance(self):
|
||||
frappe.conn.sql("delete from `tabStock Ledger Entry`")
|
||||
frappe.conn.sql("delete from tabBin")
|
||||
frappe.conn.sql("delete from `tabGL Entry`")
|
||||
frappe.db.sql("delete from `tabStock Ledger Entry`")
|
||||
frappe.db.sql("delete from tabBin")
|
||||
frappe.db.sql("delete from `tabGL Entry`")
|
||||
|
||||
def test_serialized(self):
|
||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
||||
@@ -824,9 +824,9 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
si.insert()
|
||||
si.submit()
|
||||
|
||||
self.assertEquals(frappe.conn.get_value("Serial No", serial_nos[0], "status"), "Delivered")
|
||||
self.assertFalse(frappe.conn.get_value("Serial No", serial_nos[0], "warehouse"))
|
||||
self.assertEquals(frappe.conn.get_value("Serial No", serial_nos[0],
|
||||
self.assertEquals(frappe.db.get_value("Serial No", serial_nos[0], "status"), "Delivered")
|
||||
self.assertFalse(frappe.db.get_value("Serial No", serial_nos[0], "warehouse"))
|
||||
self.assertEquals(frappe.db.get_value("Serial No", serial_nos[0],
|
||||
"delivery_document_no"), si.doc.name)
|
||||
|
||||
return si
|
||||
@@ -838,9 +838,9 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
|
||||
serial_nos = get_serial_nos(si.doclist[1].serial_no)
|
||||
|
||||
self.assertEquals(frappe.conn.get_value("Serial No", serial_nos[0], "status"), "Available")
|
||||
self.assertEquals(frappe.conn.get_value("Serial No", serial_nos[0], "warehouse"), "_Test Warehouse - _TC")
|
||||
self.assertFalse(frappe.conn.get_value("Serial No", serial_nos[0],
|
||||
self.assertEquals(frappe.db.get_value("Serial No", serial_nos[0], "status"), "Available")
|
||||
self.assertEquals(frappe.db.get_value("Serial No", serial_nos[0], "warehouse"), "_Test Warehouse - _TC")
|
||||
self.assertFalse(frappe.db.get_value("Serial No", serial_nos[0],
|
||||
"delivery_document_no"))
|
||||
|
||||
def test_serialize_status(self):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-06-04 11:02:19",
|
||||
"docstatus": 0,
|
||||
"modified": "2014-02-10 17:28:47",
|
||||
"modified": "2014-02-28 11:04:19",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -221,6 +221,22 @@
|
||||
"read_only": 1,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "pricing_rule_for_price",
|
||||
"fieldtype": "Link",
|
||||
"label": "Pricing Rule For Price",
|
||||
"options": "Pricing Rule",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "pricing_rule_for_discount",
|
||||
"fieldtype": "Link",
|
||||
"label": "Pricing Rule For Discount",
|
||||
"options": "Pricing Rule",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "accounting",
|
||||
|
||||
@@ -9,7 +9,7 @@ from frappe.model.controller import DocListController
|
||||
class DocType(DocListController):
|
||||
def validate(self):
|
||||
if self.doc.is_default == 1:
|
||||
frappe.conn.sql("""update `tabSales Taxes and Charges Master` set is_default = 0
|
||||
frappe.db.sql("""update `tabSales Taxes and Charges Master` set is_default = 0
|
||||
where ifnull(is_default,0) = 1 and name != %s and company = %s""",
|
||||
(self.doc.name, self.doc.company))
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ def validate_total_debit_credit(total_debit, total_credit):
|
||||
|
||||
def validate_account_for_auto_accounting_for_stock(gl_map):
|
||||
if gl_map[0].voucher_type=="Journal Voucher":
|
||||
aii_accounts = [d[0] for d in frappe.conn.sql("""select name from tabAccount
|
||||
aii_accounts = [d[0] for d in frappe.db.sql("""select name from tabAccount
|
||||
where account_type = 'Warehouse' and ifnull(master_name, '')!=''""")]
|
||||
|
||||
for entry in gl_map:
|
||||
@@ -107,12 +107,12 @@ def delete_gl_entries(gl_entries=None, voucher_type=None, voucher_no=None,
|
||||
check_freezing_date, update_outstanding_amt, validate_frozen_account
|
||||
|
||||
if not gl_entries:
|
||||
gl_entries = frappe.conn.sql("""select * from `tabGL Entry`
|
||||
gl_entries = frappe.db.sql("""select * from `tabGL Entry`
|
||||
where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no), as_dict=True)
|
||||
if gl_entries:
|
||||
check_freezing_date(gl_entries[0]["posting_date"], adv_adj)
|
||||
|
||||
frappe.conn.sql("""delete from `tabGL Entry` where voucher_type=%s and voucher_no=%s""",
|
||||
frappe.db.sql("""delete from `tabGL Entry` where voucher_type=%s and voucher_no=%s""",
|
||||
(voucher_type or gl_entries[0]["voucher_type"], voucher_no or gl_entries[0]["voucher_no"]))
|
||||
|
||||
for entry in gl_entries:
|
||||
|
||||
@@ -42,7 +42,7 @@ pscript['onload_Accounts Browser'] = function(wrapper){
|
||||
'</ol>'+
|
||||
'<p>'+frappe._('Please setup your chart of accounts before you start Accounting Entries')+'</p></div>').appendTo(main);
|
||||
|
||||
if (frappe.boot.profile.can_create.indexOf("Company") !== -1) {
|
||||
if (frappe.boot.user.can_create.indexOf("Company") !== -1) {
|
||||
wrapper.appframe.add_button(frappe._('New Company'), function() { newdoc('Company'); },
|
||||
'icon-plus');
|
||||
}
|
||||
@@ -109,97 +109,75 @@ erpnext.AccountsChart = Class.extend({
|
||||
args: {ctype: ctype, comp: company},
|
||||
method: 'erpnext.accounts.page.accounts_browser.accounts_browser.get_children',
|
||||
click: function(link) {
|
||||
if(me.cur_toolbar)
|
||||
$(me.cur_toolbar).toggle(false);
|
||||
|
||||
if(!link.toolbar)
|
||||
me.make_link_toolbar(link);
|
||||
|
||||
if(link.toolbar) {
|
||||
me.cur_toolbar = link.toolbar;
|
||||
$(me.cur_toolbar).toggle(true);
|
||||
}
|
||||
|
||||
// bold
|
||||
$('.bold').removeClass('bold'); // deselect
|
||||
$(link).parent().find('.balance-area:first').addClass('bold'); // select
|
||||
|
||||
},
|
||||
onrender: function(treenode) {
|
||||
if (ctype == 'Account' && treenode.data) {
|
||||
if(treenode.data.balance) {
|
||||
treenode.parent.append('<span class="balance-area pull-right">'
|
||||
+ format_currency(treenode.data.balance, treenode.data.currency)
|
||||
+ '</span>');
|
||||
toolbar: [
|
||||
{ toggle_btn: true },
|
||||
{
|
||||
label: __("Open"),
|
||||
condition: function(node) { return !node.root },
|
||||
click: function(node, btn) {
|
||||
frappe.set_route("Form", me.ctype, node.label);
|
||||
}
|
||||
},
|
||||
{
|
||||
condition: function(node) { return !node.root && node.expandable; },
|
||||
label: __("Add Child"),
|
||||
click: function() {
|
||||
if(me.ctype=='Account') {
|
||||
me.new_account();
|
||||
} else {
|
||||
me.new_cost_center();
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
condition: function(node) {
|
||||
return !node.root && me.ctype === 'Account'
|
||||
&& frappe.boot.user.can_read.indexOf("GL Entry") !== -1
|
||||
},
|
||||
label: __("View Ledger"),
|
||||
click: function(node, btn) {
|
||||
frappe.route_options = {
|
||||
"account": node.label,
|
||||
"from_date": sys_defaults.year_start_date,
|
||||
"to_date": sys_defaults.year_end_date,
|
||||
"company": me.company
|
||||
};
|
||||
frappe.set_route("query-report", "General Ledger");
|
||||
}
|
||||
|
||||
},
|
||||
{
|
||||
condition: function(node) { return !node.root && me.can_write },
|
||||
label: __("Rename"),
|
||||
click: function(node) {
|
||||
frappe.model.rename_doc(me.ctype, node.label, function(new_name) {
|
||||
node.reload();
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
condition: function(node) { return !node.root && me.can_delete },
|
||||
label: __("Delete"),
|
||||
click: function(node) {
|
||||
frappe.model.delete_doc(me.ctype, node.label, function() {
|
||||
node.parent.remove();
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
onrender: function(node) {
|
||||
if (me.ctype == 'Account' && node.data && node.data.balance!==undefined) {
|
||||
$('<span class="balance-area pull-right text-muted">'
|
||||
+ format_currency(node.data.balance, node.data.currency)
|
||||
+ '</span>').insertBefore(node.$ul);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.tree.rootnode.$a.click();
|
||||
},
|
||||
make_link_toolbar: function(link) {
|
||||
var data = $(link).data('node-data');
|
||||
if(!data) return;
|
||||
|
||||
link.toolbar = $('<span class="tree-node-toolbar highlight"></span>').insertAfter(link);
|
||||
|
||||
var node_links = [];
|
||||
// edit
|
||||
if (frappe.model.can_read(this.ctype) !== -1) {
|
||||
node_links.push('<a onclick="erpnext.account_chart.open();">'+frappe._('Edit')+'</a>');
|
||||
}
|
||||
if (data.expandable && frappe.boot.profile.in_create.indexOf(this.ctype) !== -1) {
|
||||
node_links.push('<a onclick="erpnext.account_chart.new_node();">'+frappe._('Add Child')+'</a>');
|
||||
} else if (this.ctype === 'Account' && frappe.boot.profile.can_read.indexOf("GL Entry") !== -1) {
|
||||
node_links.push('<a onclick="erpnext.account_chart.show_ledger();">'+frappe._('View Ledger')+'</a>');
|
||||
}
|
||||
|
||||
if (this.can_write) {
|
||||
node_links.push('<a onclick="erpnext.account_chart.rename()">'+frappe._('Rename')+'</a>');
|
||||
};
|
||||
|
||||
if (this.can_delete) {
|
||||
node_links.push('<a onclick="erpnext.account_chart.delete()">'+frappe._('Delete')+'</a>');
|
||||
};
|
||||
|
||||
link.toolbar.append(node_links.join(" | "));
|
||||
},
|
||||
open: function() {
|
||||
var node = this.selected_node();
|
||||
frappe.set_route("Form", this.ctype, node.data("label"));
|
||||
},
|
||||
show_ledger: function() {
|
||||
var me = this;
|
||||
var node = me.selected_node();
|
||||
frappe.route_options = {
|
||||
"account": node.data('label'),
|
||||
"from_date": sys_defaults.year_start_date,
|
||||
"to_date": sys_defaults.year_end_date,
|
||||
"company": me.company
|
||||
};
|
||||
frappe.set_route("query-report", "General Ledger");
|
||||
},
|
||||
rename: function() {
|
||||
var node = this.selected_node();
|
||||
frappe.model.rename_doc(this.ctype, node.data('label'), function(new_name) {
|
||||
node.parents("ul:first").parent().find(".tree-link:first").trigger("reload");
|
||||
});
|
||||
},
|
||||
delete: function() {
|
||||
var node = this.selected_node();
|
||||
frappe.model.delete_doc(this.ctype, node.data('label'), function() {
|
||||
node.parent().remove();
|
||||
});
|
||||
},
|
||||
new_node: function() {
|
||||
if(this.ctype=='Account') {
|
||||
this.new_account();
|
||||
} else {
|
||||
this.new_cost_center();
|
||||
}
|
||||
},
|
||||
selected_node: function() {
|
||||
return this.tree.$w.find('.tree-link.selected');
|
||||
},
|
||||
new_account: function() {
|
||||
var me = this;
|
||||
@@ -250,12 +228,11 @@ erpnext.AccountsChart = Class.extend({
|
||||
// create
|
||||
$(fd.create_new.input).click(function() {
|
||||
var btn = this;
|
||||
$(btn).set_working();
|
||||
var v = d.get_values();
|
||||
if(!v) return;
|
||||
|
||||
var node = me.selected_node();
|
||||
v.parent_account = node.data('label');
|
||||
var node = me.tree.get_selected_node();
|
||||
v.parent_account = node.label;
|
||||
v.master_type = '';
|
||||
v.company = me.company;
|
||||
|
||||
@@ -263,9 +240,8 @@ erpnext.AccountsChart = Class.extend({
|
||||
args: v,
|
||||
method: 'erpnext.accounts.utils.add_ac',
|
||||
callback: function(r) {
|
||||
$(btn).done_working();
|
||||
d.hide();
|
||||
node.trigger('reload');
|
||||
node.reload;
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -296,23 +272,20 @@ erpnext.AccountsChart = Class.extend({
|
||||
|
||||
// create
|
||||
$(d.fields_dict.create_new.input).click(function() {
|
||||
var btn = this;
|
||||
$(btn).set_working();
|
||||
var v = d.get_values();
|
||||
if(!v) return;
|
||||
|
||||
var node = me.selected_node();
|
||||
var node = me.tree.get_selected_node();
|
||||
|
||||
v.parent_cost_center = node.data('label');
|
||||
v.parent_cost_center = node.label;
|
||||
v.company = me.company;
|
||||
|
||||
return frappe.call({
|
||||
args: v,
|
||||
method: 'erpnext.accounts.utils.add_cc',
|
||||
callback: function(r) {
|
||||
$(btn).done_working();
|
||||
d.hide();
|
||||
node.trigger('reload');
|
||||
node.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@ def get_children():
|
||||
|
||||
# root
|
||||
if args['parent'] in ("Accounts", "Cost Centers"):
|
||||
acc = frappe.conn.sql(""" select
|
||||
acc = frappe.db.sql(""" select
|
||||
name as value, if(group_or_ledger='Group', 1, 0) as expandable
|
||||
from `tab%s`
|
||||
where ifnull(parent_%s,'') = ''
|
||||
@@ -29,7 +29,7 @@ def get_children():
|
||||
company, as_dict=1)
|
||||
else:
|
||||
# other
|
||||
acc = frappe.conn.sql("""select
|
||||
acc = frappe.db.sql("""select
|
||||
name as value, if(group_or_ledger='Group', 1, 0) as expandable
|
||||
from `tab%s`
|
||||
where ifnull(parent_%s,'') = %s
|
||||
@@ -38,7 +38,7 @@ def get_children():
|
||||
args['parent'], as_dict=1)
|
||||
|
||||
if ctype == 'Account':
|
||||
currency = frappe.conn.sql("select default_currency from `tabCompany` where name = %s", company)[0][0]
|
||||
currency = frappe.db.sql("select default_currency from `tabCompany` where name = %s", company)[0][0]
|
||||
for each in acc:
|
||||
bal = get_balance_on(each.get("value"))
|
||||
each["currency"] = currency
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
||||
@@ -1,295 +0,0 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt"
|
||||
|
||||
frappe.module_page["Accounts"] = [
|
||||
{
|
||||
top: true,
|
||||
title: frappe._("Documents"),
|
||||
icon: "icon-copy",
|
||||
items: [
|
||||
{
|
||||
label: frappe._("Journal Voucher"),
|
||||
description: frappe._("Accounting journal entries."),
|
||||
doctype:"Journal Voucher"
|
||||
},
|
||||
{
|
||||
label: frappe._("Sales Invoice"),
|
||||
description: frappe._("Bills raised to Customers."),
|
||||
doctype:"Sales Invoice"
|
||||
},
|
||||
{
|
||||
label: frappe._("Purchase Invoice"),
|
||||
description: frappe._("Bills raised by Suppliers."),
|
||||
doctype:"Purchase Invoice"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: frappe._("Masters"),
|
||||
icon: "icon-book",
|
||||
items: [
|
||||
{
|
||||
label: frappe._("Chart of Accounts"),
|
||||
route: "Accounts Browser/Account",
|
||||
description: frappe._("Structure of books of accounts."),
|
||||
doctype:"Account"
|
||||
},
|
||||
{
|
||||
label: frappe._("Chart of Cost Centers"),
|
||||
route: "Accounts Browser/Cost Center",
|
||||
description: frappe._("Structure cost centers for budgeting."),
|
||||
doctype:"Cost Center"
|
||||
},
|
||||
{
|
||||
label: frappe._("Customer"),
|
||||
description: frappe._("Customer database."),
|
||||
doctype:"Customer"
|
||||
},
|
||||
{
|
||||
label: frappe._("Supplier"),
|
||||
description: frappe._("Supplier database."),
|
||||
doctype:"Supplier"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: frappe._("Setup"),
|
||||
icon: "icon-wrench",
|
||||
items: [
|
||||
{
|
||||
label: frappe._("Company"),
|
||||
description: frappe._("Company Master."),
|
||||
doctype:"Company"
|
||||
},
|
||||
{
|
||||
label: frappe._("Fiscal Year"),
|
||||
description: frappe._("Accounting Year."),
|
||||
doctype:"Fiscal Year"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: frappe._("Tools"),
|
||||
icon: "icon-wrench",
|
||||
items: [
|
||||
{
|
||||
"route":"Form/Bank Reconciliation/Bank Reconciliation",
|
||||
"label": frappe._("Bank Reconciliation"),
|
||||
"description": frappe._("Update bank payment dates with journals."),
|
||||
doctype: "Bank Reconciliation"
|
||||
},
|
||||
{
|
||||
"route":"Form/Payment to Invoice Matching Tool/Payment to Invoice Matching Tool",
|
||||
"label": frappe._("Payment Reconciliation"),
|
||||
"description": frappe._("Match non-linked Invoices and Payments."),
|
||||
doctype: "Payment to Invoice Matching Tool"
|
||||
|
||||
},
|
||||
{
|
||||
"label": frappe._("Period Closing Voucher"),
|
||||
"doctype": "Period Closing Voucher",
|
||||
description: frappe._("Close Balance Sheet and book Profit or Loss.")
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: frappe._("Setup"),
|
||||
icon: "icon-cog",
|
||||
items: [
|
||||
{
|
||||
"label": frappe._("Accounts Settings"),
|
||||
"route": "Form/Accounts Settings",
|
||||
"doctype":"Accounts Settings",
|
||||
"description": frappe._("Settings for Accounts")
|
||||
},
|
||||
{
|
||||
"label": frappe._("Sales Taxes and Charges Master"),
|
||||
"doctype":"Sales Taxes and Charges Master",
|
||||
"description": frappe._("Tax Template for Sales")
|
||||
},
|
||||
{
|
||||
"label": frappe._("Purchase Taxes and Charges Master"),
|
||||
"doctype":"Purchase Taxes and Charges Master",
|
||||
"description": frappe._("Tax Template for Purchase")
|
||||
},
|
||||
{
|
||||
"label": frappe._("Shipping Rules"),
|
||||
"doctype":"Shipping Rule",
|
||||
"description": frappe._("Rules to calculate shipping amount for a sale")
|
||||
},
|
||||
{
|
||||
"label": frappe._("Currency Exchange"),
|
||||
"doctype":"Currency Exchange",
|
||||
"description": frappe._("Manage exchange rates for currency conversion")
|
||||
},
|
||||
{
|
||||
"label": frappe._("Point-of-Sale Setting"),
|
||||
"doctype":"POS Setting",
|
||||
"description": frappe._("User settings for Point-of-sale (POS)")
|
||||
},
|
||||
{
|
||||
"doctype":"Budget Distribution",
|
||||
"label": frappe._("Budget Distribution"),
|
||||
"description": frappe._("Seasonality for setting budgets.")
|
||||
},
|
||||
{
|
||||
"doctype":"Terms and Conditions",
|
||||
"label": frappe._("Terms and Conditions Template"),
|
||||
description: frappe._("Template of terms or contract.")
|
||||
},
|
||||
{
|
||||
"doctype":"Mode of Payment",
|
||||
"label": frappe._("Mode of Payment"),
|
||||
description: frappe._("e.g. Bank, Cash, Credit Card")
|
||||
},
|
||||
{
|
||||
"doctype":"C-Form",
|
||||
"label": frappe._("C-Form"),
|
||||
description: frappe._("C-Form records"),
|
||||
country: "India"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: frappe._("Main Reports"),
|
||||
right: true,
|
||||
icon: "icon-table",
|
||||
items: [
|
||||
{
|
||||
"label":frappe._("General Ledger"),
|
||||
doctype: "GL Entry",
|
||||
route: "query-report/General Ledger"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Trial Balance"),
|
||||
page: "trial-balance"
|
||||
},
|
||||
{
|
||||
"page":"Financial Statements",
|
||||
"label": frappe._("Financial Statements")
|
||||
},
|
||||
{
|
||||
"label":frappe._("Accounts Receivable"),
|
||||
route: "query-report/Accounts Receivable",
|
||||
doctype: "Sales Invoice"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Accounts Payable"),
|
||||
route: "query-report/Accounts Payable",
|
||||
doctype: "Purchase Invoice"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Sales Register"),
|
||||
route: "query-report/Sales Register",
|
||||
doctype: "Sales Invoice"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Purchase Register"),
|
||||
route: "query-report/Purchase Register",
|
||||
doctype: "Purchase Invoice"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: frappe._("Analytics"),
|
||||
right: true,
|
||||
icon: "icon-bar-chart",
|
||||
items: [
|
||||
{
|
||||
"label":frappe._("Financial Analytics"),
|
||||
page: "financial-analytics"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Gross Profit"),
|
||||
route: "query-report/Gross Profit",
|
||||
doctype: "Sales Invoice"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: frappe._("Reports"),
|
||||
right: true,
|
||||
icon: "icon-list",
|
||||
items: [
|
||||
{
|
||||
"label":frappe._("Bank Reconciliation Statement"),
|
||||
route: "query-report/Bank Reconciliation Statement",
|
||||
doctype: "Journal Voucher"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Ordered Items To Be Billed"),
|
||||
route: "query-report/Ordered Items To Be Billed",
|
||||
doctype: "Sales Invoice"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Delivered Items To Be Billed"),
|
||||
route: "query-report/Delivered Items To Be Billed",
|
||||
doctype: "Sales Invoice"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Purchase Order Items To Be Billed"),
|
||||
route: "query-report/Purchase Order Items To Be Billed",
|
||||
doctype: "Purchase Invoice"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Received Items To Be Billed"),
|
||||
route: "query-report/Received Items To Be Billed",
|
||||
doctype: "Purchase Invoice"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Bank Clearance Summary"),
|
||||
route: "query-report/Bank Clearance Summary",
|
||||
doctype: "Journal Voucher"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Payment Period Based On Invoice Date"),
|
||||
route: "query-report/Payment Period Based On Invoice Date",
|
||||
doctype: "Journal Voucher"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Sales Partners Commission"),
|
||||
route: "query-report/Sales Partners Commission",
|
||||
doctype: "Sales Invoice"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Customer Account Head"),
|
||||
route: "query-report/Customer Account Head",
|
||||
doctype: "Account"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Supplier Account Head"),
|
||||
route: "query-report/Supplier Account Head",
|
||||
doctype: "Account"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Item-wise Sales Register"),
|
||||
route: "query-report/Item-wise Sales Register",
|
||||
doctype: "Sales Invoice"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Item-wise Purchase Register"),
|
||||
route: "query-report/Item-wise Purchase Register",
|
||||
doctype: "Purchase Invoice"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Budget Variance Report"),
|
||||
route: "query-report/Budget Variance Report",
|
||||
doctype: "Cost Center"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Purchase Invoice Trends"),
|
||||
route: "query-report/Purchase Invoice Trends",
|
||||
doctype: "Purchase Invoice"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Sales Invoice Trends"),
|
||||
route: "query-report/Sales Invoice Trends",
|
||||
doctype: "Sales Invoice"
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
pscript['onload_accounts-home'] = function(wrapper) {
|
||||
frappe.views.moduleview.make(wrapper, "Accounts");
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2012-06-14 15:07:28",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-11 14:40:16",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Page",
|
||||
"icon": "icon-th",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"page_name": "accounts-home",
|
||||
"standard": "Yes",
|
||||
"title": "Accounts Home"
|
||||
},
|
||||
{
|
||||
"doctype": "Page",
|
||||
"name": "accounts-home"
|
||||
}
|
||||
]
|
||||
@@ -6,23 +6,30 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.defaults import get_restrictions
|
||||
from frappe.utils import add_days
|
||||
from erpnext.utilities.doctype.address.address import get_address_display
|
||||
from erpnext.utilities.doctype.contact.contact import get_contact_details
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_party_details(party=None, account=None, party_type="Customer", company=None,
|
||||
posting_date=None, price_list=None, currency=None):
|
||||
|
||||
return _get_party_details(party, account, party_type, company, posting_date, price_list, currency)
|
||||
|
||||
def _get_party_details(party=None, account=None, party_type="Customer", company=None,
|
||||
posting_date=None, price_list=None, currency=None, ignore_permissions=False):
|
||||
out = frappe._dict(set_account_and_due_date(party, account, party_type, company, posting_date))
|
||||
|
||||
party = out[party_type.lower()]
|
||||
|
||||
if not frappe.has_permission(party_type, "read", party):
|
||||
if not ignore_permissions and not frappe.has_permission(party_type, "read", party):
|
||||
frappe.throw("Not Permitted", frappe.PermissionError)
|
||||
|
||||
party_bean = frappe.bean(party_type, party)
|
||||
party = party_bean.doc
|
||||
|
||||
set_address_and_contact(out, party, party_type)
|
||||
set_address_details(out, party, party_type)
|
||||
set_contact_details(out, party, party_type)
|
||||
set_other_values(out, party, party_type)
|
||||
set_price_list(out, party, price_list)
|
||||
|
||||
@@ -38,20 +45,26 @@ def get_party_details(party=None, account=None, party_type="Customer", company=N
|
||||
|
||||
return out
|
||||
|
||||
def set_address_and_contact(out, party, party_type):
|
||||
out.update({
|
||||
party_type.lower() + "_address": frappe.conn.get_value("Address",
|
||||
{party_type.lower(): party.name, "is_primary_address":1}, "name"),
|
||||
"contact_person": frappe.conn.get_value("Contact",
|
||||
{party_type.lower(): party.name, "is_primary_contact":1}, "name")
|
||||
})
|
||||
def set_address_details(out, party, party_type):
|
||||
billing_address_field = "customer_address" if party_type == "Lead" \
|
||||
else party_type.lower() + "_address"
|
||||
out[billing_address_field] = frappe.db.get_value("Address",
|
||||
{party_type.lower(): party.name, "is_primary_address":1}, "name")
|
||||
|
||||
# address display
|
||||
out.address_display = get_address_display(out[party_type.lower() + "_address"])
|
||||
out.address_display = get_address_display(out[billing_address_field])
|
||||
|
||||
# shipping address
|
||||
if party_type in ["Customer", "Lead"]:
|
||||
out.shipping_address_name = frappe.db.get_value("Address",
|
||||
{party_type.lower(): party.name, "is_shipping_address":1}, "name")
|
||||
out.shipping_address = get_address_display(out["shipping_address_name"])
|
||||
|
||||
def set_contact_details(out, party, party_type):
|
||||
out.contact_person = frappe.db.get_value("Contact",
|
||||
{party_type.lower(): party.name, "is_primary_contact":1}, "name")
|
||||
|
||||
# primary contact details
|
||||
out.update(get_contact_details(out.contact_person))
|
||||
|
||||
|
||||
def set_other_values(out, party, party_type):
|
||||
# copy
|
||||
@@ -78,14 +91,14 @@ def set_price_list(out, party, given_price_list):
|
||||
price_list = party.default_price_list
|
||||
|
||||
if not price_list and party.party_type=="Customer":
|
||||
price_list = frappe.conn.get_value("Customer Group",
|
||||
price_list = frappe.db.get_value("Customer Group",
|
||||
party.customer_group, "default_price_list")
|
||||
|
||||
if not price_list:
|
||||
price_list = given_price_list
|
||||
|
||||
if price_list:
|
||||
out.price_list_currency = frappe.conn.get_value("Price List", price_list, "currency")
|
||||
out.price_list_currency = frappe.db.get_value("Price List", price_list, "currency")
|
||||
|
||||
out["selling_price_list" if party.doctype=="Customer" else "buying_price_list"] = price_list
|
||||
|
||||
@@ -100,7 +113,7 @@ def set_account_and_due_date(party, account, party_type, company, posting_date):
|
||||
if party:
|
||||
account = get_party_account(company, party, party_type)
|
||||
elif account:
|
||||
party = frappe.conn.get_value('Account', account, 'master_name')
|
||||
party = frappe.db.get_value('Account', account, 'master_name')
|
||||
|
||||
account_fieldname = "debit_to" if party_type=="Customer" else "credit_to"
|
||||
|
||||
@@ -116,7 +129,7 @@ def get_party_account(company, party, party_type):
|
||||
frappe.throw(_("Please select company first."))
|
||||
|
||||
if party:
|
||||
acc_head = frappe.conn.get_value("Account", {"master_name":party,
|
||||
acc_head = frappe.db.get_value("Account", {"master_name":party,
|
||||
"master_type": party_type, "company": company})
|
||||
|
||||
if not acc_head:
|
||||
@@ -130,11 +143,11 @@ def get_due_date(posting_date, party, party_type, account, company):
|
||||
if posting_date:
|
||||
credit_days = 0
|
||||
if account:
|
||||
credit_days = frappe.conn.get_value("Account", account, "credit_days")
|
||||
credit_days = frappe.db.get_value("Account", account, "credit_days")
|
||||
if party and not credit_days:
|
||||
credit_days = frappe.conn.get_value(party_type, party, "credit_days")
|
||||
credit_days = frappe.db.get_value(party_type, party, "credit_days")
|
||||
if company and not credit_days:
|
||||
credit_days = frappe.conn.get_value("Company", company, "credit_days")
|
||||
credit_days = frappe.db.get_value("Company", company, "credit_days")
|
||||
|
||||
due_date = add_days(posting_date, credit_days) if credit_days else posting_date
|
||||
|
||||
@@ -144,9 +157,9 @@ def create_party_account(party, party_type, company):
|
||||
if not company:
|
||||
frappe.throw(_("Company is required"))
|
||||
|
||||
company_details = frappe.conn.get_value("Company", company,
|
||||
company_details = frappe.db.get_value("Company", company,
|
||||
["abbr", "receivables_group", "payables_group"], as_dict=True)
|
||||
if not frappe.conn.exists("Account", (party + " - " + company_details.abbr)):
|
||||
if not frappe.db.exists("Account", (party + " - " + company_details.abbr)):
|
||||
parent_account = company_details.receivables_group \
|
||||
if party_type=="Customer" else company_details.payables_group
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ from erpnext.accounts.report.accounts_receivable.accounts_receivable import get_
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
supplier_naming_by = frappe.conn.get_value("Buying Settings", None, "supp_master_name")
|
||||
supplier_naming_by = frappe.db.get_value("Buying Settings", None, "supp_master_name")
|
||||
columns = get_columns(supplier_naming_by)
|
||||
entries = get_gl_entries(filters)
|
||||
account_map = dict(((r.name, r) for r in frappe.conn.sql("""select acc.name,
|
||||
account_map = dict(((r.name, r) for r in frappe.db.sql("""select acc.name,
|
||||
supp.supplier_name, supp.name as supplier
|
||||
from `tabAccount` acc, `tabSupplier` supp
|
||||
where acc.master_type="Supplier" and supp.name=acc.master_name""", as_dict=1)))
|
||||
@@ -85,7 +85,7 @@ def get_columns(supplier_naming_by):
|
||||
def get_gl_entries(filters, before_report_date=True):
|
||||
conditions, supplier_accounts = get_conditions(filters, before_report_date)
|
||||
gl_entries = []
|
||||
gl_entries = frappe.conn.sql("""select * from `tabGL Entry`
|
||||
gl_entries = frappe.db.sql("""select * from `tabGL Entry`
|
||||
where docstatus < 2 %s order by posting_date, account""" %
|
||||
(conditions), tuple(supplier_accounts), as_dict=1)
|
||||
return gl_entries
|
||||
@@ -99,7 +99,7 @@ def get_conditions(filters, before_report_date=True):
|
||||
if filters.get("account"):
|
||||
supplier_accounts = [filters["account"]]
|
||||
else:
|
||||
supplier_accounts = frappe.conn.sql_list("""select name from `tabAccount`
|
||||
supplier_accounts = frappe.db.sql_list("""select name from `tabAccount`
|
||||
where ifnull(master_type, '') = 'Supplier' and docstatus < 2 %s""" %
|
||||
conditions, filters)
|
||||
|
||||
@@ -118,7 +118,7 @@ def get_conditions(filters, before_report_date=True):
|
||||
|
||||
def get_account_supplier_type_map():
|
||||
account_supplier_type_map = {}
|
||||
for each in frappe.conn.sql("""select acc.name, supp.supplier_type from `tabSupplier` supp,
|
||||
for each in frappe.db.sql("""select acc.name, supp.supplier_type from `tabSupplier` supp,
|
||||
`tabAccount` acc where supp.name = acc.master_name group by acc.name"""):
|
||||
account_supplier_type_map[each[0]] = each[1]
|
||||
|
||||
@@ -128,14 +128,14 @@ def get_voucher_details():
|
||||
voucher_details = {}
|
||||
for dt in ["Purchase Invoice", "Journal Voucher"]:
|
||||
voucher_details.setdefault(dt, frappe._dict())
|
||||
for t in frappe.conn.sql("""select name, due_date, bill_no, bill_date
|
||||
for t in frappe.db.sql("""select name, due_date, bill_no, bill_date
|
||||
from `tab%s`""" % dt, as_dict=1):
|
||||
voucher_details[dt].setdefault(t.name, t)
|
||||
|
||||
return voucher_details
|
||||
|
||||
def get_outstanding_amount(gle, report_date):
|
||||
payment_amount = frappe.conn.sql("""
|
||||
payment_amount = frappe.db.sql("""
|
||||
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||
from `tabGL Entry`
|
||||
where account = %s and posting_date <= %s and against_voucher_type = %s
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-04-22 16:16:03",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-04-30 17:55:54",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -10,6 +10,7 @@
|
||||
"add_total_row": 1,
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Purchase Invoice",
|
||||
"report_name": "Accounts Payable",
|
||||
|
||||
@@ -15,7 +15,7 @@ class AccountsReceivableReport(object):
|
||||
else self.filters.report_date
|
||||
|
||||
def run(self):
|
||||
customer_naming_by = frappe.conn.get_value("Selling Settings", None, "cust_master_name")
|
||||
customer_naming_by = frappe.db.get_value("Selling Settings", None, "cust_master_name")
|
||||
return self.get_columns(customer_naming_by), self.get_data(customer_naming_by)
|
||||
|
||||
def get_columns(self, customer_naming_by):
|
||||
@@ -111,7 +111,7 @@ class AccountsReceivableReport(object):
|
||||
|
||||
def get_account_map(self):
|
||||
if not hasattr(self, "account_map"):
|
||||
self.account_map = dict(((r.name, r) for r in frappe.conn.sql("""select
|
||||
self.account_map = dict(((r.name, r) for r in frappe.db.sql("""select
|
||||
acc.name, cust.name as customer, cust.customer_name, cust.territory
|
||||
from `tabAccount` acc left join `tabCustomer` cust
|
||||
on cust.name=acc.master_name where acc.master_type="Customer" """, as_dict=True)))
|
||||
@@ -121,7 +121,7 @@ class AccountsReceivableReport(object):
|
||||
def get_due_date(self, gle):
|
||||
if not hasattr(self, "invoice_due_date_map"):
|
||||
# TODO can be restricted to posting date
|
||||
self.invoice_due_date_map = dict(frappe.conn.sql("""select name, due_date
|
||||
self.invoice_due_date_map = dict(frappe.db.sql("""select name, due_date
|
||||
from `tabSales Invoice` where docstatus=1"""))
|
||||
|
||||
return gle.voucher_type == "Sales Invoice" \
|
||||
@@ -130,7 +130,7 @@ class AccountsReceivableReport(object):
|
||||
def get_gl_entries(self):
|
||||
if not hasattr(self, "gl_entries"):
|
||||
conditions, values = self.prepare_conditions()
|
||||
self.gl_entries = frappe.conn.sql("""select * from `tabGL Entry`
|
||||
self.gl_entries = frappe.db.sql("""select * from `tabGL Entry`
|
||||
where docstatus < 2 {0} order by posting_date, account""".format(conditions),
|
||||
values, as_dict=True)
|
||||
return self.gl_entries
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-04-16 11:31:13",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-05-24 12:02:52",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -10,6 +10,7 @@
|
||||
"add_total_row": 1,
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Sales Invoice",
|
||||
"report_name": "Accounts Receivable",
|
||||
|
||||
@@ -33,7 +33,7 @@ def get_conditions(filters):
|
||||
|
||||
def get_entries(filters):
|
||||
conditions = get_conditions(filters)
|
||||
entries = frappe.conn.sql("""select jv.name, jvd.account, jv.posting_date,
|
||||
entries = frappe.db.sql("""select jv.name, jvd.account, jv.posting_date,
|
||||
jv.clearance_date, jvd.against_account, jvd.debit, jvd.credit
|
||||
from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
|
||||
where jvd.parent = jv.name and jv.docstatus=1 %s
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
{
|
||||
"creation": "2013-05-01 12:13:25",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-05-01 12:13:25",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Journal Voucher",
|
||||
"report_name": "Bank Clearance Summary",
|
||||
|
||||
@@ -8,7 +8,7 @@ from frappe.utils import flt
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
|
||||
debit_or_credit = frappe.conn.get_value("Account", filters["account"], "debit_or_credit")
|
||||
debit_or_credit = frappe.db.get_value("Account", filters["account"], "debit_or_credit")
|
||||
|
||||
columns = get_columns()
|
||||
data = get_entries(filters)
|
||||
@@ -41,7 +41,7 @@ def get_columns():
|
||||
]
|
||||
|
||||
def get_entries(filters):
|
||||
entries = frappe.conn.sql("""select
|
||||
entries = frappe.db.sql("""select
|
||||
jv.name, jv.posting_date, jv.clearance_date, jvd.against_account, jvd.debit, jvd.credit
|
||||
from
|
||||
`tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-04-30 18:30:21",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-05-01 10:53:12",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -10,6 +10,7 @@
|
||||
"add_total_row": 0,
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Journal Voucher",
|
||||
"report_name": "Bank Reconciliation Statement",
|
||||
|
||||
@@ -62,7 +62,7 @@ def get_columns(filters):
|
||||
|
||||
#Get cost center & target details
|
||||
def get_costcenter_target_details(filters):
|
||||
return frappe.conn.sql("""select cc.name, cc.distribution_id,
|
||||
return frappe.db.sql("""select cc.name, cc.distribution_id,
|
||||
cc.parent_cost_center, bd.account, bd.budget_allocated
|
||||
from `tabCost Center` cc, `tabBudget Detail` bd
|
||||
where bd.parent=cc.name and bd.fiscal_year=%s and
|
||||
@@ -73,7 +73,7 @@ def get_costcenter_target_details(filters):
|
||||
def get_target_distribution_details(filters):
|
||||
target_details = {}
|
||||
|
||||
for d in frappe.conn.sql("""select bd.name, bdd.month, bdd.percentage_allocation
|
||||
for d in frappe.db.sql("""select bd.name, bdd.month, bdd.percentage_allocation
|
||||
from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd
|
||||
where bdd.parent=bd.name and bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
|
||||
target_details.setdefault(d.name, {}).setdefault(d.month, flt(d.percentage_allocation))
|
||||
@@ -82,7 +82,7 @@ def get_target_distribution_details(filters):
|
||||
|
||||
#Get actual details from gl entry
|
||||
def get_actual_details(filters):
|
||||
ac_details = frappe.conn.sql("""select gl.account, gl.debit, gl.credit,
|
||||
ac_details = frappe.db.sql("""select gl.account, gl.debit, gl.credit,
|
||||
gl.cost_center, MONTHNAME(gl.posting_date) as month_name
|
||||
from `tabGL Entry` gl, `tabBudget Detail` bd
|
||||
where gl.fiscal_year=%s and company=%s
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
{
|
||||
"creation": "2013-06-18 12:56:36",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-06-18 12:56:36",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Cost Center",
|
||||
"report_name": "Budget Variance Report",
|
||||
|
||||
@@ -8,7 +8,7 @@ def execute(filters=None):
|
||||
account_map = get_account_map()
|
||||
columns = get_columns(account_map)
|
||||
data = []
|
||||
customers = frappe.conn.sql("select name from tabCustomer where docstatus < 2")
|
||||
customers = frappe.db.sql("select name from tabCustomer where docstatus < 2")
|
||||
for cust in customers:
|
||||
row = [cust[0]]
|
||||
for company in sorted(account_map):
|
||||
@@ -18,7 +18,7 @@ def execute(filters=None):
|
||||
return columns, data
|
||||
|
||||
def get_account_map():
|
||||
accounts = frappe.conn.sql("""select name, company, master_name
|
||||
accounts = frappe.db.sql("""select name, company, master_name
|
||||
from `tabAccount` where master_type = 'Customer'
|
||||
and ifnull(master_name, '') != '' and docstatus < 2""", as_dict=1)
|
||||
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
{
|
||||
"creation": "2013-06-03 16:17:34",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-06-03 16:17:34",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Account",
|
||||
"report_name": "Customer Account Head",
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
{
|
||||
"creation": "2013-07-30 17:28:49",
|
||||
"docstatus": 0,
|
||||
"modified": "2014-02-11 12:40:04",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"query": "select\n `tabDelivery Note`.`name` as \"Delivery Note:Link/Delivery Note:120\",\n\t`tabDelivery Note`.`customer` as \"Customer:Link/Customer:120\",\n\t`tabDelivery Note`.`posting_date` as \"Date:Date\",\n\t`tabDelivery Note`.`project_name` as \"Project\",\n\t`tabDelivery Note Item`.`item_code` as \"Item:Link/Item:120\",\n\t(`tabDelivery Note Item`.`qty` - ifnull((select sum(qty) from `tabSales Invoice Item` \n\t where `tabSales Invoice Item`.docstatus=1 and \n `tabSales Invoice Item`.delivery_note = `tabDelivery Note`.name and\n\t `tabSales Invoice Item`.dn_detail = `tabDelivery Note Item`.name), 0))\n\t\tas \"Qty:Float:110\",\n\t(`tabDelivery Note Item`.`base_amount` - ifnull((select sum(base_amount) from `tabSales Invoice Item` \n where `tabSales Invoice Item`.docstatus=1 and \n `tabSales Invoice Item`.delivery_note = `tabDelivery Note`.name and\n `tabSales Invoice Item`.dn_detail = `tabDelivery Note Item`.name), 0))\n\t\tas \"Amount:Currency:110\",\n\t`tabDelivery Note Item`.`item_name` as \"Item Name::150\",\n\t`tabDelivery Note Item`.`description` as \"Description::200\"\nfrom `tabDelivery Note`, `tabDelivery Note Item`\nwhere\n `tabDelivery Note`.docstatus = 1 and\n\t`tabDelivery Note`.`status` != \"Stopped\" and\n `tabDelivery Note`.name = `tabDelivery Note Item`.parent and\n (`tabDelivery Note Item`.qty > ifnull((select sum(qty) from `tabSales Invoice Item` \n where `tabSales Invoice Item`.docstatus=1 and \n `tabSales Invoice Item`.delivery_note = `tabDelivery Note`.name and\n `tabSales Invoice Item`.dn_detail = `tabDelivery Note Item`.name), 0))\norder by `tabDelivery Note`.`name` desc",
|
||||
"ref_doctype": "Sales Invoice",
|
||||
|
||||
@@ -8,7 +8,7 @@ from frappe import _
|
||||
|
||||
def execute(filters=None):
|
||||
account_details = {}
|
||||
for acc in frappe.conn.sql("""select name, debit_or_credit, group_or_ledger
|
||||
for acc in frappe.db.sql("""select name, debit_or_credit, group_or_ledger
|
||||
from tabAccount""", as_dict=1):
|
||||
account_details.setdefault(acc.name, acc)
|
||||
|
||||
@@ -49,7 +49,7 @@ def get_gl_entries(filters):
|
||||
group_by_condition = "group by voucher_type, voucher_no, account" \
|
||||
if filters.get("group_by_voucher") else "group by name"
|
||||
|
||||
gl_entries = frappe.conn.sql("""select posting_date, account,
|
||||
gl_entries = frappe.db.sql("""select posting_date, account,
|
||||
sum(ifnull(debit, 0)) as debit, sum(ifnull(credit, 0)) as credit,
|
||||
voucher_type, voucher_no, cost_center, remarks, is_opening, against
|
||||
from `tabGL Entry`
|
||||
@@ -64,7 +64,7 @@ def get_gl_entries(filters):
|
||||
def get_conditions(filters):
|
||||
conditions = []
|
||||
if filters.get("account"):
|
||||
lft, rgt = frappe.conn.get_value("Account", filters["account"], ["lft", "rgt"])
|
||||
lft, rgt = frappe.db.get_value("Account", filters["account"], ["lft", "rgt"])
|
||||
conditions.append("""account in (select name from tabAccount
|
||||
where lft>=%s and rgt<=%s and docstatus<2)""" % (lft, rgt))
|
||||
else:
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
{
|
||||
"creation": "2013-12-06 13:22:23",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-12-06 13:22:23",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "GL Entry",
|
||||
"report_name": "General Ledger",
|
||||
|
||||
@@ -59,7 +59,7 @@ def get_stock_ledger_entries(filters):
|
||||
|
||||
query += " order by item_code desc, warehouse desc, posting_date desc, posting_time desc, name desc"
|
||||
|
||||
res = frappe.conn.sql(query, filters, as_dict=True)
|
||||
res = frappe.db.sql(query, filters, as_dict=True)
|
||||
|
||||
out = {}
|
||||
for r in res:
|
||||
@@ -73,7 +73,7 @@ def get_stock_ledger_entries(filters):
|
||||
def get_item_sales_bom():
|
||||
item_sales_bom = {}
|
||||
|
||||
for d in frappe.conn.sql("""select parenttype, parent, parent_item,
|
||||
for d in frappe.db.sql("""select parenttype, parent, parent_item,
|
||||
item_code, warehouse, -1*qty as total_qty, parent_detail_docname
|
||||
from `tabPacked Item` where docstatus=1""", as_dict=True):
|
||||
item_sales_bom.setdefault(d.parenttype, frappe._dict()).setdefault(d.parent,
|
||||
@@ -90,7 +90,7 @@ def get_source_data(filters):
|
||||
if filters.get("to_date"):
|
||||
conditions += " and posting_date<=%(to_date)s"
|
||||
|
||||
delivery_note_items = frappe.conn.sql("""select item.parenttype, dn.name,
|
||||
delivery_note_items = frappe.db.sql("""select item.parenttype, dn.name,
|
||||
dn.posting_date, dn.posting_time, dn.project_name,
|
||||
item.item_code, item.item_name, item.description, item.warehouse,
|
||||
item.qty, item.base_rate, item.base_amount, item.name as "item_row",
|
||||
@@ -99,7 +99,7 @@ def get_source_data(filters):
|
||||
where item.parent = dn.name and dn.docstatus = 1 %s
|
||||
order by dn.posting_date desc, dn.posting_time desc""" % (conditions,), filters, as_dict=1)
|
||||
|
||||
sales_invoice_items = frappe.conn.sql("""select item.parenttype, si.name,
|
||||
sales_invoice_items = frappe.db.sql("""select item.parenttype, si.name,
|
||||
si.posting_date, si.posting_time, si.project_name,
|
||||
item.item_code, item.item_name, item.description, item.warehouse,
|
||||
item.qty, item.base_rate, item.base_amount, item.name as "item_row",
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
{
|
||||
"creation": "2013-02-25 17:03:34",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-02-25 17:03:34",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Sales Invoice",
|
||||
"report_name": "Gross Profit",
|
||||
|
||||
@@ -57,7 +57,7 @@ def get_items(filters):
|
||||
conditions = get_conditions(filters)
|
||||
match_conditions = frappe.build_match_conditions("Purchase Invoice")
|
||||
|
||||
return frappe.conn.sql("""select pi_item.parent, pi.posting_date, pi.credit_to, pi.company,
|
||||
return frappe.db.sql("""select pi_item.parent, pi.posting_date, pi.credit_to, pi.company,
|
||||
pi.supplier, pi.remarks, pi_item.item_code, pi_item.item_name, pi_item.item_group,
|
||||
pi_item.project_name, pi_item.purchase_order, pi_item.purchase_receipt,
|
||||
pi_item.expense_account, pi_item.qty, pi_item.base_rate, pi_item.base_amount, pi.supplier_name
|
||||
@@ -66,14 +66,14 @@ def get_items(filters):
|
||||
order by pi.posting_date desc, pi_item.item_code desc""" % (conditions, match_conditions), filters, as_dict=1)
|
||||
|
||||
def get_aii_accounts():
|
||||
return dict(frappe.conn.sql("select name, stock_received_but_not_billed from tabCompany"))
|
||||
return dict(frappe.db.sql("select name, stock_received_but_not_billed from tabCompany"))
|
||||
|
||||
def get_tax_accounts(item_list, columns):
|
||||
import json
|
||||
item_tax = {}
|
||||
tax_accounts = []
|
||||
|
||||
tax_details = frappe.conn.sql("""select parent, account_head, item_wise_tax_detail
|
||||
tax_details = frappe.db.sql("""select parent, account_head, item_wise_tax_detail
|
||||
from `tabPurchase Taxes and Charges` where parenttype = 'Purchase Invoice'
|
||||
and docstatus = 1 and ifnull(account_head, '') != '' and category in ('Total', 'Valuation and Total')
|
||||
and parent in (%s)""" % ', '.join(['%s']*len(item_list)), tuple([item.parent for item in item_list]))
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-06-05 15:37:30",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-06-05 15:37:30",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -10,6 +10,7 @@
|
||||
"add_total_row": 1,
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Purchase Invoice",
|
||||
"report_name": "Item-wise Purchase Register",
|
||||
|
||||
@@ -55,7 +55,7 @@ def get_conditions(filters):
|
||||
|
||||
def get_items(filters):
|
||||
conditions = get_conditions(filters)
|
||||
return frappe.conn.sql("""select si_item.parent, si.posting_date, si.debit_to, si.project_name,
|
||||
return frappe.db.sql("""select si_item.parent, si.posting_date, si.debit_to, si.project_name,
|
||||
si.customer, si.remarks, si.territory, si.company, si_item.item_code, si_item.item_name,
|
||||
si_item.item_group, si_item.sales_order, si_item.delivery_note, si_item.income_account,
|
||||
si_item.qty, si_item.base_rate, si_item.base_amount, si.customer_name
|
||||
@@ -68,7 +68,7 @@ def get_tax_accounts(item_list, columns):
|
||||
item_tax = {}
|
||||
tax_accounts = []
|
||||
|
||||
tax_details = frappe.conn.sql("""select parent, account_head, item_wise_tax_detail
|
||||
tax_details = frappe.db.sql("""select parent, account_head, item_wise_tax_detail
|
||||
from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice'
|
||||
and docstatus = 1 and ifnull(account_head, '') != ''
|
||||
and parent in (%s)""" % ', '.join(['%s']*len(item_list)),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-13 17:50:55",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-05-13 17:50:55",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -10,6 +10,7 @@
|
||||
"add_total_row": 1,
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Sales Invoice",
|
||||
"report_name": "Item-wise Sales Register",
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
{
|
||||
"creation": "2013-02-21 14:26:44",
|
||||
"docstatus": 0,
|
||||
"modified": "2014-02-11 15:53:01",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"query": "select \n `tabSales Order`.`name` as \"Sales Order:Link/Sales Order:120\",\n `tabSales Order`.`customer` as \"Customer:Link/Customer:120\",\n `tabSales Order`.`status` as \"Status\",\n `tabSales Order`.`transaction_date` as \"Date:Date\",\n `tabSales Order`.`project_name` as \"Project\",\n `tabSales Order Item`.item_code as \"Item:Link/Item:120\",\n `tabSales Order Item`.base_amount as \"Amount:Currency:110\",\n (`tabSales Order Item`.billed_amt * ifnull(`tabSales Order`.conversion_rate, 1)) as \"Billed Amount:Currency:110\",\n (ifnull(`tabSales Order Item`.base_amount, 0) - (ifnull(`tabSales Order Item`.billed_amt, 0) * ifnull(`tabSales Order`.conversion_rate, 1))) as \"Pending Amount:Currency:120\",\n `tabSales Order Item`.item_name as \"Item Name::150\",\n `tabSales Order Item`.description as \"Description::200\"\nfrom\n `tabSales Order`, `tabSales Order Item`\nwhere\n `tabSales Order Item`.`parent` = `tabSales Order`.`name`\n and `tabSales Order`.docstatus = 1\n and `tabSales Order`.status != \"Stopped\"\n and ifnull(`tabSales Order Item`.billed_amt,0) < ifnull(`tabSales Order Item`.amount,0)\norder by `tabSales Order`.transaction_date asc",
|
||||
"ref_doctype": "Sales Invoice",
|
||||
|
||||
@@ -58,7 +58,7 @@ def get_conditions(filters):
|
||||
else:
|
||||
cond += " and master_type = 'Supplier'"
|
||||
|
||||
party_accounts = frappe.conn.sql_list("""select name from `tabAccount`
|
||||
party_accounts = frappe.db.sql_list("""select name from `tabAccount`
|
||||
where ifnull(master_name, '')!='' and docstatus < 2 %s""" % cond)
|
||||
|
||||
if party_accounts:
|
||||
@@ -74,7 +74,7 @@ def get_conditions(filters):
|
||||
|
||||
def get_entries(filters):
|
||||
conditions, party_accounts = get_conditions(filters)
|
||||
entries = frappe.conn.sql("""select jv.name, jvd.account, jv.posting_date,
|
||||
entries = frappe.db.sql("""select jv.name, jvd.account, jv.posting_date,
|
||||
jvd.against_voucher, jvd.against_invoice, jvd.debit, jvd.credit,
|
||||
jv.cheque_no, jv.cheque_date, jv.remark
|
||||
from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
|
||||
@@ -86,10 +86,10 @@ def get_entries(filters):
|
||||
def get_invoice_posting_date_map(filters):
|
||||
invoice_posting_date_map = {}
|
||||
if filters.get("payment_type") == "Incoming":
|
||||
for t in frappe.conn.sql("""select name, posting_date from `tabSales Invoice`"""):
|
||||
for t in frappe.db.sql("""select name, posting_date from `tabSales Invoice`"""):
|
||||
invoice_posting_date_map[t[0]] = t[1]
|
||||
else:
|
||||
for t in frappe.conn.sql("""select name, posting_date from `tabPurchase Invoice`"""):
|
||||
for t in frappe.db.sql("""select name, posting_date from `tabPurchase Invoice`"""):
|
||||
invoice_posting_date_map[t[0]] = t[1]
|
||||
|
||||
return invoice_posting_date_map
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-12-02 17:06:37",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-12-02 17:06:39",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -10,6 +10,7 @@
|
||||
"add_total_row": 1,
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Journal Voucher",
|
||||
"report_name": "Payment Period Based On Invoice Date",
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
{
|
||||
"creation": "2013-06-13 18:46:55",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-06-13 18:46:55",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Purchase Invoice",
|
||||
"report_name": "Purchase Invoice Trends",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-28 15:54:16",
|
||||
"docstatus": 0,
|
||||
"modified": "2014-02-11 13:01:05",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -10,6 +10,7 @@
|
||||
"add_total_row": 1,
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n `tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order Item`.`project_name` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.base_amount as \"Amount:Currency:100\",\n\t`tabPurchase Order Item`.billed_amt as \"Billed Amount:Currency:100\", \n\t(`tabPurchase Order Item`.base_amount - ifnull(`tabPurchase Order Item`.billed_amt, 0)) as \"Amount to Bill:Currency:100\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status != \"Stopped\"\n\tand ifnull(`tabPurchase Order Item`.billed_amt, 0) < ifnull(`tabPurchase Order Item`.base_amount, 0)\norder by `tabPurchase Order`.transaction_date asc",
|
||||
"ref_doctype": "Purchase Invoice",
|
||||
|
||||
@@ -72,12 +72,12 @@ def get_columns(invoice_list):
|
||||
expense_accounts = tax_accounts = expense_columns = tax_columns = []
|
||||
|
||||
if invoice_list:
|
||||
expense_accounts = frappe.conn.sql_list("""select distinct expense_account
|
||||
expense_accounts = frappe.db.sql_list("""select distinct expense_account
|
||||
from `tabPurchase Invoice Item` where docstatus = 1 and ifnull(expense_account, '') != ''
|
||||
and parent in (%s) order by expense_account""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
|
||||
|
||||
tax_accounts = frappe.conn.sql_list("""select distinct account_head
|
||||
tax_accounts = frappe.db.sql_list("""select distinct account_head
|
||||
from `tabPurchase Taxes and Charges` where parenttype = 'Purchase Invoice'
|
||||
and docstatus = 1 and ifnull(account_head, '') != '' and category in ('Total', 'Valuation and Total')
|
||||
and parent in (%s) order by account_head""" %
|
||||
@@ -109,14 +109,14 @@ def get_conditions(filters):
|
||||
|
||||
def get_invoices(filters):
|
||||
conditions = get_conditions(filters)
|
||||
return frappe.conn.sql("""select name, posting_date, credit_to, supplier, supplier_name,
|
||||
return frappe.db.sql("""select name, posting_date, credit_to, supplier, supplier_name,
|
||||
bill_no, bill_date, remarks, net_total, grand_total, outstanding_amount
|
||||
from `tabPurchase Invoice` where docstatus = 1 %s
|
||||
order by posting_date desc, name desc""" % conditions, filters, as_dict=1)
|
||||
|
||||
|
||||
def get_invoice_expense_map(invoice_list):
|
||||
expense_details = frappe.conn.sql("""select parent, expense_account, sum(base_amount) as amount
|
||||
expense_details = frappe.db.sql("""select parent, expense_account, sum(base_amount) as amount
|
||||
from `tabPurchase Invoice Item` where parent in (%s) group by parent, expense_account""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||
|
||||
@@ -128,7 +128,7 @@ def get_invoice_expense_map(invoice_list):
|
||||
return invoice_expense_map
|
||||
|
||||
def get_invoice_tax_map(invoice_list, invoice_expense_map, expense_accounts):
|
||||
tax_details = frappe.conn.sql("""select parent, account_head, sum(tax_amount) as tax_amount
|
||||
tax_details = frappe.db.sql("""select parent, account_head, sum(tax_amount) as tax_amount
|
||||
from `tabPurchase Taxes and Charges` where parent in (%s) group by parent, account_head""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||
|
||||
@@ -146,7 +146,7 @@ def get_invoice_tax_map(invoice_list, invoice_expense_map, expense_accounts):
|
||||
return invoice_expense_map, invoice_tax_map
|
||||
|
||||
def get_invoice_po_pr_map(invoice_list):
|
||||
pi_items = frappe.conn.sql("""select parent, purchase_order, purchase_receipt,
|
||||
pi_items = frappe.db.sql("""select parent, purchase_order, purchase_receipt,
|
||||
project_name from `tabPurchase Invoice Item` where parent in (%s)
|
||||
and (ifnull(purchase_order, '') != '' or ifnull(purchase_receipt, '') != '')""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||
@@ -168,7 +168,7 @@ def get_invoice_po_pr_map(invoice_list):
|
||||
def get_account_details(invoice_list):
|
||||
account_map = {}
|
||||
accounts = list(set([inv.credit_to for inv in invoice_list]))
|
||||
for acc in frappe.conn.sql("""select name, parent_account from tabAccount
|
||||
for acc in frappe.db.sql("""select name, parent_account from tabAccount
|
||||
where name in (%s)""" % ", ".join(["%s"]*len(accounts)), tuple(accounts), as_dict=1):
|
||||
account_map[acc.name] = acc.parent_account
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-04-29 16:13:11",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-04-30 17:51:19",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -10,6 +10,7 @@
|
||||
"add_total_row": 1,
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Purchase Invoice",
|
||||
"report_name": "Purchase Register",
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
{
|
||||
"creation": "2013-07-30 18:35:10",
|
||||
"docstatus": 0,
|
||||
"modified": "2014-02-11 11:46:57",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"query": "select\n `tabPurchase Receipt`.`name` as \"Purchase Receipt:Link/Purchase Receipt:120\",\n `tabPurchase Receipt`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Receipt`.`posting_date` as \"Date:Date\",\n\t`tabPurchase Receipt Item`.`project_name` as \"Project\",\n\t`tabPurchase Receipt Item`.`item_code` as \"Item:Link/Item:120\",\n\t(`tabPurchase Receipt Item`.`qty` - ifnull((select sum(qty) from `tabPurchase Invoice Item` \n\t where `tabPurchase Invoice Item`.purchase_receipt = `tabPurchase Receipt`.name and\n\t `tabPurchase Invoice Item`.pr_detail = `tabPurchase Receipt Item`.name), 0))\n\t\tas \"Qty:Float:110\",\n\t(`tabPurchase Receipt Item`.`base_amount` - ifnull((select sum(base_amount) from `tabPurchase Invoice Item` \n where `tabPurchase Invoice Item`.purchase_receipt = `tabPurchase Receipt`.name and\n `tabPurchase Invoice Item`.pr_detail = `tabPurchase Receipt Item`.name), 0))\n\t\tas \"Amount:Currency:110\",\n\t`tabPurchase Receipt Item`.`item_name` as \"Item Name::150\",\n\t`tabPurchase Receipt Item`.`description` as \"Description::200\"\nfrom `tabPurchase Receipt`, `tabPurchase Receipt Item`\nwhere\n `tabPurchase Receipt`.docstatus = 1 and\n\t`tabPurchase Receipt`.`status` != \"Stopped\" and\n `tabPurchase Receipt`.name = `tabPurchase Receipt Item`.parent and\n (`tabPurchase Receipt Item`.qty > ifnull((select sum(qty) from `tabPurchase Invoice Item` \n where `tabPurchase Invoice Item`.purchase_receipt = `tabPurchase Receipt`.name and\n `tabPurchase Invoice Item`.pr_detail = `tabPurchase Receipt Item`.name), 0))\norder by `tabPurchase Receipt`.`name` desc",
|
||||
"ref_doctype": "Purchase Invoice",
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
{
|
||||
"creation": "2013-06-13 18:44:21",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-06-13 18:44:21",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Sales Invoice",
|
||||
"report_name": "Sales Invoice Trends",
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
{
|
||||
"creation": "2013-05-06 12:28:23",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-05-06 12:41:15",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"query": "SELECT\n sales_partner as \"Sales Partner:Link/Sales Partner:150\",\n\tsum(net_total) as \"Invoiced Amount (Exculsive Tax):Currency:210\",\n\tsum(total_commission) as \"Total Commission:Currency:150\",\n\tsum(total_commission)*100/sum(net_total) as \"Average Commission Rate:Currency:170\"\nFROM\n\t`tabSales Invoice`\nWHERE\n\tdocstatus = 1 and ifnull(net_total, 0) > 0 and ifnull(total_commission, 0) > 0\nGROUP BY\n\tsales_partner\nORDER BY\n\t\"Total Commission:Currency:120\"",
|
||||
"ref_doctype": "Sales Invoice",
|
||||
|
||||
@@ -72,12 +72,12 @@ def get_columns(invoice_list):
|
||||
income_accounts = tax_accounts = income_columns = tax_columns = []
|
||||
|
||||
if invoice_list:
|
||||
income_accounts = frappe.conn.sql_list("""select distinct income_account
|
||||
income_accounts = frappe.db.sql_list("""select distinct income_account
|
||||
from `tabSales Invoice Item` where docstatus = 1 and parent in (%s)
|
||||
order by income_account""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
|
||||
|
||||
tax_accounts = frappe.conn.sql_list("""select distinct account_head
|
||||
tax_accounts = frappe.db.sql_list("""select distinct account_head
|
||||
from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice'
|
||||
and docstatus = 1 and ifnull(tax_amount_after_discount_amount, 0) != 0
|
||||
and parent in (%s) order by account_head""" %
|
||||
@@ -107,14 +107,14 @@ def get_conditions(filters):
|
||||
|
||||
def get_invoices(filters):
|
||||
conditions = get_conditions(filters)
|
||||
return frappe.conn.sql("""select name, posting_date, debit_to, project_name, customer,
|
||||
return frappe.db.sql("""select name, posting_date, debit_to, project_name, customer,
|
||||
customer_name, remarks, net_total, grand_total, rounded_total, outstanding_amount
|
||||
from `tabSales Invoice`
|
||||
where docstatus = 1 %s order by posting_date desc, name desc""" %
|
||||
conditions, filters, as_dict=1)
|
||||
|
||||
def get_invoice_income_map(invoice_list):
|
||||
income_details = frappe.conn.sql("""select parent, income_account, sum(base_amount) as amount
|
||||
income_details = frappe.db.sql("""select parent, income_account, sum(base_amount) as amount
|
||||
from `tabSales Invoice Item` where parent in (%s) group by parent, income_account""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||
|
||||
@@ -126,7 +126,7 @@ def get_invoice_income_map(invoice_list):
|
||||
return invoice_income_map
|
||||
|
||||
def get_invoice_tax_map(invoice_list, invoice_income_map, income_accounts):
|
||||
tax_details = frappe.conn.sql("""select parent, account_head,
|
||||
tax_details = frappe.db.sql("""select parent, account_head,
|
||||
sum(tax_amount_after_discount_amount) as tax_amount
|
||||
from `tabSales Taxes and Charges` where parent in (%s) group by parent, account_head""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||
@@ -145,7 +145,7 @@ def get_invoice_tax_map(invoice_list, invoice_income_map, income_accounts):
|
||||
return invoice_income_map, invoice_tax_map
|
||||
|
||||
def get_invoice_so_dn_map(invoice_list):
|
||||
si_items = frappe.conn.sql("""select parent, sales_order, delivery_note
|
||||
si_items = frappe.db.sql("""select parent, sales_order, delivery_note
|
||||
from `tabSales Invoice Item` where parent in (%s)
|
||||
and (ifnull(sales_order, '') != '' or ifnull(delivery_note, '') != '')""" %
|
||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||
@@ -164,7 +164,7 @@ def get_invoice_so_dn_map(invoice_list):
|
||||
def get_customer_deatils(invoice_list):
|
||||
customer_map = {}
|
||||
customers = list(set([inv.customer for inv in invoice_list]))
|
||||
for cust in frappe.conn.sql("""select name, territory from `tabCustomer`
|
||||
for cust in frappe.db.sql("""select name, territory from `tabCustomer`
|
||||
where name in (%s)""" % ", ".join(["%s"]*len(customers)), tuple(customers), as_dict=1):
|
||||
customer_map[cust.name] = cust.territory
|
||||
|
||||
@@ -173,7 +173,7 @@ def get_customer_deatils(invoice_list):
|
||||
def get_account_details(invoice_list):
|
||||
account_map = {}
|
||||
accounts = list(set([inv.debit_to for inv in invoice_list]))
|
||||
for acc in frappe.conn.sql("""select name, parent_account from tabAccount
|
||||
for acc in frappe.db.sql("""select name, parent_account from tabAccount
|
||||
where name in (%s)""" % ", ".join(["%s"]*len(accounts)), tuple(accounts), as_dict=1):
|
||||
account_map[acc.name] = acc.parent_account
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-04-23 18:15:29",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-04-30 17:53:10",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -10,6 +10,7 @@
|
||||
"add_total_row": 1,
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Sales Invoice",
|
||||
"report_name": "Sales Register",
|
||||
|
||||
@@ -8,7 +8,7 @@ def execute(filters=None):
|
||||
account_map = get_account_map()
|
||||
columns = get_columns(account_map)
|
||||
data = []
|
||||
suppliers = frappe.conn.sql("select name from tabSupplier where docstatus < 2")
|
||||
suppliers = frappe.db.sql("select name from tabSupplier where docstatus < 2")
|
||||
for supplier in suppliers:
|
||||
row = [supplier[0]]
|
||||
for company in sorted(account_map):
|
||||
@@ -18,7 +18,7 @@ def execute(filters=None):
|
||||
return columns, data
|
||||
|
||||
def get_account_map():
|
||||
accounts = frappe.conn.sql("""select name, company, master_name
|
||||
accounts = frappe.db.sql("""select name, company, master_name
|
||||
from `tabAccount` where master_type = 'Supplier'
|
||||
and ifnull(master_name, '') != '' and docstatus < 2""", as_dict=1)
|
||||
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
{
|
||||
"creation": "2013-06-04 12:56:17",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-06-04 12:56:46",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Accounts",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Account",
|
||||
"report_name": "Supplier Account Head",
|
||||
|
||||
@@ -26,7 +26,7 @@ def get_fiscal_years(date=None, fiscal_year=None, label="Date", verbose=1):
|
||||
else:
|
||||
cond = "'%s' >= year_start_date and '%s' <= year_end_date" % \
|
||||
(date, date)
|
||||
fy = frappe.conn.sql("""select name, year_start_date, year_end_date
|
||||
fy = frappe.db.sql("""select name, year_start_date, year_end_date
|
||||
from `tabFiscal Year` where %s order by year_start_date desc""" % cond)
|
||||
|
||||
if not fy:
|
||||
@@ -73,7 +73,7 @@ def get_balance_on(account=None, date=None):
|
||||
# hence, assuming balance as 0.0
|
||||
return 0.0
|
||||
|
||||
acc = frappe.conn.get_value('Account', account, \
|
||||
acc = frappe.db.get_value('Account', account, \
|
||||
['lft', 'rgt', 'debit_or_credit', 'is_pl_account', 'group_or_ledger'], as_dict=1)
|
||||
|
||||
# for pl accounts, get balance within a fiscal year
|
||||
@@ -90,7 +90,7 @@ def get_balance_on(account=None, date=None):
|
||||
else:
|
||||
cond.append("""gle.account = "%s" """ % (account, ))
|
||||
|
||||
bal = frappe.conn.sql("""
|
||||
bal = frappe.db.sql("""
|
||||
SELECT sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||
FROM `tabGL Entry` gle
|
||||
WHERE %s""" % " and ".join(cond))[0][0]
|
||||
@@ -160,7 +160,7 @@ def check_if_jv_modified(args):
|
||||
check if amount is same
|
||||
check if jv is submitted
|
||||
"""
|
||||
ret = frappe.conn.sql("""
|
||||
ret = frappe.db.sql("""
|
||||
select t2.%(dr_or_cr)s from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2
|
||||
where t1.name = t2.parent and t2.account = '%(account)s'
|
||||
and ifnull(t2.against_voucher, '')=''
|
||||
@@ -176,14 +176,14 @@ def update_against_doc(d, jv_obj):
|
||||
Updates against document, if partial amount splits into rows
|
||||
"""
|
||||
|
||||
frappe.conn.sql("""
|
||||
frappe.db.sql("""
|
||||
update `tabJournal Voucher Detail` t1, `tabJournal Voucher` t2
|
||||
set t1.%(dr_or_cr)s = '%(allocated_amt)s',
|
||||
t1.%(against_fld)s = '%(against_voucher)s', t2.modified = now()
|
||||
where t1.name = '%(voucher_detail_no)s' and t1.parent = t2.name""" % d)
|
||||
|
||||
if d['allocated_amt'] < d['unadjusted_amt']:
|
||||
jvd = frappe.conn.sql("""select cost_center, balance, against_account, is_advance
|
||||
jvd = frappe.db.sql("""select cost_center, balance, against_account, is_advance
|
||||
from `tabJournal Voucher Detail` where name = %s""", d['voucher_detail_no'])
|
||||
# new entry with balance amount
|
||||
ch = addchild(jv_obj.doc, 'entries', 'Journal Voucher Detail')
|
||||
@@ -203,7 +203,7 @@ def get_account_list(doctype, txt, searchfield, start, page_len, filters):
|
||||
|
||||
conditions, filter_values = build_filter_conditions(filters)
|
||||
|
||||
return frappe.conn.sql("""select name, parent_account from `tabAccount`
|
||||
return frappe.db.sql("""select name, parent_account from `tabAccount`
|
||||
where docstatus < 2 %s and %s like %s order by name limit %s, %s""" %
|
||||
(conditions, searchfield, "%s", "%s", "%s"),
|
||||
tuple(filter_values + ["%%%s%%" % txt, start, page_len]))
|
||||
@@ -214,22 +214,22 @@ def get_cost_center_list(doctype, txt, searchfield, start, page_len, filters):
|
||||
|
||||
conditions, filter_values = build_filter_conditions(filters)
|
||||
|
||||
return frappe.conn.sql("""select name, parent_cost_center from `tabCost Center`
|
||||
return frappe.db.sql("""select name, parent_cost_center from `tabCost Center`
|
||||
where docstatus < 2 %s and %s like %s order by name limit %s, %s""" %
|
||||
(conditions, searchfield, "%s", "%s", "%s"),
|
||||
tuple(filter_values + ["%%%s%%" % txt, start, page_len]))
|
||||
|
||||
def remove_against_link_from_jv(ref_type, ref_no, against_field):
|
||||
linked_jv = frappe.conn.sql_list("""select parent from `tabJournal Voucher Detail`
|
||||
linked_jv = frappe.db.sql_list("""select parent from `tabJournal Voucher Detail`
|
||||
where `%s`=%s and docstatus < 2""" % (against_field, "%s"), (ref_no))
|
||||
|
||||
if linked_jv:
|
||||
frappe.conn.sql("""update `tabJournal Voucher Detail` set `%s`=null,
|
||||
frappe.db.sql("""update `tabJournal Voucher Detail` set `%s`=null,
|
||||
modified=%s, modified_by=%s
|
||||
where `%s`=%s and docstatus < 2""" % (against_field, "%s", "%s", against_field, "%s"),
|
||||
(now(), frappe.session.user, ref_no))
|
||||
|
||||
frappe.conn.sql("""update `tabGL Entry`
|
||||
frappe.db.sql("""update `tabGL Entry`
|
||||
set against_voucher_type=null, against_voucher=null,
|
||||
modified=%s, modified_by=%s
|
||||
where against_voucher_type=%s and against_voucher=%s
|
||||
@@ -243,7 +243,7 @@ def remove_against_link_from_jv(ref_type, ref_no, against_field):
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_company_default(company, fieldname):
|
||||
value = frappe.conn.get_value("Company", company, fieldname)
|
||||
value = frappe.db.get_value("Company", company, fieldname)
|
||||
|
||||
if not value:
|
||||
throw(_("Please mention default value for '") +
|
||||
@@ -253,7 +253,7 @@ def get_company_default(company, fieldname):
|
||||
return value
|
||||
|
||||
def fix_total_debit_credit():
|
||||
vouchers = frappe.conn.sql("""select voucher_type, voucher_no,
|
||||
vouchers = frappe.db.sql("""select voucher_type, voucher_no,
|
||||
sum(debit) - sum(credit) as diff
|
||||
from `tabGL Entry`
|
||||
group by voucher_type, voucher_no
|
||||
@@ -263,7 +263,7 @@ def fix_total_debit_credit():
|
||||
if abs(d.diff) > 0:
|
||||
dr_or_cr = d.voucher_type == "Sales Invoice" and "credit" or "debit"
|
||||
|
||||
frappe.conn.sql("""update `tabGL Entry` set %s = %s + %s
|
||||
frappe.db.sql("""update `tabGL Entry` set %s = %s + %s
|
||||
where voucher_type = %s and voucher_no = %s and %s > 0 limit 1""" %
|
||||
(dr_or_cr, dr_or_cr, '%s', '%s', '%s', dr_or_cr),
|
||||
(d.diff, d.voucher_type, d.voucher_no))
|
||||
@@ -275,7 +275,7 @@ def get_stock_and_account_difference(account_list=None, posting_date=None):
|
||||
|
||||
difference = {}
|
||||
|
||||
account_warehouse = dict(frappe.conn.sql("""select name, master_name from tabAccount
|
||||
account_warehouse = dict(frappe.db.sql("""select name, master_name from tabAccount
|
||||
where account_type = 'Warehouse' and ifnull(master_name, '') != ''
|
||||
and name in (%s)""" % ', '.join(['%s']*len(account_list)), account_list))
|
||||
|
||||
@@ -289,16 +289,16 @@ def get_stock_and_account_difference(account_list=None, posting_date=None):
|
||||
|
||||
def validate_expense_against_budget(args):
|
||||
args = frappe._dict(args)
|
||||
if frappe.conn.get_value("Account", {"name": args.account, "is_pl_account": "Yes",
|
||||
if frappe.db.get_value("Account", {"name": args.account, "is_pl_account": "Yes",
|
||||
"debit_or_credit": "Debit"}):
|
||||
budget = frappe.conn.sql("""
|
||||
budget = frappe.db.sql("""
|
||||
select bd.budget_allocated, cc.distribution_id
|
||||
from `tabCost Center` cc, `tabBudget Detail` bd
|
||||
where cc.name=bd.parent and cc.name=%s and account=%s and bd.fiscal_year=%s
|
||||
""", (args.cost_center, args.account, args.fiscal_year), as_dict=True)
|
||||
|
||||
if budget and budget[0].budget_allocated:
|
||||
yearly_action, monthly_action = frappe.conn.get_value("Company", args.company,
|
||||
yearly_action, monthly_action = frappe.db.get_value("Company", args.company,
|
||||
["yearly_bgt_flag", "monthly_bgt_flag"])
|
||||
action_for = action = ""
|
||||
|
||||
@@ -306,7 +306,7 @@ def validate_expense_against_budget(args):
|
||||
budget_amount = get_allocated_budget(budget[0].distribution_id,
|
||||
args.posting_date, args.fiscal_year, budget[0].budget_allocated)
|
||||
|
||||
args["month_end_date"] = frappe.conn.sql("select LAST_DAY(%s)",
|
||||
args["month_end_date"] = frappe.db.sql("select LAST_DAY(%s)",
|
||||
args.posting_date)[0][0]
|
||||
action_for, action = "Monthly", monthly_action
|
||||
|
||||
@@ -326,12 +326,12 @@ def validate_expense_against_budget(args):
|
||||
def get_allocated_budget(distribution_id, posting_date, fiscal_year, yearly_budget):
|
||||
if distribution_id:
|
||||
distribution = {}
|
||||
for d in frappe.conn.sql("""select bdd.month, bdd.percentage_allocation
|
||||
for d in frappe.db.sql("""select bdd.month, bdd.percentage_allocation
|
||||
from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd
|
||||
where bdd.parent=bd.name and bd.fiscal_year=%s""", fiscal_year, as_dict=1):
|
||||
distribution.setdefault(d.month, d.percentage_allocation)
|
||||
|
||||
dt = frappe.conn.get_value("Fiscal Year", fiscal_year, "year_start_date")
|
||||
dt = frappe.db.get_value("Fiscal Year", fiscal_year, "year_start_date")
|
||||
budget_percentage = 0.0
|
||||
|
||||
while(dt <= getdate(posting_date)):
|
||||
@@ -348,7 +348,7 @@ def get_actual_expense(args):
|
||||
args["condition"] = " and posting_date<='%s'" % args.month_end_date \
|
||||
if args.get("month_end_date") else ""
|
||||
|
||||
return frappe.conn.sql("""
|
||||
return frappe.db.sql("""
|
||||
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||
from `tabGL Entry`
|
||||
where account='%(account)s' and cost_center='%(cost_center)s'
|
||||
@@ -367,7 +367,7 @@ def rename_account_for(dt, olddn, newdn, merge, company):
|
||||
new_account = frappe.rename_doc("Account", old_account,
|
||||
existing_new_account or newdn, merge=True if existing_new_account else False)
|
||||
|
||||
frappe.conn.set_value("Account", new_account or old_account, "master_name", newdn)
|
||||
frappe.db.set_value("Account", new_account or old_account, "master_name", newdn)
|
||||
|
||||
def add_abbr_if_missing(dn, company):
|
||||
from erpnext.setup.doctype.company.company import get_name_with_abbr
|
||||
@@ -379,14 +379,14 @@ def get_account_for(account_for_doctype, account_for):
|
||||
elif account_for_doctype == "Warehouse":
|
||||
account_for_field = "account_type"
|
||||
|
||||
return frappe.conn.get_value("Account", {account_for_field: account_for_doctype,
|
||||
return frappe.db.get_value("Account", {account_for_field: account_for_doctype,
|
||||
"master_name": account_for})
|
||||
|
||||
def get_currency_precision(currency=None):
|
||||
if not currency:
|
||||
currency = frappe.conn.get_value("Company",
|
||||
frappe.conn.get_default("company"), "default_currency")
|
||||
currency_format = frappe.conn.get_value("Currency", currency, "number_format")
|
||||
currency = frappe.db.get_value("Company",
|
||||
frappe.db.get_default("company"), "default_currency")
|
||||
currency_format = frappe.db.get_value("Currency", currency, "number_format")
|
||||
|
||||
from frappe.utils import get_number_format_info
|
||||
return get_number_format_info(currency_format)[2]
|
||||
|
||||
@@ -12,7 +12,7 @@ class DocType:
|
||||
|
||||
def validate(self):
|
||||
for key in ["supplier_type", "supp_master_name", "maintain_same_rate", "buying_price_list"]:
|
||||
frappe.conn.set_default(key, self.doc.fields.get(key, ""))
|
||||
frappe.db.set_default(key, self.doc.fields.get(key, ""))
|
||||
|
||||
from erpnext.setup.doctype.naming_series.naming_series import set_by_naming_series
|
||||
set_by_naming_series("Supplier", "supplier_name",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-06-25 11:04:03",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-12-20 19:22:59",
|
||||
"modified": "2014-02-19 19:02:00",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -42,6 +42,7 @@
|
||||
"name": "Buying Settings"
|
||||
},
|
||||
{
|
||||
"default": "Supplier Name",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "supp_master_name",
|
||||
"fieldtype": "Select",
|
||||
|
||||
@@ -42,7 +42,7 @@ class DocType(BuyingController):
|
||||
|
||||
# update last purchsae rate
|
||||
if last_purchase_rate:
|
||||
frappe.conn.sql("""update `tabItem` set last_purchase_rate = %s where name = %s""",
|
||||
frappe.db.sql("""update `tabItem` set last_purchase_rate = %s where name = %s""",
|
||||
(flt(last_purchase_rate), d.item_code))
|
||||
|
||||
def get_last_purchase_rate(self, obj):
|
||||
@@ -64,7 +64,7 @@ class DocType(BuyingController):
|
||||
# if no last purchase found, reset all values to 0
|
||||
d.base_price_list_rate = d.base_rate = d.price_list_rate = d.rate = d.discount_percentage = 0
|
||||
|
||||
item_last_purchase_rate = frappe.conn.get_value("Item",
|
||||
item_last_purchase_rate = frappe.db.get_value("Item",
|
||||
d.item_code, "last_purchase_rate")
|
||||
if item_last_purchase_rate:
|
||||
d.base_price_list_rate = d.base_rate = d.price_list_rate \
|
||||
@@ -78,7 +78,7 @@ class DocType(BuyingController):
|
||||
frappe.throw("Please enter valid qty for item %s" % cstr(d.item_code))
|
||||
|
||||
# udpate with latest quantities
|
||||
bin = frappe.conn.sql("""select projected_qty from `tabBin` where
|
||||
bin = frappe.db.sql("""select projected_qty from `tabBin` where
|
||||
item_code = %s and warehouse = %s""", (d.item_code, d.warehouse), as_dict=1)
|
||||
|
||||
f_lst ={'projected_qty': bin and flt(bin[0]['projected_qty']) or 0, 'ordered_qty': 0, 'received_qty' : 0}
|
||||
@@ -88,7 +88,7 @@ class DocType(BuyingController):
|
||||
if d.fields.has_key(x):
|
||||
d.fields[x] = f_lst[x]
|
||||
|
||||
item = frappe.conn.sql("""select is_stock_item, is_purchase_item,
|
||||
item = frappe.db.sql("""select is_stock_item, is_purchase_item,
|
||||
is_sub_contracted_item, end_of_life from `tabItem` where name=%s""", d.item_code)
|
||||
if not item:
|
||||
frappe.throw("Item %s does not exist in Item Master." % cstr(d.item_code))
|
||||
@@ -113,7 +113,7 @@ class DocType(BuyingController):
|
||||
# if is not stock item
|
||||
f = [d.schedule_date, d.item_code, d.description]
|
||||
|
||||
ch = frappe.conn.sql("""select is_stock_item from `tabItem` where name = %s""", d.item_code)
|
||||
ch = frappe.db.sql("""select is_stock_item from `tabItem` where name = %s""", d.item_code)
|
||||
|
||||
if ch and ch[0][0] == 'Yes':
|
||||
# check for same items
|
||||
@@ -139,21 +139,21 @@ class DocType(BuyingController):
|
||||
# but if in Material Request uom KG it can change in PO
|
||||
|
||||
get_qty = (transaction == 'Material Request - Purchase Order') and 'qty * conversion_factor' or 'qty'
|
||||
qty = frappe.conn.sql("""select sum(%s) from `tab%s` where %s = %s and
|
||||
qty = frappe.db.sql("""select sum(%s) from `tab%s` where %s = %s and
|
||||
docstatus = 1 and parent != %s""" % (get_qty, curr_doctype, ref_tab_fname, '%s', '%s'),
|
||||
(ref_tab_dn, curr_parent_name))
|
||||
qty = qty and flt(qty[0][0]) or 0
|
||||
|
||||
# get total qty of ref doctype
|
||||
#--------------------
|
||||
max_qty = frappe.conn.sql("""select qty from `tab%s` where name = %s
|
||||
max_qty = frappe.db.sql("""select qty from `tab%s` where name = %s
|
||||
and docstatus = 1""" % (ref_doc_tname, '%s'), ref_tab_dn)
|
||||
max_qty = max_qty and flt(max_qty[0][0]) or 0
|
||||
|
||||
return cstr(qty)+'~~~'+cstr(max_qty)
|
||||
|
||||
def check_for_stopped_status(self, doctype, docname):
|
||||
stopped = frappe.conn.sql("""select name from `tab%s` where name = %s and
|
||||
stopped = frappe.db.sql("""select name from `tab%s` where name = %s and
|
||||
status = 'Stopped'""" % (doctype, '%s'), docname)
|
||||
if stopped:
|
||||
frappe.throw("One cannot do any transaction against %s : %s, it's status is 'Stopped'" %
|
||||
@@ -161,7 +161,7 @@ class DocType(BuyingController):
|
||||
|
||||
def check_docstatus(self, check, doctype, docname, detail_doctype = ''):
|
||||
if check == 'Next':
|
||||
submitted = frappe.conn.sql("""select t1.name from `tab%s` t1,`tab%s` t2
|
||||
submitted = frappe.db.sql("""select t1.name from `tab%s` t1,`tab%s` t2
|
||||
where t1.name = t2.parent and t2.prevdoc_docname = %s and t1.docstatus = 1"""
|
||||
% (doctype, detail_doctype, '%s'), docname)
|
||||
if submitted:
|
||||
@@ -169,7 +169,7 @@ class DocType(BuyingController):
|
||||
+ _("has already been submitted."))
|
||||
|
||||
if check == 'Previous':
|
||||
submitted = frappe.conn.sql("""select name from `tab%s`
|
||||
submitted = frappe.db.sql("""select name from `tab%s`
|
||||
where docstatus = 1 and name = %s""" % (doctype, '%s'), docname)
|
||||
if not submitted:
|
||||
frappe.throw(cstr(doctype) + ": " + cstr(submitted[0][0]) + _("not submitted"))
|
||||
|
||||
@@ -67,7 +67,7 @@ class DocType(BuyingController):
|
||||
def get_schedule_dates(self):
|
||||
for d in getlist(self.doclist, 'po_details'):
|
||||
if d.prevdoc_detail_docname and not d.schedule_date:
|
||||
d.schedule_date = frappe.conn.get_value("Material Request Item",
|
||||
d.schedule_date = frappe.db.get_value("Material Request Item",
|
||||
d.prevdoc_detail_docname, "schedule_date")
|
||||
|
||||
def get_last_purchase_rate(self):
|
||||
@@ -87,7 +87,7 @@ class DocType(BuyingController):
|
||||
pc_obj = get_obj('Purchase Common')
|
||||
for d in getlist(self.doclist, 'po_details'):
|
||||
#1. Check if is_stock_item == 'Yes'
|
||||
if frappe.conn.get_value("Item", d.item_code, "is_stock_item") == "Yes":
|
||||
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == "Yes":
|
||||
# this happens when item is changed from non-stock to stock item
|
||||
if not d.warehouse:
|
||||
continue
|
||||
@@ -127,8 +127,8 @@ class DocType(BuyingController):
|
||||
update_bin(args)
|
||||
|
||||
def check_modified_date(self):
|
||||
mod_db = frappe.conn.sql("select modified from `tabPurchase Order` where name = '%s'" % self.doc.name)
|
||||
date_diff = frappe.conn.sql("select TIMEDIFF('%s', '%s')" % ( mod_db[0][0],cstr(self.doc.modified)))
|
||||
mod_db = frappe.db.sql("select modified from `tabPurchase Order` where name = '%s'" % self.doc.name)
|
||||
date_diff = frappe.db.sql("select TIMEDIFF('%s', '%s')" % ( mod_db[0][0],cstr(self.doc.modified)))
|
||||
|
||||
if date_diff and date_diff[0][0]:
|
||||
msgprint(cstr(self.doc.doctype) +" => "+ cstr(self.doc.name) +" has been modified. Please Refresh. ")
|
||||
@@ -137,7 +137,7 @@ class DocType(BuyingController):
|
||||
def update_status(self, status):
|
||||
self.check_modified_date()
|
||||
# step 1:=> Set Status
|
||||
frappe.conn.set(self.doc,'status',cstr(status))
|
||||
frappe.db.set(self.doc,'status',cstr(status))
|
||||
|
||||
# step 2:=> Update Bin
|
||||
self.update_bin(is_submit = (status == 'Submitted') and 1 or 0, is_stopped = 1)
|
||||
@@ -156,7 +156,7 @@ class DocType(BuyingController):
|
||||
|
||||
purchase_controller.update_last_purchase_rate(self, is_submit = 1)
|
||||
|
||||
frappe.conn.set(self.doc,'status','Submitted')
|
||||
frappe.db.set(self.doc,'status','Submitted')
|
||||
|
||||
def on_cancel(self):
|
||||
pc_obj = get_obj(dt = 'Purchase Common')
|
||||
@@ -166,12 +166,12 @@ class DocType(BuyingController):
|
||||
pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Receipt', docname = self.doc.name, detail_doctype = 'Purchase Receipt Item')
|
||||
|
||||
# Check if Purchase Invoice has been submitted against current Purchase Order
|
||||
submitted = frappe.conn.sql("select t1.name from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 where t1.name = t2.parent and t2.purchase_order = '%s' and t1.docstatus = 1" % self.doc.name)
|
||||
submitted = frappe.db.sql("select t1.name from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2 where t1.name = t2.parent and t2.purchase_order = '%s' and t1.docstatus = 1" % self.doc.name)
|
||||
if submitted:
|
||||
msgprint("Purchase Invoice : " + cstr(submitted[0][0]) + " has already been submitted !")
|
||||
raise Exception
|
||||
|
||||
frappe.conn.set(self.doc,'status','Cancelled')
|
||||
frappe.db.set(self.doc,'status','Cancelled')
|
||||
self.update_prevdoc_status()
|
||||
self.update_bin( is_submit = 0, is_stopped = 0)
|
||||
pc_obj.update_last_purchase_rate(self, is_submit = 0)
|
||||
|
||||
@@ -25,12 +25,12 @@ class TestPurchaseOrder(unittest.TestCase):
|
||||
self.assertEquals(pr[0]["doctype"], "Purchase Receipt")
|
||||
self.assertEquals(len(pr), len(test_records[0]))
|
||||
|
||||
pr[0].naming_series = "_T-Purchase Receipt-"
|
||||
pr[0]["naming_series"] = "_T-Purchase Receipt-"
|
||||
pr_bean = frappe.bean(pr)
|
||||
pr_bean.insert()
|
||||
|
||||
def test_ordered_qty(self):
|
||||
frappe.conn.sql("delete from tabBin")
|
||||
frappe.db.sql("delete from tabBin")
|
||||
|
||||
from erpnext.buying.doctype.purchase_order.purchase_order import make_purchase_receipt
|
||||
|
||||
@@ -44,7 +44,7 @@ class TestPurchaseOrder(unittest.TestCase):
|
||||
po.doclist[1].item_code = "_Test Item"
|
||||
po.submit()
|
||||
|
||||
self.assertEquals(frappe.conn.get_value("Bin", {"item_code": "_Test Item",
|
||||
self.assertEquals(frappe.db.get_value("Bin", {"item_code": "_Test Item",
|
||||
"warehouse": "_Test Warehouse - _TC"}, "ordered_qty"), 10)
|
||||
|
||||
pr = make_purchase_receipt(po.doc.name)
|
||||
@@ -52,26 +52,26 @@ class TestPurchaseOrder(unittest.TestCase):
|
||||
self.assertEquals(pr[0]["doctype"], "Purchase Receipt")
|
||||
self.assertEquals(len(pr), len(test_records[0]))
|
||||
pr[0]["posting_date"] = "2013-05-12"
|
||||
pr[0].naming_series = "_T-Purchase Receipt-"
|
||||
pr[1].qty = 4.0
|
||||
pr[0]["naming_series"] = "_T-Purchase Receipt-"
|
||||
pr[1]["qty"] = 4.0
|
||||
pr_bean = frappe.bean(pr)
|
||||
pr_bean.insert()
|
||||
pr_bean.submit()
|
||||
|
||||
self.assertEquals(flt(frappe.conn.get_value("Bin", {"item_code": "_Test Item",
|
||||
self.assertEquals(flt(frappe.db.get_value("Bin", {"item_code": "_Test Item",
|
||||
"warehouse": "_Test Warehouse - _TC"}, "ordered_qty")), 6.0)
|
||||
|
||||
frappe.conn.set_value('Item', '_Test Item', 'tolerance', 50)
|
||||
frappe.db.set_value('Item', '_Test Item', 'tolerance', 50)
|
||||
|
||||
pr1 = make_purchase_receipt(po.doc.name)
|
||||
pr1[0].naming_series = "_T-Purchase Receipt-"
|
||||
pr1[0]["naming_series"] = "_T-Purchase Receipt-"
|
||||
pr1[0]["posting_date"] = "2013-05-12"
|
||||
pr1[1].qty = 8
|
||||
pr1[1]["qty"] = 8
|
||||
pr1_bean = frappe.bean(pr1)
|
||||
pr1_bean.insert()
|
||||
pr1_bean.submit()
|
||||
|
||||
self.assertEquals(flt(frappe.conn.get_value("Bin", {"item_code": "_Test Item",
|
||||
self.assertEquals(flt(frappe.db.get_value("Bin", {"item_code": "_Test Item",
|
||||
"warehouse": "_Test Warehouse - _TC"}, "ordered_qty")), 0.0)
|
||||
|
||||
def test_make_purchase_invoice(self):
|
||||
@@ -89,7 +89,7 @@ class TestPurchaseOrder(unittest.TestCase):
|
||||
self.assertEquals(pi[0]["doctype"], "Purchase Invoice")
|
||||
self.assertEquals(len(pi), len(test_records[0]))
|
||||
pi[0]["posting_date"] = "2013-05-12"
|
||||
pi[0].bill_no = "NA"
|
||||
pi[0]["bill_no"] = "NA"
|
||||
frappe.bean(pi).insert()
|
||||
|
||||
def test_subcontracting(self):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-24 19:29:06",
|
||||
"docstatus": 0,
|
||||
"modified": "2014-02-10 17:29:01",
|
||||
"modified": "2014-02-28 11:26:25",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -272,6 +272,22 @@
|
||||
"read_only": 1,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "pricing_rule_for_price",
|
||||
"fieldtype": "Link",
|
||||
"label": "Pricing Rule For Price",
|
||||
"options": "Pricing Rule",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "pricing_rule_for_discount",
|
||||
"fieldtype": "Link",
|
||||
"label": "Pricing Rule For Discount",
|
||||
"options": "Pricing Rule",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "warehouse_and_reference",
|
||||
|
||||
@@ -13,7 +13,7 @@ class DocType:
|
||||
|
||||
def get_item_specification_details(self):
|
||||
self.doclist = self.doc.clear_table(self.doclist, 'qa_specification_details')
|
||||
specification = frappe.conn.sql("select specification, value from `tabItem Quality Inspection Parameter` \
|
||||
specification = frappe.db.sql("select specification, value from `tabItem Quality Inspection Parameter` \
|
||||
where parent = '%s' order by idx" % (self.doc.item_code))
|
||||
for d in specification:
|
||||
child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', self.doclist)
|
||||
@@ -23,14 +23,14 @@ class DocType:
|
||||
|
||||
def on_submit(self):
|
||||
if self.doc.purchase_receipt_no:
|
||||
frappe.conn.sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '%s', t2.modified = '%s' \
|
||||
frappe.db.sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '%s', t2.modified = '%s' \
|
||||
where t1.parent = '%s' and t1.item_code = '%s' and t1.parent = t2.name" \
|
||||
% (self.doc.name, self.doc.modified, self.doc.purchase_receipt_no, self.doc.item_code))
|
||||
|
||||
|
||||
def on_cancel(self):
|
||||
if self.doc.purchase_receipt_no:
|
||||
frappe.conn.sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '', t2.modified = '%s' \
|
||||
frappe.db.sql("update `tabPurchase Receipt Item` t1, `tabPurchase Receipt` t2 set t1.qa_no = '', t2.modified = '%s' \
|
||||
where t1.parent = '%s' and t1.item_code = '%s' and t1.parent = t2.name" \
|
||||
% (self.doc.modified, self.doc.purchase_receipt_no, self.doc.item_code))
|
||||
|
||||
@@ -40,10 +40,10 @@ def item_query(doctype, txt, searchfield, start, page_len, filters):
|
||||
from frappe.widgets.reportview import get_match_cond
|
||||
filters.update({
|
||||
"txt": txt,
|
||||
"mcond": get_match_cond(filters["from"], searchfield),
|
||||
"mcond": get_match_cond(filters["from"]),
|
||||
"start": start,
|
||||
"page_len": page_len
|
||||
})
|
||||
return frappe.conn.sql("""select item_code from `tab%(from)s`
|
||||
return frappe.db.sql("""select item_code from `tab%(from)s`
|
||||
where parent='%(parent)s' and docstatus < 2 and item_code like '%%%(txt)s%%' %(mcond)s
|
||||
order by item_code limit %(start)s, %(page_len)s""" % filters)
|
||||
@@ -21,22 +21,22 @@ class DocType(TransactionBase):
|
||||
supp_master_name = frappe.defaults.get_global_default('supp_master_name')
|
||||
|
||||
if supp_master_name == 'Supplier Name':
|
||||
if frappe.conn.exists("Customer", self.doc.supplier_name):
|
||||
if frappe.db.exists("Customer", self.doc.supplier_name):
|
||||
frappe.msgprint(_("A Customer exists with same name"), raise_exception=1)
|
||||
self.doc.name = self.doc.supplier_name
|
||||
else:
|
||||
self.doc.name = make_autoname(self.doc.naming_series + '.#####')
|
||||
|
||||
def update_address(self):
|
||||
frappe.conn.sql("""update `tabAddress` set supplier_name=%s, modified=NOW()
|
||||
frappe.db.sql("""update `tabAddress` set supplier_name=%s, modified=NOW()
|
||||
where supplier=%s""", (self.doc.supplier_name, self.doc.name))
|
||||
|
||||
def update_contact(self):
|
||||
frappe.conn.sql("""update `tabContact` set supplier_name=%s, modified=NOW()
|
||||
frappe.db.sql("""update `tabContact` set supplier_name=%s, modified=NOW()
|
||||
where supplier=%s""", (self.doc.supplier_name, self.doc.name))
|
||||
|
||||
def update_credit_days_limit(self):
|
||||
frappe.conn.sql("""update tabAccount set credit_days = %s where name = %s""",
|
||||
frappe.db.sql("""update tabAccount set credit_days = %s where name = %s""",
|
||||
(cint(self.doc.credit_days), self.doc.name + " - " + self.get_company_abbr()))
|
||||
|
||||
def on_update(self):
|
||||
@@ -53,7 +53,7 @@ class DocType(TransactionBase):
|
||||
self.update_credit_days_limit()
|
||||
|
||||
def get_company_abbr(self):
|
||||
return frappe.conn.sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0]
|
||||
return frappe.db.sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0]
|
||||
|
||||
def validate(self):
|
||||
#validation for Naming Series mandatory field...
|
||||
@@ -63,24 +63,24 @@ class DocType(TransactionBase):
|
||||
|
||||
def get_contacts(self,nm):
|
||||
if nm:
|
||||
contact_details =frappe.conn.convert_to_lists(frappe.conn.sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where supplier = '%s'"%nm))
|
||||
contact_details =frappe.db.convert_to_lists(frappe.db.sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where supplier = '%s'"%nm))
|
||||
|
||||
return contact_details
|
||||
else:
|
||||
return ''
|
||||
|
||||
def delete_supplier_address(self):
|
||||
for rec in frappe.conn.sql("select * from `tabAddress` where supplier=%s", (self.doc.name,), as_dict=1):
|
||||
frappe.conn.sql("delete from `tabAddress` where name=%s",(rec['name']))
|
||||
for rec in frappe.db.sql("select * from `tabAddress` where supplier=%s", (self.doc.name,), as_dict=1):
|
||||
frappe.db.sql("delete from `tabAddress` where name=%s",(rec['name']))
|
||||
|
||||
def delete_supplier_contact(self):
|
||||
for contact in frappe.conn.sql_list("""select name from `tabContact`
|
||||
for contact in frappe.db.sql_list("""select name from `tabContact`
|
||||
where supplier=%s""", self.doc.name):
|
||||
frappe.delete_doc("Contact", contact)
|
||||
|
||||
def delete_supplier_account(self):
|
||||
"""delete supplier's ledger if exist and check balance before deletion"""
|
||||
acc = frappe.conn.sql("select name from `tabAccount` where master_type = 'Supplier' \
|
||||
acc = frappe.db.sql("select name from `tabAccount` where master_type = 'Supplier' \
|
||||
and master_name = %s and docstatus < 2", self.doc.name)
|
||||
if acc:
|
||||
frappe.delete_doc('Account', acc[0][0])
|
||||
@@ -97,13 +97,13 @@ class DocType(TransactionBase):
|
||||
def after_rename(self, olddn, newdn, merge=False):
|
||||
set_field = ''
|
||||
if frappe.defaults.get_global_default('supp_master_name') == 'Supplier Name':
|
||||
frappe.conn.set(self.doc, "supplier_name", newdn)
|
||||
frappe.db.set(self.doc, "supplier_name", newdn)
|
||||
self.update_contact()
|
||||
set_field = ", supplier_name=%(newdn)s"
|
||||
self.update_supplier_address(newdn, set_field)
|
||||
|
||||
def update_supplier_address(self, newdn, set_field):
|
||||
frappe.conn.sql("""update `tabAddress` set address_title=%(newdn)s
|
||||
frappe.db.sql("""update `tabAddress` set address_title=%(newdn)s
|
||||
{set_field} where supplier=%(newdn)s"""\
|
||||
.format(set_field=set_field), ({"newdn": newdn}))
|
||||
|
||||
@@ -114,14 +114,14 @@ def get_dashboard_info(supplier):
|
||||
|
||||
out = {}
|
||||
for doctype in ["Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"]:
|
||||
out[doctype] = frappe.conn.get_value(doctype,
|
||||
out[doctype] = frappe.db.get_value(doctype,
|
||||
{"supplier": supplier, "docstatus": ["!=", 2] }, "count(*)")
|
||||
|
||||
billing = frappe.conn.sql("""select sum(grand_total), sum(outstanding_amount)
|
||||
billing = frappe.db.sql("""select sum(grand_total), sum(outstanding_amount)
|
||||
from `tabPurchase Invoice`
|
||||
where supplier=%s
|
||||
and docstatus = 1
|
||||
and fiscal_year = %s""", (supplier, frappe.conn.get_default("fiscal_year")))
|
||||
and fiscal_year = %s""", (supplier, frappe.db.get_default("fiscal_year")))
|
||||
|
||||
out["total_billing"] = billing[0][0]
|
||||
out["total_unpaid"] = billing[0][1]
|
||||
|
||||
@@ -26,10 +26,10 @@ class DocType(BuyingController):
|
||||
self.validate_uom_is_integer("uom", "qty")
|
||||
|
||||
def on_submit(self):
|
||||
frappe.conn.set(self.doc, "status", "Submitted")
|
||||
frappe.db.set(self.doc, "status", "Submitted")
|
||||
|
||||
def on_cancel(self):
|
||||
frappe.conn.set(self.doc, "status", "Cancelled")
|
||||
frappe.db.set(self.doc, "status", "Cancelled")
|
||||
|
||||
def on_trash(self):
|
||||
pass
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-22 12:43:10",
|
||||
"docstatus": 0,
|
||||
"modified": "2014-02-10 17:28:54",
|
||||
"modified": "2014-02-28 11:25:38",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -215,6 +215,22 @@
|
||||
"read_only": 1,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "pricing_rule_for_price",
|
||||
"fieldtype": "Link",
|
||||
"label": "Pricing Rule For Price",
|
||||
"options": "Pricing Rule",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "pricing_rule_for_discount",
|
||||
"fieldtype": "Link",
|
||||
"label": "Pricing Rule For Discount",
|
||||
"options": "Pricing Rule",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "warehouse_and_reference",
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
||||
@@ -1,169 +0,0 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt"
|
||||
|
||||
frappe.module_page["Buying"] = [
|
||||
{
|
||||
title: frappe._("Documents"),
|
||||
top: true,
|
||||
icon: "icon-copy",
|
||||
items: [
|
||||
{
|
||||
label: frappe._("Supplier"),
|
||||
description: frappe._("Supplier database."),
|
||||
doctype:"Supplier"
|
||||
},
|
||||
{
|
||||
label: frappe._("Material Request"),
|
||||
description: frappe._("Request for purchase."),
|
||||
doctype:"Material Request"
|
||||
},
|
||||
{
|
||||
label: frappe._("Supplier Quotation"),
|
||||
description: frappe._("Quotations received from Suppliers."),
|
||||
doctype:"Supplier Quotation"
|
||||
},
|
||||
{
|
||||
label: frappe._("Purchase Order"),
|
||||
description: frappe._("Purchase Orders given to Suppliers."),
|
||||
doctype:"Purchase Order"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: frappe._("Masters"),
|
||||
icon: "icon-book",
|
||||
items: [
|
||||
{
|
||||
label: frappe._("Contact"),
|
||||
description: frappe._("All Contacts."),
|
||||
doctype:"Contact"
|
||||
},
|
||||
{
|
||||
label: frappe._("Address"),
|
||||
description: frappe._("All Addresses."),
|
||||
doctype:"Address"
|
||||
},
|
||||
{
|
||||
label: frappe._("Item"),
|
||||
description: frappe._("All Products or Services."),
|
||||
doctype:"Item"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: frappe._("Setup"),
|
||||
icon: "icon-cog",
|
||||
items: [
|
||||
{
|
||||
"label": frappe._("Buying Settings"),
|
||||
"route": "Form/Buying Settings",
|
||||
"doctype":"Buying Settings",
|
||||
"description": frappe._("Settings for Buying Module")
|
||||
},
|
||||
{
|
||||
"label": frappe._("Purchase Taxes and Charges Master"),
|
||||
"doctype":"Purchase Taxes and Charges Master",
|
||||
"description": frappe._("Tax Template for Purchase")
|
||||
},
|
||||
{
|
||||
label: frappe._("Price List"),
|
||||
description: frappe._("Multiple Price list."),
|
||||
doctype:"Price List"
|
||||
},
|
||||
{
|
||||
label: frappe._("Item Price"),
|
||||
description: frappe._("Multiple Item prices."),
|
||||
doctype:"Item Price"
|
||||
},
|
||||
{
|
||||
"doctype":"Supplier Type",
|
||||
"label": frappe._("Supplier Type"),
|
||||
"description": frappe._("Supplier classification.")
|
||||
},
|
||||
{
|
||||
"route":"Sales Browser/Item Group",
|
||||
"label":frappe._("Item Group"),
|
||||
"description": frappe._("Tree of item classification"),
|
||||
doctype:"Item Group"
|
||||
},
|
||||
{
|
||||
label: frappe._("Terms and Conditions"),
|
||||
description: frappe._("Template of terms or contract."),
|
||||
doctype:"Terms and Conditions"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: frappe._("Tools"),
|
||||
icon: "icon-wrench",
|
||||
items: [
|
||||
]
|
||||
},
|
||||
{
|
||||
title: frappe._("Analytics"),
|
||||
right: true,
|
||||
icon: "icon-bar-chart",
|
||||
items: [
|
||||
{
|
||||
"label":frappe._("Purchase Analytics"),
|
||||
page: "purchase-analytics"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
title: frappe._("Reports"),
|
||||
right: true,
|
||||
icon: "icon-list",
|
||||
items: [
|
||||
{
|
||||
"label":frappe._("Items To Be Requested"),
|
||||
route: "query-report/Items To Be Requested",
|
||||
doctype: "Item"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Requested Items To Be Ordered"),
|
||||
route: "query-report/Requested Items To Be Ordered",
|
||||
doctype: "Material Request"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Material Requests for which Supplier Quotations are not created"),
|
||||
route: "query-report/Material Requests for which Supplier Quotations are not created",
|
||||
doctype: "Material Request"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Purchase In Transit"),
|
||||
route: "query-report/Purchase In Transit",
|
||||
doctype: "Purchase Order"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Item-wise Purchase History"),
|
||||
route: "query-report/Item-wise Purchase History",
|
||||
doctype: "Item"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Item-wise Last Purchase Rate"),
|
||||
route: "query-report/Item-wise Last Purchase Rate",
|
||||
doctype: "Item"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Purchase Order Trends"),
|
||||
route: "query-report/Purchase Order Trends",
|
||||
doctype: "Purchase Order"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Supplier Addresses And Contacts"),
|
||||
route: "query-report/Supplier Addresses and Contacts",
|
||||
doctype: "Supplier"
|
||||
},
|
||||
{
|
||||
"label":frappe._("Supplier-Wise Sales Analytics"),
|
||||
route: "query-report/Supplier-Wise Sales Analytics",
|
||||
doctype: "Stock Ledger Entry"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
pscript['onload_buying-home'] = function(wrapper) {
|
||||
frappe.views.moduleview.make(wrapper, "Buying");
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
[
|
||||
{
|
||||
"creation": "2012-02-21 13:22:54",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-11 14:41:50",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Page",
|
||||
"icon": "icon-th",
|
||||
"module": "Buying",
|
||||
"name": "__common__",
|
||||
"page_name": "buying-home",
|
||||
"standard": "Yes",
|
||||
"title": "Buying Home"
|
||||
},
|
||||
{
|
||||
"doctype": "Page",
|
||||
"name": "buying-home"
|
||||
}
|
||||
]
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-03 14:55:53",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-07-11 12:28:00",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -10,6 +10,7 @@
|
||||
"add_total_row": 1,
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Buying",
|
||||
"name": "__common__",
|
||||
"query": "select\n po_item.item_code as \"Item Code:Link/Item:120\",\n\tpo_item.item_name as \"Item Name::120\",\n\tpo_item.description as \"Description::150\",\n\tpo_item.qty as \"Qty:Float:100\",\n\tpo_item.stock_uom as \"UOM:Link/UOM:80\",\n\tpo_item.base_rate as \"Rate:Currency:120\",\n\tpo_item.base_amount as \"Amount:Currency:120\",\n\tpo.name as \"Purchase Order:Link/Purchase Order:120\",\n\tpo.transaction_date as \"Transaction Date:Date:140\",\n\tpo.supplier as \"Supplier:Link/Supplier:130\",\n\tpo_item.project_name as \"Project:Link/Project:130\",\n\tifnull(po_item.received_qty, 0) as \"Received Qty:Float:120\"\nfrom\n\t`tabPurchase Order` po, `tabPurchase Order Item` po_item\nwhere\n\tpo.name = po_item.parent and po.docstatus = 1\norder by po.name desc",
|
||||
"ref_doctype": "Purchase Order",
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
{
|
||||
"creation": "2013-06-13 18:45:01",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-06-13 18:45:01",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Buying",
|
||||
"name": "__common__",
|
||||
"ref_doctype": "Purchase Order",
|
||||
"report_name": "Purchase Order Trends",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-13 16:10:02",
|
||||
"docstatus": 0,
|
||||
"modified": "2014-01-24 18:19:11",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -10,6 +10,7 @@
|
||||
"add_total_row": 1,
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Buying",
|
||||
"name": "__common__",
|
||||
"query": "select \n mr.name as \"Material Request:Link/Material Request:120\",\n\tmr.transaction_date as \"Date:Date:100\",\n\tmr_item.item_code as \"Item Code:Link/Item:120\",\n\tsum(ifnull(mr_item.qty, 0)) as \"Qty:Float:100\",\n\tsum(ifnull(mr_item.ordered_qty, 0)) as \"Ordered Qty:Float:100\", \n\t(sum(mr_item.qty) - sum(ifnull(mr_item.ordered_qty, 0))) as \"Qty to Order:Float:100\",\n\tmr_item.item_name as \"Item Name::150\",\n\tmr_item.description as \"Description::200\"\nfrom\n\t`tabMaterial Request` mr, `tabMaterial Request Item` mr_item\nwhere\n\tmr_item.parent = mr.name\n\tand mr.material_request_type = \"Purchase\"\n\tand mr.docstatus = 1\n\tand mr.status != \"Stopped\"\ngroup by mr.name, mr_item.item_code\nhaving\n\tsum(ifnull(mr_item.ordered_qty, 0)) < sum(ifnull(mr_item.qty, 0))\norder by mr.transaction_date asc",
|
||||
"ref_doctype": "Purchase Order",
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
{
|
||||
"creation": "2013-10-09 10:38:40",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-10-09 10:53:52",
|
||||
"modified": "2014-03-07 15:30:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"module": "Buying",
|
||||
"name": "__common__",
|
||||
"query": "SELECT\n `tabSupplier`.name as \"Supplier:Link/Supplier:120\",\n\t`tabSupplier`.supplier_name as \"Supplier Name::120\",\n\t`tabSupplier`.supplier_type as \"Supplier Type:Link/Supplier Type:120\",\n\tconcat_ws(', ', \n\t\ttrim(',' from `tabAddress`.address_line1), \n\t\ttrim(',' from tabAddress.address_line2), \n\t\ttabAddress.state, tabAddress.pincode, tabAddress.country\n\t) as 'Address::180',\n concat_ws(', ', `tabContact`.first_name, `tabContact`.last_name) as 'Contact Name::180',\n\t`tabContact`.phone as \"Phone\",\n\t`tabContact`.mobile_no as \"Mobile No\",\n\t`tabContact`.email_id as \"Email Id::120\",\n\t`tabContact`.is_primary_contact as \"Is Primary Contact::120\"\nFROM\n\t`tabSupplier`\n\tleft join `tabAddress` on (\n\t\t`tabAddress`.supplier=`tabSupplier`.name\n\t)\n\tleft join `tabContact` on (\n\t\t`tabContact`.supplier=`tabSupplier`.name\n\t)\nWHERE\n\t`tabSupplier`.docstatus<2\nORDER BY\n\t`tabSupplier`.name asc",
|
||||
"ref_doctype": "Supplier",
|
||||
|
||||
303
erpnext/config/accounts.py
Normal file
303
erpnext/config/accounts.py
Normal file
@@ -0,0 +1,303 @@
|
||||
from frappe import _
|
||||
|
||||
data = [
|
||||
{
|
||||
"label": _("Documents"),
|
||||
"icon": "icon-star",
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Journal Voucher",
|
||||
"description": _("Accounting journal entries.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Sales Invoice",
|
||||
"description": _("Bills raised to Customers.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Purchase Invoice",
|
||||
"description": _("Bills raised by Suppliers.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Customer",
|
||||
"description": _("Customer database.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Supplier",
|
||||
"description": _("Supplier database.")
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Tools"),
|
||||
"icon": "icon-wrench",
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Bank Reconciliation",
|
||||
"description": _("Update bank payment dates with journals.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Payment to Invoice Matching Tool",
|
||||
"description": _("Match non-linked Invoices and Payments.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Period Closing Voucher",
|
||||
"description": _("Close Balance Sheet and book Profit or Loss.")
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Setup"),
|
||||
"icon": "icon-cog",
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Fiscal Year",
|
||||
"description": _("Financial / accounting year.")
|
||||
},
|
||||
{
|
||||
"type": "page",
|
||||
"name": "Accounts Browser",
|
||||
"icon": "icon-sitemap",
|
||||
"label": _("Chart of Accounts"),
|
||||
"route": "Accounts Browser/Account",
|
||||
"description": _("Tree of finanial accounts."),
|
||||
"doctype": "Account",
|
||||
},
|
||||
{
|
||||
"type": "page",
|
||||
"name": "Accounts Browser",
|
||||
"icon": "icon-sitemap",
|
||||
"label": _("Chart of Cost Centers"),
|
||||
"route": "Accounts Browser/Cost Center",
|
||||
"description": _("Tree of finanial Cost Centers."),
|
||||
"doctype": "Cost Center",
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Accounts Settings",
|
||||
"description": _("Default settings for accounting transactions.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Sales Taxes and Charges Master",
|
||||
"description": _("Tax template for selling transactions.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Purchase Taxes and Charges Master",
|
||||
"description": _("Tax template for buying transactions.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "POS Setting",
|
||||
"label": _("Point-of-Sale Setting"),
|
||||
"description": _("Rules to calculate shipping amount for a sale")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Shipping Rule",
|
||||
"description": _("Rules for adding shipping costs.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Pricing Rule",
|
||||
"description": _("Rules for applying pricing and discount.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Currency",
|
||||
"description": _("Enable / disable currencies.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Currency Exchange",
|
||||
"description": _("Currency exchange rate master.")
|
||||
},
|
||||
{
|
||||
"type":"doctype",
|
||||
"name": "Budget Distribution",
|
||||
"description": _("Seasonality for setting budgets.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name":"Terms and Conditions",
|
||||
"label": _("Terms and Conditions Template"),
|
||||
"description": _("Template of terms or contract.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name":"Mode of Payment",
|
||||
"description": _("e.g. Bank, Cash, Credit Card")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name":"C-Form",
|
||||
"description": _("C-Form records"),
|
||||
"country": "India"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Main Reports"),
|
||||
"icon": "icon-table",
|
||||
"items": [
|
||||
{
|
||||
"type": "report",
|
||||
"name":"General Ledger",
|
||||
"doctype": "GL Entry",
|
||||
"is_query_report": True,
|
||||
},
|
||||
{
|
||||
"type": "page",
|
||||
"name": "trial-balance",
|
||||
"label": _("Trial Balance"),
|
||||
"icon": "icon-table"
|
||||
},
|
||||
{
|
||||
"type": "page",
|
||||
"name":"Financial Statements",
|
||||
"icon": "icon-table"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Accounts Receivable",
|
||||
"doctype": "Sales Invoice",
|
||||
"is_query_report": True
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Accounts Payable",
|
||||
"doctype": "Purchase Invoice",
|
||||
"is_query_report": True
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Sales Register",
|
||||
"doctype": "Sales Invoice",
|
||||
"is_query_report": True
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Purchase Register",
|
||||
"doctype": "Purchase Invoice",
|
||||
"is_query_report": True
|
||||
},
|
||||
{
|
||||
"type": "page",
|
||||
"name": "financial-analytics",
|
||||
"label": _("Financial Analytics"),
|
||||
"icon": "icon-bar-chart",
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Gross Profit",
|
||||
"doctype": "Sales Invoice",
|
||||
"is_query_report": True
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Standard Reports"),
|
||||
"icon": "icon-list",
|
||||
"items": [
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Bank Reconciliation Statement",
|
||||
"is_query_report": True,
|
||||
"doctype": "Journal Voucher"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Ordered Items To Be Billed",
|
||||
"is_query_report": True,
|
||||
"doctype": "Sales Invoice"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Delivered Items To Be Billed",
|
||||
"is_query_report": True,
|
||||
"doctype": "Sales Invoice"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Purchase Order Items To Be Billed",
|
||||
"is_query_report": True,
|
||||
"doctype": "Purchase Invoice"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Received Items To Be Billed",
|
||||
"is_query_report": True,
|
||||
"doctype": "Purchase Invoice"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Bank Clearance Summary",
|
||||
"is_query_report": True,
|
||||
"doctype": "Journal Voucher"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Payment Period Based On Invoice Date",
|
||||
"is_query_report": True,
|
||||
"doctype": "Journal Voucher"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Sales Partners Commission",
|
||||
"is_query_report": True,
|
||||
"doctype": "Sales Invoice"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Customer Account Head",
|
||||
"is_query_report": True,
|
||||
"doctype": "Account"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Supplier Account Head",
|
||||
"is_query_report": True,
|
||||
"doctype": "Account"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Item-wise Sales Register",
|
||||
"is_query_report": True,
|
||||
"doctype": "Sales Invoice"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Item-wise Purchase Register",
|
||||
"is_query_report": True,
|
||||
"doctype": "Purchase Invoice"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Budget Variance Report",
|
||||
"is_query_report": True,
|
||||
"doctype": "Cost Center"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Purchase Invoice Trends",
|
||||
"is_query_report": True,
|
||||
"doctype": "Purchase Invoice"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Sales Invoice Trends",
|
||||
"is_query_report": True,
|
||||
"doctype": "Sales Invoice"
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
169
erpnext/config/buying.py
Normal file
169
erpnext/config/buying.py
Normal file
@@ -0,0 +1,169 @@
|
||||
from frappe import _
|
||||
|
||||
data = [
|
||||
{
|
||||
"label": _("Documents"),
|
||||
"icon": "icon-star",
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Supplier",
|
||||
"description": _("Supplier database."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Material Request",
|
||||
"description": _("Request for purchase."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Supplier Quotation",
|
||||
"description": _("Quotations received from Suppliers."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Purchase Order",
|
||||
"description": _("Purchase Orders given to Suppliers."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Contact",
|
||||
"description": _("All Contacts."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Address",
|
||||
"description": _("All Addresses."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Item",
|
||||
"description": _("All Products or Services."),
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Setup"),
|
||||
"icon": "icon-cog",
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Buying Settings",
|
||||
"description": _("Default settings for buying transactions.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Supplier Type",
|
||||
"description": _("Supplier Type master.")
|
||||
},
|
||||
{
|
||||
"type": "page",
|
||||
"name": "Sales Browser",
|
||||
"icon": "icon-sitemap",
|
||||
"label": _("Item Group Tree"),
|
||||
"link": "Sales Browser/Item Group",
|
||||
"description": _("Tree of Item Groups."),
|
||||
"doctype": "Item Group",
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name":"Terms and Conditions",
|
||||
"label": _("Terms and Conditions Template"),
|
||||
"description": _("Template of terms or contract.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Purchase Taxes and Charges Master",
|
||||
"description": _("Tax template for buying transactions.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Price List",
|
||||
"description": _("Price List master.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Item Price",
|
||||
"description": _("Multiple Item prices."),
|
||||
"route": "Report/Item Price"
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Pricing Rule",
|
||||
"description": _("Rules for applying pricing and discount.")
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Main Reports"),
|
||||
"icon": "icon-table",
|
||||
"items": [
|
||||
{
|
||||
"type": "page",
|
||||
"name": "purchase-analytics",
|
||||
"label": _("Purchase Analytics"),
|
||||
"icon": "icon-bar-chart",
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Standard Reports"),
|
||||
"icon": "icon-list",
|
||||
"items": [
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Items To Be Requested",
|
||||
"doctype": "Item"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Requested Items To Be Ordered",
|
||||
"doctype": "Material Request"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Material Requests for which Supplier Quotations are not created",
|
||||
"doctype": "Material Request"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Purchase In Transit",
|
||||
"doctype": "Purchase Order"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Item-wise Purchase History",
|
||||
"doctype": "Item"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Item-wise Last Purchase Rate",
|
||||
"doctype": "Item"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Purchase Order Trends",
|
||||
"doctype": "Purchase Order"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Supplier Addresses And Contacts",
|
||||
"doctype": "Supplier"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Supplier-Wise Sales Analytics",
|
||||
"doctype": "Stock Ledger Entry"
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
@@ -4,7 +4,6 @@ data = {
|
||||
"Accounts": {
|
||||
"color": "#3498db",
|
||||
"icon": "icon-money",
|
||||
"link": "accounts-home",
|
||||
"type": "module"
|
||||
},
|
||||
"Activity": {
|
||||
@@ -17,20 +16,17 @@ data = {
|
||||
"Buying": {
|
||||
"color": "#c0392b",
|
||||
"icon": "icon-shopping-cart",
|
||||
"link": "buying-home",
|
||||
"type": "module"
|
||||
},
|
||||
"HR": {
|
||||
"color": "#2ecc71",
|
||||
"icon": "icon-group",
|
||||
"label": _("Human Resources"),
|
||||
"link": "hr-home",
|
||||
"type": "module"
|
||||
},
|
||||
"Manufacturing": {
|
||||
"color": "#7f8c8d",
|
||||
"icon": "icon-cogs",
|
||||
"link": "manufacturing-home",
|
||||
"type": "module"
|
||||
},
|
||||
"Notes": {
|
||||
@@ -44,25 +40,21 @@ data = {
|
||||
"Projects": {
|
||||
"color": "#8e44ad",
|
||||
"icon": "icon-puzzle-piece",
|
||||
"link": "projects-home",
|
||||
"type": "module"
|
||||
},
|
||||
"Selling": {
|
||||
"color": "#1abc9c",
|
||||
"icon": "icon-tag",
|
||||
"link": "selling-home",
|
||||
"type": "module"
|
||||
},
|
||||
"Stock": {
|
||||
"color": "#f39c12",
|
||||
"icon": "icon-truck",
|
||||
"link": "stock-home",
|
||||
"type": "module"
|
||||
},
|
||||
"Support": {
|
||||
"color": "#2c3e50",
|
||||
"icon": "icon-phone",
|
||||
"link": "support-home",
|
||||
"type": "module"
|
||||
}
|
||||
}
|
||||
202
erpnext/config/hr.py
Normal file
202
erpnext/config/hr.py
Normal file
@@ -0,0 +1,202 @@
|
||||
from frappe import _
|
||||
|
||||
data = [
|
||||
{
|
||||
"label": _("Documents"),
|
||||
"icon": "icon-star",
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Employee",
|
||||
"description": _("Employee records."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Salary Slip",
|
||||
"description": _("Monthly salary statement."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Leave Application",
|
||||
"description": _("Applications for leave."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Attendance",
|
||||
"description": _("Attendance record."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Expense Claim",
|
||||
"description": _("Claims for company expense."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Appraisal",
|
||||
"description": _("Performance appraisal."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Job Applicant",
|
||||
"description": _("Applicant for a Job."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Job Opening",
|
||||
"description": _("Opening for a Job."),
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Tools"),
|
||||
"icon": "icon-wrench",
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Salary Manager",
|
||||
"label": _("Process Payroll"),
|
||||
"description":_("Generate Salary Slips"),
|
||||
"hide_count": True
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Upload Attendance",
|
||||
"description":_("Upload attendance from a .csv file"),
|
||||
"hide_count": True
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Leave Control Panel",
|
||||
"label": _("Leave Allocation Tool"),
|
||||
"description":_("Allocate leaves for the year."),
|
||||
"hide_count": True
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Setup"),
|
||||
"icon": "icon-cog",
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "HR Settings",
|
||||
"description": _("Settings for HR Module")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Employee",
|
||||
"description": _("Employee master.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Employment Type",
|
||||
"description": _("Types of employment (permanent, contract, intern etc.).")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Branch",
|
||||
"description": _("Organization branch master.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Department",
|
||||
"description": _("Organization unit (department) master.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Grade",
|
||||
"description": _("Employee grade.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Designation",
|
||||
"description": _("Employee designation (e.g. CEO, Director etc.).")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Salary Structure",
|
||||
"description": _("Salary template master.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Earning Type",
|
||||
"description": _("Salary components.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Deduction Type",
|
||||
"description": _("Tax and other salary deductions.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Leave Allocation",
|
||||
"description": _("Allocate leaves for a period.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name":"Leave Type",
|
||||
"description": _("Type of leaves like casual, sick etc."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Holiday List",
|
||||
"description": _("Holiday master.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Leave Block List",
|
||||
"description": _("Block leave applications by department.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Appraisal Template",
|
||||
"description": _("Template for performance appraisals.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Expense Claim Type",
|
||||
"description": _("Types of Expense Claim.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Jobs Email Settings",
|
||||
"description": _("Setup incoming server for jobs email id. (e.g. jobs@example.com)")
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Standard Reports"),
|
||||
"icon": "icon-list",
|
||||
"items": [
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Employee Leave Balance",
|
||||
"doctype": "Leave Application"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Employee Birthday",
|
||||
"doctype": "Employee"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"name": "Employee Information",
|
||||
"doctype": "Employee"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Monthly Salary Register",
|
||||
"doctype": "Salary Slip"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Monthly Attendance Sheet",
|
||||
"doctype": "Attendance"
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
77
erpnext/config/manufacturing.py
Normal file
77
erpnext/config/manufacturing.py
Normal file
@@ -0,0 +1,77 @@
|
||||
from frappe import _
|
||||
|
||||
data = [
|
||||
{
|
||||
"label": _("Documents"),
|
||||
"icon": "icon-star",
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Bill of Materials",
|
||||
"description": _("Bill of Materials (BOM)"),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Production Order",
|
||||
"description": _("Orders released for production."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Item",
|
||||
"description": _("All Products or Services."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Workstation",
|
||||
"description": _("Where manufacturing operations are carried out."),
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Tools"),
|
||||
"icon": "icon-wrench",
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Production Planning Tool",
|
||||
"description": _("Generate Material Requests (MRP) and Production Orders."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "BOM Replace Tool",
|
||||
"description": _("Replace Item / BOM in all BOMs"),
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Standard Reports"),
|
||||
"icon": "icon-list",
|
||||
"items": [
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Open Production Orders",
|
||||
"doctype": "Production Order"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Production Orders in Progress",
|
||||
"doctype": "Production Order"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Issued Items Against Production Order",
|
||||
"doctype": "Production Order"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Completed Production Orders",
|
||||
"doctype": "Production Order"
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
66
erpnext/config/projects.py
Normal file
66
erpnext/config/projects.py
Normal file
@@ -0,0 +1,66 @@
|
||||
from frappe import _
|
||||
|
||||
data = [
|
||||
{
|
||||
"label": _("Documents"),
|
||||
"icon": "icon-star",
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Task",
|
||||
"description": _("Project activity / task."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Project",
|
||||
"description": _("Project master."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Time Log",
|
||||
"description": _("Time Log for tasks."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Time Log Batch",
|
||||
"description": _("Batch Time Logs for billing."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Activity Type",
|
||||
"description": _("Types of activities for Time Sheets"),
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Tools"),
|
||||
"icon": "icon-wrench",
|
||||
"items": [
|
||||
{
|
||||
"type": "report",
|
||||
"route": "Gantt/Task",
|
||||
"doctype": "Task",
|
||||
"name": "Gantt Chart",
|
||||
"description": _("Gantt chart of all tasks.")
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Standard Reports"),
|
||||
"icon": "icon-list",
|
||||
"items": [
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Daily Time Log Summary",
|
||||
"doctype": "Time Log"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Project wise Stock Tracking",
|
||||
"doctype": "Project"
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
260
erpnext/config/selling.py
Normal file
260
erpnext/config/selling.py
Normal file
@@ -0,0 +1,260 @@
|
||||
from frappe import _
|
||||
|
||||
data = [
|
||||
{
|
||||
"label": _("Documents"),
|
||||
"icon": "icon-star",
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Lead",
|
||||
"description": _("Database of potential customers."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Customer",
|
||||
"description": _("Customer database."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Opportunity",
|
||||
"description": _("Potential opportunities for selling."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Quotation",
|
||||
"description": _("Quotes to Leads or Customers."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Sales Order",
|
||||
"description": _("Confirmed orders from Customers."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Contact",
|
||||
"description": _("All Contacts."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Address",
|
||||
"description": _("All Addresses."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Item",
|
||||
"description": _("All Products or Services."),
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Tools"),
|
||||
"icon": "icon-wrench",
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "SMS Center",
|
||||
"description":_("Send mass SMS to your contacts"),
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Setup"),
|
||||
"icon": "icon-cog",
|
||||
"items": [
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Selling Settings",
|
||||
"description": _("Default settings for selling transactions.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Campaign",
|
||||
"description": _("Sales campaigns."),
|
||||
},
|
||||
{
|
||||
"type": "page",
|
||||
"label": _("Customer Group"),
|
||||
"name": "Sales Browser",
|
||||
"icon": "icon-sitemap",
|
||||
"link": "Sales Browser/Customer Group",
|
||||
"description": _("Manage Customer Group Tree."),
|
||||
"doctype": "Customer Group",
|
||||
},
|
||||
{
|
||||
"type": "page",
|
||||
"label": _("Territory"),
|
||||
"name": "Sales Browser",
|
||||
"icon": "icon-sitemap",
|
||||
"link": "Sales Browser/Territory",
|
||||
"description": _("Manage Territory Tree."),
|
||||
"doctype": "Territory",
|
||||
},
|
||||
{
|
||||
"type": "page",
|
||||
"label": _("Sales Person"),
|
||||
"name": "Sales Browser",
|
||||
"icon": "icon-sitemap",
|
||||
"link": "Sales Browser/Sales Person",
|
||||
"description": _("Manage Sales Person Tree."),
|
||||
"doctype": "Sales Person",
|
||||
},
|
||||
{
|
||||
"type": "page",
|
||||
"name": "Sales Browser",
|
||||
"icon": "icon-sitemap",
|
||||
"label": _("Item Group Tree"),
|
||||
"link": "Sales Browser/Item Group",
|
||||
"description": _("Tree of Item Groups."),
|
||||
"doctype": "Item Group",
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name":"Terms and Conditions",
|
||||
"label": _("Terms and Conditions Template"),
|
||||
"description": _("Template of terms or contract.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Sales Taxes and Charges Master",
|
||||
"description": _("Tax template for selling transactions.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Shipping Rule",
|
||||
"description": _("Rules for adding shipping costs.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Price List",
|
||||
"description": _("Price List master.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Item Price",
|
||||
"description": _("Multiple Item prices."),
|
||||
"route": "Report/Item Price"
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Pricing Rule",
|
||||
"description": _("Rules for applying pricing and discount.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Sales BOM",
|
||||
"description": _("Bundle items at time of sale."),
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Sales Email Settings",
|
||||
"description": _("Setup incoming server for sales email id. (e.g. sales@example.com)")
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Main Reports"),
|
||||
"icon": "icon-table",
|
||||
"items": [
|
||||
{
|
||||
"type": "page",
|
||||
"name": "sales-analytics",
|
||||
"label": _("Sales Analytics"),
|
||||
"icon": "icon-bar-chart",
|
||||
},
|
||||
{
|
||||
"type": "page",
|
||||
"name": "sales-funnel",
|
||||
"label": _("Sales Funnel"),
|
||||
"icon": "icon-bar-chart",
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Customer Acquisition and Loyalty",
|
||||
"doctype": "Customer",
|
||||
"icon": "icon-bar-chart",
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": _("Standard Reports"),
|
||||
"icon": "icon-list",
|
||||
"items": [
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Lead Details",
|
||||
"doctype": "Lead"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Customer Addresses And Contacts",
|
||||
"doctype": "Contact"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Ordered Items To Be Delivered",
|
||||
"doctype": "Sales Order"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Sales Person-wise Transaction Summary",
|
||||
"doctype": "Sales Order"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Item-wise Sales History",
|
||||
"doctype": "Item"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Territory Target Variance (Item Group-Wise)",
|
||||
"route": "query-report/Territory Target Variance Item Group-Wise",
|
||||
"doctype": "Territory"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Sales Person Target Variance (Item Group-Wise)",
|
||||
"route": "query-report/Sales Person Target Variance Item Group-Wise",
|
||||
"doctype": "Sales Person",
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Customers Not Buying Since Long Time",
|
||||
"doctype": "Sales Order"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Quotation Trend",
|
||||
"doctype": "Quotation"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Sales Order Trends",
|
||||
"doctype": "Sales Order"
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Available Stock for Packing Items",
|
||||
"doctype": "Item",
|
||||
},
|
||||
{
|
||||
"type": "report",
|
||||
"is_query_report": True,
|
||||
"name": "Pending SO Items For Purchase Request",
|
||||
"doctype": "Sales Order"
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user