Merge pull request #2232 from nabinhait/hotfix
Fix gl entries for stock transactions
This commit is contained in:
commit
81332789cb
@ -0,0 +1,26 @@
|
|||||||
|
# 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():
|
||||||
|
warehouses_with_account = frappe.db.sql_list("""select master_name from tabAccount
|
||||||
|
where ifnull(account_type, '') = 'Warehouse'""")
|
||||||
|
|
||||||
|
stock_vouchers_without_gle = frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no
|
||||||
|
from `tabStock Ledger Entry` sle
|
||||||
|
where sle.warehouse in (%s)
|
||||||
|
and not exists(select name from `tabGL Entry`
|
||||||
|
where voucher_type=sle.voucher_type and voucher_no=sle.voucher_no)
|
||||||
|
order by sle.posting_date""" %
|
||||||
|
', '.join(['%s']*len(warehouses_with_account)), tuple(warehouses_with_account))
|
||||||
|
|
||||||
|
for voucher_type, voucher_no in stock_vouchers_without_gle:
|
||||||
|
print voucher_type, voucher_no
|
||||||
|
frappe.db.sql("""delete from `tabGL Entry`
|
||||||
|
where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no))
|
||||||
|
|
||||||
|
voucher = frappe.get_doc(voucher_type, voucher_no)
|
||||||
|
voucher.make_gl_entries()
|
||||||
|
frappe.db.commit()
|
@ -1,5 +1,5 @@
|
|||||||
frappe.listview_settings['Item'] = {
|
frappe.listview_settings['Item'] = {
|
||||||
add_fields: ["item_name", "stock_uom", "item_group", "image",
|
add_fields: ["`tabItem`.`item_name`", "`tabItem`.`stock_uom`", "`tabItem`.`item_group`", "`tabItem`.`image`",
|
||||||
"is_stock_item", "is_sales_item", "is_purchase_item",
|
"`tabItem`.`is_stock_item`", "`tabItem`.`is_sales_item`", "`tabItem`.`is_purchase_item`",
|
||||||
"is_manufactured_item", "show_in_website"]
|
"`tabItem`.`is_manufactured_item`", "`tabItem`.`show_in_website`"]
|
||||||
};
|
};
|
||||||
|
@ -71,10 +71,10 @@ def get_item_warehouse_map(filters):
|
|||||||
for d in sle:
|
for d in sle:
|
||||||
iwb_map.setdefault(d.company, {}).setdefault(d.item_code, {}).\
|
iwb_map.setdefault(d.company, {}).setdefault(d.item_code, {}).\
|
||||||
setdefault(d.warehouse, frappe._dict({\
|
setdefault(d.warehouse, frappe._dict({\
|
||||||
"opening_qty": 0.0, "opening_val": 0.0,
|
"opening_qty": 0.0, "opening_val": 0.0,
|
||||||
"in_qty": 0.0, "in_val": 0.0,
|
"in_qty": 0.0, "in_val": 0.0,
|
||||||
"out_qty": 0.0, "out_val": 0.0,
|
"out_qty": 0.0, "out_val": 0.0,
|
||||||
"bal_qty": 0.0, "bal_val": 0.0,
|
"bal_qty": 0.0, "bal_val": 0.0,
|
||||||
"val_rate": 0.0, "uom": None
|
"val_rate": 0.0, "uom": None
|
||||||
}))
|
}))
|
||||||
qty_dict = iwb_map[d.company][d.item_code][d.warehouse]
|
qty_dict = iwb_map[d.company][d.item_code][d.warehouse]
|
||||||
@ -82,19 +82,19 @@ def get_item_warehouse_map(filters):
|
|||||||
|
|
||||||
if d.posting_date < filters["from_date"]:
|
if d.posting_date < filters["from_date"]:
|
||||||
qty_dict.opening_qty += flt(d.actual_qty)
|
qty_dict.opening_qty += flt(d.actual_qty)
|
||||||
qty_dict.opening_val += flt(d.actual_qty * d.valuation_rate)
|
qty_dict.opening_val += flt(d.actual_qty) * flt(d.valuation_rate)
|
||||||
elif d.posting_date >= filters["from_date"] and d.posting_date <= filters["to_date"]:
|
elif d.posting_date >= filters["from_date"] and d.posting_date <= filters["to_date"]:
|
||||||
qty_dict.val_rate = d.valuation_rate
|
qty_dict.val_rate = d.valuation_rate
|
||||||
|
|
||||||
if flt(d.actual_qty) > 0:
|
if flt(d.actual_qty) > 0:
|
||||||
qty_dict.in_qty += flt(d.actual_qty)
|
qty_dict.in_qty += flt(d.actual_qty)
|
||||||
qty_dict.in_val += flt(d.actual_qty * d.valuation_rate)
|
qty_dict.in_val += flt(d.actual_qty) * flt(d.valuation_rate)
|
||||||
else:
|
else:
|
||||||
qty_dict.out_qty += abs(flt(d.actual_qty))
|
qty_dict.out_qty += abs(flt(d.actual_qty))
|
||||||
qty_dict.out_val += flt(abs(flt(d.actual_qty)) * d.valuation_rate)
|
qty_dict.out_val += flt(abs(flt(d.actual_qty) * flt(d.valuation_rate)))
|
||||||
|
|
||||||
qty_dict.bal_qty += flt(d.actual_qty)
|
qty_dict.bal_qty += flt(d.actual_qty)
|
||||||
qty_dict.bal_val += flt(d.actual_qty * d.valuation_rate)
|
qty_dict.bal_val += flt(d.actual_qty) * flt(d.valuation_rate)
|
||||||
|
|
||||||
return iwb_map
|
return iwb_map
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user