Merge branch 'master' into edge
This commit is contained in:
commit
f2dc4222f9
@ -18,169 +18,171 @@ from __future__ import unicode_literals
|
|||||||
import unittest
|
import unittest
|
||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.model.doc import Document
|
test_records = []
|
||||||
from webnotes.model.code import get_obj
|
|
||||||
from webnotes.utils import cstr, flt
|
|
||||||
sql = webnotes.conn.sql
|
|
||||||
|
|
||||||
class TestInternalReco(unittest.TestCase):
|
# from webnotes.model.doc import Document
|
||||||
def setUp(self):
|
# from webnotes.model.code import get_obj
|
||||||
webnotes.conn.begin()
|
# from webnotes.utils import cstr, flt
|
||||||
|
# sql = webnotes.conn.sql
|
||||||
comp1.save(1)
|
#
|
||||||
cust1.save(1)
|
# class TestInternalReco(unittest.TestCase):
|
||||||
bank1.save(1)
|
# def setUp(self):
|
||||||
rv1.save(1)
|
# webnotes.conn.begin()
|
||||||
rv_gle.save(1)
|
#
|
||||||
|
# comp1.save(1)
|
||||||
|
# cust1.save(1)
|
||||||
for t in jv1: t.save(1)
|
# bank1.save(1)
|
||||||
for t in jv1[1:]:
|
# rv1.save(1)
|
||||||
sql("update `tabJournal Voucher Detail` set parent = '%s' where name = '%s'" % (jv1[0].name, t.name))
|
# rv_gle.save(1)
|
||||||
|
#
|
||||||
ir[0].save()
|
#
|
||||||
for t in ir[1:]:
|
# for t in jv1: t.save(1)
|
||||||
t.save(1)
|
# for t in jv1[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 `tabJournal Voucher Detail` set parent = '%s' where name = '%s'" % (jv1[0].name, t.name))
|
||||||
|
#
|
||||||
|
# ir[0].save()
|
||||||
sql("update `tabGL Entry` set voucher_no = %s, against_voucher = %s where voucher_no = 'rv1'", (rv1.name, rv1.name))
|
# for t in ir[1:]:
|
||||||
sql("update `tabSingles` set value = %s where doctype = 'Payment to Invoice Matching Tool' and field = 'voucher_no'", rv1.name)
|
# 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))
|
||||||
|
#
|
||||||
self.ir = get_obj('Payment to Invoice Matching Tool', with_children=1)
|
#
|
||||||
self.ir.reconcile()
|
# 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)
|
||||||
#===========================
|
#
|
||||||
def test_jv(self):
|
#
|
||||||
"""
|
# self.ir = get_obj('Payment to Invoice Matching Tool', with_children=1)
|
||||||
Test whether JV has benn properly splitted and against doc has been updated
|
# self.ir.reconcile()
|
||||||
"""
|
#
|
||||||
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_jv(self):
|
||||||
|
# """
|
||||||
#============================
|
# Test whether JV has benn properly splitted and against doc has been updated
|
||||||
def test_gl_entry(self):
|
# """
|
||||||
"""
|
# 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)]
|
||||||
Check proper gl entry has been made
|
# self.assertTrue(amt_against_doc == [[rv1.name, 0, 100.0], ['', 0, 400.0]])
|
||||||
"""
|
#
|
||||||
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)]
|
# #============================
|
||||||
|
# def test_gl_entry(self):
|
||||||
self.assertTrue([rv1.name, 100.0] in gle)
|
# """
|
||||||
self.assertTrue(['', 400.0] in gle)
|
# 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)]
|
||||||
def test_outstanding(self):
|
#
|
||||||
"""
|
# self.assertTrue([rv1.name, 100.0] in gle)
|
||||||
Check whether Outstanding amount has been properly updated in RV
|
# self.assertTrue(['', 400.0] in gle)
|
||||||
"""
|
#
|
||||||
amt = sql("select outstanding_amount from `tabSales Invoice` where name = '%s'" % rv1.name)[0][0]
|
# #============================
|
||||||
self.assertTrue(amt == 0)
|
# def test_outstanding(self):
|
||||||
|
# """
|
||||||
#============================
|
# Check whether Outstanding amount has been properly updated in RV
|
||||||
def tearDown(self):
|
# """
|
||||||
webnotes.conn.rollback()
|
# amt = sql("select outstanding_amount from `tabSales Invoice` where name = '%s'" % rv1.name)[0][0]
|
||||||
|
# self.assertTrue(amt == 0)
|
||||||
|
#
|
||||||
|
# #============================
|
||||||
|
# def tearDown(self):
|
||||||
# test data
|
# webnotes.conn.rollback()
|
||||||
#---------------
|
#
|
||||||
rv1 = Document(fielddata={
|
#
|
||||||
'doctype':'Sales Invoice',
|
#
|
||||||
'docstatus':1,
|
#
|
||||||
'debit_to':'cust1 - c1',
|
# # test data
|
||||||
'grand_total': 100,
|
# #---------------
|
||||||
'outstanding_amount': 100,
|
# rv1 = Document(fielddata={
|
||||||
'name': 'rv1'
|
# 'doctype':'Sales Invoice',
|
||||||
})
|
# 'docstatus':1,
|
||||||
|
# 'debit_to':'cust1 - c1',
|
||||||
jv1 = [Document(fielddata={
|
# 'grand_total': 100,
|
||||||
'doctype':'Journal Voucher',
|
# 'outstanding_amount': 100,
|
||||||
'docstatus':1,
|
# 'name': 'rv1'
|
||||||
'cheque_no': '163567',
|
# })
|
||||||
'docstatus':1,
|
#
|
||||||
'company': 'comp1',
|
# jv1 = [Document(fielddata={
|
||||||
'posting_date' : '2011-05-02',
|
# 'doctype':'Journal Voucher',
|
||||||
'remark': 'test data',
|
# 'docstatus':1,
|
||||||
'fiscal_year': '2011-2012',
|
# 'cheque_no': '163567',
|
||||||
'total_debit': 500,
|
# 'docstatus':1,
|
||||||
'total_credit': 500
|
# 'company': 'comp1',
|
||||||
}),
|
# 'posting_date' : '2011-05-02',
|
||||||
Document(fielddata = {
|
# 'remark': 'test data',
|
||||||
'parenttype':'Journal Voucher',
|
# 'fiscal_year': '2011-2012',
|
||||||
'parentfield':'entries',
|
# 'total_debit': 500,
|
||||||
'doctype':'Journal Voucher Detail',
|
# 'total_credit': 500
|
||||||
'account' : 'cust1 - c1',
|
# }),
|
||||||
'credit':500,
|
# Document(fielddata = {
|
||||||
'debit' : 0,
|
# 'parenttype':'Journal Voucher',
|
||||||
'docstatus':1
|
# 'parentfield':'entries',
|
||||||
}),
|
# 'doctype':'Journal Voucher Detail',
|
||||||
Document(fielddata = {
|
# 'account' : 'cust1 - c1',
|
||||||
'parenttype':'Journal Voucher',
|
# 'credit':500,
|
||||||
'parentfield':'entries',
|
# 'debit' : 0,
|
||||||
'doctype':'Journal Voucher Detail',
|
# 'docstatus':1
|
||||||
'account' : 'bank1 - c1',
|
# }),
|
||||||
'credit':0,
|
# Document(fielddata = {
|
||||||
'debit' : 500,
|
# 'parenttype':'Journal Voucher',
|
||||||
'docstatus':1
|
# 'parentfield':'entries',
|
||||||
})]
|
# 'doctype':'Journal Voucher Detail',
|
||||||
|
# 'account' : 'bank1 - c1',
|
||||||
ir = [Document(fielddata = {
|
# 'credit':0,
|
||||||
'doctype':'Payment to Invoice Matching Tool',
|
# 'debit' : 500,
|
||||||
'name' : 'Payment to Invoice Matching Tool',
|
# 'docstatus':1
|
||||||
'account':'cust1 - c1',
|
# })]
|
||||||
'voucher_type' : 'Sales Invoice',
|
#
|
||||||
'voucher_no': 'rv1'
|
# ir = [Document(fielddata = {
|
||||||
}),
|
# 'doctype':'Payment to Invoice Matching Tool',
|
||||||
Document(fielddata = {
|
# 'name' : 'Payment to Invoice Matching Tool',
|
||||||
'parenttype':'Payment to Invoice Matching Tool',
|
# 'account':'cust1 - c1',
|
||||||
'parentfield':'ir_payment_details',
|
# 'voucher_type' : 'Sales Invoice',
|
||||||
'doctype':'Payment to Invoice Matching Tool Detail',
|
# 'voucher_no': 'rv1'
|
||||||
'parent': 'Payment to Invoice Matching Tool',
|
# }),
|
||||||
'voucher_no': 'jv1',
|
# Document(fielddata = {
|
||||||
'name' : '123112',
|
# 'parenttype':'Payment to Invoice Matching Tool',
|
||||||
'voucher_detail_no' : 'jvd1',
|
# 'parentfield':'ir_payment_details',
|
||||||
'selected' : 1,
|
# 'doctype':'Payment to Invoice Matching Tool Detail',
|
||||||
'amt_due' : 500,
|
# 'parent': 'Payment to Invoice Matching Tool',
|
||||||
'amt_to_be_reconciled':100
|
# 'voucher_no': 'jv1',
|
||||||
})]
|
# 'name' : '123112',
|
||||||
|
# 'voucher_detail_no' : 'jvd1',
|
||||||
cust1 = Document(fielddata={
|
# 'selected' : 1,
|
||||||
'doctype':'Account',
|
# 'amt_due' : 500,
|
||||||
'docstatus':0,
|
# 'amt_to_be_reconciled':100
|
||||||
'account_name' : 'cust1',
|
# })]
|
||||||
'debit_or_credit': 'Debit',
|
#
|
||||||
'company' : 'comp1',
|
# cust1 = Document(fielddata={
|
||||||
'lft': 1,
|
# 'doctype':'Account',
|
||||||
'rgt': 2
|
# 'docstatus':0,
|
||||||
})
|
# 'account_name' : 'cust1',
|
||||||
|
# 'debit_or_credit': 'Debit',
|
||||||
bank1 = Document(fielddata={
|
# 'company' : 'comp1',
|
||||||
'doctype':'Account',
|
# 'lft': 1,
|
||||||
'docstatus':0,
|
# 'rgt': 2
|
||||||
'account_name' : 'bank1',
|
# })
|
||||||
'debit_or_credit': 'Debit',
|
#
|
||||||
'company' : 'comp1',
|
# bank1 = Document(fielddata={
|
||||||
'lft': 3,
|
# 'doctype':'Account',
|
||||||
'rgt': 4
|
# 'docstatus':0,
|
||||||
})
|
# 'account_name' : 'bank1',
|
||||||
|
# 'debit_or_credit': 'Debit',
|
||||||
comp1 = Document(fielddata={
|
# 'company' : 'comp1',
|
||||||
'doctype':'Company',
|
# 'lft': 3,
|
||||||
'abbr': 'c1',
|
# 'rgt': 4
|
||||||
'company_name' : 'comp1',
|
# })
|
||||||
'name': 'comp1'
|
#
|
||||||
})
|
# comp1 = Document(fielddata={
|
||||||
|
# 'doctype':'Company',
|
||||||
rv_gle = Document(fielddata={
|
# 'abbr': 'c1',
|
||||||
'doctype':'GL Entry',
|
# 'company_name' : 'comp1',
|
||||||
'account': 'cust1 - c1',
|
# 'name': 'comp1'
|
||||||
'company' : 'comp1',
|
# })
|
||||||
'voucher_no': 'rv1',
|
#
|
||||||
'against_voucher': 'rv1',
|
# rv_gle = Document(fielddata={
|
||||||
'against_voucher_type': 'Sales Invoice',
|
# 'doctype':'GL Entry',
|
||||||
'voucher_type' : 'Sales Invoice',
|
# 'account': 'cust1 - c1',
|
||||||
'debit': 100,
|
# 'company' : 'comp1',
|
||||||
'credit': 0
|
# 'voucher_no': 'rv1',
|
||||||
})
|
# 'against_voucher': 'rv1',
|
||||||
|
# 'against_voucher_type': 'Sales Invoice',
|
||||||
|
# 'voucher_type' : 'Sales Invoice',
|
||||||
|
# 'debit': 100,
|
||||||
|
# 'credit': 0
|
||||||
|
# })
|
||||||
|
@ -7,8 +7,10 @@ test_records = [
|
|||||||
"price_list_name": "_Test Price List",
|
"price_list_name": "_Test Price List",
|
||||||
"company": "_Test Company",
|
"company": "_Test Company",
|
||||||
"warehouse": "_Test Warehouse",
|
"warehouse": "_Test Warehouse",
|
||||||
|
"territory": "_Test Territory",
|
||||||
"cash_bank_account": "_Test Account Bank Account - _TC",
|
"cash_bank_account": "_Test Account Bank Account - _TC",
|
||||||
"income_account": "Sales - _TC",
|
"income_account": "Sales - _TC",
|
||||||
"cost_center": "_Test Cost Center - _TC",
|
"cost_center": "_Test Cost Center - _TC",
|
||||||
|
"expense_account": "_Test Account Cost for Goods Sold - _TC",
|
||||||
}]
|
}]
|
||||||
]
|
]
|
@ -217,21 +217,11 @@ class TestSalesInvoice(unittest.TestCase):
|
|||||||
return dn
|
return dn
|
||||||
|
|
||||||
def _insert_pos_settings(self):
|
def _insert_pos_settings(self):
|
||||||
|
from accounts.doctype.pos_setting.test_pos_setting \
|
||||||
|
import test_records as pos_setting_test_records
|
||||||
webnotes.conn.sql("""delete from `tabPOS Setting`""")
|
webnotes.conn.sql("""delete from `tabPOS Setting`""")
|
||||||
ps = webnotes.bean([
|
|
||||||
{
|
ps = webnotes.bean(copy=pos_setting_test_records[0])
|
||||||
"cash_bank_account": "_Test Account Bank Account - _TC",
|
|
||||||
"company": "_Test Company",
|
|
||||||
"conversion_rate": 1.0,
|
|
||||||
"cost_center": "_Test Cost Center - _TC",
|
|
||||||
"currency": "INR",
|
|
||||||
"doctype": "POS Setting",
|
|
||||||
"income_account": "_Test Account Bank Account - _TC",
|
|
||||||
"price_list_name": "_Test Price List",
|
|
||||||
"territory": "_Test Territory",
|
|
||||||
"warehouse": "_Test Warehouse"
|
|
||||||
}
|
|
||||||
])
|
|
||||||
ps.insert()
|
ps.insert()
|
||||||
|
|
||||||
def test_sales_invoice_with_advance(self):
|
def test_sales_invoice_with_advance(self):
|
||||||
|
@ -12,7 +12,7 @@ def execute(filters=None):
|
|||||||
|
|
||||||
item_sales_bom = get_item_sales_bom()
|
item_sales_bom = get_item_sales_bom()
|
||||||
|
|
||||||
columns = ["Delivery Note/Sales Invoice::120", "Posting Date:Date", "Posting Time",
|
columns = ["Delivery Note/Sales Invoice::120", "Link::30", "Posting Date:Date", "Posting Time",
|
||||||
"Item Code:Link/Item", "Item Name", "Description", "Warehouse:Link/Warehouse",
|
"Item Code:Link/Item", "Item Name", "Description", "Warehouse:Link/Warehouse",
|
||||||
"Qty:Float", "Selling Rate:Currency", "Selling Amount:Currency", "Buying Amount:Currency",
|
"Qty:Float", "Selling Rate:Currency", "Selling Amount:Currency", "Buying Amount:Currency",
|
||||||
"Gross Profit:Currency", "Gross Profit %:Percent", "Project:Link/Project"]
|
"Gross Profit:Currency", "Gross Profit %:Percent", "Project:Link/Project"]
|
||||||
@ -32,8 +32,9 @@ def execute(filters=None):
|
|||||||
else:
|
else:
|
||||||
gross_profit = gross_profit_percent = 0.0
|
gross_profit = gross_profit_percent = 0.0
|
||||||
|
|
||||||
name = """<a href="%s">%s</a>""" % ("/".join(["#Form", row.parenttype, row.name]), row.name)
|
icon = """<a href="%s"><i class="icon icon-share" style="cursor: pointer;"></i></a>""" \
|
||||||
data.append([name, row.posting_date, row.posting_time, row.item_code, row.item_name,
|
% ("/".join(["#Form", row.parenttype, row.name]),)
|
||||||
|
data.append([row.name, icon, row.posting_date, row.posting_time, row.item_code, row.item_name,
|
||||||
row.description, row.warehouse, row.qty, row.basic_rate, row.amount, buying_amount,
|
row.description, row.warehouse, row.qty, row.basic_rate, row.amount, buying_amount,
|
||||||
gross_profit, gross_profit_percent, row.project])
|
gross_profit, gross_profit_percent, row.project])
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ 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 webnotes.conn.sql("""select parenttype, parent, parent_item,
|
||||||
item_code, warehouse, -1*qty as total_qty
|
item_code, warehouse, -1*qty as total_qty, parent_detail_docname
|
||||||
from `tabDelivery Note Packing Item` where docstatus=1""", as_dict=True):
|
from `tabDelivery Note Packing Item` where docstatus=1""", as_dict=True):
|
||||||
item_sales_bom.setdefault(d.parenttype, webnotes._dict()).setdefault(d.parent,
|
item_sales_bom.setdefault(d.parenttype, webnotes._dict()).setdefault(d.parent,
|
||||||
webnotes._dict()).setdefault(d.parent_item, []).append(d)
|
webnotes._dict()).setdefault(d.parent_item, []).append(d)
|
||||||
|
@ -77,14 +77,10 @@ for r in res:
|
|||||||
r.append(net_total)
|
r.append(net_total)
|
||||||
|
|
||||||
#Get tax for account heads
|
#Get tax for account heads
|
||||||
acc_head_tax = sql("""select account_head, sum(tax_amount)
|
acc_head_tax = sql("""select account_head,
|
||||||
from `tabPurchase Taxes and Charges`
|
sum(if(add_deduct_tax='Add', tax_amount, -tax_amount))
|
||||||
where parent = '%s'
|
from `tabPurchase Taxes and Charges` where parent = %s and parenttype = 'Purchase Invoice'
|
||||||
and parenttype = 'Purchase Invoice'
|
and category in ('Total', 'Valuation and Total') group by account_head""", r[col_idx['ID']])
|
||||||
and add_deduct_tax = 'Add'
|
|
||||||
and category in ('Total', 'Valuation and Total')
|
|
||||||
group by account_head
|
|
||||||
""" %(r[col_idx['ID']],))
|
|
||||||
|
|
||||||
#Convert the result to dictionary for easy retrieval
|
#Convert the result to dictionary for easy retrieval
|
||||||
acc_head_tax_dict = {}
|
acc_head_tax_dict = {}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
test_ignore = ["Leave Block List"]
|
||||||
|
|
||||||
test_records = [
|
test_records = [
|
||||||
[{"doctype":"Department", "department_name":"_Test Department"}],
|
[{"doctype":"Department", "department_name":"_Test Department"}],
|
||||||
[{"doctype":"Department", "department_name":"_Test Department 1"}]
|
[{"doctype":"Department", "department_name":"_Test Department 1"}]
|
||||||
|
@ -57,6 +57,7 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
application.doc.status = "Approved"
|
application.doc.status = "Approved"
|
||||||
self.assertRaises(LeaveDayBlockedError, application.submit)
|
self.assertRaises(LeaveDayBlockedError, application.submit)
|
||||||
|
|
||||||
|
test_dependencies = ["Leave Block List"]
|
||||||
|
|
||||||
test_records = [
|
test_records = [
|
||||||
[{
|
[{
|
||||||
|
@ -18,199 +18,201 @@ from __future__ import unicode_literals
|
|||||||
import unittest
|
import unittest
|
||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.model.doc import Document
|
test_records = []
|
||||||
from webnotes.model.code import get_obj
|
|
||||||
sql = webnotes.conn.sql
|
|
||||||
|
|
||||||
class TestSalaryManager(unittest.TestCase):
|
# from webnotes.model.doc import Document
|
||||||
def setUp(self):
|
# from webnotes.model.code import get_obj
|
||||||
webnotes.conn.begin()
|
# sql = webnotes.conn.sql
|
||||||
for rec in [des1, dep1, branch1, grade1, comp1, emp1, emp2]:
|
#
|
||||||
rec.save(1)
|
# class TestSalaryManager(unittest.TestCase):
|
||||||
|
# def setUp(self):
|
||||||
ss1[0].employee = emp1.name
|
# webnotes.conn.begin()
|
||||||
for s in ss1: s.save(1)
|
# for rec in [des1, dep1, branch1, grade1, comp1, emp1, emp2]:
|
||||||
for s in ss1[1:]:
|
# rec.save(1)
|
||||||
sql("update `tabSalary Structure Earning` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
|
#
|
||||||
sql("update `tabSalary Structure Deduction` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
|
# ss1[0].employee = emp1.name
|
||||||
|
# for s in ss1: s.save(1)
|
||||||
|
# for s in ss1[1:]:
|
||||||
ss2[0].employee = emp2.name
|
# sql("update `tabSalary Structure Earning` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
|
||||||
for s in ss2: s.save(1)
|
# sql("update `tabSalary Structure Deduction` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
|
||||||
for s in ss2[1:]:
|
#
|
||||||
sql("update `tabSalary Structure Earning` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
|
#
|
||||||
sql("update `tabSalary Structure Deduction` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
|
# ss2[0].employee = emp2.name
|
||||||
|
# for s in ss2: s.save(1)
|
||||||
sman.save()
|
# for s in ss2[1:]:
|
||||||
self.sm = get_obj('Salary Manager')
|
# sql("update `tabSalary Structure Earning` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
|
||||||
leave.save(1)
|
# sql("update `tabSalary Structure Deduction` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
|
||||||
self.sm.create_sal_slip()
|
#
|
||||||
|
# sman.save()
|
||||||
def test_creation(self):
|
# self.sm = get_obj('Salary Manager')
|
||||||
ssid = sql("""
|
# leave.save(1)
|
||||||
select name, department
|
# self.sm.create_sal_slip()
|
||||||
from `tabSalary Slip`
|
#
|
||||||
where month = '08' and fiscal_year='2011-2012'""")
|
# def test_creation(self):
|
||||||
|
# ssid = sql("""
|
||||||
self.assertTrue(len(ssid)==1)
|
# select name, department
|
||||||
self.assertTrue(ssid[0][1] == 'dep1')
|
# from `tabSalary Slip`
|
||||||
|
# where month = '08' and fiscal_year='2011-2012'""")
|
||||||
|
#
|
||||||
def test_lwp_calc(self):
|
# self.assertTrue(len(ssid)==1)
|
||||||
ss = sql("""
|
# self.assertTrue(ssid[0][1] == 'dep1')
|
||||||
select payment_days
|
#
|
||||||
from `tabSalary Slip`
|
#
|
||||||
where month = '08' and fiscal_year='2011-2012' and employee = '%s'
|
# def test_lwp_calc(self):
|
||||||
""" % emp1.name)
|
# ss = sql("""
|
||||||
|
# select payment_days
|
||||||
self.assertTrue(ss[0][0]==27)
|
# from `tabSalary Slip`
|
||||||
|
# where month = '08' and fiscal_year='2011-2012' and employee = '%s'
|
||||||
def test_net_pay(self):
|
# """ % emp1.name)
|
||||||
ss = webnotes.conn.sql("""
|
#
|
||||||
select rounded_total
|
# self.assertTrue(ss[0][0]==27)
|
||||||
from `tabSalary Slip`
|
#
|
||||||
where month = '08'
|
# def test_net_pay(self):
|
||||||
and fiscal_year='2011-2012' and employee = '%s'""" % emp1.name)
|
# ss = webnotes.conn.sql("""
|
||||||
self.assertTrue(ss[0][0]==67)
|
# select rounded_total
|
||||||
|
# from `tabSalary Slip`
|
||||||
def test_submit(self):
|
# where month = '08'
|
||||||
self.sm.submit_salary_slip()
|
# and fiscal_year='2011-2012' and employee = '%s'""" % emp1.name)
|
||||||
ss = webnotes.conn.sql("""
|
# self.assertTrue(ss[0][0]==67)
|
||||||
select docstatus
|
#
|
||||||
from `tabSalary Slip`
|
# def test_submit(self):
|
||||||
where month = '08'
|
# self.sm.submit_salary_slip()
|
||||||
and fiscal_year='2011-2012' and employee = '%s'""" % emp1.name)
|
# ss = webnotes.conn.sql("""
|
||||||
self.assertTrue(ss[0][0]==1)
|
# select docstatus
|
||||||
|
# from `tabSalary Slip`
|
||||||
def tearDown(self):
|
# where month = '08'
|
||||||
webnotes.conn.rollback()
|
# and fiscal_year='2011-2012' and employee = '%s'""" % emp1.name)
|
||||||
|
# self.assertTrue(ss[0][0]==1)
|
||||||
#--------------------------------------------
|
#
|
||||||
# test data
|
# def tearDown(self):
|
||||||
#--------------------------------------------
|
# webnotes.conn.rollback()
|
||||||
des1 = Document(fielddata={
|
#
|
||||||
'name':'des1',
|
# #--------------------------------------------
|
||||||
'doctype':'Designation',
|
# # test data
|
||||||
'designation_name':'des1'
|
# #--------------------------------------------
|
||||||
})
|
# des1 = Document(fielddata={
|
||||||
|
# 'name':'des1',
|
||||||
dep1 = Document(fielddata={
|
# 'doctype':'Designation',
|
||||||
'name':'dep1',
|
# 'designation_name':'des1'
|
||||||
'doctype':'Department',
|
# })
|
||||||
'department_name' : 'dep1'
|
#
|
||||||
})
|
# dep1 = Document(fielddata={
|
||||||
|
# 'name':'dep1',
|
||||||
branch1 = Document(fielddata={
|
# 'doctype':'Department',
|
||||||
'name':'branch1',
|
# 'department_name' : 'dep1'
|
||||||
'doctype':'Branch',
|
# })
|
||||||
'branch' : 'branch1'
|
#
|
||||||
})
|
# branch1 = Document(fielddata={
|
||||||
|
# 'name':'branch1',
|
||||||
comp1 = Document(fielddata={
|
# 'doctype':'Branch',
|
||||||
'name':'comp1',
|
# 'branch' : 'branch1'
|
||||||
'doctype':'Company',
|
# })
|
||||||
'abbr':'c1',
|
#
|
||||||
'company_name' : 'comp1'
|
# comp1 = Document(fielddata={
|
||||||
})
|
# 'name':'comp1',
|
||||||
|
# 'doctype':'Company',
|
||||||
grade1 = Document(fielddata={
|
# 'abbr':'c1',
|
||||||
'name':'grade1',
|
# 'company_name' : 'comp1'
|
||||||
'doctype':'Grade',
|
# })
|
||||||
'grade_name' : 'grade1'
|
#
|
||||||
})
|
# grade1 = Document(fielddata={
|
||||||
|
# 'name':'grade1',
|
||||||
emp1 = Document(fielddata={
|
# 'doctype':'Grade',
|
||||||
'doctype':'Employee',
|
# 'grade_name' : 'grade1'
|
||||||
'employee_number':'emp1',
|
# })
|
||||||
'department':'dep1',
|
#
|
||||||
'designation':'des1',
|
# emp1 = Document(fielddata={
|
||||||
'branch' : 'branch1',
|
# 'doctype':'Employee',
|
||||||
'company':'comp1',
|
# 'employee_number':'emp1',
|
||||||
'grade':'grade1',
|
# 'department':'dep1',
|
||||||
'naming_series':'EMP/',
|
# 'designation':'des1',
|
||||||
'status':'Active',
|
# 'branch' : 'branch1',
|
||||||
'docstatus':0,
|
# 'company':'comp1',
|
||||||
'employee_name':'emp1'
|
# 'grade':'grade1',
|
||||||
})
|
# 'naming_series':'EMP/',
|
||||||
|
# 'status':'Active',
|
||||||
emp2 = Document(fielddata={
|
# 'docstatus':0,
|
||||||
'doctype':'Employee',
|
# 'employee_name':'emp1'
|
||||||
'employee_number':'emp2',
|
# })
|
||||||
'department':'dep1',
|
#
|
||||||
'designation':'des2',
|
# emp2 = Document(fielddata={
|
||||||
'branch' : 'branch1',
|
# 'doctype':'Employee',
|
||||||
'company':'comp1',
|
# 'employee_number':'emp2',
|
||||||
'naming_series':'EMP/',
|
# 'department':'dep1',
|
||||||
'grade':'grade1',
|
# 'designation':'des2',
|
||||||
'status':'Active',
|
# 'branch' : 'branch1',
|
||||||
|
# 'company':'comp1',
|
||||||
})
|
# 'naming_series':'EMP/',
|
||||||
|
# 'grade':'grade1',
|
||||||
ss1 = [
|
# 'status':'Active',
|
||||||
Document(fielddata={
|
#
|
||||||
'doctype':'Salary Structure',
|
# })
|
||||||
'docstatus':0,
|
#
|
||||||
'employee':'emp1',
|
# ss1 = [
|
||||||
'is_active':'Yes',
|
# Document(fielddata={
|
||||||
'department': 'dep1',
|
# 'doctype':'Salary Structure',
|
||||||
'designation' : 'des1',
|
# 'docstatus':0,
|
||||||
'employee_name': 'emp1'
|
# 'employee':'emp1',
|
||||||
}),
|
# 'is_active':'Yes',
|
||||||
Document(fielddata={
|
# 'department': 'dep1',
|
||||||
'parenttype':'Salary Structure',
|
# 'designation' : 'des1',
|
||||||
'parentfield':'earning_details',
|
# 'employee_name': 'emp1'
|
||||||
'doctype':'Salary Structure Earning',
|
# }),
|
||||||
'e_type' : 'Basic',
|
# Document(fielddata={
|
||||||
'depend_on_lwp':1,
|
# 'parenttype':'Salary Structure',
|
||||||
'modified_value':100
|
# 'parentfield':'earning_details',
|
||||||
}),
|
# 'doctype':'Salary Structure Earning',
|
||||||
Document(fielddata={
|
# 'e_type' : 'Basic',
|
||||||
'parenttype':'Salary Structure',
|
# 'depend_on_lwp':1,
|
||||||
'parentfield':'earning_details',
|
# 'modified_value':100
|
||||||
'doctype':'Salary Structure Deduction',
|
# }),
|
||||||
'd_type':'TDS',
|
# Document(fielddata={
|
||||||
'd_modified_amt':20
|
# 'parenttype':'Salary Structure',
|
||||||
})
|
# 'parentfield':'earning_details',
|
||||||
]
|
# 'doctype':'Salary Structure Deduction',
|
||||||
|
# 'd_type':'TDS',
|
||||||
ss2 = [
|
# 'd_modified_amt':20
|
||||||
Document(fielddata={
|
# })
|
||||||
'doctype':'Salary Structure',
|
# ]
|
||||||
'is_active':'Yes',
|
#
|
||||||
'docstatus':0,
|
# ss2 = [
|
||||||
}),
|
# Document(fielddata={
|
||||||
Document(fielddata={
|
# 'doctype':'Salary Structure',
|
||||||
'parenttype':'Salary Structure',
|
# 'is_active':'Yes',
|
||||||
'parentfield':'deduction_details',
|
# 'docstatus':0,
|
||||||
'doctype':'Salary Structure Earning',
|
# }),
|
||||||
'e_type' : 'Basic',
|
# Document(fielddata={
|
||||||
'modified_value':100
|
# 'parenttype':'Salary Structure',
|
||||||
}),
|
# 'parentfield':'deduction_details',
|
||||||
Document(fielddata={
|
# 'doctype':'Salary Structure Earning',
|
||||||
'parenttype':'Salary Structure',
|
# 'e_type' : 'Basic',
|
||||||
'parentfield':'deduction_details',
|
# 'modified_value':100
|
||||||
'doctype':'Salary Structure Deduction',
|
# }),
|
||||||
'd_type':'TDS',
|
# Document(fielddata={
|
||||||
'd_modified_amt':20
|
# 'parenttype':'Salary Structure',
|
||||||
})
|
# 'parentfield':'deduction_details',
|
||||||
]
|
# 'doctype':'Salary Structure Deduction',
|
||||||
|
# 'd_type':'TDS',
|
||||||
sman = Document(fielddata={
|
# 'd_modified_amt':20
|
||||||
'name':'Salary Manager',
|
# })
|
||||||
'doctype':'Salary Manager',
|
# ]
|
||||||
'company': 'comp1',
|
#
|
||||||
'department':'dep1',
|
# sman = Document(fielddata={
|
||||||
'designation':'des1',
|
# 'name':'Salary Manager',
|
||||||
'month': '08',
|
# 'doctype':'Salary Manager',
|
||||||
'fiscal_year':'2011-2012'
|
# 'company': 'comp1',
|
||||||
})
|
# 'department':'dep1',
|
||||||
|
# 'designation':'des1',
|
||||||
leave = Document(fielddata = {
|
# 'month': '08',
|
||||||
'doctype':'Leave Application',
|
# 'fiscal_year':'2011-2012'
|
||||||
'employee':'emp1',
|
# })
|
||||||
'from_date':'2011-08-12',
|
#
|
||||||
'to_date':'2011-08-15',
|
# leave = Document(fielddata = {
|
||||||
'total_leave_days':'4',
|
# 'doctype':'Leave Application',
|
||||||
'leave_type':'Leave Without Pay',
|
# 'employee':'emp1',
|
||||||
'docstatus':1
|
# 'from_date':'2011-08-12',
|
||||||
})
|
# 'to_date':'2011-08-15',
|
||||||
|
# 'total_leave_days':'4',
|
||||||
|
# 'leave_type':'Leave Without Pay',
|
||||||
|
# 'docstatus':1
|
||||||
|
# })
|
||||||
|
@ -3,8 +3,11 @@ import webnotes, os, sys
|
|||||||
def execute():
|
def execute():
|
||||||
webnotes.reload_doc("core", "doctype", "doctype")
|
webnotes.reload_doc("core", "doctype", "doctype")
|
||||||
|
|
||||||
webnotes.rename_doc("DocType", "Purchase Request Item", "Material Request Item", force=True)
|
tables = webnotes.conn.sql_list("show tables")
|
||||||
webnotes.rename_doc("DocType", "Purchase Request", "Material Request", force=True)
|
if not "tabMaterial Request Item" in tables:
|
||||||
|
webnotes.rename_doc("DocType", "Purchase Request Item", "Material Request Item", force=True)
|
||||||
|
if not "tabMaterial Request" in tables:
|
||||||
|
webnotes.rename_doc("DocType", "Purchase Request", "Material Request", force=True)
|
||||||
webnotes.reload_doc("buying", "search_criteria", "pending_po_items_to_bill")
|
webnotes.reload_doc("buying", "search_criteria", "pending_po_items_to_bill")
|
||||||
webnotes.reload_doc("buying", "search_criteria", "pending_po_items_to_receive")
|
webnotes.reload_doc("buying", "search_criteria", "pending_po_items_to_receive")
|
||||||
|
|
||||||
|
18
patches/march_2013/p10_set_fiscal_year_for_stock.py
Normal file
18
patches/march_2013/p10_set_fiscal_year_for_stock.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import webnotes
|
||||||
|
from accounts.utils import get_fiscal_year, FiscalYearError
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
webnotes.reload_doc("stock", "doctype", "stock_entry")
|
||||||
|
webnotes.reload_doc("stock", "doctype", "stock_reconciliation")
|
||||||
|
|
||||||
|
for doctype in ["Stock Entry", "Stock Reconciliation"]:
|
||||||
|
for name, posting_date in webnotes.conn.sql("""select name, posting_date from `tab%s`
|
||||||
|
where ifnull(fiscal_year,'')='' and docstatus=1""" % doctype):
|
||||||
|
try:
|
||||||
|
fiscal_year = get_fiscal_year(posting_date, 0)[0]
|
||||||
|
webnotes.conn.sql("""update `tab%s` set fiscal_year=%s where name=%s""" % \
|
||||||
|
(doctype, "%s", "%s"), (fiscal_year, name))
|
||||||
|
except FiscalYearError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
@ -216,7 +216,12 @@ patch_list = [
|
|||||||
"patches.march_2013.p06_remove_sales_purchase_return_tool",
|
"patches.march_2013.p06_remove_sales_purchase_return_tool",
|
||||||
"execute:webnotes.bean('Global Defaults').save()",
|
"execute:webnotes.bean('Global Defaults').save()",
|
||||||
"patches.march_2013.p07_update_project_in_stock_ledger",
|
"patches.march_2013.p07_update_project_in_stock_ledger",
|
||||||
|
"execute:webnotes.reload_doc('stock', 'doctype', 'item') #2013-03-25",
|
||||||
|
"execute:webnotes.reload_doc('setup', 'doctype', 'item_group') #2013-03-25",
|
||||||
|
"execute:webnotes.reload_doc('website', 'doctype', 'blog_post') #2013-03-25",
|
||||||
|
"execute:webnotes.reload_doc('website', 'doctype', 'web_page') #2013-03-25",
|
||||||
"execute:webnotes.bean('Style Settings').save() #2013-03-25",
|
"execute:webnotes.bean('Style Settings').save() #2013-03-25",
|
||||||
"execute:webnotes.conn.set_value('Email Settings', None, 'send_print_in_body_and_attachment', 1)",
|
"execute:webnotes.conn.set_value('Email Settings', None, 'send_print_in_body_and_attachment', 1)",
|
||||||
"patches.march_2013.p09_unset_user_type_partner",
|
"patches.march_2013.p09_unset_user_type_partner",
|
||||||
|
"patches.march_2013.p10_set_fiscal_year_for_stock",
|
||||||
]
|
]
|
@ -9,6 +9,7 @@ class TestTimeLog(unittest.TestCase):
|
|||||||
self.assertRaises(OverlapError, ts.insert)
|
self.assertRaises(OverlapError, ts.insert)
|
||||||
|
|
||||||
test_records = [[{
|
test_records = [[{
|
||||||
|
"doctype": "Time Log",
|
||||||
"from_time": "2013-01-01 10:00:00",
|
"from_time": "2013-01-01 10:00:00",
|
||||||
"to_time": "2013-01-01 11:00:00",
|
"to_time": "2013-01-01 11:00:00",
|
||||||
"activity_type": "_Test Activity Type",
|
"activity_type": "_Test Activity Type",
|
||||||
|
@ -24,7 +24,8 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
"doctype": "Stock Entry",
|
"doctype": "Stock Entry",
|
||||||
"posting_date": "2013-03-01",
|
"posting_date": "2013-03-01",
|
||||||
"posting_time": "00:00:00",
|
"posting_time": "00:00:00",
|
||||||
"purpose": "Material Receipt"
|
"purpose": "Material Receipt",
|
||||||
|
"fiscal_year": "_Test Fiscal Year 2013",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"conversion_factor": 1.0,
|
"conversion_factor": 1.0,
|
||||||
@ -125,7 +126,8 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
["Material Request Item", "Stock Entry Detail"]], mr.doc.name)
|
["Material Request Item", "Stock Entry Detail"]], mr.doc.name)
|
||||||
se_doclist[0].fields.update({
|
se_doclist[0].fields.update({
|
||||||
"posting_date": "2013-03-01",
|
"posting_date": "2013-03-01",
|
||||||
"posting_time": "01:00"
|
"posting_time": "01:00",
|
||||||
|
"fiscal_year": "_Test Fiscal Year 2013",
|
||||||
})
|
})
|
||||||
se_doclist[1].fields.update({
|
se_doclist[1].fields.update({
|
||||||
"qty": 27.0,
|
"qty": 27.0,
|
||||||
@ -186,7 +188,8 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
["Material Request Item", "Stock Entry Detail"]], mr.doc.name)
|
["Material Request Item", "Stock Entry Detail"]], mr.doc.name)
|
||||||
se_doclist[0].fields.update({
|
se_doclist[0].fields.update({
|
||||||
"posting_date": "2013-03-01",
|
"posting_date": "2013-03-01",
|
||||||
"posting_time": "00:00"
|
"posting_time": "00:00",
|
||||||
|
"fiscal_year": "_Test Fiscal Year 2013",
|
||||||
})
|
})
|
||||||
se_doclist[1].fields.update({
|
se_doclist[1].fields.update({
|
||||||
"qty": 60.0,
|
"qty": 60.0,
|
||||||
@ -239,7 +242,8 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
["Material Request Item", "Stock Entry Detail"]], mr.doc.name)
|
["Material Request Item", "Stock Entry Detail"]], mr.doc.name)
|
||||||
se_doclist[0].fields.update({
|
se_doclist[0].fields.update({
|
||||||
"posting_date": "2013-03-01",
|
"posting_date": "2013-03-01",
|
||||||
"posting_time": "00:00"
|
"posting_time": "00:00",
|
||||||
|
"fiscal_year": "_Test Fiscal Year 2013",
|
||||||
})
|
})
|
||||||
se_doclist[1].fields.update({
|
se_doclist[1].fields.update({
|
||||||
"qty": 60.0,
|
"qty": 60.0,
|
||||||
|
@ -170,9 +170,10 @@ def get_buying_amount(item_code, warehouse, qty, voucher_type, voucher_no, vouch
|
|||||||
# sales bom item
|
# sales bom item
|
||||||
buying_amount = 0.0
|
buying_amount = 0.0
|
||||||
for bom_item in item_sales_bom[item_code]:
|
for bom_item in item_sales_bom[item_code]:
|
||||||
buying_amount += _get_buying_amount(voucher_type, voucher_no, "[** No Item Row **]",
|
if bom_item.get("parent_detail_docname")==voucher_detail_no:
|
||||||
bom_item.item_code, bom_item.warehouse or warehouse,
|
buying_amount += _get_buying_amount(voucher_type, voucher_no, "[** No Item Row **]",
|
||||||
bom_item.total_qty or (bom_item.qty * qty), stock_ledger_entries)
|
bom_item.item_code, bom_item.warehouse or warehouse,
|
||||||
|
bom_item.total_qty or (bom_item.qty * qty), stock_ledger_entries)
|
||||||
return buying_amount
|
return buying_amount
|
||||||
else:
|
else:
|
||||||
# doesn't have sales bom
|
# doesn't have sales bom
|
||||||
@ -181,12 +182,15 @@ def get_buying_amount(item_code, warehouse, qty, voucher_type, voucher_no, vouch
|
|||||||
|
|
||||||
def _get_buying_amount(voucher_type, voucher_no, item_row, item_code, warehouse, qty,
|
def _get_buying_amount(voucher_type, voucher_no, item_row, item_code, warehouse, qty,
|
||||||
stock_ledger_entries):
|
stock_ledger_entries):
|
||||||
for i, sle in enumerate(stock_ledger_entries):
|
relevant_stock_ledger_entries = [sle for sle in stock_ledger_entries
|
||||||
|
if sle.item_code == item_code and sle.warehouse == warehouse]
|
||||||
|
|
||||||
|
for i, sle in enumerate(relevant_stock_ledger_entries):
|
||||||
if sle.voucher_type == voucher_type and sle.voucher_no == voucher_no and \
|
if sle.voucher_type == voucher_type and sle.voucher_no == voucher_no and \
|
||||||
(sle.voucher_detail_no == item_row or (sle.voucher_type != "Stock Reconciliation"
|
((sle.voucher_detail_no == item_row) or (sle.voucher_type != "Stock Reconciliation"
|
||||||
and sle.item_code == item_code and sle.warehouse == warehouse and flt(sle.qty) == qty)):
|
and flt(sle.qty) == qty)):
|
||||||
previous_stock_value = len(stock_ledger_entries) > i+1 and \
|
previous_stock_value = len(relevant_stock_ledger_entries) > i+1 and \
|
||||||
flt(stock_ledger_entries[i+1].stock_value) or 0.0
|
flt(relevant_stock_ledger_entries[i+1].stock_value) or 0.0
|
||||||
|
|
||||||
buying_amount = previous_stock_value - flt(sle.stock_value)
|
buying_amount = previous_stock_value - flt(sle.stock_value)
|
||||||
|
|
||||||
|
@ -38,18 +38,21 @@ test_dependencies = ["Lead", "Contact"]
|
|||||||
|
|
||||||
test_records =[
|
test_records =[
|
||||||
[{
|
[{
|
||||||
|
"doctype": "Newsletter",
|
||||||
"subject": "_Test Newsletter to Lead",
|
"subject": "_Test Newsletter to Lead",
|
||||||
"send_to_type": "Lead",
|
"send_to_type": "Lead",
|
||||||
"lead_source": "All",
|
"lead_source": "All",
|
||||||
"message": "This is a test newsletter"
|
"message": "This is a test newsletter"
|
||||||
}],
|
}],
|
||||||
[{
|
[{
|
||||||
|
"doctype": "Newsletter",
|
||||||
"subject": "_Test Newsletter to Contact",
|
"subject": "_Test Newsletter to Contact",
|
||||||
"send_to_type": "Contact",
|
"send_to_type": "Contact",
|
||||||
"contact_type": "Customer",
|
"contact_type": "Customer",
|
||||||
"message": "This is a test newsletter"
|
"message": "This is a test newsletter"
|
||||||
}],
|
}],
|
||||||
[{
|
[{
|
||||||
|
"doctype": "Newsletter",
|
||||||
"subject": "_Test Newsletter to Custom",
|
"subject": "_Test Newsletter to Custom",
|
||||||
"send_to_type": "Custom",
|
"send_to_type": "Custom",
|
||||||
"email_list": "test_custom@example.com, test_custom1@example.com, test_custom2@example.com",
|
"email_list": "test_custom@example.com, test_custom1@example.com, test_custom2@example.com",
|
||||||
|
Loading…
Reference in New Issue
Block a user