From 87bed5281842515e7e044511e3a0e0ee3785847b Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 12 Jul 2013 16:55:03 +0530 Subject: [PATCH] [minor] [fix] get_query for cost center --- accounts/doctype/cost_center/cost_center.js | 6 +- .../journal_voucher/journal_voucher.js | 2 +- .../test_payment_to_invoice_matching_tool.py | 169 +----------------- accounts/doctype/pos_setting/pos_setting.js | 2 +- .../purchase_invoice/purchase_invoice.js | 2 +- .../purchase_taxes_and_charges_master.js | 2 +- .../doctype/sales_invoice/sales_invoice.js | 2 +- .../sales_taxes_and_charges_master.js | 2 +- stock/doctype/delivery_note/delivery_note.js | 2 +- 9 files changed, 11 insertions(+), 178 deletions(-) diff --git a/accounts/doctype/cost_center/cost_center.js b/accounts/doctype/cost_center/cost_center.js index d273e53e56f..ed60cc01f9e 100644 --- a/accounts/doctype/cost_center/cost_center.js +++ b/accounts/doctype/cost_center/cost_center.js @@ -38,7 +38,7 @@ cur_frm.fields_dict['budget_details'].grid.get_field('account').get_query = func var mydoc = locals[this.doctype][this.docname]; return{ filters:[ - ['Account', 'company', '=', doc.company_name], + ['Account', 'company', '=', doc.company], ['Account', 'is_pl_account', '=', 'Yes'], ['Account', 'debit_or_credit', '=', 'Debit'], ['Account', 'group_or_ledger', '!=', 'Group'], @@ -51,8 +51,8 @@ cur_frm.fields_dict['parent_cost_center'].get_query = function(doc){ return{ filters:[ ['Cost Center', 'group_or_ledger', '=', 'Group'], - ['Cost Center', 'company', '=', doc.company_name], - ['Cost Center', 'company_name', 'is not', 'NULL'] + ['Cost Center', 'company', '=', doc.company], + ['Cost Center', 'company', 'is not', 'NULL'] ] } } diff --git a/accounts/doctype/journal_voucher/journal_voucher.js b/accounts/doctype/journal_voucher/journal_voucher.js index ea077981789..6503064eff4 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.js +++ b/accounts/doctype/journal_voucher/journal_voucher.js @@ -197,7 +197,7 @@ 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 { filters: { - 'company_name': doc.company, + 'company': doc.company, 'group_or_ledger': 'Ledger' } } diff --git a/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py b/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py index 870147a7fb0..4a90928c491 100644 --- a/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py +++ b/accounts/doctype/payment_to_invoice_matching_tool/test_payment_to_invoice_matching_tool.py @@ -18,171 +18,4 @@ from __future__ import unicode_literals import unittest import webnotes -test_records = [] - -# from webnotes.model.doc import Document -# from webnotes.model.code import get_obj -# from webnotes.utils import cstr, flt -# sql = webnotes.conn.sql -# -# class TestInternalReco(unittest.TestCase): -# def setUp(self): -# webnotes.conn.begin() -# -# comp1.save(1) -# cust1.save(1) -# bank1.save(1) -# rv1.save(1) -# rv_gle.save(1) -# -# -# for t in jv1: t.save(1) -# for t in jv1[1:]: -# sql("update `tabJournal Voucher Detail` set parent = '%s' where name = '%s'" % (jv1[0].name, t.name)) -# -# ir[0].save() -# for t in ir[1:]: -# t.save(1) -# sql("update `tabPayment to Invoice Matching Tool Detail` set voucher_no = '%s', voucher_detail_no = '%s' where parent = 'Payment to Invoice Matching Tool'" % (jv1[0].name, jv1[1].name)) -# -# -# sql("update `tabGL Entry` set voucher_no = %s, against_voucher = %s where voucher_no = 'rv1'", (rv1.name, rv1.name)) -# sql("update `tabSingles` set value = %s where doctype = 'Payment to Invoice Matching Tool' and field = 'voucher_no'", rv1.name) -# -# -# self.ir = get_obj('Payment to Invoice Matching Tool', with_children=1) -# self.ir.reconcile() -# -# #=========================== -# def test_jv(self): -# """ -# Test whether JV has benn properly splitted and against doc has been updated -# """ -# amt_against_doc = [[cstr(d[0]), flt(d[1]), flt(d[2])]for d in sql("select against_invoice, debit, credit from `tabJournal Voucher Detail` where parent = %s and account = 'cust1 - c1'", jv1[0].name)] -# self.assertTrue(amt_against_doc == [[rv1.name, 0, 100.0], ['', 0, 400.0]]) -# -# #============================ -# def test_gl_entry(self): -# """ -# Check proper gl entry has been made -# """ -# gle = [[cstr(d[0]), flt(d[1])] for d in sql("select against_voucher, sum(credit) - sum(debit) from `tabGL Entry` where voucher_no = %s and account = 'cust1 - c1' and ifnull(is_cancelled, 'No') = 'No' group by against_voucher", jv1[0].name)] -# -# self.assertTrue([rv1.name, 100.0] in gle) -# self.assertTrue(['', 400.0] in gle) -# -# #============================ -# def test_outstanding(self): -# """ -# Check whether Outstanding amount has been properly updated in RV -# """ -# amt = sql("select outstanding_amount from `tabSales Invoice` where name = '%s'" % rv1.name)[0][0] -# self.assertTrue(amt == 0) -# -# #============================ -# def tearDown(self): -# webnotes.conn.rollback() -# -# -# -# -# # test data -# #--------------- -# rv1 = Document(fielddata={ -# 'doctype':'Sales Invoice', -# 'docstatus':1, -# 'debit_to':'cust1 - c1', -# 'grand_total': 100, -# 'outstanding_amount': 100, -# 'name': 'rv1' -# }) -# -# jv1 = [Document(fielddata={ -# 'doctype':'Journal Voucher', -# 'docstatus':1, -# 'cheque_no': '163567', -# 'docstatus':1, -# 'company': 'comp1', -# 'posting_date' : '2011-05-02', -# 'remark': 'test data', -# 'fiscal_year': '2011-2012', -# 'total_debit': 500, -# 'total_credit': 500 -# }), -# Document(fielddata = { -# 'parenttype':'Journal Voucher', -# 'parentfield':'entries', -# 'doctype':'Journal Voucher Detail', -# 'account' : 'cust1 - c1', -# 'credit':500, -# 'debit' : 0, -# 'docstatus':1 -# }), -# Document(fielddata = { -# 'parenttype':'Journal Voucher', -# 'parentfield':'entries', -# 'doctype':'Journal Voucher Detail', -# 'account' : 'bank1 - c1', -# 'credit':0, -# 'debit' : 500, -# 'docstatus':1 -# })] -# -# ir = [Document(fielddata = { -# 'doctype':'Payment to Invoice Matching Tool', -# 'name' : 'Payment to Invoice Matching Tool', -# 'account':'cust1 - c1', -# 'voucher_type' : 'Sales Invoice', -# 'voucher_no': 'rv1' -# }), -# Document(fielddata = { -# 'parenttype':'Payment to Invoice Matching Tool', -# 'parentfield':'ir_payment_details', -# 'doctype':'Payment to Invoice Matching Tool Detail', -# 'parent': 'Payment to Invoice Matching Tool', -# 'voucher_no': 'jv1', -# 'name' : '123112', -# 'voucher_detail_no' : 'jvd1', -# 'selected' : 1, -# 'amt_due' : 500, -# 'amt_to_be_reconciled':100 -# })] -# -# cust1 = Document(fielddata={ -# 'doctype':'Account', -# 'docstatus':0, -# 'account_name' : 'cust1', -# 'debit_or_credit': 'Debit', -# 'company' : 'comp1', -# 'lft': 1, -# 'rgt': 2 -# }) -# -# bank1 = Document(fielddata={ -# 'doctype':'Account', -# 'docstatus':0, -# 'account_name' : 'bank1', -# 'debit_or_credit': 'Debit', -# 'company' : 'comp1', -# 'lft': 3, -# 'rgt': 4 -# }) -# -# comp1 = Document(fielddata={ -# 'doctype':'Company', -# 'abbr': 'c1', -# 'company_name' : 'comp1', -# 'name': 'comp1' -# }) -# -# rv_gle = Document(fielddata={ -# 'doctype':'GL Entry', -# 'account': 'cust1 - c1', -# 'company' : 'comp1', -# 'voucher_no': 'rv1', -# 'against_voucher': 'rv1', -# 'against_voucher_type': 'Sales Invoice', -# 'voucher_type' : 'Sales Invoice', -# 'debit': 100, -# 'credit': 0 -# }) +test_records = [] \ No newline at end of file diff --git a/accounts/doctype/pos_setting/pos_setting.js b/accounts/doctype/pos_setting/pos_setting.js index 991c8daadf1..2f8beabe051 100755 --- a/accounts/doctype/pos_setting/pos_setting.js +++ b/accounts/doctype/pos_setting/pos_setting.js @@ -54,7 +54,7 @@ cur_frm.fields_dict['income_account'].get_query = function(doc,cdt,cdn) { cur_frm.fields_dict['cost_center'].get_query = function(doc,cdt,cdn) { return{ filters:{ - 'company_name': doc.company, + 'company': doc.company, 'group_or_ledger': "Ledger" } } diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.js b/accounts/doctype/purchase_invoice/purchase_invoice.js index efe0c2a990e..4afb838f687 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -216,7 +216,7 @@ cur_frm.cscript.expense_head = function(doc, cdt, cdn){ cur_frm.fields_dict["entries"].grid.get_field("cost_center").get_query = function(doc) { return { filters: { - 'company_name': doc.company, + 'company': doc.company, 'group_or_ledger': 'Ledger' } diff --git a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js index c9f78fbb332..5717bbfb25b 100644 --- a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js +++ b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js @@ -143,7 +143,7 @@ cur_frm.set_query("account_head", "purchase_tax_details", function() { cur_frm.fields_dict['purchase_tax_details'].grid.get_field("cost_center").get_query = function(doc) { return { filters: { - 'company_name': doc.company, + 'company': doc.company, 'group_or_ledger': "Ledger" } } diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 70bf03b56c4..c802622ebbe 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -287,7 +287,7 @@ cur_frm.fields_dict.write_off_cost_center.get_query = function(doc) { return{ filters:{ 'group_or_ledger': 'Ledger', - 'company_name': doc.company + 'company': doc.company } } } diff --git a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js index 9ec574ed33d..6d7f2db7041 100644 --- a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js +++ b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js @@ -148,7 +148,7 @@ cur_frm.fields_dict['other_charges'].grid.get_field("account_head").get_query = cur_frm.fields_dict['other_charges'].grid.get_field("cost_center").get_query = function(doc) { return{ - 'company_name': doc.company, + 'company': doc.company, 'group_or_ledger': "Ledger" } } diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js index 790d4096752..62d6529675e 100644 --- a/stock/doctype/delivery_note/delivery_note.js +++ b/stock/doctype/delivery_note/delivery_note.js @@ -252,7 +252,7 @@ if (sys_defaults.auto_inventory_accounting) { return { filters: { - 'company_name': doc.company, + 'company': doc.company, 'group_or_ledger': "Ledger" } }