Merge branch 'develop' of https://github.com/frappe/erpnext into show_address_in_online_pos
This commit is contained in:
commit
df8add272c
@ -1,4 +1,10 @@
|
|||||||
# ERPNext - ERP made simple
|
<div align="center">
|
||||||
|
<img src="https://github.com/frappe/design/blob/master/logos/erpnext-logo.svg" height="128">
|
||||||
|
<h2>ERPNext</h2>
|
||||||
|
<p align="center">
|
||||||
|
<p>ERP made simple</p>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/frappe/erpnext.png)](https://travis-ci.org/frappe/erpnext) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/frappe/erpnext?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[![Build Status](https://travis-ci.org/frappe/erpnext.png)](https://travis-ci.org/frappe/erpnext) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/frappe/erpnext?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
|
||||||
|
@ -80,7 +80,6 @@ class TestItem(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
make_test_objects("Item Price")
|
make_test_objects("Item Price")
|
||||||
print(frappe.get_all("Item Price"))
|
|
||||||
|
|
||||||
details = get_item_details({
|
details = get_item_details({
|
||||||
"item_code": "_Test Item",
|
"item_code": "_Test Item",
|
||||||
|
@ -274,14 +274,15 @@ class StockEntry(StockController):
|
|||||||
self.set_actual_qty()
|
self.set_actual_qty()
|
||||||
self.calculate_rate_and_amount()
|
self.calculate_rate_and_amount()
|
||||||
|
|
||||||
def calculate_rate_and_amount(self, force=False, update_finished_item_rate=True):
|
def calculate_rate_and_amount(self, force=False,
|
||||||
|
update_finished_item_rate=True, raise_error_if_no_rate=True):
|
||||||
self.set_basic_rate(force, update_finished_item_rate)
|
self.set_basic_rate(force, update_finished_item_rate)
|
||||||
self.distribute_additional_costs()
|
self.distribute_additional_costs()
|
||||||
self.update_valuation_rate()
|
self.update_valuation_rate()
|
||||||
self.set_total_incoming_outgoing_value()
|
self.set_total_incoming_outgoing_value()
|
||||||
self.set_total_amount()
|
self.set_total_amount()
|
||||||
|
|
||||||
def set_basic_rate(self, force=False, update_finished_item_rate=True):
|
def set_basic_rate(self, force=False, update_finished_item_rate=True, raise_error_if_no_rate=True):
|
||||||
"""get stock and incoming rate on posting date"""
|
"""get stock and incoming rate on posting date"""
|
||||||
raw_material_cost = 0.0
|
raw_material_cost = 0.0
|
||||||
scrap_material_cost = 0.0
|
scrap_material_cost = 0.0
|
||||||
@ -294,7 +295,7 @@ class StockEntry(StockController):
|
|||||||
# get basic rate
|
# get basic rate
|
||||||
if not d.bom_no:
|
if not d.bom_no:
|
||||||
if (not flt(d.basic_rate) and not d.allow_zero_valuation_rate) or d.s_warehouse or force:
|
if (not flt(d.basic_rate) and not d.allow_zero_valuation_rate) or d.s_warehouse or force:
|
||||||
basic_rate = flt(get_incoming_rate(args), self.precision("basic_rate", d))
|
basic_rate = flt(get_incoming_rate(args, raise_error_if_no_rate), self.precision("basic_rate", d))
|
||||||
if basic_rate > 0:
|
if basic_rate > 0:
|
||||||
d.basic_rate = basic_rate
|
d.basic_rate = basic_rate
|
||||||
|
|
||||||
@ -306,7 +307,8 @@ class StockEntry(StockController):
|
|||||||
if d.bom_no:
|
if d.bom_no:
|
||||||
if not flt(d.basic_rate) and not d.allow_zero_valuation_rate and \
|
if not flt(d.basic_rate) and not d.allow_zero_valuation_rate and \
|
||||||
getattr(self, "pro_doc", frappe._dict()).scrap_warehouse == d.t_warehouse:
|
getattr(self, "pro_doc", frappe._dict()).scrap_warehouse == d.t_warehouse:
|
||||||
basic_rate = flt(get_incoming_rate(args), self.precision("basic_rate", d))
|
basic_rate = flt(get_incoming_rate(args, raise_error_if_no_rate),
|
||||||
|
self.precision("basic_rate", d))
|
||||||
if basic_rate > 0:
|
if basic_rate > 0:
|
||||||
d.basic_rate = basic_rate
|
d.basic_rate = basic_rate
|
||||||
d.basic_amount = flt(flt(d.transfer_qty) * flt(d.basic_rate), d.precision("basic_amount"))
|
d.basic_amount = flt(flt(d.transfer_qty) * flt(d.basic_rate), d.precision("basic_amount"))
|
||||||
@ -600,7 +602,8 @@ class StockEntry(StockController):
|
|||||||
if self.pro_doc and not self.pro_doc.skip_transfer:
|
if self.pro_doc and not self.pro_doc.skip_transfer:
|
||||||
item["from_warehouse"] = self.pro_doc.wip_warehouse
|
item["from_warehouse"] = self.pro_doc.wip_warehouse
|
||||||
#Get Reserve Warehouse from PO
|
#Get Reserve Warehouse from PO
|
||||||
item["from_warehouse"] = item_wh.get(item.item_code) if self.purchase_order and self.purpose=="Subcontract" else ""
|
if self.purchase_order and self.purpose=="Subcontract":
|
||||||
|
item["from_warehouse"] = item_wh.get(item.item_code)
|
||||||
item["to_warehouse"] = self.to_warehouse if self.purpose=="Subcontract" else ""
|
item["to_warehouse"] = self.to_warehouse if self.purpose=="Subcontract" else ""
|
||||||
|
|
||||||
self.add_to_stock_entry_detail(item_dict)
|
self.add_to_stock_entry_detail(item_dict)
|
||||||
@ -622,7 +625,7 @@ class StockEntry(StockController):
|
|||||||
self.load_items_from_bom()
|
self.load_items_from_bom()
|
||||||
|
|
||||||
self.set_actual_qty()
|
self.set_actual_qty()
|
||||||
self.calculate_rate_and_amount()
|
self.calculate_rate_and_amount(raise_error_if_no_rate=False)
|
||||||
|
|
||||||
def set_production_order_details(self):
|
def set_production_order_details(self):
|
||||||
if not getattr(self, "pro_doc", None):
|
if not getattr(self, "pro_doc", None):
|
||||||
|
@ -557,12 +557,13 @@ class TestStockEntry(unittest.TestCase):
|
|||||||
production_order.submit()
|
production_order.submit()
|
||||||
|
|
||||||
make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=50, basic_rate=100)
|
make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=50, basic_rate=100)
|
||||||
|
make_stock_entry(item_code="_Test Item 2", target="_Test Warehouse - _TC", qty=50, basic_rate=20)
|
||||||
|
|
||||||
stock_entry = _make_stock_entry(production_order.name, "Manufacture", 1)
|
stock_entry = _make_stock_entry(production_order.name, "Manufacture", 1)
|
||||||
|
|
||||||
rm_cost = 0
|
rm_cost = 0
|
||||||
for d in stock_entry.get("items"):
|
for d in stock_entry.get("items"):
|
||||||
if d.s_warehouse:
|
if d.item_code != "_Test FG Item 2":
|
||||||
rm_cost += flt(d.amount)
|
rm_cost += flt(d.amount)
|
||||||
|
|
||||||
fg_cost = filter(lambda x: x.item_code=="_Test FG Item 2", stock_entry.get("items"))[0].amount
|
fg_cost = filter(lambda x: x.item_code=="_Test FG Item 2", stock_entry.get("items"))[0].amount
|
||||||
|
@ -430,7 +430,7 @@ def get_stock_ledger_entries(previous_sle, operator=None, order="desc", limit=No
|
|||||||
}, previous_sle, as_dict=1, debug=debug)
|
}, previous_sle, as_dict=1, debug=debug)
|
||||||
|
|
||||||
def get_valuation_rate(item_code, warehouse, voucher_type, voucher_no,
|
def get_valuation_rate(item_code, warehouse, voucher_type, voucher_no,
|
||||||
allow_zero_rate=False, currency=None, company=None):
|
allow_zero_rate=False, currency=None, company=None, raise_error_if_no_rate=True):
|
||||||
# Get valuation rate from last sle for the same item and warehouse
|
# Get valuation rate from last sle for the same item and warehouse
|
||||||
if not company:
|
if not company:
|
||||||
company = erpnext.get_default_company()
|
company = erpnext.get_default_company()
|
||||||
@ -465,7 +465,7 @@ def get_valuation_rate(item_code, warehouse, voucher_type, voucher_no,
|
|||||||
dict(item_code=item_code, buying=1, currency=currency),
|
dict(item_code=item_code, buying=1, currency=currency),
|
||||||
'price_list_rate')
|
'price_list_rate')
|
||||||
|
|
||||||
if not allow_zero_rate and not valuation_rate \
|
if not allow_zero_rate and not valuation_rate and raise_error_if_no_rate \
|
||||||
and cint(erpnext.is_perpetual_inventory_enabled(company)):
|
and cint(erpnext.is_perpetual_inventory_enabled(company)):
|
||||||
frappe.local.message_log = []
|
frappe.local.message_log = []
|
||||||
frappe.throw(_("Valuation rate not found for the Item {0}, which is required to do accounting entries for {1} {2}. If the item is transacting as a zero valuation rate item in the {1}, please mention that in the {1} Item table. Otherwise, please create an incoming stock transaction for the item or mention valuation rate in the Item record, and then try submiting/cancelling this entry").format(item_code, voucher_type, voucher_no))
|
frappe.throw(_("Valuation rate not found for the Item {0}, which is required to do accounting entries for {1} {2}. If the item is transacting as a zero valuation rate item in the {1}, please mention that in the {1} Item table. Otherwise, please create an incoming stock transaction for the item or mention valuation rate in the Item record, and then try submiting/cancelling this entry").format(item_code, voucher_type, voucher_no))
|
||||||
|
@ -123,7 +123,7 @@ def update_bin(args, allow_negative_stock=False, via_landed_cost_voucher=False):
|
|||||||
frappe.msgprint(_("Item {0} ignored since it is not a stock item").format(args.get("item_code")))
|
frappe.msgprint(_("Item {0} ignored since it is not a stock item").format(args.get("item_code")))
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_incoming_rate(args):
|
def get_incoming_rate(args, raise_error_if_no_rate=True):
|
||||||
"""Get Incoming Rate based on valuation method"""
|
"""Get Incoming Rate based on valuation method"""
|
||||||
from erpnext.stock.stock_ledger import get_previous_sle, get_valuation_rate
|
from erpnext.stock.stock_ledger import get_previous_sle, get_valuation_rate
|
||||||
if isinstance(args, basestring):
|
if isinstance(args, basestring):
|
||||||
@ -146,7 +146,8 @@ def get_incoming_rate(args):
|
|||||||
voucher_no = args.get('voucher_no') or args.get('name')
|
voucher_no = args.get('voucher_no') or args.get('name')
|
||||||
in_rate = get_valuation_rate(args.get('item_code'), args.get('warehouse'),
|
in_rate = get_valuation_rate(args.get('item_code'), args.get('warehouse'),
|
||||||
args.get('voucher_type'), voucher_no, args.get('allow_zero_valuation'),
|
args.get('voucher_type'), voucher_no, args.get('allow_zero_valuation'),
|
||||||
currency=erpnext.get_company_currency(args.get('company')), company=args.get('company'))
|
currency=erpnext.get_company_currency(args.get('company')), company=args.get('company'),
|
||||||
|
raise_error_if_no_rate=True)
|
||||||
|
|
||||||
return in_rate
|
return in_rate
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user