Merge branch 'master' into develop

This commit is contained in:
Nabin Hait 2016-06-24 12:48:24 +05:30
commit 2effad33d0
4 changed files with 42 additions and 21 deletions

View File

@ -271,3 +271,4 @@ erpnext.patches.v7_0.update_project_in_gl_entry
execute:frappe.db.sql('update tabQuotation set status="Cancelled" where docstatus=2')
execute:frappe.rename_doc("DocType", "Payments", "Sales Invoice Payment", force=True)
erpnext.patches.v7_0.update_mins_to_first_response
erpnext.patches.v6_20x.repost_valuation_rate_for_negative_inventory

View File

@ -0,0 +1,10 @@
# 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
from erpnext.stock.stock_balance import repost
def execute():
if frappe.db.get_value("Stock Settings", None, "allow_negative_stock"):
repost(only_actual=True)

View File

@ -192,7 +192,8 @@ class PurchaseReceipt(BuyingController):
stock_value_diff = frappe.db.get_value("Stock Ledger Entry",
{"voucher_type": "Purchase Receipt", "voucher_no": self.name,
"voucher_detail_no": d.name}, "stock_value_difference")
if not stock_value_diff:
continue
gl_entries.append(self.get_gl_dict({
"account": warehouse_account[d.warehouse]["name"],
"against": stock_rbnb,

View File

@ -232,24 +232,32 @@ class update_entries_after(object):
def get_moving_average_values(self, sle):
actual_qty = flt(sle.actual_qty)
new_stock_qty = flt(self.qty_after_transaction) + actual_qty
if new_stock_qty >= 0:
if actual_qty > 0:
if flt(self.qty_after_transaction) <= 0:
self.valuation_rate = sle.incoming_rate
else:
new_stock_value = (self.qty_after_transaction * self.valuation_rate) + \
(actual_qty * sle.incoming_rate)
if actual_qty > 0 or flt(sle.outgoing_rate) > 0:
rate = flt(sle.incoming_rate) if actual_qty > 0 else flt(sle.outgoing_rate)
self.valuation_rate = new_stock_value / new_stock_qty
if self.qty_after_transaction < 0 and not self.valuation_rate:
# if negative stock, take current valuation rate as incoming rate
self.valuation_rate = rate
elif sle.outgoing_rate:
if new_stock_qty:
new_stock_value = (self.qty_after_transaction * self.valuation_rate) + \
(actual_qty * sle.outgoing_rate)
new_stock_qty = abs(self.qty_after_transaction) + actual_qty
new_stock_value = (abs(self.qty_after_transaction) * self.valuation_rate) + (actual_qty * rate)
self.valuation_rate = new_stock_value / new_stock_qty
else:
self.valuation_rate = self.outgoing_rate
if new_stock_qty:
self.valuation_rate = new_stock_value / flt(new_stock_qty)
else:
if flt(self.qty_after_transaction) >= 0 and sle.outgoing_rate:
self.valuation_rate = sle.outgoing_rate
elif not self.valuation_rate and self.qty_after_transaction <= 0:
self.valuation_rate = get_valuation_rate(sle.item_code, sle.warehouse, self.allow_zero_rate)
self.valuation_rate = abs(flt(self.valuation_rate))
if not self.valuation_rate and actual_qty > 0:
self.valuation_rate = sle.incoming_rate
def get_fifo_values(self, sle):
incoming_rate = flt(sle.incoming_rate)
@ -268,10 +276,7 @@ class update_entries_after(object):
self.stock_queue.append([actual_qty, incoming_rate])
else:
qty = self.stock_queue[-1][0] + actual_qty
if qty == 0:
self.stock_queue.pop(-1)
else:
self.stock_queue[-1] = [qty, incoming_rate]
self.stock_queue[-1] = [qty, incoming_rate]
else:
qty_to_pop = abs(actual_qty)
while qty_to_pop:
@ -320,7 +325,11 @@ class update_entries_after(object):
stock_value = sum((flt(batch[0]) * flt(batch[1]) for batch in self.stock_queue))
stock_qty = sum((flt(batch[0]) for batch in self.stock_queue))
self.valuation_rate = (stock_value / flt(stock_qty)) if stock_qty else 0
if stock_qty:
self.valuation_rate = stock_value / flt(stock_qty)
if not self.stock_queue:
self.stock_queue.append([0, sle.incoming_rate or sle.outgoing_rate or self.valuation_rate])
def get_sle_before_datetime(self):
"""get previous stock ledger entry before current time-bucket"""