From 613cb6a9f950124b80dc395fbc557aac821df2f4 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 6 Feb 2013 17:33:46 +0530 Subject: [PATCH 01/14] bug fix in clear unallocated advances --- accounts/doctype/account/account.py | 2 - .../purchase_invoice/test_purchase_invoice.py | 120 ++++++++++++++---- .../sales_invoice/test_sales_invoice.py | 14 +- controllers/accounts_controller.py | 28 ++-- controllers/buying_controller.py | 5 +- setup/doctype/supplier_type/supplier_type.py | 10 +- .../purchase_receipt/test_purchase_receipt.py | 6 +- 7 files changed, 135 insertions(+), 50 deletions(-) diff --git a/accounts/doctype/account/account.py b/accounts/doctype/account/account.py index 04e13d8efe..eac269a0e1 100644 --- a/accounts/doctype/account/account.py +++ b/accounts/doctype/account/account.py @@ -18,8 +18,6 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import flt, fmt_money -from webnotes.model import db_exists -from webnotes.model.wrapper import copy_doclist from webnotes import msgprint sql = webnotes.conn.sql diff --git a/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/accounts/doctype/purchase_invoice/test_purchase_invoice.py index 606ebb9bb4..f7cfc96eab 100644 --- a/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -20,6 +20,7 @@ import unittest import webnotes import webnotes.model from webnotes.utils import nowdate +from webnotes.test_runner import make_test_records from stock.doctype.purchase_receipt import test_purchase_receipt @@ -34,15 +35,15 @@ def load_data(): "group_or_ledger": "Ledger"}) webnotes.insert({"doctype": "Account", "account_name": "Excise Duty", - "parent_account": "Tax Assets - %s" % abbr, "company": company, + "parent_account": "_Test Tax Assets - %s" % abbr, "company": company, "group_or_ledger": "Ledger"}) webnotes.insert({"doctype": "Account", "account_name": "Education Cess", - "parent_account": "Tax Assets - %s" % abbr, "company": company, + "parent_account": "_Test Tax Assets - %s" % abbr, "company": company, "group_or_ledger": "Ledger"}) webnotes.insert({"doctype": "Account", "account_name": "S&H Education Cess", - "parent_account": "Tax Assets - %s" % abbr, "company": company, + "parent_account": "_Test Tax Assets - %s" % abbr, "company": company, "group_or_ledger": "Ledger"}) webnotes.insert({"doctype": "Account", "account_name": "CST", @@ -94,61 +95,66 @@ purchase_invoice_doclist = [ { "doctype": "Purchase Taxes and Charges", "charge_type": "Actual", "account_head": "Shipping Charges - %s" % abbr, "rate": 100, "tax_amount": 100, - "category": "Valuation and Total", "parentfield": "other_charges", - "cost_center": "Default Cost Center - %s" % abbr + "category": "Valuation and Total", "parentfield": "purchase_tax_details", + "cost_center": "Default Cost Center - %s" % abbr, "add_deduct_tax": "Add" }, { "doctype": "Purchase Taxes and Charges", "charge_type": "On Net Total", "account_head": "Customs Duty - %s" % abbr, "rate": 10, "tax_amount": 125.00, - "category": "Valuation", "parentfield": "other_charges", - "cost_center": "Default Cost Center - %s" % abbr + "category": "Valuation", "parentfield": "purchase_tax_details", + "cost_center": "Default Cost Center - %s" % abbr, "add_deduct_tax": "Add" }, { "doctype": "Purchase Taxes and Charges", "charge_type": "On Net Total", "account_head": "Excise Duty - %s" % abbr, "rate": 12, "tax_amount": 140.00, - "category": "Total", "parentfield": "other_charges" + "category": "Total", "parentfield": "purchase_tax_details", "add_deduct_tax": "Add" }, { "doctype": "Purchase Taxes and Charges", "charge_type": "On Previous Row Amount", "account_head": "Education Cess - %s" % abbr, "rate": 2, "row_id": 3, "tax_amount": 2.80, - "category": "Total", "parentfield": "other_charges" + "category": "Total", "parentfield": "purchase_tax_details", "add_deduct_tax": "Add" }, { "doctype": "Purchase Taxes and Charges", "charge_type": "On Previous Row Amount", "account_head": "S&H Education Cess - %s" % abbr, "rate": 1, "row_id": 3, - "tax_amount": 1.4, "category": "Total", "parentfield": "other_charges" + "tax_amount": 1.4, "category": "Total", "parentfield": "purchase_tax_details", + "add_deduct_tax": "Add" }, { "doctype": "Purchase Taxes and Charges", "charge_type": "On Previous Row Total", "account_head": "CST - %s" % abbr, "rate": 2, "row_id": 5, "tax_amount": 29.88, - "category": "Total", "parentfield": "other_charges", - "cost_center": "Default Cost Center - %s" % abbr + "category": "Total", "parentfield": "purchase_tax_details", + "cost_center": "Default Cost Center - %s" % abbr, "add_deduct_tax": "Add" }, { "doctype": "Purchase Taxes and Charges", "charge_type": "On Net Total", "account_head": "VAT - Test - %s" % abbr, "rate": 12.5, "tax_amount": 156.25, - "category": "Total", "parentfield": "other_charges" + "category": "Total", "parentfield": "purchase_tax_details", "add_deduct_tax": "Add" }, { "doctype": "Purchase Taxes and Charges", "charge_type": "On Previous Row Total", - "account_head": "Discount - %s" % abbr, "rate": -10, "row_id": 7, "tax_amount": -168.03, - "category": "Total", "parentfield": "other_charges", - "cost_center": "Default Cost Center - %s" % abbr + "account_head": "Discount - %s" % abbr, "rate": 10, "row_id": 7, "tax_amount": 168.03, + "category": "Total", "parentfield": "purchase_tax_details", + "cost_center": "Default Cost Center - %s" % abbr, "add_deduct_tax": "Deduct" }, ] -class TestPurchaseReceipt(unittest.TestCase): +class TestPurchaseInvoice(unittest.TestCase): def setUp(self): webnotes.conn.begin() load_data() # webnotes.conn.set_value("Global Defaults", None, "automatic_inventory_accounting", 1) + self.load_test_data() + + def load_test_data(self): + make_test_records("Company") + def test_gl_entries(self): - from webnotes.model.doclist import DocList - controller = webnotes.insert(DocList(purchase_invoice_doclist)) - controller.submit() - controller.load_from_db() - dl = controller.doclist + wrapper = webnotes.model_wrapper(purchase_invoice_doclist).insert() + wrapper.submit() + wrapper.load_from_db() + dl = wrapper.doclist expected_gl_entries = { "East Wind Inc. - %s" % abbr : [0, 1512.30], @@ -165,6 +171,76 @@ class TestPurchaseReceipt(unittest.TestCase): where voucher_type = 'Purchase Invoice' and voucher_no = %s""", dl[0].name, as_dict=1) for d in gl_entries: self.assertEqual([d.debit, d.credit], expected_gl_entries.get(d.account)) + + def test_purchase_invoice_calculation(self): + test_doclist = [] + purchase_invoice_doclist + for doc in test_doclist: + if doc["doctype"] == "Purchase Taxes and Charges": + del doc["tax_amount"] + + wrapper = webnotes.model_wrapper(test_doclist).insert() + wrapper.load_from_db() + + # tax amounts + expected_values = [ + ["Shipping Charges - %s" % abbr, 100, 1350], + ["Customs Duty - %s" % abbr, 125, 1350], + ["Excise Duty - %s" % abbr, 140, 1490], + ["Education Cess - %s" % abbr, 2.8, 1492.8], + ["S&H Education Cess - %s" % abbr, 1.4, 1494.2], + ["CST - %s" % abbr, 29.88, 1524.08], + ["VAT - Test - %s" % abbr, 156.25, 1680.33], + ["Discount - %s" % abbr, 168.03, 1512.30], + ] + + for i, tax in enumerate(wrapper.doclist.get({"parentfield": "purchase_tax_details"})): + self.assertEqual(tax.account_head, expected_values[i][0]) + self.assertEqual(tax.tax_amount, expected_values[i][1]) + self.assertEqual(tax.total, expected_values[i][2]) + + expected_values = [ + ["Home Desktop 100", 90], + ["Home Desktop 200", 135] + ] + for i, item in enumerate(wrapper.doclist.get({"parentfield": "entries"})): + self.assertEqual(item.item_code, expected_values[i][0]) + self.assertEqual(item.item_tax_amount, expected_values[i][1]) + + + # def test_purchase_invoice_calculation(self): + # from webnotes.model.doclist import DocList + # wrapper = webnotes.insert(DocList(purchase_invoice_doclist)) + # wrapper.load_from_db() + # dl = wrapper.doclist + # + # # test net total + # self.assertEqual(dl[0].net_total, 1250) + # + # # test tax amounts and totals + # expected_values = [ + # ["Shipping Charges - %s" % abbr, 100, 1350], + # ["Customs Duty - %s" % abbr, 125, 1350], + # ["Excise Duty - %s" % abbr, 140, 1490], + # ["Education Cess - %s" % abbr, 2.8, 1492.8], + # ["S&H Education Cess - %s" % abbr, 1.4, 1494.2], + # ["CST - %s" % abbr, 29.88, 1524.08], + # ["VAT - Test - %s" % abbr, 156.25, 1680.33], + # ["Discount - %s" % abbr, -168.03, 1512.30], + # ] + # for i, tax in enumerate(dl.get({"parentfield": "taxes_and_charges"})): + # # print tax.account_head, tax.tax_amount, tax.total + # self.assertEqual(tax.account_head, expected_values[i][0]) + # self.assertEqual(tax.tax_amount, expected_values[i][1]) + # self.assertEqual(tax.total, expected_values[i][2]) + # + # # test item tax amount + # expected_values = [ + # ["Home Desktop 100", 90], + # ["Home Desktop 200", 135] + # ] + # for i, item in enumerate(dl.get({"parentfield": "purchase_invoice_items"})): + # self.assertEqual(item.item_code, expected_values[i][0]) + # self.assertEqual(item.valuation_tax_amount, expected_values[i][1]) def tearDown(self): webnotes.conn.rollback() \ No newline at end of file diff --git a/accounts/doctype/sales_invoice/test_sales_invoice.py b/accounts/doctype/sales_invoice/test_sales_invoice.py index bb2157c2a4..06ca887aa1 100644 --- a/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -32,16 +32,16 @@ def load_data(): # create customer group webnotes.insert({"doctype": "Customer Group", - "customer_group_name": "Default Customer Group", + "customer_group_name": "_Test Customer Group", "parent_customer_group": "All Customer Groups", "is_group": "No"}) # create customer webnotes.insert({"doctype": "Customer", "customer_name": "West Wind Inc.", "customer_type": "Company", "territory": "Default", - "customer_group": "Default Customer Group", "company": company, + "customer_group": "_Test Customer Group", "company": company, "credit_days": 50, "credit_limit": 0}) - webnotes.insert({"doctype": "Account", "account_name": "Sales", + webnotes.insert({"doctype": "Account", "account_name": "_Test Account Sales", "parent_account": "Income - %s" % abbr, "company": company, "group_or_ledger": "Ledger"}) @@ -93,15 +93,15 @@ sales_invoice_doclist = [ "doctype": "Sales Invoice Item", "warehouse": "Default Warehouse", "item_code": "Home Desktop 100", "qty": 10, "basic_rate": 50, "amount": 500, "parentfield": "entries", "so_detail": None, "dn_detail": None, - "uom": "Nos", "item_tax_rate": json.dumps({"Excise Duty - %s" % abbr: 10}), - "income_account": "Sales - %s" % abbr, + "stock_uom": "Nos", "item_tax_rate": json.dumps({"Excise Duty - %s" % abbr: 10}), + "income_account": "_Test Account Sales - %s" % abbr, "cost_center": "Default Cost Center - %s" % abbr }, { "doctype": "Sales Invoice Item", "warehouse": "Default Warehouse", "item_code": "Home Desktop 200", "qty": 5, "basic_rate": 150, "amount": 750, "so_detail": None, "dn_detail": None, - "parentfield": "entries", "uom": "Nos", "income_account": "Sales - %s" % abbr, + "parentfield": "entries", "stock_uom": "Nos", "income_account": "_Test Account Sales - %s" % abbr, "cost_center": "Default Cost Center - %s" % abbr }, # taxes @@ -211,7 +211,7 @@ class TestSalesInvoice(unittest.TestCase): expected_gl_entries = { "West Wind Inc. - %s" % abbr : [1627.05, 0.0], - "Sales - %s" % abbr: [0.0, 1250.00], + "_Test Account Sales - %s" % abbr: [0.0, 1250.00], "Shipping Charges - %s" % abbr: [0.0, 100], "Customs Duty - %s" % abbr: [0, 125.0], "Excise Duty - %s" % abbr: [0, 140], diff --git a/controllers/accounts_controller.py b/controllers/accounts_controller.py index a80afc5587..60535ccfb2 100644 --- a/controllers/accounts_controller.py +++ b/controllers/accounts_controller.py @@ -17,7 +17,6 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import flt -from webnotes.model.doc import addchild from utilities.transaction_base import TransactionBase class AccountsController(TransactionBase): @@ -47,15 +46,13 @@ class AccountsController(TransactionBase): return stock_in_hand - def clear_unallocated_advances(self, parenttype, parentfield): - for d in self.doclist: - if d.parentfield == parentfield and flt(d.allocated_amount) == 0: - self.doclist.remove(d) + def clear_unallocated_advances(self, childtype, parentfield): + self.doclist.remove_items({"parentfield": parentfield, "allocated_amount": ["in", [0, None, ""]]}) - webnotes.conn.sql("""delete from `tab%s` where parent = %s - and ifnull(allocated_amount, 0) = 0""" % (parenttype, '%s'), self.doc.name) + webnotes.conn.sql("""delete from `tab%s` where parentfield=%s and parent = %s + and ifnull(allocated_amount, 0) = 0""" % (childtype, '%s', '%s'), (parentfield, self.doc.name)) - def get_advances(self, account_head, parenttype, parentfield, dr_or_cr): + def get_advances(self, account_head, child_doctype, parentfield, dr_or_cr): res = webnotes.conn.sql("""select t1.name as jv_no, t1.remark, t2.%s as amount, t2.name as jv_detail_no from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 @@ -68,9 +65,12 @@ class AccountsController(TransactionBase): self.doclist = self.doc.clear_table(self.doclist, parentfield) for d in res: - add = addchild(self.doc, parentfield, parenttype, self.doclist) - add.journal_voucher = d.jv_no - add.jv_detail_no = d.jv_detail_no - add.remarks = d.remark - add.advance_amount = flt(d.amount) - add.allocate_amount = 0 \ No newline at end of file + self.doclist.append({ + "doctype": child_doctype, + "parentfield": parentfield, + "journal_voucher": d.jv_no, + "jv_detail_no": d.jv_detail_no, + "remarks": d.remark, + "advance_amount": flt(d.amount), + "allocate_amount": 0 + }) \ No newline at end of file diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index 8a51e3adfb..f416b853fb 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -83,4 +83,7 @@ class BuyingController(AccountsController): self.doc.in_words = money_in_words(self.doc.grand_total, company_currency) if self.meta.get_field("in_words_import"): self.doc.in_words_import = money_in_words(self.doc.grand_total_import, - self.doc.currency) \ No newline at end of file + self.doc.currency) + + def calculate_taxes_and_totals(self): + pass \ No newline at end of file diff --git a/setup/doctype/supplier_type/supplier_type.py b/setup/doctype/supplier_type/supplier_type.py index 7f48feb2eb..4a8fdff58d 100644 --- a/setup/doctype/supplier_type/supplier_type.py +++ b/setup/doctype/supplier_type/supplier_type.py @@ -19,4 +19,12 @@ import webnotes class DocType: def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file + self.doc, self.doclist = d, dl + + +test_records = [ + [{ + "doctype": "Supplier Type", + "supplier_type": "_Test Supplier Type", + }] +] \ No newline at end of file diff --git a/stock/doctype/purchase_receipt/test_purchase_receipt.py b/stock/doctype/purchase_receipt/test_purchase_receipt.py index b619cbd31d..f91455f4d3 100644 --- a/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -56,7 +56,7 @@ def load_data(): webnotes.insert({"doctype": "Cost Center", "group_or_ledger": "Ledger", "cost_center_name": "Default Cost Center", "parent_cost_center": "Root - %s" % abbr, - "company_name": company, "company_abbr": abbr}) + "company_name": company}) # create account heads for taxes @@ -67,11 +67,11 @@ def load_data(): webnotes.insert({"doctype": "Account", "account_name": "Customs Duty", "parent_account": "Stock Expenses - %s" % abbr, "company": company, "group_or_ledger": "Ledger"}) - webnotes.insert({"doctype": "Account", "account_name": "Tax Assets", + webnotes.insert({"doctype": "Account", "account_name": "_Test Tax Assets", "parent_account": "Current Assets - %s" % abbr, "company": company, "group_or_ledger": "Group"}) webnotes.insert({"doctype": "Account", "account_name": "VAT - Test", - "parent_account": "Tax Assets - %s" % abbr, "company": company, + "parent_account": "_Test Tax Assets - %s" % abbr, "company": company, "group_or_ledger": "Ledger"}) # create BOM From fa230e47f4cf696861f65708170af034fb9faed2 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 6 Feb 2013 17:40:14 +0530 Subject: [PATCH 02/14] get_query shifted to server for account --- accounts/doctype/account/account.js | 25 ++++++++++++------------- accounts/doctype/account/account.py | 11 ++++++++++- stock/utils.py | 2 +- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/accounts/doctype/account/account.js b/accounts/doctype/account/account.js index 14e35d3094..77386823e4 100644 --- a/accounts/doctype/account/account.js +++ b/accounts/doctype/account/account.js @@ -116,19 +116,18 @@ cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) { }); } -// Master name get query -// ----------------------------------------- -cur_frm.fields_dict['master_name'].get_query=function(doc){ - if (doc.master_type){ - return 'SELECT `tab'+doc.master_type+'`.name FROM `tab'+doc.master_type+'` WHERE `tab'+doc.master_type+'`.name LIKE "%s" and `tab'+doc.master_type+'`.docstatus != 2 ORDER BY `tab'+doc.master_type+'`.name LIMIT 50'; - } +cur_frm.fields_dict['master_name'].get_query = function(doc) { + if (doc.master_type) { + return { + query: "accounts.doctype.account.account.get_master_name", + args: { "master_type": doc.master_type } + } + } } -// parent account get query -// ----------------------------------------- -cur_frm.fields_dict['parent_account'].get_query = function(doc){ - return 'SELECT DISTINCT `tabAccount`.name FROM `tabAccount` WHERE \ - `tabAccount`.group_or_ledger="Group" AND `tabAccount`.docstatus != 2 AND \ - `tabAccount`.company="'+ doc.company+'" AND `tabAccount`.company is not NULL AND \ - `tabAccount`.name LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50'; +cur_frm.fields_dict['parent_account'].get_query = function(doc) { + return { + query: "accounts.doctype.account.account.get_parent_account", + args: { "company": doc.company} + } } diff --git a/accounts/doctype/account/account.py b/accounts/doctype/account/account.py index 04e13d8efe..57ab191756 100644 --- a/accounts/doctype/account/account.py +++ b/accounts/doctype/account/account.py @@ -200,4 +200,13 @@ class DocType: sql("update `tabAccount` set account_name = '%s' where name = '%s'" % \ (account_name, old)) - return " - ".join(parts) \ No newline at end of file + return " - ".join(parts) + +def get_master_name(doctype, txt, searchfield, start, page_len, args): + return webnotes.conn.sql("""select name from `tab%s` where name like '%%%s%%'""" % + (args["master_type"], txt), as_list=1) + +def get_parent_account(doctype, txt, searchfield, start, page_len, args): + return webnotes.conn.sql("""select name from tabAccount + where group_or_ledger = 'Group' and docstatus != 2 and company = '%s' + and name like '%%%s%%'""" % (args["company"], txt)) \ No newline at end of file diff --git a/stock/utils.py b/stock/utils.py index 87f4c02ad1..3b98cf0683 100644 --- a/stock/utils.py +++ b/stock/utils.py @@ -148,7 +148,7 @@ def get_valid_serial_nos(sr_nos, qty=0, item_code=''): return valid_serial_nos -def get_warehouse_list(doctype, txt, searchfield, start, page_len): +def get_warehouse_list(doctype, txt, searchfield, start, page_len, args): """used in search queries""" wlist = [] for w in webnotes.conn.sql_list("""select name from tabWarehouse From e343ac717391c068a568cde3285ebdb5b28c46be Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 6 Feb 2013 18:42:26 +0530 Subject: [PATCH 03/14] fixes in voucher import tool --- accounts/doctype/journal_voucher/journal_voucher.py | 4 +++- accounts/page/voucher_import_tool/voucher_import_tool.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/accounts/doctype/journal_voucher/journal_voucher.py b/accounts/doctype/journal_voucher/journal_voucher.py index 4f20308369..eafd7ee25c 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.py +++ b/accounts/doctype/journal_voucher/journal_voucher.py @@ -51,7 +51,7 @@ class DocType(AccountsController): self.doc.posting_date, 'Posting Date') self.set_against_account() - self.create_remarks() + self.create_remarks() self.set_aging_date() self.set_print_format_fields() @@ -152,6 +152,8 @@ class DocType(AccountsController): if r: self.doc.remark = ("\n").join(r) + else: + webnotes.msgprint("Remarks is mandatory", raise_exception=1) def set_aging_date(self): if self.doc.is_opening != 'Yes': diff --git a/accounts/page/voucher_import_tool/voucher_import_tool.py b/accounts/page/voucher_import_tool/voucher_import_tool.py index 0d3a7f70cd..f99a0781e9 100644 --- a/accounts/page/voucher_import_tool/voucher_import_tool.py +++ b/accounts/page/voucher_import_tool/voucher_import_tool.py @@ -168,7 +168,7 @@ def import_vouchers(common_values, data, start_idx, import_type): webnotes.conn.commit() except Exception, e: webnotes.conn.rollback() - err_msg = webnotes.message_log and webnotes.message_log[0] or unicode(e) + err_msg = webnotes.message_log and "
".join(webnotes.message_log) or unicode(e) messages.append("""

[row #%s] %s failed: %s

""" % ((start_idx + 1) + i, jv.name or "", err_msg or "No message")) messages.append("

All transactions rolled back

") From 981577050ca6e830e3a106d2d344342a5dda3f40 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 7 Feb 2013 09:09:14 +0530 Subject: [PATCH 04/14] added company in leave application and global holiday block list --- .../holiday_block_list/holiday_block_list.py | 3 +- .../holiday_block_list/holiday_block_list.txt | 17 +++++++- .../leave_application/leave_application.py | 43 +++++++++++++------ .../leave_application/leave_application.txt | 15 +++++-- .../test_leave_application.py | 22 ++++++++-- .../update_company_in_leave_application.py | 9 ++++ patches/patch_list.py | 1 + 7 files changed, 88 insertions(+), 22 deletions(-) create mode 100644 patches/february_2013/update_company_in_leave_application.py diff --git a/hr/doctype/holiday_block_list/holiday_block_list.py b/hr/doctype/holiday_block_list/holiday_block_list.py index 619f373e37..87ab7052f1 100644 --- a/hr/doctype/holiday_block_list/holiday_block_list.py +++ b/hr/doctype/holiday_block_list/holiday_block_list.py @@ -23,7 +23,8 @@ class DocType: test_records = [[{ "doctype":"Holiday Block List", "holiday_block_list_name": "_Test Holiday Block List", - "year": "_Test Fiscal Year" + "year": "_Test Fiscal Year", + "company": "_Test Company" }, { "doctype": "Holiday Block List Date", "parent": "_Test Holiday Block List", diff --git a/hr/doctype/holiday_block_list/holiday_block_list.txt b/hr/doctype/holiday_block_list/holiday_block_list.txt index 31b2f98ee1..23b70e2ecf 100644 --- a/hr/doctype/holiday_block_list/holiday_block_list.txt +++ b/hr/doctype/holiday_block_list/holiday_block_list.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-04 15:31:29", "docstatus": 0, - "modified": "2013-02-06 14:39:09", + "modified": "2013-02-07 08:47:25", "modified_by": "Administrator", "owner": "Administrator" }, @@ -53,6 +53,21 @@ "options": "Fiscal Year", "reqd": 1 }, + { + "doctype": "DocField", + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "reqd": 1 + }, + { + "description": "If not checked, the list will have to be added to each Department where it has to be applied.", + "doctype": "DocField", + "fieldname": "applies_to_all_departments", + "fieldtype": "Check", + "label": "Applies to all Departments" + }, { "description": "Stop users from making Leave Applications on following days.", "doctype": "DocField", diff --git a/hr/doctype/leave_application/leave_application.py b/hr/doctype/leave_application/leave_application.py index cab8f17b69..9c6278d902 100755 --- a/hr/doctype/leave_application/leave_application.py +++ b/hr/doctype/leave_application/leave_application.py @@ -46,22 +46,39 @@ class DocType: raise_exception=True) def validate_block_days(self): - from_date = getdate(self.doc.from_date) - to_date = getdate(self.doc.to_date) - + for block_list in self.get_applicable_block_lists(): + self.check_block_dates(block_list) + + def get_applicable_block_lists(self): + block_lists = [] + def add_block_list(block_list): + if block_list: + if not self.is_user_in_allow_list(block_list): + block_lists.append(block_list) + + # per department department = webnotes.conn.get_value("Employee", self.doc.employee, "department") if department: block_list = webnotes.conn.get_value("Department", department, "holiday_block_list") - if block_list: - if self.is_user_in_allow_list(block_list): - return - for d in webnotes.conn.sql("""select block_date, reason from - `tabHoliday Block List Date` where parent=%s""", block_list, as_dict=1): - block_date = getdate(d.block_date) - if block_date > from_date and block_date < to_date: - webnotes.msgprint(_("You cannot apply for a leave on the following date because it is blocked") - + ": " + formatdate(d.block_date) + _(" Reason: ") + d.reason) - raise LeaveDayBlockedError + add_block_list(block_list) + + # global + for block_list in webnotes.conn.sql_list("""select name from `tabHoliday Block List` + where ifnull(applies_to_all_departments,0)=1 and company=%s""", self.doc.company): + add_block_list(block_list) + + return block_lists + + def check_block_dates(self, block_list): + from_date = getdate(self.doc.from_date) + to_date = getdate(self.doc.to_date) + for d in webnotes.conn.sql("""select block_date, reason from + `tabHoliday Block List Date` where parent=%s""", block_list, as_dict=1): + block_date = getdate(d.block_date) + if block_date > from_date and block_date < to_date: + webnotes.msgprint(_("You cannot apply for a leave on the following date because it is blocked") + + ": " + formatdate(d.block_date) + _(" Reason: ") + d.reason) + raise LeaveDayBlockedError def is_user_in_allow_list(self, block_list): return webnotes.session.user in webnotes.conn.sql_list("""select allow_user diff --git a/hr/doctype/leave_application/leave_application.txt b/hr/doctype/leave_application/leave_application.txt index 4436d3c2f8..e105dff0f1 100644 --- a/hr/doctype/leave_application/leave_application.txt +++ b/hr/doctype/leave_application/leave_application.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-01-10 16:34:14", + "creation": "2013-02-02 14:40:08", "docstatus": 0, - "modified": "2013-02-01 10:34:14", + "modified": "2013-02-07 08:54:22", "modified_by": "Administrator", "owner": "Administrator" }, @@ -180,6 +180,15 @@ "reqd": 1, "search_index": 0 }, + { + "doctype": "DocField", + "fieldname": "company", + "fieldtype": "Link", + "label": "Company", + "options": "Company", + "permlevel": 0, + "reqd": 1 + }, { "doctype": "DocField", "fieldname": "letter_head", @@ -241,4 +250,4 @@ "role": "Leave Approver", "submit": 0 } -] +] \ No newline at end of file diff --git a/hr/doctype/leave_application/test_leave_application.py b/hr/doctype/leave_application/test_leave_application.py index e485289ffa..e7c1bccd00 100644 --- a/hr/doctype/leave_application/test_leave_application.py +++ b/hr/doctype/leave_application/test_leave_application.py @@ -4,20 +4,33 @@ import unittest from hr.doctype.leave_application.leave_application import LeaveDayBlockedError class TestLeaveApplication(unittest.TestCase): + def get_application(self): + application = webnotes.model_wrapper(test_records[1]) + application.doc.from_date = "2013-01-01" + application.doc.to_date = "2013-01-05" + return application + def test_block_list(self): import webnotes webnotes.conn.set_value("Employee", "_T-Employee-0001", "department", "_Test Department with Block List") - application = webnotes.model_wrapper(test_records[1]) - application.doc.from_date = "2013-01-01" - application.doc.to_date = "2013-01-05" + application = self.get_application() self.assertRaises(LeaveDayBlockedError, application.insert) webnotes.session.user = "test1@erpnext.com" webnotes.get_obj("Profile", "test1@erpnext.com").add_role("HR User") self.assertTrue(application.insert()) + def test_global_block_list(self): + application = self.get_application() + webnotes.conn.set_value("Holiday Block List", "_Test Holiday Block List", + "applies_to_all_departments", 1) + webnotes.conn.set_value("Employee", "_T-Employee-0001", "department", + "_Test Department") + webnotes.session.user = "test@erpnext.com" + + self.assertRaises(LeaveDayBlockedError, application.insert) test_records = [ [{ @@ -35,7 +48,8 @@ test_records = [ "to_date": "2013-05-05", "posting_date": "2013-01-02", "fiscal_year": "_Test Fiscal Year", - "employee": "_T-Employee-0001" + "employee": "_T-Employee-0001", + "company": "_Test Company" }]] if __name__=="__main__": diff --git a/patches/february_2013/update_company_in_leave_application.py b/patches/february_2013/update_company_in_leave_application.py new file mode 100644 index 0000000000..098c7e32b1 --- /dev/null +++ b/patches/february_2013/update_company_in_leave_application.py @@ -0,0 +1,9 @@ +def execute(): + import webnotes + webnotes.conn.sql("""update `tabLeave Application`, `tabEmployee` set + `tabLeave Application`.company = `tabEmployee`.company where + `tabLeave Application`.employee = `tabEmployee`.name""") + + company = webnotes.conn.get_default("company") + webnotes.conn.sql("""update `tabLeave Application` + set company = %s where ifnull(company,'')=''""", company) \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index cf9c189cb4..467c6b05cf 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -166,4 +166,5 @@ patch_list = [ "patches.february_2013.remove_sales_order_pending_items", "patches.february_2013.account_negative_balance", "patches.february_2013.remove_account_utils_folder", + "patches.february_2013.update_company_in_leave_application" ] \ No newline at end of file From 9986ae8c6f1c683864133d6b98a258fc2e288bd7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 7 Feb 2013 10:51:40 +0530 Subject: [PATCH 05/14] stock_qty now editable in PO item and PR Item table --- buying/doctype/purchase_order_item/purchase_order_item.txt | 6 +++--- .../doctype/purchase_receipt_item/purchase_receipt_item.txt | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/buying/doctype/purchase_order_item/purchase_order_item.txt b/buying/doctype/purchase_order_item/purchase_order_item.txt index 20ba876a70..c8c21cac77 100755 --- a/buying/doctype/purchase_order_item/purchase_order_item.txt +++ b/buying/doctype/purchase_order_item/purchase_order_item.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-01-28 10:05:59", + "creation": "2013-01-30 12:49:48", "docstatus": 0, - "modified": "2013-01-29 16:28:05", + "modified": "2013-02-07 10:49:35", "modified_by": "Administrator", "owner": "Administrator" }, @@ -344,7 +344,7 @@ "oldfieldtype": "Currency", "print_hide": 1, "print_width": "100px", - "read_only": 1, + "read_only": 0, "width": "100px" }, { diff --git a/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt b/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt index e1ceb05674..2e5b219baa 100755 --- a/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt +++ b/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-01-28 10:06:02", + "creation": "2013-01-30 12:49:56", "docstatus": 0, - "modified": "2013-01-29 16:28:06", + "modified": "2013-02-07 10:50:00", "modified_by": "Administrator", "owner": "Administrator" }, From 79b8ca8f68190ab4185b860bf2d1c9f57b20571e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 7 Feb 2013 10:55:48 +0530 Subject: [PATCH 06/14] fixes in patch --- patches/february_2013/update_company_in_leave_application.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/patches/february_2013/update_company_in_leave_application.py b/patches/february_2013/update_company_in_leave_application.py index 098c7e32b1..eaf03b6083 100644 --- a/patches/february_2013/update_company_in_leave_application.py +++ b/patches/february_2013/update_company_in_leave_application.py @@ -1,5 +1,7 @@ def execute(): import webnotes + webnotes.reload_doc("hr", "doctype", "leave_application") + webnotes.conn.sql("""update `tabLeave Application`, `tabEmployee` set `tabLeave Application`.company = `tabEmployee`.company where `tabLeave Application`.employee = `tabEmployee`.name""") From 7e0b9a421272298501c9316bed6007d8b25a02fc Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 7 Feb 2013 10:58:15 +0530 Subject: [PATCH 07/14] fixes in patch --- patches/february_2013/update_company_in_leave_application.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/patches/february_2013/update_company_in_leave_application.py b/patches/february_2013/update_company_in_leave_application.py index eaf03b6083..be07cb8f35 100644 --- a/patches/february_2013/update_company_in_leave_application.py +++ b/patches/february_2013/update_company_in_leave_application.py @@ -7,5 +7,6 @@ def execute(): `tabLeave Application`.employee = `tabEmployee`.name""") company = webnotes.conn.get_default("company") - webnotes.conn.sql("""update `tabLeave Application` - set company = %s where ifnull(company,'')=''""", company) \ No newline at end of file + if company: + webnotes.conn.sql("""update `tabLeave Application` + set company = %s where ifnull(company,'')=''""", company) \ No newline at end of file From c39d13b6a717438715e18375c1ef59017e927a7e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 7 Feb 2013 11:36:37 +0530 Subject: [PATCH 08/14] fixes in item: duplicate tax validation --- stock/doctype/item/item.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index eab977bc91..2bbf48a370 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -122,21 +122,20 @@ class DocType: cust_code.append(d.ref_code) self.doc.customer_code=','.join(cust_code) - # Check whether Tax Rate is not entered twice for same Tax Type def check_item_tax(self): + """Check whether Tax Rate is not entered twice for same Tax Type""" check_list=[] for d in getlist(self.doclist,'item_tax'): - account_type = sql("select account_type from tabAccount where name = %s",d.tax_type) - account_type = account_type and account_type[0][0] or '' - if account_type not in ['Tax', 'Chargeable']: - msgprint("'%s' is not Tax / Chargeable Account"%(d.tax_type)) - raise Exception, "Tax Account validation" - else: - if d.tax_type in check_list: - msgprint("Rate is entered twice for Tax : '%s'." % (d.tax_type)) - raise Exception + if d.tax_type: + account_type = webnotes.conn.get_value("Account", d.tax_type, "account_type") + + if account_type not in ['Tax', 'Chargeable']: + msgprint("'%s' is not Tax / Chargeable Account" % d.tax_type, raise_exception=1) else: - check_list.append(d.tax_type) + if d.tax_type in check_list: + msgprint("Rate is entered twice for: '%s'" % d.tax_type, raise_exception=1) + else: + check_list.append(d.tax_type) def check_for_active_boms(self, field_label): if field_label in ['Is Active', 'Is Purchase Item']: From b7084b899597d37e2c77d4fe968e9c8ea8ca1f10 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 7 Feb 2013 18:15:04 +0530 Subject: [PATCH 09/14] Update hr/doctype/appraisal/appraisal.py fixed issue in appraisal --- hr/doctype/appraisal/appraisal.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hr/doctype/appraisal/appraisal.py b/hr/doctype/appraisal/appraisal.py index 849e48ac37..3d49c311d9 100644 --- a/hr/doctype/appraisal/appraisal.py +++ b/hr/doctype/appraisal/appraisal.py @@ -77,10 +77,9 @@ class DocType: msgprint("Total weightage assigned should be 100%. It is :" + str(total_w) + "%", raise_exception=1) - if webnotes.conn.get_default("employee", webnotes.session.user) != self.doc.employee: - - if total==0: - msgprint("Total can't be zero. You must atleast give some points!", raise_exception=1) + if webnotes.conn.get_value("Employee", self.doc.employee, "user_id") != \ + webnotes.session.user and total == 0: + msgprint("Total can't be zero. You must atleast give some points!", raise_exception=1) self.doc.total_score = total From 6209046772f2f7c9f83b6b0749ec22fe9d32a9de Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 7 Feb 2013 19:47:34 +0530 Subject: [PATCH 10/14] added some test records --- accounts/doctype/account/account.py | 30 +++++++++++- accounts/doctype/cost_center/cost_center.py | 10 ++++ accounts/doctype/fiscal_year/fiscal_year.py | 11 +++-- .../purchase_invoice/purchase_invoice.py | 2 +- .../purchase_invoice/test_purchase_invoice.py | 45 ++---------------- buying/doctype/supplier/supplier.py | 9 ++++ controllers/buying_controller.py | 10 +++- .../test_leave_application.py | 4 +- selling/doctype/customer/customer.py | 10 ++++ setup/doctype/brand/brand.py | 9 +++- setup/doctype/company/company.py | 6 +-- setup/doctype/country/country.py | 9 +++- setup/doctype/currency/currency.py | 2 - .../doctype/customer_group/customer_group.py | 14 ++++-- setup/doctype/item_group/item_group.py | 17 ++++++- setup/doctype/territory/territory.py | 11 ++++- setup/doctype/uom/uom.py | 9 +++- .../doctype/warehouse_type/warehouse_type.py | 9 +++- stock/doctype/item/item.py | 46 ++++++++++++++++++- stock/doctype/warehouse/warehouse.py | 15 ++++-- 20 files changed, 210 insertions(+), 68 deletions(-) diff --git a/accounts/doctype/account/account.py b/accounts/doctype/account/account.py index 0e3ace19fb..14af7cf4ef 100644 --- a/accounts/doctype/account/account.py +++ b/accounts/doctype/account/account.py @@ -23,8 +23,6 @@ from webnotes import msgprint sql = webnotes.conn.sql get_value = webnotes.conn.get_value -test_records = [] - class DocType: def __init__(self,d,dl): self.doc, self.doclist = d,dl @@ -208,3 +206,31 @@ def get_parent_account(doctype, txt, searchfield, start, page_len, args): return webnotes.conn.sql("""select name from tabAccount where group_or_ledger = 'Group' and docstatus != 2 and company = '%s' and name like '%%%s%%'""" % (args["company"], txt)) + +def make_test_records(verbose): + from webnotes.test_runner import load_module_and_make_records, make_test_objects + + load_module_and_make_records("Company", verbose) + + accounts = [ + # [account_name, parent_account, group_or_ledger] + ["_Test Account Stock Expenses", "Direct Expenses - _TC", "Group"], + ["_Test Account Shipping Charges", "_Test Account Stock Expenses - _TC", "Ledger"], + ["_Test Account Customs Duty", "_Test Account Stock Expenses - _TC", "Ledger"], + ["_Test Account Tax Assets", "Current Assets - _TC", "Group"], + ["_Test Account VAT", "_Test Account Tax Assets - _TC", "Ledger"], + ["_Test Account Cost for Goods Sold", "Expenses - _TC", "Ledger"], + ["_Test Account Excise Duty", "_Test Account Tax Assets - _TC", "Ledger"], + ["_Test Account Education Cess", "_Test Account Tax Assets - _TC", "Ledger"], + ["_Test Account S&H Education Cess", "_Test Account Tax Assets - _TC", "Ledger"], + ["_Test Account CST", "Direct Expenses - _TC", "Ledger"], + ["_Test Account Discount", "Direct Expenses - _TC", "Ledger"] + ] + + return make_test_objects([[{ + "doctype": "Account", + "account_name": account_name, + "parent_account": parent_account, + "company": "_Test Company", + "group_or_ledger": group_or_ledger + }] for account_name, parent_account, group_or_ledger in accounts]) \ No newline at end of file diff --git a/accounts/doctype/cost_center/cost_center.py b/accounts/doctype/cost_center/cost_center.py index d23b08681c..65d1f68520 100644 --- a/accounts/doctype/cost_center/cost_center.py +++ b/accounts/doctype/cost_center/cost_center.py @@ -98,3 +98,13 @@ class DocType(DocTypeNestedSet): (cost_center_name, old)) return " - ".join(parts) + +test_records = [ + [{ + "doctype": "Cost Center", + "cost_center_name": "_Test Cost Center", + "parent_cost_center": "Root - _TC", + "company_name": "_Test Company", + "group_or_ledger": "Ledger" + }], +] \ No newline at end of file diff --git a/accounts/doctype/fiscal_year/fiscal_year.py b/accounts/doctype/fiscal_year/fiscal_year.py index d5dff6ee4b..34134777db 100644 --- a/accounts/doctype/fiscal_year/fiscal_year.py +++ b/accounts/doctype/fiscal_year/fiscal_year.py @@ -31,6 +31,11 @@ class DocType: msgprint(self.doc.name + _(""" is now the default Fiscal Year. \ Please refresh your browser for the change to take effect.""")) - -test_records = [[{"doctype":"Fiscal Year", "year":"_Test Fiscal Year", - "year_start_date":"2013-01-01"}]] \ No newline at end of file + +test_records = [ + [{ + "doctype": "Fiscal Year", + "year": "_Test Fiscal Year", + "year_start_date": "2013-01-01" + }] +] \ No newline at end of file diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py index 98bfda554d..8b65e0dbda 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -526,4 +526,4 @@ class DocType(BuyingController): def on_update(self): pass - + diff --git a/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/accounts/doctype/purchase_invoice/test_purchase_invoice.py index f7cfc96eab..d13af0e653 100644 --- a/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -20,7 +20,6 @@ import unittest import webnotes import webnotes.model from webnotes.utils import nowdate -from webnotes.test_runner import make_test_records from stock.doctype.purchase_receipt import test_purchase_receipt @@ -147,9 +146,9 @@ class TestPurchaseInvoice(unittest.TestCase): self.load_test_data() def load_test_data(self): - make_test_records("Company") + from webnotes.test_runner import make_test_records + make_test_records("Purchase Invoice", verbose=0) - def test_gl_entries(self): wrapper = webnotes.model_wrapper(purchase_invoice_doclist).insert() wrapper.submit() @@ -172,7 +171,7 @@ class TestPurchaseInvoice(unittest.TestCase): for d in gl_entries: self.assertEqual([d.debit, d.credit], expected_gl_entries.get(d.account)) - def test_purchase_invoice_calculation(self): + def atest_purchase_invoice_calculation(self): test_doclist = [] + purchase_invoice_doclist for doc in test_doclist: if doc["doctype"] == "Purchase Taxes and Charges": @@ -205,42 +204,8 @@ class TestPurchaseInvoice(unittest.TestCase): for i, item in enumerate(wrapper.doclist.get({"parentfield": "entries"})): self.assertEqual(item.item_code, expected_values[i][0]) self.assertEqual(item.item_tax_amount, expected_values[i][1]) - - - # def test_purchase_invoice_calculation(self): - # from webnotes.model.doclist import DocList - # wrapper = webnotes.insert(DocList(purchase_invoice_doclist)) - # wrapper.load_from_db() - # dl = wrapper.doclist - # - # # test net total - # self.assertEqual(dl[0].net_total, 1250) - # - # # test tax amounts and totals - # expected_values = [ - # ["Shipping Charges - %s" % abbr, 100, 1350], - # ["Customs Duty - %s" % abbr, 125, 1350], - # ["Excise Duty - %s" % abbr, 140, 1490], - # ["Education Cess - %s" % abbr, 2.8, 1492.8], - # ["S&H Education Cess - %s" % abbr, 1.4, 1494.2], - # ["CST - %s" % abbr, 29.88, 1524.08], - # ["VAT - Test - %s" % abbr, 156.25, 1680.33], - # ["Discount - %s" % abbr, -168.03, 1512.30], - # ] - # for i, tax in enumerate(dl.get({"parentfield": "taxes_and_charges"})): - # # print tax.account_head, tax.tax_amount, tax.total - # self.assertEqual(tax.account_head, expected_values[i][0]) - # self.assertEqual(tax.tax_amount, expected_values[i][1]) - # self.assertEqual(tax.total, expected_values[i][2]) - # - # # test item tax amount - # expected_values = [ - # ["Home Desktop 100", 90], - # ["Home Desktop 200", 135] - # ] - # for i, item in enumerate(dl.get({"parentfield": "purchase_invoice_items"})): - # self.assertEqual(item.item_code, expected_values[i][0]) - # self.assertEqual(item.valuation_tax_amount, expected_values[i][1]) + + # self.assertEqual(dl[0].net_total, 1250) def tearDown(self): webnotes.conn.rollback() \ No newline at end of file diff --git a/buying/doctype/supplier/supplier.py b/buying/doctype/supplier/supplier.py index 096a43e3ff..0149f81cc5 100644 --- a/buying/doctype/supplier/supplier.py +++ b/buying/doctype/supplier/supplier.py @@ -182,3 +182,12 @@ class DocType(TransactionBase): #update master_name in doctype account webnotes.conn.sql("""update `tabAccount` set master_name = %s, master_type = 'Supplier' where master_name = %s""" , (new,old)) + +test_records = [ + [{ + "doctype": "Supplier", + "supplier_name": "_Test Supplier", + "supplier_type": "_Test Supplier Type", + "company": "_Test Company" + }] +] \ No newline at end of file diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index f416b853fb..511ca17fd0 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -86,4 +86,12 @@ class BuyingController(AccountsController): self.doc.currency) def calculate_taxes_and_totals(self): - pass \ No newline at end of file + self.doc.conversion_rate = flt(self.doc.conversion_rate) + + # self.calculate_item_values() + # self.initialize_taxes() + # self.calculate_net_total() + # self.calculate_taxes() + # self.calculate_totals() + # self.set_total_in_words() + \ No newline at end of file diff --git a/hr/doctype/leave_application/test_leave_application.py b/hr/doctype/leave_application/test_leave_application.py index e7c1bccd00..22164a7f79 100644 --- a/hr/doctype/leave_application/test_leave_application.py +++ b/hr/doctype/leave_application/test_leave_application.py @@ -1,6 +1,9 @@ import sys import unittest +if __name__=="__main__": + sys.path.extend([".", "app", "lib"]) + from hr.doctype.leave_application.leave_application import LeaveDayBlockedError class TestLeaveApplication(unittest.TestCase): @@ -53,7 +56,6 @@ test_records = [ }]] if __name__=="__main__": - sys.path.extend(["app", "lib"]) import webnotes webnotes.connect() diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py index 01fa69cc48..315e7931a9 100644 --- a/selling/doctype/customer/customer.py +++ b/selling/doctype/customer/customer.py @@ -249,3 +249,13 @@ class DocType(TransactionBase): #update master_name in doctype account webnotes.conn.sql("""update `tabAccount` set master_name = %s, master_type = 'Customer' where master_name = %s""", (new,old)) + +test_records = [ + [{ + "doctype": "Customer", + "customer_type": "Individual", + "customer_group": "_Test Customer Group", + "territory": "_Test Territory", + "company": "_Test Company" + }] +] \ No newline at end of file diff --git a/setup/doctype/brand/brand.py b/setup/doctype/brand/brand.py index 7f48feb2eb..19546da1a9 100644 --- a/setup/doctype/brand/brand.py +++ b/setup/doctype/brand/brand.py @@ -19,4 +19,11 @@ import webnotes class DocType: def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file + self.doc, self.doclist = d, dl + +test_records = [ + [{ + "doctype": "Brand", + "brand": "_Test Brand" + }] +] \ No newline at end of file diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py index b36253ed39..a951af58c9 100644 --- a/setup/doctype/company/company.py +++ b/setup/doctype/company/company.py @@ -258,9 +258,9 @@ class DocType: test_records = [ [{ + "doctype": "Company", "company_name": "_Test Company", - "abbr": "TC", + "abbr": "_TC", "default_currency": "INR", - "doctype": "Company" - }] + }], ] \ No newline at end of file diff --git a/setup/doctype/country/country.py b/setup/doctype/country/country.py index 7f48feb2eb..360f67915b 100644 --- a/setup/doctype/country/country.py +++ b/setup/doctype/country/country.py @@ -19,4 +19,11 @@ import webnotes class DocType: def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file + self.doc, self.doclist = d, dl + +test_records = [ + [{ + "doctype": "Country", + "country_name": "_Test Country" + }] +] \ No newline at end of file diff --git a/setup/doctype/currency/currency.py b/setup/doctype/currency/currency.py index 73076cbde2..7794430349 100644 --- a/setup/doctype/currency/currency.py +++ b/setup/doctype/currency/currency.py @@ -20,5 +20,3 @@ import webnotes class DocType: def __init__(self, d, dl): self.doc, self.doclist = d, dl - -test_records = [] \ No newline at end of file diff --git a/setup/doctype/customer_group/customer_group.py b/setup/doctype/customer_group/customer_group.py index b34d3c6425..fa81dcad15 100644 --- a/setup/doctype/customer_group/customer_group.py +++ b/setup/doctype/customer_group/customer_group.py @@ -16,9 +16,6 @@ from __future__ import unicode_literals import webnotes - -from webnotes.model import db_exists -from webnotes.model.wrapper import copy_doclist from webnotes import msgprint sql = webnotes.conn.sql @@ -63,4 +60,13 @@ class DocType(DocTypeNestedSet): You can not trash/cancel/delete this customer group.", raise_exception=1) # rebuild tree - super(DocType, self).on_trash() \ No newline at end of file + super(DocType, self).on_trash() + +test_records = [ + [{ + "doctype": "Customer Group", + "customer_group_name": "_Test Customer Group", + "parent_customer_group": "All Customer Groups", + "is_group": "No" + }] +] \ No newline at end of file diff --git a/setup/doctype/item_group/item_group.py b/setup/doctype/item_group/item_group.py index 32c5d527c0..c0fd9068ab 100644 --- a/setup/doctype/item_group/item_group.py +++ b/setup/doctype/item_group/item_group.py @@ -67,4 +67,19 @@ class DocType(DocTypeNestedSet): if self.doc.slideshow: from website.helpers.slideshow import get_slideshow - get_slideshow(self) \ No newline at end of file + get_slideshow(self) + +test_records = [ + [{ + "doctype": "Item Group", + "item_group_name": "_Test Item Group", + "parent_item_group": "All Item Groups", + "is_group": "No" + }], + [{ + "doctype": "Item Group", + "item_group_name": "_Test Item Group Desktops", + "parent_item_group": "All Item Groups", + "is_group": "No" + }], +] \ No newline at end of file diff --git a/setup/doctype/territory/territory.py b/setup/doctype/territory/territory.py index 6d2da6a336..11bd4cc9c4 100644 --- a/setup/doctype/territory/territory.py +++ b/setup/doctype/territory/territory.py @@ -32,4 +32,13 @@ class DocType(DocTypeNestedSet): for d in getlist(self.doclist, 'target_details'): if not flt(d.target_qty) and not flt(d.target_amount): msgprint("Either target qty or target amount is mandatory.") - raise Exception \ No newline at end of file + raise Exception + +test_records = [ + [{ + "doctype": "Territory", + "territory_name": "_Test Territory", + "parent_territory": "All Territories", + "is_group": "No", + }] +] \ No newline at end of file diff --git a/setup/doctype/uom/uom.py b/setup/doctype/uom/uom.py index 7f48feb2eb..733cb57822 100644 --- a/setup/doctype/uom/uom.py +++ b/setup/doctype/uom/uom.py @@ -19,4 +19,11 @@ import webnotes class DocType: def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file + self.doc, self.doclist = d, dl + +test_records = [ + [{ + "doctype": "UOM", + "uom_name": "_Test UOM" + }] +] \ No newline at end of file diff --git a/setup/doctype/warehouse_type/warehouse_type.py b/setup/doctype/warehouse_type/warehouse_type.py index 7f48feb2eb..451db4122c 100644 --- a/setup/doctype/warehouse_type/warehouse_type.py +++ b/setup/doctype/warehouse_type/warehouse_type.py @@ -19,4 +19,11 @@ import webnotes class DocType: def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file + self.doc, self.doclist = d, dl + +test_records = [ + [{ + "doctype": "Warehouse Type", + "warehouse_type": "_Test Warehouse Type" + }] +] \ No newline at end of file diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index 2bbf48a370..b2923b1dd5 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -220,4 +220,48 @@ class DocType: if self.doc.slideshow: from website.helpers.slideshow import get_slideshow - get_slideshow(self) \ No newline at end of file + get_slideshow(self) + +test_records = [ + [{ + "doctype": "Item", + "item_code": "_Test Item Home Desktop 100", + "item_name": "_Test Item Home Desktop 100", + "description": "_Test Item Home Desktop 100", + "item_group": "_Test Item Group Desktops", + "is_stock_item": "Yes", + "is_asset_item": "No", + "has_batch_no": "No", + "has_serial_no": "No", + "is_purchase_item": "Yes", + "is_sales_item": "Yes", + "is_service_item": "No", + "is_sample_item": "No", + "inspection_required": "No", + "is_pro_applicable": "No", + "is_sub_contracted_item": "No", + }, + { + "doctype": "Item Tax", + "tax_type": "_Test Account Excise Duty - _TC", + "tax_rate": 10 + }], + [{ + "doctype": "Item", + "item_code": "_Test Item Home Desktop 200", + "item_name": "_Test Item Home Desktop 200", + "description": "_Test Item Home Desktop 200", + "item_group": "_Test Item Group Desktops", + "is_stock_item": "Yes", + "is_asset_item": "No", + "has_batch_no": "No", + "has_serial_no": "No", + "is_purchase_item": "Yes", + "is_sales_item": "Yes", + "is_service_item": "No", + "is_sample_item": "No", + "inspection_required": "No", + "is_pro_applicable": "No", + "is_sub_contracted_item": "No", + }], +] \ No newline at end of file diff --git a/stock/doctype/warehouse/warehouse.py b/stock/doctype/warehouse/warehouse.py index 7c3cbd6feb..a4ee3704e2 100644 --- a/stock/doctype/warehouse/warehouse.py +++ b/stock/doctype/warehouse/warehouse.py @@ -18,7 +18,6 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import cstr, flt, validate_email_add -from webnotes.model.doc import Document from webnotes.model.code import get_obj from webnotes import msgprint @@ -204,7 +203,15 @@ class DocType: # delete cancelled sle if sql("""select name from `tabStock Ledger Entry` where warehouse = %s and ifnull('is_cancelled', '') = 'No'""", self.doc.name): - mdgprint("""Warehosue can not be deleted as stock ledger entry - exists for this warehosue.""", raise_exception=1) + msgprint("""Warehosue can not be deleted as stock ledger entry + exists for this warehouse.""", raise_exception=1) else: - sql("delete from `tabStock Ledger Entry` where warehouse = %s", self.doc.name) \ No newline at end of file + sql("delete from `tabStock Ledger Entry` where warehouse = %s", self.doc.name) + +test_records = [ + [{ + "doctype": "Warehouse", + "warehouse_name": "_Test Warehouse", + "warehouse_type": "_Test Warehouse Type" + }] +] \ No newline at end of file From 677b4b4e7992565505581fbfe1e19ddcab28093c Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 7 Feb 2013 22:19:47 +0530 Subject: [PATCH 11/14] dynamic loading of grid reports --- startup/report_data_map.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/startup/report_data_map.py b/startup/report_data_map.py index dc1833d1e2..ff9f3e44cf 100644 --- a/startup/report_data_map.py +++ b/startup/report_data_map.py @@ -47,7 +47,7 @@ data_map = { "order_by": "lft" }, "GL Entry": { - "columns": ["account", "posting_date", "cost_center", "debit", "credit", "is_opening", + "columns": ["name", "account", "posting_date", "cost_center", "debit", "credit", "is_opening", "company", "voucher_type", "voucher_no", "remarks"], "conditions": ["ifnull(is_cancelled, 'No')='No'"], "order_by": "posting_date, account", @@ -86,7 +86,7 @@ data_map = { "order_by": "name" }, "Stock Ledger Entry": { - "columns": ["posting_date", "posting_time", "item_code", "warehouse", "actual_qty as qty", + "columns": ["name", "posting_date", "posting_time", "item_code", "warehouse", "actual_qty as qty", "voucher_type", "voucher_no", "ifnull(incoming_rate,0) as incoming_rate"], "conditions": ["ifnull(is_cancelled, 'No')='No'"], "order_by": "posting_date, posting_time, name", @@ -102,7 +102,7 @@ data_map = { "order_by": "posting_date, posting_time, name", }, "Production Order": { - "columns": ["production_item as item_code", + "columns": ["name", "production_item as item_code", "(ifnull(qty, 0) - ifnull(produced_qty, 0)) as qty", "fg_warehouse as warehouse"], "conditions": ["docstatus=1", "status != 'Stopped'", "ifnull(fg_warehouse, '')!=''", @@ -113,7 +113,7 @@ data_map = { }, }, "Purchase Request Item": { - "columns": ["item_code", "warehouse", + "columns": ["name", "item_code", "warehouse", "(ifnull(qty, 0) - ifnull(ordered_qty, 0)) as qty"], "from": "`tabPurchase Request Item` item, `tabPurchase Request` main", "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'", @@ -124,7 +124,7 @@ data_map = { }, }, "Purchase Order Item": { - "columns": ["item_code", "warehouse", + "columns": ["name", "item_code", "warehouse", "(ifnull(qty, 0) - ifnull(received_qty, 0)) as qty"], "from": "`tabPurchase Order Item` item, `tabPurchase Order` main", "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'", @@ -136,7 +136,7 @@ data_map = { }, "Sales Order Item": { - "columns": ["item_code", "(ifnull(qty, 0) - ifnull(delivered_qty, 0)) as qty", + "columns": ["name", "item_code", "(ifnull(qty, 0) - ifnull(delivered_qty, 0)) as qty", "reserved_warehouse as warehouse"], "from": "`tabSales Order Item` item, `tabSales Order` main", "conditions": ["item.parent = main.name", "main.docstatus=1", "main.status != 'Stopped'", @@ -178,7 +178,7 @@ data_map = { } }, "Sales Invoice Item": { - "columns": ["parent", "item_code", "qty", "amount"], + "columns": ["name", "parent", "item_code", "qty", "amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { @@ -196,7 +196,7 @@ data_map = { } }, "Sales Order Item[Sales Analytics]": { - "columns": ["parent", "item_code", "qty", "amount"], + "columns": ["name", "parent", "item_code", "qty", "amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { @@ -214,7 +214,7 @@ data_map = { } }, "Delivery Note Item[Sales Analytics]": { - "columns": ["parent", "item_code", "qty", "amount"], + "columns": ["name", "parent", "item_code", "qty", "amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { @@ -246,7 +246,7 @@ data_map = { } }, "Purchase Invoice Item": { - "columns": ["parent", "item_code", "qty", "amount"], + "columns": ["name", "parent", "item_code", "qty", "amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { @@ -264,7 +264,7 @@ data_map = { } }, "Purchase Order Item[Purchase Analytics]": { - "columns": ["parent", "item_code", "qty", "amount"], + "columns": ["name", "parent", "item_code", "qty", "amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { @@ -282,7 +282,7 @@ data_map = { } }, "Purchase Receipt Item[Purchase Analytics]": { - "columns": ["parent", "item_code", "qty", "amount"], + "columns": ["name", "parent", "item_code", "qty", "amount"], "conditions": ["docstatus=1", "ifnull(parent, '')!=''"], "order_by": "parent", "links": { From 197861f576b0d0079b613b96be0c53d019603de3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 8 Feb 2013 11:28:40 +0530 Subject: [PATCH 12/14] Update hr/doctype/leave_application/leave_application.txt changed permlevel for some fiedls in leave application --- hr/doctype/leave_application/leave_application.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hr/doctype/leave_application/leave_application.txt b/hr/doctype/leave_application/leave_application.txt index e105dff0f1..ec17544df5 100644 --- a/hr/doctype/leave_application/leave_application.txt +++ b/hr/doctype/leave_application/leave_application.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-02 14:40:08", "docstatus": 0, - "modified": "2013-02-07 08:54:22", + "modified": "2013-02-08 11:27:22", "modified_by": "Administrator", "owner": "Administrator" }, @@ -165,7 +165,7 @@ "fieldtype": "Date", "label": "Posting Date", "no_copy": 1, - "permlevel": 2, + "permlevel": 0, "reqd": 1 }, { @@ -175,7 +175,7 @@ "in_filter": 1, "label": "Fiscal Year", "options": "link:Fiscal Year", - "permlevel": 2, + "permlevel": 0, "read_only": 0, "reqd": 1, "search_index": 0 @@ -195,7 +195,7 @@ "fieldtype": "Link", "label": "Letter Head", "options": "Letter Head", - "permlevel": 2, + "permlevel": 0, "print_hide": 1, "read_only": 0 }, @@ -250,4 +250,4 @@ "role": "Leave Approver", "submit": 0 } -] \ No newline at end of file +] From df35645e2a2243ce3cec279bd624020ce9686b06 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 8 Feb 2013 13:09:18 +0530 Subject: [PATCH 13/14] Update hr/doctype/employee/employee.txt removed salary structure button --- hr/doctype/employee/employee.txt | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/hr/doctype/employee/employee.txt b/hr/doctype/employee/employee.txt index e8879f5fb8..7b1f730353 100644 --- a/hr/doctype/employee/employee.txt +++ b/hr/doctype/employee/employee.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-23 19:57:17", "docstatus": 0, - "modified": "2013-01-29 17:47:25", + "modified": "2013-02-08 13:07:25", "modified_by": "Administrator", "owner": "Administrator" }, @@ -543,14 +543,6 @@ "fieldtype": "Date", "label": "Valid Upto" }, - { - "doctype": "DocField", - "fieldname": "salary_structure", - "fieldtype": "Button", - "hidden": 1, - "label": "Salary Structure", - "oldfieldtype": "Button" - }, { "doctype": "DocField", "fieldname": "place_of_issue", @@ -775,4 +767,4 @@ "role": "HR Manager", "write": 1 } -] \ No newline at end of file +] From 6a5efa972bede2d8f3eedb74883f7d14caaf916d Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 8 Feb 2013 13:57:05 +0530 Subject: [PATCH 14/14] added test record for purchase invoice test case --- .../purchase_invoice/test_purchase_invoice.py | 170 ++++++++++++++++-- selling/doctype/customer/customer.py | 1 + stock/doctype/item/item.py | 2 + 3 files changed, 157 insertions(+), 16 deletions(-) diff --git a/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/accounts/doctype/purchase_invoice/test_purchase_invoice.py index d13af0e653..87577880f2 100644 --- a/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -147,9 +147,11 @@ class TestPurchaseInvoice(unittest.TestCase): def load_test_data(self): from webnotes.test_runner import make_test_records + make_test_records("Cost Center", verbose=0) + make_test_records("Item", verbose=0) make_test_records("Purchase Invoice", verbose=0) - def test_gl_entries(self): + def atest_gl_entries(self): wrapper = webnotes.model_wrapper(purchase_invoice_doclist).insert() wrapper.submit() wrapper.load_from_db() @@ -171,25 +173,161 @@ class TestPurchaseInvoice(unittest.TestCase): for d in gl_entries: self.assertEqual([d.debit, d.credit], expected_gl_entries.get(d.account)) - def atest_purchase_invoice_calculation(self): - test_doclist = [] + purchase_invoice_doclist - for doc in test_doclist: - if doc["doctype"] == "Purchase Taxes and Charges": - del doc["tax_amount"] + def test_purchase_invoice_calculation(self): + test_doclist = [ + # parent + { + "doctype": "Purchase Invoice", + "naming_series": "BILL", + "supplier_name": "_Test Supplier", + "credit_to": "_Test Supplier - _TC", + "bill_no": "NA", + "posting_date": "2013-02-03", + "fiscal_year": "_Test Fiscal Year", + "company": "_Test Company", + "currency": "INR", + "conversion_rate": 1, + "grand_total_import": 0 # for feed + }, + # items + { + "doctype": "Purchase Invoice Item", + "parentfield": "entries", + "item_code": "_Test Item Home Desktop 100", + "item_name": "_Test Item Home Desktop 100", + "qty": 10, + "import_rate": 50, + "import_amount": 500, + "rate": 50, + "amount": 50, + "uom": "_Test UOM", + "item_tax_rate": json.dumps({"_Test Account Excise Duty - _TC": 10}), + "expense_head": "_Test Account Cost for Goods Sold - _TC", + "cost_center": "_Test Cost Center - _TC" + + }, + { + "doctype": "Purchase Invoice Item", + "parentfield": "entries", + "item_code": "_Test Item Home Desktop 200", + "item_name": "_Test Item Home Desktop 200", + "qty": 5, + "import_rate": 150, + "import_amount": 750, + "rate": 150, + "amount": 750, + "uom": "_Test UOM", + "expense_head": "_Test Account Cost for Goods Sold - _TC", + "cost_center": "_Test Cost Center - _TC" + }, + # taxes + { + "doctype": "Purchase Taxes and Charges", + "parentfield": "purchase_tax_details", + "charge_type": "Actual", + "account_head": "_Test Account Shipping Charges - _TC", + "cost_center": "_Test Cost Center - _TC", + "description": "Shipping Charges", + "category": "Valuation and Total", + "add_deduct_tax": "Add", + "rate": 100 + }, + { + "doctype": "Purchase Taxes and Charges", + "parentfield": "purchase_tax_details", + "charge_type": "On Net Total", + "account_head": "_Test Account Customs Duty - _TC", + "cost_center": "_Test Cost Center - _TC", + "description": "Customs Duty", + "category": "Valuation", + "add_deduct_tax": "Add", + "rate": 10 + }, + { + "doctype": "Purchase Taxes and Charges", + "parentfield": "purchase_tax_details", + "charge_type": "On Net Total", + "account_head": "_Test Account Excise Duty - _TC", + "cost_center": "_Test Cost Center - _TC", + "description": "Excise Duty", + "category": "Total", + "add_deduct_tax": "Add", + "rate": 12 + }, + { + "doctype": "Purchase Taxes and Charges", + "parentfield": "purchase_tax_details", + "charge_type": "On Previous Row Amount", + "account_head": "_Test Account Education Cess - _TC", + "cost_center": "_Test Cost Center - _TC", + "description": "Education Cess", + "category": "Total", + "add_deduct_tax": "Add", + "rate": 2, + "row_id": 3 + }, + { + "doctype": "Purchase Taxes and Charges", + "parentfield": "purchase_tax_details", + "charge_type": "On Previous Row Amount", + "account_head": "_Test Account S&H Education Cess - _TC", + "cost_center": "_Test Cost Center - _TC", + "description": "S&H Education Cess", + "category": "Total", + "add_deduct_tax": "Add", + "rate": 1, + "row_id": 3 + }, + { + "doctype": "Purchase Taxes and Charges", + "parentfield": "purchase_tax_details", + "charge_type": "On Previous Row Total", + "account_head": "_Test Account CST - _TC", + "cost_center": "_Test Cost Center - _TC", + "description": "CST", + "category": "Total", + "add_deduct_tax": "Add", + "rate": 2, + "row_id": 5 + }, + { + "doctype": "Purchase Taxes and Charges", + "parentfield": "purchase_tax_details", + "charge_type": "On Net Total", + "account_head": "_Test Account VAT - _TC", + "cost_center": "_Test Cost Center - _TC", + "description": "VAT", + "category": "Total", + "add_deduct_tax": "Add", + "rate": 12.5 + }, + { + "doctype": "Purchase Taxes and Charges", + "parentfield": "purchase_tax_details", + "charge_type": "On Previous Row Total", + "account_head": "_Test Account Discount - _TC", + "cost_center": "_Test Cost Center - _TC", + "description": "Discount", + "category": "Total", + "add_deduct_tax": "Deduct", + "rate": 10, + "row_id": 7 + }, + ] wrapper = webnotes.model_wrapper(test_doclist).insert() wrapper.load_from_db() # tax amounts expected_values = [ - ["Shipping Charges - %s" % abbr, 100, 1350], - ["Customs Duty - %s" % abbr, 125, 1350], - ["Excise Duty - %s" % abbr, 140, 1490], - ["Education Cess - %s" % abbr, 2.8, 1492.8], - ["S&H Education Cess - %s" % abbr, 1.4, 1494.2], - ["CST - %s" % abbr, 29.88, 1524.08], - ["VAT - Test - %s" % abbr, 156.25, 1680.33], - ["Discount - %s" % abbr, 168.03, 1512.30], + ["_Test Account Shipping Charges - _TC", 100, 1350], + ["_Test Account Customs Duty - _TC", 125, 1350], + ["_Test Account Excise Duty - _TC", 140, 1490], + ["_Test Account Education Cess - _TC", 2.8, 1492.8], + ["_Test Account S&H Education Cess - _TC", 1.4, 1494.2], + ["_Test Account CST - _TC", 29.88, 1524.08], + ["_Test Account VAT - _TC", 156.25, 1680.33], + ["_Test Account Discount - _TC", 168.03, 1512.30], ] for i, tax in enumerate(wrapper.doclist.get({"parentfield": "purchase_tax_details"})): @@ -198,8 +336,8 @@ class TestPurchaseInvoice(unittest.TestCase): self.assertEqual(tax.total, expected_values[i][2]) expected_values = [ - ["Home Desktop 100", 90], - ["Home Desktop 200", 135] + ["_Test Item Home Desktop 100", 90], + ["_Test Item Home Desktop 200", 135] ] for i, item in enumerate(wrapper.doclist.get({"parentfield": "entries"})): self.assertEqual(item.item_code, expected_values[i][0]) diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py index 315e7931a9..932256fcf5 100644 --- a/selling/doctype/customer/customer.py +++ b/selling/doctype/customer/customer.py @@ -253,6 +253,7 @@ class DocType(TransactionBase): test_records = [ [{ "doctype": "Customer", + "customer_name": "_Test Customer", "customer_type": "Individual", "customer_group": "_Test Customer Group", "territory": "_Test Territory", diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index b2923b1dd5..2d781bd3b9 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -240,6 +240,7 @@ test_records = [ "inspection_required": "No", "is_pro_applicable": "No", "is_sub_contracted_item": "No", + "stock_uom": "_Test UOM" }, { "doctype": "Item Tax", @@ -263,5 +264,6 @@ test_records = [ "inspection_required": "No", "is_pro_applicable": "No", "is_sub_contracted_item": "No", + "stock_uom": "_Test UOM" }], ] \ No newline at end of file