[minor] [fix] get_query for cost center

This commit is contained in:
Nabin Hait 2013-07-12 16:55:03 +05:30
parent e102235662
commit 87bed52818
9 changed files with 11 additions and 178 deletions

View File

@ -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']
]
}
}

View File

@ -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'
}
}

View File

@ -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 = []

View File

@ -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"
}
}

View File

@ -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'
}

View File

@ -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"
}
}

View File

@ -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
}
}
}

View File

@ -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"
}
}

View File

@ -252,7 +252,7 @@ if (sys_defaults.auto_inventory_accounting) {
return {
filters: {
'company_name': doc.company,
'company': doc.company,
'group_or_ledger': "Ledger"
}
}