From 05b56d0d08c73777dbfaff8186ea64ead68431c3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 7 Aug 2014 15:03:25 +0530 Subject: [PATCH 1/4] Fix account's master type --- erpnext/patches.txt | 1 + erpnext/patches/v4_2/fix_account_master_type.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 erpnext/patches/v4_2/fix_account_master_type.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 7fc858dee7..1ae0a952a7 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -73,3 +73,4 @@ execute:frappe.delete_doc("DocType", "Payment to Invoice Matching Tool Detail") execute:frappe.delete_doc("Page", "trial-balance") #2014-07-22 erpnext.patches.v4_2.delete_old_print_formats #2014-07-29 erpnext.patches.v4_2.toggle_rounded_total #2014-07-30 +erpnext.patches.v4_2.fix_account_master_type diff --git a/erpnext/patches/v4_2/fix_account_master_type.py b/erpnext/patches/v4_2/fix_account_master_type.py new file mode 100644 index 0000000000..09fa7891d0 --- /dev/null +++ b/erpnext/patches/v4_2/fix_account_master_type.py @@ -0,0 +1,12 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + for d in frappe.db.sql("""select name from `tabAccount` + where ifnull(master_type, '') not in ('Customer', 'Supplier', 'Employee', '')"""): + ac = frappe.get_doc("Account", d[0]) + ac.master_type = None + ac.save() From 9a0c46fda747de760b8f163d5846fe254039f7a9 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 7 Aug 2014 15:10:05 +0530 Subject: [PATCH 2/4] Get Stock Rreceived But Not Billed Difference Amount --- erpnext/accounts/utils.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 0144108a22..7185216417 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -363,3 +363,30 @@ def get_currency_precision(currency=None): from frappe.utils import get_number_format_info return get_number_format_info(currency_format)[2] + +def get_stock_rbnb_difference(posting_date, company): + stock_items = frappe.db.sql_list("""select distinct item_code + from `tabStock Ledger Entry` where comapny=%s""", company) + + pr_valuation_amount = frappe.db.sql(""" + select sum(ifnull(pr_item.valuation_rate, 0) * ifnull(pr_item.qty, 0) * ifnull(pr_item.conversion_factor, 0)) + from `tabPurchase Receipt Item` pr_item, `tabPurchase Receipt` pr + where pr.name = pr_item.parent and pr.docstatus=1 and pr.company=%s + and pr.posting_date <= %s and pr_item.item_code in (%s)""" % + ('%s', '%s', ', '.join(['%s']*len(stock_items))), tuple([company, posting_date] + stock_items))[0][0] + + pi_valuation_amount = frappe.db.sql(""" + select sum(ifnull(pi_item.valuation_rate, 0) * ifnull(pi_item.qty, 0) * ifnull(pi_item.conversion_factor, 0)) + from `tabPurchase Invoice Item` pi_item, `tabPurchase Invoice` pi + where pi.name = pi_item.parent and pi.docstatus=1 and pi.company=%s + and pi.posting_date <= %s and pi_item.item_code in (%s)""" % + ('%s', '%s', ', '.join(['%s']*len(stock_items))), tuple([company, posting_date] + stock_items))[0][0] + + # Balance should be + stock_rbnb = flt(pr_valuation_amount, 2) - flt(pi_valuation_amount, 2) + + # Balance as per system + sys_bal = get_balance_on("Stock Received But Not Billed - RIGPL", posting_date) + + # Amount should be credited + return flt(stock_rbnb) + flt(sys_bal) From 849b7b172a38eba55505f4dc4f9af0b405275b6d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 7 Aug 2014 15:13:52 +0530 Subject: [PATCH 3/4] minor fix --- erpnext/accounts/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 7185216417..d1b65846d5 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -366,7 +366,7 @@ def get_currency_precision(currency=None): def get_stock_rbnb_difference(posting_date, company): stock_items = frappe.db.sql_list("""select distinct item_code - from `tabStock Ledger Entry` where comapny=%s""", company) + from `tabStock Ledger Entry` where company=%s""", company) pr_valuation_amount = frappe.db.sql(""" select sum(ifnull(pr_item.valuation_rate, 0) * ifnull(pr_item.qty, 0) * ifnull(pr_item.conversion_factor, 0)) @@ -386,7 +386,8 @@ def get_stock_rbnb_difference(posting_date, company): stock_rbnb = flt(pr_valuation_amount, 2) - flt(pi_valuation_amount, 2) # Balance as per system - sys_bal = get_balance_on("Stock Received But Not Billed - RIGPL", posting_date) + stock_rbnb_account = "Stock Received But Not Billed - " + frappe.db.get_value("Company", company, "abbr") + sys_bal = get_balance_on(stock_rbnb_account, posting_date) # Amount should be credited return flt(stock_rbnb) + flt(sys_bal) From 67cd3fb89ce5896c43ccdbe47a472fa7c3b69d33 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 7 Aug 2014 15:34:53 +0530 Subject: [PATCH 4/4] Fixes in making credit note from Sales Return --- .../stock/doctype/stock_entry/stock_entry.js | 17 ++++++++--------- .../stock/doctype/stock_entry/stock_entry.py | 6 +----- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 7dca72a88e..96b2cd5b70 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -211,10 +211,9 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ }, callback: function(r) { if(!r.exc) { - var jv_name = frappe.model.make_new_doc_and_get_name('Journal Voucher'); - var jv = locals["Journal Voucher"][jv_name]; - $.extend(jv, r.message); - loaddoc("Journal Voucher", jv_name); + var doclist = frappe.model.sync(r.message); + frappe.set_route("Form", doclist[0].doctype, doclist[0].name); + } } }); @@ -266,20 +265,20 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ customer: function() { this.get_party_details({ - party: this.frm.doc.customer, - party_type:"Customer", + party: this.frm.doc.customer, + party_type:"Customer", doctype: this.frm.doc.doctype }); }, supplier: function() { this.get_party_details({ - party: this.frm.doc.supplier, - party_type:"Supplier", + party: this.frm.doc.supplier, + party_type:"Supplier", doctype: this.frm.doc.doctype }); }, - + get_party_details: function(args) { var me = this; frappe.call({ diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 7629c3cefd..861d967596 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -780,14 +780,10 @@ def make_return_jv(stock_entry): from erpnext.accounts.utils import get_balance_on for r in result: jv.append("entries", { - "__islocal": 1, - "doctype": "Journal Voucher Detail", - "parentfield": "entries", "account": r.get("account"), "against_invoice": r.get("against_invoice"), "against_voucher": r.get("against_voucher"), - "balance": get_balance_on(r.get("account"), se.posting_date) \ - if r.get("account") else 0 + "balance": get_balance_on(r.get("account"), se.posting_date) if r.get("account") else 0 }) return jv