From c5d4fc38aa57e4bde919d5e8e1859fcd11e3e4d3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 15 Jan 2014 10:54:07 +0530 Subject: [PATCH 1/7] Fixes in monthly salary register --- .../monthly_salary_register/monthly_salary_register.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hr/report/monthly_salary_register/monthly_salary_register.py b/hr/report/monthly_salary_register/monthly_salary_register.py index 9b8a84fd91..42c62e474b 100644 --- a/hr/report/monthly_salary_register/monthly_salary_register.py +++ b/hr/report/monthly_salary_register/monthly_salary_register.py @@ -50,9 +50,9 @@ def get_columns(salary_slips): where ifnull(d_modified_amount, 0) != 0 and parent in (%s)""" % (', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips])) - columns = columns + [(e + ":Link/Earning Type:120") for e in earning_types] + \ + columns = columns + [(e + ":Currency:120") for e in earning_types] + \ ["Arrear Amount:Currency:120", "Leave Encashment Amount:Currency:150", - "Gross Pay:Currency:120"] + [(d + ":Link/Deduction Type:120") for d in ded_types] + \ + "Gross Pay:Currency:120"] + [(d + ":Currency:120") for d in ded_types] + \ ["Total Deduction:Currency:120", "Net Pay:Currency:120"] return columns, earning_types, ded_types @@ -102,6 +102,6 @@ def get_ss_ded_map(salary_slips): ss_ded_map = {} for d in ss_deductions: ss_ded_map.setdefault(d.parent, webnotes._dict()).setdefault(d.d_type, []) - ss_ded_map[d.parent][d.e_type] = flt(d.d_modified_amount) + ss_ded_map[d.parent][d.d_type] = flt(d.d_modified_amount) return ss_ded_map \ No newline at end of file From a6df26839dea38b04a17ecf29fafd2f60bc73d8b Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 15 Jan 2014 12:21:14 +0530 Subject: [PATCH 2/7] Higher priority to user's default price list over customer's default price list --- utilities/transaction_base.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py index 5c28d8d8b6..f783faa9ec 100644 --- a/utilities/transaction_base.py +++ b/utilities/transaction_base.py @@ -79,9 +79,10 @@ class TransactionBase(StatusUpdater): """ customer_defaults = self.get_customer_defaults() - customer_defaults["selling_price_list"] = customer_defaults.get("price_list") or \ - webnotes.conn.get_value("Customer Group", self.doc.customer_group, "default_price_list") or \ - self.doc.selling_price_list + customer_defaults["selling_price_list"] = self.get_user_default_price_list("Selling") or \ + customer_defaults.get("price_list") or \ + webnotes.conn.get_value("Customer Group", self.doc.customer_group, + "default_price_list") or self.doc.selling_price_list for fieldname, val in customer_defaults.items(): if self.meta.get_field(fieldname): @@ -90,6 +91,12 @@ class TransactionBase(StatusUpdater): if self.meta.get_field("sales_team") and self.doc.customer: self.set_sales_team_for_customer() + def get_user_default_price_list(self, price_list_for): + from webnotes.defaults import get_user_default_as_list + user_default_price_list = get_user_default_as_list("selling_price_list" + if price_list_for=="Selling" else "buying_price_list") + return user_default_price_list[0] if len(user_default_price_list)==1 else "" + def set_sales_team_for_customer(self): from webnotes.model import default_fields @@ -120,8 +127,9 @@ class TransactionBase(StatusUpdater): out["supplier_name"] = supplier.supplier_name if supplier.default_currency: out["currency"] = supplier.default_currency - if supplier.default_price_list: - out["buying_price_list"] = supplier.default_price_list + + out["buying_price_list"] = self.get_user_default_price_list("Buying") or \ + supplier.default_price_list or self.doc.buying_price_list return out From a682d45846de23f3c03382a4d371befe2b5342f7 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Wed, 15 Jan 2014 16:39:01 +0530 Subject: [PATCH 3/7] webnotes/erpnext # 1320 - hide fields fix --- accounts/doctype/pos_setting/pos_setting.txt | 4 ++-- .../doctype/purchase_receipt_item/purchase_receipt_item.txt | 4 ++-- stock/doctype/stock_entry_detail/stock_entry_detail.txt | 6 +++--- stock/doctype/stock_reconciliation/stock_reconciliation.txt | 5 +++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/accounts/doctype/pos_setting/pos_setting.txt b/accounts/doctype/pos_setting/pos_setting.txt index 09a3757985..4319c268ed 100755 --- a/accounts/doctype/pos_setting/pos_setting.txt +++ b/accounts/doctype/pos_setting/pos_setting.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 12:15:51", "docstatus": 0, - "modified": "2013-11-02 16:58:38", + "modified": "2014-01-15 16:23:58", "modified_by": "Administrator", "owner": "Administrator" }, @@ -154,7 +154,7 @@ "reqd": 1 }, { - "depends_on": "eval:sys_defaults.auto_accounting_for_stock", + "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", "doctype": "DocField", "fieldname": "expense_account", "fieldtype": "Link", diff --git a/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt b/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt index 1d9397909d..9bc66a42da 100755 --- a/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt +++ b/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 19:29:10", "docstatus": 0, - "modified": "2014-01-03 18:28:20", + "modified": "2014-01-15 16:00:44", "modified_by": "Administrator", "owner": "Administrator" }, @@ -336,7 +336,7 @@ }, { "default": ":Company", - "depends_on": "eval:sys_defaults.auto_accounting_for_stock", + "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", "doctype": "DocField", "fieldname": "cost_center", "fieldtype": "Link", diff --git a/stock/doctype/stock_entry_detail/stock_entry_detail.txt b/stock/doctype/stock_entry_detail/stock_entry_detail.txt index b97928b961..25835e0bf3 100644 --- a/stock/doctype/stock_entry_detail/stock_entry_detail.txt +++ b/stock/doctype/stock_entry_detail/stock_entry_detail.txt @@ -2,7 +2,7 @@ { "creation": "2013-03-29 18:22:12", "docstatus": 0, - "modified": "2013-11-08 16:15:44", + "modified": "2014-01-15 16:08:45", "modified_by": "Administrator", "owner": "Administrator" }, @@ -165,7 +165,7 @@ "read_only": 1 }, { - "depends_on": "eval:sys_defaults.auto_accounting_for_stock", + "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", "doctype": "DocField", "fieldname": "expense_account", "fieldtype": "Link", @@ -175,7 +175,7 @@ }, { "default": ":Company", - "depends_on": "eval:sys_defaults.auto_accounting_for_stock", + "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", "doctype": "DocField", "fieldname": "cost_center", "fieldtype": "Link", diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.txt b/stock/doctype/stock_reconciliation/stock_reconciliation.txt index c9959d36e3..7d5021c89e 100644 --- a/stock/doctype/stock_reconciliation/stock_reconciliation.txt +++ b/stock/doctype/stock_reconciliation/stock_reconciliation.txt @@ -2,7 +2,7 @@ { "creation": "2013-03-28 10:35:31", "docstatus": 0, - "modified": "2013-09-24 15:35:12", + "modified": "2014-01-15 15:45:07", "modified_by": "Administrator", "owner": "Administrator" }, @@ -102,7 +102,7 @@ "reqd": 1 }, { - "depends_on": "eval:sys_defaults.auto_accounting_for_stock", + "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", "doctype": "DocField", "fieldname": "expense_account", "fieldtype": "Link", @@ -110,6 +110,7 @@ "options": "Account" }, { + "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", "doctype": "DocField", "fieldname": "cost_center", "fieldtype": "Link", From 39eb7faeb9148cb667834cbdce00eab926ac2a25 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 15 Jan 2014 17:36:18 +0530 Subject: [PATCH 4/7] Update billing percentage and status from SI/PI in SO/PO, when net total is zero --- .../accounts_settings/accounts_settings.py | 8 +++- .../purchase_invoice/purchase_invoice.py | 3 +- .../doctype/sales_invoice/sales_invoice.py | 2 + controllers/status_updater.py | 37 +++++++++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/accounts/doctype/accounts_settings/accounts_settings.py b/accounts/doctype/accounts_settings/accounts_settings.py index a6e993863d..2475fdaf66 100644 --- a/accounts/doctype/accounts_settings/accounts_settings.py +++ b/accounts/doctype/accounts_settings/accounts_settings.py @@ -6,6 +6,7 @@ from __future__ import unicode_literals import webnotes from webnotes import _ +from webnotes.utils import cint class DocType: def __init__(self, d, dl): @@ -14,7 +15,12 @@ class DocType: def on_update(self): webnotes.conn.set_default("auto_accounting_for_stock", self.doc.auto_accounting_for_stock) - if self.doc.auto_accounting_for_stock: + if cint(self.doc.auto_accounting_for_stock): + # set default perpetual account in company + for company in webnotes.conn.sql("select name from tabCompany"): + webnotes.bean("Company", company[0]).save() + + # Create account head for warehouses warehouse_list = webnotes.conn.sql("select name, company from tabWarehouse", as_dict=1) warehouse_with_no_company = [d.name for d in warehouse_list if not d.company] if warehouse_with_no_company: diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py index 06b7a3ad2e..fcd6846507 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -302,6 +302,7 @@ class DocType(BuyingController): self.make_gl_entries() self.update_against_document_in_jv() self.update_prevdoc_status() + self.update_billing_status_for_zero_amount_refdoc("Purchase Order") def make_gl_entries(self): auto_accounting_for_stock = \ @@ -421,7 +422,7 @@ class DocType(BuyingController): remove_against_link_from_jv(self.doc.doctype, self.doc.name, "against_voucher") self.update_prevdoc_status() - + self.update_billing_status_for_zero_amount_refdoc("Purchase Order") self.make_cancel_gl_entries() def on_update(self): diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index bfba30fa1b..a39702b3fc 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -88,6 +88,7 @@ class DocType(SellingController): self.update_status_updater_args() self.update_prevdoc_status() + self.update_billing_status_for_zero_amount_refdoc("Sales Order") # this sequence because outstanding may get -ve self.make_gl_entries() @@ -114,6 +115,7 @@ class DocType(SellingController): self.update_status_updater_args() self.update_prevdoc_status() + self.update_billing_status_for_zero_amount_refdoc("Sales Order") self.make_cancel_gl_entries() diff --git a/controllers/status_updater.py b/controllers/status_updater.py index a285c4798d..1743887bf7 100644 --- a/controllers/status_updater.py +++ b/controllers/status_updater.py @@ -232,6 +232,43 @@ class StatusUpdater(DocListController): 'Fully %(keyword)s', 'Partly %(keyword)s')) where name='%(name)s'""" % args) + + def update_billing_status_for_zero_amount_refdoc(self, ref_dt): + ref_fieldname = ref_dt.lower().replace(" ", "_") + zero_amount_refdoc = [] + all_zero_amount_refdoc = webnotes.conn.sql_list("""select name from `tab%s` + where docstatus=1 and net_total = 0""" % ref_dt) + + for item in self.doclist.get({"parentfield": "entries"}): + if item.fields.get(ref_fieldname) \ + and item.fields.get(ref_fieldname) in all_zero_amount_refdoc \ + and item.fields.get(ref_fieldname) not in zero_amount_refdoc: + zero_amount_refdoc.append(item.fields[ref_fieldname]) + + if zero_amount_refdoc: + self.update_biling_status(zero_amount_refdoc, ref_dt, ref_fieldname) + + def update_biling_status(self, zero_amount_refdoc, ref_dt, ref_fieldname): + for ref_dn in zero_amount_refdoc: + ref_doc_qty = flt(webnotes.conn.sql("""select sum(ifnull(qty, 0)) from `tab%s Item` + where parent=%s""" % (ref_dt, '%s'), (ref_dn))[0][0]) + + billed_qty = flt(webnotes.conn.sql("""select sum(ifnull(qty, 0)) + from `tab%s Item` where %s=%s and docstatus=1""" % + (self.doc.doctype, ref_fieldname, '%s'), (ref_dn))[0][0]) + + per_billed = ((ref_doc_qty if billed_qty > ref_doc_qty else billed_qty)\ + / ref_doc_qty)*100 + webnotes.conn.set_value(ref_dt, ref_dn, "per_billed", per_billed) + + from webnotes.model.meta import has_field + if has_field(ref_dt, "billing_status"): + if per_billed < 0.001: billing_status = "Not Billed" + elif per_billed >= 99.99: billing_status = "Fully Billed" + else: billing_status = "Partly Billed" + + webnotes.conn.set_value(ref_dt, ref_dn, "billing_status", billing_status) + def get_tolerance_for(item_code, item_tolerance={}, global_tolerance=None): """ Returns the tolerance for the item, if not set, returns global tolerance From 5cdb8cea135f2df03e8a662fe37be28cc5735794 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 16 Jan 2014 12:08:12 +0530 Subject: [PATCH 5/7] Reset filters in Item Price report on each route --- stock/doctype/item/item.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js index c9aa75e7b7..e18a0f2809 100644 --- a/stock/doctype/item/item.js +++ b/stock/doctype/item/item.js @@ -29,10 +29,7 @@ cur_frm.cscript.make_dashboard = function() { cur_frm.cscript.edit_prices_button = function() { cur_frm.add_custom_button("Add / Edit Prices", function() { - wn.route_options = { - "item_code": cur_frm.doc.name - }; - wn.set_route("Report", "Item Price"); + wn.set_route("Report", "Item Price", {"item_code": cur_frm.doc.name}); }, "icon-money"); } From e31a97f3558479d6b6a989e1d716e21351c62547 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 16 Jan 2014 14:24:32 +0530 Subject: [PATCH 6/7] Calculate taxes and charges total in server side --- .../purchase_common/purchase_common.js | 30 +++++++++++-------- controllers/buying_controller.py | 22 ++++++++++++-- controllers/selling_controller.py | 3 +- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js index 14b8279245..e3957ab847 100644 --- a/buying/doctype/purchase_common/purchase_common.js +++ b/buying/doctype/purchase_common/purchase_common.js @@ -302,11 +302,11 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ calculate_totals: function() { var tax_count = this.frm.tax_doclist.length; - this.frm.doc.grand_total = flt( - tax_count ? this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total, + this.frm.doc.grand_total = flt(tax_count ? + this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total, precision("grand_total")); - this.frm.doc.grand_total_import = flt(this.frm.doc.grand_total / this.frm.doc.conversion_rate, - precision("grand_total_import")); + this.frm.doc.grand_total_import = flt(this.frm.doc.grand_total / + this.frm.doc.conversion_rate, precision("grand_total_import")); this.frm.doc.total_tax = flt(this.frm.doc.grand_total - this.frm.doc.net_total, precision("total_tax")); @@ -321,20 +321,26 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ } // other charges added/deducted + this.frm.doc.other_charges_added = 0.0 + this.frm.doc.other_charges_deducted = 0.0 if(tax_count) { this.frm.doc.other_charges_added = wn.utils.sum($.map(this.frm.tax_doclist, - function(tax) { return (tax.add_deduct_tax == "Add" && in_list(["Valuation and Total", "Total"], tax.category)) ? tax.tax_amount : 0.0; })); + function(tax) { return (tax.add_deduct_tax == "Add" + && in_list(["Valuation and Total", "Total"], tax.category)) ? + tax.tax_amount : 0.0; })); this.frm.doc.other_charges_deducted = wn.utils.sum($.map(this.frm.tax_doclist, - function(tax) { return (tax.add_deduct_tax == "Deduct" && in_list(["Valuation and Total", "Total"], tax.category)) ? tax.tax_amount : 0.0; })); + function(tax) { return (tax.add_deduct_tax == "Deduct" + && in_list(["Valuation and Total", "Total"], tax.category)) ? + tax.tax_amount : 0.0; })); - wn.model.round_floats_in(this.frm.doc, ["other_charges_added", "other_charges_deducted"]); - - this.frm.doc.other_charges_added_import = flt(this.frm.doc.other_charges_added / this.frm.doc.conversion_rate, - precision("other_charges_added_import")); - this.frm.doc.other_charges_deducted_import = flt(this.frm.doc.other_charges_deducted / this.frm.doc.conversion_rate, - precision("other_charges_deducted_import")); + wn.model.round_floats_in(this.frm.doc, + ["other_charges_added", "other_charges_deducted"]); } + this.frm.doc.other_charges_added_import = flt(this.frm.doc.other_charges_added / + this.frm.doc.conversion_rate, precision("other_charges_added_import")); + this.frm.doc.other_charges_deducted_import = flt(this.frm.doc.other_charges_deducted / + this.frm.doc.conversion_rate, precision("other_charges_deducted_import")); }, _cleanup: function() { diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index 7954ca0abb..bdc7327c5f 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -124,8 +124,8 @@ class BuyingController(StockController): self.round_floats_in(self.doc, ["net_total", "net_total_import"]) def calculate_totals(self): - self.doc.grand_total = flt(self.tax_doclist and \ - self.tax_doclist[-1].total or self.doc.net_total, self.precision("grand_total")) + self.doc.grand_total = flt(self.tax_doclist[-1].total if self.tax_doclist + else self.doc.net_total, self.precision("grand_total")) self.doc.grand_total_import = flt(self.doc.grand_total / self.doc.conversion_rate, self.precision("grand_total_import")) @@ -137,6 +137,24 @@ class BuyingController(StockController): if self.meta.get_field("rounded_total_import"): self.doc.rounded_total_import = _round(self.doc.grand_total_import) + + if self.meta.get_field("other_charges_added"): + self.doc.other_charges_added = flt(sum([flt(d.tax_amount) for d in self.tax_doclist + if d.add_deduct_tax=="Add" and d.category in ["Valuation and Total", "Total"]]), + self.precision("other_charges_added")) + + if self.meta.get_field("other_charges_deducted"): + self.doc.other_charges_deducted = flt(sum([flt(d.tax_amount) for d in self.tax_doclist + if d.add_deduct_tax=="Deduct" and d.category in ["Valuation and Total", "Total"]]), + self.precision("other_charges_deducted")) + + if self.meta.get_field("other_charges_added_import"): + self.doc.other_charges_added_import = flt(self.doc.other_charges_added / + self.doc.conversion_rate, self.precision("other_charges_added_import")) + + if self.meta.get_field("other_charges_deducted_import"): + self.doc.other_charges_deducted_import = flt(self.doc.other_charges_deducted / + self.doc.conversion_rate, self.precision("other_charges_deducted_import")) def calculate_outstanding_amount(self): if self.doc.doctype == "Purchase Invoice" and self.doc.docstatus < 2: diff --git a/controllers/selling_controller.py b/controllers/selling_controller.py index 67c1462662..4806c73a81 100644 --- a/controllers/selling_controller.py +++ b/controllers/selling_controller.py @@ -191,7 +191,8 @@ class SellingController(StockController): self.doc.other_charges_total = flt(self.doc.grand_total - self.doc.net_total, self.precision("other_charges_total")) - self.doc.other_charges_total_export = flt(self.doc.grand_total_export - self.doc.net_total_export, + self.doc.other_charges_total_export = flt( + self.doc.grand_total_export - self.doc.net_total_export, self.precision("other_charges_total_export")) self.doc.rounded_total = _round(self.doc.grand_total) From 6933617538236c33f1ae2c103483b4161dc1dab3 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Thu, 16 Jan 2014 16:59:22 +0600 Subject: [PATCH 7/7] bumped to version 3.6.2 --- config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index 45acaf2cd3..c2524671a0 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.6.1", + "app_version": "3.6.2", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": { @@ -74,5 +74,5 @@ "type": "module" } }, - "requires_framework_version": "==3.7.1" + "requires_framework_version": "==3.7.2" } \ No newline at end of file