mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
[conflict] merged for get_query
This commit is contained in:
@@ -132,7 +132,9 @@ cur_frm.fields_dict['master_name'].get_query = function(doc) {
|
||||
|
||||
cur_frm.fields_dict['parent_account'].get_query = function(doc) {
|
||||
return {
|
||||
query: "accounts.doctype.account.account.get_parent_account",
|
||||
filters: { "company": doc.company}
|
||||
filters: {
|
||||
"group_or_ledger": "Group",
|
||||
"company": doc.company
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,10 +18,12 @@
|
||||
// -----------------------------
|
||||
cur_frm.fields_dict.invoice_details.grid.get_field("invoice_no").get_query = function(doc) {
|
||||
return {
|
||||
query: "accounts.doctype.c_form.c_form.get_invoice_nos",
|
||||
filters: {
|
||||
customer: doc.customer,
|
||||
company: doc.company
|
||||
"docstatus": 1,
|
||||
"customer": doc.customer,
|
||||
"company": doc.company,
|
||||
"c_form_applicable": 'Yes',
|
||||
"c_form_no": ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,11 +36,25 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
//Account filtering for cost center
|
||||
cur_frm.fields_dict['budget_details'].grid.get_field('account').get_query = function(doc) {
|
||||
var mydoc = locals[this.doctype][this.docname];
|
||||
return 'SELECT DISTINCT `tabAccount`.`name`,`tabAccount`.debit_or_credit,`tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.`company` = "' + doc.company + '" AND `tabAccount`.docstatus != 2 AND `tabAccount`.`is_pl_account` = "Yes" AND `tabAccount`.debit_or_credit = "Debit" AND `tabAccount`.`group_or_ledger` != "Group" AND `tabAccount`.`group_or_ledger` is not NULL AND `tabAccount`.`name` LIKE "%s" ORDER BY `tabAccount`.`name` LIMIT 50';
|
||||
return{
|
||||
filters:[
|
||||
['Account', 'company', '=', doc.company_name],
|
||||
['Account', 'is_pl_account', '=', 'Yes'],
|
||||
['Account', 'debit_or_credit', '=', 'Debit'],
|
||||
['Account', 'group_or_ledger', '!=', 'Group'],
|
||||
['Account', 'group_or_ledger', 'is not', 'NULL']
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['parent_cost_center'].get_query = function(doc){
|
||||
return 'SELECT DISTINCT `tabCost Center`.name FROM `tabCost Center` WHERE `tabCost Center`.group_or_ledger="Group" AND `tabCost Center`.docstatus != 2 AND `tabCost Center`.company="'+ doc.company+'" AND `tabCost Center`.company is not NULL AND `tabCost Center`.name LIKE "%s" ORDER BY `tabCost Center`.name LIMIT 50';
|
||||
return{
|
||||
filters:[
|
||||
['Cost Center', 'group_or_ledger', '=', 'Group'],
|
||||
['Cost Center', 'company', '=', doc.company_name],
|
||||
['Cost Center', 'company_name', 'is not', 'NULL']
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
//parent cost center
|
||||
|
||||
@@ -196,24 +196,32 @@ cur_frm.fields_dict['entries'].grid.get_field('account').get_query = function(do
|
||||
|
||||
cur_frm.fields_dict["entries"].grid.get_field("cost_center").get_query = function(doc) {
|
||||
return {
|
||||
query: "accounts.utils.get_cost_center_list",
|
||||
filters: { company: doc.company}
|
||||
filters: {
|
||||
'company_name': doc.company,
|
||||
'group_or_ledger': 'Ledger'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['entries'].grid.get_field('against_voucher').get_query = function(doc) {
|
||||
var d = locals[this.doctype][this.docname];
|
||||
return {
|
||||
query: "accounts.doctype.journal_voucher.journal_voucher.get_against_purchase_invoice",
|
||||
filters: { account: d.account }
|
||||
filters: [
|
||||
['Purchase Invoice', 'credit_to', '=', d.account],
|
||||
['Purchase Invoice', 'docstatus', '=', 1],
|
||||
['Purchase Invoice', 'outstanding_amount', '>', 0]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['entries'].grid.get_field('against_invoice').get_query = function(doc) {
|
||||
var d = locals[this.doctype][this.docname];
|
||||
return {
|
||||
query: "accounts.doctype.journal_voucher.journal_voucher.get_against_sales_invoice",
|
||||
filters: { account: d.account }
|
||||
filters: [
|
||||
['Sales Invoice', 'debit_to', '=', d.account],
|
||||
['Sales Invoice', 'docstatus', '=', 1],
|
||||
['Sales Invoice', 'outstanding_amount', '>', 0]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,11 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cur_frm.set_query("default_account", function(doc) {
|
||||
return erpnext.queries.account({
|
||||
account_type: "Bank or Cash",
|
||||
company: doc.company
|
||||
});
|
||||
return{
|
||||
query: "controllers.queries.account_query",
|
||||
filters: {
|
||||
'account_type': "Bank or Cash",
|
||||
'company': doc.company
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -36,25 +36,12 @@ cur_frm.fields_dict.voucher_no.get_query = function(doc) {
|
||||
// TO-do: check for pos, it should not come
|
||||
if (!doc.account) msgprint("Please select Account first");
|
||||
else {
|
||||
return repl("select gle.voucher_no, gle.posting_date, gle.%(account_type)s \
|
||||
from `tabGL Entry` gle \
|
||||
where gle.account = '%(acc)s' \
|
||||
and gle.voucher_type = '%(dt)s' \
|
||||
and gle.voucher_no like '%s' \
|
||||
and ifnull(gle.is_cancelled, 'No') = 'No' \
|
||||
and (ifnull(gle.against_voucher, '') = '' \
|
||||
or ifnull(gle.against_voucher, '') = gle.voucher_no ) \
|
||||
and ifnull(gle.%(account_type)s, 0) > 0 \
|
||||
and (select ifnull(abs(sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))), 0) \
|
||||
from `tabGL Entry` \
|
||||
where against_voucher_type = '%(dt)s' \
|
||||
and against_voucher = gle.voucher_no \
|
||||
and voucher_no != gle.voucher_no \
|
||||
and account = gle.account \
|
||||
and ifnull(is_cancelled, 'No') = 'No') != \
|
||||
abs(ifnull(gle.debit, 0) - ifnull(gle.credit, 0)) \
|
||||
ORDER BY gle.posting_date DESC, gle.voucher_no DESC LIMIT 50",
|
||||
{dt:doc.voucher_type, acc:doc.account, account_type: doc.account_type});
|
||||
query: "accounts.doctype.payment_to_invoice_matching_tool.payment_to_invoice_matching_tool.gl_entry_details",
|
||||
filters: {
|
||||
"dt": doc.voucher_type,
|
||||
"acc": doc.account,
|
||||
"account_type": doc.account_type
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -139,3 +139,30 @@ class DocType:
|
||||
msgprint("Successfully allocated.")
|
||||
else:
|
||||
msgprint("No amount allocated.", raise_exception=1)
|
||||
|
||||
def gl_entry_details(doctype, txt, searchfield, start, page_len, filters):
|
||||
from controllers.queries import get_match_cond
|
||||
|
||||
return webnotes.conn.sql("""select gle.voucher_no, gle.posting_date,
|
||||
gle.%(account_type)s from `tabGL Entry` gle
|
||||
where gle.account = '%(acc)s'
|
||||
and gle.voucher_type = '%(dt)s'
|
||||
and gle.voucher_no like '%(txt)s'
|
||||
and ifnull(gle.is_cancelled, 'No') = 'No'
|
||||
and (ifnull(gle.against_voucher, '') = ''
|
||||
or ifnull(gle.against_voucher, '') = gle.voucher_no )
|
||||
and ifnull(gle.%(account_type)s, 0) > 0
|
||||
and (select ifnull(abs(sum(ifnull(debit, 0))
|
||||
- sum(ifnull(credit, 0))), 0)
|
||||
from `tabGL Entry`
|
||||
where against_voucher_type = '%(dt)s'
|
||||
and against_voucher = gle.voucher_no
|
||||
and voucher_no != gle.voucher_no
|
||||
and ifnull(is_cancelled, 'No') = 'No')
|
||||
!= abs(ifnull(gle.debit, 0) - ifnull(gle.credit, 0)
|
||||
)
|
||||
%(mcond)s
|
||||
ORDER BY gle.posting_date desc, gle.voucher_no desc
|
||||
limit %(start)s, %(page_len)s""" % {dt:filters["dt"], acc:filters["acc"],
|
||||
account_type: filters['account_type'], 'mcond':get_match_cond(doctype, searchfield)
|
||||
'txt': "%%%s%%" % txt,"start": start, "page_len": page_len})
|
||||
@@ -23,5 +23,13 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
|
||||
// ***************** Get Account Head *****************
|
||||
cur_frm.fields_dict['closing_account_head'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT `tabAccount`.name FROM `tabAccount` WHERE `tabAccount`.is_pl_account = "No" AND `tabAccount`.debit_or_credit = "Credit" AND `tabAccount`.company = "'+ cstr(doc.company) +'" AND ifnull(`tabAccount`.freeze_account, "No") = "No" AND `tabAccount`.group_or_ledger = "Ledger" AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name ASC LIMIT 50';
|
||||
return{
|
||||
filters:{
|
||||
'is_pl_account': "No",
|
||||
"debit_or_credit": "Credit",
|
||||
"company": doc.company,
|
||||
"freeze_account": "No",
|
||||
"group_or_ledger": "Ledger"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,43 +25,72 @@ cur_frm.cscript.onload = function(doc,cdt,cdn){
|
||||
//cash bank account
|
||||
//------------------------------------
|
||||
cur_frm.fields_dict['cash_bank_account'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||
return{
|
||||
filters:{
|
||||
'debit_or_credit': "Debit",
|
||||
'is_pl_account': "No",
|
||||
'group_or_ledger': "Ledger",
|
||||
'company': doc.company
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Income Account
|
||||
// --------------------------------
|
||||
cur_frm.fields_dict['income_account'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Credit" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.account_type ="Income Account" AND tabAccount.%(key)s LIKE "%s"'
|
||||
return{
|
||||
filters:{
|
||||
'debit_or_credit': "Credit",
|
||||
'group_or_ledger': "Ledger",
|
||||
'company': doc.company,
|
||||
'account_type': "Income Account"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Cost Center
|
||||
// -----------------------------
|
||||
cur_frm.fields_dict['cost_center'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company` = "' +doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.`docstatus`!= 2 ORDER BY `tabCost Center`.`name` ASC LIMIT 50';
|
||||
return{
|
||||
filters:{
|
||||
'company_name': doc.company,
|
||||
'group_or_ledger': "Ledger"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//get query select Territory
|
||||
//=================================================================
|
||||
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||
return{
|
||||
filters:{
|
||||
'is_group': "No"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------ Get Print Heading ------------------------------------
|
||||
cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT `tabPrint Heading`.name FROM `tabPrint Heading` WHERE `tabPrint Heading`.docstatus !=2 AND `tabPrint Heading`.name LIKE "%s" ORDER BY `tabPrint Heading`.name ASC LIMIT 50';
|
||||
return{
|
||||
filters:[
|
||||
['Print Heading', 'docstatus', '!=', 2]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict["expense_account"].get_query = function(doc) {
|
||||
return {
|
||||
"query": "accounts.utils.get_account_list",
|
||||
"filters": {
|
||||
filters: {
|
||||
"is_pl_account": "Yes",
|
||||
"debit_or_credit": "Debit",
|
||||
"company": doc.company
|
||||
"company": doc.company,
|
||||
"group_or_ledger": "Ledger"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.user.get_query = erpnext.utils.profile_query;
|
||||
cur_frm.fields_dict.user.get_query = function(doc,cdt,cdn) {
|
||||
return{ query:"controllers.queries.profile_query"}
|
||||
}
|
||||
|
||||
@@ -152,30 +152,55 @@ cur_frm.cscript.make_bank_voucher = function() {
|
||||
|
||||
|
||||
cur_frm.fields_dict['supplier_address'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT name,address_line1,city FROM tabAddress WHERE supplier = "'+ doc.supplier +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
|
||||
return{
|
||||
filters:{'supplier': doc.supplier}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE supplier = "'+ doc.supplier +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
|
||||
return{
|
||||
filters:{'supplier': doc.supplier}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['entries'].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
|
||||
return erpnext.queries.item({
|
||||
'ifnull(tabItem.is_purchase_item, "No")': 'Yes'
|
||||
})
|
||||
return {
|
||||
query:"controllers.queries.item_query",
|
||||
filters:{
|
||||
'is_purchase_item': 'Yes'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['credit_to'].get_query = function(doc) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Credit" AND tabAccount.is_pl_account="No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||
return{
|
||||
filters:{
|
||||
'debit_or_credit': 'Credit',
|
||||
'is_pl_account': 'No',
|
||||
'group_or_ledger': 'Ledger',
|
||||
'company': doc.company
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get Print Heading
|
||||
cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT `tabPrint Heading`.name FROM `tabPrint Heading` WHERE `tabPrint Heading`.docstatus !=2 AND `tabPrint Heading`.name LIKE "%s" ORDER BY `tabPrint Heading`.name ASC LIMIT 50';
|
||||
return{
|
||||
filters:[
|
||||
['Print Heading', 'docstatus', '!=', 2]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['entries'].grid.get_field("expense_head").get_query = function(doc) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE (tabAccount.debit_or_credit="Debit" OR tabAccount.account_type = "Expense Account") AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"';
|
||||
return{
|
||||
filters:{
|
||||
'debit_or_credit':'Debit',
|
||||
'account_type': 'Expense Account',
|
||||
'group_or_ledger': 'Ledger',
|
||||
'company': doc.company
|
||||
}
|
||||
}
|
||||
}
|
||||
cur_frm.cscript.expense_head = function(doc, cdt, cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
@@ -190,8 +215,11 @@ cur_frm.cscript.expense_head = function(doc, cdt, cdn){
|
||||
|
||||
cur_frm.fields_dict["entries"].grid.get_field("cost_center").get_query = function(doc) {
|
||||
return {
|
||||
query: "accounts.utils.get_cost_center_list",
|
||||
filters: { company: doc.company}
|
||||
filters: {
|
||||
'company_name': doc.company,
|
||||
'group_or_ledger': 'Ledger'
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,9 +260,11 @@ cur_frm.cscript.make_jv = function(doc, dt, dn, bank_account) {
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['entries'].grid.get_field('project_name').get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT `tabProject`.name FROM `tabProject` \
|
||||
WHERE `tabProject`.status not in ("Completed", "Cancelled") \
|
||||
AND `tabProject`.name LIKE "%s" ORDER BY `tabProject`.name ASC LIMIT 50';
|
||||
return{
|
||||
filters:[
|
||||
['Project', 'status', 'not in', 'Completed, Cancelled']
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -127,18 +127,28 @@ cur_frm.cscript.row_id = function(doc, cdt, cdn) {
|
||||
refresh_field('row_id',d.name,'purchase_tax_details');
|
||||
}
|
||||
|
||||
/*---------------------- Get rate if account_head has account_type as TAX or CHARGEABLE-------------------------------------*/
|
||||
|
||||
cur_frm.fields_dict['purchase_tax_details'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND (tabAccount.account_type in ("Tax", "Chargeable", "Expense Account") or (tabAccount.is_pl_account = "Yes" and tabAccount.debit_or_credit = "Debit")) AND tabAccount.company = "' + doc.company + '" AND tabAccount.name LIKE "%s"'
|
||||
}
|
||||
|
||||
cur_frm.set_query("account_head", "purchase_tax_details", function() {
|
||||
return {
|
||||
filters: [
|
||||
["Account", "group_or_ledger", "=", "Ledger"],
|
||||
["Account", "docstatus", "!=", 2],
|
||||
["Account", "account_type", "in", "Tax, Chargeable, Expense Account"],
|
||||
["Account", "is_pl_account", "=", "Yes"],
|
||||
["Account", "debit_or_credit", "=", "Debit"],
|
||||
["Account", "company", "=", doc.company]
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
cur_frm.fields_dict['purchase_tax_details'].grid.get_field("cost_center").get_query = function(doc) {
|
||||
return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company` = "' +doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.`docstatus`!= 2 ORDER BY `tabCost Center`.`name` ASC LIMIT 50';
|
||||
return {
|
||||
filters: {
|
||||
'company_name': doc.company,
|
||||
'group_or_ledger': "Ledger"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.account_head = function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if(!d.charge_type && d.account_head){
|
||||
|
||||
@@ -249,55 +249,84 @@ cur_frm.cscript.make_bank_voucher = function() {
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.debit_to.get_query = function(doc) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||
return{
|
||||
filters: {
|
||||
'debit_or_credit': 'Debit',
|
||||
'is_pl_account': 'No',
|
||||
'group_or_ledger': 'Ledger',
|
||||
'company': doc.company
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.cash_bank_account.get_query = function(doc) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||
return{
|
||||
filters: {
|
||||
'debit_or_credit': 'Debit',
|
||||
'is_pl_account': 'No',
|
||||
'group_or_ledger': 'Ledger',
|
||||
'company': doc.company
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.write_off_account.get_query = function(doc) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "Yes" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
|
||||
return{
|
||||
filters:{
|
||||
'debit_or_credit': 'Debit',
|
||||
'is_pl_account': 'Yes',
|
||||
'group_or_ledger': 'Ledger',
|
||||
'company': doc.company
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Write off cost center
|
||||
//-----------------------
|
||||
cur_frm.fields_dict.write_off_cost_center.get_query = function(doc) {
|
||||
return 'SELECT `tabCost Center`.name FROM `tabCost Center` WHERE `tabCost Center`.group_or_ledger="Ledger" AND `tabCost Center`.docstatus!=2 AND `tabCost Center`.company="'+doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s"'
|
||||
return{
|
||||
filters:{
|
||||
'group_or_ledger': 'Ledger',
|
||||
'company_name': doc.company
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//project name
|
||||
//--------------------------
|
||||
cur_frm.fields_dict['project_name'].get_query = function(doc, cdt, cdn) {
|
||||
var cond = '';
|
||||
if(doc.customer) cond = '(`tabProject`.customer = "'+doc.customer+'" OR IFNULL(`tabProject`.customer,"")="") AND';
|
||||
return repl('SELECT `tabProject`.name FROM `tabProject` \
|
||||
WHERE `tabProject`.status not in ("Completed", "Cancelled") \
|
||||
AND %(cond)s `tabProject`.name LIKE "%s" \
|
||||
ORDER BY `tabProject`.name ASC LIMIT 50', {cond:cond});
|
||||
return{
|
||||
query: "controllers.queries.get_project_name",
|
||||
filters: {'customer': doc.customer}
|
||||
}
|
||||
}
|
||||
|
||||
//Territory
|
||||
//-----------------------------
|
||||
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||
return{
|
||||
filters: {'is_group': 'NO'}
|
||||
}
|
||||
}
|
||||
|
||||
// Income Account in Details Table
|
||||
// --------------------------------
|
||||
cur_frm.set_query("income_account", "entries", function(doc) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE (tabAccount.debit_or_credit="Credit" OR tabAccount.account_type = "Income Account") AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"';
|
||||
})
|
||||
return{
|
||||
query: "accounts.doctype.sales_invoice.sales_invoice.get_income_account",
|
||||
filters: {'company': doc.company}
|
||||
}
|
||||
});
|
||||
|
||||
// expense account
|
||||
if (sys_defaults.auto_inventory_accounting) {
|
||||
cur_frm.fields_dict['entries'].grid.get_field('expense_account').get_query = function(doc) {
|
||||
return {
|
||||
"query": "accounts.utils.get_account_list",
|
||||
"filters": {
|
||||
"is_pl_account": "Yes",
|
||||
"debit_or_credit": "Debit",
|
||||
"company": doc.company
|
||||
filters: {
|
||||
'is_pl_account': 'Yes',
|
||||
'debit_or_credit': 'Debit',
|
||||
'company': doc.company,
|
||||
'group_or_ledger': 'Ledger'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -307,15 +336,22 @@ if (sys_defaults.auto_inventory_accounting) {
|
||||
//----------------------------
|
||||
cur_frm.fields_dict['entries'].grid.get_field('warehouse').get_query= function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
return "SELECT `tabBin`.`warehouse`, `tabBin`.`actual_qty` FROM `tabBin` WHERE `tabBin`.`item_code` = '"+ d.item_code +"' AND ifnull(`tabBin`.`actual_qty`,0) > 0 AND `tabBin`.`warehouse` like '%s' ORDER BY `tabBin`.`warehouse` DESC LIMIT 50";
|
||||
return{
|
||||
filters:[
|
||||
['Bin', 'item_code', '=', d.item_code],
|
||||
['Bin', 'actual_qty', '>', 0]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
// Cost Center in Details Table
|
||||
// -----------------------------
|
||||
cur_frm.fields_dict["entries"].grid.get_field("cost_center").get_query = function(doc) {
|
||||
return {
|
||||
query: "accounts.utils.get_cost_center_list",
|
||||
filters: { company: doc.company}
|
||||
filters: {
|
||||
'company': doc.company,
|
||||
'group_or_ledger': 'Ledger'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -984,3 +984,16 @@ def get_bank_cash_account(mode_of_payment):
|
||||
return {
|
||||
"cash_bank_account": val
|
||||
}
|
||||
|
||||
def get_income_account(doctype, txt, searchfield, start, page_len, filters):
|
||||
from controllers.queries import get_match_cond
|
||||
|
||||
return webnotes.conn.sql("""select tabAccount.name from `tabAccount`
|
||||
where (tabAccount.debit_or_credit="Credit"
|
||||
or tabAccount.account_type = "Income Account")
|
||||
and tabAccount.group_or_ledger="Ledger"
|
||||
and tabAccount.docstatus!=2
|
||||
and tabAccount.company = '%(company)s'
|
||||
and tabAccount.%(key)s LIKE '%(txt)s'
|
||||
%(mcond)s""" % {'company': filters['company'], 'key': searchfield,
|
||||
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype, searchfield)})
|
||||
@@ -137,11 +137,20 @@ cur_frm.cscript.row_id = function(doc, cdt, cdn) {
|
||||
/*---------------------- Get rate if account_head has account_type as TAX or CHARGEABLE-------------------------------------*/
|
||||
|
||||
cur_frm.fields_dict['other_charges'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND tabAccount.account_type in ("Tax", "Chargeable", "Income Account") AND tabAccount.company = "'+doc.company+'" AND tabAccount.name LIKE "%s"'
|
||||
return{
|
||||
filters:[
|
||||
['Account', 'group_or_ledger', '=', 'Ledger'],
|
||||
['Account', 'account_type', 'in', 'Tax, Chargeable, Income Account'],
|
||||
['Account', 'company', '=', doc.company]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['other_charges'].grid.get_field("cost_center").get_query = function(doc) {
|
||||
return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company` = "' +doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.`docstatus`!= 2 ORDER BY `tabCost Center`.`name` ASC LIMIT 50';
|
||||
return{
|
||||
'company_name': doc.company,
|
||||
'group_or_ledger': "Ledger"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user