From d3b82cf9de460063a9a632c20605bd35bf1e4c37 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 4 Dec 2012 11:49:37 +0530 Subject: [PATCH 1/4] fixes in tax controller and test purchase receipt --- controllers/__init__.py | 0 controllers/tax_controller.py | 16 ++++++++++++++-- controllers/transaction_controller.py | 2 -- .../purchase_receipt/test_purchase_receipt.py | 19 +++++++++++++------ 4 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 controllers/__init__.py diff --git a/controllers/__init__.py b/controllers/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/controllers/tax_controller.py b/controllers/tax_controller.py index 6df17f54f5..d19a729ee6 100644 --- a/controllers/tax_controller.py +++ b/controllers/tax_controller.py @@ -72,6 +72,7 @@ class TaxController(TransactionController): self.calculate_taxes() self.calculate_totals() self.set_amount_in_words() + self.cleanup() def calculate_item_values(self): def _set_base(item, print_field, base_field): @@ -104,12 +105,12 @@ class TaxController(TransactionController): item.fields[self.fmap.print_amount] = \ flt(item.fields.get(self.fmap.print_rate) * \ - item.fields.get(self.fmap.qty), + item.fields.get("qty"), self.precision.item[self.fmap.print_amount]) _set_base(item, self.fmap.print_ref_rate, self.fmap.ref_rate) _set_base(item, self.fmap.print_rate, self.fmap.rate) - _set_base(item, self.fmap.print_amount, self.fmap.amount) + _set_base(item, self.fmap.print_amount, "amount") def initialize_taxes(self): for tax in self.tax_doclist: @@ -431,3 +432,14 @@ class TaxController(TransactionController): return flt(item_tax_map.get(tax.account_head), self.precision.tax.rate) else: return tax.rate + + def cleanup(self): + for f in ["taxes_and_charges_total_print", "rounded_total_in_words_print", + "rounded_total_print", "rounded_total_in_words"]: + del self.doc.fields[self.fmap.get(f) or f] + + for f in ["grand_total_print_for_current_item", "tax_amount_print", + "grand_total_for_current_item", "tax_amount_for_current_item", + "total_print"]: + for doc in self.doclist.get({"parentfield": self.fmap.taxes_and_charges}): + del doc.fields[self.fmap.get(f) or f] diff --git a/controllers/transaction_controller.py b/controllers/transaction_controller.py index 5d77472df7..a7dbde1ece 100644 --- a/controllers/transaction_controller.py +++ b/controllers/transaction_controller.py @@ -21,8 +21,6 @@ from webnotes import _, DictObj from webnotes.utils import cint import json -import stock.utils - from webnotes.model.controller import DocListController class TransactionController(DocListController): diff --git a/stock/doctype/purchase_receipt/test_purchase_receipt.py b/stock/doctype/purchase_receipt/test_purchase_receipt.py index 98418d0755..dfd2188baf 100644 --- a/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -97,24 +97,24 @@ base_purchase_receipt = [ "doctype": "Purchase Receipt Item", "item_code": "Home Desktop 100", "qty": 10, "received_qty": 10, "rejected_qty": 0, "purchase_rate": 50, - "amount": 500, "warehouse": "Default Warehouse", "valuation_tax_amount": 250, + "amount": 500, "warehouse": "Default Warehouse", "parentfield": "purchase_receipt_details", "conversion_factor": 1, "uom": "Nos", "stock_uom": "Nos" }, { "doctype": "Purchase Taxes and Charges", "charge_type": "Actual", - "account_head": "Shipping Charges - %s" % abbr, "purchase_rate": 100, "tax_amount": 100, + "account_head": "Shipping Charges - %s" % abbr, "rate": 100, "tax_amount": 100, "category": "Valuation and Total", "parentfield": "purchase_tax_details", "cost_center": "Default Cost Center - %s" % abbr }, { "doctype": "Purchase Taxes and Charges", "charge_type": "Actual", - "account_head": "VAT - Test - %s" % abbr, "purchase_rate": 120, "tax_amount": 120, + "account_head": "VAT - Test - %s" % abbr, "rate": 120, "tax_amount": 120, "category": "Total", "parentfield": "purchase_tax_details" }, { "doctype": "Purchase Taxes and Charges", "charge_type": "Actual", - "account_head": "Customs Duty - %s" % abbr, "purchase_rate": 150, "tax_amount": 150, + "account_head": "Customs Duty - %s" % abbr, "rate": 150, "tax_amount": 150, "category": "Valuation", "parentfield": "purchase_tax_details", "cost_center": "Default Cost Center - %s" % abbr } @@ -158,7 +158,6 @@ class TestPurchaseReceipt(unittest.TestCase): load_data() webnotes.conn.set_value("Global Defaults", None, "automatic_inventory_accounting", 1) - def test_purchase_receipt(self): # warehouse does not have stock in hand specified self.run_purchase_receipt_test(base_purchase_receipt, @@ -169,9 +168,17 @@ class TestPurchaseReceipt(unittest.TestCase): credit_account, stock_value): from webnotes.model.doclist import DocList dl = webnotes.insert(DocList(purchase_receipt)) + + from controllers.tax_controller import TaxController + tax_controller = TaxController(dl.doc, dl.doclist) + tax_controller.item_table_field = "purchase_receipt_details" + tax_controller.calculate_taxes_and_totals() + dl.doc = tax_controller.doc + dl.doclist = tax_controller.doclist + dl.submit() dl.load_from_db() - + gle = webnotes.conn.sql("""select account, ifnull(debit, 0), ifnull(credit, 0) from `tabGL Entry` where voucher_no = %s""", dl.doclist[0].name) From 5c2319549a57a51feb5c21f0f8b9c4a683869aa8 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 4 Dec 2012 11:53:42 +0530 Subject: [PATCH 2/4] updated webnotes.utils.__init__ with a few refactored methods --- .../doctype/trend_analyzer_control/trend_analyzer_control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/doctype/trend_analyzer_control/trend_analyzer_control.py b/accounts/doctype/trend_analyzer_control/trend_analyzer_control.py index f43542f109..b8461bd1c7 100755 --- a/accounts/doctype/trend_analyzer_control/trend_analyzer_control.py +++ b/accounts/doctype/trend_analyzer_control/trend_analyzer_control.py @@ -17,7 +17,7 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import add_days, add_months, cint, cstr, month_name +from webnotes.utils import add_days, add_months, cint, cstr from webnotes.model import db_exists from webnotes.model.wrapper import copy_doclist From 0bb2d2b4674419168b995442cba358b6b79b48ec Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 4 Dec 2012 12:36:36 +0530 Subject: [PATCH 3/4] report builder updates --- home/page/latest_updates/latest_updates.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/home/page/latest_updates/latest_updates.js b/home/page/latest_updates/latest_updates.js index 525c2679d5..80580d7cbe 100644 --- a/home/page/latest_updates/latest_updates.js +++ b/home/page/latest_updates/latest_updates.js @@ -1,4 +1,9 @@ erpnext.updates = [ + ["4rd December 2012", [ + "Email: Add contact name as 'Dear so-and-so' in Email.", + "Report Builder: Remember last column setup for users", + "Report Builder: Autoset column width (remember)", + ]], ["3rd December 2012", [ "Linked With: Added new Linked with in all Forms.", "Rename Tool: Documents that can be renamed will have a 'Rename' option in the sidebar (wherever applicable).", From e00244628ab3b3c9159fbdc7c4d0194e7de1f484 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 4 Dec 2012 12:38:00 +0530 Subject: [PATCH 4/4] fixed naming series form --- setup/doctype/naming_series/naming_series.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/setup/doctype/naming_series/naming_series.js b/setup/doctype/naming_series/naming_series.js index 967e8b0128..4a741e4fb2 100644 --- a/setup/doctype/naming_series/naming_series.js +++ b/setup/doctype/naming_series/naming_series.js @@ -15,10 +15,14 @@ // along with this program. If not, see . // Settings -cur_frm.cscript.onload = function(doc, cdt, cdn){ - cur_frm.call_server('get_transactions', '', cur_frm.cscript.update_selects); - - cur_frm.cscript.select_doc_for_series(doc); +cur_frm.cscript.onload_post_render = function(doc, cdt, cdn){ + cur_frm.call({ + method: 'get_transactions', + callback: function(r) { + cur_frm.cscript.update_selects(r); + cur_frm.cscript.select_doc_for_series(doc, cdt, cdn); + } + }) } cur_frm.cscript.update_selects = function(r) { @@ -47,7 +51,7 @@ cur_frm.cscript.update = function() { cur_frm.call_server('update_series', '', cur_frm.cscript.update_selects) } -cur_frm.cscript.prefix = function(doc) { +cur_frm.cscript.prefix = function(doc, dt, dn) { cur_frm.call_server('get_current', '', function(r) { refresh_field('current_value'); })