-webnotes +frappe 💥

This commit is contained in:
Rushabh Mehta 2014-02-14 15:47:51 +05:30
parent 8ae051cb39
commit 793ba6bd37
729 changed files with 5194 additions and 9971 deletions

View File

@ -4,7 +4,7 @@
Includes Accounting, Inventory, CRM, Sales, Purchase, Projects, HRMS. Built on Python / MySQL.
ERPNext is built on [wnframework](https://github.com/webnotes/wnframework)
ERPNext is built on [frappe](https://github.com/frappe/frappe)
- [User Guide](http://erpnext.org/user-guide.html)
- [Getting Help](http://erpnext.org/getting-help.html)
@ -24,10 +24,10 @@ ERPNext is built on [wnframework](https://github.com/webnotes/wnframework)
1. Switch to root user using `sudo su`
1. create a folder where you want to install erpnext
1. go to the new folder
1. `wget https://raw.github.com/webnotes/erpnext/master/install_erpnext.py`
1. `wget https://raw.github.com/frappe/erpnext/master/install_erpnext.py`
1. `python install_erpnext.py`
[See installation notes](https://github.com/webnotes/erpnext/wiki/How-to-Install-ERPNext)
[See installation notes](https://github.com/frappe/erpnext/wiki/How-to-Install-ERPNext)
##### Patch and update

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
{%- if doc.letter_head -%}
{{ webnotes.conn.get_value("Letter Head", doc.letter_head, "content") }}
{{ frappe.conn.get_value("Letter Head", doc.letter_head, "content") }}
{%- endif -%}
<!-- Page Layout Settings -->
<div class='common page-header'>

View File

@ -11,7 +11,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
// -----------------------------------------
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
if(doc.__islocal) {
msgprint(wn._("Please create new account from Chart of Accounts."));
msgprint(frappe._("Please create new account from Chart of Accounts."));
throw "cannot create";
}
@ -26,8 +26,8 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
'is_pl_account', 'company'], false);
if(doc.group_or_ledger=='Ledger') {
wn.model.with_doc("Accounts Settings", "Accounts Settings", function (name) {
var accounts_settings = wn.model.get_doc("Accounts Settings", name);
frappe.model.with_doc("Accounts Settings", "Accounts Settings", function (name) {
var accounts_settings = frappe.model.get_doc("Accounts Settings", name);
var display = accounts_settings["frozen_accounts_modifier"]
&& in_list(user_roles, accounts_settings["frozen_accounts_modifier"]);
@ -38,7 +38,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
// read-only for root accounts
if(!doc.parent_account) {
cur_frm.set_read_only();
cur_frm.set_intro(wn._("This is a root account and cannot be edited."));
cur_frm.set_intro(frappe._("This is a root account and cannot be edited."));
} else {
// credit days and type if customer or supplier
cur_frm.set_intro(null);
@ -81,24 +81,24 @@ cur_frm.cscript.account_type = function(doc, cdt, cdn) {
// Hide/unhide group or ledger
// -----------------------------------------
cur_frm.cscript.add_toolbar_buttons = function(doc) {
cur_frm.appframe.add_button(wn._('Chart of Accounts'),
function() { wn.set_route("Accounts Browser", "Account"); }, 'icon-sitemap')
cur_frm.appframe.add_button(frappe._('Chart of Accounts'),
function() { frappe.set_route("Accounts Browser", "Account"); }, 'icon-sitemap')
if (cstr(doc.group_or_ledger) == 'Group') {
cur_frm.add_custom_button(wn._('Convert to Ledger'),
cur_frm.add_custom_button(frappe._('Convert to Ledger'),
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet')
} else if (cstr(doc.group_or_ledger) == 'Ledger') {
cur_frm.add_custom_button(wn._('Convert to Group'),
cur_frm.add_custom_button(frappe._('Convert to Group'),
function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet')
cur_frm.appframe.add_button(wn._('View Ledger'), function() {
wn.route_options = {
cur_frm.appframe.add_button(frappe._('View Ledger'), function() {
frappe.route_options = {
"account": doc.name,
"from_date": sys_defaults.year_start_date,
"to_date": sys_defaults.year_end_date,
"company": doc.company
};
wn.set_route("query-report", "General Ledger");
frappe.set_route("query-report", "General Ledger");
}, "icon-table");
}
}

View File

@ -2,12 +2,12 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
from webnotes.utils import flt, fmt_money, cstr, cint
from webnotes import msgprint, throw, _
from frappe.utils import flt, fmt_money, cstr, cint
from frappe import msgprint, throw, _
get_value = webnotes.conn.get_value
get_value = frappe.conn.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() + ' - ' + \
webnotes.conn.get_value("Company", self.doc.company, "abbr")
frappe.conn.get_value("Company", self.doc.company, "abbr")
def get_address(self):
return {
'address': webnotes.conn.get_value(self.doc.master_type,
'address': frappe.conn.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 webnotes.conn.exists(self.doc.master_type or self.doc.account_type,
elif not frappe.conn.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 = webnotes.conn.sql("""select name, group_or_ledger, is_pl_account, debit_or_credit
par = frappe.conn.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 webnotes.conn.sql("""select count(*) from tabAccount where
if frappe.conn.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 = webnotes.conn.get_value("Company", self.doc.company, "abbr")
if webnotes.conn.sql("""select name from tabAccount where name=%s""",
company_abbr = frappe.conn.get_value("Company", self.doc.company, "abbr")
if frappe.conn.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,17 +91,17 @@ class DocType:
def validate_root_details(self):
#does not exists parent
if webnotes.conn.exists("Account", self.doc.name):
if not webnotes.conn.get_value("Account", self.doc.name, "parent_account"):
if frappe.conn.exists("Account", self.doc.name):
if not frappe.conn.get_value("Account", self.doc.name, "parent_account"):
throw(_("Root cannot be edited."))
def validate_frozen_accounts_modifier(self):
old_value = webnotes.conn.get_value("Account", self.doc.name, "freeze_account")
old_value = frappe.conn.get_value("Account", self.doc.name, "freeze_account")
if old_value and old_value != self.doc.freeze_account:
frozen_accounts_modifier = webnotes.conn.get_value( 'Accounts Settings', None,
frozen_accounts_modifier = frappe.conn.get_value( 'Accounts Settings', None,
'frozen_accounts_modifier')
if not frozen_accounts_modifier or \
frozen_accounts_modifier not in webnotes.user.get_roles():
frozen_accounts_modifier not in frappe.user.get_roles():
throw(_("You are not authorized to set Frozen value"))
def convert_group_to_ledger(self):
@ -131,10 +131,10 @@ class DocType:
# Check if any previous balance exists
def check_gle_exists(self):
return webnotes.conn.get_value("GL Entry", {"account": self.doc.name})
return frappe.conn.get_value("GL Entry", {"account": self.doc.name})
def check_if_child_exists(self):
return webnotes.conn.sql("""select name from `tabAccount` where parent_account = %s
return frappe.conn.sql("""select name from `tabAccount` where parent_account = %s
and docstatus != 2""", self.doc.name)
def validate_mandatory(self):
@ -144,11 +144,11 @@ class DocType:
throw(_("Is PL Account field is mandatory"))
def validate_warehouse_account(self):
if not cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")):
if not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
return
if self.doc.account_type == "Warehouse":
old_warehouse = cstr(webnotes.conn.get_value("Account", self.doc.name, "master_name"))
old_warehouse = cstr(frappe.conn.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,15 +158,15 @@ class DocType:
throw(_("Master Name is mandatory if account type is Warehouse"))
def validate_warehouse(self, warehouse):
if webnotes.conn.get_value("Stock Ledger Entry", {"warehouse": warehouse}):
if frappe.conn.get_value("Stock Ledger Entry", {"warehouse": warehouse}):
throw(_("Stock transactions exist against warehouse ") + warehouse +
_(" .You can not assign / modify / remove Master Name"))
def update_nsm_model(self):
"""update lft, rgt indices for nested set model"""
import webnotes
import webnotes.utils.nestedset
webnotes.utils.nestedset.update_nsm(self)
import frappe
import frappe.utils.nestedset
frappe.utils.nestedset.update_nsm(self)
def on_update(self):
self.validate_max_root_accounts()
@ -174,19 +174,19 @@ class DocType:
def get_authorized_user(self):
# Check logged-in user is authorized
if webnotes.conn.get_value('Accounts Settings', None, 'credit_controller') \
in webnotes.user.get_roles():
if frappe.conn.get_value('Accounts Settings', None, 'credit_controller') \
in frappe.user.get_roles():
return 1
def check_credit_limit(self, total_outstanding):
# Get credit limit
credit_limit_from = 'Customer'
cr_limit = webnotes.conn.sql("""select t1.credit_limit from tabCustomer t1, `tabAccount` t2
cr_limit = frappe.conn.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 = webnotes.conn.get_value('Company', self.doc.company, 'credit_limit')
credit_limit = frappe.conn.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 webnotes.conn.exists("Account", new):
if not frappe.conn.exists("Account", new):
throw(_("Account ") + new +_(" does not exists"))
val = list(webnotes.conn.get_value("Account", new_account,
val = list(frappe.conn.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,22 +234,22 @@ class DocType:
def after_rename(self, old, new, merge=False):
if not merge:
webnotes.conn.set_value("Account", new, "account_name",
frappe.conn.set_value("Account", new, "account_name",
" - ".join(new.split(" - ")[:-1]))
else:
from webnotes.utils.nestedset import rebuild_tree
from frappe.utils.nestedset import rebuild_tree
rebuild_tree("Account", "parent_account")
def get_master_name(doctype, txt, searchfield, start, page_len, filters):
conditions = (" and company='%s'"% filters["company"]) if doctype == "Warehouse" else ""
return webnotes.conn.sql("""select name from `tab%s` where %s like %s %s
return frappe.conn.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 webnotes.conn.sql("""select name from tabAccount
return frappe.conn.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"),

View File

@ -2,10 +2,10 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
def _make_test_records(verbose):
from webnotes.test_runner import make_test_objects
from frappe.test_runner import make_test_objects
accounts = [
# [account_name, parent_account, group_or_ledger]

View File

@ -4,28 +4,28 @@
# For license information, please see license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import _
from webnotes.utils import cint
import frappe
from frappe import _
from frappe.utils import cint
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def on_update(self):
webnotes.conn.set_default("auto_accounting_for_stock", self.doc.auto_accounting_for_stock)
frappe.conn.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 webnotes.conn.sql("select name from tabCompany"):
webnotes.bean("Company", company[0]).save()
for company in frappe.conn.sql("select name from tabCompany"):
frappe.bean("Company", company[0]).save()
# Create account head for warehouses
warehouse_list = webnotes.conn.sql("select name, company from tabWarehouse", as_dict=1)
warehouse_list = frappe.conn.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:
webnotes.throw(_("Company is missing in following warehouses") + ": \n" +
frappe.throw(_("Company is missing in following warehouses") + ": \n" +
"\n".join(warehouse_with_no_company))
for wh in warehouse_list:
wh_bean = webnotes.bean("Warehouse", wh.name)
wh_bean = frappe.bean("Warehouse", wh.name)
wh_bean.save()

View File

@ -4,5 +4,5 @@
cur_frm.add_fetch("bank_account", "company", "company");
cur_frm.cscript.onload = function(doc, cdt, cdn){
cur_frm.set_intro('<i class="icon-question" /> ' +
wn._("Update clearance date of Journal Entries marked as 'Bank Vouchers'"))
frappe._("Update clearance date of Journal Entries marked as 'Bank Vouchers'"))
}

View File

@ -2,13 +2,13 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
from webnotes.utils import cstr, flt, getdate, now, nowdate
from webnotes.model import db_exists
from webnotes.model.doc import addchild
from webnotes.model.bean import getlist, copy_doclist
from webnotes import msgprint
from frappe.utils import cstr, flt, getdate, now, nowdate
from frappe.model import db_exists
from frappe.model.doc import addchild
from frappe.model.bean import getlist, copy_doclist
from frappe import msgprint
@ -22,7 +22,7 @@ class DocType:
msgprint("Bank Account, From Date and To Date are Mandatory")
return
dl = webnotes.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.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))
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)
webnotes.conn.sql("""update `tabJournal Voucher`
frappe.conn.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)

View File

@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
class DocType:
def __init__(self, d, dl):

View File

@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
class DocType:
def __init__(self, d, dl):

View File

@ -8,7 +8,7 @@ cur_frm.cscript.onload = function(doc,cdt,cdn){
}
return $c('runserverobj',args={'method' : 'get_months', 'docs' :
wn.model.compress(make_doclist(doc.doctype, doc.name))},callback1);
frappe.model.compress(make_doclist(doc.doctype, doc.name))},callback1);
}
}

View File

@ -2,12 +2,12 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
from webnotes.utils import flt
from webnotes.model.doc import addchild
from webnotes.model.bean import getlist
from webnotes import msgprint, _
from frappe.utils import flt
from frappe.model.doc import addchild
from frappe.model.bean import getlist
from frappe import msgprint, _
class DocType:
def __init__(self,doc,doclist=[]):

View File

@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
class DocType:
def __init__(self, d, dl):

View File

@ -2,9 +2,9 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt, getdate
from webnotes.model.bean import getlist
import frappe
from frappe.utils import flt, getdate
from frappe.model.bean import getlist
class DocType:
def __init__(self,d,dl):
@ -16,19 +16,19 @@ class DocType:
for d in getlist(self.doclist, 'invoice_details'):
if d.invoice_no:
inv = webnotes.conn.sql("""select c_form_applicable, c_form_no from
inv = frappe.conn.sql("""select c_form_applicable, c_form_no from
`tabSales Invoice` where name = %s and docstatus = 1""", d.invoice_no)
if not inv:
webnotes.msgprint("""Invoice: %s is not exists in the system or
frappe.msgprint("""Invoice: %s is not exists in the system or
is not submitted, please check.""" % d.invoice_no, raise_exception=1)
elif inv[0][0] != 'Yes':
webnotes.msgprint("C-form is not applicable for Invoice: %s" %
frappe.msgprint("C-form is not applicable for Invoice: %s" %
d.invoice_no, raise_exception=1)
elif inv[0][1] and inv[0][1] != self.doc.name:
webnotes.msgprint("""Invoice %s is tagged in another C-form: %s.
frappe.msgprint("""Invoice %s is tagged in another C-form: %s.
If you want to change C-form no for this invoice,
please remove invoice no from the previous c-form and then try again""" %
(d.invoice_no, inv[0][1]), raise_exception=1)
@ -42,31 +42,31 @@ class DocType:
def before_cancel(self):
# remove cform reference
webnotes.conn.sql("""update `tabSales Invoice` set c_form_no=null
frappe.conn.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:
webnotes.conn.sql("""update `tabSales Invoice` set c_form_no=%s, modified=%s
frappe.conn.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))
webnotes.conn.sql("""update `tabSales Invoice` set c_form_no = null, modified = %s
frappe.conn.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]))
else:
webnotes.msgprint("Please enter atleast 1 invoice in the table", raise_exception=1)
frappe.msgprint("Please enter atleast 1 invoice in the table", raise_exception=1)
def set_total_invoiced_amount(self):
total = sum([flt(d.grand_total) for d in getlist(self.doclist, 'invoice_details')])
webnotes.conn.set(self.doc, 'total_invoiced_amount', total)
frappe.conn.set(self.doc, 'total_invoiced_amount', total)
def get_invoice_details(self, invoice_no):
""" Pull details from invoices for referrence """
inv = webnotes.conn.sql("""select posting_date, territory, net_total, grand_total
inv = frappe.conn.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 webnotes.conn.sql("""select name from `tabSales Invoice` where docstatus = 1
return frappe.conn.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"),

View File

@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
class DocType:
def __init__(self, d, dl):

View File

@ -1,8 +1,8 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.provide("erpnext.accounts");
erpnext.accounts.CostCenterController = wn.ui.form.Controller.extend({
frappe.provide("erpnext.accounts");
erpnext.accounts.CostCenterController = frappe.ui.form.Controller.extend({
onload: function() {
this.setup_queries();
},
@ -41,8 +41,8 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.toggle_enable(['group_or_ledger', 'company'], doc.__islocal);
if(!doc.__islocal && doc.group_or_ledger=='Group') {
intro_txt += '<p><b>'+wn._('Note:')+'</b>'+ wn._('This Cost Center is a')+ '<i>'+wn._('Group')+'</i>, '+
wn._('Accounting Entries are not allowed against groups.')+'</p>';
intro_txt += '<p><b>'+frappe._('Note:')+'</b>'+ frappe._('This Cost Center is a')+ '<i>'+frappe._('Group')+'</i>, '+
frappe._('Accounting Entries are not allowed against groups.')+'</p>';
}
cur_frm.cscript.hide_unhide_group_ledger(doc);
@ -50,22 +50,22 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.toggle_display('sb1', doc.group_or_ledger=='Ledger')
cur_frm.set_intro(intro_txt);
cur_frm.appframe.add_button(wn._('Chart of Cost Centers'),
function() { wn.set_route("Accounts Browser", "Cost Center"); }, 'icon-sitemap')
cur_frm.appframe.add_button(frappe._('Chart of Cost Centers'),
function() { frappe.set_route("Accounts Browser", "Cost Center"); }, 'icon-sitemap')
}
cur_frm.cscript.parent_cost_center = function(doc, cdt, cdn) {
if(!doc.company){
msgprint(wn._('Please enter company name first'));
msgprint(frappe._('Please enter company name first'));
}
}
cur_frm.cscript.hide_unhide_group_ledger = function(doc) {
if (cstr(doc.group_or_ledger) == 'Group') {
cur_frm.add_custom_button(wn._('Convert to Ledger'),
cur_frm.add_custom_button(frappe._('Convert to Ledger'),
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet')
} else if (cstr(doc.group_or_ledger) == 'Ledger') {
cur_frm.add_custom_button(wn._('Convert to Group'),
cur_frm.add_custom_button(frappe._('Convert to Group'),
function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet')
}
}

View File

@ -2,11 +2,11 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.model.bean import getlist
from webnotes import msgprint, _
import frappe
from frappe.model.bean import getlist
from frappe import msgprint, _
from webnotes.utils.nestedset import DocTypeNestedSet
from frappe.utils.nestedset import DocTypeNestedSet
class DocType(DocTypeNestedSet):
def __init__(self,d,dl):
@ -14,7 +14,7 @@ class DocType(DocTypeNestedSet):
self.nsm_parent_field = 'parent_cost_center'
def autoname(self):
company_abbr = webnotes.conn.sql("select abbr from tabCompany where name=%s",
company_abbr = frappe.conn.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 webnotes.conn.get_value("GL Entry", {"cost_center": self.doc.name})
return frappe.conn.get_value("GL Entry", {"cost_center": self.doc.name})
def check_if_child_exists(self):
return webnotes.conn.sql("select name from `tabCost Center` where \
return frappe.conn.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 webnotes.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.conn.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:
webnotes.conn.set_value("Cost Center", newdn, "cost_center_name",
frappe.conn.set_value("Cost Center", newdn, "cost_center_name",
" - ".join(newdn.split(" - ")[:-1]))
else:
super(DocType, self).after_rename(olddn, newdn, merge)

View File

@ -8,12 +8,12 @@ $.extend(cur_frm.cscript, {
this.frm.toggle_enable('year_end_date', doc.__islocal)
if (!doc.__islocal && (doc.name != sys_defaults.fiscal_year)) {
this.frm.add_custom_button(wn._("Set as Default"), this.frm.cscript.set_as_default);
this.frm.set_intro(wn._("To set this Fiscal Year as Default, click on 'Set as Default'"));
this.frm.add_custom_button(frappe._("Set as Default"), this.frm.cscript.set_as_default);
this.frm.set_intro(frappe._("To set this Fiscal Year as Default, click on 'Set as Default'"));
} else this.frm.set_intro("");
},
set_as_default: function() {
return wn.call({
return frappe.call({
doc: cur_frm.doc,
method: "set_as_default"
});
@ -22,7 +22,7 @@ $.extend(cur_frm.cscript, {
var me = this;
year_end_date =
wn.datetime.add_days(wn.datetime.add_months(this.frm.doc.year_start_date, 12), -1);
frappe.datetime.add_days(frappe.datetime.add_months(this.frm.doc.year_start_date, 12), -1);
this.frm.set_value("year_end_date", year_end_date);
},
});

View File

@ -2,44 +2,44 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import msgprint, _
from webnotes.utils import getdate
import frappe
from frappe import msgprint, _
from frappe.utils import getdate
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def set_as_default(self):
webnotes.conn.set_value("Global Defaults", None, "current_fiscal_year", self.doc.name)
webnotes.get_obj("Global Defaults").on_update()
frappe.conn.set_value("Global Defaults", None, "current_fiscal_year", self.doc.name)
frappe.get_obj("Global Defaults").on_update()
# clear cache
webnotes.clear_cache()
frappe.clear_cache()
msgprint(self.doc.name + _(""" is now the default Fiscal Year. \
Please refresh your browser for the change to take effect."""))
def validate(self):
year_start_end_dates = webnotes.conn.sql("""select year_start_date, year_end_date
year_start_end_dates = frappe.conn.sql("""select year_start_date, year_end_date
from `tabFiscal Year` where name=%s""", (self.doc.name))
if year_start_end_dates:
if getdate(self.doc.year_start_date) != year_start_end_dates[0][0] or getdate(self.doc.year_end_date) != year_start_end_dates[0][1]:
webnotes.throw(_("Cannot change Year Start Date and Year End Date once the Fiscal Year is saved."))
frappe.throw(_("Cannot change Year Start Date and Year End Date once the Fiscal Year is saved."))
def on_update(self):
# validate year start date and year end date
if getdate(self.doc.year_start_date) > getdate(self.doc.year_end_date):
webnotes.throw(_("Year Start Date should not be greater than Year End Date"))
frappe.throw(_("Year Start Date should not be greater than Year End Date"))
if (getdate(self.doc.year_end_date) - getdate(self.doc.year_start_date)).days > 366:
webnotes.throw(_("Year Start Date and Year End Date are not within Fiscal Year."))
frappe.throw(_("Year Start Date and Year End Date are not within Fiscal Year."))
year_start_end_dates = webnotes.conn.sql("""select name, year_start_date, year_end_date
year_start_end_dates = frappe.conn.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:
if (getdate(self.doc.year_start_date) == ysd and getdate(self.doc.year_end_date) == yed) \
and (not webnotes.flags.in_test):
webnotes.throw(_("Year Start Date and Year End Date are already set in Fiscal Year: ") + fiscal_year)
and (not frappe.flags.in_test):
frappe.throw(_("Year Start Date and Year End Date are already set in Fiscal Year: ") + fiscal_year)

View File

@ -2,10 +2,10 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
from webnotes.utils import flt, fmt_money, getdate
from webnotes import _
from frappe.utils import flt, fmt_money, getdate
from frappe import _
class DocType:
def __init__(self,d,dl):
@ -34,17 +34,17 @@ class DocType:
mandatory = ['account','remarks','voucher_type','voucher_no','fiscal_year','company']
for k in mandatory:
if not self.doc.fields.get(k):
webnotes.throw(k + _(" is mandatory for GL Entry"))
frappe.throw(k + _(" is mandatory for GL Entry"))
# Zero value transaction is not allowed
if not (flt(self.doc.debit) or flt(self.doc.credit)):
webnotes.throw(_("GL Entry: Debit or Credit amount is mandatory for ") +
frappe.throw(_("GL Entry: Debit or Credit amount is mandatory for ") +
self.doc.account)
def pl_must_have_cost_center(self):
if webnotes.conn.get_value("Account", self.doc.account, "is_pl_account") == "Yes":
if frappe.conn.get_value("Account", self.doc.account, "is_pl_account") == "Yes":
if not self.doc.cost_center and self.doc.voucher_type != 'Period Closing Voucher':
webnotes.throw(_("Cost Center must be specified for PL Account: ") +
frappe.throw(_("Cost Center must be specified for PL Account: ") +
self.doc.account)
elif self.doc.cost_center:
self.doc.cost_center = None
@ -55,23 +55,23 @@ class DocType:
def check_pl_account(self):
if self.doc.is_opening=='Yes' and \
webnotes.conn.get_value("Account", self.doc.account, "is_pl_account") == "Yes":
webnotes.throw(_("For opening balance entry account can not be a PL account"))
frappe.conn.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 = webnotes.conn.sql("""select group_or_ledger, docstatus, company
ret = frappe.conn.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':
webnotes.throw(_("Account") + ": " + self.doc.account + _(" is not a ledger"))
frappe.throw(_("Account") + ": " + self.doc.account + _(" is not a ledger"))
if ret.docstatus==2:
webnotes.throw(_("Account") + ": " + self.doc.account + _(" is not active"))
frappe.throw(_("Account") + ": " + self.doc.account + _(" is not active"))
if ret.company != self.doc.company:
webnotes.throw(_("Account") + ": " + self.doc.account +
frappe.throw(_("Account") + ": " + self.doc.account +
_(" does not belong to the company") + ": " + self.doc.company)
def validate_cost_center(self):
@ -80,27 +80,27 @@ 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] = webnotes.conn.get_value(
self.cost_center_company[self.doc.cost_center] = frappe.conn.get_value(
"Cost Center", self.doc.cost_center, "company")
return self.cost_center_company[self.doc.cost_center]
if self.doc.cost_center and _get_cost_center_company() != self.doc.company:
webnotes.throw(_("Cost Center") + ": " + self.doc.cost_center +
frappe.throw(_("Cost Center") + ": " + self.doc.cost_center +
_(" does not belong to the company") + ": " + self.doc.company)
def check_negative_balance(account, adv_adj=False):
if not adv_adj and account:
account_details = webnotes.conn.get_value("Account", account,
account_details = frappe.conn.get_value("Account", account,
["allow_negative_balance", "debit_or_credit"], as_dict=True)
if not account_details["allow_negative_balance"]:
balance = webnotes.conn.sql("""select sum(debit) - sum(credit) from `tabGL Entry`
balance = frappe.conn.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])
if flt(balance) < 0:
webnotes.throw(_("Negative balance is not allowed for account ") + account)
frappe.throw(_("Negative balance is not allowed for account ") + account)
def check_freezing_date(posting_date, adv_adj=False):
"""
@ -108,17 +108,17 @@ def check_freezing_date(posting_date, adv_adj=False):
except authorized person
"""
if not adv_adj:
acc_frozen_upto = webnotes.conn.get_value('Accounts Settings', None, 'acc_frozen_upto')
acc_frozen_upto = frappe.conn.get_value('Accounts Settings', None, 'acc_frozen_upto')
if acc_frozen_upto:
bde_auth_role = webnotes.conn.get_value( 'Accounts Settings', None,'bde_auth_role')
bde_auth_role = frappe.conn.get_value( 'Accounts Settings', None,'bde_auth_role')
if getdate(posting_date) <= getdate(acc_frozen_upto) \
and not bde_auth_role in webnotes.user.get_roles():
webnotes.throw(_("You are not authorized to do/modify back dated entries before ")
and not bde_auth_role in frappe.user.get_roles():
frappe.throw(_("You are not authorized to do/modify back dated entries before ")
+ getdate(acc_frozen_upto).strftime('%d-%m-%Y'))
def update_outstanding_amt(account, against_voucher_type, against_voucher, on_cancel=False):
# get final outstanding amt
bal = flt(webnotes.conn.sql("""select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
bal = flt(frappe.conn.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(webnotes.conn.sql("""
against_voucher_amount = flt(frappe.conn.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, '') = ''""",
@ -137,23 +137,23 @@ def update_outstanding_amt(account, against_voucher_type, against_voucher, on_ca
# Validation : Outstanding can not be negative
if bal < 0 and not on_cancel:
webnotes.throw(_("Outstanding for Voucher ") + against_voucher + _(" will become ") +
frappe.throw(_("Outstanding for Voucher ") + against_voucher + _(" will become ") +
fmt_money(bal) + _(". Outstanding cannot be less than zero. \
Please match exact outstanding."))
# Update outstanding amt on against voucher
if against_voucher_type in ["Sales Invoice", "Purchase Invoice"]:
webnotes.conn.sql("update `tab%s` set outstanding_amount=%s where name='%s'" %
frappe.conn.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 = webnotes.conn.get_value("Account", account, "freeze_account")
frozen_account = frappe.conn.get_value("Account", account, "freeze_account")
if frozen_account == 'Yes' and not adv_adj:
frozen_accounts_modifier = webnotes.conn.get_value( 'Accounts Settings', None,
frozen_accounts_modifier = frappe.conn.get_value( 'Accounts Settings', None,
'frozen_accounts_modifier')
if not frozen_accounts_modifier:
webnotes.throw(account + _(" is a frozen account. Either make the account active or assign role in Accounts Settings who can create / modify entries against this account"))
elif frozen_accounts_modifier not in webnotes.user.get_roles():
webnotes.throw(account + _(" is a frozen account. To create / edit transactions against this account, you need role") \
frappe.throw(account + _(" is a frozen account. Either make the account active or assign role in Accounts Settings who can create / modify entries against this account"))
elif frozen_accounts_modifier not in frappe.user.get_roles():
frappe.throw(account + _(" is a frozen account. To create / edit transactions against this account, you need role") \
+ ": " + frozen_accounts_modifier)

View File

@ -1,9 +1,9 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.provide("erpnext.accounts");
frappe.provide("erpnext.accounts");
erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({
erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
onload: function() {
this.load_defaults();
this.setup_queries();
@ -11,10 +11,10 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({
load_defaults: function() {
if(this.frm.doc.__islocal && this.frm.doc.company) {
wn.model.set_default_values(this.frm.doc);
$.each(wn.model.get_doclist(this.frm.doc.doctype,
frappe.model.set_default_values(this.frm.doc);
$.each(frappe.model.get_doclist(this.frm.doc.doctype,
this.frm.doc.name, {parentfield: "entries"}), function(i, jvd) {
wn.model.set_default_values(jvd);
frappe.model.set_default_values(jvd);
}
);
@ -27,7 +27,7 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({
$.each(["account", "cost_center"], function(i, fieldname) {
me.frm.set_query(fieldname, "entries", function() {
wn.model.validate_missing(me.frm.doc, "company");
frappe.model.validate_missing(me.frm.doc, "company");
return {
filters: {
company: me.frm.doc.company,
@ -40,8 +40,8 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({
$.each([["against_voucher", "Purchase Invoice", "credit_to"],
["against_invoice", "Sales Invoice", "debit_to"]], function(i, opts) {
me.frm.set_query(opts[0], "entries", function(doc, cdt, cdn) {
var jvd = wn.model.get_doc(cdt, cdn);
wn.model.validate_missing(jvd, "account");
var jvd = frappe.model.get_doc(cdt, cdn);
frappe.model.validate_missing(jvd, "account");
return {
filters: [
[opts[1], opts[2], "=", jvd.account],
@ -53,8 +53,8 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({
});
this.frm.set_query("against_jv", "entries", function(doc, cdt, cdn) {
var jvd = wn.model.get_doc(cdt, cdn);
wn.model.validate_missing(jvd, "account");
var jvd = frappe.model.get_doc(cdt, cdn);
frappe.model.validate_missing(jvd, "account");
return {
query: "accounts.doctype.journal_voucher.journal_voucher.get_against_jv",
@ -64,7 +64,7 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({
},
against_voucher: function(doc, cdt, cdn) {
var d = wn.model.get_doc(cdt, cdn);
var d = frappe.model.get_doc(cdt, cdn);
if (d.against_voucher && !flt(d.debit)) {
this.get_outstanding({
'doctype': 'Purchase Invoice',
@ -74,7 +74,7 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({
},
against_invoice: function(doc, cdt, cdn) {
var d = wn.model.get_doc(cdt, cdn);
var d = frappe.model.get_doc(cdt, cdn);
if (d.against_invoice && !flt(d.credit)) {
this.get_outstanding({
'doctype': 'Sales Invoice',
@ -84,7 +84,7 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({
},
against_jv: function(doc, cdt, cdn) {
var d = wn.model.get_doc(cdt, cdn);
var d = frappe.model.get_doc(cdt, cdn);
if (d.against_jv && !flt(d.credit) && !flt(d.debit)) {
this.get_outstanding({
'doctype': 'Journal Voucher',
@ -115,15 +115,15 @@ cur_frm.cscript.refresh = function(doc) {
erpnext.hide_naming_series();
cur_frm.cscript.voucher_type(doc);
if(doc.docstatus==1) {
cur_frm.appframe.add_button(wn._('View Ledger'), function() {
wn.route_options = {
cur_frm.appframe.add_button(frappe._('View Ledger'), function() {
frappe.route_options = {
"voucher_no": doc.name,
"from_date": doc.posting_date,
"to_date": doc.posting_date,
"company": doc.company,
group_by_voucher: 0
};
wn.set_route("query-report", "General Ledger");
frappe.set_route("query-report", "General Ledger");
}, "icon-table");
}
}
@ -166,7 +166,7 @@ cur_frm.cscript.get_balance = function(doc,dt,dn) {
cur_frm.cscript.account = function(doc,dt,dn) {
var d = locals[dt][dn];
if(d.account) {
return wn.call({
return frappe.call({
method: "erpnext.accounts.utils.get_balance_on",
args: {account: d.account, date: doc.posting_date},
callback: function(r) {
@ -187,20 +187,20 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){
cur_frm.pformat.print_heading = doc.select_print_heading;
}
else
cur_frm.pformat.print_heading = wn._("Journal Voucher");
cur_frm.pformat.print_heading = frappe._("Journal Voucher");
}
cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
cur_frm.set_df_property("cheque_no", "reqd", doc.voucher_type=="Bank Voucher");
cur_frm.set_df_property("cheque_date", "reqd", doc.voucher_type=="Bank Voucher");
if(wn.model.get("Journal Voucher Detail", {"parent":doc.name}).length!==0 // too late
if(frappe.model.get("Journal Voucher Detail", {"parent":doc.name}).length!==0 // too late
|| !doc.company) // too early
return;
var update_jv_details = function(doc, r) {
$.each(r.message, function(i, d) {
var jvdetail = wn.model.add_child(doc, "Journal Voucher Detail", "entries");
var jvdetail = frappe.model.add_child(doc, "Journal Voucher Detail", "entries");
jvdetail.account = d.account;
jvdetail.balance = d.balance;
});
@ -208,7 +208,7 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
}
if(in_list(["Bank Voucher", "Cash Voucher"], doc.voucher_type)) {
return wn.call({
return frappe.call({
type: "GET",
method: "erpnext.accounts.doctype.journal_voucher.journal_voucher.get_default_bank_cash_account",
args: {
@ -222,14 +222,14 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
}
})
} else if(doc.voucher_type=="Opening Entry") {
return wn.call({
return frappe.call({
type:"GET",
method: "erpnext.accounts.doctype.journal_voucher.journal_voucher.get_opening_accounts",
args: {
"company": doc.company
},
callback: function(r) {
wn.model.clear_table("Journal Voucher Detail", "Journal Voucher",
frappe.model.clear_table("Journal Voucher Detail", "Journal Voucher",
doc.name, "entries");
if(r.message) {
update_jv_details(doc, r);

View File

@ -2,12 +2,12 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
from webnotes.utils import cint, cstr, flt, fmt_money, formatdate, getdate
from webnotes.model.doc import addchild
from webnotes.model.bean import getlist
from webnotes import msgprint, _
from frappe.utils import cint, cstr, flt, fmt_money, formatdate, getdate
from frappe.model.doc import addchild
from frappe.model.bean import getlist
from frappe import msgprint, _
from erpnext.setup.utils import get_company_currency
from erpnext.controllers.accounts_controller import AccountsController
@ -54,7 +54,7 @@ class DocType(AccountsController):
def on_trash(self):
pass
#if self.doc.amended_from:
# webnotes.delete_doc("Journal Voucher", self.doc.amended_from)
# frappe.delete_doc("Journal Voucher", self.doc.amended_from)
def validate_debit_credit(self):
for d in getlist(self.doclist, 'entries'):
@ -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 = webnotes.conn.get_value("Account", d.account, "master_type")
master_type = frappe.conn.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 webnotes.conn.sql("""select name from `tabJournal Voucher Detail`
elif not frappe.conn.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 = webnotes.conn.get_value("Sales Invoice", d.against_invoice, "currency")
currency = frappe.conn.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 = webnotes.conn.sql("""select bill_no, bill_date, currency
bill_no = frappe.conn.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']:
@ -144,7 +144,7 @@ class DocType(AccountsController):
if r:
self.doc.remark = ("\n").join(r)
else:
webnotes.msgprint("User Remarks is mandatory", raise_exception=1)
frappe.msgprint("User Remarks is mandatory", raise_exception=1)
def set_aging_date(self):
if self.doc.is_opening != 'Yes':
@ -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 = webnotes.conn.get_value("Account", d.account, "account_type")
account_type = frappe.conn.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 = webnotes.conn.get_value("Account", d.account,
account_type, master_type = frappe.conn.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 = webnotes.conn.get_value(master_type,
self.doc.pay_to_recd_from = frappe.conn.get_value(master_type,
' - '.join(d.account.split(' - ')[:-1]),
master_type == 'Customer' and 'customer_name' or 'supplier_name')
@ -179,7 +179,7 @@ class DocType(AccountsController):
company_currency = get_company_currency(self.doc.company)
amt = flt(d.debit) and d.debit or d.credit
self.doc.total_amount = company_currency + ' ' + cstr(amt)
from webnotes.utils import money_in_words
from frappe.utils import money_in_words
self.doc.total_amount_in_words = money_in_words(amt, company_currency)
def check_credit_days(self):
@ -190,7 +190,7 @@ class DocType(AccountsController):
if date_diff <= 0: return
# Get List of Customer Account
acc_list = filter(lambda d: webnotes.conn.get_value("Account", d.account,
acc_list = filter(lambda d: frappe.conn.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(webnotes.conn.get_value("Account", ac, "credit_days"))
self.credit_days_for[ac] = cint(frappe.conn.get_value("Account", ac, "credit_days"))
if not self.credit_days_for[ac]:
if self.credit_days_global==-1:
self.credit_days_global = cint(webnotes.conn.get_value("Company",
self.credit_days_global = cint(frappe.conn.get_value("Company",
self.doc.company, "credit_days"))
return self.credit_days_global
@ -218,25 +218,25 @@ class DocType(AccountsController):
self.is_approving_authority = 0
# Fetch credit controller role
approving_authority = webnotes.conn.get_value("Global Defaults", None,
approving_authority = frappe.conn.get_value("Global Defaults", None,
"credit_controller")
# Check logged-in user is authorized
if approving_authority in webnotes.user.get_roles():
if approving_authority in frappe.user.get_roles():
self.is_approving_authority = 1
return self.is_approving_authority
def check_account_against_entries(self):
for d in self.doclist.get({"parentfield": "entries"}):
if d.against_invoice and webnotes.conn.get_value("Sales Invoice",
if d.against_invoice and frappe.conn.get_value("Sales Invoice",
d.against_invoice, "debit_to") != d.account:
webnotes.throw(_("Row #") + cstr(d.idx) + ": " +
frappe.throw(_("Row #") + cstr(d.idx) + ": " +
_("Account is not matching with Debit To account of Sales Invoice"))
if d.against_voucher and webnotes.conn.get_value("Purchase Invoice",
if d.against_voucher and frappe.conn.get_value("Purchase Invoice",
d.against_voucher, "credit_to") != d.account:
webnotes.throw(_("Row #") + cstr(d.idx) + ": " +
frappe.throw(_("Row #") + cstr(d.idx) + ": " +
_("Account is not matching with Credit To account of Purchase Invoice"))
def make_gl_entries(self, cancel=0, adv_adj=0):
@ -267,7 +267,7 @@ class DocType(AccountsController):
def check_credit_limit(self):
for d in self.doclist.get({"parentfield": "entries"}):
master_type, master_name = webnotes.conn.get_value("Account", d.account,
master_type, master_name = frappe.conn.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 webnotes.conn.sql("""select name, debit_to, outstanding_amount
return frappe.conn.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 webnotes.conn.sql("""select name, credit_to, outstanding_amount
return frappe.conn.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)
@webnotes.whitelist()
@frappe.whitelist()
def get_default_bank_cash_account(company, voucher_type):
from erpnext.accounts.utils import get_balance_on
account = webnotes.conn.get_value("Company", company,
account = frappe.conn.get_value("Company", company,
voucher_type=="Bank Voucher" and "default_bank_account" or "default_cash_account")
if account:
return {
@ -347,10 +347,10 @@ def get_default_bank_cash_account(company, voucher_type):
"balance": get_balance_on(account)
}
@webnotes.whitelist()
@frappe.whitelist()
def get_payment_entry_from_sales_invoice(sales_invoice):
from erpnext.accounts.utils import get_balance_on
si = webnotes.bean("Sales Invoice", sales_invoice)
si = frappe.bean("Sales Invoice", sales_invoice)
jv = get_payment_entry(si.doc)
jv.doc.remark = 'Payment received against Sales Invoice %(name)s. %(remarks)s' % si.doc.fields
@ -365,10 +365,10 @@ def get_payment_entry_from_sales_invoice(sales_invoice):
return [d.fields for d in jv.doclist]
@webnotes.whitelist()
@frappe.whitelist()
def get_payment_entry_from_purchase_invoice(purchase_invoice):
from erpnext.accounts.utils import get_balance_on
pi = webnotes.bean("Purchase Invoice", purchase_invoice)
pi = frappe.bean("Purchase Invoice", purchase_invoice)
jv = get_payment_entry(pi.doc)
jv.doc.remark = 'Payment against Purchase Invoice %(name)s. %(remarks)s' % pi.doc.fields
@ -386,7 +386,7 @@ def get_payment_entry_from_purchase_invoice(purchase_invoice):
def get_payment_entry(doc):
bank_account = get_default_bank_cash_account(doc.company, "Bank Voucher")
jv = webnotes.new_bean('Journal Voucher')
jv = frappe.new_bean('Journal Voucher')
jv.doc.voucher_type = 'Bank Voucher'
jv.doc.company = doc.company
@ -408,42 +408,42 @@ def get_payment_entry(doc):
return jv
@webnotes.whitelist()
@frappe.whitelist()
def get_opening_accounts(company):
"""get all balance sheet accounts for opening entry"""
from erpnext.accounts.utils import get_balance_on
accounts = webnotes.conn.sql_list("""select name from tabAccount
accounts = frappe.conn.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 webnotes.conn.sql("""select name, credit_to, outstanding_amount, bill_no, bill_date
return frappe.conn.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 webnotes.conn.sql("""select name, debit_to, outstanding_amount
return frappe.conn.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 webnotes.conn.sql("""select jv.name, jv.posting_date, jv.user_remark
return frappe.conn.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""" %
("%s", searchfield, "%s", "%s", "%s"),
(filters["account"], "%%%s%%" % txt, start, page_len))
@webnotes.whitelist()
@frappe.whitelist()
def get_outstanding(args):
args = eval(args)
if args.get("doctype") == "Journal Voucher" and args.get("account"):
against_jv_amount = webnotes.conn.sql("""
against_jv_amount = frappe.conn.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(webnotes.conn.get_value("Sales Invoice", args["docname"],
"credit": flt(frappe.conn.get_value("Sales Invoice", args["docname"],
"outstanding_amount"))
}
elif args.get("doctype") == "Purchase Invoice":
return {
"debit": flt(webnotes.conn.get_value("Purchase Invoice", args["docname"],
"debit": flt(frappe.conn.get_value("Purchase Invoice", args["docname"],
"outstanding_amount"))
}

View File

@ -4,40 +4,40 @@
from __future__ import unicode_literals
import unittest
import webnotes
import frappe
class TestJournalVoucher(unittest.TestCase):
def test_journal_voucher_with_against_jv(self):
self.clear_account_balance()
jv_invoice = webnotes.bean(copy=test_records[2])
jv_invoice = frappe.bean(copy=test_records[2])
jv_invoice.insert()
jv_invoice.submit()
self.assertTrue(not webnotes.conn.sql("""select name from `tabJournal Voucher Detail`
self.assertTrue(not frappe.conn.sql("""select name from `tabJournal Voucher Detail`
where against_jv=%s""", jv_invoice.doc.name))
jv_payment = webnotes.bean(copy=test_records[0])
jv_payment = frappe.bean(copy=test_records[0])
jv_payment.doclist[1].against_jv = jv_invoice.doc.name
jv_payment.insert()
jv_payment.submit()
self.assertTrue(webnotes.conn.sql("""select name from `tabJournal Voucher Detail`
self.assertTrue(frappe.conn.sql("""select name from `tabJournal Voucher Detail`
where against_jv=%s""", jv_invoice.doc.name))
self.assertTrue(webnotes.conn.sql("""select name from `tabJournal Voucher Detail`
self.assertTrue(frappe.conn.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 webnotes.conn.sql("""select name from `tabJournal Voucher Detail`
self.assertTrue(not frappe.conn.sql("""select name from `tabJournal Voucher Detail`
where against_jv=%s""", jv_invoice.doc.name))
def test_jv_against_stock_account(self):
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
set_perpetual_inventory()
jv = webnotes.bean(copy=test_records[0])
jv = frappe.bean(copy=test_records[0])
jv.doclist[1].account = "_Test Warehouse - _TC"
jv.insert()
@ -47,25 +47,25 @@ class TestJournalVoucher(unittest.TestCase):
set_perpetual_inventory(0)
def test_monthly_budget_crossed_ignore(self):
webnotes.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore")
frappe.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore")
self.clear_account_balance()
jv = webnotes.bean(copy=test_records[0])
jv = frappe.bean(copy=test_records[0])
jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
jv.doclist[2].debit = 20000.0
jv.doclist[1].credit = 20000.0
jv.insert()
jv.submit()
self.assertTrue(webnotes.conn.get_value("GL Entry",
self.assertTrue(frappe.conn.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
webnotes.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop")
frappe.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop")
self.clear_account_balance()
jv = webnotes.bean(copy=test_records[0])
jv = frappe.bean(copy=test_records[0])
jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
jv.doclist[2].debit = 20000.0
@ -74,16 +74,16 @@ class TestJournalVoucher(unittest.TestCase):
self.assertRaises(BudgetError, jv.submit)
webnotes.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore")
frappe.conn.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()
webnotes.conn.set_value("Company", "_Test Company", "yearly_bgt_flag", "Stop")
frappe.conn.set_value("Company", "_Test Company", "yearly_bgt_flag", "Stop")
jv = webnotes.bean(copy=test_records[0])
jv = frappe.bean(copy=test_records[0])
jv.doc.posting_date = "2013-08-12"
jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
@ -93,39 +93,39 @@ class TestJournalVoucher(unittest.TestCase):
self.assertRaises(BudgetError, jv.submit)
webnotes.conn.set_value("Company", "_Test Company", "yearly_bgt_flag", "Ignore")
frappe.conn.set_value("Company", "_Test Company", "yearly_bgt_flag", "Ignore")
def test_monthly_budget_on_cancellation(self):
from erpnext.accounts.utils import BudgetError
webnotes.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop")
frappe.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Stop")
self.clear_account_balance()
jv = webnotes.bean(copy=test_records[0])
jv = frappe.bean(copy=test_records[0])
jv.doclist[1].account = "_Test Account Cost for Goods Sold - _TC"
jv.doclist[1].cost_center = "_Test Cost Center - _TC"
jv.doclist[1].credit = 30000.0
jv.doclist[2].debit = 30000.0
jv.submit()
self.assertTrue(webnotes.conn.get_value("GL Entry",
self.assertTrue(frappe.conn.get_value("GL Entry",
{"voucher_type": "Journal Voucher", "voucher_no": jv.doc.name}))
jv1 = webnotes.bean(copy=test_records[0])
jv1 = frappe.bean(copy=test_records[0])
jv1.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
jv1.doclist[2].cost_center = "_Test Cost Center - _TC"
jv1.doclist[2].debit = 40000.0
jv1.doclist[1].credit = 40000.0
jv1.submit()
self.assertTrue(webnotes.conn.get_value("GL Entry",
self.assertTrue(frappe.conn.get_value("GL Entry",
{"voucher_type": "Journal Voucher", "voucher_no": jv1.doc.name}))
self.assertRaises(BudgetError, jv.cancel)
webnotes.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore")
frappe.conn.set_value("Company", "_Test Company", "monthly_bgt_flag", "Ignore")
def clear_account_balance(self):
webnotes.conn.sql("""delete from `tabGL Entry`""")
frappe.conn.sql("""delete from `tabGL Entry`""")
test_records = [

View File

@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
class DocType:
def __init__(self, d, dl):

View File

@ -2,9 +2,9 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt, get_first_day, get_last_day, has_common
import webnotes.defaults
import frappe
from frappe.utils import flt, get_first_day, get_last_day, has_common
import frappe.defaults
from erpnext.accounts.utils import get_balance_on
class DocType:
@ -33,7 +33,7 @@ class DocType:
ret['company'] = get_companies()
#--- to get fiscal year and start_date of that fiscal year -----
res = webnotes.conn.sql("select name, year_start_date from `tabFiscal Year`")
res = frappe.conn.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 = webnotes.conn.sql("select MONTH(year_start_date) from `tabFiscal Year` where name = %s",(webnotes.defaults.get_global_default("fiscal_year")))
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 = 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])
@ -49,7 +49,7 @@ class DocType:
ret['month'] = mon
# get MIS Type on basis of roles of session user
self.roles = webnotes.user.get_roles()
self.roles = frappe.user.get_roles()
if has_common(self.roles, ['Sales Manager']):
type.append('Sales')
if has_common(self.roles, ['Purchase Manager']):
@ -76,7 +76,7 @@ class DocType:
return self.return_data
def get_children(self, parent_account, level, pl, company, fy):
cl = webnotes.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.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))
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 = webnotes.conn.sql("select year_start_date from `tabFiscal Year` where name=%s", year)
ysd = frappe.conn.sql("select year_start_date from `tabFiscal Year` where name=%s", year)
ysd = ysd and ysd[0][0] or ''
self.ysd = ysd

View File

@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
class DocType:
def __init__(self, d, dl):

View File

@ -13,15 +13,15 @@ cur_frm.cscript.onload_post_render = function(doc) {
cur_frm.cscript.refresh = function(doc) {
cur_frm.set_intro("");
if(!doc.voucher_no) {
cur_frm.set_intro(wn._("Select the Invoice against which you want to allocate payments."));
cur_frm.set_intro(frappe._("Select the Invoice against which you want to allocate payments."));
} else {
cur_frm.set_intro(wn._("Set allocated amount against each Payment Entry and click 'Allocate'."));
cur_frm.set_intro(frappe._("Set allocated amount against each Payment Entry and click 'Allocate'."));
}
}
cur_frm.fields_dict.voucher_no.get_query = function(doc) {
// TO-do: check for pos, it should not come
if (!doc.account) msgprint(wn._("Please select Account first"));
if (!doc.account) msgprint(frappe._("Please select Account first"));
else {
return {
doctype: doc.voucher_type,
@ -40,7 +40,7 @@ cur_frm.cscript.voucher_no =function(doc, cdt, cdn) {
}
cur_frm.cscript.account = function(doc, cdt, cdn) {
return wn.call({
return frappe.call({
doc: this.frm.doc,
method: "set_account_type",
callback: function(r) {

View File

@ -2,12 +2,12 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
from webnotes.utils import flt
from webnotes.model.doc import addchild
from webnotes.model.bean import getlist
from webnotes import msgprint
from frappe.utils import flt
from frappe.model.doc import addchild
from frappe.model.bean import getlist
from frappe import msgprint
class DocType:
def __init__(self, doc, doclist):
@ -16,17 +16,17 @@ class DocType:
def set_account_type(self):
self.doc.account_type = self.doc.account and \
webnotes.conn.get_value("Account", self.doc.account, "debit_or_credit").lower() or ""
frappe.conn.get_value("Account", self.doc.account, "debit_or_credit").lower() or ""
def get_voucher_details(self):
total_amount = webnotes.conn.sql("""select sum(%s) from `tabGL Entry`
total_amount = frappe.conn.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 = webnotes.conn.sql("""
reconciled_payment = frappe.conn.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 = webnotes.conn.sql("""
gle = frappe.conn.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 webnotes.conn.sql("""select name from `tab%s`
if not self.doc.voucher_no or not frappe.conn.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 webnotes.conn.sql("""select gle.voucher_no, gle.posting_date,
return frappe.conn.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'

View File

@ -3,6 +3,6 @@
from __future__ import unicode_literals
import unittest
import webnotes
import frappe
test_records = []

View File

@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
class DocType:
def __init__(self, d, dl):

View File

@ -2,9 +2,9 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, flt, getdate
from webnotes import msgprint, _
import frappe
from frappe.utils import cstr, flt, getdate
from frappe import msgprint, _
from erpnext.controllers.accounts_controller import AccountsController
class DocType(AccountsController):
@ -21,30 +21,30 @@ class DocType(AccountsController):
self.make_gl_entries()
def on_cancel(self):
webnotes.conn.sql("""delete from `tabGL Entry`
frappe.conn.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 = webnotes.conn.get_value("Account",
debit_or_credit, is_pl_account = frappe.conn.get_value("Account",
self.doc.closing_account_head, ["debit_or_credit", "is_pl_account"])
if debit_or_credit != 'Credit' or is_pl_account != 'No':
webnotes.throw(_("Account") + ": " + self.doc.closing_account_head +
frappe.throw(_("Account") + ": " + self.doc.closing_account_head +
_("must be a Liability account"))
def validate_posting_date(self):
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 = webnotes.conn.sql("""select name from `tabPeriod Closing Voucher`
pce = frappe.conn.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]:
webnotes.throw(_("Another Period Closing Entry") + ": " + cstr(pce[0][0]) +
frappe.throw(_("Another Period Closing Entry") + ": " + cstr(pce[0][0]) +
_("has been made after posting date") + ": " + self.doc.posting_date)
def validate_pl_balances(self):
income_bal = webnotes.conn.sql("""
income_bal = frappe.conn.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 = webnotes.conn.sql("""
expense_bal = frappe.conn.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
@ -64,11 +64,11 @@ class DocType(AccountsController):
expense_bal = expense_bal and expense_bal[0][0] or 0
if not income_bal and not expense_bal:
webnotes.throw(_("Both Income and Expense balances are zero. No Need to make Period Closing Entry."))
frappe.throw(_("Both Income and Expense balances are zero. No Need to make Period Closing Entry."))
def get_pl_balances(self):
"""Get balance for pl accounts"""
return webnotes.conn.sql("""
return frappe.conn.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'

View File

@ -4,30 +4,30 @@
from __future__ import unicode_literals
import unittest
import webnotes
import frappe
class TestPeriodClosingVoucher(unittest.TestCase):
def test_closing_entry(self):
# clear GL Entries
webnotes.conn.sql("""delete from `tabGL Entry`""")
frappe.conn.sql("""delete from `tabGL Entry`""")
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher import test_records as jv_records
jv = webnotes.bean(copy=jv_records[2])
jv = frappe.bean(copy=jv_records[2])
jv.insert()
jv.submit()
jv1 = webnotes.bean(copy=jv_records[0])
jv1 = frappe.bean(copy=jv_records[0])
jv1.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
jv1.doclist[2].debit = 600.0
jv1.doclist[1].credit = 600.0
jv1.insert()
jv1.submit()
pcv = webnotes.bean(copy=test_record)
pcv = frappe.bean(copy=test_record)
pcv.insert()
pcv.submit()
gl_entries = webnotes.conn.sql("""select account, debit, credit
gl_entries = frappe.conn.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)

View File

@ -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:"webnotes.core.doctype.profile.profile.profile_query"}
return{ query:"frappe.core.doctype.profile.profile.profile_query"}
}

View File

@ -2,17 +2,17 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import msgprint, _
from webnotes.utils import cint
import frappe
from frappe import msgprint, _
from frappe.utils import cint
class DocType:
def __init__(self,doc,doclist):
self.doc, self.doclist = doc,doclist
def get_series(self):
import webnotes.model.doctype
docfield = webnotes.model.doctype.get('Sales Invoice')
import frappe.model.doctype
docfield = frappe.model.doctype.get('Sales Invoice')
series = [d.options for d in docfield
if d.doctype == 'DocField' and d.fieldname == 'naming_series']
return series and series[0] or ''
@ -23,7 +23,7 @@ class DocType:
self.validate_all_link_fields()
def check_for_duplicate(self):
res = webnotes.conn.sql("""select name, user from `tabPOS Setting`
res = frappe.conn.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:
@ -35,7 +35,7 @@ class DocType:
(res[0][0], self.doc.company), raise_exception=1)
def validate_expense_account(self):
if cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")) \
if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) \
and not self.doc.expense_account:
msgprint(_("Expense Account is mandatory"), raise_exception=1)
@ -46,19 +46,19 @@ class DocType:
for link_dt, dn_list in accounts.items():
for link_dn in dn_list:
if link_dn and not webnotes.conn.exists({"doctype": link_dt,
if link_dn and not frappe.conn.exists({"doctype": link_dt,
"company": self.doc.company, "name": link_dn}):
webnotes.throw(link_dn +_(" does not belong to ") + self.doc.company)
frappe.throw(link_dn +_(" does not belong to ") + self.doc.company)
def on_update(self):
webnotes.defaults.clear_default("is_pos")
frappe.defaults.clear_default("is_pos")
pos_view_users = webnotes.conn.sql_list("""select user from `tabPOS Setting`""")
pos_view_users = frappe.conn.sql_list("""select user from `tabPOS Setting`""")
for user in pos_view_users:
if user:
webnotes.defaults.set_user_default("is_pos", 1, user)
frappe.defaults.set_user_default("is_pos", 1, user)
else:
webnotes.defaults.set_global_default("is_pos", 1)
frappe.defaults.set_global_default("is_pos", 1)
def on_trash(self):
self.on_update()

View File

@ -5,7 +5,7 @@ cur_frm.cscript.tname = "Purchase Invoice Item";
cur_frm.cscript.fname = "entries";
cur_frm.cscript.other_fname = "other_charges";
wn.provide("erpnext.accounts");
frappe.provide("erpnext.accounts");
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
{% include 'accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %}
{% include 'accounts/doctype/sales_invoice/pos.js' %}
@ -27,25 +27,25 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
// Show / Hide button
if(doc.docstatus==1 && doc.outstanding_amount > 0)
this.frm.add_custom_button(wn._('Make Payment Entry'), this.make_bank_voucher);
this.frm.add_custom_button(frappe._('Make Payment Entry'), this.make_bank_voucher);
if(doc.docstatus==1) {
cur_frm.appframe.add_button(wn._('View Ledger'), function() {
wn.route_options = {
cur_frm.appframe.add_button(frappe._('View Ledger'), function() {
frappe.route_options = {
"voucher_no": doc.name,
"from_date": doc.posting_date,
"to_date": doc.posting_date,
"company": doc.company,
group_by_voucher: 0
};
wn.set_route("query-report", "General Ledger");
frappe.set_route("query-report", "General Ledger");
}, "icon-table");
}
if(doc.docstatus===0) {
cur_frm.add_custom_button(wn._('From Purchase Order'),
cur_frm.add_custom_button(frappe._('From Purchase Order'),
function() {
wn.model.map_current_doc({
frappe.model.map_current_doc({
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice",
source_doctype: "Purchase Order",
get_query_filters: {
@ -58,9 +58,9 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
})
});
cur_frm.add_custom_button(wn._('From Purchase Receipt'),
cur_frm.add_custom_button(frappe._('From Purchase Receipt'),
function() {
wn.model.map_current_doc({
frappe.model.map_current_doc({
method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
source_doctype: "Purchase Receipt",
get_query_filters: {
@ -108,7 +108,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
},
entries_add: function(doc, cdt, cdn) {
var row = wn.model.get_doc(cdt, cdn);
var row = frappe.model.get_doc(cdt, cdn);
this.frm.script_manager.copy_from_first_row("entries", row, ["expense_account", "cost_center"]);
}
});
@ -121,14 +121,14 @@ cur_frm.cscript.is_opening = function(doc, dt, dn) {
}
cur_frm.cscript.make_bank_voucher = function() {
return wn.call({
return frappe.call({
method: "erpnext.accounts.doctype.journal_voucher.journal_voucher.get_payment_entry_from_purchase_invoice",
args: {
"purchase_invoice": cur_frm.doc.name,
},
callback: function(r) {
var doclist = wn.model.sync(r.message);
wn.set_route("Form", doclist[0].doctype, doclist[0].name);
var doclist = frappe.model.sync(r.message);
frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
}
});
}
@ -229,5 +229,5 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){
cur_frm.pformat.print_heading = doc.select_print_heading;
}
else
cur_frm.pformat.print_heading = wn._("Purchase Invoice");
cur_frm.pformat.print_heading = frappe._("Purchase Invoice");
}

View File

@ -2,15 +2,15 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
from webnotes.utils import add_days, cint, cstr, flt, formatdate
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint, _
from frappe.utils import add_days, cint, cstr, flt, formatdate
from frappe.model.bean import getlist
from frappe.model.code import get_obj
from frappe import msgprint, _
from erpnext.setup.utils import get_company_currency
import webnotes.defaults
import frappe.defaults
from erpnext.controllers.buying_controller import BuyingController
from erpnext.accounts.party import get_party_account, get_due_date
@ -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 = webnotes.conn.sql("select docstatus,is_purchase_item from tabItem where name = %s",d.item_code)
valid_item = frappe.conn.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 = webnotes.conn.sql("""select bill_no, name, ifnull(is_opening,'') from `tabPurchase Invoice`
b_no = frappe.conn.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 = webnotes.conn.sql("select debit_or_credit, is_pl_account from tabAccount where name = %s",
acc = frappe.conn.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 = webnotes.conn.sql("select master_name from `tabAccount` where name = %s", self.doc.credit_to)
acc_head = frappe.conn.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 = webnotes.conn.sql("select name from `tabPurchase Order` where status = 'Stopped' and name = '%s'" % d.purchase_order)
stopped = frappe.conn.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
@ -165,7 +165,7 @@ class DocType(BuyingController):
}
})
if cint(webnotes.defaults.get_global_default('maintain_same_rate')):
if cint(frappe.defaults.get_global_default('maintain_same_rate')):
super(DocType, self).validate_with_previous_doc(self.tname, {
"Purchase Order Item": {
"ref_dn_field": "po_detail",
@ -189,7 +189,7 @@ class DocType(BuyingController):
raise Exception
def set_against_expense_account(self):
auto_accounting_for_stock = cint(webnotes.defaults.get_global_default("auto_accounting_for_stock"))
auto_accounting_for_stock = cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
if auto_accounting_for_stock:
stock_not_billed_account = self.get_company_default("stock_received_but_not_billed")
@ -218,14 +218,14 @@ class DocType(BuyingController):
self.doc.against_expense_account = ",".join(against_accounts)
def po_required(self):
if webnotes.conn.get_value("Buying Settings", None, "po_required") == 'Yes':
if frappe.conn.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 webnotes.conn.get_value("Buying Settings", None, "pr_required") == 'Yes':
if frappe.conn.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,13 +238,13 @@ class DocType(BuyingController):
def check_prev_docstatus(self):
for d in getlist(self.doclist,'entries'):
if d.purchase_order:
submitted = webnotes.conn.sql("select name from `tabPurchase Order` where docstatus = 1 and name = '%s'" % d.purchase_order)
submitted = frappe.conn.sql("select name from `tabPurchase Order` where docstatus = 1 and name = '%s'" % d.purchase_order)
if not submitted:
webnotes.throw("Purchase Order : "+ cstr(d.purchase_order) +" is not submitted")
frappe.throw("Purchase Order : "+ cstr(d.purchase_order) +" is not submitted")
if d.purchase_receipt:
submitted = webnotes.conn.sql("select name from `tabPurchase Receipt` where docstatus = 1 and name = '%s'" % d.purchase_receipt)
submitted = frappe.conn.sql("select name from `tabPurchase Receipt` where docstatus = 1 and name = '%s'" % d.purchase_receipt)
if not submitted:
webnotes.throw("Purchase Receipt : "+ cstr(d.purchase_receipt) +" is not submitted")
frappe.throw("Purchase Receipt : "+ cstr(d.purchase_receipt) +" is not submitted")
def update_against_document_in_jv(self):
@ -289,7 +289,7 @@ class DocType(BuyingController):
def make_gl_entries(self):
auto_accounting_for_stock = \
cint(webnotes.defaults.get_global_default("auto_accounting_for_stock"))
cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
gl_entries = []
@ -324,7 +324,7 @@ class DocType(BuyingController):
# accumulate valuation tax
if tax.category in ("Valuation", "Valuation and Total") and flt(tax.tax_amount):
if auto_accounting_for_stock and not tax.cost_center:
webnotes.throw(_("Row %(row)s: Cost Center is mandatory \
frappe.throw(_("Row %(row)s: Cost Center is mandatory \
if tax/charges category is Valuation or Valuation and Total" %
{"row": tax.idx}))
valuation_tax.setdefault(tax.cost_center, 0)
@ -414,25 +414,25 @@ class DocType(BuyingController):
def update_raw_material_cost(self):
if self.sub_contracted_items:
for d in self.doclist.get({"parentfield": "entries"}):
rm_cost = webnotes.conn.sql("""select raw_material_cost / quantity
rm_cost = frappe.conn.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(webnotes.conn.get_value(
d.conversion_factor = d.conversion_factor or flt(frappe.conn.get_value(
"UOM Conversion Detail", {"parent": d.item_code, "uom": d.uom},
"conversion_factor")) or 1
d.rm_supp_cost = rm_cost * flt(d.qty) * flt(d.conversion_factor)
@webnotes.whitelist()
@frappe.whitelist()
def get_expense_account(doctype, txt, searchfield, start, page_len, filters):
from erpnext.controllers.queries import get_match_cond
# 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 webnotes.conn.sql("""select tabAccount.name from `tabAccount`
return frappe.conn.sql("""select tabAccount.name from `tabAccount`
where (tabAccount.debit_or_credit="Debit"
or tabAccount.account_type = "Expense Account")
and tabAccount.group_or_ledger="Ledger"

View File

@ -2,7 +2,7 @@
// License: GNU General Public License v3. See license.txt
// render
wn.listview_settings['Purchase Invoice'] = {
frappe.listview_settings['Purchase Invoice'] = {
add_fields: ["`tabPurchase Invoice`.grand_total", "`tabPurchase Invoice`.outstanding_amount"],
add_columns: [{"content":"paid_amount", width:"10%", type:"bar-graph", label: "Paid"}],
prepare_data: function(data) {

View File

@ -4,11 +4,11 @@
from __future__ import unicode_literals
import unittest
import webnotes
import webnotes.model
import frappe
import frappe.model
import json
from webnotes.utils import cint
import webnotes.defaults
from frappe.utils import cint
import frappe.defaults
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
test_dependencies = ["Item", "Cost Center"]
@ -17,9 +17,9 @@ test_ignore = ["Serial No"]
class TestPurchaseInvoice(unittest.TestCase):
def test_gl_entries_without_auto_accounting_for_stock(self):
set_perpetual_inventory(0)
self.assertTrue(not cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")))
self.assertTrue(not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")))
wrapper = webnotes.bean(copy=test_records[0])
wrapper = frappe.bean(copy=test_records[0])
wrapper.run_method("calculate_taxes_and_totals")
wrapper.insert()
wrapper.submit()
@ -37,21 +37,21 @@ class TestPurchaseInvoice(unittest.TestCase):
"_Test Account VAT - _TC": [156.25, 0],
"_Test Account Discount - _TC": [0, 168.03],
}
gl_entries = webnotes.conn.sql("""select account, debit, credit from `tabGL Entry`
gl_entries = frappe.conn.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))
def test_gl_entries_with_auto_accounting_for_stock(self):
set_perpetual_inventory(1)
self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 1)
self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1)
pi = webnotes.bean(copy=test_records[1])
pi = frappe.bean(copy=test_records[1])
pi.run_method("calculate_taxes_and_totals")
pi.insert()
pi.submit()
gl_entries = webnotes.conn.sql("""select account, debit, credit
gl_entries = frappe.conn.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)
@ -73,9 +73,9 @@ class TestPurchaseInvoice(unittest.TestCase):
def test_gl_entries_with_aia_for_non_stock_items(self):
set_perpetual_inventory()
self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 1)
self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1)
pi = webnotes.bean(copy=test_records[1])
pi = frappe.bean(copy=test_records[1])
pi.doclist[1].item_code = "_Test Non Stock Item"
pi.doclist[1].expense_account = "_Test Account Cost for Goods Sold - _TC"
pi.doclist.pop(2)
@ -84,7 +84,7 @@ class TestPurchaseInvoice(unittest.TestCase):
pi.insert()
pi.submit()
gl_entries = webnotes.conn.sql("""select account, debit, credit
gl_entries = frappe.conn.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)
@ -102,7 +102,7 @@ class TestPurchaseInvoice(unittest.TestCase):
set_perpetual_inventory(0)
def test_purchase_invoice_calculation(self):
wrapper = webnotes.bean(copy=test_records[0])
wrapper = frappe.bean(copy=test_records[0])
wrapper.run_method("calculate_taxes_and_totals")
wrapper.insert()
wrapper.load_from_db()
@ -136,7 +136,7 @@ class TestPurchaseInvoice(unittest.TestCase):
self.assertEqual(tax.total, expected_values[i][2])
def test_purchase_invoice_with_subcontracted_item(self):
wrapper = webnotes.bean(copy=test_records[0])
wrapper = frappe.bean(copy=test_records[0])
wrapper.doclist[1].item_code = "_Test FG Item"
wrapper.run_method("calculate_taxes_and_totals")
wrapper.insert()
@ -174,11 +174,11 @@ class TestPurchaseInvoice(unittest.TestCase):
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
import test_records as jv_test_records
jv = webnotes.bean(copy=jv_test_records[1])
jv = frappe.bean(copy=jv_test_records[1])
jv.insert()
jv.submit()
pi = webnotes.bean(copy=test_records[0])
pi = frappe.bean(copy=test_records[0])
pi.doclist.append({
"doctype": "Purchase Invoice Advance",
"parentfield": "advance_allocation_details",
@ -193,17 +193,17 @@ class TestPurchaseInvoice(unittest.TestCase):
pi.submit()
pi.load_from_db()
self.assertTrue(webnotes.conn.sql("""select name from `tabJournal Voucher Detail`
self.assertTrue(frappe.conn.sql("""select name from `tabJournal Voucher Detail`
where against_voucher=%s""", pi.doc.name))
self.assertTrue(webnotes.conn.sql("""select name from `tabJournal Voucher Detail`
self.assertTrue(frappe.conn.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 webnotes.conn.sql("""select name from `tabJournal Voucher Detail`
self.assertTrue(not frappe.conn.sql("""select name from `tabJournal Voucher Detail`
where against_voucher=%s""", pi.doc.name))
test_records = [

View File

@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
class DocType:
def __init__(self, d, dl):

View File

@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
class DocType:
def __init__(self, d, dl):

View File

@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
class DocType:
def __init__(self, d, dl):

View File

@ -4,7 +4,7 @@
{% include "public/js/controllers/accounts.js" %}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.set_footnote(wn.markdown(cur_frm.meta.description));
cur_frm.set_footnote(frappe.markdown(cur_frm.meta.description));
}
// For customizing print
@ -37,7 +37,7 @@ cur_frm.pformat.other_charges= function(doc) {
}
function print_hide(fieldname) {
var doc_field = wn.meta.get_docfield(doc.doctype, fieldname, doc.name);
var doc_field = frappe.meta.get_docfield(doc.doctype, fieldname, doc.name);
return doc_field.print_hide;
}
@ -78,11 +78,11 @@ cur_frm.cscript.add_deduct_tax = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.category && d.add_deduct_tax) {
msgprint(wn._("Please select Category first"));
msgprint(frappe._("Please select Category first"));
d.add_deduct_tax = '';
}
else if(d.category != 'Total' && d.add_deduct_tax == 'Deduct') {
msgprint(wn._("You cannot deduct when category is for 'Valuation' or 'Valuation and Total'"));
msgprint(frappe._("You cannot deduct when category is for 'Valuation' or 'Valuation and Total'"));
d.add_deduct_tax = '';
}
}
@ -91,15 +91,15 @@ cur_frm.cscript.charge_type = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.category && d.charge_type) {
msgprint(wn._("Please select Category first"));
msgprint(frappe._("Please select Category first"));
d.charge_type = '';
}
else if(d.idx == 1 && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')) {
msgprint(wn._("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row"));
msgprint(frappe._("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row"));
d.charge_type = '';
}
else if((d.category == 'Valuation' || d.category == 'Valuation and Total') && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')) {
msgprint(wn._("You cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for valuation. You can select only 'Total' option for previous row amount or previous row total"));
msgprint(frappe._("You cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for valuation. You can select only 'Total' option for previous row amount or previous row total"));
d.charge_type = '';
}
@ -116,16 +116,16 @@ cur_frm.cscript.row_id = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.row_id) {
msgprint(wn._("Please select Charge Type first"));
msgprint(frappe._("Please select Charge Type first"));
d.row_id = '';
}
else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) {
msgprint(wn._("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'"));
msgprint(frappe._("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'"));
d.row_id = '';
}
else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id) {
if(d.row_id >= d.idx){
msgprint(wn._("You cannot Enter Row no. greater than or equal to current row no. for this Charge type"));
msgprint(frappe._("You cannot Enter Row no. greater than or equal to current row no. for this Charge type"));
d.row_id = '';
}
}
@ -157,7 +157,7 @@ cur_frm.cscript.rate = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.rate) {
msgprint(wn._("Please select Charge Type first"));
msgprint(frappe._("Please select Charge Type first"));
d.rate = '';
}
validated = false;
@ -168,11 +168,11 @@ cur_frm.cscript.tax_amount = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.tax_amount) {
msgprint(wn._("Please select Charge Type first"));
msgprint(frappe._("Please select Charge Type first"));
d.tax_amount = '';
}
else if(d.charge_type && d.tax_amount) {
msgprint(wn._("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate"));
msgprint(frappe._("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate"));
d.tax_amount = '';
}

View File

@ -2,11 +2,11 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
from webnotes.model import db_exists
from webnotes.model.bean import copy_doclist
from webnotes.model.code import get_obj
from frappe.model import db_exists
from frappe.model.bean import copy_doclist
from frappe.model.code import get_obj

View File

@ -105,7 +105,7 @@ erpnext.POS = Class.extend({
});
this.wrapper.find('input.discount-amount').on("change", function() {
wn.model.set_value(me.frm.doctype, me.frm.docname, "discount_amount", this.value);
frappe.model.set_value(me.frm.doctype, me.frm.docname, "discount_amount", this.value);
});
this.call_function("remove-items", function() {me.remove_selected_items();});
@ -115,10 +115,10 @@ erpnext.POS = Class.extend({
var me = this;
// Check whether the transaction is "Sales" or "Purchase"
if (wn.meta.has_field(cur_frm.doc.doctype, "customer")) {
if (frappe.meta.has_field(cur_frm.doc.doctype, "customer")) {
this.set_transaction_defaults("Customer", "export");
}
else if (wn.meta.has_field(cur_frm.doc.doctype, "supplier")) {
else if (frappe.meta.has_field(cur_frm.doc.doctype, "supplier")) {
this.set_transaction_defaults("Supplier", "import");
}
},
@ -146,7 +146,7 @@ erpnext.POS = Class.extend({
},
make_party: function() {
var me = this;
this.party_field = wn.ui.form.make_control({
this.party_field = frappe.ui.form.make_control({
df: {
"fieldtype": "Link",
"options": this.party,
@ -160,13 +160,13 @@ erpnext.POS = Class.extend({
this.party_field.make_input();
this.party_field.$input.on("change", function() {
if(!me.party_field.autocomplete_open)
wn.model.set_value(me.frm.doctype, me.frm.docname,
frappe.model.set_value(me.frm.doctype, me.frm.docname,
me.party.toLowerCase(), this.value);
});
},
make_barcode: function() {
var me = this;
this.barcode = wn.ui.form.make_control({
this.barcode = frappe.ui.form.make_control({
df: {
"fieldtype": "Data",
"label": "Barcode",
@ -185,7 +185,7 @@ erpnext.POS = Class.extend({
},
make_search: function() {
var me = this;
this.search = wn.ui.form.make_control({
this.search = frappe.ui.form.make_control({
df: {
"fieldtype": "Data",
"label": "Item",
@ -205,7 +205,7 @@ erpnext.POS = Class.extend({
},
make_item_group: function() {
var me = this;
this.item_group = wn.ui.form.make_control({
this.item_group = frappe.ui.form.make_control({
df: {
"fieldtype": "Link",
"options": "Item Group",
@ -225,7 +225,7 @@ erpnext.POS = Class.extend({
make_item_list: function() {
var me = this;
me.item_timeout = null;
wn.call({
frappe.call({
method: 'erpnext.accounts.doctype.sales_invoice.pos.get_items',
args: {
sales_or_purchase: this.sales_or_purchase,
@ -284,14 +284,14 @@ erpnext.POS = Class.extend({
// check whether the item is already added
if (no_of_items != 0) {
$.each(wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
$.each(frappe.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
this.frm.cscript.fname, this.frm.doctype), function(i, d) {
if (d.item_code == item_code) {
caught = true;
if (serial_no)
wn.model.set_value(d.doctype, d.name, "serial_no", d.serial_no + '\n' + serial_no);
frappe.model.set_value(d.doctype, d.name, "serial_no", d.serial_no + '\n' + serial_no);
else
wn.model.set_value(d.doctype, d.name, "qty", d.qty + 1);
frappe.model.set_value(d.doctype, d.name, "qty", d.qty + 1);
}
});
}
@ -306,7 +306,7 @@ erpnext.POS = Class.extend({
add_new_item_to_grid: function(item_code, serial_no) {
var me = this;
var child = wn.model.add_child(me.frm.doc, this.frm.doctype + " Item",
var child = frappe.model.add_child(me.frm.doc, this.frm.doctype + " Item",
this.frm.cscript.fname);
child.item_code = item_code;
@ -326,14 +326,14 @@ erpnext.POS = Class.extend({
},
update_qty: function(item_code, qty) {
var me = this;
$.each(wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
$.each(frappe.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
this.frm.cscript.fname, this.frm.doctype), function(i, d) {
if (d.item_code == item_code) {
if (qty == 0) {
wn.model.clear_doc(d.doctype, d.name);
frappe.model.clear_doc(d.doctype, d.name);
me.refresh_grid();
} else {
wn.model.set_value(d.doctype, d.name, "qty", qty);
frappe.model.set_value(d.doctype, d.name, "qty", qty);
}
}
});
@ -378,7 +378,7 @@ erpnext.POS = Class.extend({
var me = this;
var $items = this.wrapper.find("#cart tbody").empty();
$.each(wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
$.each(frappe.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
this.frm.cscript.fname, this.frm.doctype), function(i, d) {
$(repl('<tr id="%(item_code)s" data-selected="false">\
@ -413,7 +413,7 @@ erpnext.POS = Class.extend({
},
show_taxes: function() {
var me = this;
var taxes = wn.model.get_children(this.sales_or_purchase + " Taxes and Charges",
var taxes = frappe.model.get_children(this.sales_or_purchase + " Taxes and Charges",
this.frm.doc.name, this.frm.cscript.other_fname, this.frm.doctype);
$(this.wrapper).find(".tax-table")
.toggle((taxes && taxes.length) ? true : false)
@ -510,7 +510,7 @@ erpnext.POS = Class.extend({
add_item_thru_barcode: function() {
var me = this;
me.barcode_timeout = null;
wn.call({
frappe.call({
method: 'erpnext.accounts.doctype.sales_invoice.pos.get_item_code',
args: {barcode_serial_no: this.barcode.$input.val()},
callback: function(r) {
@ -521,7 +521,7 @@ erpnext.POS = Class.extend({
me.add_to_cart(r.message[0][0].name);
}
else
msgprint(wn._("Invalid Barcode"));
msgprint(frappe._("Invalid Barcode"));
me.refresh();
}
@ -538,13 +538,13 @@ erpnext.POS = Class.extend({
}
}
var child = wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
var child = frappe.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
this.frm.cscript.fname, this.frm.doctype);
$.each(child, function(i, d) {
for (var i in selected_items) {
if (d.item_code == selected_items[i]) {
wn.model.clear_doc(d.doctype, d.name);
frappe.model.clear_doc(d.doctype, d.name);
}
}
});
@ -563,9 +563,9 @@ erpnext.POS = Class.extend({
var mode_of_payment = [];
if (no_of_items == 0)
msgprint(wn._("Payment cannot be made for empty cart"));
msgprint(frappe._("Payment cannot be made for empty cart"));
else {
wn.call({
frappe.call({
method: 'erpnext.accounts.doctype.sales_invoice.pos.get_mode_of_payment',
callback: function(r) {
for (x=0; x<=r.message.length - 1; x++) {
@ -573,7 +573,7 @@ erpnext.POS = Class.extend({
}
// show payment wizard
var dialog = new wn.ui.Dialog({
var dialog = new frappe.ui.Dialog({
width: 400,
title: 'Payment',
fields: [

View File

@ -2,9 +2,9 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
@webnotes.whitelist()
@frappe.whitelist()
def get_items(price_list, sales_or_purchase, item=None, item_group=None):
condition = ""
args = {"price_list": price_list}
@ -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 webnotes.conn.sql("""select i.name, i.item_name, i.image,
return frappe.conn.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
@ -31,22 +31,22 @@ def get_items(price_list, sales_or_purchase, item=None, item_group=None):
where
%s""" % ('%(price_list)s', condition), args, as_dict=1)
@webnotes.whitelist()
@frappe.whitelist()
def get_item_code(barcode_serial_no):
input_via = "serial_no"
item_code = webnotes.conn.sql("""select name, item_code from `tabSerial No` where
item_code = frappe.conn.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 = webnotes.conn.sql("""select name from `tabItem` where barcode=%s""",
item_code = frappe.conn.sql("""select name from `tabItem` where barcode=%s""",
(barcode_serial_no), as_dict=1)
if item_code:
return item_code, input_via
else:
webnotes.throw("Invalid Barcode / Serial No")
frappe.throw("Invalid Barcode / Serial No")
@webnotes.whitelist()
@frappe.whitelist()
def get_mode_of_payment():
return webnotes.conn.sql("""select name from `tabMode of Payment`""", as_dict=1)
return frappe.conn.sql("""select name from `tabMode of Payment`""", as_dict=1)

View File

@ -14,7 +14,7 @@ cur_frm.pformat.print_heading = 'Invoice';
{% include 'utilities/doctype/sms_control/sms_control.js' %}
{% include 'accounts/doctype/sales_invoice/pos.js' %}
wn.provide("erpnext.accounts");
frappe.provide("erpnext.accounts");
erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.extend({
onload: function() {
this._super();
@ -25,11 +25,11 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
}
// toggle to pos view if is_pos is 1 in user_defaults
if ((cint(wn.defaults.get_user_defaults("is_pos"))===1 || this.frm.doc.is_pos)) {
if ((cint(frappe.defaults.get_user_defaults("is_pos"))===1 || this.frm.doc.is_pos)) {
if(this.frm.doc.__islocal && !this.frm.doc.amended_from && !this.frm.doc.customer) {
this.frm.set_value("is_pos", 1);
this.is_pos(function() {
if (cint(wn.defaults.get_user_defaults("fs_pos_view"))===1)
if (cint(frappe.defaults.get_user_defaults("fs_pos_view"))===1)
cur_frm.cscript.toggle_pos(true);
});
}
@ -50,20 +50,20 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
if(doc.docstatus==1) {
cur_frm.appframe.add_button('View Ledger', function() {
wn.route_options = {
frappe.route_options = {
"voucher_no": doc.name,
"from_date": doc.posting_date,
"to_date": doc.posting_date,
"company": doc.company,
group_by_voucher: 0
};
wn.set_route("query-report", "General Ledger");
frappe.set_route("query-report", "General Ledger");
}, "icon-table");
var percent_paid = cint(flt(doc.grand_total - doc.outstanding_amount) / flt(doc.grand_total) * 100);
cur_frm.dashboard.add_progress(percent_paid + "% Paid", percent_paid);
cur_frm.appframe.add_button(wn._('Send SMS'), cur_frm.cscript.send_sms, 'icon-mobile-phone');
cur_frm.appframe.add_button(frappe._('Send SMS'), cur_frm.cscript.send_sms, 'icon-mobile-phone');
if(cint(doc.update_stock)!=1) {
// show Make Delivery Note button only if Sales Invoice is not created from Delivery Note
@ -74,11 +74,11 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
});
if(!from_delivery_note)
cur_frm.appframe.add_primary_action(wn._('Make Delivery'), cur_frm.cscript['Make Delivery Note'])
cur_frm.appframe.add_primary_action(frappe._('Make Delivery'), cur_frm.cscript['Make Delivery Note'])
}
if(doc.outstanding_amount!=0)
cur_frm.appframe.add_primary_action(wn._('Make Payment Entry'), cur_frm.cscript.make_bank_voucher);
cur_frm.appframe.add_primary_action(frappe._('Make Payment Entry'), cur_frm.cscript.make_bank_voucher);
}
// Show buttons only when pos view is active
@ -89,9 +89,9 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
},
sales_order_btn: function() {
this.$sales_order_btn = cur_frm.appframe.add_primary_action(wn._('From Sales Order'),
this.$sales_order_btn = cur_frm.appframe.add_primary_action(frappe._('From Sales Order'),
function() {
wn.model.map_current_doc({
frappe.model.map_current_doc({
method: "erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice",
source_doctype: "Sales Order",
get_query_filters: {
@ -106,9 +106,9 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
},
delivery_note_btn: function() {
this.$delivery_note_btn = cur_frm.appframe.add_primary_action(wn._('From Delivery Note'),
this.$delivery_note_btn = cur_frm.appframe.add_primary_action(frappe._('From Delivery Note'),
function() {
wn.model.map_current_doc({
frappe.model.map_current_doc({
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice",
source_doctype: "Delivery Note",
get_query: function() {
@ -134,7 +134,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
if(cint(this.frm.doc.is_pos)) {
if(!this.frm.doc.company) {
this.frm.set_value("is_pos", 0);
msgprint(wn._("Please specify Company to proceed"));
msgprint(frappe._("Please specify Company to proceed"));
} else {
var me = this;
return this.frm.call({
@ -179,7 +179,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
write_off_outstanding_amount_automatically: function() {
if(cint(this.frm.doc.write_off_outstanding_amount_automatically)) {
wn.model.round_floats_in(this.frm.doc, ["grand_total", "paid_amount"]);
frappe.model.round_floats_in(this.frm.doc, ["grand_total", "paid_amount"]);
// this will make outstanding amount 0
this.frm.set_value("write_off_amount",
flt(this.frm.doc.grand_total - this.frm.doc.paid_amount), precision("write_off_amount"));
@ -198,7 +198,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
},
entries_add: function(doc, cdt, cdn) {
var row = wn.model.get_doc(cdt, cdn);
var row = frappe.model.get_doc(cdt, cdn);
this.frm.script_manager.copy_from_first_row("entries", row, ["income_account", "cost_center"]);
},
@ -233,7 +233,7 @@ cur_frm.cscript.hide_fields = function(doc) {
} else {
hide_field('payments_section');
for (i in par_flds) {
var docfield = wn.meta.docfield_map[doc.doctype][par_flds[i]];
var docfield = frappe.meta.docfield_map[doc.doctype][par_flds[i]];
if(!docfield.hidden) unhide_field(par_flds[i]);
}
cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal, true);
@ -244,7 +244,7 @@ cur_frm.cscript.hide_fields = function(doc) {
(cint(doc.update_stock)==1 ? true : false));
// India related fields
var cp = wn.control_panel;
var cp = frappe.control_panel;
if (cp.country == 'India') unhide_field(['c_form_applicable', 'c_form_no']);
else hide_field(['c_form_applicable', 'c_form_no']);
@ -269,21 +269,21 @@ cur_frm.cscript.is_opening = function(doc, dt, dn) {
}
cur_frm.cscript['Make Delivery Note'] = function() {
wn.model.open_mapped_doc({
frappe.model.open_mapped_doc({
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_delivery_note",
source_name: cur_frm.doc.name
})
}
cur_frm.cscript.make_bank_voucher = function() {
return wn.call({
return frappe.call({
method: "erpnext.accounts.doctype.journal_voucher.journal_voucher.get_payment_entry_from_sales_invoice",
args: {
"sales_invoice": cur_frm.doc.name
},
callback: function(r) {
var doclist = wn.model.sync(r.message);
wn.set_route("Form", doclist[0].doctype, doclist[0].name);
var doclist = frappe.model.sync(r.message);
frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
}
});
}
@ -400,8 +400,8 @@ cur_frm.cscript.cost_center = function(doc, cdt, cdn) {
}
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
if(cint(wn.boot.notification_settings.sales_invoice)) {
cur_frm.email_doc(wn.boot.notification_settings.sales_invoice_message);
if(cint(frappe.boot.notification_settings.sales_invoice)) {
cur_frm.email_doc(frappe.boot.notification_settings.sales_invoice_message);
}
}
@ -409,12 +409,12 @@ cur_frm.cscript.convert_into_recurring_invoice = function(doc, dt, dn) {
// set default values for recurring invoices
if(doc.convert_into_recurring_invoice) {
var owner_email = doc.owner=="Administrator"
? wn.user_info("Administrator").email
? frappe.user_info("Administrator").email
: doc.owner;
doc.notification_email_address = $.map([cstr(owner_email),
cstr(doc.contact_email)], function(v) { return v || null; }).join(", ");
doc.repeat_on_day_of_month = wn.datetime.str_to_obj(doc.posting_date).getDate();
doc.repeat_on_day_of_month = frappe.datetime.str_to_obj(doc.posting_date).getDate();
}
refresh_many(["notification_email_address", "repeat_on_day_of_month"]);
@ -428,9 +428,9 @@ cur_frm.cscript.invoice_period_from_date = function(doc, dt, dn) {
var months = recurring_type_map[doc.recurring_type];
if(months) {
var to_date = wn.datetime.add_months(doc.invoice_period_from_date,
var to_date = frappe.datetime.add_months(doc.invoice_period_from_date,
months);
doc.invoice_period_to_date = wn.datetime.add_days(to_date, -1);
doc.invoice_period_to_date = frappe.datetime.add_days(to_date, -1);
refresh_field('invoice_period_to_date');
}
}

View File

@ -2,17 +2,17 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import webnotes.defaults
import frappe
import frappe.defaults
from webnotes.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdate, \
from frappe.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdate, \
get_first_day, get_last_day
from webnotes.utils import comma_and, get_url
from webnotes.model.doc import make_autoname
from webnotes.model.bean import getlist
from webnotes.model.code import get_obj
from webnotes import _, msgprint
from frappe.utils import comma_and, get_url
from frappe.model.doc import make_autoname
from frappe.model.bean import getlist
from frappe.model.code import get_obj
from frappe import _, msgprint
from erpnext.accounts.party import get_party_account, get_due_date
@ -160,16 +160,16 @@ class DocType(SellingController):
def update_time_log_batch(self, sales_invoice):
for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
if d.time_log_batch:
tlb = webnotes.bean("Time Log Batch", d.time_log_batch)
tlb = frappe.bean("Time Log Batch", d.time_log_batch)
tlb.doc.sales_invoice = sales_invoice
tlb.update_after_submit()
def validate_time_logs_are_submitted(self):
for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
if d.time_log_batch:
status = webnotes.conn.get_value("Time Log Batch", d.time_log_batch, "status")
status = frappe.conn.get_value("Time Log Batch", d.time_log_batch, "status")
if status!="Submitted":
webnotes.msgprint(_("Time Log Batch status must be 'Submitted'") + ":" + d.time_log_batch,
frappe.msgprint(_("Time Log Batch status must be 'Submitted'") + ":" + d.time_log_batch,
raise_exception=True)
def set_pos_fields(self, for_validate=False):
@ -202,7 +202,7 @@ class DocType(SellingController):
# fetch terms
if self.doc.tc_name and not self.doc.terms:
self.doc.terms = webnotes.conn.get_value("Terms and Conditions", self.doc.tc_name, "terms")
self.doc.terms = frappe.conn.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 +213,7 @@ class DocType(SellingController):
"Sales Invoice Advance", "advance_adjustment_details", "credit")
def get_company_abbr(self):
return webnotes.conn.sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0]
return frappe.conn.sql("select abbr from tabCompany where name=%s", self.doc.company)[0][0]
def update_against_document_in_jv(self):
"""
@ -246,7 +246,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 = webnotes.conn.sql("select master_name from `tabAccount` where name = %s and docstatus != 2", self.doc.debit_to)
acc_head = frappe.conn.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 +255,7 @@ class DocType(SellingController):
def validate_debit_acc(self):
acc = webnotes.conn.sql("select debit_or_credit, is_pl_account from tabAccount where name = '%s' and docstatus != 2" % self.doc.debit_to)
acc = frappe.conn.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 +270,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 = webnotes.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 = webnotes.conn.sql("select account_type from `tabAccount` where name = '%s' and docstatus != 2" % d.income_account)
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)
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':
@ -291,7 +291,7 @@ class DocType(SellingController):
},
})
if cint(webnotes.defaults.get_global_default('maintain_same_sales_rate')):
if cint(frappe.defaults.get_global_default('maintain_same_sales_rate')):
super(DocType, self).validate_with_previous_doc(self.tname, {
"Sales Order Item": {
"ref_dn_field": "so_detail",
@ -332,9 +332,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 webnotes.conn.get_value('Selling Settings', None, dic[i]) == 'Yes':
if frappe.conn.get_value('Selling Settings', None, dic[i]) == 'Yes':
for d in getlist(self.doclist,'entries'):
if webnotes.conn.get_value('Item', d.item_code, 'is_stock_item') == 'Yes' \
if frappe.conn.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 +342,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 = webnotes.conn.sql("select name from `tabProject` where name = '%s' and (customer = '%s' or ifnull(customer,'')='')"%(self.doc.project_name, 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))
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
@ -353,7 +353,7 @@ class DocType(SellingController):
raise Exception
if flt(self.doc.paid_amount) + flt(self.doc.write_off_amount) \
- flt(self.doc.grand_total) > 1/(10**(self.precision("grand_total") + 1)):
webnotes.throw(_("""(Paid amount + Write Off Amount) can not be \
frappe.throw(_("""(Paid amount + Write Off Amount) can not be \
greater than Grand Total"""))
@ -377,28 +377,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:
webnotes.conn.sql("""delete from `tabC-Form Invoice Detail` where invoice_no = %s
frappe.conn.sql("""delete from `tabC-Form Invoice Detail` where invoice_no = %s
and parent = %s""", (self.doc.amended_from, self.doc.c_form_no))
webnotes.conn.set(self.doc, 'c_form_no', '')
frappe.conn.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 = webnotes.conn.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
bin = frappe.conn.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 = webnotes.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.conn.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 = webnotes.conn.sql("select warehouse from `tabPOS Setting` where ifnull(user,'') = '%s' and company = '%s'" % (webnotes.session['user'], self.doc.company))
w = frappe.conn.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 = webnotes.conn.sql("select name, warehouse from `tabPOS Setting` where ifnull(user,'') = '' and company = '%s'" % self.doc.company)
ps = frappe.conn.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 +425,25 @@ class DocType(SellingController):
if cint(self.doc.is_pos) == 1:
if flt(self.doc.paid_amount) == 0:
if self.doc.cash_bank_account:
webnotes.conn.set(self.doc, 'paid_amount',
frappe.conn.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
webnotes.conn.set(self.doc,'paid_amount',0)
webnotes.msgprint("Note: Payment Entry will not be created since 'Cash/Bank Account' was not specified.")
frappe.conn.set(self.doc,'paid_amount',0)
frappe.msgprint("Note: Payment Entry will not be created since 'Cash/Bank Account' was not specified.")
else:
webnotes.conn.set(self.doc,'paid_amount',0)
frappe.conn.set(self.doc,'paid_amount',0)
def check_prev_docstatus(self):
for d in getlist(self.doclist,'entries'):
if d.sales_order:
submitted = webnotes.conn.sql("select name from `tabSales Order` where docstatus = 1 and name = '%s'" % d.sales_order)
submitted = frappe.conn.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 = webnotes.conn.sql("select name from `tabDelivery Note` where docstatus = 1 and name = '%s'" % d.delivery_note)
submitted = frappe.conn.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 +451,11 @@ class DocType(SellingController):
def update_stock_ledger(self):
sl_entries = []
for d in self.get_item_list():
if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == "Yes" \
if frappe.conn.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": webnotes.conn.get_value("Item", d.item_code, "stock_uom")
"stock_uom": frappe.conn.get_value("Item", d.item_code, "stock_uom")
}))
self.make_sl_entries(sl_entries)
@ -472,7 +472,7 @@ class DocType(SellingController):
update_outstanding=update_outstanding, merge_entries=False)
if update_gl_entries_after and cint(self.doc.update_stock) \
and cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")):
and cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
self.update_gl_entries_after()
def get_gl_entries(self, warehouse_account=None):
@ -534,7 +534,7 @@ class DocType(SellingController):
)
# expense account gl entries
if cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")) \
if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) \
and cint(self.doc.update_stock):
gl_entries += super(DocType, self).get_gl_entries()
@ -584,7 +584,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:
webnotes.conn.sql("""update `tabC-Form Invoice Detail` set invoice_no = %s,
frappe.conn.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))
@ -592,7 +592,7 @@ class DocType(SellingController):
@property
def meta(self):
if not hasattr(self, "_meta"):
self._meta = webnotes.get_doctype(self.doc.doctype)
self._meta = frappe.get_doctype(self.doc.doctype)
return self._meta
def validate_recurring_invoice(self):
@ -613,13 +613,13 @@ class DocType(SellingController):
def convert_to_recurring(self):
if self.doc.convert_into_recurring_invoice:
if not self.doc.recurring_id:
webnotes.conn.set(self.doc, "recurring_id",
frappe.conn.set(self.doc, "recurring_id",
make_autoname("RECINV/.#####"))
self.set_next_date()
elif self.doc.recurring_id:
webnotes.conn.sql("""update `tabSales Invoice`
frappe.conn.sql("""update `tabSales Invoice`
set convert_into_recurring_invoice = 0
where recurring_id = %s""", (self.doc.recurring_id,))
@ -628,7 +628,7 @@ class DocType(SellingController):
email_list = filter(None, [cstr(email).strip() for email in
self.doc.notification_email_address.replace("\n", "").split(",")])
from webnotes.utils import validate_email_add
from frappe.utils import validate_email_add
for email in email_list:
if not validate_email_add(email):
msgprint(self.meta.get_label("notification_email_address") \
@ -649,7 +649,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))
webnotes.conn.set(self.doc, 'next_date', next_date)
frappe.conn.set(self.doc, 'next_date', next_date)
def get_next_date(dt, mcount, day=None):
dt = getdate(dt)
@ -665,43 +665,43 @@ def manage_recurring_invoices(next_date=None, commit=True):
and notify the concerned people
"""
next_date = next_date or nowdate()
recurring_invoices = webnotes.conn.sql("""select name, recurring_id
recurring_invoices = frappe.conn.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 webnotes.conn.sql("""select name from `tabSales Invoice`
if not frappe.conn.sql("""select name from `tabSales Invoice`
where posting_date=%s and recurring_id=%s and docstatus=1""",
(next_date, recurring_id)):
try:
ref_wrapper = webnotes.bean('Sales Invoice', ref_invoice)
ref_wrapper = frappe.bean('Sales Invoice', ref_invoice)
new_invoice_wrapper = make_new_invoice(ref_wrapper, next_date)
send_notification(new_invoice_wrapper)
if commit:
webnotes.conn.commit()
frappe.conn.commit()
except:
if commit:
webnotes.conn.rollback()
frappe.conn.rollback()
webnotes.conn.begin()
webnotes.conn.sql("update `tabSales Invoice` set \
frappe.conn.begin()
frappe.conn.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)
webnotes.conn.commit()
frappe.conn.commit()
exception_list.append(webnotes.get_traceback())
exception_list.append(frappe.get_traceback())
finally:
if commit:
webnotes.conn.begin()
frappe.conn.begin()
if exception_list:
exception_message = "\n\n".join([cstr(d) for d in exception_list])
raise Exception, exception_message
def make_new_invoice(ref_wrapper, posting_date):
from webnotes.model.bean import clone
from frappe.model.bean import clone
from erpnext.accounts.utils import get_fiscal_year
new_invoice = clone(ref_wrapper)
@ -738,17 +738,17 @@ def make_new_invoice(ref_wrapper, posting_date):
def send_notification(new_rv):
"""Notify concerned persons about recurring invoice generation"""
from webnotes.core.doctype.print_format.print_format import get_html
webnotes.sendmail(new_rv.doc.notification_email_address,
from frappe.core.doctype.print_format.print_format import get_html
frappe.sendmail(new_rv.doc.notification_email_address,
subject="New Invoice : " + new_rv.doc.name,
message = get_html(new_rv.doc, new_rv.doclist, "SalesInvoice"))
def notify_errors(inv, customer, owner):
from webnotes.profile import get_system_managers
from frappe.profile import get_system_managers
webnotes.sendmail(recipients=get_system_managers() + [webnotes.conn.get_value("Profile", owner, "email")],
frappe.sendmail(recipients=get_system_managers() + [frappe.conn.get_value("Profile", owner, "email")],
subject="[Urgent] Error while creating recurring invoice for %s" % inv,
message = webnotes.get_template("template/emails/recurring_invoice_failed.html").render({
message = frappe.get_template("template/emails/recurring_invoice_failed.html").render({
"name": inv,
"customer": customer
}))
@ -757,7 +757,7 @@ def notify_errors(inv, customer, owner):
def assign_task_to_owner(inv, msg, users):
for d in users:
from webnotes.widgets.form import assign_to
from frappe.widgets.form import assign_to
args = {
'assign_to' : d,
'doctype' : 'Sales Invoice',
@ -767,23 +767,23 @@ def assign_task_to_owner(inv, msg, users):
}
assign_to.add(args)
@webnotes.whitelist()
@frappe.whitelist()
def get_bank_cash_account(mode_of_payment):
val = webnotes.conn.get_value("Mode of Payment", mode_of_payment, "default_account")
val = frappe.conn.get_value("Mode of Payment", mode_of_payment, "default_account")
if not val:
webnotes.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)
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 {
"cash_bank_account": val
}
@webnotes.whitelist()
@frappe.whitelist()
def get_income_account(doctype, txt, searchfield, start, page_len, filters):
from erpnext.controllers.queries import get_match_cond
# 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 webnotes.conn.sql("""select tabAccount.name from `tabAccount`
return frappe.conn.sql("""select tabAccount.name from `tabAccount`
where (tabAccount.debit_or_credit="Credit"
or tabAccount.account_type = "Income Account")
and tabAccount.group_or_ledger="Ledger"
@ -796,12 +796,12 @@ def get_income_account(doctype, txt, searchfield, start, page_len, filters):
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield)})
@webnotes.whitelist()
@frappe.whitelist()
def make_delivery_note(source_name, target_doclist=None):
from webnotes.model.mapper import get_mapped_doclist
from frappe.model.mapper import get_mapped_doclist
def set_missing_values(source, target):
bean = webnotes.bean(target)
bean = frappe.bean(target)
bean.run_method("onload_post_render")
def update_item(source_doc, target_doc, source_parent):

View File

@ -2,7 +2,7 @@
// License: GNU General Public License v3. See license.txt
// render
wn.listview_settings['Sales Invoice'] = {
frappe.listview_settings['Sales Invoice'] = {
add_fields: ["`tabSales Invoice`.grand_total", "`tabSales Invoice`.outstanding_amount"],
add_columns: [{"content":"Percent Paid", width:"10%", type:"bar-graph",
label: "Payment Received"}],

View File

@ -1,7 +1,7 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.model.map_info["Sales Invoice"] = {
frappe.model.map_info["Sales Invoice"] = {
"Time Log Batch": {
table_map: {
"Sales Invoice Item": "Time Log Batch",

View File

@ -1,38 +1,38 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
import webnotes
import frappe
import unittest, json
from webnotes.utils import flt
from webnotes.model.bean import DocstatusTransitionError, TimestampMismatchError
from frappe.utils import flt
from frappe.model.bean import DocstatusTransitionError, TimestampMismatchError
from erpnext.accounts.utils import get_stock_and_account_difference
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
class TestSalesInvoice(unittest.TestCase):
def make(self):
w = webnotes.bean(copy=test_records[0])
w = frappe.bean(copy=test_records[0])
w.doc.is_pos = 0
w.insert()
w.submit()
return w
def test_double_submission(self):
w = webnotes.bean(copy=test_records[0])
w = frappe.bean(copy=test_records[0])
w.doc.docstatus = '0'
w.insert()
w2 = [d for d in w.doclist]
w.submit()
w = webnotes.bean(w2)
w = frappe.bean(w2)
self.assertRaises(DocstatusTransitionError, w.submit)
def test_timestamp_change(self):
w = webnotes.bean(copy=test_records[0])
w = frappe.bean(copy=test_records[0])
w.doc.docstatus = '0'
w.insert()
w2 = webnotes.bean([d.fields.copy() for d in w.doclist])
w2 = frappe.bean([d.fields.copy() for d in w.doclist])
import time
time.sleep(1)
@ -43,7 +43,7 @@ class TestSalesInvoice(unittest.TestCase):
self.assertRaises(TimestampMismatchError, w2.save)
def test_sales_invoice_calculation_base_currency(self):
si = webnotes.bean(copy=test_records[2])
si = frappe.bean(copy=test_records[2])
si.insert()
expected_values = {
@ -87,7 +87,7 @@ class TestSalesInvoice(unittest.TestCase):
self.assertEquals(si.doc.grand_total_export, 1627.05)
def test_sales_invoice_calculation_export_currency(self):
si = webnotes.bean(copy=test_records[2])
si = frappe.bean(copy=test_records[2])
si.doc.currency = "USD"
si.doc.conversion_rate = 50
si.doclist[1].rate = 1
@ -137,7 +137,7 @@ class TestSalesInvoice(unittest.TestCase):
self.assertEquals(si.doc.grand_total_export, 32.54)
def test_sales_invoice_discount_amount(self):
si = webnotes.bean(copy=test_records[3])
si = frappe.bean(copy=test_records[3])
si.doc.discount_amount = 104.95
si.doclist.append({
"doctype": "Sales Taxes and Charges",
@ -194,7 +194,7 @@ class TestSalesInvoice(unittest.TestCase):
self.assertEquals(si.doc.grand_total_export, 1500)
def test_discount_amount_gl_entry(self):
si = webnotes.bean(copy=test_records[3])
si = frappe.bean(copy=test_records[3])
si.doc.discount_amount = 104.95
si.doclist.append({
"doctype": "Sales Taxes and Charges",
@ -210,7 +210,7 @@ class TestSalesInvoice(unittest.TestCase):
si.insert()
si.submit()
gl_entries = webnotes.conn.sql("""select account, debit, credit
gl_entries = frappe.conn.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,13 +238,13 @@ class TestSalesInvoice(unittest.TestCase):
# cancel
si.cancel()
gle = webnotes.conn.sql("""select * from `tabGL Entry`
gle = frappe.conn.sql("""select * from `tabGL Entry`
where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name)
self.assertFalse(gle)
def test_inclusive_rate_validations(self):
si = webnotes.bean(copy=test_records[2])
si = frappe.bean(copy=test_records[2])
for i, tax in enumerate(si.doclist.get({"parentfield": "other_charges"})):
tax.idx = i+1
@ -254,15 +254,15 @@ class TestSalesInvoice(unittest.TestCase):
si.doclist[i].included_in_print_rate = 1
# tax type "Actual" cannot be inclusive
self.assertRaises(webnotes.ValidationError, si.insert)
self.assertRaises(frappe.ValidationError, si.insert)
# taxes above included type 'On Previous Row Total' should also be included
si.doclist[3].included_in_print_rate = 0
self.assertRaises(webnotes.ValidationError, si.insert)
self.assertRaises(frappe.ValidationError, si.insert)
def test_sales_invoice_calculation_base_currency_with_tax_inclusive_price(self):
# prepare
si = webnotes.bean(copy=test_records[3])
si = frappe.bean(copy=test_records[3])
si.insert()
expected_values = {
@ -307,7 +307,7 @@ class TestSalesInvoice(unittest.TestCase):
def test_sales_invoice_calculation_export_currency_with_tax_inclusive_price(self):
# prepare
si = webnotes.bean(copy=test_records[3])
si = frappe.bean(copy=test_records[3])
si.doc.currency = "USD"
si.doc.conversion_rate = 50
si.doclist[1].price_list_rate = 55.56
@ -363,55 +363,55 @@ class TestSalesInvoice(unittest.TestCase):
self.assertEquals(w.doc.outstanding_amount, w.doc.grand_total)
def test_payment(self):
webnotes.conn.sql("""delete from `tabGL Entry`""")
frappe.conn.sql("""delete from `tabGL Entry`""")
w = self.make()
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
import test_records as jv_test_records
jv = webnotes.bean(webnotes.copy_doclist(jv_test_records[0]))
jv = frappe.bean(frappe.copy_doclist(jv_test_records[0]))
jv.doclist[1].against_invoice = w.doc.name
jv.insert()
jv.submit()
self.assertEquals(webnotes.conn.get_value("Sales Invoice", w.doc.name, "outstanding_amount"),
self.assertEquals(frappe.conn.get_value("Sales Invoice", w.doc.name, "outstanding_amount"),
161.8)
jv.cancel()
self.assertEquals(webnotes.conn.get_value("Sales Invoice", w.doc.name, "outstanding_amount"),
self.assertEquals(frappe.conn.get_value("Sales Invoice", w.doc.name, "outstanding_amount"),
561.8)
def test_time_log_batch(self):
tlb = webnotes.bean("Time Log Batch", "_T-Time Log Batch-00001")
tlb = frappe.bean("Time Log Batch", "_T-Time Log Batch-00001")
tlb.submit()
si = webnotes.bean(webnotes.copy_doclist(test_records[0]))
si = frappe.bean(frappe.copy_doclist(test_records[0]))
si.doclist[1].time_log_batch = "_T-Time Log Batch-00001"
si.insert()
si.submit()
self.assertEquals(webnotes.conn.get_value("Time Log Batch", "_T-Time Log Batch-00001",
self.assertEquals(frappe.conn.get_value("Time Log Batch", "_T-Time Log Batch-00001",
"status"), "Billed")
self.assertEquals(webnotes.conn.get_value("Time Log", "_T-Time Log-00001", "status"),
self.assertEquals(frappe.conn.get_value("Time Log", "_T-Time Log-00001", "status"),
"Billed")
si.cancel()
self.assertEquals(webnotes.conn.get_value("Time Log Batch", "_T-Time Log Batch-00001",
self.assertEquals(frappe.conn.get_value("Time Log Batch", "_T-Time Log Batch-00001",
"status"), "Submitted")
self.assertEquals(webnotes.conn.get_value("Time Log", "_T-Time Log-00001", "status"),
self.assertEquals(frappe.conn.get_value("Time Log", "_T-Time Log-00001", "status"),
"Batched for Billing")
def test_sales_invoice_gl_entry_without_aii(self):
self.clear_stock_account_balance()
set_perpetual_inventory(0)
si = webnotes.bean(copy=test_records[1])
si = frappe.bean(copy=test_records[1])
si.insert()
si.submit()
gl_entries = webnotes.conn.sql("""select account, debit, credit
gl_entries = frappe.conn.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 = webnotes.conn.sql("""select * from `tabGL Entry`
gle = frappe.conn.sql("""select * from `tabGL Entry`
where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name)
self.assertFalse(gle)
@ -444,19 +444,19 @@ class TestSalesInvoice(unittest.TestCase):
self._insert_purchase_receipt()
self._insert_pos_settings()
pos = webnotes.copy_doclist(test_records[1])
pos = frappe.copy_doclist(test_records[1])
pos[0]["is_pos"] = 1
pos[0]["update_stock"] = 1
pos[0]["posting_time"] = "12:05"
pos[0]["cash_bank_account"] = "_Test Account Bank Account - _TC"
pos[0]["paid_amount"] = 600.0
si = webnotes.bean(copy=pos)
si = frappe.bean(copy=pos)
si.insert()
si.submit()
# check stock ledger entries
sle = webnotes.conn.sql("""select * from `tabStock Ledger Entry`
sle = frappe.conn.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 = webnotes.conn.sql("""select account, debit, credit
gl_entries = frappe.conn.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 = webnotes.conn.get_value("Account", {"master_name": "_Test Warehouse - _TC"})
stock_in_hand = frappe.conn.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 = webnotes.conn.sql("""select * from `tabGL Entry`
gle = frappe.conn.sql("""select * from `tabGL Entry`
where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name)
self.assertFalse(gle)
@ -499,28 +499,28 @@ class TestSalesInvoice(unittest.TestCase):
def test_si_gl_entry_with_aii_and_update_stock_with_warehouse_but_no_account(self):
self.clear_stock_account_balance()
set_perpetual_inventory()
webnotes.delete_doc("Account", "_Test Warehouse No Account - _TC")
frappe.delete_doc("Account", "_Test Warehouse No Account - _TC")
# insert purchase receipt
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
as pr_test_records
pr = webnotes.bean(copy=pr_test_records[0])
pr = frappe.bean(copy=pr_test_records[0])
pr.doc.naming_series = "_T-Purchase Receipt-"
pr.doclist[1].warehouse = "_Test Warehouse No Account - _TC"
pr.insert()
pr.submit()
si_doclist = webnotes.copy_doclist(test_records[1])
si_doclist = frappe.copy_doclist(test_records[1])
si_doclist[0]["update_stock"] = 1
si_doclist[0]["posting_time"] = "12:05"
si_doclist[1]["warehouse"] = "_Test Warehouse No Account - _TC"
si = webnotes.bean(copy=si_doclist)
si = frappe.bean(copy=si_doclist)
si.insert()
si.submit()
# check stock ledger entries
sle = webnotes.conn.sql("""select * from `tabStock Ledger Entry`
sle = frappe.conn.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 = webnotes.conn.sql("""select account, debit, credit
gl_entries = frappe.conn.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 = webnotes.conn.sql("""select * from `tabGL Entry`
gle = frappe.conn.sql("""select * from `tabGL Entry`
where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name)
self.assertFalse(gle)
@ -555,13 +555,13 @@ class TestSalesInvoice(unittest.TestCase):
self.clear_stock_account_balance()
set_perpetual_inventory()
si_copy = webnotes.copy_doclist(test_records[1])
si_copy = frappe.copy_doclist(test_records[1])
si_copy[1]["item_code"] = None
si = webnotes.bean(si_copy)
si = frappe.bean(si_copy)
si.insert()
si.submit()
gl_entries = webnotes.conn.sql("""select account, debit, credit
gl_entries = frappe.conn.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)
@ -582,13 +582,13 @@ class TestSalesInvoice(unittest.TestCase):
def test_sales_invoice_gl_entry_with_aii_non_stock_item(self):
self.clear_stock_account_balance()
set_perpetual_inventory()
si_copy = webnotes.copy_doclist(test_records[1])
si_copy = frappe.copy_doclist(test_records[1])
si_copy[1]["item_code"] = "_Test Non Stock Item"
si = webnotes.bean(si_copy)
si = frappe.bean(si_copy)
si.insert()
si.submit()
gl_entries = webnotes.conn.sql("""select account, debit, credit
gl_entries = frappe.conn.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)
@ -609,7 +609,7 @@ class TestSalesInvoice(unittest.TestCase):
def _insert_purchase_receipt(self):
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
as pr_test_records
pr = webnotes.bean(copy=pr_test_records[0])
pr = frappe.bean(copy=pr_test_records[0])
pr.doc.naming_series = "_T-Purchase Receipt-"
pr.insert()
pr.submit()
@ -617,7 +617,7 @@ class TestSalesInvoice(unittest.TestCase):
def _insert_delivery_note(self):
from erpnext.stock.doctype.delivery_note.test_delivery_note import test_records \
as dn_test_records
dn = webnotes.bean(copy=dn_test_records[0])
dn = frappe.bean(copy=dn_test_records[0])
dn.doc.naming_series = "_T-Delivery Note-"
dn.insert()
dn.submit()
@ -626,20 +626,20 @@ 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
webnotes.conn.sql("""delete from `tabPOS Setting`""")
frappe.conn.sql("""delete from `tabPOS Setting`""")
ps = webnotes.bean(copy=pos_setting_test_records[0])
ps = frappe.bean(copy=pos_setting_test_records[0])
ps.insert()
def test_sales_invoice_with_advance(self):
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
import test_records as jv_test_records
jv = webnotes.bean(copy=jv_test_records[0])
jv = frappe.bean(copy=jv_test_records[0])
jv.insert()
jv.submit()
si = webnotes.bean(copy=test_records[0])
si = frappe.bean(copy=test_records[0])
si.doclist.append({
"doctype": "Sales Invoice Advance",
"parentfield": "advance_adjustment_details",
@ -653,24 +653,24 @@ class TestSalesInvoice(unittest.TestCase):
si.submit()
si.load_from_db()
self.assertTrue(webnotes.conn.sql("""select name from `tabJournal Voucher Detail`
self.assertTrue(frappe.conn.sql("""select name from `tabJournal Voucher Detail`
where against_invoice=%s""", si.doc.name))
self.assertTrue(webnotes.conn.sql("""select name from `tabJournal Voucher Detail`
self.assertTrue(frappe.conn.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 webnotes.conn.sql("""select name from `tabJournal Voucher Detail`
self.assertTrue(not frappe.conn.sql("""select name from `tabJournal Voucher Detail`
where against_invoice=%s""", si.doc.name))
def test_recurring_invoice(self):
from webnotes.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate
from frappe.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate
from erpnext.accounts.utils import get_fiscal_year
today = nowdate()
base_si = webnotes.bean(copy=test_records[0])
base_si = frappe.bean(copy=test_records[0])
base_si.doc.fields.update({
"convert_into_recurring_invoice": 1,
"recurring_type": "Monthly",
@ -683,13 +683,13 @@ class TestSalesInvoice(unittest.TestCase):
})
# monthly
si1 = webnotes.bean(copy=base_si.doclist)
si1 = frappe.bean(copy=base_si.doclist)
si1.insert()
si1.submit()
self._test_recurring_invoice(si1, True)
# monthly without a first and last day period
si2 = webnotes.bean(copy=base_si.doclist)
si2 = frappe.bean(copy=base_si.doclist)
si2.doc.fields.update({
"invoice_period_from_date": today,
"invoice_period_to_date": add_to_date(today, days=30)
@ -699,7 +699,7 @@ class TestSalesInvoice(unittest.TestCase):
self._test_recurring_invoice(si2, False)
# quarterly
si3 = webnotes.bean(copy=base_si.doclist)
si3 = frappe.bean(copy=base_si.doclist)
si3.doc.fields.update({
"recurring_type": "Quarterly",
"invoice_period_from_date": get_first_day(today),
@ -710,7 +710,7 @@ class TestSalesInvoice(unittest.TestCase):
self._test_recurring_invoice(si3, True)
# quarterly without a first and last day period
si4 = webnotes.bean(copy=base_si.doclist)
si4 = frappe.bean(copy=base_si.doclist)
si4.doc.fields.update({
"recurring_type": "Quarterly",
"invoice_period_from_date": today,
@ -721,7 +721,7 @@ class TestSalesInvoice(unittest.TestCase):
self._test_recurring_invoice(si4, False)
# yearly
si5 = webnotes.bean(copy=base_si.doclist)
si5 = frappe.bean(copy=base_si.doclist)
si5.doc.fields.update({
"recurring_type": "Yearly",
"invoice_period_from_date": get_first_day(today),
@ -732,7 +732,7 @@ class TestSalesInvoice(unittest.TestCase):
self._test_recurring_invoice(si5, True)
# yearly without a first and last day period
si6 = webnotes.bean(copy=base_si.doclist)
si6 = frappe.bean(copy=base_si.doclist)
si6.doc.fields.update({
"recurring_type": "Yearly",
"invoice_period_from_date": today,
@ -743,7 +743,7 @@ class TestSalesInvoice(unittest.TestCase):
self._test_recurring_invoice(si6, False)
# change posting date but keep recuring day to be today
si7 = webnotes.bean(copy=base_si.doclist)
si7 = frappe.bean(copy=base_si.doclist)
si7.doc.fields.update({
"posting_date": add_to_date(today, days=-1)
})
@ -755,14 +755,14 @@ class TestSalesInvoice(unittest.TestCase):
self._test_recurring_invoice(si7, True)
def _test_recurring_invoice(self, base_si, first_and_last_day):
from webnotes.utils import add_months, get_last_day
from frappe.utils import add_months, get_last_day
from erpnext.accounts.doctype.sales_invoice.sales_invoice \
import manage_recurring_invoices, get_next_date
no_of_months = ({"Monthly": 1, "Quarterly": 3, "Yearly": 12})[base_si.doc.recurring_type]
def _test(i):
self.assertEquals(i+1, webnotes.conn.sql("""select count(*) from `tabSales Invoice`
self.assertEquals(i+1, frappe.conn.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,13 +770,13 @@ class TestSalesInvoice(unittest.TestCase):
manage_recurring_invoices(next_date=next_date, commit=False)
recurred_invoices = webnotes.conn.sql("""select name from `tabSales Invoice`
recurred_invoices = frappe.conn.sql("""select name from `tabSales Invoice`
where recurring_id=%s and docstatus=1 order by name desc""",
base_si.doc.recurring_id)
self.assertEquals(i+2, len(recurred_invoices))
new_si = webnotes.bean("Sales Invoice", recurred_invoices[0][0])
new_si = frappe.bean("Sales Invoice", recurred_invoices[0][0])
for fieldname in ["convert_into_recurring_invoice", "recurring_type",
"repeat_on_day_of_month", "notification_email_address"]:
@ -805,9 +805,9 @@ class TestSalesInvoice(unittest.TestCase):
base_si = _test(i)
def clear_stock_account_balance(self):
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
webnotes.conn.sql("delete from tabBin")
webnotes.conn.sql("delete from `tabGL Entry`")
frappe.conn.sql("delete from `tabStock Ledger Entry`")
frappe.conn.sql("delete from tabBin")
frappe.conn.sql("delete from `tabGL Entry`")
def test_serialized(self):
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item
@ -816,7 +816,7 @@ class TestSalesInvoice(unittest.TestCase):
se = make_serialized_item()
serial_nos = get_serial_nos(se.doclist[1].serial_no)
si = webnotes.bean(copy=test_records[0])
si = frappe.bean(copy=test_records[0])
si.doc.update_stock = 1
si.doclist[1].item_code = "_Test Serialized Item With Series"
si.doclist[1].qty = 1
@ -824,9 +824,9 @@ class TestSalesInvoice(unittest.TestCase):
si.insert()
si.submit()
self.assertEquals(webnotes.conn.get_value("Serial No", serial_nos[0], "status"), "Delivered")
self.assertFalse(webnotes.conn.get_value("Serial No", serial_nos[0], "warehouse"))
self.assertEquals(webnotes.conn.get_value("Serial No", serial_nos[0],
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],
"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(webnotes.conn.get_value("Serial No", serial_nos[0], "status"), "Available")
self.assertEquals(webnotes.conn.get_value("Serial No", serial_nos[0], "warehouse"), "_Test Warehouse - _TC")
self.assertFalse(webnotes.conn.get_value("Serial No", serial_nos[0],
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],
"delivery_document_no"))
def test_serialize_status(self):
@ -850,11 +850,11 @@ class TestSalesInvoice(unittest.TestCase):
se = make_serialized_item()
serial_nos = get_serial_nos(se.doclist[1].serial_no)
sr = webnotes.bean("Serial No", serial_nos[0])
sr = frappe.bean("Serial No", serial_nos[0])
sr.doc.status = "Not Available"
sr.save()
si = webnotes.bean(copy=test_records[0])
si = frappe.bean(copy=test_records[0])
si.doc.update_stock = 1
si.doclist[1].item_code = "_Test Serialized Item With Series"
si.doclist[1].qty = 1

View File

@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
class DocType:
def __init__(self, d, dl):

View File

@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
class DocType:
def __init__(self, d, dl):

View File

@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
class DocType:
def __init__(self, d, dl):

View File

@ -9,7 +9,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.set_footnote(wn.markdown(cur_frm.meta.description));
cur_frm.set_footnote(frappe.markdown(cur_frm.meta.description));
}
// For customizing print
@ -48,7 +48,7 @@ cur_frm.pformat.other_charges= function(doc){
}
function print_hide(fieldname) {
var doc_field = wn.meta.get_docfield(doc.doctype, fieldname, doc.name);
var doc_field = frappe.meta.get_docfield(doc.doctype, fieldname, doc.name);
return doc_field.print_hide;
}
@ -100,7 +100,7 @@ cur_frm.pformat.other_charges= function(doc){
cur_frm.cscript.charge_type = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(d.idx == 1 && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')) {
msgprint(wn._("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row"));
msgprint(frappe._("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row"));
d.charge_type = '';
}
validated = false;
@ -113,16 +113,16 @@ cur_frm.cscript.charge_type = function(doc, cdt, cdn) {
cur_frm.cscript.row_id = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.row_id) {
msgprint(wn._("Please select Charge Type first"));
msgprint(frappe._("Please select Charge Type first"));
d.row_id = '';
}
else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) {
msgprint(wn._("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'"));
msgprint(frappe._("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'"));
d.row_id = '';
}
else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id) {
if(d.row_id >= d.idx){
msgprint(wn._("You cannot Enter Row no. greater than or equal to current row no. for this Charge type"));
msgprint(frappe._("You cannot Enter Row no. greater than or equal to current row no. for this Charge type"));
d.row_id = '';
}
}
@ -153,7 +153,7 @@ cur_frm.fields_dict['other_charges'].grid.get_field("cost_center").get_query = f
cur_frm.cscript.rate = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.rate) {
msgprint(wn._("Please select Charge Type first"));
msgprint(frappe._("Please select Charge Type first"));
d.rate = '';
}
validated = false;
@ -163,11 +163,11 @@ cur_frm.cscript.rate = function(doc, cdt, cdn) {
cur_frm.cscript.tax_amount = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.tax_amount) {
msgprint(wn._("Please select Charge Type first"));
msgprint(frappe._("Please select Charge Type first"));
d.tax_amount = '';
}
else if(d.charge_type && d.tax_amount) {
msgprint(wn._("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate"));
msgprint(frappe._("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate"));
d.tax_amount = '';
}
validated = false;

View File

@ -2,14 +2,14 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint
from webnotes.model.controller import DocListController
import frappe
from frappe.utils import cint
from frappe.model.controller import DocListController
class DocType(DocListController):
def validate(self):
if self.doc.is_default == 1:
webnotes.conn.sql("""update `tabSales Taxes and Charges Master` set is_default = 0
frappe.conn.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))

View File

@ -4,15 +4,15 @@
# For license information, please see license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import _, msgprint
from webnotes.utils import flt, fmt_money
from webnotes.model.controller import DocListController
import frappe
from frappe import _, msgprint
from frappe.utils import flt, fmt_money
from frappe.model.controller import DocListController
from erpnext.setup.utils import get_company_currency
class OverlappingConditionError(webnotes.ValidationError): pass
class FromGreaterThanToError(webnotes.ValidationError): pass
class ManyBlankToValuesError(webnotes.ValidationError): pass
class OverlappingConditionError(frappe.ValidationError): pass
class FromGreaterThanToError(frappe.ValidationError): pass
class ManyBlankToValuesError(frappe.ValidationError): pass
class DocType(DocListController):
def __init__(self, d, dl):

View File

@ -1,18 +1,18 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
import webnotes
import frappe
import unittest
from erpnext.accounts.doctype.shipping_rule.shipping_rule import FromGreaterThanToError, ManyBlankToValuesError, OverlappingConditionError
class TestShippingRule(unittest.TestCase):
def test_from_greater_than_to(self):
shipping_rule = webnotes.bean(copy=test_records[0])
shipping_rule = frappe.bean(copy=test_records[0])
shipping_rule.doclist[1].from_value = 101
self.assertRaises(FromGreaterThanToError, shipping_rule.insert)
def test_many_zero_to_values(self):
shipping_rule = webnotes.bean(copy=test_records[0])
shipping_rule = frappe.bean(copy=test_records[0])
shipping_rule.doclist[1].to_value = 0
self.assertRaises(ManyBlankToValuesError, shipping_rule.insert)
@ -24,7 +24,7 @@ class TestShippingRule(unittest.TestCase):
((50, 150), (25, 175)),
((50, 150), (50, 150)),
]:
shipping_rule = webnotes.bean(copy=test_records[0])
shipping_rule = frappe.bean(copy=test_records[0])
shipping_rule.doclist[1].from_value = range_a[0]
shipping_rule.doclist[1].to_value = range_a[1]
shipping_rule.doclist[2].from_value = range_b[0]

View File

@ -4,7 +4,7 @@
# For license information, please see license.txt
from __future__ import unicode_literals
import webnotes
import frappe
class DocType:
def __init__(self, d, dl):

View File

@ -2,13 +2,13 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt, cstr
from webnotes import _
import frappe
from frappe.utils import flt, cstr
from frappe import _
from erpnext.accounts.utils import validate_expense_against_budget
class StockAccountInvalidTransaction(webnotes.ValidationError): pass
class StockAccountInvalidTransaction(frappe.ValidationError): pass
def make_gl_entries(gl_map, cancel=False, adv_adj=False, merge_entries=True,
update_outstanding='Yes'):
@ -77,7 +77,7 @@ def save_entries(gl_map, adv_adj, update_outstanding):
def make_entry(args, adv_adj, update_outstanding):
args.update({"doctype": "GL Entry"})
gle = webnotes.bean([args])
gle = frappe.bean([args])
gle.ignore_permissions = 1
gle.insert()
gle.run_method("on_update_with_args", adv_adj, update_outstanding)
@ -85,17 +85,17 @@ def make_entry(args, adv_adj, update_outstanding):
def validate_total_debit_credit(total_debit, total_credit):
if abs(total_debit - total_credit) > 0.005:
webnotes.throw(_("Debit and Credit not equal for this voucher: Diff (Debit) is ") +
frappe.throw(_("Debit and Credit not equal for this voucher: Diff (Debit) is ") +
cstr(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 webnotes.conn.sql("""select name from tabAccount
aii_accounts = [d[0] for d in frappe.conn.sql("""select name from tabAccount
where account_type = 'Warehouse' and ifnull(master_name, '')!=''""")]
for entry in gl_map:
if entry.account in aii_accounts:
webnotes.throw(_("Account") + ": " + entry.account +
frappe.throw(_("Account") + ": " + entry.account +
_(" can only be debited/credited through Stock transactions"),
StockAccountInvalidTransaction)
@ -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 = webnotes.conn.sql("""select * from `tabGL Entry`
gl_entries = frappe.conn.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)
webnotes.conn.sql("""delete from `tabGL Entry` where voucher_type=%s and voucher_no=%s""",
frappe.conn.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:

View File

@ -8,7 +8,7 @@
// see ledger
pscript['onload_Accounts Browser'] = function(wrapper){
wn.ui.make_app_page({
frappe.ui.make_app_page({
parent: wrapper,
single_column: true
})
@ -20,30 +20,30 @@ pscript['onload_Accounts Browser'] = function(wrapper){
.css({"margin-bottom": "15px", "min-height": "200px"})
.appendTo(main),
help_area = $('<div class="well">'+
'<h4>'+wn._('Quick Help')+'</h4>'+
'<h4>'+frappe._('Quick Help')+'</h4>'+
'<ol>'+
'<li>'+wn._('To add child nodes, explore tree and click on the node under which you want to add more nodes.')+'</li>'+
'<li>'+frappe._('To add child nodes, explore tree and click on the node under which you want to add more nodes.')+'</li>'+
'<li>'+
wn._('Accounting Entries can be made against leaf nodes, called')+
'<b>' +wn._('Ledgers')+'</b>.'+ wn._('Entries against') +
'<b>' +wn._('Groups') + '</b>'+ wn._('are not allowed.')+
frappe._('Accounting Entries can be made against leaf nodes, called')+
'<b>' +frappe._('Ledgers')+'</b>.'+ frappe._('Entries against') +
'<b>' +frappe._('Groups') + '</b>'+ frappe._('are not allowed.')+
'</li>'+
'<li>'+wn._('Please do NOT create Account (Ledgers) for Customers and Suppliers. They are created directly from the Customer / Supplier masters.')+'</li>'+
'<li>'+frappe._('Please do NOT create Account (Ledgers) for Customers and Suppliers. They are created directly from the Customer / Supplier masters.')+'</li>'+
'<li>'+
'<b>'+wn._('To create a Bank Account:')+'</b>'+
wn._('Go to the appropriate group (usually Application of Funds > Current Assets > Bank Accounts)')+
wn._('and create a new Account Ledger (by clicking on Add Child) of type "Bank or Cash"')+
'<b>'+frappe._('To create a Bank Account:')+'</b>'+
frappe._('Go to the appropriate group (usually Application of Funds > Current Assets > Bank Accounts)')+
frappe._('and create a new Account Ledger (by clicking on Add Child) of type "Bank or Cash"')+
'</li>'+
'<li>'+
'<b>'+wn._('To create a Tax Account:')+'</b>'+
wn._('Go to the appropriate group (usually Source of Funds > Current Liabilities > Taxes and Duties)')+
wn._('and create a new Account Ledger (by clicking on Add Child) of type "Tax" and do mention the Tax rate.')+
'<b>'+frappe._('To create a Tax Account:')+'</b>'+
frappe._('Go to the appropriate group (usually Source of Funds > Current Liabilities > Taxes and Duties)')+
frappe._('and create a new Account Ledger (by clicking on Add Child) of type "Tax" and do mention the Tax rate.')+
'</li>'+
'</ol>'+
'<p>'+wn._('Please setup your chart of accounts before you start Accounting Entries')+'</p></div>').appendTo(main);
'<p>'+frappe._('Please setup your chart of accounts before you start Accounting Entries')+'</p></div>').appendTo(main);
if (wn.boot.profile.can_create.indexOf("Company") !== -1) {
wrapper.appframe.add_button(wn._('New Company'), function() { newdoc('Company'); },
if (frappe.boot.profile.can_create.indexOf("Company") !== -1) {
wrapper.appframe.add_button(frappe._('New Company'), function() { newdoc('Company'); },
'icon-plus');
}
@ -54,21 +54,21 @@ pscript['onload_Accounts Browser'] = function(wrapper){
// company-select
wrapper.$company_select = wrapper.appframe.add_select("Company", [])
.change(function() {
var ctype = wn.get_route()[1] || 'Account';
var ctype = frappe.get_route()[1] || 'Account';
erpnext.account_chart = new erpnext.AccountsChart(ctype, $(this).val(),
chart_area.get(0));
pscript.set_title(wrapper, ctype, $(this).val());
})
// load up companies
return wn.call({
return frappe.call({
method: 'erpnext.accounts.page.accounts_browser.accounts_browser.get_companies',
callback: function(r) {
wrapper.$company_select.empty();
$.each(r.message, function(i, v) {
$('<option>').html(v).attr('value', v).appendTo(wrapper.$company_select);
});
wrapper.$company_select.val(wn.defaults.get_default("company") || r[0]).change();
wrapper.$company_select.val(frappe.defaults.get_default("company") || r[0]).change();
}
});
}
@ -83,7 +83,7 @@ pscript.set_title = function(wrapper, ctype, val) {
pscript['onshow_Accounts Browser'] = function(wrapper){
// set route
var ctype = wn.get_route()[1] || 'Account';
var ctype = frappe.get_route()[1] || 'Account';
if(erpnext.account_chart && erpnext.account_chart.ctype != ctype) {
wrapper.$company_select.change();
@ -97,13 +97,13 @@ erpnext.AccountsChart = Class.extend({
$(wrapper).empty();
var me = this;
me.ctype = ctype;
me.can_create = wn.model.can_create(this.ctype);
me.can_delete = wn.model.can_delete(this.ctype);
me.can_write = wn.model.can_write(this.ctype);
me.can_create = frappe.model.can_create(this.ctype);
me.can_delete = frappe.model.can_delete(this.ctype);
me.can_write = frappe.model.can_write(this.ctype);
me.company = company;
this.tree = new wn.ui.Tree({
this.tree = new frappe.ui.Tree({
parent: $(wrapper),
label: ctype==="Account" ? "Accounts" : "Cost Centers",
args: {ctype: ctype, comp: company},
@ -145,49 +145,49 @@ erpnext.AccountsChart = Class.extend({
var node_links = [];
// edit
if (wn.model.can_read(this.ctype) !== -1) {
node_links.push('<a onclick="erpnext.account_chart.open();">'+wn._('Edit')+'</a>');
if (frappe.model.can_read(this.ctype) !== -1) {
node_links.push('<a onclick="erpnext.account_chart.open();">'+frappe._('Edit')+'</a>');
}
if (data.expandable && wn.boot.profile.in_create.indexOf(this.ctype) !== -1) {
node_links.push('<a onclick="erpnext.account_chart.new_node();">'+wn._('Add Child')+'</a>');
} else if (this.ctype === 'Account' && wn.boot.profile.can_read.indexOf("GL Entry") !== -1) {
node_links.push('<a onclick="erpnext.account_chart.show_ledger();">'+wn._('View Ledger')+'</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()">'+wn._('Rename')+'</a>');
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()">'+wn._('Delete')+'</a>');
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();
wn.set_route("Form", this.ctype, node.data("label"));
frappe.set_route("Form", this.ctype, node.data("label"));
},
show_ledger: function() {
var me = this;
var node = me.selected_node();
wn.route_options = {
frappe.route_options = {
"account": node.data('label'),
"from_date": sys_defaults.year_start_date,
"to_date": sys_defaults.year_end_date,
"company": me.company
};
wn.set_route("query-report", "General Ledger");
frappe.set_route("query-report", "General Ledger");
},
rename: function() {
var node = this.selected_node();
wn.model.rename_doc(this.ctype, node.data('label'), function(new_name) {
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();
wn.model.delete_doc(this.ctype, node.data('label'), function() {
frappe.model.delete_doc(this.ctype, node.data('label'), function() {
node.parent().remove();
});
},
@ -205,21 +205,21 @@ erpnext.AccountsChart = Class.extend({
var me = this;
// the dialog
var d = new wn.ui.Dialog({
title:wn._('New Account'),
var d = new frappe.ui.Dialog({
title:frappe._('New Account'),
fields: [
{fieldtype:'Data', fieldname:'account_name', label:wn._('New Account Name'), reqd:true,
description: wn._("Name of new Account. Note: Please don't create accounts for Customers and Suppliers,")+
wn._("they are created automatically from the Customer and Supplier master")},
{fieldtype:'Select', fieldname:'group_or_ledger', label:wn._('Group or Ledger'),
options:'Group\nLedger', description: wn._('Further accounts can be made under Groups,')+
wn._('but entries can be made against Ledger')},
{fieldtype:'Select', fieldname:'account_type', label:wn._('Account Type'),
{fieldtype:'Data', fieldname:'account_name', label:frappe._('New Account Name'), reqd:true,
description: frappe._("Name of new Account. Note: Please don't create accounts for Customers and Suppliers,")+
frappe._("they are created automatically from the Customer and Supplier master")},
{fieldtype:'Select', fieldname:'group_or_ledger', label:frappe._('Group or Ledger'),
options:'Group\nLedger', description: frappe._('Further accounts can be made under Groups,')+
frappe._('but entries can be made against Ledger')},
{fieldtype:'Select', fieldname:'account_type', label:frappe._('Account Type'),
options: ['', 'Fixed Asset Account', 'Bank or Cash', 'Expense Account', 'Tax',
'Income Account', 'Chargeable'].join('\n'),
description: wn._("Optional. This setting will be used to filter in various transactions.") },
{fieldtype:'Float', fieldname:'tax_rate', label:wn._('Tax Rate')},
{fieldtype:'Button', fieldname:'create_new', label:wn._('Create New') }
description: frappe._("Optional. This setting will be used to filter in various transactions.") },
{fieldtype:'Float', fieldname:'tax_rate', label:frappe._('Tax Rate')},
{fieldtype:'Button', fieldname:'create_new', label:frappe._('Create New') }
]
})
@ -259,7 +259,7 @@ erpnext.AccountsChart = Class.extend({
v.master_type = '';
v.company = me.company;
return wn.call({
return frappe.call({
args: v,
method: 'erpnext.accounts.utils.add_ac',
callback: function(r) {
@ -283,14 +283,14 @@ erpnext.AccountsChart = Class.extend({
new_cost_center: function(){
var me = this;
// the dialog
var d = new wn.ui.Dialog({
title:wn._('New Cost Center'),
var d = new frappe.ui.Dialog({
title:frappe._('New Cost Center'),
fields: [
{fieldtype:'Data', fieldname:'cost_center_name', label:wn._('New Cost Center Name'), reqd:true},
{fieldtype:'Select', fieldname:'group_or_ledger', label:wn._('Group or Ledger'),
options:'Group\nLedger', description:wn._('Further accounts can be made under Groups,')+
wn._('but entries can be made against Ledger')},
{fieldtype:'Button', fieldname:'create_new', label:wn._('Create New') }
{fieldtype:'Data', fieldname:'cost_center_name', label:frappe._('New Cost Center Name'), reqd:true},
{fieldtype:'Select', fieldname:'group_or_ledger', label:frappe._('Group or Ledger'),
options:'Group\nLedger', description:frappe._('Further accounts can be made under Groups,')+
frappe._('but entries can be made against Ledger')},
{fieldtype:'Button', fieldname:'create_new', label:frappe._('Create New') }
]
});
@ -306,7 +306,7 @@ erpnext.AccountsChart = Class.extend({
v.parent_cost_center = node.data('label');
v.company = me.company;
return wn.call({
return frappe.call({
args: v,
method: 'erpnext.accounts.utils.add_cc',
callback: function(r) {

View File

@ -2,25 +2,25 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import webnotes.defaults
from webnotes.utils import flt
import frappe
import frappe.defaults
from frappe.utils import flt
from erpnext.accounts.utils import get_balance_on
@webnotes.whitelist()
@frappe.whitelist()
def get_companies():
"""get a list of companies based on permission"""
return [d.name for d in webnotes.get_list("Company", fields=["name"],
return [d.name for d in frappe.get_list("Company", fields=["name"],
order_by="name")]
@webnotes.whitelist()
@frappe.whitelist()
def get_children():
args = webnotes.local.form_dict
args = frappe.local.form_dict
ctype, company = args['ctype'], args['comp']
# root
if args['parent'] in ("Accounts", "Cost Centers"):
acc = webnotes.conn.sql(""" select
acc = frappe.conn.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 = webnotes.conn.sql("""select
acc = frappe.conn.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 = webnotes.conn.sql("select default_currency from `tabCompany` where name = %s", company)[0][0]
currency = frappe.conn.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

View File

@ -1,288 +1,288 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt"
wn.module_page["Accounts"] = [
frappe.module_page["Accounts"] = [
{
top: true,
title: wn._("Documents"),
title: frappe._("Documents"),
icon: "icon-copy",
items: [
{
label: wn._("Journal Voucher"),
description: wn._("Accounting journal entries."),
label: frappe._("Journal Voucher"),
description: frappe._("Accounting journal entries."),
doctype:"Journal Voucher"
},
{
label: wn._("Sales Invoice"),
description: wn._("Bills raised to Customers."),
label: frappe._("Sales Invoice"),
description: frappe._("Bills raised to Customers."),
doctype:"Sales Invoice"
},
{
label: wn._("Purchase Invoice"),
description: wn._("Bills raised by Suppliers."),
label: frappe._("Purchase Invoice"),
description: frappe._("Bills raised by Suppliers."),
doctype:"Purchase Invoice"
},
]
},
{
title: wn._("Masters"),
title: frappe._("Masters"),
icon: "icon-book",
items: [
{
label: wn._("Chart of Accounts"),
label: frappe._("Chart of Accounts"),
route: "Accounts Browser/Account",
description: wn._("Structure of books of accounts."),
description: frappe._("Structure of books of accounts."),
doctype:"Account"
},
{
label: wn._("Chart of Cost Centers"),
label: frappe._("Chart of Cost Centers"),
route: "Accounts Browser/Cost Center",
description: wn._("Structure cost centers for budgeting."),
description: frappe._("Structure cost centers for budgeting."),
doctype:"Cost Center"
},
{
label: wn._("Customer"),
description: wn._("Customer database."),
label: frappe._("Customer"),
description: frappe._("Customer database."),
doctype:"Customer"
},
{
label: wn._("Supplier"),
description: wn._("Supplier database."),
label: frappe._("Supplier"),
description: frappe._("Supplier database."),
doctype:"Supplier"
},
]
},
{
title: wn._("Setup"),
title: frappe._("Setup"),
icon: "icon-wrench",
items: [
{
label: wn._("Company"),
description: wn._("Company Master."),
label: frappe._("Company"),
description: frappe._("Company Master."),
doctype:"Company"
},
{
label: wn._("Fiscal Year"),
description: wn._("Accounting Year."),
label: frappe._("Fiscal Year"),
description: frappe._("Accounting Year."),
doctype:"Fiscal Year"
},
]
},
{
title: wn._("Tools"),
title: frappe._("Tools"),
icon: "icon-wrench",
items: [
{
"route":"Form/Bank Reconciliation/Bank Reconciliation",
"label": wn._("Bank Reconciliation"),
"description": wn._("Update bank payment dates with journals."),
"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": wn._("Payment Reconciliation"),
"description": wn._("Match non-linked Invoices and Payments."),
"label": frappe._("Payment Reconciliation"),
"description": frappe._("Match non-linked Invoices and Payments."),
doctype: "Payment to Invoice Matching Tool"
},
{
"label": wn._("Period Closing Voucher"),
"label": frappe._("Period Closing Voucher"),
"doctype": "Period Closing Voucher",
description: wn._("Close Balance Sheet and book Profit or Loss.")
description: frappe._("Close Balance Sheet and book Profit or Loss.")
},
]
},
{
title: wn._("Setup"),
title: frappe._("Setup"),
icon: "icon-cog",
items: [
{
"label": wn._("Accounts Settings"),
"label": frappe._("Accounts Settings"),
"route": "Form/Accounts Settings",
"doctype":"Accounts Settings",
"description": wn._("Settings for Accounts")
"description": frappe._("Settings for Accounts")
},
{
"label": wn._("Sales Taxes and Charges Master"),
"label": frappe._("Sales Taxes and Charges Master"),
"doctype":"Sales Taxes and Charges Master",
"description": wn._("Tax Template for Sales")
"description": frappe._("Tax Template for Sales")
},
{
"label": wn._("Purchase Taxes and Charges Master"),
"label": frappe._("Purchase Taxes and Charges Master"),
"doctype":"Purchase Taxes and Charges Master",
"description": wn._("Tax Template for Purchase")
"description": frappe._("Tax Template for Purchase")
},
{
"label": wn._("Shipping Rules"),
"label": frappe._("Shipping Rules"),
"doctype":"Shipping Rule",
"description": wn._("Rules to calculate shipping amount for a sale")
"description": frappe._("Rules to calculate shipping amount for a sale")
},
{
"label": wn._("Currency Exchange"),
"label": frappe._("Currency Exchange"),
"doctype":"Currency Exchange",
"description": wn._("Manage exchange rates for currency conversion")
"description": frappe._("Manage exchange rates for currency conversion")
},
{
"label": wn._("Point-of-Sale Setting"),
"label": frappe._("Point-of-Sale Setting"),
"doctype":"POS Setting",
"description": wn._("User settings for Point-of-sale (POS)")
"description": frappe._("User settings for Point-of-sale (POS)")
},
{
"doctype":"Budget Distribution",
"label": wn._("Budget Distribution"),
"description": wn._("Seasonality for setting budgets.")
"label": frappe._("Budget Distribution"),
"description": frappe._("Seasonality for setting budgets.")
},
{
"doctype":"Terms and Conditions",
"label": wn._("Terms and Conditions Template"),
description: wn._("Template of terms or contract.")
"label": frappe._("Terms and Conditions Template"),
description: frappe._("Template of terms or contract.")
},
{
"doctype":"Mode of Payment",
"label": wn._("Mode of Payment"),
description: wn._("e.g. Bank, Cash, Credit Card")
"label": frappe._("Mode of Payment"),
description: frappe._("e.g. Bank, Cash, Credit Card")
},
{
"doctype":"C-Form",
"label": wn._("C-Form"),
description: wn._("C-Form records"),
"label": frappe._("C-Form"),
description: frappe._("C-Form records"),
country: "India"
}
]
},
{
title: wn._("Main Reports"),
title: frappe._("Main Reports"),
right: true,
icon: "icon-table",
items: [
{
"label":wn._("General Ledger"),
"label":frappe._("General Ledger"),
doctype: "GL Entry",
route: "query-report/General Ledger"
},
{
"label":wn._("Trial Balance"),
"label":frappe._("Trial Balance"),
page: "trial-balance"
},
{
"page":"Financial Statements",
"label": wn._("Financial Statements")
"label": frappe._("Financial Statements")
},
{
"label":wn._("Accounts Receivable"),
"label":frappe._("Accounts Receivable"),
route: "query-report/Accounts Receivable",
doctype: "Sales Invoice"
},
{
"label":wn._("Accounts Payable"),
"label":frappe._("Accounts Payable"),
route: "query-report/Accounts Payable",
doctype: "Purchase Invoice"
},
{
"label":wn._("Sales Register"),
"label":frappe._("Sales Register"),
route: "query-report/Sales Register",
doctype: "Sales Invoice"
},
{
"label":wn._("Purchase Register"),
"label":frappe._("Purchase Register"),
route: "query-report/Purchase Register",
doctype: "Purchase Invoice"
},
]
},
{
title: wn._("Analytics"),
title: frappe._("Analytics"),
right: true,
icon: "icon-bar-chart",
items: [
{
"label":wn._("Financial Analytics"),
"label":frappe._("Financial Analytics"),
page: "financial-analytics"
},
{
"label":wn._("Gross Profit"),
"label":frappe._("Gross Profit"),
route: "query-report/Gross Profit",
doctype: "Sales Invoice"
},
]
},
{
title: wn._("Reports"),
title: frappe._("Reports"),
right: true,
icon: "icon-list",
items: [
{
"label":wn._("Bank Reconciliation Statement"),
"label":frappe._("Bank Reconciliation Statement"),
route: "query-report/Bank Reconciliation Statement",
doctype: "Journal Voucher"
},
{
"label":wn._("Ordered Items To Be Billed"),
"label":frappe._("Ordered Items To Be Billed"),
route: "query-report/Ordered Items To Be Billed",
doctype: "Sales Invoice"
},
{
"label":wn._("Delivered Items To Be Billed"),
"label":frappe._("Delivered Items To Be Billed"),
route: "query-report/Delivered Items To Be Billed",
doctype: "Sales Invoice"
},
{
"label":wn._("Purchase Order Items To Be Billed"),
"label":frappe._("Purchase Order Items To Be Billed"),
route: "query-report/Purchase Order Items To Be Billed",
doctype: "Purchase Invoice"
},
{
"label":wn._("Received Items To Be Billed"),
"label":frappe._("Received Items To Be Billed"),
route: "query-report/Received Items To Be Billed",
doctype: "Purchase Invoice"
},
{
"label":wn._("Bank Clearance Summary"),
"label":frappe._("Bank Clearance Summary"),
route: "query-report/Bank Clearance Summary",
doctype: "Journal Voucher"
},
{
"label":wn._("Payment Period Based On Invoice Date"),
"label":frappe._("Payment Period Based On Invoice Date"),
route: "query-report/Payment Period Based On Invoice Date",
doctype: "Journal Voucher"
},
{
"label":wn._("Sales Partners Commission"),
"label":frappe._("Sales Partners Commission"),
route: "query-report/Sales Partners Commission",
doctype: "Sales Invoice"
},
{
"label":wn._("Customer Account Head"),
"label":frappe._("Customer Account Head"),
route: "query-report/Customer Account Head",
doctype: "Account"
},
{
"label":wn._("Supplier Account Head"),
"label":frappe._("Supplier Account Head"),
route: "query-report/Supplier Account Head",
doctype: "Account"
},
{
"label":wn._("Item-wise Sales Register"),
"label":frappe._("Item-wise Sales Register"),
route: "query-report/Item-wise Sales Register",
doctype: "Sales Invoice"
},
{
"label":wn._("Item-wise Purchase Register"),
"label":frappe._("Item-wise Purchase Register"),
route: "query-report/Item-wise Purchase Register",
doctype: "Purchase Invoice"
},
{
"label":wn._("Budget Variance Report"),
"label":frappe._("Budget Variance Report"),
route: "query-report/Budget Variance Report",
doctype: "Cost Center"
},
{
"label":wn._("Purchase Invoice Trends"),
"label":frappe._("Purchase Invoice Trends"),
route: "query-report/Purchase Invoice Trends",
doctype: "Purchase Invoice"
},
{
"label":wn._("Sales Invoice Trends"),
"label":frappe._("Sales Invoice Trends"),
route: "query-report/Sales Invoice Trends",
doctype: "Sales Invoice"
},
@ -291,5 +291,5 @@ wn.module_page["Accounts"] = [
]
pscript['onload_accounts-home'] = function(wrapper) {
wn.views.moduleview.make(wrapper, "Accounts");
frappe.views.moduleview.make(wrapper, "Accounts");
}

View File

@ -1,12 +1,12 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.require("assets/erpnext/js/account_tree_grid.js");
frappe.require("assets/erpnext/js/account_tree_grid.js");
wn.pages['financial-analytics'].onload = function(wrapper) {
wn.ui.make_app_page({
frappe.pages['financial-analytics'].onload = function(wrapper) {
frappe.ui.make_app_page({
parent: wrapper,
title: wn._('Financial Analytics'),
title: frappe._('Financial Analytics'),
single_column: true
});
erpnext.trial_balance = new erpnext.FinancialAnalytics(wrapper, 'Financial Analytics');
@ -16,7 +16,7 @@ wn.pages['financial-analytics'].onload = function(wrapper) {
erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
filters: [
{fieldtype:"Select", label: wn._("PL or BS"), options:["Profit and Loss", "Balance Sheet"],
{fieldtype:"Select", label: frappe._("PL or BS"), options:["Profit and Loss", "Balance Sheet"],
filter: function(val, item, opts, me) {
if(item._show) return true;
@ -26,27 +26,27 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
return me.apply_zero_filter(val, item, opts, me);
}},
{fieldtype:"Select", label: wn._("Company"), link:"Company", default_value: "Select Company...",
{fieldtype:"Select", label: frappe._("Company"), link:"Company", default_value: "Select Company...",
filter: function(val, item, opts) {
return item.company == val || val == opts.default_value || item._show;
}},
{fieldtype:"Select", label: wn._("Fiscal Year"), link:"Fiscal Year",
{fieldtype:"Select", label: frappe._("Fiscal Year"), link:"Fiscal Year",
default_value: "Select Fiscal Year..."},
{fieldtype:"Date", label: wn._("From Date")},
{fieldtype:"Label", label: wn._("To")},
{fieldtype:"Date", label: wn._("To Date")},
{fieldtype:"Select", label: wn._("Range"),
{fieldtype:"Date", label: frappe._("From Date")},
{fieldtype:"Label", label: frappe._("To")},
{fieldtype:"Date", label: frappe._("To Date")},
{fieldtype:"Select", label: frappe._("Range"),
options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]},
{fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white"},
{fieldtype:"Button", label: wn._("Reset Filters")}
{fieldtype:"Button", label: frappe._("Refresh"), icon:"icon-refresh icon-white"},
{fieldtype:"Button", label: frappe._("Reset Filters")}
],
setup_columns: function() {
var std_columns = [
{id: "check", name: wn._("Plot"), field: "check", width: 30,
{id: "check", name: frappe._("Plot"), field: "check", width: 30,
formatter: this.check_formatter},
{id: "name", name: wn._("Account"), field: "name", width: 300,
{id: "name", name: frappe._("Account"), field: "name", width: 300,
formatter: this.tree_formatter},
{id: "opening", name: wn._("Opening"), field: "opening", hidden: true,
{id: "opening", name: frappe._("Opening"), field: "opening", hidden: true,
formatter: this.currency_formatter}
];
@ -59,7 +59,7 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
this.trigger_refresh_on_change(["pl_or_bs"]);
this.filter_inputs.pl_or_bs
.add_options($.map(wn.report_dump.data["Cost Center"], function(v) {return v.name;}));
.add_options($.map(frappe.report_dump.data["Cost Center"], function(v) {return v.name;}));
this.setup_plot_check();
},
@ -72,13 +72,13 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
// setup cost center map
if(!this.cost_center_by_name) {
this.cost_center_by_name = this.make_name_map(wn.report_dump.data["Cost Center"]);
this.cost_center_by_name = this.make_name_map(frappe.report_dump.data["Cost Center"]);
}
var cost_center = inList(["Balance Sheet", "Profit and Loss"], this.pl_or_bs)
? null : this.cost_center_by_name[this.pl_or_bs];
$.each(wn.report_dump.data['GL Entry'], function(i, gl) {
$.each(frappe.report_dump.data['GL Entry'], function(i, gl) {
var filter_by_cost_center = (function() {
if(cost_center) {
if(gl.cost_center) {

View File

@ -4,9 +4,9 @@
erpnext.fs = {}
pscript['onload_Financial Statements'] = function(wrapper) {
wn.ui.make_app_page({
frappe.ui.make_app_page({
parent: wrapper,
"title": wn._("Financial Statements"),
"title": frappe._("Financial Statements"),
"single_column": true,
});
@ -34,18 +34,18 @@ pscript['onload_Financial Statements'] = function(wrapper) {
options: ['Loading...']
})
wrapper.appframe.add_button(wn._("Create"), function() {
wrapper.appframe.add_button(frappe._("Create"), function() {
pscript.stmt_new();
}, "icon-refresh")
wrapper.appframe.add_button(wn._("Print"), function() {
wrapper.appframe.add_button(frappe._("Print"), function() {
_p.go($i('print_html').innerHTML);
}, "icon-print")
$(wrapper).find(".layout-main").html('<div id="print_html">\
<div id="stmt_title1" style="margin:16px 0px 4px 0px; font-size: 16px; font-weight: bold; color: #888;"></div>\
<div id="stmt_title2" style="margin:0px 0px 8px 0px; font-size: 16px; font-weight: bold;"></div>\
<div id="stmt_tree" style="margin: 0px 0px 16px; overflow: auto;">'+wn._('Please select options and click on Create')+'</div>\
<div id="stmt_tree" style="margin: 0px 0px 16px; overflow: auto;">'+frappe._('Please select options and click on Create')+'</div>\
</div>').css({"min-height": "400px"});
// load companies
@ -61,7 +61,7 @@ pscript['onload_Financial Statements'] = function(wrapper) {
pscript.stmt_new = function(stmt,company_name,level,period,year) {
$i('stmt_tree').innerHTML = wn._('Refreshing....');
$i('stmt_tree').innerHTML = frappe._('Refreshing....');
$i('stmt_tree').style.display = 'block';
var company =erpnext.fs.stmt_company.get_value();

View File

@ -1,12 +1,12 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.require("assets/erpnext/js/account_tree_grid.js");
frappe.require("assets/erpnext/js/account_tree_grid.js");
wn.pages['trial-balance'].onload = function(wrapper) {
wn.ui.make_app_page({
frappe.pages['trial-balance'].onload = function(wrapper) {
frappe.ui.make_app_page({
parent: wrapper,
title: wn._('Trial Balance'),
title: frappe._('Trial Balance'),
single_column: true
});
var TrialBalance = erpnext.AccountTreeGrid.extend({
@ -18,7 +18,7 @@ wn.pages['trial-balance'].onload = function(wrapper) {
this.wrapper.bind("make", function() {
$('<div style="margin: 10px 0px; "\
class="with_period_closing_entry"><input type="checkbox" checked="checked">' +
wn._("With period closing entry") + '</div>')
frappe._("With period closing entry") + '</div>')
.appendTo(me.wrapper)
.find("input").click(function() { me.refresh(); });
});

View File

@ -3,23 +3,23 @@
from __future__ import unicode_literals
import webnotes
from webnotes import _
from webnotes.defaults import get_restrictions
import frappe
from frappe import _
from frappe.defaults import get_restrictions
from erpnext.utilities.doctype.address.address import get_address_display
from erpnext.utilities.doctype.contact.contact import get_contact_details
@webnotes.whitelist()
@frappe.whitelist()
def get_party_details(party=None, account=None, party_type="Customer", company=None,
posting_date=None, price_list=None, currency=None):
out = webnotes._dict(set_account_and_due_date(party, account, party_type, company, posting_date))
out = frappe._dict(set_account_and_due_date(party, account, party_type, company, posting_date))
party = out[party_type.lower()]
if not webnotes.has_permission(party_type, "read", party):
webnotes.throw("Not Permitted", webnotes.PermissionError)
if not frappe.has_permission(party_type, "read", party):
frappe.throw("Not Permitted", frappe.PermissionError)
party_bean = webnotes.bean(party_type, party)
party_bean = frappe.bean(party_type, party)
party = party_bean.doc
set_address_and_contact(out, party, party_type)
@ -40,9 +40,9 @@ def get_party_details(party=None, account=None, party_type="Customer", company=N
def set_address_and_contact(out, party, party_type):
out.update({
party_type.lower() + "_address": webnotes.conn.get_value("Address",
party_type.lower() + "_address": frappe.conn.get_value("Address",
{party_type.lower(): party.name, "is_primary_address":1}, "name"),
"contact_person": webnotes.conn.get_value("Contact",
"contact_person": frappe.conn.get_value("Contact",
{party_type.lower(): party.name, "is_primary_contact":1}, "name")
})
@ -78,14 +78,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 = webnotes.conn.get_value("Customer Group",
price_list = frappe.conn.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 = webnotes.conn.get_value("Price List", price_list, "currency")
out.price_list_currency = frappe.conn.get_value("Price List", price_list, "currency")
out["selling_price_list" if party.doctype=="Customer" else "buying_price_list"] = price_list
@ -100,7 +100,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 = webnotes.conn.get_value('Account', account, 'master_name')
party = frappe.conn.get_value('Account', account, 'master_name')
account_fieldname = "debit_to" if party_type=="Customer" else "credit_to"
@ -113,10 +113,10 @@ def set_account_and_due_date(party, account, party_type, company, posting_date):
def get_party_account(company, party, party_type):
if not company:
webnotes.throw(_("Please select company first."))
frappe.throw(_("Please select company first."))
if party:
acc_head = webnotes.conn.get_value("Account", {"master_name":party,
acc_head = frappe.conn.get_value("Account", {"master_name":party,
"master_type": party_type, "company": company})
if not acc_head:
@ -130,11 +130,11 @@ def get_due_date(posting_date, party, party_type, account, company):
if posting_date:
credit_days = 0
if account:
credit_days = webnotes.conn.get_value("Account", account, "credit_days")
credit_days = frappe.conn.get_value("Account", account, "credit_days")
if party and not credit_days:
credit_days = webnotes.conn.get_value(party_type, party, "credit_days")
credit_days = frappe.conn.get_value(party_type, party, "credit_days")
if company and not credit_days:
credit_days = webnotes.conn.get_value("Company", company, "credit_days")
credit_days = frappe.conn.get_value("Company", company, "credit_days")
due_date = add_days(posting_date, credit_days) if credit_days else posting_date
@ -142,16 +142,16 @@ def get_due_date(posting_date, party, party_type, account, company):
def create_party_account(party, party_type, company):
if not company:
webnotes.throw(_("Company is required"))
frappe.throw(_("Company is required"))
company_details = webnotes.conn.get_value("Company", company,
company_details = frappe.conn.get_value("Company", company,
["abbr", "receivables_group", "payables_group"], as_dict=True)
if not webnotes.conn.exists("Account", (party + " - " + company_details.abbr)):
if not frappe.conn.exists("Account", (party + " - " + company_details.abbr)):
parent_account = company_details.receivables_group \
if party_type=="Customer" else company_details.payables_group
# create
account = webnotes.bean({
account = frappe.bean({
"doctype": "Account",
'account_name': party,
'parent_account': parent_account,
@ -162,4 +162,4 @@ def create_party_account(party, party_type, company):
"freeze_account": "No"
}).insert(ignore_permissions=True)
webnotes.msgprint(_("Account Created") + ": " + account.doc.name)
frappe.msgprint(_("Account Created") + ": " + account.doc.name)

View File

@ -1,22 +1,22 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.query_reports["Accounts Payable"] = {
frappe.query_reports["Accounts Payable"] = {
"filters": [
{
"fieldname":"company",
"label": wn._("Company"),
"label": frappe._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_default("company")
"default": frappe.defaults.get_default("company")
},
{
"fieldname":"account",
"label": wn._("Account"),
"label": frappe._("Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
var company = wn.query_report.filters_by_name.company.get_value();
var company = frappe.query_report.filters_by_name.company.get_value();
return {
"query": "accounts.utils.get_account_list",
"filters": {
@ -30,13 +30,13 @@ wn.query_reports["Accounts Payable"] = {
},
{
"fieldname":"report_date",
"label": wn._("Date"),
"label": frappe._("Date"),
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"ageing_based_on",
"label": wn._("Ageing Based On"),
"label": frappe._("Ageing Based On"),
"fieldtype": "Select",
"options": 'Posting Date' + NEWLINE + 'Due Date',
"default": "Posting Date"

View File

@ -2,17 +2,17 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import getdate, nowdate, flt, cstr
from webnotes import msgprint, _
import frappe
from frappe.utils import getdate, nowdate, flt, cstr
from frappe import msgprint, _
from erpnext.accounts.report.accounts_receivable.accounts_receivable import get_ageing_data
def execute(filters=None):
if not filters: filters = {}
supplier_naming_by = webnotes.conn.get_value("Buying Settings", None, "supp_master_name")
supplier_naming_by = frappe.conn.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 webnotes.conn.sql("""select acc.name,
account_map = dict(((r.name, r) for r in frappe.conn.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 = webnotes.conn.sql("""select * from `tabGL Entry`
gl_entries = frappe.conn.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 = webnotes.conn.sql_list("""select name from `tabAccount`
supplier_accounts = frappe.conn.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 webnotes.conn.sql("""select acc.name, supp.supplier_type from `tabSupplier` supp,
for each in frappe.conn.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]
@ -127,15 +127,15 @@ def get_account_supplier_type_map():
def get_voucher_details():
voucher_details = {}
for dt in ["Purchase Invoice", "Journal Voucher"]:
voucher_details.setdefault(dt, webnotes._dict())
for t in webnotes.conn.sql("""select name, due_date, bill_no, bill_date
voucher_details.setdefault(dt, frappe._dict())
for t in frappe.conn.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 = webnotes.conn.sql("""
payment_amount = frappe.conn.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

View File

@ -1,22 +1,22 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.query_reports["Accounts Receivable"] = {
frappe.query_reports["Accounts Receivable"] = {
"filters": [
{
"fieldname":"company",
"label": wn._("Company"),
"label": frappe._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_default("company")
"default": frappe.defaults.get_default("company")
},
{
"fieldname":"account",
"label": wn._("Account"),
"label": frappe._("Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
var company = wn.query_report.filters_by_name.company.get_value();
var company = frappe.query_report.filters_by_name.company.get_value();
return {
"query": "accounts.utils.get_account_list",
"filters": {
@ -30,13 +30,13 @@ wn.query_reports["Accounts Receivable"] = {
},
{
"fieldname":"report_date",
"label": wn._("Date"),
"label": frappe._("Date"),
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"ageing_based_on",
"label": wn._("Ageing Based On"),
"label": frappe._("Ageing Based On"),
"fieldtype": "Select",
"options": 'Posting Date' + NEWLINE + 'Due Date',
"default": "Posting Date"

View File

@ -2,20 +2,20 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import _
from webnotes.utils import getdate, nowdate, flt
import frappe
from frappe import _
from frappe.utils import getdate, nowdate, flt
class AccountsReceivableReport(object):
def __init__(self, filters=None):
self.filters = webnotes._dict(filters or {})
self.filters = frappe._dict(filters or {})
self.filters.report_date = getdate(self.filters.report_date or nowdate())
self.age_as_on = getdate(nowdate()) \
if self.filters.report_date > getdate(nowdate()) \
else self.filters.report_date
def run(self):
customer_naming_by = webnotes.conn.get_value("Selling Settings", None, "cust_master_name")
customer_naming_by = frappe.conn.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 webnotes.conn.sql("""select
self.account_map = dict(((r.name, r) for r in frappe.conn.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(webnotes.conn.sql("""select name, due_date
self.invoice_due_date_map = dict(frappe.conn.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 = webnotes.conn.sql("""select * from `tabGL Entry`
self.gl_entries = frappe.conn.sql("""select * from `tabGL Entry`
where docstatus < 2 {0} order by posting_date, account""".format(conditions),
values, as_dict=True)
return self.gl_entries
@ -149,7 +149,7 @@ class AccountsReceivableReport(object):
else:
account_map = self.get_account_map()
if not account_map:
webnotes.throw(_("No Customer Accounts found."))
frappe.throw(_("No Customer Accounts found."))
else:
accounts_list = ['"{0}"'.format(ac) for ac in account_map]
conditions.append("account in ({0})".format(", ".join(accounts_list)))

View File

@ -1,24 +1,24 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.query_reports["Bank Clearance Summary"] = {
frappe.query_reports["Bank Clearance Summary"] = {
"filters": [
{
"fieldname":"from_date",
"label": wn._("From Date"),
"label": frappe._("From Date"),
"fieldtype": "Date",
"default": wn.defaults.get_user_default("year_start_date"),
"default": frappe.defaults.get_user_default("year_start_date"),
"width": "80"
},
{
"fieldname":"to_date",
"label": wn._("To Date"),
"label": frappe._("To Date"),
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"account",
"label": wn._("Bank Account"),
"label": frappe._("Bank Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {

View File

@ -2,8 +2,8 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import _, msgprint
import frappe
from frappe import _, msgprint
def execute(filters=None):
if not filters: filters = {}
@ -33,7 +33,7 @@ def get_conditions(filters):
def get_entries(filters):
conditions = get_conditions(filters)
entries = webnotes.conn.sql("""select jv.name, jvd.account, jv.posting_date,
entries = frappe.conn.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

View File

@ -1,11 +1,11 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.query_reports["Bank Reconciliation Statement"] = {
frappe.query_reports["Bank Reconciliation Statement"] = {
"filters": [
{
"fieldname":"account",
"label": wn._("Bank Account"),
"label": frappe._("Bank Account"),
"fieldtype": "Link",
"options": "Account",
"reqd": 1,
@ -21,7 +21,7 @@ wn.query_reports["Bank Reconciliation Statement"] = {
},
{
"fieldname":"report_date",
"label": wn._("Date"),
"label": frappe._("Date"),
"fieldtype": "Date",
"default": get_today(),
"reqd": 1

View File

@ -2,13 +2,13 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt
import frappe
from frappe.utils import flt
def execute(filters=None):
if not filters: filters = {}
debit_or_credit = webnotes.conn.get_value("Account", filters["account"], "debit_or_credit")
debit_or_credit = frappe.conn.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 = webnotes.conn.sql("""select
entries = frappe.conn.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

View File

@ -1,28 +1,28 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.query_reports["Budget Variance Report"] = {
frappe.query_reports["Budget Variance Report"] = {
"filters": [
{
fieldname: "fiscal_year",
label: wn._("Fiscal Year"),
label: frappe._("Fiscal Year"),
fieldtype: "Link",
options: "Fiscal Year",
default: sys_defaults.fiscal_year
},
{
fieldname: "period",
label: wn._("Period"),
label: frappe._("Period"),
fieldtype: "Select",
options: "Monthly\nQuarterly\nHalf-Yearly\nYearly",
default: "Monthly"
},
{
fieldname: "company",
label: wn._("Company"),
label: frappe._("Company"),
fieldtype: "Link",
options: "Company",
default: wn.defaults.get_default("company")
default: frappe.defaults.get_default("company")
},
]
}

View File

@ -2,9 +2,9 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import _, msgprint
from webnotes.utils import flt
import frappe
from frappe import _, msgprint
from frappe.utils import flt
import time
from erpnext.accounts.utils import get_fiscal_year
from erpnext.controllers.trends import get_period_date_ranges, get_period_month_ranges
@ -62,7 +62,7 @@ def get_columns(filters):
#Get cost center & target details
def get_costcenter_target_details(filters):
return webnotes.conn.sql("""select cc.name, cc.distribution_id,
return frappe.conn.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 webnotes.conn.sql("""select bd.name, bdd.month, bdd.percentage_allocation
for d in frappe.conn.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 = webnotes.conn.sql("""select gl.account, gl.debit, gl.credit,
ac_details = frappe.conn.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
@ -108,7 +108,7 @@ def get_costcenter_account_month_map(filters):
month = datetime.date(2013, month_id, 1).strftime('%B')
cam_map.setdefault(ccd.name, {}).setdefault(ccd.account, {})\
.setdefault(month, webnotes._dict({
.setdefault(month, frappe._dict({
"target": 0.0, "actual": 0.0
}))

View File

@ -2,13 +2,13 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
def execute(filters=None):
account_map = get_account_map()
columns = get_columns(account_map)
data = []
customers = webnotes.conn.sql("select name from tabCustomer where docstatus < 2")
customers = frappe.conn.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 = webnotes.conn.sql("""select name, company, master_name
accounts = frappe.conn.sql("""select name, company, master_name
from `tabAccount` where master_type = 'Customer'
and ifnull(master_name, '') != '' and docstatus < 2""", as_dict=1)

View File

@ -1,29 +1,29 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.query_reports["General Ledger"] = {
frappe.query_reports["General Ledger"] = {
"filters": [
{
"fieldname":"company",
"label": wn._("Company"),
"label": frappe._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_user_default("company"),
"default": frappe.defaults.get_user_default("company"),
"reqd": 1
},
{
"fieldname":"from_date",
"label": wn._("From Date"),
"label": frappe._("From Date"),
"fieldtype": "Date",
"default": wn.datetime.add_months(wn.datetime.get_today(), -1),
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
"reqd": 1,
"width": "60px"
},
{
"fieldname":"to_date",
"label": wn._("To Date"),
"label": frappe._("To Date"),
"fieldtype": "Date",
"default": wn.datetime.get_today(),
"default": frappe.datetime.get_today(),
"reqd": 1,
"width": "60px"
},
@ -32,11 +32,11 @@ wn.query_reports["General Ledger"] = {
},
{
"fieldname":"account",
"label": wn._("Account"),
"label": frappe._("Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
var company = wn.query_report.filters_by_name.company.get_value();
var company = frappe.query_report.filters_by_name.company.get_value();
return {
"doctype": "Account",
"filters": {
@ -47,18 +47,18 @@ wn.query_reports["General Ledger"] = {
},
{
"fieldname":"voucher_no",
"label": wn._("Voucher No"),
"label": frappe._("Voucher No"),
"fieldtype": "Data",
},
{
"fieldname":"group_by_voucher",
"label": wn._("Group by Voucher"),
"label": frappe._("Group by Voucher"),
"fieldtype": "Check",
"default": 1
},
{
"fieldname":"group_by_account",
"label": wn._("Group by Account"),
"label": frappe._("Group by Account"),
"fieldtype": "Check",
}
]

View File

@ -2,13 +2,13 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, flt
from webnotes import _
import frappe
from frappe.utils import cstr, flt
from frappe import _
def execute(filters=None):
account_details = {}
for acc in webnotes.conn.sql("""select name, debit_or_credit, group_or_ledger
for acc in frappe.conn.sql("""select name, debit_or_credit, group_or_ledger
from tabAccount""", as_dict=1):
account_details.setdefault(acc.name, acc)
@ -23,13 +23,13 @@ def execute(filters=None):
def validate_filters(filters, account_details):
if filters.get("account") and filters.get("group_by_account") \
and account_details[filters.account].group_or_ledger == "Ledger":
webnotes.throw(_("Can not filter based on Account, if grouped by Account"))
frappe.throw(_("Can not filter based on Account, if grouped by Account"))
if filters.get("voucher_no") and filters.get("group_by_voucher"):
webnotes.throw(_("Can not filter based on Voucher No, if grouped by Voucher"))
frappe.throw(_("Can not filter based on Voucher No, if grouped by Voucher"))
if filters.from_date > filters.to_date:
webnotes.throw(_("From Date must be before To Date"))
frappe.throw(_("From Date must be before To Date"))
def get_columns():
return ["Posting Date:Date:100", "Account:Link/Account:200", "Debit:Float:100",
@ -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 = webnotes.conn.sql("""select posting_date, account,
gl_entries = frappe.conn.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 = webnotes.conn.get_value("Account", filters["account"], ["lft", "rgt"])
lft, rgt = frappe.conn.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:
@ -74,7 +74,7 @@ def get_conditions(filters):
conditions.append("voucher_no=%(voucher_no)s")
from webnotes.widgets.reportview import build_match_conditions
from frappe.widgets.reportview import build_match_conditions
match_conditions = build_match_conditions("GL Entry")
if match_conditions: conditions.append(match_conditions)
@ -121,9 +121,9 @@ def get_data_with_opening_closing(filters, account_details, gl_entries):
return data
def initialize_gle_map(gl_entries):
gle_map = webnotes._dict()
gle_map = frappe._dict()
for gle in gl_entries:
gle_map.setdefault(gle.account, webnotes._dict({
gle_map.setdefault(gle.account, frappe._dict({
"opening": 0,
"entries": [],
"total_debit": 0,

View File

@ -1,26 +1,26 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.query_reports["Gross Profit"] = {
frappe.query_reports["Gross Profit"] = {
"filters": [
{
"fieldname":"company",
"label": wn._("Company"),
"label": frappe._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_user_default("company")
"default": frappe.defaults.get_user_default("company")
},
{
"fieldname":"from_date",
"label": wn._("From Date"),
"label": frappe._("From Date"),
"fieldtype": "Date",
"default": wn.defaults.get_user_default("year_start_date")
"default": frappe.defaults.get_user_default("year_start_date")
},
{
"fieldname":"to_date",
"label": wn._("To Date"),
"label": frappe._("To Date"),
"fieldtype": "Date",
"default": wn.defaults.get_user_default("year_end_date")
"default": frappe.defaults.get_user_default("year_end_date")
},
]
}

View File

@ -2,8 +2,8 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt
import frappe
from frappe.utils import flt
from erpnext.stock.utils import get_buying_amount, get_sales_bom_buying_amount
def execute(filters=None):
@ -22,7 +22,7 @@ def execute(filters=None):
for row in source:
selling_amount = flt(row.base_amount)
item_sales_bom_map = item_sales_bom.get(row.parenttype, {}).get(row.name, webnotes._dict())
item_sales_bom_map = item_sales_bom.get(row.parenttype, {}).get(row.name, frappe._dict())
if item_sales_bom_map.get(row.item_code):
buying_amount = get_sales_bom_buying_amount(row.item_code, row.warehouse,
@ -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 = webnotes.conn.sql(query, filters, as_dict=True)
res = frappe.conn.sql(query, filters, as_dict=True)
out = {}
for r in res:
@ -73,11 +73,11 @@ def get_stock_ledger_entries(filters):
def get_item_sales_bom():
item_sales_bom = {}
for d in webnotes.conn.sql("""select parenttype, parent, parent_item,
for d in frappe.conn.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, webnotes._dict()).setdefault(d.parent,
webnotes._dict()).setdefault(d.parent_item, []).append(d)
item_sales_bom.setdefault(d.parenttype, frappe._dict()).setdefault(d.parent,
frappe._dict()).setdefault(d.parent_item, []).append(d)
return item_sales_bom
@ -90,7 +90,7 @@ def get_source_data(filters):
if filters.get("to_date"):
conditions += " and posting_date<=%(to_date)s"
delivery_note_items = webnotes.conn.sql("""select item.parenttype, dn.name,
delivery_note_items = frappe.conn.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 = webnotes.conn.sql("""select item.parenttype, si.name,
sales_invoice_items = frappe.conn.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",

View File

@ -1,34 +1,34 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.query_reports["Item-wise Purchase Register"] = {
frappe.query_reports["Item-wise Purchase Register"] = {
"filters": [
{
"fieldname":"from_date",
"label": wn._("From Date"),
"label": frappe._("From Date"),
"fieldtype": "Date",
"default": wn.defaults.get_user_default("year_start_date"),
"default": frappe.defaults.get_user_default("year_start_date"),
"width": "80"
},
{
"fieldname":"to_date",
"label": wn._("To Date"),
"label": frappe._("To Date"),
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname": "item_code",
"label": wn._("Item"),
"label": frappe._("Item"),
"fieldtype": "Link",
"options": "Item",
},
{
"fieldname":"account",
"label": wn._("Account"),
"label": frappe._("Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
var company = wn.query_report.filters_by_name.company.get_value();
var company = frappe.query_report.filters_by_name.company.get_value();
return {
"query": "accounts.utils.get_account_list",
"filters": {
@ -42,10 +42,10 @@ wn.query_reports["Item-wise Purchase Register"] = {
},
{
"fieldname":"company",
"label": wn._("Company"),
"label": frappe._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_default("company")
"default": frappe.defaults.get_default("company")
}
]
}

View File

@ -2,8 +2,8 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt
import frappe
from frappe.utils import flt
def execute(filters=None):
if not filters: filters = {}
@ -55,9 +55,9 @@ def get_conditions(filters):
def get_items(filters):
conditions = get_conditions(filters)
match_conditions = webnotes.build_match_conditions("Purchase Invoice")
match_conditions = frappe.build_match_conditions("Purchase Invoice")
return webnotes.conn.sql("""select pi_item.parent, pi.posting_date, pi.credit_to, pi.company,
return frappe.conn.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(webnotes.conn.sql("select name, stock_received_but_not_billed from tabCompany"))
return dict(frappe.conn.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 = webnotes.conn.sql("""select parent, account_head, item_wise_tax_detail
tax_details = frappe.conn.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]))

View File

@ -1,28 +1,28 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.query_reports["Item-wise Sales Register"] = wn.query_reports["Sales Register"] = {
frappe.query_reports["Item-wise Sales Register"] = frappe.query_reports["Sales Register"] = {
"filters": [
{
"fieldname":"from_date",
"label": wn._("From Date"),
"label": frappe._("From Date"),
"fieldtype": "Date",
"default": wn.defaults.get_default("year_start_date"),
"default": frappe.defaults.get_default("year_start_date"),
"width": "80"
},
{
"fieldname":"to_date",
"label": wn._("To Date"),
"label": frappe._("To Date"),
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"account",
"label": wn._("Account"),
"label": frappe._("Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
var company = wn.query_report.filters_by_name.company.get_value();
var company = frappe.query_report.filters_by_name.company.get_value();
return {
"query": "accounts.utils.get_account_list",
"filters": {
@ -36,10 +36,10 @@ wn.query_reports["Item-wise Sales Register"] = wn.query_reports["Sales Register"
},
{
"fieldname":"company",
"label": wn._("Company"),
"label": frappe._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_default("company")
"default": frappe.defaults.get_default("company")
}
]
}

View File

@ -2,8 +2,8 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt
import frappe
from frappe.utils import flt
def execute(filters=None):
if not filters: filters = {}
@ -55,7 +55,7 @@ def get_conditions(filters):
def get_items(filters):
conditions = get_conditions(filters)
return webnotes.conn.sql("""select si_item.parent, si.posting_date, si.debit_to, si.project_name,
return frappe.conn.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 = webnotes.conn.sql("""select parent, account_head, item_wise_tax_detail
tax_details = frappe.conn.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)),

View File

@ -1,30 +1,30 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.query_reports["Payment Period Based On Invoice Date"] = {
frappe.query_reports["Payment Period Based On Invoice Date"] = {
"filters": [
{
fieldname: "from_date",
label: wn._("From Date"),
label: frappe._("From Date"),
fieldtype: "Date",
default: wn.defaults.get_user_default("year_start_date"),
default: frappe.defaults.get_user_default("year_start_date"),
},
{
fieldname:"to_date",
label: wn._("To Date"),
label: frappe._("To Date"),
fieldtype: "Date",
default: get_today()
},
{
fieldname:"payment_type",
label: wn._("Payment Type"),
label: frappe._("Payment Type"),
fieldtype: "Select",
options: "Incoming\nOutgoing",
default: "Incoming"
},
{
fieldname:"account",
label: wn._("Account"),
label: frappe._("Account"),
fieldtype: "Link",
options: "Account",
get_query: function() {
@ -32,17 +32,17 @@ wn.query_reports["Payment Period Based On Invoice Date"] = {
query: "accounts.utils.get_account_list",
filters: {
is_pl_account: "No",
company: wn.query_report.filters_by_name.company.get_value()
company: frappe.query_report.filters_by_name.company.get_value()
}
}
}
},
{
fieldname:"company",
label: wn._("Company"),
label: frappe._("Company"),
fieldtype: "Link",
options: "Company",
default: wn.defaults.get_default("company")
default: frappe.defaults.get_default("company")
},
]
}

View File

@ -2,8 +2,8 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import msgprint, _
import frappe
from frappe import msgprint, _
from erpnext.accounts.report.accounts_receivable.accounts_receivable import get_ageing_data
def execute(filters=None):
@ -58,7 +58,7 @@ def get_conditions(filters):
else:
cond += " and master_type = 'Supplier'"
party_accounts = webnotes.conn.sql_list("""select name from `tabAccount`
party_accounts = frappe.conn.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 = webnotes.conn.sql("""select jv.name, jvd.account, jv.posting_date,
entries = frappe.conn.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 webnotes.conn.sql("""select name, posting_date from `tabSales Invoice`"""):
for t in frappe.conn.sql("""select name, posting_date from `tabSales Invoice`"""):
invoice_posting_date_map[t[0]] = t[1]
else:
for t in webnotes.conn.sql("""select name, posting_date from `tabPurchase Invoice`"""):
for t in frappe.conn.sql("""select name, posting_date from `tabPurchase Invoice`"""):
invoice_posting_date_map[t[0]] = t[1]
return invoice_posting_date_map

View File

@ -1,8 +1,8 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.require("assets/erpnext/js/purchase_trends_filters.js");
frappe.require("assets/erpnext/js/purchase_trends_filters.js");
wn.query_reports["Purchase Invoice Trends"] = {
frappe.query_reports["Purchase Invoice Trends"] = {
filters: get_filters()
}

View File

@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
from erpnext.controllers.trends import get_columns,get_data
def execute(filters=None):

View File

@ -1,28 +1,28 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.query_reports["Purchase Register"] = {
frappe.query_reports["Purchase Register"] = {
"filters": [
{
"fieldname":"from_date",
"label": wn._("From Date"),
"label": frappe._("From Date"),
"fieldtype": "Date",
"default": wn.defaults.get_user_default("year_start_date"),
"default": frappe.defaults.get_user_default("year_start_date"),
"width": "80"
},
{
"fieldname":"to_date",
"label": wn._("To Date"),
"label": frappe._("To Date"),
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"account",
"label": wn._("Account"),
"label": frappe._("Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
var company = wn.query_report.filters_by_name.company.get_value();
var company = frappe.query_report.filters_by_name.company.get_value();
return {
"query": "accounts.utils.get_account_list",
"filters": {
@ -36,10 +36,10 @@ wn.query_reports["Purchase Register"] = {
},
{
"fieldname":"company",
"label": wn._("Company"),
"label": frappe._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_default("company")
"default": frappe.defaults.get_default("company")
}
]
}

View File

@ -2,9 +2,9 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt
from webnotes import msgprint, _
import frappe
from frappe.utils import flt
from frappe import msgprint, _
def execute(filters=None):
if not filters: filters = {}
@ -72,12 +72,12 @@ def get_columns(invoice_list):
expense_accounts = tax_accounts = expense_columns = tax_columns = []
if invoice_list:
expense_accounts = webnotes.conn.sql_list("""select distinct expense_account
expense_accounts = frappe.conn.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 = webnotes.conn.sql_list("""select distinct account_head
tax_accounts = frappe.conn.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,26 +109,26 @@ def get_conditions(filters):
def get_invoices(filters):
conditions = get_conditions(filters)
return webnotes.conn.sql("""select name, posting_date, credit_to, supplier, supplier_name,
return frappe.conn.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 = webnotes.conn.sql("""select parent, expense_account, sum(base_amount) as amount
expense_details = frappe.conn.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)
invoice_expense_map = {}
for d in expense_details:
invoice_expense_map.setdefault(d.parent, webnotes._dict()).setdefault(d.expense_account, [])
invoice_expense_map.setdefault(d.parent, frappe._dict()).setdefault(d.expense_account, [])
invoice_expense_map[d.parent][d.expense_account] = flt(d.amount)
return invoice_expense_map
def get_invoice_tax_map(invoice_list, invoice_expense_map, expense_accounts):
tax_details = webnotes.conn.sql("""select parent, account_head, sum(tax_amount) as tax_amount
tax_details = frappe.conn.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)
@ -140,13 +140,13 @@ def get_invoice_tax_map(invoice_list, invoice_expense_map, expense_accounts):
else:
invoice_expense_map[d.parent][d.account_head] = flt(d.tax_amount)
else:
invoice_tax_map.setdefault(d.parent, webnotes._dict()).setdefault(d.account_head, [])
invoice_tax_map.setdefault(d.parent, frappe._dict()).setdefault(d.account_head, [])
invoice_tax_map[d.parent][d.account_head] = flt(d.tax_amount)
return invoice_expense_map, invoice_tax_map
def get_invoice_po_pr_map(invoice_list):
pi_items = webnotes.conn.sql("""select parent, purchase_order, purchase_receipt,
pi_items = frappe.conn.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)
@ -154,13 +154,13 @@ def get_invoice_po_pr_map(invoice_list):
invoice_po_pr_map = {}
for d in pi_items:
if d.purchase_order:
invoice_po_pr_map.setdefault(d.parent, webnotes._dict()).setdefault(
invoice_po_pr_map.setdefault(d.parent, frappe._dict()).setdefault(
"purchase_order", []).append(d.purchase_order)
if d.purchase_receipt:
invoice_po_pr_map.setdefault(d.parent, webnotes._dict()).setdefault(
invoice_po_pr_map.setdefault(d.parent, frappe._dict()).setdefault(
"purchase_receipt", []).append(d.purchase_receipt)
if d.project_name:
invoice_po_pr_map.setdefault(d.parent, webnotes._dict()).setdefault(
invoice_po_pr_map.setdefault(d.parent, frappe._dict()).setdefault(
"project_name", []).append(d.project_name)
return invoice_po_pr_map
@ -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 webnotes.conn.sql("""select name, parent_account from tabAccount
for acc in frappe.conn.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

View File

@ -1,8 +1,8 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.require("assets/erpnext/js/sales_trends_filters.js");
frappe.require("assets/erpnext/js/sales_trends_filters.js");
wn.query_reports["Sales Invoice Trends"] = {
frappe.query_reports["Sales Invoice Trends"] = {
filters: get_filters()
}

View File

@ -2,7 +2,7 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
from erpnext.controllers.trends import get_columns,get_data
def execute(filters=None):

View File

@ -1,28 +1,28 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
wn.query_reports["Sales Register"] = {
frappe.query_reports["Sales Register"] = {
"filters": [
{
"fieldname":"from_date",
"label": wn._("From Date"),
"label": frappe._("From Date"),
"fieldtype": "Date",
"default": wn.defaults.get_default("year_start_date"),
"default": frappe.defaults.get_default("year_start_date"),
"width": "80"
},
{
"fieldname":"to_date",
"label": wn._("To Date"),
"label": frappe._("To Date"),
"fieldtype": "Date",
"default": get_today()
},
{
"fieldname":"account",
"label": wn._("Account"),
"label": frappe._("Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
var company = wn.query_report.filters_by_name.company.get_value();
var company = frappe.query_report.filters_by_name.company.get_value();
return {
"query": "accounts.utils.get_account_list",
"filters": {
@ -36,10 +36,10 @@ wn.query_reports["Sales Register"] = {
},
{
"fieldname":"company",
"label": wn._("Company"),
"label": frappe._("Company"),
"fieldtype": "Link",
"options": "Company",
"default": wn.defaults.get_default("company")
"default": frappe.defaults.get_default("company")
}
]
}

View File

@ -2,9 +2,9 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt
from webnotes import msgprint, _
import frappe
from frappe.utils import flt
from frappe import msgprint, _
def execute(filters=None):
if not filters: filters = {}
@ -72,12 +72,12 @@ def get_columns(invoice_list):
income_accounts = tax_accounts = income_columns = tax_columns = []
if invoice_list:
income_accounts = webnotes.conn.sql_list("""select distinct income_account
income_accounts = frappe.conn.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 = webnotes.conn.sql_list("""select distinct account_head
tax_accounts = frappe.conn.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,26 +107,26 @@ def get_conditions(filters):
def get_invoices(filters):
conditions = get_conditions(filters)
return webnotes.conn.sql("""select name, posting_date, debit_to, project_name, customer,
return frappe.conn.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 = webnotes.conn.sql("""select parent, income_account, sum(base_amount) as amount
income_details = frappe.conn.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)
invoice_income_map = {}
for d in income_details:
invoice_income_map.setdefault(d.parent, webnotes._dict()).setdefault(d.income_account, [])
invoice_income_map.setdefault(d.parent, frappe._dict()).setdefault(d.income_account, [])
invoice_income_map[d.parent][d.income_account] = flt(d.amount)
return invoice_income_map
def get_invoice_tax_map(invoice_list, invoice_income_map, income_accounts):
tax_details = webnotes.conn.sql("""select parent, account_head,
tax_details = frappe.conn.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)
@ -139,13 +139,13 @@ def get_invoice_tax_map(invoice_list, invoice_income_map, income_accounts):
else:
invoice_income_map[d.parent][d.account_head] = flt(d.tax_amount)
else:
invoice_tax_map.setdefault(d.parent, webnotes._dict()).setdefault(d.account_head, [])
invoice_tax_map.setdefault(d.parent, frappe._dict()).setdefault(d.account_head, [])
invoice_tax_map[d.parent][d.account_head] = flt(d.tax_amount)
return invoice_income_map, invoice_tax_map
def get_invoice_so_dn_map(invoice_list):
si_items = webnotes.conn.sql("""select parent, sales_order, delivery_note
si_items = frappe.conn.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)
@ -153,10 +153,10 @@ def get_invoice_so_dn_map(invoice_list):
invoice_so_dn_map = {}
for d in si_items:
if d.sales_order:
invoice_so_dn_map.setdefault(d.parent, webnotes._dict()).setdefault(
invoice_so_dn_map.setdefault(d.parent, frappe._dict()).setdefault(
"sales_order", []).append(d.sales_order)
if d.delivery_note:
invoice_so_dn_map.setdefault(d.parent, webnotes._dict()).setdefault(
invoice_so_dn_map.setdefault(d.parent, frappe._dict()).setdefault(
"delivery_note", []).append(d.delivery_note)
return invoice_so_dn_map
@ -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 webnotes.conn.sql("""select name, territory from `tabCustomer`
for cust in frappe.conn.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 webnotes.conn.sql("""select name, parent_account from tabAccount
for acc in frappe.conn.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

View File

@ -2,13 +2,13 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
import frappe
def execute(filters=None):
account_map = get_account_map()
columns = get_columns(account_map)
data = []
suppliers = webnotes.conn.sql("select name from tabSupplier where docstatus < 2")
suppliers = frappe.conn.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 = webnotes.conn.sql("""select name, company, master_name
accounts = frappe.conn.sql("""select name, company, master_name
from `tabAccount` where master_type = 'Supplier'
and ifnull(master_name, '') != '' and docstatus < 2""", as_dict=1)

Some files were not shown because too many files have changed in this diff Show More