Merge pull request #2035 from nabinhait/hotfix
Account master type patch and Stock RBNB Diff
This commit is contained in:
commit
e7f7416190
@ -363,3 +363,31 @@ 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 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))
|
||||
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
|
||||
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)
|
||||
|
@ -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
|
||||
|
12
erpnext/patches/v4_2/fix_account_master_type.py
Normal file
12
erpnext/patches/v4_2/fix_account_master_type.py
Normal file
@ -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()
|
@ -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({
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user