-webnotes +frappe 💥
This commit is contained in:
parent
8ae051cb39
commit
793ba6bd37
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Includes Accounting, Inventory, CRM, Sales, Purchase, Projects, HRMS. Built on Python / MySQL.
|
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)
|
- [User Guide](http://erpnext.org/user-guide.html)
|
||||||
- [Getting Help](http://erpnext.org/getting-help.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. Switch to root user using `sudo su`
|
||||||
1. create a folder where you want to install erpnext
|
1. create a folder where you want to install erpnext
|
||||||
1. go to the new folder
|
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`
|
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
|
##### 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
@ -1,5 +1,5 @@
|
|||||||
{%- if doc.letter_head -%}
|
{%- 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 -%}
|
{%- endif -%}
|
||||||
<!-- Page Layout Settings -->
|
<!-- Page Layout Settings -->
|
||||||
<div class='common page-header'>
|
<div class='common page-header'>
|
||||||
|
@ -11,7 +11,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
|||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||||
if(doc.__islocal) {
|
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";
|
throw "cannot create";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,8 +26,8 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|||||||
'is_pl_account', 'company'], false);
|
'is_pl_account', 'company'], false);
|
||||||
|
|
||||||
if(doc.group_or_ledger=='Ledger') {
|
if(doc.group_or_ledger=='Ledger') {
|
||||||
wn.model.with_doc("Accounts Settings", "Accounts Settings", function (name) {
|
frappe.model.with_doc("Accounts Settings", "Accounts Settings", function (name) {
|
||||||
var accounts_settings = wn.model.get_doc("Accounts Settings", name);
|
var accounts_settings = frappe.model.get_doc("Accounts Settings", name);
|
||||||
var display = accounts_settings["frozen_accounts_modifier"]
|
var display = accounts_settings["frozen_accounts_modifier"]
|
||||||
&& in_list(user_roles, 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
|
// read-only for root accounts
|
||||||
if(!doc.parent_account) {
|
if(!doc.parent_account) {
|
||||||
cur_frm.set_read_only();
|
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 {
|
} else {
|
||||||
// credit days and type if customer or supplier
|
// credit days and type if customer or supplier
|
||||||
cur_frm.set_intro(null);
|
cur_frm.set_intro(null);
|
||||||
@ -81,24 +81,24 @@ cur_frm.cscript.account_type = function(doc, cdt, cdn) {
|
|||||||
// Hide/unhide group or ledger
|
// Hide/unhide group or ledger
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
cur_frm.cscript.add_toolbar_buttons = function(doc) {
|
cur_frm.cscript.add_toolbar_buttons = function(doc) {
|
||||||
cur_frm.appframe.add_button(wn._('Chart of Accounts'),
|
cur_frm.appframe.add_button(frappe._('Chart of Accounts'),
|
||||||
function() { wn.set_route("Accounts Browser", "Account"); }, 'icon-sitemap')
|
function() { frappe.set_route("Accounts Browser", "Account"); }, 'icon-sitemap')
|
||||||
|
|
||||||
if (cstr(doc.group_or_ledger) == 'Group') {
|
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')
|
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet')
|
||||||
} else if (cstr(doc.group_or_ledger) == 'Ledger') {
|
} 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')
|
function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet')
|
||||||
|
|
||||||
cur_frm.appframe.add_button(wn._('View Ledger'), function() {
|
cur_frm.appframe.add_button(frappe._('View Ledger'), function() {
|
||||||
wn.route_options = {
|
frappe.route_options = {
|
||||||
"account": doc.name,
|
"account": doc.name,
|
||||||
"from_date": sys_defaults.year_start_date,
|
"from_date": sys_defaults.year_start_date,
|
||||||
"to_date": sys_defaults.year_end_date,
|
"to_date": sys_defaults.year_end_date,
|
||||||
"company": doc.company
|
"company": doc.company
|
||||||
};
|
};
|
||||||
wn.set_route("query-report", "General Ledger");
|
frappe.set_route("query-report", "General Ledger");
|
||||||
}, "icon-table");
|
}, "icon-table");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
from webnotes.utils import flt, fmt_money, cstr, cint
|
from frappe.utils import flt, fmt_money, cstr, cint
|
||||||
from webnotes import msgprint, throw, _
|
from frappe import msgprint, throw, _
|
||||||
|
|
||||||
get_value = webnotes.conn.get_value
|
get_value = frappe.conn.get_value
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self,d,dl):
|
def __init__(self,d,dl):
|
||||||
@ -16,11 +16,11 @@ class DocType:
|
|||||||
|
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
self.doc.name = self.doc.account_name.strip() + ' - ' + \
|
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):
|
def get_address(self):
|
||||||
return {
|
return {
|
||||||
'address': webnotes.conn.get_value(self.doc.master_type,
|
'address': frappe.conn.get_value(self.doc.master_type,
|
||||||
self.doc.master_name, "address")
|
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 self.doc.master_type in ('Customer', 'Supplier') or self.doc.account_type == "Warehouse":
|
||||||
if not self.doc.master_name:
|
if not self.doc.master_name:
|
||||||
msgprint(_("Please enter Master Name once the account is created."))
|
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):
|
self.doc.master_name):
|
||||||
throw(_("Invalid Master Name"))
|
throw(_("Invalid Master Name"))
|
||||||
|
|
||||||
def validate_parent(self):
|
def validate_parent(self):
|
||||||
"""Fetch Parent Details and validation for account not to be created under ledger"""
|
"""Fetch Parent Details and validation for account not to be created under ledger"""
|
||||||
if self.doc.parent_account:
|
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)
|
from tabAccount where name =%s""", self.doc.parent_account)
|
||||||
if not par:
|
if not par:
|
||||||
throw(_("Parent account does not exists"))
|
throw(_("Parent account does not exists"))
|
||||||
@ -72,15 +72,15 @@ class DocType:
|
|||||||
|
|
||||||
def validate_max_root_accounts(self):
|
def validate_max_root_accounts(self):
|
||||||
"""Raise exception if there are more than 4 root accounts"""
|
"""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""",
|
company=%s and ifnull(parent_account,'')='' and docstatus != 2""",
|
||||||
self.doc.company)[0][0] > 4:
|
self.doc.company)[0][0] > 4:
|
||||||
throw(_("One company cannot have more than 4 root Accounts"))
|
throw(_("One company cannot have more than 4 root Accounts"))
|
||||||
|
|
||||||
def validate_duplicate_account(self):
|
def validate_duplicate_account(self):
|
||||||
if self.doc.fields.get('__islocal') or not self.doc.name:
|
if self.doc.fields.get('__islocal') or not self.doc.name:
|
||||||
company_abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
|
company_abbr = frappe.conn.get_value("Company", self.doc.company, "abbr")
|
||||||
if webnotes.conn.sql("""select name from tabAccount where name=%s""",
|
if frappe.conn.sql("""select name from tabAccount where name=%s""",
|
||||||
(self.doc.account_name + " - " + company_abbr)):
|
(self.doc.account_name + " - " + company_abbr)):
|
||||||
throw("{name}: {acc_name} {exist}, {rename}".format(**{
|
throw("{name}: {acc_name} {exist}, {rename}".format(**{
|
||||||
"name": _("Account Name"),
|
"name": _("Account Name"),
|
||||||
@ -91,17 +91,17 @@ class DocType:
|
|||||||
|
|
||||||
def validate_root_details(self):
|
def validate_root_details(self):
|
||||||
#does not exists parent
|
#does not exists parent
|
||||||
if webnotes.conn.exists("Account", self.doc.name):
|
if frappe.conn.exists("Account", self.doc.name):
|
||||||
if not webnotes.conn.get_value("Account", self.doc.name, "parent_account"):
|
if not frappe.conn.get_value("Account", self.doc.name, "parent_account"):
|
||||||
throw(_("Root cannot be edited."))
|
throw(_("Root cannot be edited."))
|
||||||
|
|
||||||
def validate_frozen_accounts_modifier(self):
|
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:
|
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')
|
'frozen_accounts_modifier')
|
||||||
if not frozen_accounts_modifier or \
|
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"))
|
throw(_("You are not authorized to set Frozen value"))
|
||||||
|
|
||||||
def convert_group_to_ledger(self):
|
def convert_group_to_ledger(self):
|
||||||
@ -131,10 +131,10 @@ class DocType:
|
|||||||
|
|
||||||
# Check if any previous balance exists
|
# Check if any previous balance exists
|
||||||
def check_gle_exists(self):
|
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):
|
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)
|
and docstatus != 2""", self.doc.name)
|
||||||
|
|
||||||
def validate_mandatory(self):
|
def validate_mandatory(self):
|
||||||
@ -144,11 +144,11 @@ class DocType:
|
|||||||
throw(_("Is PL Account field is mandatory"))
|
throw(_("Is PL Account field is mandatory"))
|
||||||
|
|
||||||
def validate_warehouse_account(self):
|
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
|
return
|
||||||
|
|
||||||
if self.doc.account_type == "Warehouse":
|
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 != cstr(self.doc.master_name):
|
||||||
if old_warehouse:
|
if old_warehouse:
|
||||||
self.validate_warehouse(old_warehouse)
|
self.validate_warehouse(old_warehouse)
|
||||||
@ -158,15 +158,15 @@ class DocType:
|
|||||||
throw(_("Master Name is mandatory if account type is Warehouse"))
|
throw(_("Master Name is mandatory if account type is Warehouse"))
|
||||||
|
|
||||||
def validate_warehouse(self, 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 +
|
throw(_("Stock transactions exist against warehouse ") + warehouse +
|
||||||
_(" .You can not assign / modify / remove Master Name"))
|
_(" .You can not assign / modify / remove Master Name"))
|
||||||
|
|
||||||
def update_nsm_model(self):
|
def update_nsm_model(self):
|
||||||
"""update lft, rgt indices for nested set model"""
|
"""update lft, rgt indices for nested set model"""
|
||||||
import webnotes
|
import frappe
|
||||||
import webnotes.utils.nestedset
|
import frappe.utils.nestedset
|
||||||
webnotes.utils.nestedset.update_nsm(self)
|
frappe.utils.nestedset.update_nsm(self)
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
self.validate_max_root_accounts()
|
self.validate_max_root_accounts()
|
||||||
@ -174,19 +174,19 @@ class DocType:
|
|||||||
|
|
||||||
def get_authorized_user(self):
|
def get_authorized_user(self):
|
||||||
# Check logged-in user is authorized
|
# Check logged-in user is authorized
|
||||||
if webnotes.conn.get_value('Accounts Settings', None, 'credit_controller') \
|
if frappe.conn.get_value('Accounts Settings', None, 'credit_controller') \
|
||||||
in webnotes.user.get_roles():
|
in frappe.user.get_roles():
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def check_credit_limit(self, total_outstanding):
|
def check_credit_limit(self, total_outstanding):
|
||||||
# Get credit limit
|
# Get credit limit
|
||||||
credit_limit_from = 'Customer'
|
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)
|
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
|
credit_limit = cr_limit and flt(cr_limit[0][0]) or 0
|
||||||
if not credit_limit:
|
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'
|
credit_limit_from = 'Company'
|
||||||
|
|
||||||
# If outstanding greater than credit limit and not authorized person raise exception
|
# If outstanding greater than credit limit and not authorized person raise exception
|
||||||
@ -219,10 +219,10 @@ class DocType:
|
|||||||
|
|
||||||
# Validate properties before merging
|
# Validate properties before merging
|
||||||
if merge:
|
if merge:
|
||||||
if not webnotes.conn.exists("Account", new):
|
if not frappe.conn.exists("Account", new):
|
||||||
throw(_("Account ") + new +_(" does not exists"))
|
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"]))
|
["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]:
|
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):
|
def after_rename(self, old, new, merge=False):
|
||||||
if not merge:
|
if not merge:
|
||||||
webnotes.conn.set_value("Account", new, "account_name",
|
frappe.conn.set_value("Account", new, "account_name",
|
||||||
" - ".join(new.split(" - ")[:-1]))
|
" - ".join(new.split(" - ")[:-1]))
|
||||||
else:
|
else:
|
||||||
from webnotes.utils.nestedset import rebuild_tree
|
from frappe.utils.nestedset import rebuild_tree
|
||||||
rebuild_tree("Account", "parent_account")
|
rebuild_tree("Account", "parent_account")
|
||||||
|
|
||||||
def get_master_name(doctype, txt, searchfield, start, page_len, filters):
|
def get_master_name(doctype, txt, searchfield, start, page_len, filters):
|
||||||
conditions = (" and company='%s'"% filters["company"]) if doctype == "Warehouse" else ""
|
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""" %
|
order by name limit %s, %s""" %
|
||||||
(filters["master_type"], searchfield, "%s", conditions, "%s", "%s"),
|
(filters["master_type"], searchfield, "%s", conditions, "%s", "%s"),
|
||||||
("%%%s%%" % txt, start, page_len), as_list=1)
|
("%%%s%%" % txt, start, page_len), as_list=1)
|
||||||
|
|
||||||
def get_parent_account(doctype, txt, searchfield, start, page_len, filters):
|
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
|
where group_or_ledger = 'Group' and docstatus != 2 and company = %s
|
||||||
and %s like %s order by name limit %s, %s""" %
|
and %s like %s order by name limit %s, %s""" %
|
||||||
("%s", searchfield, "%s", "%s", "%s"),
|
("%s", searchfield, "%s", "%s", "%s"),
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
def _make_test_records(verbose):
|
def _make_test_records(verbose):
|
||||||
from webnotes.test_runner import make_test_objects
|
from frappe.test_runner import make_test_objects
|
||||||
|
|
||||||
accounts = [
|
accounts = [
|
||||||
# [account_name, parent_account, group_or_ledger]
|
# [account_name, parent_account, group_or_ledger]
|
||||||
|
@ -4,28 +4,28 @@
|
|||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes import _
|
from frappe import _
|
||||||
from webnotes.utils import cint
|
from frappe.utils import cint
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
self.doc, self.doclist = d, dl
|
self.doc, self.doclist = d, dl
|
||||||
|
|
||||||
def on_update(self):
|
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):
|
if cint(self.doc.auto_accounting_for_stock):
|
||||||
# set default perpetual account in company
|
# set default perpetual account in company
|
||||||
for company in webnotes.conn.sql("select name from tabCompany"):
|
for company in frappe.conn.sql("select name from tabCompany"):
|
||||||
webnotes.bean("Company", company[0]).save()
|
frappe.bean("Company", company[0]).save()
|
||||||
|
|
||||||
# Create account head for warehouses
|
# 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]
|
warehouse_with_no_company = [d.name for d in warehouse_list if not d.company]
|
||||||
if warehouse_with_no_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))
|
"\n".join(warehouse_with_no_company))
|
||||||
for wh in warehouse_list:
|
for wh in warehouse_list:
|
||||||
wh_bean = webnotes.bean("Warehouse", wh.name)
|
wh_bean = frappe.bean("Warehouse", wh.name)
|
||||||
wh_bean.save()
|
wh_bean.save()
|
@ -4,5 +4,5 @@
|
|||||||
cur_frm.add_fetch("bank_account", "company", "company");
|
cur_frm.add_fetch("bank_account", "company", "company");
|
||||||
cur_frm.cscript.onload = function(doc, cdt, cdn){
|
cur_frm.cscript.onload = function(doc, cdt, cdn){
|
||||||
cur_frm.set_intro('<i class="icon-question" /> ' +
|
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'"))
|
||||||
}
|
}
|
@ -2,13 +2,13 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
from webnotes.utils import cstr, flt, getdate, now, nowdate
|
from frappe.utils import cstr, flt, getdate, now, nowdate
|
||||||
from webnotes.model import db_exists
|
from frappe.model import db_exists
|
||||||
from webnotes.model.doc import addchild
|
from frappe.model.doc import addchild
|
||||||
from webnotes.model.bean import getlist, copy_doclist
|
from frappe.model.bean import getlist, copy_doclist
|
||||||
from webnotes import msgprint
|
from frappe import msgprint
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ class DocType:
|
|||||||
msgprint("Bank Account, From Date and To Date are Mandatory")
|
msgprint("Bank Account, From Date and To Date are Mandatory")
|
||||||
return
|
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.doclist = self.doc.clear_table(self.doclist, 'entries')
|
||||||
self.doc.total_amount = 0.0
|
self.doc.total_amount = 0.0
|
||||||
@ -46,7 +46,7 @@ class DocType:
|
|||||||
msgprint("Clearance Date can not be before Cheque Date (Row #%s)" %
|
msgprint("Clearance Date can not be before Cheque Date (Row #%s)" %
|
||||||
d.idx, raise_exception=1)
|
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""",
|
set clearance_date = %s, modified = %s where name=%s""",
|
||||||
(d.clearance_date, nowdate(), d.voucher_id))
|
(d.clearance_date, nowdate(), d.voucher_id))
|
||||||
vouchers.append(d.voucher_id)
|
vouchers.append(d.voucher_id)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
|
@ -8,7 +8,7 @@ cur_frm.cscript.onload = function(doc,cdt,cdn){
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $c('runserverobj',args={'method' : 'get_months', 'docs' :
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
from webnotes.utils import flt
|
from frappe.utils import flt
|
||||||
from webnotes.model.doc import addchild
|
from frappe.model.doc import addchild
|
||||||
from webnotes.model.bean import getlist
|
from frappe.model.bean import getlist
|
||||||
from webnotes import msgprint, _
|
from frappe import msgprint, _
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self,doc,doclist=[]):
|
def __init__(self,doc,doclist=[]):
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes.utils import flt, getdate
|
from frappe.utils import flt, getdate
|
||||||
from webnotes.model.bean import getlist
|
from frappe.model.bean import getlist
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self,d,dl):
|
def __init__(self,d,dl):
|
||||||
@ -16,19 +16,19 @@ class DocType:
|
|||||||
|
|
||||||
for d in getlist(self.doclist, 'invoice_details'):
|
for d in getlist(self.doclist, 'invoice_details'):
|
||||||
if d.invoice_no:
|
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)
|
`tabSales Invoice` where name = %s and docstatus = 1""", d.invoice_no)
|
||||||
|
|
||||||
if not inv:
|
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)
|
is not submitted, please check.""" % d.invoice_no, raise_exception=1)
|
||||||
|
|
||||||
elif inv[0][0] != 'Yes':
|
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)
|
d.invoice_no, raise_exception=1)
|
||||||
|
|
||||||
elif inv[0][1] and inv[0][1] != self.doc.name:
|
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,
|
If you want to change C-form no for this invoice,
|
||||||
please remove invoice no from the previous c-form and then try again""" %
|
please remove invoice no from the previous c-form and then try again""" %
|
||||||
(d.invoice_no, inv[0][1]), raise_exception=1)
|
(d.invoice_no, inv[0][1]), raise_exception=1)
|
||||||
@ -42,31 +42,31 @@ class DocType:
|
|||||||
|
|
||||||
def before_cancel(self):
|
def before_cancel(self):
|
||||||
# remove cform reference
|
# 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)
|
where c_form_no=%s""", self.doc.name)
|
||||||
|
|
||||||
def set_cform_in_sales_invoices(self):
|
def set_cform_in_sales_invoices(self):
|
||||||
inv = [d.invoice_no for d in getlist(self.doclist, 'invoice_details')]
|
inv = [d.invoice_no for d in getlist(self.doclist, 'invoice_details')]
|
||||||
if inv:
|
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))),
|
where name in (%s)""" % ('%s', '%s', ', '.join(['%s'] * len(inv))),
|
||||||
tuple([self.doc.name, self.doc.modified] + 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""" %
|
where name not in (%s) and ifnull(c_form_no, '') = %s""" %
|
||||||
('%s', ', '.join(['%s']*len(inv)), '%s'),
|
('%s', ', '.join(['%s']*len(inv)), '%s'),
|
||||||
tuple([self.doc.modified] + inv + [self.doc.name]))
|
tuple([self.doc.modified] + inv + [self.doc.name]))
|
||||||
else:
|
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):
|
def set_total_invoiced_amount(self):
|
||||||
total = sum([flt(d.grand_total) for d in getlist(self.doclist, 'invoice_details')])
|
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):
|
def get_invoice_details(self, invoice_no):
|
||||||
""" Pull details from invoices for referrence """
|
""" 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)
|
from `tabSales Invoice` where name = %s""", invoice_no)
|
||||||
return {
|
return {
|
||||||
'invoice_date' : inv and getdate(inv[0][0]).strftime('%Y-%m-%d') or '',
|
'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
|
from erpnext.utilities import build_filter_conditions
|
||||||
conditions, filter_values = build_filter_conditions(filters)
|
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 c_form_applicable = 'Yes' and ifnull(c_form_no, '') = '' %s
|
||||||
and %s like %s order by name limit %s, %s""" %
|
and %s like %s order by name limit %s, %s""" %
|
||||||
(conditions, searchfield, "%s", "%s", "%s"),
|
(conditions, searchfield, "%s", "%s", "%s"),
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
wn.provide("erpnext.accounts");
|
frappe.provide("erpnext.accounts");
|
||||||
erpnext.accounts.CostCenterController = wn.ui.form.Controller.extend({
|
erpnext.accounts.CostCenterController = frappe.ui.form.Controller.extend({
|
||||||
onload: function() {
|
onload: function() {
|
||||||
this.setup_queries();
|
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);
|
cur_frm.toggle_enable(['group_or_ledger', 'company'], doc.__islocal);
|
||||||
|
|
||||||
if(!doc.__islocal && doc.group_or_ledger=='Group') {
|
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>, '+
|
intro_txt += '<p><b>'+frappe._('Note:')+'</b>'+ frappe._('This Cost Center is a')+ '<i>'+frappe._('Group')+'</i>, '+
|
||||||
wn._('Accounting Entries are not allowed against groups.')+'</p>';
|
frappe._('Accounting Entries are not allowed against groups.')+'</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.hide_unhide_group_ledger(doc);
|
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.toggle_display('sb1', doc.group_or_ledger=='Ledger')
|
||||||
cur_frm.set_intro(intro_txt);
|
cur_frm.set_intro(intro_txt);
|
||||||
|
|
||||||
cur_frm.appframe.add_button(wn._('Chart of Cost Centers'),
|
cur_frm.appframe.add_button(frappe._('Chart of Cost Centers'),
|
||||||
function() { wn.set_route("Accounts Browser", "Cost Center"); }, 'icon-sitemap')
|
function() { frappe.set_route("Accounts Browser", "Cost Center"); }, 'icon-sitemap')
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.parent_cost_center = function(doc, cdt, cdn) {
|
cur_frm.cscript.parent_cost_center = function(doc, cdt, cdn) {
|
||||||
if(!doc.company){
|
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) {
|
cur_frm.cscript.hide_unhide_group_ledger = function(doc) {
|
||||||
if (cstr(doc.group_or_ledger) == 'Group') {
|
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')
|
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet')
|
||||||
} else if (cstr(doc.group_or_ledger) == 'Ledger') {
|
} 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')
|
function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes.model.bean import getlist
|
from frappe.model.bean import getlist
|
||||||
from webnotes import msgprint, _
|
from frappe import msgprint, _
|
||||||
|
|
||||||
from webnotes.utils.nestedset import DocTypeNestedSet
|
from frappe.utils.nestedset import DocTypeNestedSet
|
||||||
|
|
||||||
class DocType(DocTypeNestedSet):
|
class DocType(DocTypeNestedSet):
|
||||||
def __init__(self,d,dl):
|
def __init__(self,d,dl):
|
||||||
@ -14,7 +14,7 @@ class DocType(DocTypeNestedSet):
|
|||||||
self.nsm_parent_field = 'parent_cost_center'
|
self.nsm_parent_field = 'parent_cost_center'
|
||||||
|
|
||||||
def autoname(self):
|
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.company)[0][0]
|
||||||
self.doc.name = self.doc.cost_center_name.strip() + ' - ' + company_abbr
|
self.doc.name = self.doc.cost_center_name.strip() + ' - ' + company_abbr
|
||||||
|
|
||||||
@ -46,10 +46,10 @@ class DocType(DocTypeNestedSet):
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
def check_gle_exists(self):
|
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):
|
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)
|
parent_cost_center = %s and docstatus != 2", self.doc.name)
|
||||||
|
|
||||||
def validate_budget_details(self):
|
def validate_budget_details(self):
|
||||||
@ -67,7 +67,7 @@ class DocType(DocTypeNestedSet):
|
|||||||
"""
|
"""
|
||||||
Cost Center name must be unique
|
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)
|
msgprint("Cost Center Name already exists, please rename", raise_exception=1)
|
||||||
|
|
||||||
self.validate_mandatory()
|
self.validate_mandatory()
|
||||||
@ -85,7 +85,7 @@ class DocType(DocTypeNestedSet):
|
|||||||
|
|
||||||
def after_rename(self, olddn, newdn, merge=False):
|
def after_rename(self, olddn, newdn, merge=False):
|
||||||
if not merge:
|
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]))
|
" - ".join(newdn.split(" - ")[:-1]))
|
||||||
else:
|
else:
|
||||||
super(DocType, self).after_rename(olddn, newdn, merge)
|
super(DocType, self).after_rename(olddn, newdn, merge)
|
||||||
|
@ -8,12 +8,12 @@ $.extend(cur_frm.cscript, {
|
|||||||
this.frm.toggle_enable('year_end_date', doc.__islocal)
|
this.frm.toggle_enable('year_end_date', doc.__islocal)
|
||||||
|
|
||||||
if (!doc.__islocal && (doc.name != sys_defaults.fiscal_year)) {
|
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.add_custom_button(frappe._("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.set_intro(frappe._("To set this Fiscal Year as Default, click on 'Set as Default'"));
|
||||||
} else this.frm.set_intro("");
|
} else this.frm.set_intro("");
|
||||||
},
|
},
|
||||||
set_as_default: function() {
|
set_as_default: function() {
|
||||||
return wn.call({
|
return frappe.call({
|
||||||
doc: cur_frm.doc,
|
doc: cur_frm.doc,
|
||||||
method: "set_as_default"
|
method: "set_as_default"
|
||||||
});
|
});
|
||||||
@ -22,7 +22,7 @@ $.extend(cur_frm.cscript, {
|
|||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
year_end_date =
|
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);
|
this.frm.set_value("year_end_date", year_end_date);
|
||||||
},
|
},
|
||||||
});
|
});
|
@ -2,44 +2,44 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes import msgprint, _
|
from frappe import msgprint, _
|
||||||
from webnotes.utils import getdate
|
from frappe.utils import getdate
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
self.doc, self.doclist = d, dl
|
self.doc, self.doclist = d, dl
|
||||||
|
|
||||||
def set_as_default(self):
|
def set_as_default(self):
|
||||||
webnotes.conn.set_value("Global Defaults", None, "current_fiscal_year", self.doc.name)
|
frappe.conn.set_value("Global Defaults", None, "current_fiscal_year", self.doc.name)
|
||||||
webnotes.get_obj("Global Defaults").on_update()
|
frappe.get_obj("Global Defaults").on_update()
|
||||||
|
|
||||||
# clear cache
|
# clear cache
|
||||||
webnotes.clear_cache()
|
frappe.clear_cache()
|
||||||
|
|
||||||
msgprint(self.doc.name + _(""" is now the default Fiscal Year. \
|
msgprint(self.doc.name + _(""" is now the default Fiscal Year. \
|
||||||
Please refresh your browser for the change to take effect."""))
|
Please refresh your browser for the change to take effect."""))
|
||||||
|
|
||||||
def validate(self):
|
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))
|
from `tabFiscal Year` where name=%s""", (self.doc.name))
|
||||||
|
|
||||||
if year_start_end_dates:
|
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]:
|
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):
|
def on_update(self):
|
||||||
# validate year start date and year end date
|
# validate year start date and year end date
|
||||||
if getdate(self.doc.year_start_date) > getdate(self.doc.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:
|
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))
|
from `tabFiscal Year` where name!=%s""", (self.doc.name))
|
||||||
|
|
||||||
for fiscal_year, ysd, yed in year_start_end_dates:
|
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) \
|
if (getdate(self.doc.year_start_date) == ysd and getdate(self.doc.year_end_date) == yed) \
|
||||||
and (not webnotes.flags.in_test):
|
and (not frappe.flags.in_test):
|
||||||
webnotes.throw(_("Year Start Date and Year End Date are already set in Fiscal Year: ") + fiscal_year)
|
frappe.throw(_("Year Start Date and Year End Date are already set in Fiscal Year: ") + fiscal_year)
|
@ -2,10 +2,10 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
from webnotes.utils import flt, fmt_money, getdate
|
from frappe.utils import flt, fmt_money, getdate
|
||||||
from webnotes import _
|
from frappe import _
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self,d,dl):
|
def __init__(self,d,dl):
|
||||||
@ -34,17 +34,17 @@ class DocType:
|
|||||||
mandatory = ['account','remarks','voucher_type','voucher_no','fiscal_year','company']
|
mandatory = ['account','remarks','voucher_type','voucher_no','fiscal_year','company']
|
||||||
for k in mandatory:
|
for k in mandatory:
|
||||||
if not self.doc.fields.get(k):
|
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
|
# Zero value transaction is not allowed
|
||||||
if not (flt(self.doc.debit) or flt(self.doc.credit)):
|
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)
|
self.doc.account)
|
||||||
|
|
||||||
def pl_must_have_cost_center(self):
|
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':
|
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)
|
self.doc.account)
|
||||||
elif self.doc.cost_center:
|
elif self.doc.cost_center:
|
||||||
self.doc.cost_center = None
|
self.doc.cost_center = None
|
||||||
@ -55,23 +55,23 @@ class DocType:
|
|||||||
|
|
||||||
def check_pl_account(self):
|
def check_pl_account(self):
|
||||||
if self.doc.is_opening=='Yes' and \
|
if self.doc.is_opening=='Yes' and \
|
||||||
webnotes.conn.get_value("Account", self.doc.account, "is_pl_account") == "Yes":
|
frappe.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.throw(_("For opening balance entry account can not be a PL account"))
|
||||||
|
|
||||||
def validate_account_details(self, adv_adj):
|
def validate_account_details(self, adv_adj):
|
||||||
"""Account must be ledger, active and not freezed"""
|
"""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]
|
from tabAccount where name=%s""", self.doc.account, as_dict=1)[0]
|
||||||
|
|
||||||
if ret.group_or_ledger=='Group':
|
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:
|
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:
|
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)
|
_(" does not belong to the company") + ": " + self.doc.company)
|
||||||
|
|
||||||
def validate_cost_center(self):
|
def validate_cost_center(self):
|
||||||
@ -80,27 +80,27 @@ class DocType:
|
|||||||
|
|
||||||
def _get_cost_center_company():
|
def _get_cost_center_company():
|
||||||
if not self.cost_center_company.get(self.doc.cost_center):
|
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")
|
"Cost Center", self.doc.cost_center, "company")
|
||||||
|
|
||||||
return self.cost_center_company[self.doc.cost_center]
|
return self.cost_center_company[self.doc.cost_center]
|
||||||
|
|
||||||
if self.doc.cost_center and _get_cost_center_company() != self.doc.company:
|
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)
|
_(" does not belong to the company") + ": " + self.doc.company)
|
||||||
|
|
||||||
def check_negative_balance(account, adv_adj=False):
|
def check_negative_balance(account, adv_adj=False):
|
||||||
if not adv_adj and account:
|
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)
|
["allow_negative_balance", "debit_or_credit"], as_dict=True)
|
||||||
if not account_details["allow_negative_balance"]:
|
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)
|
where account = %s""", account)
|
||||||
balance = account_details["debit_or_credit"] == "Debit" and \
|
balance = account_details["debit_or_credit"] == "Debit" and \
|
||||||
flt(balance[0][0]) or -1*flt(balance[0][0])
|
flt(balance[0][0]) or -1*flt(balance[0][0])
|
||||||
|
|
||||||
if flt(balance) < 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):
|
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
|
except authorized person
|
||||||
"""
|
"""
|
||||||
if not adv_adj:
|
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:
|
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) \
|
if getdate(posting_date) <= getdate(acc_frozen_upto) \
|
||||||
and not bde_auth_role in webnotes.user.get_roles():
|
and not bde_auth_role in frappe.user.get_roles():
|
||||||
webnotes.throw(_("You are not authorized to do/modify back dated entries before ")
|
frappe.throw(_("You are not authorized to do/modify back dated entries before ")
|
||||||
+ getdate(acc_frozen_upto).strftime('%d-%m-%Y'))
|
+ getdate(acc_frozen_upto).strftime('%d-%m-%Y'))
|
||||||
|
|
||||||
def update_outstanding_amt(account, against_voucher_type, against_voucher, on_cancel=False):
|
def update_outstanding_amt(account, against_voucher_type, against_voucher, on_cancel=False):
|
||||||
# get final outstanding amt
|
# 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`
|
from `tabGL Entry`
|
||||||
where against_voucher_type=%s and against_voucher=%s and account = %s""",
|
where against_voucher_type=%s and against_voucher=%s and account = %s""",
|
||||||
(against_voucher_type, against_voucher, account))[0][0] or 0.0)
|
(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':
|
if against_voucher_type == 'Purchase Invoice':
|
||||||
bal = -bal
|
bal = -bal
|
||||||
elif against_voucher_type == "Journal Voucher":
|
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))
|
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||||
from `tabGL Entry` where voucher_type = 'Journal Voucher' and voucher_no = %s
|
from `tabGL Entry` where voucher_type = 'Journal Voucher' and voucher_no = %s
|
||||||
and account = %s and ifnull(against_voucher, '') = ''""",
|
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
|
# Validation : Outstanding can not be negative
|
||||||
if bal < 0 and not on_cancel:
|
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. \
|
fmt_money(bal) + _(". Outstanding cannot be less than zero. \
|
||||||
Please match exact outstanding."))
|
Please match exact outstanding."))
|
||||||
|
|
||||||
# Update outstanding amt on against voucher
|
# Update outstanding amt on against voucher
|
||||||
if against_voucher_type in ["Sales Invoice", "Purchase Invoice"]:
|
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))
|
(against_voucher_type, bal, against_voucher))
|
||||||
|
|
||||||
def validate_frozen_account(account, adv_adj=None):
|
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:
|
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')
|
'frozen_accounts_modifier')
|
||||||
|
|
||||||
if not 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"))
|
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 webnotes.user.get_roles():
|
elif frozen_accounts_modifier not in frappe.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. To create / edit transactions against this account, you need role") \
|
||||||
+ ": " + frozen_accounts_modifier)
|
+ ": " + frozen_accounts_modifier)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// 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() {
|
onload: function() {
|
||||||
this.load_defaults();
|
this.load_defaults();
|
||||||
this.setup_queries();
|
this.setup_queries();
|
||||||
@ -11,10 +11,10 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({
|
|||||||
|
|
||||||
load_defaults: function() {
|
load_defaults: function() {
|
||||||
if(this.frm.doc.__islocal && this.frm.doc.company) {
|
if(this.frm.doc.__islocal && this.frm.doc.company) {
|
||||||
wn.model.set_default_values(this.frm.doc);
|
frappe.model.set_default_values(this.frm.doc);
|
||||||
$.each(wn.model.get_doclist(this.frm.doc.doctype,
|
$.each(frappe.model.get_doclist(this.frm.doc.doctype,
|
||||||
this.frm.doc.name, {parentfield: "entries"}), function(i, jvd) {
|
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) {
|
$.each(["account", "cost_center"], function(i, fieldname) {
|
||||||
me.frm.set_query(fieldname, "entries", function() {
|
me.frm.set_query(fieldname, "entries", function() {
|
||||||
wn.model.validate_missing(me.frm.doc, "company");
|
frappe.model.validate_missing(me.frm.doc, "company");
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
company: me.frm.doc.company,
|
company: me.frm.doc.company,
|
||||||
@ -40,8 +40,8 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({
|
|||||||
$.each([["against_voucher", "Purchase Invoice", "credit_to"],
|
$.each([["against_voucher", "Purchase Invoice", "credit_to"],
|
||||||
["against_invoice", "Sales Invoice", "debit_to"]], function(i, opts) {
|
["against_invoice", "Sales Invoice", "debit_to"]], function(i, opts) {
|
||||||
me.frm.set_query(opts[0], "entries", function(doc, cdt, cdn) {
|
me.frm.set_query(opts[0], "entries", function(doc, cdt, cdn) {
|
||||||
var jvd = wn.model.get_doc(cdt, cdn);
|
var jvd = frappe.model.get_doc(cdt, cdn);
|
||||||
wn.model.validate_missing(jvd, "account");
|
frappe.model.validate_missing(jvd, "account");
|
||||||
return {
|
return {
|
||||||
filters: [
|
filters: [
|
||||||
[opts[1], opts[2], "=", jvd.account],
|
[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) {
|
this.frm.set_query("against_jv", "entries", function(doc, cdt, cdn) {
|
||||||
var jvd = wn.model.get_doc(cdt, cdn);
|
var jvd = frappe.model.get_doc(cdt, cdn);
|
||||||
wn.model.validate_missing(jvd, "account");
|
frappe.model.validate_missing(jvd, "account");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
query: "accounts.doctype.journal_voucher.journal_voucher.get_against_jv",
|
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) {
|
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)) {
|
if (d.against_voucher && !flt(d.debit)) {
|
||||||
this.get_outstanding({
|
this.get_outstanding({
|
||||||
'doctype': 'Purchase Invoice',
|
'doctype': 'Purchase Invoice',
|
||||||
@ -74,7 +74,7 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
against_invoice: function(doc, cdt, cdn) {
|
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)) {
|
if (d.against_invoice && !flt(d.credit)) {
|
||||||
this.get_outstanding({
|
this.get_outstanding({
|
||||||
'doctype': 'Sales Invoice',
|
'doctype': 'Sales Invoice',
|
||||||
@ -84,7 +84,7 @@ erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
against_jv: function(doc, cdt, cdn) {
|
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)) {
|
if (d.against_jv && !flt(d.credit) && !flt(d.debit)) {
|
||||||
this.get_outstanding({
|
this.get_outstanding({
|
||||||
'doctype': 'Journal Voucher',
|
'doctype': 'Journal Voucher',
|
||||||
@ -115,15 +115,15 @@ cur_frm.cscript.refresh = function(doc) {
|
|||||||
erpnext.hide_naming_series();
|
erpnext.hide_naming_series();
|
||||||
cur_frm.cscript.voucher_type(doc);
|
cur_frm.cscript.voucher_type(doc);
|
||||||
if(doc.docstatus==1) {
|
if(doc.docstatus==1) {
|
||||||
cur_frm.appframe.add_button(wn._('View Ledger'), function() {
|
cur_frm.appframe.add_button(frappe._('View Ledger'), function() {
|
||||||
wn.route_options = {
|
frappe.route_options = {
|
||||||
"voucher_no": doc.name,
|
"voucher_no": doc.name,
|
||||||
"from_date": doc.posting_date,
|
"from_date": doc.posting_date,
|
||||||
"to_date": doc.posting_date,
|
"to_date": doc.posting_date,
|
||||||
"company": doc.company,
|
"company": doc.company,
|
||||||
group_by_voucher: 0
|
group_by_voucher: 0
|
||||||
};
|
};
|
||||||
wn.set_route("query-report", "General Ledger");
|
frappe.set_route("query-report", "General Ledger");
|
||||||
}, "icon-table");
|
}, "icon-table");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,7 +166,7 @@ cur_frm.cscript.get_balance = function(doc,dt,dn) {
|
|||||||
cur_frm.cscript.account = function(doc,dt,dn) {
|
cur_frm.cscript.account = function(doc,dt,dn) {
|
||||||
var d = locals[dt][dn];
|
var d = locals[dt][dn];
|
||||||
if(d.account) {
|
if(d.account) {
|
||||||
return wn.call({
|
return frappe.call({
|
||||||
method: "erpnext.accounts.utils.get_balance_on",
|
method: "erpnext.accounts.utils.get_balance_on",
|
||||||
args: {account: d.account, date: doc.posting_date},
|
args: {account: d.account, date: doc.posting_date},
|
||||||
callback: function(r) {
|
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;
|
cur_frm.pformat.print_heading = doc.select_print_heading;
|
||||||
}
|
}
|
||||||
else
|
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.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_no", "reqd", doc.voucher_type=="Bank Voucher");
|
||||||
cur_frm.set_df_property("cheque_date", "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
|
|| !doc.company) // too early
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var update_jv_details = function(doc, r) {
|
var update_jv_details = function(doc, r) {
|
||||||
$.each(r.message, function(i, d) {
|
$.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.account = d.account;
|
||||||
jvdetail.balance = d.balance;
|
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)) {
|
if(in_list(["Bank Voucher", "Cash Voucher"], doc.voucher_type)) {
|
||||||
return wn.call({
|
return frappe.call({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
method: "erpnext.accounts.doctype.journal_voucher.journal_voucher.get_default_bank_cash_account",
|
method: "erpnext.accounts.doctype.journal_voucher.journal_voucher.get_default_bank_cash_account",
|
||||||
args: {
|
args: {
|
||||||
@ -222,14 +222,14 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else if(doc.voucher_type=="Opening Entry") {
|
} else if(doc.voucher_type=="Opening Entry") {
|
||||||
return wn.call({
|
return frappe.call({
|
||||||
type:"GET",
|
type:"GET",
|
||||||
method: "erpnext.accounts.doctype.journal_voucher.journal_voucher.get_opening_accounts",
|
method: "erpnext.accounts.doctype.journal_voucher.journal_voucher.get_opening_accounts",
|
||||||
args: {
|
args: {
|
||||||
"company": doc.company
|
"company": doc.company
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
wn.model.clear_table("Journal Voucher Detail", "Journal Voucher",
|
frappe.model.clear_table("Journal Voucher Detail", "Journal Voucher",
|
||||||
doc.name, "entries");
|
doc.name, "entries");
|
||||||
if(r.message) {
|
if(r.message) {
|
||||||
update_jv_details(doc, r);
|
update_jv_details(doc, r);
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
from webnotes.utils import cint, cstr, flt, fmt_money, formatdate, getdate
|
from frappe.utils import cint, cstr, flt, fmt_money, formatdate, getdate
|
||||||
from webnotes.model.doc import addchild
|
from frappe.model.doc import addchild
|
||||||
from webnotes.model.bean import getlist
|
from frappe.model.bean import getlist
|
||||||
from webnotes import msgprint, _
|
from frappe import msgprint, _
|
||||||
from erpnext.setup.utils import get_company_currency
|
from erpnext.setup.utils import get_company_currency
|
||||||
|
|
||||||
from erpnext.controllers.accounts_controller import AccountsController
|
from erpnext.controllers.accounts_controller import AccountsController
|
||||||
@ -54,7 +54,7 @@ class DocType(AccountsController):
|
|||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
pass
|
pass
|
||||||
#if self.doc.amended_from:
|
#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):
|
def validate_debit_credit(self):
|
||||||
for d in getlist(self.doclist, 'entries'):
|
for d in getlist(self.doclist, 'entries'):
|
||||||
@ -75,7 +75,7 @@ class DocType(AccountsController):
|
|||||||
for d in getlist(self.doclist,'entries'):
|
for d in getlist(self.doclist,'entries'):
|
||||||
if not d.is_advance and not d.against_voucher and \
|
if not d.is_advance and not d.against_voucher and \
|
||||||
not d.against_invoice and not d.against_jv:
|
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 \
|
if (master_type == 'Customer' and flt(d.credit) > 0) or \
|
||||||
(master_type == 'Supplier' and flt(d.debit) > 0):
|
(master_type == 'Supplier' and flt(d.debit) > 0):
|
||||||
msgprint("Message: Please check Is Advance as 'Yes' against \
|
msgprint("Message: Please check Is Advance as 'Yes' against \
|
||||||
@ -87,7 +87,7 @@ class DocType(AccountsController):
|
|||||||
if d.against_jv == self.doc.name:
|
if d.against_jv == self.doc.name:
|
||||||
msgprint("You can not enter current voucher in 'Against JV' column",
|
msgprint("You can not enter current voucher in 'Against JV' column",
|
||||||
raise_exception=1)
|
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'""" %
|
where account = '%s' and docstatus = 1 and parent = '%s'""" %
|
||||||
(d.account, d.against_jv)):
|
(d.account, d.against_jv)):
|
||||||
msgprint("Against JV: %s is not valid." % d.against_jv, raise_exception=1)
|
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'):
|
for d in getlist(self.doclist, 'entries'):
|
||||||
if d.against_invoice and d.credit:
|
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' %
|
r.append('%s %s against Invoice: %s' %
|
||||||
(cstr(currency), fmt_money(flt(d.credit)), d.against_invoice))
|
(cstr(currency), fmt_money(flt(d.credit)), d.against_invoice))
|
||||||
|
|
||||||
if d.against_voucher and d.debit:
|
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)
|
from `tabPurchase Invoice` where name=%s""", d.against_voucher)
|
||||||
if bill_no and bill_no[0][0] and bill_no[0][0].lower().strip() \
|
if bill_no and bill_no[0][0] and bill_no[0][0].lower().strip() \
|
||||||
not in ['na', 'not applicable', 'none']:
|
not in ['na', 'not applicable', 'none']:
|
||||||
@ -144,7 +144,7 @@ class DocType(AccountsController):
|
|||||||
if r:
|
if r:
|
||||||
self.doc.remark = ("\n").join(r)
|
self.doc.remark = ("\n").join(r)
|
||||||
else:
|
else:
|
||||||
webnotes.msgprint("User Remarks is mandatory", raise_exception=1)
|
frappe.msgprint("User Remarks is mandatory", raise_exception=1)
|
||||||
|
|
||||||
def set_aging_date(self):
|
def set_aging_date(self):
|
||||||
if self.doc.is_opening != 'Yes':
|
if self.doc.is_opening != 'Yes':
|
||||||
@ -153,7 +153,7 @@ class DocType(AccountsController):
|
|||||||
# check account type whether supplier or customer
|
# check account type whether supplier or customer
|
||||||
exists = False
|
exists = False
|
||||||
for d in getlist(self.doclist, 'entries'):
|
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"]:
|
if account_type in ["Supplier", "Customer"]:
|
||||||
exists = True
|
exists = True
|
||||||
break
|
break
|
||||||
@ -166,12 +166,12 @@ class DocType(AccountsController):
|
|||||||
|
|
||||||
def set_print_format_fields(self):
|
def set_print_format_fields(self):
|
||||||
for d in getlist(self.doclist, 'entries'):
|
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"])
|
["account_type", "master_type"])
|
||||||
|
|
||||||
if master_type in ['Supplier', 'Customer']:
|
if master_type in ['Supplier', 'Customer']:
|
||||||
if not self.doc.pay_to_recd_from:
|
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]),
|
' - '.join(d.account.split(' - ')[:-1]),
|
||||||
master_type == 'Customer' and 'customer_name' or 'supplier_name')
|
master_type == 'Customer' and 'customer_name' or 'supplier_name')
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ class DocType(AccountsController):
|
|||||||
company_currency = get_company_currency(self.doc.company)
|
company_currency = get_company_currency(self.doc.company)
|
||||||
amt = flt(d.debit) and d.debit or d.credit
|
amt = flt(d.debit) and d.debit or d.credit
|
||||||
self.doc.total_amount = company_currency + ' ' + cstr(amt)
|
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)
|
self.doc.total_amount_in_words = money_in_words(amt, company_currency)
|
||||||
|
|
||||||
def check_credit_days(self):
|
def check_credit_days(self):
|
||||||
@ -190,7 +190,7 @@ class DocType(AccountsController):
|
|||||||
if date_diff <= 0: return
|
if date_diff <= 0: return
|
||||||
|
|
||||||
# Get List of Customer Account
|
# 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'))
|
"master_type")=='Customer', getlist(self.doclist,'entries'))
|
||||||
|
|
||||||
for d in acc_list:
|
for d in acc_list:
|
||||||
@ -202,11 +202,11 @@ class DocType(AccountsController):
|
|||||||
|
|
||||||
def get_credit_days_for(self, ac):
|
def get_credit_days_for(self, ac):
|
||||||
if not self.credit_days_for.has_key(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 not self.credit_days_for[ac]:
|
||||||
if self.credit_days_global==-1:
|
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"))
|
self.doc.company, "credit_days"))
|
||||||
|
|
||||||
return self.credit_days_global
|
return self.credit_days_global
|
||||||
@ -218,25 +218,25 @@ class DocType(AccountsController):
|
|||||||
self.is_approving_authority = 0
|
self.is_approving_authority = 0
|
||||||
|
|
||||||
# Fetch credit controller role
|
# Fetch credit controller role
|
||||||
approving_authority = webnotes.conn.get_value("Global Defaults", None,
|
approving_authority = frappe.conn.get_value("Global Defaults", None,
|
||||||
"credit_controller")
|
"credit_controller")
|
||||||
|
|
||||||
# Check logged-in user is authorized
|
# 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
|
self.is_approving_authority = 1
|
||||||
|
|
||||||
return self.is_approving_authority
|
return self.is_approving_authority
|
||||||
|
|
||||||
def check_account_against_entries(self):
|
def check_account_against_entries(self):
|
||||||
for d in self.doclist.get({"parentfield": "entries"}):
|
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:
|
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"))
|
_("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:
|
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"))
|
_("Account is not matching with Credit To account of Purchase Invoice"))
|
||||||
|
|
||||||
def make_gl_entries(self, cancel=0, adv_adj=0):
|
def make_gl_entries(self, cancel=0, adv_adj=0):
|
||||||
@ -267,7 +267,7 @@ class DocType(AccountsController):
|
|||||||
|
|
||||||
def check_credit_limit(self):
|
def check_credit_limit(self):
|
||||||
for d in self.doclist.get({"parentfield": "entries"}):
|
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"])
|
["master_type", "master_name"])
|
||||||
if master_type == "Customer" and master_name:
|
if master_type == "Customer" and master_name:
|
||||||
super(DocType, self).check_credit_limit(d.account)
|
super(DocType, self).check_credit_limit(d.account)
|
||||||
@ -328,18 +328,18 @@ class DocType(AccountsController):
|
|||||||
cond = (flt(self.doc.write_off_amount) > 0) and \
|
cond = (flt(self.doc.write_off_amount) > 0) and \
|
||||||
' and outstanding_amount <= '+ self.doc.write_off_amount or ''
|
' and outstanding_amount <= '+ self.doc.write_off_amount or ''
|
||||||
if self.doc.write_off_based_on == 'Accounts Receivable':
|
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
|
from `tabSales Invoice` where docstatus = 1 and company = %s
|
||||||
and outstanding_amount > 0 %s""" % ('%s', cond), self.doc.company)
|
and outstanding_amount > 0 %s""" % ('%s', cond), self.doc.company)
|
||||||
elif self.doc.write_off_based_on == 'Accounts Payable':
|
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
|
from `tabPurchase Invoice` where docstatus = 1 and company = %s
|
||||||
and outstanding_amount > 0 %s""" % ('%s', cond), self.doc.company)
|
and outstanding_amount > 0 %s""" % ('%s', cond), self.doc.company)
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@frappe.whitelist()
|
||||||
def get_default_bank_cash_account(company, voucher_type):
|
def get_default_bank_cash_account(company, voucher_type):
|
||||||
from erpnext.accounts.utils import get_balance_on
|
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")
|
voucher_type=="Bank Voucher" and "default_bank_account" or "default_cash_account")
|
||||||
if account:
|
if account:
|
||||||
return {
|
return {
|
||||||
@ -347,10 +347,10 @@ def get_default_bank_cash_account(company, voucher_type):
|
|||||||
"balance": get_balance_on(account)
|
"balance": get_balance_on(account)
|
||||||
}
|
}
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@frappe.whitelist()
|
||||||
def get_payment_entry_from_sales_invoice(sales_invoice):
|
def get_payment_entry_from_sales_invoice(sales_invoice):
|
||||||
from erpnext.accounts.utils import get_balance_on
|
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 = get_payment_entry(si.doc)
|
||||||
jv.doc.remark = 'Payment received against Sales Invoice %(name)s. %(remarks)s' % si.doc.fields
|
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]
|
return [d.fields for d in jv.doclist]
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@frappe.whitelist()
|
||||||
def get_payment_entry_from_purchase_invoice(purchase_invoice):
|
def get_payment_entry_from_purchase_invoice(purchase_invoice):
|
||||||
from erpnext.accounts.utils import get_balance_on
|
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 = get_payment_entry(pi.doc)
|
||||||
jv.doc.remark = 'Payment against Purchase Invoice %(name)s. %(remarks)s' % pi.doc.fields
|
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):
|
def get_payment_entry(doc):
|
||||||
bank_account = get_default_bank_cash_account(doc.company, "Bank Voucher")
|
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.voucher_type = 'Bank Voucher'
|
||||||
|
|
||||||
jv.doc.company = doc.company
|
jv.doc.company = doc.company
|
||||||
@ -408,42 +408,42 @@ def get_payment_entry(doc):
|
|||||||
|
|
||||||
return jv
|
return jv
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@frappe.whitelist()
|
||||||
def get_opening_accounts(company):
|
def get_opening_accounts(company):
|
||||||
"""get all balance sheet accounts for opening entry"""
|
"""get all balance sheet accounts for opening entry"""
|
||||||
from erpnext.accounts.utils import get_balance_on
|
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)
|
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]
|
return [{"account": a, "balance": get_balance_on(a)} for a in accounts]
|
||||||
|
|
||||||
def get_against_purchase_invoice(doctype, txt, searchfield, start, page_len, filters):
|
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
|
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""" %
|
and outstanding_amount > 0 and %s like %s order by name desc limit %s, %s""" %
|
||||||
("%s", searchfield, "%s", "%s", "%s"),
|
("%s", searchfield, "%s", "%s", "%s"),
|
||||||
(filters["account"], "%%%s%%" % txt, start, page_len))
|
(filters["account"], "%%%s%%" % txt, start, page_len))
|
||||||
|
|
||||||
def get_against_sales_invoice(doctype, txt, searchfield, start, page_len, filters):
|
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
|
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""" %
|
and outstanding_amount > 0 and `%s` like %s order by name desc limit %s, %s""" %
|
||||||
("%s", searchfield, "%s", "%s", "%s"),
|
("%s", searchfield, "%s", "%s", "%s"),
|
||||||
(filters["account"], "%%%s%%" % txt, start, page_len))
|
(filters["account"], "%%%s%%" % txt, start, page_len))
|
||||||
|
|
||||||
def get_against_jv(doctype, txt, searchfield, start, page_len, filters):
|
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
|
from `tabJournal Voucher` jv, `tabJournal Voucher Detail` jv_detail
|
||||||
where jv_detail.parent = jv.name and jv_detail.account = %s and jv.docstatus = 1
|
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""" %
|
and jv.%s like %s order by jv.name desc limit %s, %s""" %
|
||||||
("%s", searchfield, "%s", "%s", "%s"),
|
("%s", searchfield, "%s", "%s", "%s"),
|
||||||
(filters["account"], "%%%s%%" % txt, start, page_len))
|
(filters["account"], "%%%s%%" % txt, start, page_len))
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@frappe.whitelist()
|
||||||
def get_outstanding(args):
|
def get_outstanding(args):
|
||||||
args = eval(args)
|
args = eval(args)
|
||||||
if args.get("doctype") == "Journal Voucher" and args.get("account"):
|
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))
|
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||||
from `tabJournal Voucher Detail` where parent=%s and account=%s
|
from `tabJournal Voucher Detail` where parent=%s and account=%s
|
||||||
and ifnull(against_invoice, '')='' and ifnull(against_voucher, '')=''
|
and ifnull(against_invoice, '')='' and ifnull(against_voucher, '')=''
|
||||||
@ -457,11 +457,11 @@ def get_outstanding(args):
|
|||||||
|
|
||||||
elif args.get("doctype") == "Sales Invoice":
|
elif args.get("doctype") == "Sales Invoice":
|
||||||
return {
|
return {
|
||||||
"credit": flt(webnotes.conn.get_value("Sales Invoice", args["docname"],
|
"credit": flt(frappe.conn.get_value("Sales Invoice", args["docname"],
|
||||||
"outstanding_amount"))
|
"outstanding_amount"))
|
||||||
}
|
}
|
||||||
elif args.get("doctype") == "Purchase Invoice":
|
elif args.get("doctype") == "Purchase Invoice":
|
||||||
return {
|
return {
|
||||||
"debit": flt(webnotes.conn.get_value("Purchase Invoice", args["docname"],
|
"debit": flt(frappe.conn.get_value("Purchase Invoice", args["docname"],
|
||||||
"outstanding_amount"))
|
"outstanding_amount"))
|
||||||
}
|
}
|
||||||
|
@ -4,40 +4,40 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import unittest
|
import unittest
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
class TestJournalVoucher(unittest.TestCase):
|
class TestJournalVoucher(unittest.TestCase):
|
||||||
def test_journal_voucher_with_against_jv(self):
|
def test_journal_voucher_with_against_jv(self):
|
||||||
self.clear_account_balance()
|
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.insert()
|
||||||
jv_invoice.submit()
|
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))
|
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.doclist[1].against_jv = jv_invoice.doc.name
|
||||||
jv_payment.insert()
|
jv_payment.insert()
|
||||||
jv_payment.submit()
|
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))
|
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))
|
where against_jv=%s and credit=400""", jv_invoice.doc.name))
|
||||||
|
|
||||||
# cancel jv_invoice
|
# cancel jv_invoice
|
||||||
jv_invoice.cancel()
|
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))
|
where against_jv=%s""", jv_invoice.doc.name))
|
||||||
|
|
||||||
def test_jv_against_stock_account(self):
|
def test_jv_against_stock_account(self):
|
||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
||||||
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.doclist[1].account = "_Test Warehouse - _TC"
|
||||||
jv.insert()
|
jv.insert()
|
||||||
|
|
||||||
@ -47,25 +47,25 @@ class TestJournalVoucher(unittest.TestCase):
|
|||||||
set_perpetual_inventory(0)
|
set_perpetual_inventory(0)
|
||||||
|
|
||||||
def test_monthly_budget_crossed_ignore(self):
|
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()
|
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].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
|
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
|
||||||
jv.doclist[2].debit = 20000.0
|
jv.doclist[2].debit = 20000.0
|
||||||
jv.doclist[1].credit = 20000.0
|
jv.doclist[1].credit = 20000.0
|
||||||
jv.insert()
|
jv.insert()
|
||||||
jv.submit()
|
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}))
|
{"voucher_type": "Journal Voucher", "voucher_no": jv.doc.name}))
|
||||||
|
|
||||||
def test_monthly_budget_crossed_stop(self):
|
def test_monthly_budget_crossed_stop(self):
|
||||||
from erpnext.accounts.utils import BudgetError
|
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()
|
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].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
|
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
|
||||||
jv.doclist[2].debit = 20000.0
|
jv.doclist[2].debit = 20000.0
|
||||||
@ -74,16 +74,16 @@ class TestJournalVoucher(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertRaises(BudgetError, jv.submit)
|
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):
|
def test_yearly_budget_crossed_stop(self):
|
||||||
from erpnext.accounts.utils import BudgetError
|
from erpnext.accounts.utils import BudgetError
|
||||||
self.clear_account_balance()
|
self.clear_account_balance()
|
||||||
self.test_monthly_budget_crossed_ignore()
|
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.doc.posting_date = "2013-08-12"
|
||||||
jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
jv.doclist[2].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
|
jv.doclist[2].cost_center = "_Test Cost Center - _TC"
|
||||||
@ -93,39 +93,39 @@ class TestJournalVoucher(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertRaises(BudgetError, jv.submit)
|
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):
|
def test_monthly_budget_on_cancellation(self):
|
||||||
from erpnext.accounts.utils import BudgetError
|
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()
|
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].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv.doclist[1].cost_center = "_Test Cost Center - _TC"
|
jv.doclist[1].cost_center = "_Test Cost Center - _TC"
|
||||||
jv.doclist[1].credit = 30000.0
|
jv.doclist[1].credit = 30000.0
|
||||||
jv.doclist[2].debit = 30000.0
|
jv.doclist[2].debit = 30000.0
|
||||||
jv.submit()
|
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}))
|
{"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].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv1.doclist[2].cost_center = "_Test Cost Center - _TC"
|
jv1.doclist[2].cost_center = "_Test Cost Center - _TC"
|
||||||
jv1.doclist[2].debit = 40000.0
|
jv1.doclist[2].debit = 40000.0
|
||||||
jv1.doclist[1].credit = 40000.0
|
jv1.doclist[1].credit = 40000.0
|
||||||
jv1.submit()
|
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}))
|
{"voucher_type": "Journal Voucher", "voucher_no": jv1.doc.name}))
|
||||||
|
|
||||||
self.assertRaises(BudgetError, jv.cancel)
|
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):
|
def clear_account_balance(self):
|
||||||
webnotes.conn.sql("""delete from `tabGL Entry`""")
|
frappe.conn.sql("""delete from `tabGL Entry`""")
|
||||||
|
|
||||||
|
|
||||||
test_records = [
|
test_records = [
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes.utils import flt, get_first_day, get_last_day, has_common
|
from frappe.utils import flt, get_first_day, get_last_day, has_common
|
||||||
import webnotes.defaults
|
import frappe.defaults
|
||||||
from erpnext.accounts.utils import get_balance_on
|
from erpnext.accounts.utils import get_balance_on
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
@ -33,7 +33,7 @@ class DocType:
|
|||||||
ret['company'] = get_companies()
|
ret['company'] = get_companies()
|
||||||
|
|
||||||
#--- to get fiscal year and start_date of that fiscal year -----
|
#--- 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['fiscal_year'] = [r[0] for r in res]
|
||||||
ret['start_dates'] = {}
|
ret['start_dates'] = {}
|
||||||
for r in res:
|
for r in res:
|
||||||
@ -41,7 +41,7 @@ class DocType:
|
|||||||
|
|
||||||
#--- from month and to month (for MIS - Comparison Report) -------
|
#--- from month and to month (for MIS - Comparison Report) -------
|
||||||
month_list = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
|
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
|
fiscal_start_month = fiscal_start_month and fiscal_start_month[0][0] or 1
|
||||||
mon = ['']
|
mon = ['']
|
||||||
for i in range(fiscal_start_month,13): mon.append(month_list[i-1])
|
for i in range(fiscal_start_month,13): mon.append(month_list[i-1])
|
||||||
@ -49,7 +49,7 @@ class DocType:
|
|||||||
ret['month'] = mon
|
ret['month'] = mon
|
||||||
|
|
||||||
# get MIS Type on basis of roles of session user
|
# 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']):
|
if has_common(self.roles, ['Sales Manager']):
|
||||||
type.append('Sales')
|
type.append('Sales')
|
||||||
if has_common(self.roles, ['Purchase Manager']):
|
if has_common(self.roles, ['Purchase Manager']):
|
||||||
@ -76,7 +76,7 @@ class DocType:
|
|||||||
return self.return_data
|
return self.return_data
|
||||||
|
|
||||||
def get_children(self, parent_account, level, pl, company, fy):
|
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]
|
level0_diff = [0 for p in self.period_list]
|
||||||
if pl=='Yes' and level==0: # switch for income & expenses
|
if pl=='Yes' and level==0: # switch for income & expenses
|
||||||
cl = [c for c in cl]
|
cl = [c for c in cl]
|
||||||
@ -123,7 +123,7 @@ class DocType:
|
|||||||
self.return_data.append([4, 'Total '+c[0]] + totals)
|
self.return_data.append([4, 'Total '+c[0]] + totals)
|
||||||
|
|
||||||
def define_periods(self, year, period):
|
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 ''
|
ysd = ysd and ysd[0][0] or ''
|
||||||
|
|
||||||
self.ysd = ysd
|
self.ysd = ysd
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
|
@ -13,15 +13,15 @@ cur_frm.cscript.onload_post_render = function(doc) {
|
|||||||
cur_frm.cscript.refresh = function(doc) {
|
cur_frm.cscript.refresh = function(doc) {
|
||||||
cur_frm.set_intro("");
|
cur_frm.set_intro("");
|
||||||
if(!doc.voucher_no) {
|
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 {
|
} 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) {
|
cur_frm.fields_dict.voucher_no.get_query = function(doc) {
|
||||||
// TO-do: check for pos, it should not come
|
// 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 {
|
else {
|
||||||
return {
|
return {
|
||||||
doctype: doc.voucher_type,
|
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) {
|
cur_frm.cscript.account = function(doc, cdt, cdn) {
|
||||||
return wn.call({
|
return frappe.call({
|
||||||
doc: this.frm.doc,
|
doc: this.frm.doc,
|
||||||
method: "set_account_type",
|
method: "set_account_type",
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
from webnotes.utils import flt
|
from frappe.utils import flt
|
||||||
from webnotes.model.doc import addchild
|
from frappe.model.doc import addchild
|
||||||
from webnotes.model.bean import getlist
|
from frappe.model.bean import getlist
|
||||||
from webnotes import msgprint
|
from frappe import msgprint
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, doc, doclist):
|
def __init__(self, doc, doclist):
|
||||||
@ -16,17 +16,17 @@ class DocType:
|
|||||||
|
|
||||||
def set_account_type(self):
|
def set_account_type(self):
|
||||||
self.doc.account_type = self.doc.account and \
|
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):
|
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
|
where voucher_type = %s and voucher_no = %s
|
||||||
and account = %s""" %
|
and account = %s""" %
|
||||||
(self.doc.account_type, '%s', '%s', '%s'),
|
(self.doc.account_type, '%s', '%s', '%s'),
|
||||||
(self.doc.voucher_type, self.doc.voucher_no, self.doc.account))
|
(self.doc.voucher_type, self.doc.voucher_no, self.doc.account))
|
||||||
|
|
||||||
total_amount = total_amount and flt(total_amount[0][0]) or 0
|
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
|
select sum(ifnull(%s, 0)) - sum(ifnull(%s, 0)) from `tabGL Entry` where
|
||||||
against_voucher = %s and voucher_no != %s
|
against_voucher = %s and voucher_no != %s
|
||||||
and account = %s""" %
|
and account = %s""" %
|
||||||
@ -63,7 +63,7 @@ class DocType:
|
|||||||
cond += self.doc.amt_less_than and \
|
cond += self.doc.amt_less_than and \
|
||||||
' and t2.' + dc+' <= ' + self.doc.amt_less_than or ''
|
' 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,
|
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,
|
sum(ifnull(t2.credit, 0)) - sum(ifnull(t2.debit, 0)) as amt_due, t1.remark,
|
||||||
t2.against_account, t2.name as voucher_detail_no
|
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
|
2. split into multiple rows if partially adjusted, assign against voucher
|
||||||
3. submit payment 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):
|
where name = %s""" % (self.doc.voucher_type, '%s'), self.doc.voucher_no):
|
||||||
msgprint("Please select valid Voucher No to proceed", raise_exception=1)
|
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):
|
def gl_entry_details(doctype, txt, searchfield, start, page_len, filters):
|
||||||
from erpnext.controllers.queries import get_match_cond
|
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
|
gle.%(account_type)s from `tabGL Entry` gle
|
||||||
where gle.account = '%(acc)s'
|
where gle.account = '%(acc)s'
|
||||||
and gle.voucher_type = '%(dt)s'
|
and gle.voucher_type = '%(dt)s'
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import unittest
|
import unittest
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
test_records = []
|
test_records = []
|
@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes.utils import cstr, flt, getdate
|
from frappe.utils import cstr, flt, getdate
|
||||||
from webnotes import msgprint, _
|
from frappe import msgprint, _
|
||||||
from erpnext.controllers.accounts_controller import AccountsController
|
from erpnext.controllers.accounts_controller import AccountsController
|
||||||
|
|
||||||
class DocType(AccountsController):
|
class DocType(AccountsController):
|
||||||
@ -21,30 +21,30 @@ class DocType(AccountsController):
|
|||||||
self.make_gl_entries()
|
self.make_gl_entries()
|
||||||
|
|
||||||
def on_cancel(self):
|
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)
|
where voucher_type = 'Period Closing Voucher' and voucher_no=%s""", self.doc.name)
|
||||||
|
|
||||||
def validate_account_head(self):
|
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"])
|
self.doc.closing_account_head, ["debit_or_credit", "is_pl_account"])
|
||||||
|
|
||||||
if debit_or_credit != 'Credit' or is_pl_account != 'No':
|
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"))
|
_("must be a Liability account"))
|
||||||
|
|
||||||
def validate_posting_date(self):
|
def validate_posting_date(self):
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
self.year_start_date = get_fiscal_year(self.doc.posting_date, self.doc.fiscal_year)[1]
|
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""",
|
where posting_date > %s and fiscal_year = %s and docstatus = 1""",
|
||||||
(self.doc.posting_date, self.doc.fiscal_year))
|
(self.doc.posting_date, self.doc.fiscal_year))
|
||||||
if pce and pce[0][0]:
|
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)
|
_("has been made after posting date") + ": " + self.doc.posting_date)
|
||||||
|
|
||||||
def validate_pl_balances(self):
|
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))
|
select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0))
|
||||||
from `tabGL Entry` t1, tabAccount t2
|
from `tabGL Entry` t1, tabAccount t2
|
||||||
where t1.account = t2.name and t1.posting_date between %s and %s
|
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""",
|
and t2.docstatus < 2 and t2.company = %s""",
|
||||||
(self.year_start_date, self.doc.posting_date, self.doc.company))
|
(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))
|
select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0))
|
||||||
from `tabGL Entry` t1, tabAccount t2
|
from `tabGL Entry` t1, tabAccount t2
|
||||||
where t1.account = t2.name and t1.posting_date between %s and %s
|
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
|
expense_bal = expense_bal and expense_bal[0][0] or 0
|
||||||
|
|
||||||
if not income_bal and not expense_bal:
|
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):
|
def get_pl_balances(self):
|
||||||
"""Get balance for pl accounts"""
|
"""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
|
select t1.account, sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) as balance
|
||||||
from `tabGL Entry` t1, `tabAccount` t2
|
from `tabGL Entry` t1, `tabAccount` t2
|
||||||
where t1.account = t2.name and ifnull(t2.is_pl_account, 'No') = 'Yes'
|
where t1.account = t2.name and ifnull(t2.is_pl_account, 'No') = 'Yes'
|
||||||
|
@ -4,30 +4,30 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import unittest
|
import unittest
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
class TestPeriodClosingVoucher(unittest.TestCase):
|
class TestPeriodClosingVoucher(unittest.TestCase):
|
||||||
def test_closing_entry(self):
|
def test_closing_entry(self):
|
||||||
# clear GL Entries
|
# 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
|
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.insert()
|
||||||
jv.submit()
|
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].account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
jv1.doclist[2].debit = 600.0
|
jv1.doclist[2].debit = 600.0
|
||||||
jv1.doclist[1].credit = 600.0
|
jv1.doclist[1].credit = 600.0
|
||||||
jv1.insert()
|
jv1.insert()
|
||||||
jv1.submit()
|
jv1.submit()
|
||||||
|
|
||||||
pcv = webnotes.bean(copy=test_record)
|
pcv = frappe.bean(copy=test_record)
|
||||||
pcv.insert()
|
pcv.insert()
|
||||||
pcv.submit()
|
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
|
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)
|
order by account asc, debit asc""", pcv.doc.name, as_dict=1)
|
||||||
|
|
||||||
|
@ -74,5 +74,5 @@ cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn)
|
|||||||
|
|
||||||
|
|
||||||
cur_frm.fields_dict.user.get_query = function(doc,cdt,cdn) {
|
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"}
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,17 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes import msgprint, _
|
from frappe import msgprint, _
|
||||||
from webnotes.utils import cint
|
from frappe.utils import cint
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self,doc,doclist):
|
def __init__(self,doc,doclist):
|
||||||
self.doc, self.doclist = doc,doclist
|
self.doc, self.doclist = doc,doclist
|
||||||
|
|
||||||
def get_series(self):
|
def get_series(self):
|
||||||
import webnotes.model.doctype
|
import frappe.model.doctype
|
||||||
docfield = webnotes.model.doctype.get('Sales Invoice')
|
docfield = frappe.model.doctype.get('Sales Invoice')
|
||||||
series = [d.options for d in docfield
|
series = [d.options for d in docfield
|
||||||
if d.doctype == 'DocField' and d.fieldname == 'naming_series']
|
if d.doctype == 'DocField' and d.fieldname == 'naming_series']
|
||||||
return series and series[0] or ''
|
return series and series[0] or ''
|
||||||
@ -23,7 +23,7 @@ class DocType:
|
|||||||
self.validate_all_link_fields()
|
self.validate_all_link_fields()
|
||||||
|
|
||||||
def check_for_duplicate(self):
|
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""",
|
where ifnull(user, '') = %s and name != %s and company = %s""",
|
||||||
(self.doc.user, self.doc.name, self.doc.company))
|
(self.doc.user, self.doc.name, self.doc.company))
|
||||||
if res:
|
if res:
|
||||||
@ -35,7 +35,7 @@ class DocType:
|
|||||||
(res[0][0], self.doc.company), raise_exception=1)
|
(res[0][0], self.doc.company), raise_exception=1)
|
||||||
|
|
||||||
def validate_expense_account(self):
|
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:
|
and not self.doc.expense_account:
|
||||||
msgprint(_("Expense Account is mandatory"), raise_exception=1)
|
msgprint(_("Expense Account is mandatory"), raise_exception=1)
|
||||||
|
|
||||||
@ -46,19 +46,19 @@ class DocType:
|
|||||||
|
|
||||||
for link_dt, dn_list in accounts.items():
|
for link_dt, dn_list in accounts.items():
|
||||||
for link_dn in dn_list:
|
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}):
|
"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):
|
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:
|
for user in pos_view_users:
|
||||||
if user:
|
if user:
|
||||||
webnotes.defaults.set_user_default("is_pos", 1, user)
|
frappe.defaults.set_user_default("is_pos", 1, user)
|
||||||
else:
|
else:
|
||||||
webnotes.defaults.set_global_default("is_pos", 1)
|
frappe.defaults.set_global_default("is_pos", 1)
|
||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
self.on_update()
|
self.on_update()
|
@ -5,7 +5,7 @@ cur_frm.cscript.tname = "Purchase Invoice Item";
|
|||||||
cur_frm.cscript.fname = "entries";
|
cur_frm.cscript.fname = "entries";
|
||||||
cur_frm.cscript.other_fname = "other_charges";
|
cur_frm.cscript.other_fname = "other_charges";
|
||||||
|
|
||||||
wn.provide("erpnext.accounts");
|
frappe.provide("erpnext.accounts");
|
||||||
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
|
{% 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/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js' %}
|
||||||
{% include 'accounts/doctype/sales_invoice/pos.js' %}
|
{% include 'accounts/doctype/sales_invoice/pos.js' %}
|
||||||
@ -27,25 +27,25 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
|||||||
|
|
||||||
// Show / Hide button
|
// Show / Hide button
|
||||||
if(doc.docstatus==1 && doc.outstanding_amount > 0)
|
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) {
|
if(doc.docstatus==1) {
|
||||||
cur_frm.appframe.add_button(wn._('View Ledger'), function() {
|
cur_frm.appframe.add_button(frappe._('View Ledger'), function() {
|
||||||
wn.route_options = {
|
frappe.route_options = {
|
||||||
"voucher_no": doc.name,
|
"voucher_no": doc.name,
|
||||||
"from_date": doc.posting_date,
|
"from_date": doc.posting_date,
|
||||||
"to_date": doc.posting_date,
|
"to_date": doc.posting_date,
|
||||||
"company": doc.company,
|
"company": doc.company,
|
||||||
group_by_voucher: 0
|
group_by_voucher: 0
|
||||||
};
|
};
|
||||||
wn.set_route("query-report", "General Ledger");
|
frappe.set_route("query-report", "General Ledger");
|
||||||
}, "icon-table");
|
}, "icon-table");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(doc.docstatus===0) {
|
if(doc.docstatus===0) {
|
||||||
cur_frm.add_custom_button(wn._('From Purchase Order'),
|
cur_frm.add_custom_button(frappe._('From Purchase Order'),
|
||||||
function() {
|
function() {
|
||||||
wn.model.map_current_doc({
|
frappe.model.map_current_doc({
|
||||||
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice",
|
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice",
|
||||||
source_doctype: "Purchase Order",
|
source_doctype: "Purchase Order",
|
||||||
get_query_filters: {
|
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() {
|
function() {
|
||||||
wn.model.map_current_doc({
|
frappe.model.map_current_doc({
|
||||||
method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
|
method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
|
||||||
source_doctype: "Purchase Receipt",
|
source_doctype: "Purchase Receipt",
|
||||||
get_query_filters: {
|
get_query_filters: {
|
||||||
@ -108,7 +108,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
entries_add: function(doc, cdt, cdn) {
|
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"]);
|
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() {
|
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",
|
method: "erpnext.accounts.doctype.journal_voucher.journal_voucher.get_payment_entry_from_purchase_invoice",
|
||||||
args: {
|
args: {
|
||||||
"purchase_invoice": cur_frm.doc.name,
|
"purchase_invoice": cur_frm.doc.name,
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
var doclist = wn.model.sync(r.message);
|
var doclist = frappe.model.sync(r.message);
|
||||||
wn.set_route("Form", doclist[0].doctype, doclist[0].name);
|
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;
|
cur_frm.pformat.print_heading = doc.select_print_heading;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cur_frm.pformat.print_heading = wn._("Purchase Invoice");
|
cur_frm.pformat.print_heading = frappe._("Purchase Invoice");
|
||||||
}
|
}
|
@ -2,15 +2,15 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
from webnotes.utils import add_days, cint, cstr, flt, formatdate
|
from frappe.utils import add_days, cint, cstr, flt, formatdate
|
||||||
from webnotes.model.bean import getlist
|
from frappe.model.bean import getlist
|
||||||
from webnotes.model.code import get_obj
|
from frappe.model.code import get_obj
|
||||||
from webnotes import msgprint, _
|
from frappe import msgprint, _
|
||||||
from erpnext.setup.utils import get_company_currency
|
from erpnext.setup.utils import get_company_currency
|
||||||
|
|
||||||
import webnotes.defaults
|
import frappe.defaults
|
||||||
|
|
||||||
from erpnext.controllers.buying_controller import BuyingController
|
from erpnext.controllers.buying_controller import BuyingController
|
||||||
from erpnext.accounts.party import get_party_account, get_due_date
|
from erpnext.accounts.party import get_party_account, get_due_date
|
||||||
@ -73,7 +73,7 @@ class DocType(BuyingController):
|
|||||||
def check_active_purchase_items(self):
|
def check_active_purchase_items(self):
|
||||||
for d in getlist(self.doclist, 'entries'):
|
for d in getlist(self.doclist, 'entries'):
|
||||||
if d.item_code: # extra condn coz item_code is not mandatory in PV
|
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:
|
if valid_item[0][0] == 2:
|
||||||
msgprint("Item : '%s' is Inactive, you can restore it from Trash" %(d.item_code))
|
msgprint("Item : '%s' is Inactive, you can restore it from Trash" %(d.item_code))
|
||||||
raise Exception
|
raise Exception
|
||||||
@ -93,7 +93,7 @@ class DocType(BuyingController):
|
|||||||
def validate_bill_no(self):
|
def validate_bill_no(self):
|
||||||
if self.doc.bill_no and self.doc.bill_no.lower().strip() \
|
if self.doc.bill_no and self.doc.bill_no.lower().strip() \
|
||||||
not in ['na', 'not applicable', 'none']:
|
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""",
|
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))
|
(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):
|
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"
|
self.doc.remarks = "No Remarks"
|
||||||
|
|
||||||
def validate_credit_acc(self):
|
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)
|
self.doc.credit_to)
|
||||||
if not acc:
|
if not acc:
|
||||||
msgprint("Account: "+ self.doc.credit_to + "does not exist")
|
msgprint("Account: "+ self.doc.credit_to + "does not exist")
|
||||||
@ -125,7 +125,7 @@ class DocType(BuyingController):
|
|||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
def check_for_acc_head_of_supplier(self):
|
def check_for_acc_head_of_supplier(self):
|
||||||
if self.doc.supplier and self.doc.credit_to:
|
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)):
|
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)
|
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'):
|
for d in getlist(self.doclist,'entries'):
|
||||||
if d.purchase_order and not d.purchase_order in check_list and not d.purchase_receipt:
|
if d.purchase_order and not d.purchase_order in check_list and not d.purchase_receipt:
|
||||||
check_list.append(d.purhcase_order)
|
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:
|
if stopped:
|
||||||
msgprint("One cannot do any transaction against 'Purchase Order' : %s, it's status is 'Stopped'" % (d.purhcase_order))
|
msgprint("One cannot do any transaction against 'Purchase Order' : %s, it's status is 'Stopped'" % (d.purhcase_order))
|
||||||
raise Exception
|
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, {
|
super(DocType, self).validate_with_previous_doc(self.tname, {
|
||||||
"Purchase Order Item": {
|
"Purchase Order Item": {
|
||||||
"ref_dn_field": "po_detail",
|
"ref_dn_field": "po_detail",
|
||||||
@ -189,7 +189,7 @@ class DocType(BuyingController):
|
|||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
def set_against_expense_account(self):
|
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:
|
if auto_accounting_for_stock:
|
||||||
stock_not_billed_account = self.get_company_default("stock_received_but_not_billed")
|
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)
|
self.doc.against_expense_account = ",".join(against_accounts)
|
||||||
|
|
||||||
def po_required(self):
|
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'):
|
for d in getlist(self.doclist,'entries'):
|
||||||
if not d.purchase_order:
|
if not d.purchase_order:
|
||||||
msgprint("Purchse Order No. required against item %s"%d.item_code)
|
msgprint("Purchse Order No. required against item %s"%d.item_code)
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
def pr_required(self):
|
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'):
|
for d in getlist(self.doclist,'entries'):
|
||||||
if not d.purchase_receipt:
|
if not d.purchase_receipt:
|
||||||
msgprint("Purchase Receipt No. required against item %s"%d.item_code)
|
msgprint("Purchase Receipt No. required against item %s"%d.item_code)
|
||||||
@ -238,13 +238,13 @@ class DocType(BuyingController):
|
|||||||
def check_prev_docstatus(self):
|
def check_prev_docstatus(self):
|
||||||
for d in getlist(self.doclist,'entries'):
|
for d in getlist(self.doclist,'entries'):
|
||||||
if d.purchase_order:
|
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:
|
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:
|
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:
|
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):
|
def update_against_document_in_jv(self):
|
||||||
@ -289,7 +289,7 @@ class DocType(BuyingController):
|
|||||||
|
|
||||||
def make_gl_entries(self):
|
def make_gl_entries(self):
|
||||||
auto_accounting_for_stock = \
|
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 = []
|
gl_entries = []
|
||||||
|
|
||||||
@ -324,7 +324,7 @@ class DocType(BuyingController):
|
|||||||
# accumulate valuation tax
|
# accumulate valuation tax
|
||||||
if tax.category in ("Valuation", "Valuation and Total") and flt(tax.tax_amount):
|
if tax.category in ("Valuation", "Valuation and Total") and flt(tax.tax_amount):
|
||||||
if auto_accounting_for_stock and not tax.cost_center:
|
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" %
|
if tax/charges category is Valuation or Valuation and Total" %
|
||||||
{"row": tax.idx}))
|
{"row": tax.idx}))
|
||||||
valuation_tax.setdefault(tax.cost_center, 0)
|
valuation_tax.setdefault(tax.cost_center, 0)
|
||||||
@ -414,25 +414,25 @@ class DocType(BuyingController):
|
|||||||
def update_raw_material_cost(self):
|
def update_raw_material_cost(self):
|
||||||
if self.sub_contracted_items:
|
if self.sub_contracted_items:
|
||||||
for d in self.doclist.get({"parentfield": "entries"}):
|
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
|
from `tabBOM` where item = %s and is_default = 1 and docstatus = 1
|
||||||
and is_active = 1 """, (d.item_code,))
|
and is_active = 1 """, (d.item_code,))
|
||||||
rm_cost = rm_cost and flt(rm_cost[0][0]) or 0
|
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},
|
"UOM Conversion Detail", {"parent": d.item_code, "uom": d.uom},
|
||||||
"conversion_factor")) or 1
|
"conversion_factor")) or 1
|
||||||
|
|
||||||
d.rm_supp_cost = rm_cost * flt(d.qty) * flt(d.conversion_factor)
|
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):
|
def get_expense_account(doctype, txt, searchfield, start, page_len, filters):
|
||||||
from erpnext.controllers.queries import get_match_cond
|
from erpnext.controllers.queries import get_match_cond
|
||||||
|
|
||||||
# expense account can be any Debit account,
|
# expense account can be any Debit account,
|
||||||
# but can also be a Liability account with account_type='Expense Account' in special circumstances.
|
# but can also be a Liability account with account_type='Expense Account' in special circumstances.
|
||||||
# Hence the first condition is an "OR"
|
# 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"
|
where (tabAccount.debit_or_credit="Debit"
|
||||||
or tabAccount.account_type = "Expense Account")
|
or tabAccount.account_type = "Expense Account")
|
||||||
and tabAccount.group_or_ledger="Ledger"
|
and tabAccount.group_or_ledger="Ledger"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
// render
|
// render
|
||||||
wn.listview_settings['Purchase Invoice'] = {
|
frappe.listview_settings['Purchase Invoice'] = {
|
||||||
add_fields: ["`tabPurchase Invoice`.grand_total", "`tabPurchase Invoice`.outstanding_amount"],
|
add_fields: ["`tabPurchase Invoice`.grand_total", "`tabPurchase Invoice`.outstanding_amount"],
|
||||||
add_columns: [{"content":"paid_amount", width:"10%", type:"bar-graph", label: "Paid"}],
|
add_columns: [{"content":"paid_amount", width:"10%", type:"bar-graph", label: "Paid"}],
|
||||||
prepare_data: function(data) {
|
prepare_data: function(data) {
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import unittest
|
import unittest
|
||||||
import webnotes
|
import frappe
|
||||||
import webnotes.model
|
import frappe.model
|
||||||
import json
|
import json
|
||||||
from webnotes.utils import cint
|
from frappe.utils import cint
|
||||||
import webnotes.defaults
|
import frappe.defaults
|
||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
||||||
|
|
||||||
test_dependencies = ["Item", "Cost Center"]
|
test_dependencies = ["Item", "Cost Center"]
|
||||||
@ -17,9 +17,9 @@ test_ignore = ["Serial No"]
|
|||||||
class TestPurchaseInvoice(unittest.TestCase):
|
class TestPurchaseInvoice(unittest.TestCase):
|
||||||
def test_gl_entries_without_auto_accounting_for_stock(self):
|
def test_gl_entries_without_auto_accounting_for_stock(self):
|
||||||
set_perpetual_inventory(0)
|
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.run_method("calculate_taxes_and_totals")
|
||||||
wrapper.insert()
|
wrapper.insert()
|
||||||
wrapper.submit()
|
wrapper.submit()
|
||||||
@ -37,21 +37,21 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
"_Test Account VAT - _TC": [156.25, 0],
|
"_Test Account VAT - _TC": [156.25, 0],
|
||||||
"_Test Account Discount - _TC": [0, 168.03],
|
"_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)
|
where voucher_type = 'Purchase Invoice' and voucher_no = %s""", dl[0].name, as_dict=1)
|
||||||
for d in gl_entries:
|
for d in gl_entries:
|
||||||
self.assertEqual([d.debit, d.credit], expected_gl_entries.get(d.account))
|
self.assertEqual([d.debit, d.credit], expected_gl_entries.get(d.account))
|
||||||
|
|
||||||
def test_gl_entries_with_auto_accounting_for_stock(self):
|
def test_gl_entries_with_auto_accounting_for_stock(self):
|
||||||
set_perpetual_inventory(1)
|
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.run_method("calculate_taxes_and_totals")
|
||||||
pi.insert()
|
pi.insert()
|
||||||
pi.submit()
|
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
|
from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s
|
||||||
order by account asc""", pi.doc.name, as_dict=1)
|
order by account asc""", pi.doc.name, as_dict=1)
|
||||||
self.assertTrue(gl_entries)
|
self.assertTrue(gl_entries)
|
||||||
@ -73,9 +73,9 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
def test_gl_entries_with_aia_for_non_stock_items(self):
|
def test_gl_entries_with_aia_for_non_stock_items(self):
|
||||||
set_perpetual_inventory()
|
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].item_code = "_Test Non Stock Item"
|
||||||
pi.doclist[1].expense_account = "_Test Account Cost for Goods Sold - _TC"
|
pi.doclist[1].expense_account = "_Test Account Cost for Goods Sold - _TC"
|
||||||
pi.doclist.pop(2)
|
pi.doclist.pop(2)
|
||||||
@ -84,7 +84,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
pi.insert()
|
pi.insert()
|
||||||
pi.submit()
|
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
|
from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no=%s
|
||||||
order by account asc""", pi.doc.name, as_dict=1)
|
order by account asc""", pi.doc.name, as_dict=1)
|
||||||
self.assertTrue(gl_entries)
|
self.assertTrue(gl_entries)
|
||||||
@ -102,7 +102,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
set_perpetual_inventory(0)
|
set_perpetual_inventory(0)
|
||||||
|
|
||||||
def test_purchase_invoice_calculation(self):
|
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.run_method("calculate_taxes_and_totals")
|
||||||
wrapper.insert()
|
wrapper.insert()
|
||||||
wrapper.load_from_db()
|
wrapper.load_from_db()
|
||||||
@ -136,7 +136,7 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
self.assertEqual(tax.total, expected_values[i][2])
|
self.assertEqual(tax.total, expected_values[i][2])
|
||||||
|
|
||||||
def test_purchase_invoice_with_subcontracted_item(self):
|
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.doclist[1].item_code = "_Test FG Item"
|
||||||
wrapper.run_method("calculate_taxes_and_totals")
|
wrapper.run_method("calculate_taxes_and_totals")
|
||||||
wrapper.insert()
|
wrapper.insert()
|
||||||
@ -174,11 +174,11 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
|
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
|
||||||
import test_records as jv_test_records
|
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.insert()
|
||||||
jv.submit()
|
jv.submit()
|
||||||
|
|
||||||
pi = webnotes.bean(copy=test_records[0])
|
pi = frappe.bean(copy=test_records[0])
|
||||||
pi.doclist.append({
|
pi.doclist.append({
|
||||||
"doctype": "Purchase Invoice Advance",
|
"doctype": "Purchase Invoice Advance",
|
||||||
"parentfield": "advance_allocation_details",
|
"parentfield": "advance_allocation_details",
|
||||||
@ -193,17 +193,17 @@ class TestPurchaseInvoice(unittest.TestCase):
|
|||||||
pi.submit()
|
pi.submit()
|
||||||
pi.load_from_db()
|
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))
|
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))
|
where against_voucher=%s and debit=300""", pi.doc.name))
|
||||||
|
|
||||||
self.assertEqual(pi.doc.outstanding_amount, 1212.30)
|
self.assertEqual(pi.doc.outstanding_amount, 1212.30)
|
||||||
|
|
||||||
pi.cancel()
|
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))
|
where against_voucher=%s""", pi.doc.name))
|
||||||
|
|
||||||
test_records = [
|
test_records = [
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{% include "public/js/controllers/accounts.js" %}
|
{% include "public/js/controllers/accounts.js" %}
|
||||||
|
|
||||||
cur_frm.cscript.refresh = 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
|
// For customizing print
|
||||||
@ -37,7 +37,7 @@ cur_frm.pformat.other_charges= function(doc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function print_hide(fieldname) {
|
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;
|
return doc_field.print_hide;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,11 +78,11 @@ cur_frm.cscript.add_deduct_tax = function(doc, cdt, cdn) {
|
|||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
|
|
||||||
if(!d.category && d.add_deduct_tax) {
|
if(!d.category && d.add_deduct_tax) {
|
||||||
msgprint(wn._("Please select Category first"));
|
msgprint(frappe._("Please select Category first"));
|
||||||
d.add_deduct_tax = '';
|
d.add_deduct_tax = '';
|
||||||
}
|
}
|
||||||
else if(d.category != 'Total' && d.add_deduct_tax == 'Deduct') {
|
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 = '';
|
d.add_deduct_tax = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,15 +91,15 @@ cur_frm.cscript.charge_type = function(doc, cdt, cdn) {
|
|||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
|
|
||||||
if(!d.category && d.charge_type) {
|
if(!d.category && d.charge_type) {
|
||||||
msgprint(wn._("Please select Category first"));
|
msgprint(frappe._("Please select Category first"));
|
||||||
d.charge_type = '';
|
d.charge_type = '';
|
||||||
}
|
}
|
||||||
else if(d.idx == 1 && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')) {
|
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 = '';
|
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')) {
|
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 = '';
|
d.charge_type = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,16 +116,16 @@ cur_frm.cscript.row_id = function(doc, cdt, cdn) {
|
|||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
|
|
||||||
if(!d.charge_type && d.row_id) {
|
if(!d.charge_type && d.row_id) {
|
||||||
msgprint(wn._("Please select Charge Type first"));
|
msgprint(frappe._("Please select Charge Type first"));
|
||||||
d.row_id = '';
|
d.row_id = '';
|
||||||
}
|
}
|
||||||
else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && 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 = '';
|
d.row_id = '';
|
||||||
}
|
}
|
||||||
else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On 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){
|
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 = '';
|
d.row_id = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ cur_frm.cscript.rate = function(doc, cdt, cdn) {
|
|||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
|
|
||||||
if(!d.charge_type && d.rate) {
|
if(!d.charge_type && d.rate) {
|
||||||
msgprint(wn._("Please select Charge Type first"));
|
msgprint(frappe._("Please select Charge Type first"));
|
||||||
d.rate = '';
|
d.rate = '';
|
||||||
}
|
}
|
||||||
validated = false;
|
validated = false;
|
||||||
@ -168,11 +168,11 @@ cur_frm.cscript.tax_amount = function(doc, cdt, cdn) {
|
|||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
|
|
||||||
if(!d.charge_type && d.tax_amount) {
|
if(!d.charge_type && d.tax_amount) {
|
||||||
msgprint(wn._("Please select Charge Type first"));
|
msgprint(frappe._("Please select Charge Type first"));
|
||||||
d.tax_amount = '';
|
d.tax_amount = '';
|
||||||
}
|
}
|
||||||
else if(d.charge_type && 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 = '';
|
d.tax_amount = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
from webnotes.model import db_exists
|
from frappe.model import db_exists
|
||||||
from webnotes.model.bean import copy_doclist
|
from frappe.model.bean import copy_doclist
|
||||||
from webnotes.model.code import get_obj
|
from frappe.model.code import get_obj
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ erpnext.POS = Class.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.wrapper.find('input.discount-amount').on("change", function() {
|
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();});
|
this.call_function("remove-items", function() {me.remove_selected_items();});
|
||||||
@ -115,10 +115,10 @@ erpnext.POS = Class.extend({
|
|||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
// Check whether the transaction is "Sales" or "Purchase"
|
// 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");
|
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");
|
this.set_transaction_defaults("Supplier", "import");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -146,7 +146,7 @@ erpnext.POS = Class.extend({
|
|||||||
},
|
},
|
||||||
make_party: function() {
|
make_party: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
this.party_field = wn.ui.form.make_control({
|
this.party_field = frappe.ui.form.make_control({
|
||||||
df: {
|
df: {
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": this.party,
|
"options": this.party,
|
||||||
@ -160,13 +160,13 @@ erpnext.POS = Class.extend({
|
|||||||
this.party_field.make_input();
|
this.party_field.make_input();
|
||||||
this.party_field.$input.on("change", function() {
|
this.party_field.$input.on("change", function() {
|
||||||
if(!me.party_field.autocomplete_open)
|
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);
|
me.party.toLowerCase(), this.value);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
make_barcode: function() {
|
make_barcode: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
this.barcode = wn.ui.form.make_control({
|
this.barcode = frappe.ui.form.make_control({
|
||||||
df: {
|
df: {
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Barcode",
|
"label": "Barcode",
|
||||||
@ -185,7 +185,7 @@ erpnext.POS = Class.extend({
|
|||||||
},
|
},
|
||||||
make_search: function() {
|
make_search: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
this.search = wn.ui.form.make_control({
|
this.search = frappe.ui.form.make_control({
|
||||||
df: {
|
df: {
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Item",
|
"label": "Item",
|
||||||
@ -205,7 +205,7 @@ erpnext.POS = Class.extend({
|
|||||||
},
|
},
|
||||||
make_item_group: function() {
|
make_item_group: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
this.item_group = wn.ui.form.make_control({
|
this.item_group = frappe.ui.form.make_control({
|
||||||
df: {
|
df: {
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Item Group",
|
"options": "Item Group",
|
||||||
@ -225,7 +225,7 @@ erpnext.POS = Class.extend({
|
|||||||
make_item_list: function() {
|
make_item_list: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
me.item_timeout = null;
|
me.item_timeout = null;
|
||||||
wn.call({
|
frappe.call({
|
||||||
method: 'erpnext.accounts.doctype.sales_invoice.pos.get_items',
|
method: 'erpnext.accounts.doctype.sales_invoice.pos.get_items',
|
||||||
args: {
|
args: {
|
||||||
sales_or_purchase: this.sales_or_purchase,
|
sales_or_purchase: this.sales_or_purchase,
|
||||||
@ -284,14 +284,14 @@ erpnext.POS = Class.extend({
|
|||||||
|
|
||||||
// check whether the item is already added
|
// check whether the item is already added
|
||||||
if (no_of_items != 0) {
|
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) {
|
this.frm.cscript.fname, this.frm.doctype), function(i, d) {
|
||||||
if (d.item_code == item_code) {
|
if (d.item_code == item_code) {
|
||||||
caught = true;
|
caught = true;
|
||||||
if (serial_no)
|
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
|
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) {
|
add_new_item_to_grid: function(item_code, serial_no) {
|
||||||
var me = this;
|
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);
|
this.frm.cscript.fname);
|
||||||
child.item_code = item_code;
|
child.item_code = item_code;
|
||||||
|
|
||||||
@ -326,14 +326,14 @@ erpnext.POS = Class.extend({
|
|||||||
},
|
},
|
||||||
update_qty: function(item_code, qty) {
|
update_qty: function(item_code, qty) {
|
||||||
var me = this;
|
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) {
|
this.frm.cscript.fname, this.frm.doctype), function(i, d) {
|
||||||
if (d.item_code == item_code) {
|
if (d.item_code == item_code) {
|
||||||
if (qty == 0) {
|
if (qty == 0) {
|
||||||
wn.model.clear_doc(d.doctype, d.name);
|
frappe.model.clear_doc(d.doctype, d.name);
|
||||||
me.refresh_grid();
|
me.refresh_grid();
|
||||||
} else {
|
} 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 me = this;
|
||||||
var $items = this.wrapper.find("#cart tbody").empty();
|
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) {
|
this.frm.cscript.fname, this.frm.doctype), function(i, d) {
|
||||||
|
|
||||||
$(repl('<tr id="%(item_code)s" data-selected="false">\
|
$(repl('<tr id="%(item_code)s" data-selected="false">\
|
||||||
@ -413,7 +413,7 @@ erpnext.POS = Class.extend({
|
|||||||
},
|
},
|
||||||
show_taxes: function() {
|
show_taxes: function() {
|
||||||
var me = this;
|
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.frm.doc.name, this.frm.cscript.other_fname, this.frm.doctype);
|
||||||
$(this.wrapper).find(".tax-table")
|
$(this.wrapper).find(".tax-table")
|
||||||
.toggle((taxes && taxes.length) ? true : false)
|
.toggle((taxes && taxes.length) ? true : false)
|
||||||
@ -510,7 +510,7 @@ erpnext.POS = Class.extend({
|
|||||||
add_item_thru_barcode: function() {
|
add_item_thru_barcode: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
me.barcode_timeout = null;
|
me.barcode_timeout = null;
|
||||||
wn.call({
|
frappe.call({
|
||||||
method: 'erpnext.accounts.doctype.sales_invoice.pos.get_item_code',
|
method: 'erpnext.accounts.doctype.sales_invoice.pos.get_item_code',
|
||||||
args: {barcode_serial_no: this.barcode.$input.val()},
|
args: {barcode_serial_no: this.barcode.$input.val()},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
@ -521,7 +521,7 @@ erpnext.POS = Class.extend({
|
|||||||
me.add_to_cart(r.message[0][0].name);
|
me.add_to_cart(r.message[0][0].name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
msgprint(wn._("Invalid Barcode"));
|
msgprint(frappe._("Invalid Barcode"));
|
||||||
|
|
||||||
me.refresh();
|
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);
|
this.frm.cscript.fname, this.frm.doctype);
|
||||||
|
|
||||||
$.each(child, function(i, d) {
|
$.each(child, function(i, d) {
|
||||||
for (var i in selected_items) {
|
for (var i in selected_items) {
|
||||||
if (d.item_code == selected_items[i]) {
|
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 = [];
|
var mode_of_payment = [];
|
||||||
|
|
||||||
if (no_of_items == 0)
|
if (no_of_items == 0)
|
||||||
msgprint(wn._("Payment cannot be made for empty cart"));
|
msgprint(frappe._("Payment cannot be made for empty cart"));
|
||||||
else {
|
else {
|
||||||
wn.call({
|
frappe.call({
|
||||||
method: 'erpnext.accounts.doctype.sales_invoice.pos.get_mode_of_payment',
|
method: 'erpnext.accounts.doctype.sales_invoice.pos.get_mode_of_payment',
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
for (x=0; x<=r.message.length - 1; x++) {
|
for (x=0; x<=r.message.length - 1; x++) {
|
||||||
@ -573,7 +573,7 @@ erpnext.POS = Class.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// show payment wizard
|
// show payment wizard
|
||||||
var dialog = new wn.ui.Dialog({
|
var dialog = new frappe.ui.Dialog({
|
||||||
width: 400,
|
width: 400,
|
||||||
title: 'Payment',
|
title: 'Payment',
|
||||||
fields: [
|
fields: [
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
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):
|
def get_items(price_list, sales_or_purchase, item=None, item_group=None):
|
||||||
condition = ""
|
condition = ""
|
||||||
args = {"price_list": price_list}
|
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"
|
condition += " and CONCAT(i.name, i.item_name) like %(name)s"
|
||||||
args["name"] = "%%%s%%" % item
|
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
|
item_det.price_list_rate, item_det.currency
|
||||||
from `tabItem` i LEFT JOIN
|
from `tabItem` i LEFT JOIN
|
||||||
(select item_code, price_list_rate, currency from
|
(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
|
where
|
||||||
%s""" % ('%(price_list)s', condition), args, as_dict=1)
|
%s""" % ('%(price_list)s', condition), args, as_dict=1)
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@frappe.whitelist()
|
||||||
def get_item_code(barcode_serial_no):
|
def get_item_code(barcode_serial_no):
|
||||||
input_via = "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)
|
name=%s""", (barcode_serial_no), as_dict=1)
|
||||||
|
|
||||||
if not item_code:
|
if not item_code:
|
||||||
input_via = "barcode"
|
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)
|
(barcode_serial_no), as_dict=1)
|
||||||
|
|
||||||
if item_code:
|
if item_code:
|
||||||
return item_code, input_via
|
return item_code, input_via
|
||||||
else:
|
else:
|
||||||
webnotes.throw("Invalid Barcode / Serial No")
|
frappe.throw("Invalid Barcode / Serial No")
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@frappe.whitelist()
|
||||||
def get_mode_of_payment():
|
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)
|
@ -14,7 +14,7 @@ cur_frm.pformat.print_heading = 'Invoice';
|
|||||||
{% include 'utilities/doctype/sms_control/sms_control.js' %}
|
{% include 'utilities/doctype/sms_control/sms_control.js' %}
|
||||||
{% include 'accounts/doctype/sales_invoice/pos.js' %}
|
{% include 'accounts/doctype/sales_invoice/pos.js' %}
|
||||||
|
|
||||||
wn.provide("erpnext.accounts");
|
frappe.provide("erpnext.accounts");
|
||||||
erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.extend({
|
erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.extend({
|
||||||
onload: function() {
|
onload: function() {
|
||||||
this._super();
|
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
|
// 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) {
|
if(this.frm.doc.__islocal && !this.frm.doc.amended_from && !this.frm.doc.customer) {
|
||||||
this.frm.set_value("is_pos", 1);
|
this.frm.set_value("is_pos", 1);
|
||||||
this.is_pos(function() {
|
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);
|
cur_frm.cscript.toggle_pos(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -50,20 +50,20 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
|||||||
|
|
||||||
if(doc.docstatus==1) {
|
if(doc.docstatus==1) {
|
||||||
cur_frm.appframe.add_button('View Ledger', function() {
|
cur_frm.appframe.add_button('View Ledger', function() {
|
||||||
wn.route_options = {
|
frappe.route_options = {
|
||||||
"voucher_no": doc.name,
|
"voucher_no": doc.name,
|
||||||
"from_date": doc.posting_date,
|
"from_date": doc.posting_date,
|
||||||
"to_date": doc.posting_date,
|
"to_date": doc.posting_date,
|
||||||
"company": doc.company,
|
"company": doc.company,
|
||||||
group_by_voucher: 0
|
group_by_voucher: 0
|
||||||
};
|
};
|
||||||
wn.set_route("query-report", "General Ledger");
|
frappe.set_route("query-report", "General Ledger");
|
||||||
}, "icon-table");
|
}, "icon-table");
|
||||||
|
|
||||||
var percent_paid = cint(flt(doc.grand_total - doc.outstanding_amount) / flt(doc.grand_total) * 100);
|
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.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) {
|
if(cint(doc.update_stock)!=1) {
|
||||||
// show Make Delivery Note button only if Sales Invoice is not created from Delivery Note
|
// 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)
|
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)
|
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
|
// Show buttons only when pos view is active
|
||||||
@ -89,9 +89,9 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
|||||||
},
|
},
|
||||||
|
|
||||||
sales_order_btn: function() {
|
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() {
|
function() {
|
||||||
wn.model.map_current_doc({
|
frappe.model.map_current_doc({
|
||||||
method: "erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice",
|
method: "erpnext.selling.doctype.sales_order.sales_order.make_sales_invoice",
|
||||||
source_doctype: "Sales Order",
|
source_doctype: "Sales Order",
|
||||||
get_query_filters: {
|
get_query_filters: {
|
||||||
@ -106,9 +106,9 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
|||||||
},
|
},
|
||||||
|
|
||||||
delivery_note_btn: function() {
|
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() {
|
function() {
|
||||||
wn.model.map_current_doc({
|
frappe.model.map_current_doc({
|
||||||
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice",
|
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice",
|
||||||
source_doctype: "Delivery Note",
|
source_doctype: "Delivery Note",
|
||||||
get_query: function() {
|
get_query: function() {
|
||||||
@ -134,7 +134,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
|||||||
if(cint(this.frm.doc.is_pos)) {
|
if(cint(this.frm.doc.is_pos)) {
|
||||||
if(!this.frm.doc.company) {
|
if(!this.frm.doc.company) {
|
||||||
this.frm.set_value("is_pos", 0);
|
this.frm.set_value("is_pos", 0);
|
||||||
msgprint(wn._("Please specify Company to proceed"));
|
msgprint(frappe._("Please specify Company to proceed"));
|
||||||
} else {
|
} else {
|
||||||
var me = this;
|
var me = this;
|
||||||
return this.frm.call({
|
return this.frm.call({
|
||||||
@ -179,7 +179,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
|||||||
|
|
||||||
write_off_outstanding_amount_automatically: function() {
|
write_off_outstanding_amount_automatically: function() {
|
||||||
if(cint(this.frm.doc.write_off_outstanding_amount_automatically)) {
|
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 will make outstanding amount 0
|
||||||
this.frm.set_value("write_off_amount",
|
this.frm.set_value("write_off_amount",
|
||||||
flt(this.frm.doc.grand_total - this.frm.doc.paid_amount), precision("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) {
|
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"]);
|
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 {
|
} else {
|
||||||
hide_field('payments_section');
|
hide_field('payments_section');
|
||||||
for (i in par_flds) {
|
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]);
|
if(!docfield.hidden) unhide_field(par_flds[i]);
|
||||||
}
|
}
|
||||||
cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal, true);
|
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));
|
(cint(doc.update_stock)==1 ? true : false));
|
||||||
|
|
||||||
// India related fields
|
// 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']);
|
if (cp.country == 'India') unhide_field(['c_form_applicable', 'c_form_no']);
|
||||||
else hide_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() {
|
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",
|
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_delivery_note",
|
||||||
source_name: cur_frm.doc.name
|
source_name: cur_frm.doc.name
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.make_bank_voucher = function() {
|
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",
|
method: "erpnext.accounts.doctype.journal_voucher.journal_voucher.get_payment_entry_from_sales_invoice",
|
||||||
args: {
|
args: {
|
||||||
"sales_invoice": cur_frm.doc.name
|
"sales_invoice": cur_frm.doc.name
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
var doclist = wn.model.sync(r.message);
|
var doclist = frappe.model.sync(r.message);
|
||||||
wn.set_route("Form", doclist[0].doctype, doclist[0].name);
|
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) {
|
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
||||||
if(cint(wn.boot.notification_settings.sales_invoice)) {
|
if(cint(frappe.boot.notification_settings.sales_invoice)) {
|
||||||
cur_frm.email_doc(wn.boot.notification_settings.sales_invoice_message);
|
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
|
// set default values for recurring invoices
|
||||||
if(doc.convert_into_recurring_invoice) {
|
if(doc.convert_into_recurring_invoice) {
|
||||||
var owner_email = doc.owner=="Administrator"
|
var owner_email = doc.owner=="Administrator"
|
||||||
? wn.user_info("Administrator").email
|
? frappe.user_info("Administrator").email
|
||||||
: doc.owner;
|
: doc.owner;
|
||||||
|
|
||||||
doc.notification_email_address = $.map([cstr(owner_email),
|
doc.notification_email_address = $.map([cstr(owner_email),
|
||||||
cstr(doc.contact_email)], function(v) { return v || null; }).join(", ");
|
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"]);
|
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];
|
var months = recurring_type_map[doc.recurring_type];
|
||||||
if(months) {
|
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);
|
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');
|
refresh_field('invoice_period_to_date');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,17 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
import webnotes.defaults
|
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
|
get_first_day, get_last_day
|
||||||
|
|
||||||
from webnotes.utils import comma_and, get_url
|
from frappe.utils import comma_and, get_url
|
||||||
from webnotes.model.doc import make_autoname
|
from frappe.model.doc import make_autoname
|
||||||
from webnotes.model.bean import getlist
|
from frappe.model.bean import getlist
|
||||||
from webnotes.model.code import get_obj
|
from frappe.model.code import get_obj
|
||||||
from webnotes import _, msgprint
|
from frappe import _, msgprint
|
||||||
|
|
||||||
from erpnext.accounts.party import get_party_account, get_due_date
|
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):
|
def update_time_log_batch(self, sales_invoice):
|
||||||
for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
|
for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
|
||||||
if d.time_log_batch:
|
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.doc.sales_invoice = sales_invoice
|
||||||
tlb.update_after_submit()
|
tlb.update_after_submit()
|
||||||
|
|
||||||
def validate_time_logs_are_submitted(self):
|
def validate_time_logs_are_submitted(self):
|
||||||
for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
|
for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
|
||||||
if d.time_log_batch:
|
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":
|
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)
|
raise_exception=True)
|
||||||
|
|
||||||
def set_pos_fields(self, for_validate=False):
|
def set_pos_fields(self, for_validate=False):
|
||||||
@ -202,7 +202,7 @@ class DocType(SellingController):
|
|||||||
|
|
||||||
# fetch terms
|
# fetch terms
|
||||||
if self.doc.tc_name and not self.doc.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
|
# fetch charges
|
||||||
if self.doc.charge and not len(self.doclist.get({"parentfield": "other_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")
|
"Sales Invoice Advance", "advance_adjustment_details", "credit")
|
||||||
|
|
||||||
def get_company_abbr(self):
|
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):
|
def update_against_document_in_jv(self):
|
||||||
"""
|
"""
|
||||||
@ -246,7 +246,7 @@ class DocType(SellingController):
|
|||||||
def validate_customer_account(self):
|
def validate_customer_account(self):
|
||||||
"""Validates Debit To Account and Customer Matches"""
|
"""Validates Debit To Account and Customer Matches"""
|
||||||
if self.doc.customer and self.doc.debit_to and not cint(self.doc.is_pos):
|
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 \
|
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())):
|
(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):
|
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:
|
if not acc:
|
||||||
msgprint("Account: "+ self.doc.debit_to + " does not exist")
|
msgprint("Account: "+ self.doc.debit_to + " does not exist")
|
||||||
raise Exception
|
raise Exception
|
||||||
@ -270,8 +270,8 @@ class DocType(SellingController):
|
|||||||
def validate_fixed_asset_account(self):
|
def validate_fixed_asset_account(self):
|
||||||
"""Validate Fixed Asset Account and whether Income Account Entered Exists"""
|
"""Validate Fixed Asset Account and whether Income Account Entered Exists"""
|
||||||
for d in getlist(self.doclist,'entries'):
|
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)
|
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 = webnotes.conn.sql("select account_type from `tabAccount` where name = '%s' and docstatus != 2" % d.income_account)
|
acc = frappe.conn.sql("select account_type from `tabAccount` where name = '%s' and docstatus != 2" % d.income_account)
|
||||||
if not acc:
|
if not acc:
|
||||||
msgprint("Account: "+d.income_account+" does not exist in the system", raise_exception=True)
|
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':
|
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, {
|
super(DocType, self).validate_with_previous_doc(self.tname, {
|
||||||
"Sales Order Item": {
|
"Sales Order Item": {
|
||||||
"ref_dn_field": "so_detail",
|
"ref_dn_field": "so_detail",
|
||||||
@ -332,9 +332,9 @@ class DocType(SellingController):
|
|||||||
"""check in manage account if sales order / delivery note required or not."""
|
"""check in manage account if sales order / delivery note required or not."""
|
||||||
dic = {'Sales Order':'so_required','Delivery Note':'dn_required'}
|
dic = {'Sales Order':'so_required','Delivery Note':'dn_required'}
|
||||||
for i in dic:
|
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'):
|
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(' ','_')]:
|
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)
|
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):
|
def validate_proj_cust(self):
|
||||||
"""check for does customer belong to same project as entered.."""
|
"""check for does customer belong to same project as entered.."""
|
||||||
if self.doc.project_name and self.doc.customer:
|
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:
|
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))
|
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
|
raise Exception
|
||||||
@ -353,7 +353,7 @@ class DocType(SellingController):
|
|||||||
raise Exception
|
raise Exception
|
||||||
if flt(self.doc.paid_amount) + flt(self.doc.write_off_amount) \
|
if flt(self.doc.paid_amount) + flt(self.doc.write_off_amount) \
|
||||||
- flt(self.doc.grand_total) > 1/(10**(self.precision("grand_total") + 1)):
|
- 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"""))
|
greater than Grand Total"""))
|
||||||
|
|
||||||
|
|
||||||
@ -377,28 +377,28 @@ class DocType(SellingController):
|
|||||||
def validate_c_form(self):
|
def validate_c_form(self):
|
||||||
""" Blank C-form no if C-form applicable marked as 'No'"""
|
""" 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:
|
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))
|
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):
|
def update_current_stock(self):
|
||||||
for d in getlist(self.doclist, 'entries'):
|
for d in getlist(self.doclist, 'entries'):
|
||||||
if d.item_code and d.warehouse:
|
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
|
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
|
||||||
|
|
||||||
for d in getlist(self.doclist, 'packing_details'):
|
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.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
|
||||||
d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0
|
d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0
|
||||||
|
|
||||||
|
|
||||||
def get_warehouse(self):
|
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 ''
|
w = w and w[0][0] or ''
|
||||||
if not w:
|
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:
|
if not ps:
|
||||||
msgprint("To make POS entry, please create POS Setting from Accounts --> POS Setting page and refresh the system.", raise_exception=True)
|
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]:
|
elif not ps[0][1]:
|
||||||
@ -425,25 +425,25 @@ class DocType(SellingController):
|
|||||||
if cint(self.doc.is_pos) == 1:
|
if cint(self.doc.is_pos) == 1:
|
||||||
if flt(self.doc.paid_amount) == 0:
|
if flt(self.doc.paid_amount) == 0:
|
||||||
if self.doc.cash_bank_account:
|
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)))
|
(flt(self.doc.grand_total) - flt(self.doc.write_off_amount)))
|
||||||
else:
|
else:
|
||||||
# show message that the amount is not paid
|
# show message that the amount is not paid
|
||||||
webnotes.conn.set(self.doc,'paid_amount',0)
|
frappe.conn.set(self.doc,'paid_amount',0)
|
||||||
webnotes.msgprint("Note: Payment Entry will not be created since 'Cash/Bank Account' was not specified.")
|
frappe.msgprint("Note: Payment Entry will not be created since 'Cash/Bank Account' was not specified.")
|
||||||
else:
|
else:
|
||||||
webnotes.conn.set(self.doc,'paid_amount',0)
|
frappe.conn.set(self.doc,'paid_amount',0)
|
||||||
|
|
||||||
def check_prev_docstatus(self):
|
def check_prev_docstatus(self):
|
||||||
for d in getlist(self.doclist,'entries'):
|
for d in getlist(self.doclist,'entries'):
|
||||||
if d.sales_order:
|
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:
|
if not submitted:
|
||||||
msgprint("Sales Order : "+ cstr(d.sales_order) +" is not submitted")
|
msgprint("Sales Order : "+ cstr(d.sales_order) +" is not submitted")
|
||||||
raise Exception , "Validation Error."
|
raise Exception , "Validation Error."
|
||||||
|
|
||||||
if d.delivery_note:
|
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:
|
if not submitted:
|
||||||
msgprint("Delivery Note : "+ cstr(d.delivery_note) +" is not submitted")
|
msgprint("Delivery Note : "+ cstr(d.delivery_note) +" is not submitted")
|
||||||
raise Exception , "Validation Error."
|
raise Exception , "Validation Error."
|
||||||
@ -451,11 +451,11 @@ class DocType(SellingController):
|
|||||||
def update_stock_ledger(self):
|
def update_stock_ledger(self):
|
||||||
sl_entries = []
|
sl_entries = []
|
||||||
for d in self.get_item_list():
|
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:
|
and d.warehouse:
|
||||||
sl_entries.append(self.get_sl_entries(d, {
|
sl_entries.append(self.get_sl_entries(d, {
|
||||||
"actual_qty": -1*flt(d.qty),
|
"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)
|
self.make_sl_entries(sl_entries)
|
||||||
@ -472,7 +472,7 @@ class DocType(SellingController):
|
|||||||
update_outstanding=update_outstanding, merge_entries=False)
|
update_outstanding=update_outstanding, merge_entries=False)
|
||||||
|
|
||||||
if update_gl_entries_after and cint(self.doc.update_stock) \
|
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()
|
self.update_gl_entries_after()
|
||||||
|
|
||||||
def get_gl_entries(self, warehouse_account=None):
|
def get_gl_entries(self, warehouse_account=None):
|
||||||
@ -534,7 +534,7 @@ class DocType(SellingController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# expense account gl entries
|
# 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):
|
and cint(self.doc.update_stock):
|
||||||
gl_entries += super(DocType, self).get_gl_entries()
|
gl_entries += super(DocType, self).get_gl_entries()
|
||||||
|
|
||||||
@ -584,7 +584,7 @@ class DocType(SellingController):
|
|||||||
def update_c_form(self):
|
def update_c_form(self):
|
||||||
"""Update amended id in C-form"""
|
"""Update amended id in C-form"""
|
||||||
if self.doc.c_form_no and self.doc.amended_from:
|
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,
|
invoice_date = %s, territory = %s, net_total = %s,
|
||||||
grand_total = %s where invoice_no = %s and parent = %s""",
|
grand_total = %s where invoice_no = %s and parent = %s""",
|
||||||
(self.doc.name, self.doc.amended_from, self.doc.c_form_no))
|
(self.doc.name, self.doc.amended_from, self.doc.c_form_no))
|
||||||
@ -592,7 +592,7 @@ class DocType(SellingController):
|
|||||||
@property
|
@property
|
||||||
def meta(self):
|
def meta(self):
|
||||||
if not hasattr(self, "_meta"):
|
if not hasattr(self, "_meta"):
|
||||||
self._meta = webnotes.get_doctype(self.doc.doctype)
|
self._meta = frappe.get_doctype(self.doc.doctype)
|
||||||
return self._meta
|
return self._meta
|
||||||
|
|
||||||
def validate_recurring_invoice(self):
|
def validate_recurring_invoice(self):
|
||||||
@ -613,13 +613,13 @@ class DocType(SellingController):
|
|||||||
def convert_to_recurring(self):
|
def convert_to_recurring(self):
|
||||||
if self.doc.convert_into_recurring_invoice:
|
if self.doc.convert_into_recurring_invoice:
|
||||||
if not self.doc.recurring_id:
|
if not self.doc.recurring_id:
|
||||||
webnotes.conn.set(self.doc, "recurring_id",
|
frappe.conn.set(self.doc, "recurring_id",
|
||||||
make_autoname("RECINV/.#####"))
|
make_autoname("RECINV/.#####"))
|
||||||
|
|
||||||
self.set_next_date()
|
self.set_next_date()
|
||||||
|
|
||||||
elif self.doc.recurring_id:
|
elif self.doc.recurring_id:
|
||||||
webnotes.conn.sql("""update `tabSales Invoice`
|
frappe.conn.sql("""update `tabSales Invoice`
|
||||||
set convert_into_recurring_invoice = 0
|
set convert_into_recurring_invoice = 0
|
||||||
where recurring_id = %s""", (self.doc.recurring_id,))
|
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
|
email_list = filter(None, [cstr(email).strip() for email in
|
||||||
self.doc.notification_email_address.replace("\n", "").split(",")])
|
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:
|
for email in email_list:
|
||||||
if not validate_email_add(email):
|
if not validate_email_add(email):
|
||||||
msgprint(self.meta.get_label("notification_email_address") \
|
msgprint(self.meta.get_label("notification_email_address") \
|
||||||
@ -649,7 +649,7 @@ class DocType(SellingController):
|
|||||||
next_date = get_next_date(self.doc.posting_date,
|
next_date = get_next_date(self.doc.posting_date,
|
||||||
month_map[self.doc.recurring_type], cint(self.doc.repeat_on_day_of_month))
|
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):
|
def get_next_date(dt, mcount, day=None):
|
||||||
dt = getdate(dt)
|
dt = getdate(dt)
|
||||||
@ -665,43 +665,43 @@ def manage_recurring_invoices(next_date=None, commit=True):
|
|||||||
and notify the concerned people
|
and notify the concerned people
|
||||||
"""
|
"""
|
||||||
next_date = next_date or nowdate()
|
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
|
from `tabSales Invoice` where ifnull(convert_into_recurring_invoice, 0)=1
|
||||||
and docstatus=1 and next_date=%s
|
and docstatus=1 and next_date=%s
|
||||||
and next_date <= ifnull(end_date, '2199-12-31')""", next_date)
|
and next_date <= ifnull(end_date, '2199-12-31')""", next_date)
|
||||||
|
|
||||||
exception_list = []
|
exception_list = []
|
||||||
for ref_invoice, recurring_id in recurring_invoices:
|
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""",
|
where posting_date=%s and recurring_id=%s and docstatus=1""",
|
||||||
(next_date, recurring_id)):
|
(next_date, recurring_id)):
|
||||||
try:
|
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)
|
new_invoice_wrapper = make_new_invoice(ref_wrapper, next_date)
|
||||||
send_notification(new_invoice_wrapper)
|
send_notification(new_invoice_wrapper)
|
||||||
if commit:
|
if commit:
|
||||||
webnotes.conn.commit()
|
frappe.conn.commit()
|
||||||
except:
|
except:
|
||||||
if commit:
|
if commit:
|
||||||
webnotes.conn.rollback()
|
frappe.conn.rollback()
|
||||||
|
|
||||||
webnotes.conn.begin()
|
frappe.conn.begin()
|
||||||
webnotes.conn.sql("update `tabSales Invoice` set \
|
frappe.conn.sql("update `tabSales Invoice` set \
|
||||||
convert_into_recurring_invoice = 0 where name = %s", ref_invoice)
|
convert_into_recurring_invoice = 0 where name = %s", ref_invoice)
|
||||||
notify_errors(ref_invoice, ref_wrapper.doc.customer, ref_wrapper.doc.owner)
|
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:
|
finally:
|
||||||
if commit:
|
if commit:
|
||||||
webnotes.conn.begin()
|
frappe.conn.begin()
|
||||||
|
|
||||||
if exception_list:
|
if exception_list:
|
||||||
exception_message = "\n\n".join([cstr(d) for d in exception_list])
|
exception_message = "\n\n".join([cstr(d) for d in exception_list])
|
||||||
raise Exception, exception_message
|
raise Exception, exception_message
|
||||||
|
|
||||||
def make_new_invoice(ref_wrapper, posting_date):
|
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
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
new_invoice = clone(ref_wrapper)
|
new_invoice = clone(ref_wrapper)
|
||||||
|
|
||||||
@ -738,17 +738,17 @@ def make_new_invoice(ref_wrapper, posting_date):
|
|||||||
def send_notification(new_rv):
|
def send_notification(new_rv):
|
||||||
"""Notify concerned persons about recurring invoice generation"""
|
"""Notify concerned persons about recurring invoice generation"""
|
||||||
|
|
||||||
from webnotes.core.doctype.print_format.print_format import get_html
|
from frappe.core.doctype.print_format.print_format import get_html
|
||||||
webnotes.sendmail(new_rv.doc.notification_email_address,
|
frappe.sendmail(new_rv.doc.notification_email_address,
|
||||||
subject="New Invoice : " + new_rv.doc.name,
|
subject="New Invoice : " + new_rv.doc.name,
|
||||||
message = get_html(new_rv.doc, new_rv.doclist, "SalesInvoice"))
|
message = get_html(new_rv.doc, new_rv.doclist, "SalesInvoice"))
|
||||||
|
|
||||||
def notify_errors(inv, customer, owner):
|
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,
|
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,
|
"name": inv,
|
||||||
"customer": customer
|
"customer": customer
|
||||||
}))
|
}))
|
||||||
@ -757,7 +757,7 @@ def notify_errors(inv, customer, owner):
|
|||||||
|
|
||||||
def assign_task_to_owner(inv, msg, users):
|
def assign_task_to_owner(inv, msg, users):
|
||||||
for d in users:
|
for d in users:
|
||||||
from webnotes.widgets.form import assign_to
|
from frappe.widgets.form import assign_to
|
||||||
args = {
|
args = {
|
||||||
'assign_to' : d,
|
'assign_to' : d,
|
||||||
'doctype' : 'Sales Invoice',
|
'doctype' : 'Sales Invoice',
|
||||||
@ -767,23 +767,23 @@ def assign_task_to_owner(inv, msg, users):
|
|||||||
}
|
}
|
||||||
assign_to.add(args)
|
assign_to.add(args)
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@frappe.whitelist()
|
||||||
def get_bank_cash_account(mode_of_payment):
|
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:
|
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 {
|
return {
|
||||||
"cash_bank_account": val
|
"cash_bank_account": val
|
||||||
}
|
}
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@frappe.whitelist()
|
||||||
def get_income_account(doctype, txt, searchfield, start, page_len, filters):
|
def get_income_account(doctype, txt, searchfield, start, page_len, filters):
|
||||||
from erpnext.controllers.queries import get_match_cond
|
from erpnext.controllers.queries import get_match_cond
|
||||||
|
|
||||||
# income account can be any Credit account,
|
# income account can be any Credit account,
|
||||||
# but can also be a Asset account with account_type='Income Account' in special circumstances.
|
# but can also be a Asset account with account_type='Income Account' in special circumstances.
|
||||||
# Hence the first condition is an "OR"
|
# 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"
|
where (tabAccount.debit_or_credit="Credit"
|
||||||
or tabAccount.account_type = "Income Account")
|
or tabAccount.account_type = "Income Account")
|
||||||
and tabAccount.group_or_ledger="Ledger"
|
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)})
|
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield)})
|
||||||
|
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@frappe.whitelist()
|
||||||
def make_delivery_note(source_name, target_doclist=None):
|
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):
|
def set_missing_values(source, target):
|
||||||
bean = webnotes.bean(target)
|
bean = frappe.bean(target)
|
||||||
bean.run_method("onload_post_render")
|
bean.run_method("onload_post_render")
|
||||||
|
|
||||||
def update_item(source_doc, target_doc, source_parent):
|
def update_item(source_doc, target_doc, source_parent):
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
// render
|
// render
|
||||||
wn.listview_settings['Sales Invoice'] = {
|
frappe.listview_settings['Sales Invoice'] = {
|
||||||
add_fields: ["`tabSales Invoice`.grand_total", "`tabSales Invoice`.outstanding_amount"],
|
add_fields: ["`tabSales Invoice`.grand_total", "`tabSales Invoice`.outstanding_amount"],
|
||||||
add_columns: [{"content":"Percent Paid", width:"10%", type:"bar-graph",
|
add_columns: [{"content":"Percent Paid", width:"10%", type:"bar-graph",
|
||||||
label: "Payment Received"}],
|
label: "Payment Received"}],
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
wn.model.map_info["Sales Invoice"] = {
|
frappe.model.map_info["Sales Invoice"] = {
|
||||||
"Time Log Batch": {
|
"Time Log Batch": {
|
||||||
table_map: {
|
table_map: {
|
||||||
"Sales Invoice Item": "Time Log Batch",
|
"Sales Invoice Item": "Time Log Batch",
|
||||||
|
@ -1,38 +1,38 @@
|
|||||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
import webnotes
|
import frappe
|
||||||
import unittest, json
|
import unittest, json
|
||||||
from webnotes.utils import flt
|
from frappe.utils import flt
|
||||||
from webnotes.model.bean import DocstatusTransitionError, TimestampMismatchError
|
from frappe.model.bean import DocstatusTransitionError, TimestampMismatchError
|
||||||
from erpnext.accounts.utils import get_stock_and_account_difference
|
from erpnext.accounts.utils import get_stock_and_account_difference
|
||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
||||||
|
|
||||||
class TestSalesInvoice(unittest.TestCase):
|
class TestSalesInvoice(unittest.TestCase):
|
||||||
def make(self):
|
def make(self):
|
||||||
w = webnotes.bean(copy=test_records[0])
|
w = frappe.bean(copy=test_records[0])
|
||||||
w.doc.is_pos = 0
|
w.doc.is_pos = 0
|
||||||
w.insert()
|
w.insert()
|
||||||
w.submit()
|
w.submit()
|
||||||
return w
|
return w
|
||||||
|
|
||||||
def test_double_submission(self):
|
def test_double_submission(self):
|
||||||
w = webnotes.bean(copy=test_records[0])
|
w = frappe.bean(copy=test_records[0])
|
||||||
w.doc.docstatus = '0'
|
w.doc.docstatus = '0'
|
||||||
w.insert()
|
w.insert()
|
||||||
|
|
||||||
w2 = [d for d in w.doclist]
|
w2 = [d for d in w.doclist]
|
||||||
w.submit()
|
w.submit()
|
||||||
|
|
||||||
w = webnotes.bean(w2)
|
w = frappe.bean(w2)
|
||||||
self.assertRaises(DocstatusTransitionError, w.submit)
|
self.assertRaises(DocstatusTransitionError, w.submit)
|
||||||
|
|
||||||
def test_timestamp_change(self):
|
def test_timestamp_change(self):
|
||||||
w = webnotes.bean(copy=test_records[0])
|
w = frappe.bean(copy=test_records[0])
|
||||||
w.doc.docstatus = '0'
|
w.doc.docstatus = '0'
|
||||||
w.insert()
|
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
|
import time
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@ -43,7 +43,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self.assertRaises(TimestampMismatchError, w2.save)
|
self.assertRaises(TimestampMismatchError, w2.save)
|
||||||
|
|
||||||
def test_sales_invoice_calculation_base_currency(self):
|
def test_sales_invoice_calculation_base_currency(self):
|
||||||
si = webnotes.bean(copy=test_records[2])
|
si = frappe.bean(copy=test_records[2])
|
||||||
si.insert()
|
si.insert()
|
||||||
|
|
||||||
expected_values = {
|
expected_values = {
|
||||||
@ -87,7 +87,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self.assertEquals(si.doc.grand_total_export, 1627.05)
|
self.assertEquals(si.doc.grand_total_export, 1627.05)
|
||||||
|
|
||||||
def test_sales_invoice_calculation_export_currency(self):
|
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.currency = "USD"
|
||||||
si.doc.conversion_rate = 50
|
si.doc.conversion_rate = 50
|
||||||
si.doclist[1].rate = 1
|
si.doclist[1].rate = 1
|
||||||
@ -137,7 +137,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self.assertEquals(si.doc.grand_total_export, 32.54)
|
self.assertEquals(si.doc.grand_total_export, 32.54)
|
||||||
|
|
||||||
def test_sales_invoice_discount_amount(self):
|
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.doc.discount_amount = 104.95
|
||||||
si.doclist.append({
|
si.doclist.append({
|
||||||
"doctype": "Sales Taxes and Charges",
|
"doctype": "Sales Taxes and Charges",
|
||||||
@ -194,7 +194,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self.assertEquals(si.doc.grand_total_export, 1500)
|
self.assertEquals(si.doc.grand_total_export, 1500)
|
||||||
|
|
||||||
def test_discount_amount_gl_entry(self):
|
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.doc.discount_amount = 104.95
|
||||||
si.doclist.append({
|
si.doclist.append({
|
||||||
"doctype": "Sales Taxes and Charges",
|
"doctype": "Sales Taxes and Charges",
|
||||||
@ -210,7 +210,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
si.insert()
|
si.insert()
|
||||||
si.submit()
|
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
|
from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
|
||||||
order by account asc""", si.doc.name, as_dict=1)
|
order by account asc""", si.doc.name, as_dict=1)
|
||||||
|
|
||||||
@ -238,13 +238,13 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
# cancel
|
# cancel
|
||||||
si.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)
|
where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name)
|
||||||
|
|
||||||
self.assertFalse(gle)
|
self.assertFalse(gle)
|
||||||
|
|
||||||
def test_inclusive_rate_validations(self):
|
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"})):
|
for i, tax in enumerate(si.doclist.get({"parentfield": "other_charges"})):
|
||||||
tax.idx = i+1
|
tax.idx = i+1
|
||||||
|
|
||||||
@ -254,15 +254,15 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
si.doclist[i].included_in_print_rate = 1
|
si.doclist[i].included_in_print_rate = 1
|
||||||
|
|
||||||
# tax type "Actual" cannot be inclusive
|
# 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
|
# taxes above included type 'On Previous Row Total' should also be included
|
||||||
si.doclist[3].included_in_print_rate = 0
|
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):
|
def test_sales_invoice_calculation_base_currency_with_tax_inclusive_price(self):
|
||||||
# prepare
|
# prepare
|
||||||
si = webnotes.bean(copy=test_records[3])
|
si = frappe.bean(copy=test_records[3])
|
||||||
si.insert()
|
si.insert()
|
||||||
|
|
||||||
expected_values = {
|
expected_values = {
|
||||||
@ -307,7 +307,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
def test_sales_invoice_calculation_export_currency_with_tax_inclusive_price(self):
|
def test_sales_invoice_calculation_export_currency_with_tax_inclusive_price(self):
|
||||||
# prepare
|
# prepare
|
||||||
si = webnotes.bean(copy=test_records[3])
|
si = frappe.bean(copy=test_records[3])
|
||||||
si.doc.currency = "USD"
|
si.doc.currency = "USD"
|
||||||
si.doc.conversion_rate = 50
|
si.doc.conversion_rate = 50
|
||||||
si.doclist[1].price_list_rate = 55.56
|
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)
|
self.assertEquals(w.doc.outstanding_amount, w.doc.grand_total)
|
||||||
|
|
||||||
def test_payment(self):
|
def test_payment(self):
|
||||||
webnotes.conn.sql("""delete from `tabGL Entry`""")
|
frappe.conn.sql("""delete from `tabGL Entry`""")
|
||||||
w = self.make()
|
w = self.make()
|
||||||
|
|
||||||
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
|
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
|
||||||
import test_records as jv_test_records
|
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.doclist[1].against_invoice = w.doc.name
|
||||||
jv.insert()
|
jv.insert()
|
||||||
jv.submit()
|
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)
|
161.8)
|
||||||
|
|
||||||
jv.cancel()
|
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)
|
561.8)
|
||||||
|
|
||||||
def test_time_log_batch(self):
|
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()
|
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.doclist[1].time_log_batch = "_T-Time Log Batch-00001"
|
||||||
si.insert()
|
si.insert()
|
||||||
si.submit()
|
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")
|
"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")
|
"Billed")
|
||||||
|
|
||||||
si.cancel()
|
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")
|
"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")
|
"Batched for Billing")
|
||||||
|
|
||||||
def test_sales_invoice_gl_entry_without_aii(self):
|
def test_sales_invoice_gl_entry_without_aii(self):
|
||||||
self.clear_stock_account_balance()
|
self.clear_stock_account_balance()
|
||||||
set_perpetual_inventory(0)
|
set_perpetual_inventory(0)
|
||||||
si = webnotes.bean(copy=test_records[1])
|
si = frappe.bean(copy=test_records[1])
|
||||||
si.insert()
|
si.insert()
|
||||||
si.submit()
|
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
|
from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
|
||||||
order by account asc""", si.doc.name, as_dict=1)
|
order by account asc""", si.doc.name, as_dict=1)
|
||||||
|
|
||||||
@ -432,7 +432,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
# cancel
|
# cancel
|
||||||
si.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)
|
where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name)
|
||||||
|
|
||||||
self.assertFalse(gle)
|
self.assertFalse(gle)
|
||||||
@ -444,19 +444,19 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self._insert_purchase_receipt()
|
self._insert_purchase_receipt()
|
||||||
self._insert_pos_settings()
|
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]["is_pos"] = 1
|
||||||
pos[0]["update_stock"] = 1
|
pos[0]["update_stock"] = 1
|
||||||
pos[0]["posting_time"] = "12:05"
|
pos[0]["posting_time"] = "12:05"
|
||||||
pos[0]["cash_bank_account"] = "_Test Account Bank Account - _TC"
|
pos[0]["cash_bank_account"] = "_Test Account Bank Account - _TC"
|
||||||
pos[0]["paid_amount"] = 600.0
|
pos[0]["paid_amount"] = 600.0
|
||||||
|
|
||||||
si = webnotes.bean(copy=pos)
|
si = frappe.bean(copy=pos)
|
||||||
si.insert()
|
si.insert()
|
||||||
si.submit()
|
si.submit()
|
||||||
|
|
||||||
# check stock ledger entries
|
# 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""",
|
where voucher_type = 'Sales Invoice' and voucher_no = %s""",
|
||||||
si.doc.name, as_dict=1)[0]
|
si.doc.name, as_dict=1)[0]
|
||||||
self.assertTrue(sle)
|
self.assertTrue(sle)
|
||||||
@ -464,12 +464,12 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
["_Test Item", "_Test Warehouse - _TC", -1.0])
|
["_Test Item", "_Test Warehouse - _TC", -1.0])
|
||||||
|
|
||||||
# check gl entries
|
# 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
|
from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
|
||||||
order by account asc, debit asc""", si.doc.name, as_dict=1)
|
order by account asc, debit asc""", si.doc.name, as_dict=1)
|
||||||
self.assertTrue(gl_entries)
|
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([
|
expected_gl_entries = sorted([
|
||||||
[si.doc.debit_to, 630.0, 0.0],
|
[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)
|
self.assertEquals(expected_gl_entries[i][2], gle.credit)
|
||||||
|
|
||||||
si.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)
|
where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name)
|
||||||
|
|
||||||
self.assertFalse(gle)
|
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):
|
def test_si_gl_entry_with_aii_and_update_stock_with_warehouse_but_no_account(self):
|
||||||
self.clear_stock_account_balance()
|
self.clear_stock_account_balance()
|
||||||
set_perpetual_inventory()
|
set_perpetual_inventory()
|
||||||
webnotes.delete_doc("Account", "_Test Warehouse No Account - _TC")
|
frappe.delete_doc("Account", "_Test Warehouse No Account - _TC")
|
||||||
|
|
||||||
# insert purchase receipt
|
# insert purchase receipt
|
||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
|
||||||
as pr_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.doc.naming_series = "_T-Purchase Receipt-"
|
||||||
pr.doclist[1].warehouse = "_Test Warehouse No Account - _TC"
|
pr.doclist[1].warehouse = "_Test Warehouse No Account - _TC"
|
||||||
pr.insert()
|
pr.insert()
|
||||||
pr.submit()
|
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]["update_stock"] = 1
|
||||||
si_doclist[0]["posting_time"] = "12:05"
|
si_doclist[0]["posting_time"] = "12:05"
|
||||||
si_doclist[1]["warehouse"] = "_Test Warehouse No Account - _TC"
|
si_doclist[1]["warehouse"] = "_Test Warehouse No Account - _TC"
|
||||||
|
|
||||||
si = webnotes.bean(copy=si_doclist)
|
si = frappe.bean(copy=si_doclist)
|
||||||
si.insert()
|
si.insert()
|
||||||
si.submit()
|
si.submit()
|
||||||
|
|
||||||
# check stock ledger entries
|
# 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""",
|
where voucher_type = 'Sales Invoice' and voucher_no = %s""",
|
||||||
si.doc.name, as_dict=1)[0]
|
si.doc.name, as_dict=1)[0]
|
||||||
self.assertTrue(sle)
|
self.assertTrue(sle)
|
||||||
@ -528,7 +528,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
["_Test Item", "_Test Warehouse No Account - _TC", -1.0])
|
["_Test Item", "_Test Warehouse No Account - _TC", -1.0])
|
||||||
|
|
||||||
# check gl entries
|
# 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
|
from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
|
||||||
order by account asc, debit asc""", si.doc.name, as_dict=1)
|
order by account asc, debit asc""", si.doc.name, as_dict=1)
|
||||||
self.assertTrue(gl_entries)
|
self.assertTrue(gl_entries)
|
||||||
@ -545,7 +545,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self.assertEquals(expected_gl_entries[i][2], gle.credit)
|
self.assertEquals(expected_gl_entries[i][2], gle.credit)
|
||||||
|
|
||||||
si.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)
|
where voucher_type='Sales Invoice' and voucher_no=%s""", si.doc.name)
|
||||||
|
|
||||||
self.assertFalse(gle)
|
self.assertFalse(gle)
|
||||||
@ -555,13 +555,13 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self.clear_stock_account_balance()
|
self.clear_stock_account_balance()
|
||||||
set_perpetual_inventory()
|
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_copy[1]["item_code"] = None
|
||||||
si = webnotes.bean(si_copy)
|
si = frappe.bean(si_copy)
|
||||||
si.insert()
|
si.insert()
|
||||||
si.submit()
|
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
|
from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
|
||||||
order by account asc""", si.doc.name, as_dict=1)
|
order by account asc""", si.doc.name, as_dict=1)
|
||||||
self.assertTrue(gl_entries)
|
self.assertTrue(gl_entries)
|
||||||
@ -582,13 +582,13 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
def test_sales_invoice_gl_entry_with_aii_non_stock_item(self):
|
def test_sales_invoice_gl_entry_with_aii_non_stock_item(self):
|
||||||
self.clear_stock_account_balance()
|
self.clear_stock_account_balance()
|
||||||
set_perpetual_inventory()
|
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_copy[1]["item_code"] = "_Test Non Stock Item"
|
||||||
si = webnotes.bean(si_copy)
|
si = frappe.bean(si_copy)
|
||||||
si.insert()
|
si.insert()
|
||||||
si.submit()
|
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
|
from `tabGL Entry` where voucher_type='Sales Invoice' and voucher_no=%s
|
||||||
order by account asc""", si.doc.name, as_dict=1)
|
order by account asc""", si.doc.name, as_dict=1)
|
||||||
self.assertTrue(gl_entries)
|
self.assertTrue(gl_entries)
|
||||||
@ -609,7 +609,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
def _insert_purchase_receipt(self):
|
def _insert_purchase_receipt(self):
|
||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
|
||||||
as pr_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.doc.naming_series = "_T-Purchase Receipt-"
|
||||||
pr.insert()
|
pr.insert()
|
||||||
pr.submit()
|
pr.submit()
|
||||||
@ -617,7 +617,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
def _insert_delivery_note(self):
|
def _insert_delivery_note(self):
|
||||||
from erpnext.stock.doctype.delivery_note.test_delivery_note import test_records \
|
from erpnext.stock.doctype.delivery_note.test_delivery_note import test_records \
|
||||||
as dn_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.doc.naming_series = "_T-Delivery Note-"
|
||||||
dn.insert()
|
dn.insert()
|
||||||
dn.submit()
|
dn.submit()
|
||||||
@ -626,20 +626,20 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
def _insert_pos_settings(self):
|
def _insert_pos_settings(self):
|
||||||
from erpnext.accounts.doctype.pos_setting.test_pos_setting \
|
from erpnext.accounts.doctype.pos_setting.test_pos_setting \
|
||||||
import test_records as pos_setting_test_records
|
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()
|
ps.insert()
|
||||||
|
|
||||||
def test_sales_invoice_with_advance(self):
|
def test_sales_invoice_with_advance(self):
|
||||||
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
|
from erpnext.accounts.doctype.journal_voucher.test_journal_voucher \
|
||||||
import test_records as jv_test_records
|
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.insert()
|
||||||
jv.submit()
|
jv.submit()
|
||||||
|
|
||||||
si = webnotes.bean(copy=test_records[0])
|
si = frappe.bean(copy=test_records[0])
|
||||||
si.doclist.append({
|
si.doclist.append({
|
||||||
"doctype": "Sales Invoice Advance",
|
"doctype": "Sales Invoice Advance",
|
||||||
"parentfield": "advance_adjustment_details",
|
"parentfield": "advance_adjustment_details",
|
||||||
@ -653,24 +653,24 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
si.submit()
|
si.submit()
|
||||||
si.load_from_db()
|
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))
|
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))
|
where against_invoice=%s and credit=300""", si.doc.name))
|
||||||
|
|
||||||
self.assertEqual(si.doc.outstanding_amount, 261.8)
|
self.assertEqual(si.doc.outstanding_amount, 261.8)
|
||||||
|
|
||||||
si.cancel()
|
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))
|
where against_invoice=%s""", si.doc.name))
|
||||||
|
|
||||||
def test_recurring_invoice(self):
|
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
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
today = nowdate()
|
today = nowdate()
|
||||||
base_si = webnotes.bean(copy=test_records[0])
|
base_si = frappe.bean(copy=test_records[0])
|
||||||
base_si.doc.fields.update({
|
base_si.doc.fields.update({
|
||||||
"convert_into_recurring_invoice": 1,
|
"convert_into_recurring_invoice": 1,
|
||||||
"recurring_type": "Monthly",
|
"recurring_type": "Monthly",
|
||||||
@ -683,13 +683,13 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
})
|
})
|
||||||
|
|
||||||
# monthly
|
# monthly
|
||||||
si1 = webnotes.bean(copy=base_si.doclist)
|
si1 = frappe.bean(copy=base_si.doclist)
|
||||||
si1.insert()
|
si1.insert()
|
||||||
si1.submit()
|
si1.submit()
|
||||||
self._test_recurring_invoice(si1, True)
|
self._test_recurring_invoice(si1, True)
|
||||||
|
|
||||||
# monthly without a first and last day period
|
# 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({
|
si2.doc.fields.update({
|
||||||
"invoice_period_from_date": today,
|
"invoice_period_from_date": today,
|
||||||
"invoice_period_to_date": add_to_date(today, days=30)
|
"invoice_period_to_date": add_to_date(today, days=30)
|
||||||
@ -699,7 +699,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self._test_recurring_invoice(si2, False)
|
self._test_recurring_invoice(si2, False)
|
||||||
|
|
||||||
# quarterly
|
# quarterly
|
||||||
si3 = webnotes.bean(copy=base_si.doclist)
|
si3 = frappe.bean(copy=base_si.doclist)
|
||||||
si3.doc.fields.update({
|
si3.doc.fields.update({
|
||||||
"recurring_type": "Quarterly",
|
"recurring_type": "Quarterly",
|
||||||
"invoice_period_from_date": get_first_day(today),
|
"invoice_period_from_date": get_first_day(today),
|
||||||
@ -710,7 +710,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self._test_recurring_invoice(si3, True)
|
self._test_recurring_invoice(si3, True)
|
||||||
|
|
||||||
# quarterly without a first and last day period
|
# 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({
|
si4.doc.fields.update({
|
||||||
"recurring_type": "Quarterly",
|
"recurring_type": "Quarterly",
|
||||||
"invoice_period_from_date": today,
|
"invoice_period_from_date": today,
|
||||||
@ -721,7 +721,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self._test_recurring_invoice(si4, False)
|
self._test_recurring_invoice(si4, False)
|
||||||
|
|
||||||
# yearly
|
# yearly
|
||||||
si5 = webnotes.bean(copy=base_si.doclist)
|
si5 = frappe.bean(copy=base_si.doclist)
|
||||||
si5.doc.fields.update({
|
si5.doc.fields.update({
|
||||||
"recurring_type": "Yearly",
|
"recurring_type": "Yearly",
|
||||||
"invoice_period_from_date": get_first_day(today),
|
"invoice_period_from_date": get_first_day(today),
|
||||||
@ -732,7 +732,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self._test_recurring_invoice(si5, True)
|
self._test_recurring_invoice(si5, True)
|
||||||
|
|
||||||
# yearly without a first and last day period
|
# 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({
|
si6.doc.fields.update({
|
||||||
"recurring_type": "Yearly",
|
"recurring_type": "Yearly",
|
||||||
"invoice_period_from_date": today,
|
"invoice_period_from_date": today,
|
||||||
@ -743,7 +743,7 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self._test_recurring_invoice(si6, False)
|
self._test_recurring_invoice(si6, False)
|
||||||
|
|
||||||
# change posting date but keep recuring day to be today
|
# 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({
|
si7.doc.fields.update({
|
||||||
"posting_date": add_to_date(today, days=-1)
|
"posting_date": add_to_date(today, days=-1)
|
||||||
})
|
})
|
||||||
@ -755,14 +755,14 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
self._test_recurring_invoice(si7, True)
|
self._test_recurring_invoice(si7, True)
|
||||||
|
|
||||||
def _test_recurring_invoice(self, base_si, first_and_last_day):
|
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 \
|
from erpnext.accounts.doctype.sales_invoice.sales_invoice \
|
||||||
import manage_recurring_invoices, get_next_date
|
import manage_recurring_invoices, get_next_date
|
||||||
|
|
||||||
no_of_months = ({"Monthly": 1, "Quarterly": 3, "Yearly": 12})[base_si.doc.recurring_type]
|
no_of_months = ({"Monthly": 1, "Quarterly": 3, "Yearly": 12})[base_si.doc.recurring_type]
|
||||||
|
|
||||||
def _test(i):
|
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])
|
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,
|
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)
|
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""",
|
where recurring_id=%s and docstatus=1 order by name desc""",
|
||||||
base_si.doc.recurring_id)
|
base_si.doc.recurring_id)
|
||||||
|
|
||||||
self.assertEquals(i+2, len(recurred_invoices))
|
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",
|
for fieldname in ["convert_into_recurring_invoice", "recurring_type",
|
||||||
"repeat_on_day_of_month", "notification_email_address"]:
|
"repeat_on_day_of_month", "notification_email_address"]:
|
||||||
@ -805,9 +805,9 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
base_si = _test(i)
|
base_si = _test(i)
|
||||||
|
|
||||||
def clear_stock_account_balance(self):
|
def clear_stock_account_balance(self):
|
||||||
webnotes.conn.sql("delete from `tabStock Ledger Entry`")
|
frappe.conn.sql("delete from `tabStock Ledger Entry`")
|
||||||
webnotes.conn.sql("delete from tabBin")
|
frappe.conn.sql("delete from tabBin")
|
||||||
webnotes.conn.sql("delete from `tabGL Entry`")
|
frappe.conn.sql("delete from `tabGL Entry`")
|
||||||
|
|
||||||
def test_serialized(self):
|
def test_serialized(self):
|
||||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
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()
|
se = make_serialized_item()
|
||||||
serial_nos = get_serial_nos(se.doclist[1].serial_no)
|
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.doc.update_stock = 1
|
||||||
si.doclist[1].item_code = "_Test Serialized Item With Series"
|
si.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||||
si.doclist[1].qty = 1
|
si.doclist[1].qty = 1
|
||||||
@ -824,9 +824,9 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
si.insert()
|
si.insert()
|
||||||
si.submit()
|
si.submit()
|
||||||
|
|
||||||
self.assertEquals(webnotes.conn.get_value("Serial No", serial_nos[0], "status"), "Delivered")
|
self.assertEquals(frappe.conn.get_value("Serial No", serial_nos[0], "status"), "Delivered")
|
||||||
self.assertFalse(webnotes.conn.get_value("Serial No", serial_nos[0], "warehouse"))
|
self.assertFalse(frappe.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],
|
||||||
"delivery_document_no"), si.doc.name)
|
"delivery_document_no"), si.doc.name)
|
||||||
|
|
||||||
return si
|
return si
|
||||||
@ -838,9 +838,9 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
|
|
||||||
serial_nos = get_serial_nos(si.doclist[1].serial_no)
|
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(frappe.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.assertEquals(frappe.conn.get_value("Serial No", serial_nos[0], "warehouse"), "_Test Warehouse - _TC")
|
||||||
self.assertFalse(webnotes.conn.get_value("Serial No", serial_nos[0],
|
self.assertFalse(frappe.conn.get_value("Serial No", serial_nos[0],
|
||||||
"delivery_document_no"))
|
"delivery_document_no"))
|
||||||
|
|
||||||
def test_serialize_status(self):
|
def test_serialize_status(self):
|
||||||
@ -850,11 +850,11 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
se = make_serialized_item()
|
se = make_serialized_item()
|
||||||
serial_nos = get_serial_nos(se.doclist[1].serial_no)
|
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.doc.status = "Not Available"
|
||||||
sr.save()
|
sr.save()
|
||||||
|
|
||||||
si = webnotes.bean(copy=test_records[0])
|
si = frappe.bean(copy=test_records[0])
|
||||||
si.doc.update_stock = 1
|
si.doc.update_stock = 1
|
||||||
si.doclist[1].item_code = "_Test Serialized Item With Series"
|
si.doclist[1].item_code = "_Test Serialized Item With Series"
|
||||||
si.doclist[1].qty = 1
|
si.doclist[1].qty = 1
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
|
@ -9,7 +9,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.refresh = 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
|
// For customizing print
|
||||||
@ -48,7 +48,7 @@ cur_frm.pformat.other_charges= function(doc){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function print_hide(fieldname) {
|
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;
|
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) {
|
cur_frm.cscript.charge_type = function(doc, cdt, cdn) {
|
||||||
var d = locals[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')) {
|
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 = '';
|
d.charge_type = '';
|
||||||
}
|
}
|
||||||
validated = false;
|
validated = false;
|
||||||
@ -113,16 +113,16 @@ cur_frm.cscript.charge_type = function(doc, cdt, cdn) {
|
|||||||
cur_frm.cscript.row_id = function(doc, cdt, cdn) {
|
cur_frm.cscript.row_id = function(doc, cdt, cdn) {
|
||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
if(!d.charge_type && d.row_id) {
|
if(!d.charge_type && d.row_id) {
|
||||||
msgprint(wn._("Please select Charge Type first"));
|
msgprint(frappe._("Please select Charge Type first"));
|
||||||
d.row_id = '';
|
d.row_id = '';
|
||||||
}
|
}
|
||||||
else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && 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 = '';
|
d.row_id = '';
|
||||||
}
|
}
|
||||||
else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On 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){
|
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 = '';
|
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) {
|
cur_frm.cscript.rate = function(doc, cdt, cdn) {
|
||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
if(!d.charge_type && d.rate) {
|
if(!d.charge_type && d.rate) {
|
||||||
msgprint(wn._("Please select Charge Type first"));
|
msgprint(frappe._("Please select Charge Type first"));
|
||||||
d.rate = '';
|
d.rate = '';
|
||||||
}
|
}
|
||||||
validated = false;
|
validated = false;
|
||||||
@ -163,11 +163,11 @@ cur_frm.cscript.rate = function(doc, cdt, cdn) {
|
|||||||
cur_frm.cscript.tax_amount = function(doc, cdt, cdn) {
|
cur_frm.cscript.tax_amount = function(doc, cdt, cdn) {
|
||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
if(!d.charge_type && d.tax_amount) {
|
if(!d.charge_type && d.tax_amount) {
|
||||||
msgprint(wn._("Please select Charge Type first"));
|
msgprint(frappe._("Please select Charge Type first"));
|
||||||
d.tax_amount = '';
|
d.tax_amount = '';
|
||||||
}
|
}
|
||||||
else if(d.charge_type && 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 = '';
|
d.tax_amount = '';
|
||||||
}
|
}
|
||||||
validated = false;
|
validated = false;
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes.utils import cint
|
from frappe.utils import cint
|
||||||
from webnotes.model.controller import DocListController
|
from frappe.model.controller import DocListController
|
||||||
|
|
||||||
class DocType(DocListController):
|
class DocType(DocListController):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
if self.doc.is_default == 1:
|
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""",
|
where ifnull(is_default,0) = 1 and name != %s and company = %s""",
|
||||||
(self.doc.name, self.doc.company))
|
(self.doc.name, self.doc.company))
|
||||||
|
|
||||||
|
@ -4,15 +4,15 @@
|
|||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes import _, msgprint
|
from frappe import _, msgprint
|
||||||
from webnotes.utils import flt, fmt_money
|
from frappe.utils import flt, fmt_money
|
||||||
from webnotes.model.controller import DocListController
|
from frappe.model.controller import DocListController
|
||||||
from erpnext.setup.utils import get_company_currency
|
from erpnext.setup.utils import get_company_currency
|
||||||
|
|
||||||
class OverlappingConditionError(webnotes.ValidationError): pass
|
class OverlappingConditionError(frappe.ValidationError): pass
|
||||||
class FromGreaterThanToError(webnotes.ValidationError): pass
|
class FromGreaterThanToError(frappe.ValidationError): pass
|
||||||
class ManyBlankToValuesError(webnotes.ValidationError): pass
|
class ManyBlankToValuesError(frappe.ValidationError): pass
|
||||||
|
|
||||||
class DocType(DocListController):
|
class DocType(DocListController):
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
import webnotes
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
from erpnext.accounts.doctype.shipping_rule.shipping_rule import FromGreaterThanToError, ManyBlankToValuesError, OverlappingConditionError
|
from erpnext.accounts.doctype.shipping_rule.shipping_rule import FromGreaterThanToError, ManyBlankToValuesError, OverlappingConditionError
|
||||||
|
|
||||||
class TestShippingRule(unittest.TestCase):
|
class TestShippingRule(unittest.TestCase):
|
||||||
def test_from_greater_than_to(self):
|
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
|
shipping_rule.doclist[1].from_value = 101
|
||||||
self.assertRaises(FromGreaterThanToError, shipping_rule.insert)
|
self.assertRaises(FromGreaterThanToError, shipping_rule.insert)
|
||||||
|
|
||||||
def test_many_zero_to_values(self):
|
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
|
shipping_rule.doclist[1].to_value = 0
|
||||||
self.assertRaises(ManyBlankToValuesError, shipping_rule.insert)
|
self.assertRaises(ManyBlankToValuesError, shipping_rule.insert)
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ class TestShippingRule(unittest.TestCase):
|
|||||||
((50, 150), (25, 175)),
|
((50, 150), (25, 175)),
|
||||||
((50, 150), (50, 150)),
|
((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].from_value = range_a[0]
|
||||||
shipping_rule.doclist[1].to_value = range_a[1]
|
shipping_rule.doclist[1].to_value = range_a[1]
|
||||||
shipping_rule.doclist[2].from_value = range_b[0]
|
shipping_rule.doclist[2].from_value = range_b[0]
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes.utils import flt, cstr
|
from frappe.utils import flt, cstr
|
||||||
from webnotes import _
|
from frappe import _
|
||||||
from erpnext.accounts.utils import validate_expense_against_budget
|
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,
|
def make_gl_entries(gl_map, cancel=False, adv_adj=False, merge_entries=True,
|
||||||
update_outstanding='Yes'):
|
update_outstanding='Yes'):
|
||||||
@ -77,7 +77,7 @@ def save_entries(gl_map, adv_adj, update_outstanding):
|
|||||||
|
|
||||||
def make_entry(args, adv_adj, update_outstanding):
|
def make_entry(args, adv_adj, update_outstanding):
|
||||||
args.update({"doctype": "GL Entry"})
|
args.update({"doctype": "GL Entry"})
|
||||||
gle = webnotes.bean([args])
|
gle = frappe.bean([args])
|
||||||
gle.ignore_permissions = 1
|
gle.ignore_permissions = 1
|
||||||
gle.insert()
|
gle.insert()
|
||||||
gle.run_method("on_update_with_args", adv_adj, update_outstanding)
|
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):
|
def validate_total_debit_credit(total_debit, total_credit):
|
||||||
if abs(total_debit - total_credit) > 0.005:
|
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))
|
cstr(total_debit - total_credit))
|
||||||
|
|
||||||
def validate_account_for_auto_accounting_for_stock(gl_map):
|
def validate_account_for_auto_accounting_for_stock(gl_map):
|
||||||
if gl_map[0].voucher_type=="Journal Voucher":
|
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, '')!=''""")]
|
where account_type = 'Warehouse' and ifnull(master_name, '')!=''""")]
|
||||||
|
|
||||||
for entry in gl_map:
|
for entry in gl_map:
|
||||||
if entry.account in aii_accounts:
|
if entry.account in aii_accounts:
|
||||||
webnotes.throw(_("Account") + ": " + entry.account +
|
frappe.throw(_("Account") + ": " + entry.account +
|
||||||
_(" can only be debited/credited through Stock transactions"),
|
_(" can only be debited/credited through Stock transactions"),
|
||||||
StockAccountInvalidTransaction)
|
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
|
check_freezing_date, update_outstanding_amt, validate_frozen_account
|
||||||
|
|
||||||
if not gl_entries:
|
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)
|
where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no), as_dict=True)
|
||||||
if gl_entries:
|
if gl_entries:
|
||||||
check_freezing_date(gl_entries[0]["posting_date"], adv_adj)
|
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"]))
|
(voucher_type or gl_entries[0]["voucher_type"], voucher_no or gl_entries[0]["voucher_no"]))
|
||||||
|
|
||||||
for entry in gl_entries:
|
for entry in gl_entries:
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
// see ledger
|
// see ledger
|
||||||
|
|
||||||
pscript['onload_Accounts Browser'] = function(wrapper){
|
pscript['onload_Accounts Browser'] = function(wrapper){
|
||||||
wn.ui.make_app_page({
|
frappe.ui.make_app_page({
|
||||||
parent: wrapper,
|
parent: wrapper,
|
||||||
single_column: true
|
single_column: true
|
||||||
})
|
})
|
||||||
@ -20,30 +20,30 @@ pscript['onload_Accounts Browser'] = function(wrapper){
|
|||||||
.css({"margin-bottom": "15px", "min-height": "200px"})
|
.css({"margin-bottom": "15px", "min-height": "200px"})
|
||||||
.appendTo(main),
|
.appendTo(main),
|
||||||
help_area = $('<div class="well">'+
|
help_area = $('<div class="well">'+
|
||||||
'<h4>'+wn._('Quick Help')+'</h4>'+
|
'<h4>'+frappe._('Quick Help')+'</h4>'+
|
||||||
'<ol>'+
|
'<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>'+
|
'<li>'+
|
||||||
wn._('Accounting Entries can be made against leaf nodes, called')+
|
frappe._('Accounting Entries can be made against leaf nodes, called')+
|
||||||
'<b>' +wn._('Ledgers')+'</b>.'+ wn._('Entries against') +
|
'<b>' +frappe._('Ledgers')+'</b>.'+ frappe._('Entries against') +
|
||||||
'<b>' +wn._('Groups') + '</b>'+ wn._('are not allowed.')+
|
'<b>' +frappe._('Groups') + '</b>'+ frappe._('are not allowed.')+
|
||||||
'</li>'+
|
'</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>'+
|
'<li>'+
|
||||||
'<b>'+wn._('To create a Bank Account:')+'</b>'+
|
'<b>'+frappe._('To create a Bank Account:')+'</b>'+
|
||||||
wn._('Go to the appropriate group (usually Application of Funds > Current Assets > Bank Accounts)')+
|
frappe._('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"')+
|
frappe._('and create a new Account Ledger (by clicking on Add Child) of type "Bank or Cash"')+
|
||||||
'</li>'+
|
'</li>'+
|
||||||
'<li>'+
|
'<li>'+
|
||||||
'<b>'+wn._('To create a Tax Account:')+'</b>'+
|
'<b>'+frappe._('To create a Tax Account:')+'</b>'+
|
||||||
wn._('Go to the appropriate group (usually Source of Funds > Current Liabilities > Taxes and Duties)')+
|
frappe._('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.')+
|
frappe._('and create a new Account Ledger (by clicking on Add Child) of type "Tax" and do mention the Tax rate.')+
|
||||||
'</li>'+
|
'</li>'+
|
||||||
'</ol>'+
|
'</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) {
|
if (frappe.boot.profile.can_create.indexOf("Company") !== -1) {
|
||||||
wrapper.appframe.add_button(wn._('New Company'), function() { newdoc('Company'); },
|
wrapper.appframe.add_button(frappe._('New Company'), function() { newdoc('Company'); },
|
||||||
'icon-plus');
|
'icon-plus');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,21 +54,21 @@ pscript['onload_Accounts Browser'] = function(wrapper){
|
|||||||
// company-select
|
// company-select
|
||||||
wrapper.$company_select = wrapper.appframe.add_select("Company", [])
|
wrapper.$company_select = wrapper.appframe.add_select("Company", [])
|
||||||
.change(function() {
|
.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(),
|
erpnext.account_chart = new erpnext.AccountsChart(ctype, $(this).val(),
|
||||||
chart_area.get(0));
|
chart_area.get(0));
|
||||||
pscript.set_title(wrapper, ctype, $(this).val());
|
pscript.set_title(wrapper, ctype, $(this).val());
|
||||||
})
|
})
|
||||||
|
|
||||||
// load up companies
|
// load up companies
|
||||||
return wn.call({
|
return frappe.call({
|
||||||
method: 'erpnext.accounts.page.accounts_browser.accounts_browser.get_companies',
|
method: 'erpnext.accounts.page.accounts_browser.accounts_browser.get_companies',
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
wrapper.$company_select.empty();
|
wrapper.$company_select.empty();
|
||||||
$.each(r.message, function(i, v) {
|
$.each(r.message, function(i, v) {
|
||||||
$('<option>').html(v).attr('value', v).appendTo(wrapper.$company_select);
|
$('<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){
|
pscript['onshow_Accounts Browser'] = function(wrapper){
|
||||||
// set route
|
// 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) {
|
if(erpnext.account_chart && erpnext.account_chart.ctype != ctype) {
|
||||||
wrapper.$company_select.change();
|
wrapper.$company_select.change();
|
||||||
@ -97,13 +97,13 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
$(wrapper).empty();
|
$(wrapper).empty();
|
||||||
var me = this;
|
var me = this;
|
||||||
me.ctype = ctype;
|
me.ctype = ctype;
|
||||||
me.can_create = wn.model.can_create(this.ctype);
|
me.can_create = frappe.model.can_create(this.ctype);
|
||||||
me.can_delete = wn.model.can_delete(this.ctype);
|
me.can_delete = frappe.model.can_delete(this.ctype);
|
||||||
me.can_write = wn.model.can_write(this.ctype);
|
me.can_write = frappe.model.can_write(this.ctype);
|
||||||
|
|
||||||
|
|
||||||
me.company = company;
|
me.company = company;
|
||||||
this.tree = new wn.ui.Tree({
|
this.tree = new frappe.ui.Tree({
|
||||||
parent: $(wrapper),
|
parent: $(wrapper),
|
||||||
label: ctype==="Account" ? "Accounts" : "Cost Centers",
|
label: ctype==="Account" ? "Accounts" : "Cost Centers",
|
||||||
args: {ctype: ctype, comp: company},
|
args: {ctype: ctype, comp: company},
|
||||||
@ -145,49 +145,49 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
|
|
||||||
var node_links = [];
|
var node_links = [];
|
||||||
// edit
|
// edit
|
||||||
if (wn.model.can_read(this.ctype) !== -1) {
|
if (frappe.model.can_read(this.ctype) !== -1) {
|
||||||
node_links.push('<a onclick="erpnext.account_chart.open();">'+wn._('Edit')+'</a>');
|
node_links.push('<a onclick="erpnext.account_chart.open();">'+frappe._('Edit')+'</a>');
|
||||||
}
|
}
|
||||||
if (data.expandable && wn.boot.profile.in_create.indexOf(this.ctype) !== -1) {
|
if (data.expandable && frappe.boot.profile.in_create.indexOf(this.ctype) !== -1) {
|
||||||
node_links.push('<a onclick="erpnext.account_chart.new_node();">'+wn._('Add Child')+'</a>');
|
node_links.push('<a onclick="erpnext.account_chart.new_node();">'+frappe._('Add Child')+'</a>');
|
||||||
} else if (this.ctype === 'Account' && wn.boot.profile.can_read.indexOf("GL Entry") !== -1) {
|
} else if (this.ctype === 'Account' && frappe.boot.profile.can_read.indexOf("GL Entry") !== -1) {
|
||||||
node_links.push('<a onclick="erpnext.account_chart.show_ledger();">'+wn._('View Ledger')+'</a>');
|
node_links.push('<a onclick="erpnext.account_chart.show_ledger();">'+frappe._('View Ledger')+'</a>');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.can_write) {
|
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) {
|
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(" | "));
|
link.toolbar.append(node_links.join(" | "));
|
||||||
},
|
},
|
||||||
open: function() {
|
open: function() {
|
||||||
var node = this.selected_node();
|
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() {
|
show_ledger: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
var node = me.selected_node();
|
var node = me.selected_node();
|
||||||
wn.route_options = {
|
frappe.route_options = {
|
||||||
"account": node.data('label'),
|
"account": node.data('label'),
|
||||||
"from_date": sys_defaults.year_start_date,
|
"from_date": sys_defaults.year_start_date,
|
||||||
"to_date": sys_defaults.year_end_date,
|
"to_date": sys_defaults.year_end_date,
|
||||||
"company": me.company
|
"company": me.company
|
||||||
};
|
};
|
||||||
wn.set_route("query-report", "General Ledger");
|
frappe.set_route("query-report", "General Ledger");
|
||||||
},
|
},
|
||||||
rename: function() {
|
rename: function() {
|
||||||
var node = this.selected_node();
|
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");
|
node.parents("ul:first").parent().find(".tree-link:first").trigger("reload");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
delete: function() {
|
delete: function() {
|
||||||
var node = this.selected_node();
|
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();
|
node.parent().remove();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -205,21 +205,21 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
// the dialog
|
// the dialog
|
||||||
var d = new wn.ui.Dialog({
|
var d = new frappe.ui.Dialog({
|
||||||
title:wn._('New Account'),
|
title:frappe._('New Account'),
|
||||||
fields: [
|
fields: [
|
||||||
{fieldtype:'Data', fieldname:'account_name', label:wn._('New Account Name'), reqd:true,
|
{fieldtype:'Data', fieldname:'account_name', label:frappe._('New Account Name'), reqd:true,
|
||||||
description: wn._("Name of new Account. Note: Please don't create accounts for Customers and Suppliers,")+
|
description: frappe._("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")},
|
frappe._("they are created automatically from the Customer and Supplier master")},
|
||||||
{fieldtype:'Select', fieldname:'group_or_ledger', label:wn._('Group or Ledger'),
|
{fieldtype:'Select', fieldname:'group_or_ledger', label:frappe._('Group or Ledger'),
|
||||||
options:'Group\nLedger', description: wn._('Further accounts can be made under Groups,')+
|
options:'Group\nLedger', description: frappe._('Further accounts can be made under Groups,')+
|
||||||
wn._('but entries can be made against Ledger')},
|
frappe._('but entries can be made against Ledger')},
|
||||||
{fieldtype:'Select', fieldname:'account_type', label:wn._('Account Type'),
|
{fieldtype:'Select', fieldname:'account_type', label:frappe._('Account Type'),
|
||||||
options: ['', 'Fixed Asset Account', 'Bank or Cash', 'Expense Account', 'Tax',
|
options: ['', 'Fixed Asset Account', 'Bank or Cash', 'Expense Account', 'Tax',
|
||||||
'Income Account', 'Chargeable'].join('\n'),
|
'Income Account', 'Chargeable'].join('\n'),
|
||||||
description: wn._("Optional. This setting will be used to filter in various transactions.") },
|
description: frappe._("Optional. This setting will be used to filter in various transactions.") },
|
||||||
{fieldtype:'Float', fieldname:'tax_rate', label:wn._('Tax Rate')},
|
{fieldtype:'Float', fieldname:'tax_rate', label:frappe._('Tax Rate')},
|
||||||
{fieldtype:'Button', fieldname:'create_new', label:wn._('Create New') }
|
{fieldtype:'Button', fieldname:'create_new', label:frappe._('Create New') }
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
v.master_type = '';
|
v.master_type = '';
|
||||||
v.company = me.company;
|
v.company = me.company;
|
||||||
|
|
||||||
return wn.call({
|
return frappe.call({
|
||||||
args: v,
|
args: v,
|
||||||
method: 'erpnext.accounts.utils.add_ac',
|
method: 'erpnext.accounts.utils.add_ac',
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
@ -283,14 +283,14 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
new_cost_center: function(){
|
new_cost_center: function(){
|
||||||
var me = this;
|
var me = this;
|
||||||
// the dialog
|
// the dialog
|
||||||
var d = new wn.ui.Dialog({
|
var d = new frappe.ui.Dialog({
|
||||||
title:wn._('New Cost Center'),
|
title:frappe._('New Cost Center'),
|
||||||
fields: [
|
fields: [
|
||||||
{fieldtype:'Data', fieldname:'cost_center_name', label:wn._('New Cost Center Name'), reqd:true},
|
{fieldtype:'Data', fieldname:'cost_center_name', label:frappe._('New Cost Center Name'), reqd:true},
|
||||||
{fieldtype:'Select', fieldname:'group_or_ledger', label:wn._('Group or Ledger'),
|
{fieldtype:'Select', fieldname:'group_or_ledger', label:frappe._('Group or Ledger'),
|
||||||
options:'Group\nLedger', description:wn._('Further accounts can be made under Groups,')+
|
options:'Group\nLedger', description:frappe._('Further accounts can be made under Groups,')+
|
||||||
wn._('but entries can be made against Ledger')},
|
frappe._('but entries can be made against Ledger')},
|
||||||
{fieldtype:'Button', fieldname:'create_new', label:wn._('Create New') }
|
{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.parent_cost_center = node.data('label');
|
||||||
v.company = me.company;
|
v.company = me.company;
|
||||||
|
|
||||||
return wn.call({
|
return frappe.call({
|
||||||
args: v,
|
args: v,
|
||||||
method: 'erpnext.accounts.utils.add_cc',
|
method: 'erpnext.accounts.utils.add_cc',
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
|
@ -2,25 +2,25 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
import webnotes.defaults
|
import frappe.defaults
|
||||||
from webnotes.utils import flt
|
from frappe.utils import flt
|
||||||
from erpnext.accounts.utils import get_balance_on
|
from erpnext.accounts.utils import get_balance_on
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@frappe.whitelist()
|
||||||
def get_companies():
|
def get_companies():
|
||||||
"""get a list of companies based on permission"""
|
"""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")]
|
order_by="name")]
|
||||||
|
|
||||||
@webnotes.whitelist()
|
@frappe.whitelist()
|
||||||
def get_children():
|
def get_children():
|
||||||
args = webnotes.local.form_dict
|
args = frappe.local.form_dict
|
||||||
ctype, company = args['ctype'], args['comp']
|
ctype, company = args['ctype'], args['comp']
|
||||||
|
|
||||||
# root
|
# root
|
||||||
if args['parent'] in ("Accounts", "Cost Centers"):
|
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
|
name as value, if(group_or_ledger='Group', 1, 0) as expandable
|
||||||
from `tab%s`
|
from `tab%s`
|
||||||
where ifnull(parent_%s,'') = ''
|
where ifnull(parent_%s,'') = ''
|
||||||
@ -29,7 +29,7 @@ def get_children():
|
|||||||
company, as_dict=1)
|
company, as_dict=1)
|
||||||
else:
|
else:
|
||||||
# other
|
# other
|
||||||
acc = webnotes.conn.sql("""select
|
acc = frappe.conn.sql("""select
|
||||||
name as value, if(group_or_ledger='Group', 1, 0) as expandable
|
name as value, if(group_or_ledger='Group', 1, 0) as expandable
|
||||||
from `tab%s`
|
from `tab%s`
|
||||||
where ifnull(parent_%s,'') = %s
|
where ifnull(parent_%s,'') = %s
|
||||||
@ -38,7 +38,7 @@ def get_children():
|
|||||||
args['parent'], as_dict=1)
|
args['parent'], as_dict=1)
|
||||||
|
|
||||||
if ctype == 'Account':
|
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:
|
for each in acc:
|
||||||
bal = get_balance_on(each.get("value"))
|
bal = get_balance_on(each.get("value"))
|
||||||
each["currency"] = currency
|
each["currency"] = currency
|
||||||
|
@ -1,288 +1,288 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt"
|
// License: GNU General Public License v3. See license.txt"
|
||||||
|
|
||||||
wn.module_page["Accounts"] = [
|
frappe.module_page["Accounts"] = [
|
||||||
{
|
{
|
||||||
top: true,
|
top: true,
|
||||||
title: wn._("Documents"),
|
title: frappe._("Documents"),
|
||||||
icon: "icon-copy",
|
icon: "icon-copy",
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
label: wn._("Journal Voucher"),
|
label: frappe._("Journal Voucher"),
|
||||||
description: wn._("Accounting journal entries."),
|
description: frappe._("Accounting journal entries."),
|
||||||
doctype:"Journal Voucher"
|
doctype:"Journal Voucher"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: wn._("Sales Invoice"),
|
label: frappe._("Sales Invoice"),
|
||||||
description: wn._("Bills raised to Customers."),
|
description: frappe._("Bills raised to Customers."),
|
||||||
doctype:"Sales Invoice"
|
doctype:"Sales Invoice"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: wn._("Purchase Invoice"),
|
label: frappe._("Purchase Invoice"),
|
||||||
description: wn._("Bills raised by Suppliers."),
|
description: frappe._("Bills raised by Suppliers."),
|
||||||
doctype:"Purchase Invoice"
|
doctype:"Purchase Invoice"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: wn._("Masters"),
|
title: frappe._("Masters"),
|
||||||
icon: "icon-book",
|
icon: "icon-book",
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
label: wn._("Chart of Accounts"),
|
label: frappe._("Chart of Accounts"),
|
||||||
route: "Accounts Browser/Account",
|
route: "Accounts Browser/Account",
|
||||||
description: wn._("Structure of books of accounts."),
|
description: frappe._("Structure of books of accounts."),
|
||||||
doctype:"Account"
|
doctype:"Account"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: wn._("Chart of Cost Centers"),
|
label: frappe._("Chart of Cost Centers"),
|
||||||
route: "Accounts Browser/Cost Center",
|
route: "Accounts Browser/Cost Center",
|
||||||
description: wn._("Structure cost centers for budgeting."),
|
description: frappe._("Structure cost centers for budgeting."),
|
||||||
doctype:"Cost Center"
|
doctype:"Cost Center"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: wn._("Customer"),
|
label: frappe._("Customer"),
|
||||||
description: wn._("Customer database."),
|
description: frappe._("Customer database."),
|
||||||
doctype:"Customer"
|
doctype:"Customer"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: wn._("Supplier"),
|
label: frappe._("Supplier"),
|
||||||
description: wn._("Supplier database."),
|
description: frappe._("Supplier database."),
|
||||||
doctype:"Supplier"
|
doctype:"Supplier"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: wn._("Setup"),
|
title: frappe._("Setup"),
|
||||||
icon: "icon-wrench",
|
icon: "icon-wrench",
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
label: wn._("Company"),
|
label: frappe._("Company"),
|
||||||
description: wn._("Company Master."),
|
description: frappe._("Company Master."),
|
||||||
doctype:"Company"
|
doctype:"Company"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: wn._("Fiscal Year"),
|
label: frappe._("Fiscal Year"),
|
||||||
description: wn._("Accounting Year."),
|
description: frappe._("Accounting Year."),
|
||||||
doctype:"Fiscal Year"
|
doctype:"Fiscal Year"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: wn._("Tools"),
|
title: frappe._("Tools"),
|
||||||
icon: "icon-wrench",
|
icon: "icon-wrench",
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
"route":"Form/Bank Reconciliation/Bank Reconciliation",
|
"route":"Form/Bank Reconciliation/Bank Reconciliation",
|
||||||
"label": wn._("Bank Reconciliation"),
|
"label": frappe._("Bank Reconciliation"),
|
||||||
"description": wn._("Update bank payment dates with journals."),
|
"description": frappe._("Update bank payment dates with journals."),
|
||||||
doctype: "Bank Reconciliation"
|
doctype: "Bank Reconciliation"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"route":"Form/Payment to Invoice Matching Tool/Payment to Invoice Matching Tool",
|
"route":"Form/Payment to Invoice Matching Tool/Payment to Invoice Matching Tool",
|
||||||
"label": wn._("Payment Reconciliation"),
|
"label": frappe._("Payment Reconciliation"),
|
||||||
"description": wn._("Match non-linked Invoices and Payments."),
|
"description": frappe._("Match non-linked Invoices and Payments."),
|
||||||
doctype: "Payment to Invoice Matching Tool"
|
doctype: "Payment to Invoice Matching Tool"
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": wn._("Period Closing Voucher"),
|
"label": frappe._("Period Closing Voucher"),
|
||||||
"doctype": "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",
|
icon: "icon-cog",
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
"label": wn._("Accounts Settings"),
|
"label": frappe._("Accounts Settings"),
|
||||||
"route": "Form/Accounts Settings",
|
"route": "Form/Accounts Settings",
|
||||||
"doctype":"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",
|
"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",
|
"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",
|
"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",
|
"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",
|
"doctype":"POS Setting",
|
||||||
"description": wn._("User settings for Point-of-sale (POS)")
|
"description": frappe._("User settings for Point-of-sale (POS)")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype":"Budget Distribution",
|
"doctype":"Budget Distribution",
|
||||||
"label": wn._("Budget Distribution"),
|
"label": frappe._("Budget Distribution"),
|
||||||
"description": wn._("Seasonality for setting budgets.")
|
"description": frappe._("Seasonality for setting budgets.")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype":"Terms and Conditions",
|
"doctype":"Terms and Conditions",
|
||||||
"label": wn._("Terms and Conditions Template"),
|
"label": frappe._("Terms and Conditions Template"),
|
||||||
description: wn._("Template of terms or contract.")
|
description: frappe._("Template of terms or contract.")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype":"Mode of Payment",
|
"doctype":"Mode of Payment",
|
||||||
"label": wn._("Mode of Payment"),
|
"label": frappe._("Mode of Payment"),
|
||||||
description: wn._("e.g. Bank, Cash, Credit Card")
|
description: frappe._("e.g. Bank, Cash, Credit Card")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype":"C-Form",
|
"doctype":"C-Form",
|
||||||
"label": wn._("C-Form"),
|
"label": frappe._("C-Form"),
|
||||||
description: wn._("C-Form records"),
|
description: frappe._("C-Form records"),
|
||||||
country: "India"
|
country: "India"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: wn._("Main Reports"),
|
title: frappe._("Main Reports"),
|
||||||
right: true,
|
right: true,
|
||||||
icon: "icon-table",
|
icon: "icon-table",
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
"label":wn._("General Ledger"),
|
"label":frappe._("General Ledger"),
|
||||||
doctype: "GL Entry",
|
doctype: "GL Entry",
|
||||||
route: "query-report/General Ledger"
|
route: "query-report/General Ledger"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Trial Balance"),
|
"label":frappe._("Trial Balance"),
|
||||||
page: "trial-balance"
|
page: "trial-balance"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"page":"Financial Statements",
|
"page":"Financial Statements",
|
||||||
"label": wn._("Financial Statements")
|
"label": frappe._("Financial Statements")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Accounts Receivable"),
|
"label":frappe._("Accounts Receivable"),
|
||||||
route: "query-report/Accounts Receivable",
|
route: "query-report/Accounts Receivable",
|
||||||
doctype: "Sales Invoice"
|
doctype: "Sales Invoice"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Accounts Payable"),
|
"label":frappe._("Accounts Payable"),
|
||||||
route: "query-report/Accounts Payable",
|
route: "query-report/Accounts Payable",
|
||||||
doctype: "Purchase Invoice"
|
doctype: "Purchase Invoice"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Sales Register"),
|
"label":frappe._("Sales Register"),
|
||||||
route: "query-report/Sales Register",
|
route: "query-report/Sales Register",
|
||||||
doctype: "Sales Invoice"
|
doctype: "Sales Invoice"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Purchase Register"),
|
"label":frappe._("Purchase Register"),
|
||||||
route: "query-report/Purchase Register",
|
route: "query-report/Purchase Register",
|
||||||
doctype: "Purchase Invoice"
|
doctype: "Purchase Invoice"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: wn._("Analytics"),
|
title: frappe._("Analytics"),
|
||||||
right: true,
|
right: true,
|
||||||
icon: "icon-bar-chart",
|
icon: "icon-bar-chart",
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
"label":wn._("Financial Analytics"),
|
"label":frappe._("Financial Analytics"),
|
||||||
page: "financial-analytics"
|
page: "financial-analytics"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Gross Profit"),
|
"label":frappe._("Gross Profit"),
|
||||||
route: "query-report/Gross Profit",
|
route: "query-report/Gross Profit",
|
||||||
doctype: "Sales Invoice"
|
doctype: "Sales Invoice"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: wn._("Reports"),
|
title: frappe._("Reports"),
|
||||||
right: true,
|
right: true,
|
||||||
icon: "icon-list",
|
icon: "icon-list",
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
"label":wn._("Bank Reconciliation Statement"),
|
"label":frappe._("Bank Reconciliation Statement"),
|
||||||
route: "query-report/Bank Reconciliation Statement",
|
route: "query-report/Bank Reconciliation Statement",
|
||||||
doctype: "Journal Voucher"
|
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",
|
route: "query-report/Ordered Items To Be Billed",
|
||||||
doctype: "Sales Invoice"
|
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",
|
route: "query-report/Delivered Items To Be Billed",
|
||||||
doctype: "Sales Invoice"
|
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",
|
route: "query-report/Purchase Order Items To Be Billed",
|
||||||
doctype: "Purchase Invoice"
|
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",
|
route: "query-report/Received Items To Be Billed",
|
||||||
doctype: "Purchase Invoice"
|
doctype: "Purchase Invoice"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Bank Clearance Summary"),
|
"label":frappe._("Bank Clearance Summary"),
|
||||||
route: "query-report/Bank Clearance Summary",
|
route: "query-report/Bank Clearance Summary",
|
||||||
doctype: "Journal Voucher"
|
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",
|
route: "query-report/Payment Period Based On Invoice Date",
|
||||||
doctype: "Journal Voucher"
|
doctype: "Journal Voucher"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Sales Partners Commission"),
|
"label":frappe._("Sales Partners Commission"),
|
||||||
route: "query-report/Sales Partners Commission",
|
route: "query-report/Sales Partners Commission",
|
||||||
doctype: "Sales Invoice"
|
doctype: "Sales Invoice"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Customer Account Head"),
|
"label":frappe._("Customer Account Head"),
|
||||||
route: "query-report/Customer Account Head",
|
route: "query-report/Customer Account Head",
|
||||||
doctype: "Account"
|
doctype: "Account"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Supplier Account Head"),
|
"label":frappe._("Supplier Account Head"),
|
||||||
route: "query-report/Supplier Account Head",
|
route: "query-report/Supplier Account Head",
|
||||||
doctype: "Account"
|
doctype: "Account"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Item-wise Sales Register"),
|
"label":frappe._("Item-wise Sales Register"),
|
||||||
route: "query-report/Item-wise Sales Register",
|
route: "query-report/Item-wise Sales Register",
|
||||||
doctype: "Sales Invoice"
|
doctype: "Sales Invoice"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Item-wise Purchase Register"),
|
"label":frappe._("Item-wise Purchase Register"),
|
||||||
route: "query-report/Item-wise Purchase Register",
|
route: "query-report/Item-wise Purchase Register",
|
||||||
doctype: "Purchase Invoice"
|
doctype: "Purchase Invoice"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Budget Variance Report"),
|
"label":frappe._("Budget Variance Report"),
|
||||||
route: "query-report/Budget Variance Report",
|
route: "query-report/Budget Variance Report",
|
||||||
doctype: "Cost Center"
|
doctype: "Cost Center"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Purchase Invoice Trends"),
|
"label":frappe._("Purchase Invoice Trends"),
|
||||||
route: "query-report/Purchase Invoice Trends",
|
route: "query-report/Purchase Invoice Trends",
|
||||||
doctype: "Purchase Invoice"
|
doctype: "Purchase Invoice"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Sales Invoice Trends"),
|
"label":frappe._("Sales Invoice Trends"),
|
||||||
route: "query-report/Sales Invoice Trends",
|
route: "query-report/Sales Invoice Trends",
|
||||||
doctype: "Sales Invoice"
|
doctype: "Sales Invoice"
|
||||||
},
|
},
|
||||||
@ -291,5 +291,5 @@ wn.module_page["Accounts"] = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
pscript['onload_accounts-home'] = function(wrapper) {
|
pscript['onload_accounts-home'] = function(wrapper) {
|
||||||
wn.views.moduleview.make(wrapper, "Accounts");
|
frappe.views.moduleview.make(wrapper, "Accounts");
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// 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) {
|
frappe.pages['financial-analytics'].onload = function(wrapper) {
|
||||||
wn.ui.make_app_page({
|
frappe.ui.make_app_page({
|
||||||
parent: wrapper,
|
parent: wrapper,
|
||||||
title: wn._('Financial Analytics'),
|
title: frappe._('Financial Analytics'),
|
||||||
single_column: true
|
single_column: true
|
||||||
});
|
});
|
||||||
erpnext.trial_balance = new erpnext.FinancialAnalytics(wrapper, 'Financial Analytics');
|
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({
|
erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
|
||||||
filters: [
|
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) {
|
filter: function(val, item, opts, me) {
|
||||||
if(item._show) return true;
|
if(item._show) return true;
|
||||||
|
|
||||||
@ -26,27 +26,27 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
|
|||||||
|
|
||||||
return me.apply_zero_filter(val, item, opts, me);
|
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) {
|
filter: function(val, item, opts) {
|
||||||
return item.company == val || val == opts.default_value || item._show;
|
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..."},
|
default_value: "Select Fiscal Year..."},
|
||||||
{fieldtype:"Date", label: wn._("From Date")},
|
{fieldtype:"Date", label: frappe._("From Date")},
|
||||||
{fieldtype:"Label", label: wn._("To")},
|
{fieldtype:"Label", label: frappe._("To")},
|
||||||
{fieldtype:"Date", label: wn._("To Date")},
|
{fieldtype:"Date", label: frappe._("To Date")},
|
||||||
{fieldtype:"Select", label: wn._("Range"),
|
{fieldtype:"Select", label: frappe._("Range"),
|
||||||
options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]},
|
options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]},
|
||||||
{fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white"},
|
{fieldtype:"Button", label: frappe._("Refresh"), icon:"icon-refresh icon-white"},
|
||||||
{fieldtype:"Button", label: wn._("Reset Filters")}
|
{fieldtype:"Button", label: frappe._("Reset Filters")}
|
||||||
],
|
],
|
||||||
setup_columns: function() {
|
setup_columns: function() {
|
||||||
var std_columns = [
|
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},
|
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},
|
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}
|
formatter: this.currency_formatter}
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
|
|||||||
this.trigger_refresh_on_change(["pl_or_bs"]);
|
this.trigger_refresh_on_change(["pl_or_bs"]);
|
||||||
|
|
||||||
this.filter_inputs.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();
|
this.setup_plot_check();
|
||||||
},
|
},
|
||||||
@ -72,13 +72,13 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
|
|||||||
|
|
||||||
// setup cost center map
|
// setup cost center map
|
||||||
if(!this.cost_center_by_name) {
|
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)
|
var cost_center = inList(["Balance Sheet", "Profit and Loss"], this.pl_or_bs)
|
||||||
? null : this.cost_center_by_name[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() {
|
var filter_by_cost_center = (function() {
|
||||||
if(cost_center) {
|
if(cost_center) {
|
||||||
if(gl.cost_center) {
|
if(gl.cost_center) {
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
erpnext.fs = {}
|
erpnext.fs = {}
|
||||||
|
|
||||||
pscript['onload_Financial Statements'] = function(wrapper) {
|
pscript['onload_Financial Statements'] = function(wrapper) {
|
||||||
wn.ui.make_app_page({
|
frappe.ui.make_app_page({
|
||||||
parent: wrapper,
|
parent: wrapper,
|
||||||
"title": wn._("Financial Statements"),
|
"title": frappe._("Financial Statements"),
|
||||||
"single_column": true,
|
"single_column": true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -34,18 +34,18 @@ pscript['onload_Financial Statements'] = function(wrapper) {
|
|||||||
options: ['Loading...']
|
options: ['Loading...']
|
||||||
})
|
})
|
||||||
|
|
||||||
wrapper.appframe.add_button(wn._("Create"), function() {
|
wrapper.appframe.add_button(frappe._("Create"), function() {
|
||||||
pscript.stmt_new();
|
pscript.stmt_new();
|
||||||
}, "icon-refresh")
|
}, "icon-refresh")
|
||||||
|
|
||||||
wrapper.appframe.add_button(wn._("Print"), function() {
|
wrapper.appframe.add_button(frappe._("Print"), function() {
|
||||||
_p.go($i('print_html').innerHTML);
|
_p.go($i('print_html').innerHTML);
|
||||||
}, "icon-print")
|
}, "icon-print")
|
||||||
|
|
||||||
$(wrapper).find(".layout-main").html('<div id="print_html">\
|
$(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_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_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"});
|
</div>').css({"min-height": "400px"});
|
||||||
|
|
||||||
// load companies
|
// load companies
|
||||||
@ -61,7 +61,7 @@ pscript['onload_Financial Statements'] = function(wrapper) {
|
|||||||
|
|
||||||
pscript.stmt_new = function(stmt,company_name,level,period,year) {
|
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';
|
$i('stmt_tree').style.display = 'block';
|
||||||
|
|
||||||
var company =erpnext.fs.stmt_company.get_value();
|
var company =erpnext.fs.stmt_company.get_value();
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// 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) {
|
frappe.pages['trial-balance'].onload = function(wrapper) {
|
||||||
wn.ui.make_app_page({
|
frappe.ui.make_app_page({
|
||||||
parent: wrapper,
|
parent: wrapper,
|
||||||
title: wn._('Trial Balance'),
|
title: frappe._('Trial Balance'),
|
||||||
single_column: true
|
single_column: true
|
||||||
});
|
});
|
||||||
var TrialBalance = erpnext.AccountTreeGrid.extend({
|
var TrialBalance = erpnext.AccountTreeGrid.extend({
|
||||||
@ -18,7 +18,7 @@ wn.pages['trial-balance'].onload = function(wrapper) {
|
|||||||
this.wrapper.bind("make", function() {
|
this.wrapper.bind("make", function() {
|
||||||
$('<div style="margin: 10px 0px; "\
|
$('<div style="margin: 10px 0px; "\
|
||||||
class="with_period_closing_entry"><input type="checkbox" checked="checked">' +
|
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)
|
.appendTo(me.wrapper)
|
||||||
.find("input").click(function() { me.refresh(); });
|
.find("input").click(function() { me.refresh(); });
|
||||||
});
|
});
|
||||||
|
@ -3,23 +3,23 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes import _
|
from frappe import _
|
||||||
from webnotes.defaults import get_restrictions
|
from frappe.defaults import get_restrictions
|
||||||
from erpnext.utilities.doctype.address.address import get_address_display
|
from erpnext.utilities.doctype.address.address import get_address_display
|
||||||
from erpnext.utilities.doctype.contact.contact import get_contact_details
|
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,
|
def get_party_details(party=None, account=None, party_type="Customer", company=None,
|
||||||
posting_date=None, price_list=None, currency=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()]
|
party = out[party_type.lower()]
|
||||||
|
|
||||||
if not webnotes.has_permission(party_type, "read", party):
|
if not frappe.has_permission(party_type, "read", party):
|
||||||
webnotes.throw("Not Permitted", webnotes.PermissionError)
|
frappe.throw("Not Permitted", frappe.PermissionError)
|
||||||
|
|
||||||
party_bean = webnotes.bean(party_type, party)
|
party_bean = frappe.bean(party_type, party)
|
||||||
party = party_bean.doc
|
party = party_bean.doc
|
||||||
|
|
||||||
set_address_and_contact(out, party, party_type)
|
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):
|
def set_address_and_contact(out, party, party_type):
|
||||||
out.update({
|
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"),
|
{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")
|
{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
|
price_list = party.default_price_list
|
||||||
|
|
||||||
if not price_list and party.party_type=="Customer":
|
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")
|
party.customer_group, "default_price_list")
|
||||||
|
|
||||||
if not price_list:
|
if not price_list:
|
||||||
price_list = given_price_list
|
price_list = given_price_list
|
||||||
|
|
||||||
if 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
|
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:
|
if party:
|
||||||
account = get_party_account(company, party, party_type)
|
account = get_party_account(company, party, party_type)
|
||||||
elif account:
|
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"
|
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):
|
def get_party_account(company, party, party_type):
|
||||||
if not company:
|
if not company:
|
||||||
webnotes.throw(_("Please select company first."))
|
frappe.throw(_("Please select company first."))
|
||||||
|
|
||||||
if party:
|
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})
|
"master_type": party_type, "company": company})
|
||||||
|
|
||||||
if not acc_head:
|
if not acc_head:
|
||||||
@ -130,11 +130,11 @@ def get_due_date(posting_date, party, party_type, account, company):
|
|||||||
if posting_date:
|
if posting_date:
|
||||||
credit_days = 0
|
credit_days = 0
|
||||||
if account:
|
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:
|
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:
|
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
|
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):
|
def create_party_account(party, party_type, company):
|
||||||
if not 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)
|
["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 \
|
parent_account = company_details.receivables_group \
|
||||||
if party_type=="Customer" else company_details.payables_group
|
if party_type=="Customer" else company_details.payables_group
|
||||||
|
|
||||||
# create
|
# create
|
||||||
account = webnotes.bean({
|
account = frappe.bean({
|
||||||
"doctype": "Account",
|
"doctype": "Account",
|
||||||
'account_name': party,
|
'account_name': party,
|
||||||
'parent_account': parent_account,
|
'parent_account': parent_account,
|
||||||
@ -162,4 +162,4 @@ def create_party_account(party, party_type, company):
|
|||||||
"freeze_account": "No"
|
"freeze_account": "No"
|
||||||
}).insert(ignore_permissions=True)
|
}).insert(ignore_permissions=True)
|
||||||
|
|
||||||
webnotes.msgprint(_("Account Created") + ": " + account.doc.name)
|
frappe.msgprint(_("Account Created") + ": " + account.doc.name)
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
wn.query_reports["Accounts Payable"] = {
|
frappe.query_reports["Accounts Payable"] = {
|
||||||
"filters": [
|
"filters": [
|
||||||
{
|
{
|
||||||
"fieldname":"company",
|
"fieldname":"company",
|
||||||
"label": wn._("Company"),
|
"label": frappe._("Company"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Company",
|
"options": "Company",
|
||||||
"default": wn.defaults.get_default("company")
|
"default": frappe.defaults.get_default("company")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"account",
|
"fieldname":"account",
|
||||||
"label": wn._("Account"),
|
"label": frappe._("Account"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Account",
|
"options": "Account",
|
||||||
"get_query": function() {
|
"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 {
|
return {
|
||||||
"query": "accounts.utils.get_account_list",
|
"query": "accounts.utils.get_account_list",
|
||||||
"filters": {
|
"filters": {
|
||||||
@ -30,13 +30,13 @@ wn.query_reports["Accounts Payable"] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"report_date",
|
"fieldname":"report_date",
|
||||||
"label": wn._("Date"),
|
"label": frappe._("Date"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": get_today()
|
"default": get_today()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"ageing_based_on",
|
"fieldname":"ageing_based_on",
|
||||||
"label": wn._("Ageing Based On"),
|
"label": frappe._("Ageing Based On"),
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"options": 'Posting Date' + NEWLINE + 'Due Date',
|
"options": 'Posting Date' + NEWLINE + 'Due Date',
|
||||||
"default": "Posting Date"
|
"default": "Posting Date"
|
||||||
|
@ -2,17 +2,17 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes.utils import getdate, nowdate, flt, cstr
|
from frappe.utils import getdate, nowdate, flt, cstr
|
||||||
from webnotes import msgprint, _
|
from frappe import msgprint, _
|
||||||
from erpnext.accounts.report.accounts_receivable.accounts_receivable import get_ageing_data
|
from erpnext.accounts.report.accounts_receivable.accounts_receivable import get_ageing_data
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
if not filters: filters = {}
|
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)
|
columns = get_columns(supplier_naming_by)
|
||||||
entries = get_gl_entries(filters)
|
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
|
supp.supplier_name, supp.name as supplier
|
||||||
from `tabAccount` acc, `tabSupplier` supp
|
from `tabAccount` acc, `tabSupplier` supp
|
||||||
where acc.master_type="Supplier" and supp.name=acc.master_name""", as_dict=1)))
|
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):
|
def get_gl_entries(filters, before_report_date=True):
|
||||||
conditions, supplier_accounts = get_conditions(filters, before_report_date)
|
conditions, supplier_accounts = get_conditions(filters, before_report_date)
|
||||||
gl_entries = []
|
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""" %
|
where docstatus < 2 %s order by posting_date, account""" %
|
||||||
(conditions), tuple(supplier_accounts), as_dict=1)
|
(conditions), tuple(supplier_accounts), as_dict=1)
|
||||||
return gl_entries
|
return gl_entries
|
||||||
@ -99,7 +99,7 @@ def get_conditions(filters, before_report_date=True):
|
|||||||
if filters.get("account"):
|
if filters.get("account"):
|
||||||
supplier_accounts = [filters["account"]]
|
supplier_accounts = [filters["account"]]
|
||||||
else:
|
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""" %
|
where ifnull(master_type, '') = 'Supplier' and docstatus < 2 %s""" %
|
||||||
conditions, filters)
|
conditions, filters)
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ def get_conditions(filters, before_report_date=True):
|
|||||||
|
|
||||||
def get_account_supplier_type_map():
|
def get_account_supplier_type_map():
|
||||||
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"""):
|
`tabAccount` acc where supp.name = acc.master_name group by acc.name"""):
|
||||||
account_supplier_type_map[each[0]] = each[1]
|
account_supplier_type_map[each[0]] = each[1]
|
||||||
|
|
||||||
@ -127,15 +127,15 @@ def get_account_supplier_type_map():
|
|||||||
def get_voucher_details():
|
def get_voucher_details():
|
||||||
voucher_details = {}
|
voucher_details = {}
|
||||||
for dt in ["Purchase Invoice", "Journal Voucher"]:
|
for dt in ["Purchase Invoice", "Journal Voucher"]:
|
||||||
voucher_details.setdefault(dt, webnotes._dict())
|
voucher_details.setdefault(dt, frappe._dict())
|
||||||
for t in webnotes.conn.sql("""select name, due_date, bill_no, bill_date
|
for t in frappe.conn.sql("""select name, due_date, bill_no, bill_date
|
||||||
from `tab%s`""" % dt, as_dict=1):
|
from `tab%s`""" % dt, as_dict=1):
|
||||||
voucher_details[dt].setdefault(t.name, t)
|
voucher_details[dt].setdefault(t.name, t)
|
||||||
|
|
||||||
return voucher_details
|
return voucher_details
|
||||||
|
|
||||||
def get_outstanding_amount(gle, report_date):
|
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))
|
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||||
from `tabGL Entry`
|
from `tabGL Entry`
|
||||||
where account = %s and posting_date <= %s and against_voucher_type = %s
|
where account = %s and posting_date <= %s and against_voucher_type = %s
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
wn.query_reports["Accounts Receivable"] = {
|
frappe.query_reports["Accounts Receivable"] = {
|
||||||
"filters": [
|
"filters": [
|
||||||
{
|
{
|
||||||
"fieldname":"company",
|
"fieldname":"company",
|
||||||
"label": wn._("Company"),
|
"label": frappe._("Company"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Company",
|
"options": "Company",
|
||||||
"default": wn.defaults.get_default("company")
|
"default": frappe.defaults.get_default("company")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"account",
|
"fieldname":"account",
|
||||||
"label": wn._("Account"),
|
"label": frappe._("Account"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Account",
|
"options": "Account",
|
||||||
"get_query": function() {
|
"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 {
|
return {
|
||||||
"query": "accounts.utils.get_account_list",
|
"query": "accounts.utils.get_account_list",
|
||||||
"filters": {
|
"filters": {
|
||||||
@ -30,13 +30,13 @@ wn.query_reports["Accounts Receivable"] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"report_date",
|
"fieldname":"report_date",
|
||||||
"label": wn._("Date"),
|
"label": frappe._("Date"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": get_today()
|
"default": get_today()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"ageing_based_on",
|
"fieldname":"ageing_based_on",
|
||||||
"label": wn._("Ageing Based On"),
|
"label": frappe._("Ageing Based On"),
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"options": 'Posting Date' + NEWLINE + 'Due Date',
|
"options": 'Posting Date' + NEWLINE + 'Due Date',
|
||||||
"default": "Posting Date"
|
"default": "Posting Date"
|
||||||
|
@ -2,20 +2,20 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes import _
|
from frappe import _
|
||||||
from webnotes.utils import getdate, nowdate, flt
|
from frappe.utils import getdate, nowdate, flt
|
||||||
|
|
||||||
class AccountsReceivableReport(object):
|
class AccountsReceivableReport(object):
|
||||||
def __init__(self, filters=None):
|
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.filters.report_date = getdate(self.filters.report_date or nowdate())
|
||||||
self.age_as_on = getdate(nowdate()) \
|
self.age_as_on = getdate(nowdate()) \
|
||||||
if self.filters.report_date > getdate(nowdate()) \
|
if self.filters.report_date > getdate(nowdate()) \
|
||||||
else self.filters.report_date
|
else self.filters.report_date
|
||||||
|
|
||||||
def run(self):
|
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)
|
return self.get_columns(customer_naming_by), self.get_data(customer_naming_by)
|
||||||
|
|
||||||
def get_columns(self, customer_naming_by):
|
def get_columns(self, customer_naming_by):
|
||||||
@ -111,7 +111,7 @@ class AccountsReceivableReport(object):
|
|||||||
|
|
||||||
def get_account_map(self):
|
def get_account_map(self):
|
||||||
if not hasattr(self, "account_map"):
|
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
|
acc.name, cust.name as customer, cust.customer_name, cust.territory
|
||||||
from `tabAccount` acc left join `tabCustomer` cust
|
from `tabAccount` acc left join `tabCustomer` cust
|
||||||
on cust.name=acc.master_name where acc.master_type="Customer" """, as_dict=True)))
|
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):
|
def get_due_date(self, gle):
|
||||||
if not hasattr(self, "invoice_due_date_map"):
|
if not hasattr(self, "invoice_due_date_map"):
|
||||||
# TODO can be restricted to posting date
|
# 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"""))
|
from `tabSales Invoice` where docstatus=1"""))
|
||||||
|
|
||||||
return gle.voucher_type == "Sales Invoice" \
|
return gle.voucher_type == "Sales Invoice" \
|
||||||
@ -130,7 +130,7 @@ class AccountsReceivableReport(object):
|
|||||||
def get_gl_entries(self):
|
def get_gl_entries(self):
|
||||||
if not hasattr(self, "gl_entries"):
|
if not hasattr(self, "gl_entries"):
|
||||||
conditions, values = self.prepare_conditions()
|
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),
|
where docstatus < 2 {0} order by posting_date, account""".format(conditions),
|
||||||
values, as_dict=True)
|
values, as_dict=True)
|
||||||
return self.gl_entries
|
return self.gl_entries
|
||||||
@ -149,7 +149,7 @@ class AccountsReceivableReport(object):
|
|||||||
else:
|
else:
|
||||||
account_map = self.get_account_map()
|
account_map = self.get_account_map()
|
||||||
if not account_map:
|
if not account_map:
|
||||||
webnotes.throw(_("No Customer Accounts found."))
|
frappe.throw(_("No Customer Accounts found."))
|
||||||
else:
|
else:
|
||||||
accounts_list = ['"{0}"'.format(ac) for ac in account_map]
|
accounts_list = ['"{0}"'.format(ac) for ac in account_map]
|
||||||
conditions.append("account in ({0})".format(", ".join(accounts_list)))
|
conditions.append("account in ({0})".format(", ".join(accounts_list)))
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
wn.query_reports["Bank Clearance Summary"] = {
|
frappe.query_reports["Bank Clearance Summary"] = {
|
||||||
"filters": [
|
"filters": [
|
||||||
{
|
{
|
||||||
"fieldname":"from_date",
|
"fieldname":"from_date",
|
||||||
"label": wn._("From Date"),
|
"label": frappe._("From Date"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": wn.defaults.get_user_default("year_start_date"),
|
"default": frappe.defaults.get_user_default("year_start_date"),
|
||||||
"width": "80"
|
"width": "80"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"to_date",
|
"fieldname":"to_date",
|
||||||
"label": wn._("To Date"),
|
"label": frappe._("To Date"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": get_today()
|
"default": get_today()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"account",
|
"fieldname":"account",
|
||||||
"label": wn._("Bank Account"),
|
"label": frappe._("Bank Account"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Account",
|
"options": "Account",
|
||||||
"get_query": function() {
|
"get_query": function() {
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes import _, msgprint
|
from frappe import _, msgprint
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
if not filters: filters = {}
|
if not filters: filters = {}
|
||||||
@ -33,7 +33,7 @@ def get_conditions(filters):
|
|||||||
|
|
||||||
def get_entries(filters):
|
def get_entries(filters):
|
||||||
conditions = get_conditions(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
|
jv.clearance_date, jvd.against_account, jvd.debit, jvd.credit
|
||||||
from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
|
from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
|
||||||
where jvd.parent = jv.name and jv.docstatus=1 %s
|
where jvd.parent = jv.name and jv.docstatus=1 %s
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
wn.query_reports["Bank Reconciliation Statement"] = {
|
frappe.query_reports["Bank Reconciliation Statement"] = {
|
||||||
"filters": [
|
"filters": [
|
||||||
{
|
{
|
||||||
"fieldname":"account",
|
"fieldname":"account",
|
||||||
"label": wn._("Bank Account"),
|
"label": frappe._("Bank Account"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Account",
|
"options": "Account",
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
@ -21,7 +21,7 @@ wn.query_reports["Bank Reconciliation Statement"] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"report_date",
|
"fieldname":"report_date",
|
||||||
"label": wn._("Date"),
|
"label": frappe._("Date"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": get_today(),
|
"default": get_today(),
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes.utils import flt
|
from frappe.utils import flt
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
if not filters: filters = {}
|
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()
|
columns = get_columns()
|
||||||
data = get_entries(filters)
|
data = get_entries(filters)
|
||||||
@ -41,7 +41,7 @@ def get_columns():
|
|||||||
]
|
]
|
||||||
|
|
||||||
def get_entries(filters):
|
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
|
jv.name, jv.posting_date, jv.clearance_date, jvd.against_account, jvd.debit, jvd.credit
|
||||||
from
|
from
|
||||||
`tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
|
`tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
wn.query_reports["Budget Variance Report"] = {
|
frappe.query_reports["Budget Variance Report"] = {
|
||||||
"filters": [
|
"filters": [
|
||||||
{
|
{
|
||||||
fieldname: "fiscal_year",
|
fieldname: "fiscal_year",
|
||||||
label: wn._("Fiscal Year"),
|
label: frappe._("Fiscal Year"),
|
||||||
fieldtype: "Link",
|
fieldtype: "Link",
|
||||||
options: "Fiscal Year",
|
options: "Fiscal Year",
|
||||||
default: sys_defaults.fiscal_year
|
default: sys_defaults.fiscal_year
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "period",
|
fieldname: "period",
|
||||||
label: wn._("Period"),
|
label: frappe._("Period"),
|
||||||
fieldtype: "Select",
|
fieldtype: "Select",
|
||||||
options: "Monthly\nQuarterly\nHalf-Yearly\nYearly",
|
options: "Monthly\nQuarterly\nHalf-Yearly\nYearly",
|
||||||
default: "Monthly"
|
default: "Monthly"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "company",
|
fieldname: "company",
|
||||||
label: wn._("Company"),
|
label: frappe._("Company"),
|
||||||
fieldtype: "Link",
|
fieldtype: "Link",
|
||||||
options: "Company",
|
options: "Company",
|
||||||
default: wn.defaults.get_default("company")
|
default: frappe.defaults.get_default("company")
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -2,9 +2,9 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes import _, msgprint
|
from frappe import _, msgprint
|
||||||
from webnotes.utils import flt
|
from frappe.utils import flt
|
||||||
import time
|
import time
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
from erpnext.controllers.trends import get_period_date_ranges, get_period_month_ranges
|
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
|
#Get cost center & target details
|
||||||
def get_costcenter_target_details(filters):
|
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
|
cc.parent_cost_center, bd.account, bd.budget_allocated
|
||||||
from `tabCost Center` cc, `tabBudget Detail` bd
|
from `tabCost Center` cc, `tabBudget Detail` bd
|
||||||
where bd.parent=cc.name and bd.fiscal_year=%s and
|
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):
|
def get_target_distribution_details(filters):
|
||||||
target_details = {}
|
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
|
from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd
|
||||||
where bdd.parent=bd.name and bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
|
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))
|
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
|
#Get actual details from gl entry
|
||||||
def get_actual_details(filters):
|
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
|
gl.cost_center, MONTHNAME(gl.posting_date) as month_name
|
||||||
from `tabGL Entry` gl, `tabBudget Detail` bd
|
from `tabGL Entry` gl, `tabBudget Detail` bd
|
||||||
where gl.fiscal_year=%s and company=%s
|
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')
|
month = datetime.date(2013, month_id, 1).strftime('%B')
|
||||||
|
|
||||||
cam_map.setdefault(ccd.name, {}).setdefault(ccd.account, {})\
|
cam_map.setdefault(ccd.name, {}).setdefault(ccd.account, {})\
|
||||||
.setdefault(month, webnotes._dict({
|
.setdefault(month, frappe._dict({
|
||||||
"target": 0.0, "actual": 0.0
|
"target": 0.0, "actual": 0.0
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
account_map = get_account_map()
|
account_map = get_account_map()
|
||||||
columns = get_columns(account_map)
|
columns = get_columns(account_map)
|
||||||
data = []
|
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:
|
for cust in customers:
|
||||||
row = [cust[0]]
|
row = [cust[0]]
|
||||||
for company in sorted(account_map):
|
for company in sorted(account_map):
|
||||||
@ -18,7 +18,7 @@ def execute(filters=None):
|
|||||||
return columns, data
|
return columns, data
|
||||||
|
|
||||||
def get_account_map():
|
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'
|
from `tabAccount` where master_type = 'Customer'
|
||||||
and ifnull(master_name, '') != '' and docstatus < 2""", as_dict=1)
|
and ifnull(master_name, '') != '' and docstatus < 2""", as_dict=1)
|
||||||
|
|
||||||
|
@ -1,29 +1,29 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
wn.query_reports["General Ledger"] = {
|
frappe.query_reports["General Ledger"] = {
|
||||||
"filters": [
|
"filters": [
|
||||||
{
|
{
|
||||||
"fieldname":"company",
|
"fieldname":"company",
|
||||||
"label": wn._("Company"),
|
"label": frappe._("Company"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Company",
|
"options": "Company",
|
||||||
"default": wn.defaults.get_user_default("company"),
|
"default": frappe.defaults.get_user_default("company"),
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"from_date",
|
"fieldname":"from_date",
|
||||||
"label": wn._("From Date"),
|
"label": frappe._("From Date"),
|
||||||
"fieldtype": "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,
|
"reqd": 1,
|
||||||
"width": "60px"
|
"width": "60px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"to_date",
|
"fieldname":"to_date",
|
||||||
"label": wn._("To Date"),
|
"label": frappe._("To Date"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": wn.datetime.get_today(),
|
"default": frappe.datetime.get_today(),
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"width": "60px"
|
"width": "60px"
|
||||||
},
|
},
|
||||||
@ -32,11 +32,11 @@ wn.query_reports["General Ledger"] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"account",
|
"fieldname":"account",
|
||||||
"label": wn._("Account"),
|
"label": frappe._("Account"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Account",
|
"options": "Account",
|
||||||
"get_query": function() {
|
"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 {
|
return {
|
||||||
"doctype": "Account",
|
"doctype": "Account",
|
||||||
"filters": {
|
"filters": {
|
||||||
@ -47,18 +47,18 @@ wn.query_reports["General Ledger"] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"voucher_no",
|
"fieldname":"voucher_no",
|
||||||
"label": wn._("Voucher No"),
|
"label": frappe._("Voucher No"),
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"group_by_voucher",
|
"fieldname":"group_by_voucher",
|
||||||
"label": wn._("Group by Voucher"),
|
"label": frappe._("Group by Voucher"),
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"default": 1
|
"default": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"group_by_account",
|
"fieldname":"group_by_account",
|
||||||
"label": wn._("Group by Account"),
|
"label": frappe._("Group by Account"),
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes.utils import cstr, flt
|
from frappe.utils import cstr, flt
|
||||||
from webnotes import _
|
from frappe import _
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
account_details = {}
|
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):
|
from tabAccount""", as_dict=1):
|
||||||
account_details.setdefault(acc.name, acc)
|
account_details.setdefault(acc.name, acc)
|
||||||
|
|
||||||
@ -23,13 +23,13 @@ def execute(filters=None):
|
|||||||
def validate_filters(filters, account_details):
|
def validate_filters(filters, account_details):
|
||||||
if filters.get("account") and filters.get("group_by_account") \
|
if filters.get("account") and filters.get("group_by_account") \
|
||||||
and account_details[filters.account].group_or_ledger == "Ledger":
|
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"):
|
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:
|
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():
|
def get_columns():
|
||||||
return ["Posting Date:Date:100", "Account:Link/Account:200", "Debit:Float:100",
|
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" \
|
group_by_condition = "group by voucher_type, voucher_no, account" \
|
||||||
if filters.get("group_by_voucher") else "group by name"
|
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,
|
sum(ifnull(debit, 0)) as debit, sum(ifnull(credit, 0)) as credit,
|
||||||
voucher_type, voucher_no, cost_center, remarks, is_opening, against
|
voucher_type, voucher_no, cost_center, remarks, is_opening, against
|
||||||
from `tabGL Entry`
|
from `tabGL Entry`
|
||||||
@ -64,7 +64,7 @@ def get_gl_entries(filters):
|
|||||||
def get_conditions(filters):
|
def get_conditions(filters):
|
||||||
conditions = []
|
conditions = []
|
||||||
if filters.get("account"):
|
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
|
conditions.append("""account in (select name from tabAccount
|
||||||
where lft>=%s and rgt<=%s and docstatus<2)""" % (lft, rgt))
|
where lft>=%s and rgt<=%s and docstatus<2)""" % (lft, rgt))
|
||||||
else:
|
else:
|
||||||
@ -74,7 +74,7 @@ def get_conditions(filters):
|
|||||||
conditions.append("voucher_no=%(voucher_no)s")
|
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")
|
match_conditions = build_match_conditions("GL Entry")
|
||||||
if match_conditions: conditions.append(match_conditions)
|
if match_conditions: conditions.append(match_conditions)
|
||||||
|
|
||||||
@ -121,9 +121,9 @@ def get_data_with_opening_closing(filters, account_details, gl_entries):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
def initialize_gle_map(gl_entries):
|
def initialize_gle_map(gl_entries):
|
||||||
gle_map = webnotes._dict()
|
gle_map = frappe._dict()
|
||||||
for gle in gl_entries:
|
for gle in gl_entries:
|
||||||
gle_map.setdefault(gle.account, webnotes._dict({
|
gle_map.setdefault(gle.account, frappe._dict({
|
||||||
"opening": 0,
|
"opening": 0,
|
||||||
"entries": [],
|
"entries": [],
|
||||||
"total_debit": 0,
|
"total_debit": 0,
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
wn.query_reports["Gross Profit"] = {
|
frappe.query_reports["Gross Profit"] = {
|
||||||
"filters": [
|
"filters": [
|
||||||
{
|
{
|
||||||
"fieldname":"company",
|
"fieldname":"company",
|
||||||
"label": wn._("Company"),
|
"label": frappe._("Company"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Company",
|
"options": "Company",
|
||||||
"default": wn.defaults.get_user_default("company")
|
"default": frappe.defaults.get_user_default("company")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"from_date",
|
"fieldname":"from_date",
|
||||||
"label": wn._("From Date"),
|
"label": frappe._("From Date"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": wn.defaults.get_user_default("year_start_date")
|
"default": frappe.defaults.get_user_default("year_start_date")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"to_date",
|
"fieldname":"to_date",
|
||||||
"label": wn._("To Date"),
|
"label": frappe._("To Date"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": wn.defaults.get_user_default("year_end_date")
|
"default": frappe.defaults.get_user_default("year_end_date")
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -2,8 +2,8 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes.utils import flt
|
from frappe.utils import flt
|
||||||
from erpnext.stock.utils import get_buying_amount, get_sales_bom_buying_amount
|
from erpnext.stock.utils import get_buying_amount, get_sales_bom_buying_amount
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
@ -22,7 +22,7 @@ def execute(filters=None):
|
|||||||
for row in source:
|
for row in source:
|
||||||
selling_amount = flt(row.base_amount)
|
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):
|
if item_sales_bom_map.get(row.item_code):
|
||||||
buying_amount = get_sales_bom_buying_amount(row.item_code, row.warehouse,
|
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"
|
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 = {}
|
out = {}
|
||||||
for r in res:
|
for r in res:
|
||||||
@ -73,11 +73,11 @@ def get_stock_ledger_entries(filters):
|
|||||||
def get_item_sales_bom():
|
def get_item_sales_bom():
|
||||||
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
|
item_code, warehouse, -1*qty as total_qty, parent_detail_docname
|
||||||
from `tabPacked Item` where docstatus=1""", as_dict=True):
|
from `tabPacked Item` where docstatus=1""", as_dict=True):
|
||||||
item_sales_bom.setdefault(d.parenttype, webnotes._dict()).setdefault(d.parent,
|
item_sales_bom.setdefault(d.parenttype, frappe._dict()).setdefault(d.parent,
|
||||||
webnotes._dict()).setdefault(d.parent_item, []).append(d)
|
frappe._dict()).setdefault(d.parent_item, []).append(d)
|
||||||
|
|
||||||
return item_sales_bom
|
return item_sales_bom
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ def get_source_data(filters):
|
|||||||
if filters.get("to_date"):
|
if filters.get("to_date"):
|
||||||
conditions += " and posting_date<=%(to_date)s"
|
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,
|
dn.posting_date, dn.posting_time, dn.project_name,
|
||||||
item.item_code, item.item_name, item.description, item.warehouse,
|
item.item_code, item.item_name, item.description, item.warehouse,
|
||||||
item.qty, item.base_rate, item.base_amount, item.name as "item_row",
|
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
|
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)
|
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,
|
si.posting_date, si.posting_time, si.project_name,
|
||||||
item.item_code, item.item_name, item.description, item.warehouse,
|
item.item_code, item.item_name, item.description, item.warehouse,
|
||||||
item.qty, item.base_rate, item.base_amount, item.name as "item_row",
|
item.qty, item.base_rate, item.base_amount, item.name as "item_row",
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
wn.query_reports["Item-wise Purchase Register"] = {
|
frappe.query_reports["Item-wise Purchase Register"] = {
|
||||||
"filters": [
|
"filters": [
|
||||||
{
|
{
|
||||||
"fieldname":"from_date",
|
"fieldname":"from_date",
|
||||||
"label": wn._("From Date"),
|
"label": frappe._("From Date"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": wn.defaults.get_user_default("year_start_date"),
|
"default": frappe.defaults.get_user_default("year_start_date"),
|
||||||
"width": "80"
|
"width": "80"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"to_date",
|
"fieldname":"to_date",
|
||||||
"label": wn._("To Date"),
|
"label": frappe._("To Date"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": get_today()
|
"default": get_today()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "item_code",
|
"fieldname": "item_code",
|
||||||
"label": wn._("Item"),
|
"label": frappe._("Item"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Item",
|
"options": "Item",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"account",
|
"fieldname":"account",
|
||||||
"label": wn._("Account"),
|
"label": frappe._("Account"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Account",
|
"options": "Account",
|
||||||
"get_query": function() {
|
"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 {
|
return {
|
||||||
"query": "accounts.utils.get_account_list",
|
"query": "accounts.utils.get_account_list",
|
||||||
"filters": {
|
"filters": {
|
||||||
@ -42,10 +42,10 @@ wn.query_reports["Item-wise Purchase Register"] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"company",
|
"fieldname":"company",
|
||||||
"label": wn._("Company"),
|
"label": frappe._("Company"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Company",
|
"options": "Company",
|
||||||
"default": wn.defaults.get_default("company")
|
"default": frappe.defaults.get_default("company")
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -2,8 +2,8 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes.utils import flt
|
from frappe.utils import flt
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
if not filters: filters = {}
|
if not filters: filters = {}
|
||||||
@ -55,9 +55,9 @@ def get_conditions(filters):
|
|||||||
|
|
||||||
def get_items(filters):
|
def get_items(filters):
|
||||||
conditions = get_conditions(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.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.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
|
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)
|
order by pi.posting_date desc, pi_item.item_code desc""" % (conditions, match_conditions), filters, as_dict=1)
|
||||||
|
|
||||||
def get_aii_accounts():
|
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):
|
def get_tax_accounts(item_list, columns):
|
||||||
import json
|
import json
|
||||||
item_tax = {}
|
item_tax = {}
|
||||||
tax_accounts = []
|
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'
|
from `tabPurchase Taxes and Charges` where parenttype = 'Purchase Invoice'
|
||||||
and docstatus = 1 and ifnull(account_head, '') != '' and category in ('Total', 'Valuation and Total')
|
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]))
|
and parent in (%s)""" % ', '.join(['%s']*len(item_list)), tuple([item.parent for item in item_list]))
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// 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": [
|
"filters": [
|
||||||
{
|
{
|
||||||
"fieldname":"from_date",
|
"fieldname":"from_date",
|
||||||
"label": wn._("From Date"),
|
"label": frappe._("From Date"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": wn.defaults.get_default("year_start_date"),
|
"default": frappe.defaults.get_default("year_start_date"),
|
||||||
"width": "80"
|
"width": "80"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"to_date",
|
"fieldname":"to_date",
|
||||||
"label": wn._("To Date"),
|
"label": frappe._("To Date"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": get_today()
|
"default": get_today()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"account",
|
"fieldname":"account",
|
||||||
"label": wn._("Account"),
|
"label": frappe._("Account"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Account",
|
"options": "Account",
|
||||||
"get_query": function() {
|
"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 {
|
return {
|
||||||
"query": "accounts.utils.get_account_list",
|
"query": "accounts.utils.get_account_list",
|
||||||
"filters": {
|
"filters": {
|
||||||
@ -36,10 +36,10 @@ wn.query_reports["Item-wise Sales Register"] = wn.query_reports["Sales Register"
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"company",
|
"fieldname":"company",
|
||||||
"label": wn._("Company"),
|
"label": frappe._("Company"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Company",
|
"options": "Company",
|
||||||
"default": wn.defaults.get_default("company")
|
"default": frappe.defaults.get_default("company")
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -2,8 +2,8 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes.utils import flt
|
from frappe.utils import flt
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
if not filters: filters = {}
|
if not filters: filters = {}
|
||||||
@ -55,7 +55,7 @@ def get_conditions(filters):
|
|||||||
|
|
||||||
def get_items(filters):
|
def get_items(filters):
|
||||||
conditions = get_conditions(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.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.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
|
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 = {}
|
item_tax = {}
|
||||||
tax_accounts = []
|
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'
|
from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice'
|
||||||
and docstatus = 1 and ifnull(account_head, '') != ''
|
and docstatus = 1 and ifnull(account_head, '') != ''
|
||||||
and parent in (%s)""" % ', '.join(['%s']*len(item_list)),
|
and parent in (%s)""" % ', '.join(['%s']*len(item_list)),
|
||||||
|
@ -1,30 +1,30 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// 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": [
|
"filters": [
|
||||||
{
|
{
|
||||||
fieldname: "from_date",
|
fieldname: "from_date",
|
||||||
label: wn._("From Date"),
|
label: frappe._("From Date"),
|
||||||
fieldtype: "Date",
|
fieldtype: "Date",
|
||||||
default: wn.defaults.get_user_default("year_start_date"),
|
default: frappe.defaults.get_user_default("year_start_date"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname:"to_date",
|
fieldname:"to_date",
|
||||||
label: wn._("To Date"),
|
label: frappe._("To Date"),
|
||||||
fieldtype: "Date",
|
fieldtype: "Date",
|
||||||
default: get_today()
|
default: get_today()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname:"payment_type",
|
fieldname:"payment_type",
|
||||||
label: wn._("Payment Type"),
|
label: frappe._("Payment Type"),
|
||||||
fieldtype: "Select",
|
fieldtype: "Select",
|
||||||
options: "Incoming\nOutgoing",
|
options: "Incoming\nOutgoing",
|
||||||
default: "Incoming"
|
default: "Incoming"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname:"account",
|
fieldname:"account",
|
||||||
label: wn._("Account"),
|
label: frappe._("Account"),
|
||||||
fieldtype: "Link",
|
fieldtype: "Link",
|
||||||
options: "Account",
|
options: "Account",
|
||||||
get_query: function() {
|
get_query: function() {
|
||||||
@ -32,17 +32,17 @@ wn.query_reports["Payment Period Based On Invoice Date"] = {
|
|||||||
query: "accounts.utils.get_account_list",
|
query: "accounts.utils.get_account_list",
|
||||||
filters: {
|
filters: {
|
||||||
is_pl_account: "No",
|
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",
|
fieldname:"company",
|
||||||
label: wn._("Company"),
|
label: frappe._("Company"),
|
||||||
fieldtype: "Link",
|
fieldtype: "Link",
|
||||||
options: "Company",
|
options: "Company",
|
||||||
default: wn.defaults.get_default("company")
|
default: frappe.defaults.get_default("company")
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -2,8 +2,8 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes import msgprint, _
|
from frappe import msgprint, _
|
||||||
from erpnext.accounts.report.accounts_receivable.accounts_receivable import get_ageing_data
|
from erpnext.accounts.report.accounts_receivable.accounts_receivable import get_ageing_data
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
@ -58,7 +58,7 @@ def get_conditions(filters):
|
|||||||
else:
|
else:
|
||||||
cond += " and master_type = 'Supplier'"
|
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)
|
where ifnull(master_name, '')!='' and docstatus < 2 %s""" % cond)
|
||||||
|
|
||||||
if party_accounts:
|
if party_accounts:
|
||||||
@ -74,7 +74,7 @@ def get_conditions(filters):
|
|||||||
|
|
||||||
def get_entries(filters):
|
def get_entries(filters):
|
||||||
conditions, party_accounts = get_conditions(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,
|
jvd.against_voucher, jvd.against_invoice, jvd.debit, jvd.credit,
|
||||||
jv.cheque_no, jv.cheque_date, jv.remark
|
jv.cheque_no, jv.cheque_date, jv.remark
|
||||||
from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
|
from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
|
||||||
@ -86,10 +86,10 @@ def get_entries(filters):
|
|||||||
def get_invoice_posting_date_map(filters):
|
def get_invoice_posting_date_map(filters):
|
||||||
invoice_posting_date_map = {}
|
invoice_posting_date_map = {}
|
||||||
if filters.get("payment_type") == "Incoming":
|
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]
|
invoice_posting_date_map[t[0]] = t[1]
|
||||||
else:
|
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]
|
invoice_posting_date_map[t[0]] = t[1]
|
||||||
|
|
||||||
return invoice_posting_date_map
|
return invoice_posting_date_map
|
@ -1,8 +1,8 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// 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()
|
filters: get_filters()
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from erpnext.controllers.trends import get_columns,get_data
|
from erpnext.controllers.trends import get_columns,get_data
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
wn.query_reports["Purchase Register"] = {
|
frappe.query_reports["Purchase Register"] = {
|
||||||
"filters": [
|
"filters": [
|
||||||
{
|
{
|
||||||
"fieldname":"from_date",
|
"fieldname":"from_date",
|
||||||
"label": wn._("From Date"),
|
"label": frappe._("From Date"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": wn.defaults.get_user_default("year_start_date"),
|
"default": frappe.defaults.get_user_default("year_start_date"),
|
||||||
"width": "80"
|
"width": "80"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"to_date",
|
"fieldname":"to_date",
|
||||||
"label": wn._("To Date"),
|
"label": frappe._("To Date"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": get_today()
|
"default": get_today()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"account",
|
"fieldname":"account",
|
||||||
"label": wn._("Account"),
|
"label": frappe._("Account"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Account",
|
"options": "Account",
|
||||||
"get_query": function() {
|
"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 {
|
return {
|
||||||
"query": "accounts.utils.get_account_list",
|
"query": "accounts.utils.get_account_list",
|
||||||
"filters": {
|
"filters": {
|
||||||
@ -36,10 +36,10 @@ wn.query_reports["Purchase Register"] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"company",
|
"fieldname":"company",
|
||||||
"label": wn._("Company"),
|
"label": frappe._("Company"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Company",
|
"options": "Company",
|
||||||
"default": wn.defaults.get_default("company")
|
"default": frappe.defaults.get_default("company")
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -2,9 +2,9 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes.utils import flt
|
from frappe.utils import flt
|
||||||
from webnotes import msgprint, _
|
from frappe import msgprint, _
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
if not filters: filters = {}
|
if not filters: filters = {}
|
||||||
@ -72,12 +72,12 @@ def get_columns(invoice_list):
|
|||||||
expense_accounts = tax_accounts = expense_columns = tax_columns = []
|
expense_accounts = tax_accounts = expense_columns = tax_columns = []
|
||||||
|
|
||||||
if invoice_list:
|
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, '') != ''
|
from `tabPurchase Invoice Item` where docstatus = 1 and ifnull(expense_account, '') != ''
|
||||||
and parent in (%s) order by expense_account""" %
|
and parent in (%s) order by expense_account""" %
|
||||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
|
', '.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'
|
from `tabPurchase Taxes and Charges` where parenttype = 'Purchase Invoice'
|
||||||
and docstatus = 1 and ifnull(account_head, '') != '' and category in ('Total', 'Valuation and Total')
|
and docstatus = 1 and ifnull(account_head, '') != '' and category in ('Total', 'Valuation and Total')
|
||||||
and parent in (%s) order by account_head""" %
|
and parent in (%s) order by account_head""" %
|
||||||
@ -109,26 +109,26 @@ def get_conditions(filters):
|
|||||||
|
|
||||||
def get_invoices(filters):
|
def get_invoices(filters):
|
||||||
conditions = get_conditions(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
|
bill_no, bill_date, remarks, net_total, grand_total, outstanding_amount
|
||||||
from `tabPurchase Invoice` where docstatus = 1 %s
|
from `tabPurchase Invoice` where docstatus = 1 %s
|
||||||
order by posting_date desc, name desc""" % conditions, filters, as_dict=1)
|
order by posting_date desc, name desc""" % conditions, filters, as_dict=1)
|
||||||
|
|
||||||
|
|
||||||
def get_invoice_expense_map(invoice_list):
|
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""" %
|
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)
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||||
|
|
||||||
invoice_expense_map = {}
|
invoice_expense_map = {}
|
||||||
for d in expense_details:
|
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)
|
invoice_expense_map[d.parent][d.expense_account] = flt(d.amount)
|
||||||
|
|
||||||
return invoice_expense_map
|
return invoice_expense_map
|
||||||
|
|
||||||
def get_invoice_tax_map(invoice_list, invoice_expense_map, expense_accounts):
|
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""" %
|
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)
|
', '.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:
|
else:
|
||||||
invoice_expense_map[d.parent][d.account_head] = flt(d.tax_amount)
|
invoice_expense_map[d.parent][d.account_head] = flt(d.tax_amount)
|
||||||
else:
|
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)
|
invoice_tax_map[d.parent][d.account_head] = flt(d.tax_amount)
|
||||||
|
|
||||||
return invoice_expense_map, invoice_tax_map
|
return invoice_expense_map, invoice_tax_map
|
||||||
|
|
||||||
def get_invoice_po_pr_map(invoice_list):
|
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)
|
project_name from `tabPurchase Invoice Item` where parent in (%s)
|
||||||
and (ifnull(purchase_order, '') != '' or ifnull(purchase_receipt, '') != '')""" %
|
and (ifnull(purchase_order, '') != '' or ifnull(purchase_receipt, '') != '')""" %
|
||||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
', '.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 = {}
|
invoice_po_pr_map = {}
|
||||||
for d in pi_items:
|
for d in pi_items:
|
||||||
if d.purchase_order:
|
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)
|
"purchase_order", []).append(d.purchase_order)
|
||||||
if d.purchase_receipt:
|
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)
|
"purchase_receipt", []).append(d.purchase_receipt)
|
||||||
if d.project_name:
|
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)
|
"project_name", []).append(d.project_name)
|
||||||
|
|
||||||
return invoice_po_pr_map
|
return invoice_po_pr_map
|
||||||
@ -168,7 +168,7 @@ def get_invoice_po_pr_map(invoice_list):
|
|||||||
def get_account_details(invoice_list):
|
def get_account_details(invoice_list):
|
||||||
account_map = {}
|
account_map = {}
|
||||||
accounts = list(set([inv.credit_to for inv in invoice_list]))
|
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):
|
where name in (%s)""" % ", ".join(["%s"]*len(accounts)), tuple(accounts), as_dict=1):
|
||||||
account_map[acc.name] = acc.parent_account
|
account_map[acc.name] = acc.parent_account
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// 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()
|
filters: get_filters()
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from erpnext.controllers.trends import get_columns,get_data
|
from erpnext.controllers.trends import get_columns,get_data
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
wn.query_reports["Sales Register"] = {
|
frappe.query_reports["Sales Register"] = {
|
||||||
"filters": [
|
"filters": [
|
||||||
{
|
{
|
||||||
"fieldname":"from_date",
|
"fieldname":"from_date",
|
||||||
"label": wn._("From Date"),
|
"label": frappe._("From Date"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": wn.defaults.get_default("year_start_date"),
|
"default": frappe.defaults.get_default("year_start_date"),
|
||||||
"width": "80"
|
"width": "80"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"to_date",
|
"fieldname":"to_date",
|
||||||
"label": wn._("To Date"),
|
"label": frappe._("To Date"),
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"default": get_today()
|
"default": get_today()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"account",
|
"fieldname":"account",
|
||||||
"label": wn._("Account"),
|
"label": frappe._("Account"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Account",
|
"options": "Account",
|
||||||
"get_query": function() {
|
"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 {
|
return {
|
||||||
"query": "accounts.utils.get_account_list",
|
"query": "accounts.utils.get_account_list",
|
||||||
"filters": {
|
"filters": {
|
||||||
@ -36,10 +36,10 @@ wn.query_reports["Sales Register"] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"company",
|
"fieldname":"company",
|
||||||
"label": wn._("Company"),
|
"label": frappe._("Company"),
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Company",
|
"options": "Company",
|
||||||
"default": wn.defaults.get_default("company")
|
"default": frappe.defaults.get_default("company")
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -2,9 +2,9 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
from webnotes.utils import flt
|
from frappe.utils import flt
|
||||||
from webnotes import msgprint, _
|
from frappe import msgprint, _
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
if not filters: filters = {}
|
if not filters: filters = {}
|
||||||
@ -72,12 +72,12 @@ def get_columns(invoice_list):
|
|||||||
income_accounts = tax_accounts = income_columns = tax_columns = []
|
income_accounts = tax_accounts = income_columns = tax_columns = []
|
||||||
|
|
||||||
if invoice_list:
|
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)
|
from `tabSales Invoice Item` where docstatus = 1 and parent in (%s)
|
||||||
order by income_account""" %
|
order by income_account""" %
|
||||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
|
', '.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'
|
from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice'
|
||||||
and docstatus = 1 and ifnull(tax_amount_after_discount_amount, 0) != 0
|
and docstatus = 1 and ifnull(tax_amount_after_discount_amount, 0) != 0
|
||||||
and parent in (%s) order by account_head""" %
|
and parent in (%s) order by account_head""" %
|
||||||
@ -107,26 +107,26 @@ def get_conditions(filters):
|
|||||||
|
|
||||||
def get_invoices(filters):
|
def get_invoices(filters):
|
||||||
conditions = get_conditions(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
|
customer_name, remarks, net_total, grand_total, rounded_total, outstanding_amount
|
||||||
from `tabSales Invoice`
|
from `tabSales Invoice`
|
||||||
where docstatus = 1 %s order by posting_date desc, name desc""" %
|
where docstatus = 1 %s order by posting_date desc, name desc""" %
|
||||||
conditions, filters, as_dict=1)
|
conditions, filters, as_dict=1)
|
||||||
|
|
||||||
def get_invoice_income_map(invoice_list):
|
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""" %
|
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)
|
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
||||||
|
|
||||||
invoice_income_map = {}
|
invoice_income_map = {}
|
||||||
for d in income_details:
|
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)
|
invoice_income_map[d.parent][d.income_account] = flt(d.amount)
|
||||||
|
|
||||||
return invoice_income_map
|
return invoice_income_map
|
||||||
|
|
||||||
def get_invoice_tax_map(invoice_list, invoice_income_map, income_accounts):
|
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
|
sum(tax_amount_after_discount_amount) as tax_amount
|
||||||
from `tabSales Taxes and Charges` where parent in (%s) group by parent, account_head""" %
|
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)
|
', '.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:
|
else:
|
||||||
invoice_income_map[d.parent][d.account_head] = flt(d.tax_amount)
|
invoice_income_map[d.parent][d.account_head] = flt(d.tax_amount)
|
||||||
else:
|
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)
|
invoice_tax_map[d.parent][d.account_head] = flt(d.tax_amount)
|
||||||
|
|
||||||
return invoice_income_map, invoice_tax_map
|
return invoice_income_map, invoice_tax_map
|
||||||
|
|
||||||
def get_invoice_so_dn_map(invoice_list):
|
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)
|
from `tabSales Invoice Item` where parent in (%s)
|
||||||
and (ifnull(sales_order, '') != '' or ifnull(delivery_note, '') != '')""" %
|
and (ifnull(sales_order, '') != '' or ifnull(delivery_note, '') != '')""" %
|
||||||
', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
|
', '.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 = {}
|
invoice_so_dn_map = {}
|
||||||
for d in si_items:
|
for d in si_items:
|
||||||
if d.sales_order:
|
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)
|
"sales_order", []).append(d.sales_order)
|
||||||
if d.delivery_note:
|
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)
|
"delivery_note", []).append(d.delivery_note)
|
||||||
|
|
||||||
return invoice_so_dn_map
|
return invoice_so_dn_map
|
||||||
@ -164,7 +164,7 @@ def get_invoice_so_dn_map(invoice_list):
|
|||||||
def get_customer_deatils(invoice_list):
|
def get_customer_deatils(invoice_list):
|
||||||
customer_map = {}
|
customer_map = {}
|
||||||
customers = list(set([inv.customer for inv in invoice_list]))
|
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):
|
where name in (%s)""" % ", ".join(["%s"]*len(customers)), tuple(customers), as_dict=1):
|
||||||
customer_map[cust.name] = cust.territory
|
customer_map[cust.name] = cust.territory
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ def get_customer_deatils(invoice_list):
|
|||||||
def get_account_details(invoice_list):
|
def get_account_details(invoice_list):
|
||||||
account_map = {}
|
account_map = {}
|
||||||
accounts = list(set([inv.debit_to for inv in invoice_list]))
|
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):
|
where name in (%s)""" % ", ".join(["%s"]*len(accounts)), tuple(accounts), as_dict=1):
|
||||||
account_map[acc.name] = acc.parent_account
|
account_map[acc.name] = acc.parent_account
|
||||||
|
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import frappe
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
account_map = get_account_map()
|
account_map = get_account_map()
|
||||||
columns = get_columns(account_map)
|
columns = get_columns(account_map)
|
||||||
data = []
|
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:
|
for supplier in suppliers:
|
||||||
row = [supplier[0]]
|
row = [supplier[0]]
|
||||||
for company in sorted(account_map):
|
for company in sorted(account_map):
|
||||||
@ -18,7 +18,7 @@ def execute(filters=None):
|
|||||||
return columns, data
|
return columns, data
|
||||||
|
|
||||||
def get_account_map():
|
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'
|
from `tabAccount` where master_type = 'Supplier'
|
||||||
and ifnull(master_name, '') != '' and docstatus < 2""", as_dict=1)
|
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
Loading…
x
Reference in New Issue
Block a user