mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-18 12:39:18 +00:00
[merge] [minor] merged with master
This commit is contained in:
@@ -8,6 +8,7 @@ from webnotes.utils import flt, cstr, nowdate, add_days, cint
|
||||
from webnotes.defaults import get_global_default
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
|
||||
class UserNotAllowedForWarehouse(webnotes.ValidationError): pass
|
||||
|
||||
def get_stock_balance_on(warehouse_list, posting_date=None):
|
||||
if not posting_date: posting_date = nowdate()
|
||||
@@ -208,20 +209,28 @@ def get_warehouse_list(doctype, txt, searchfield, start, page_len, filters):
|
||||
wlist.append([w])
|
||||
return wlist
|
||||
|
||||
def get_buying_amount(item_code, voucher_type, voucher_no, voucher_detail_no,
|
||||
stock_ledger_entries, item_sales_bom=None):
|
||||
if item_sales_bom and item_sales_bom.get(item_code):
|
||||
# sales bom item
|
||||
buying_amount = 0.0
|
||||
for bom_item in item_sales_bom[item_code]:
|
||||
if bom_item.get("parent_detail_docname")==voucher_detail_no:
|
||||
buying_amount += _get_buying_amount(voucher_type, voucher_no, voucher_detail_no, stock_ledger_entries)
|
||||
return buying_amount
|
||||
else:
|
||||
# doesn't have sales bom
|
||||
return _get_buying_amount(voucher_type, voucher_no, voucher_detail_no, stock_ledger_entries)
|
||||
def validate_warehouse_user(warehouse):
|
||||
if webnotes.session.user=="Administrator":
|
||||
return
|
||||
warehouse_users = [p[0] for p in webnotes.conn.sql("""select user from `tabWarehouse User`
|
||||
where parent=%s""", warehouse)]
|
||||
|
||||
if warehouse_users and not (webnotes.session.user in warehouse_users):
|
||||
webnotes.throw(_("Not allowed entry in Warehouse") \
|
||||
+ ": " + warehouse, UserNotAllowedForWarehouse)
|
||||
|
||||
def get_sales_bom_buying_amount(item_code, warehouse, voucher_type, voucher_no, voucher_detail_no,
|
||||
stock_ledger_entries, item_sales_bom):
|
||||
# sales bom item
|
||||
buying_amount = 0.0
|
||||
for bom_item in item_sales_bom[item_code]:
|
||||
if bom_item.get("parent_detail_docname")==voucher_detail_no:
|
||||
buying_amount += get_buying_amount(voucher_type, voucher_no, voucher_detail_no,
|
||||
stock_ledger_entries.get((bom_item.item_code, warehouse), []))
|
||||
|
||||
return buying_amount
|
||||
|
||||
def _get_buying_amount(voucher_type, voucher_no, item_row, stock_ledger_entries):
|
||||
def get_buying_amount(voucher_type, voucher_no, item_row, stock_ledger_entries):
|
||||
# IMP NOTE
|
||||
# stock_ledger_entries should already be filtered by item_code and warehouse and
|
||||
# sorted by posting_date desc, posting_time desc
|
||||
|
||||
Reference in New Issue
Block a user