mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
aii: gl entries for delivery note
This commit is contained in:
@@ -163,4 +163,37 @@ def get_warehouse_list(doctype, txt, searchfield, start, page_len, filters):
|
||||
elif webnotes.session.user in warehouse_users:
|
||||
wlist.append([w])
|
||||
return wlist
|
||||
|
||||
|
||||
def get_buying_amount(item_code, warehouse, qty, voucher_no, voucher_detail_no,
|
||||
stock_ledger_entries, item_sales_bom):
|
||||
if item_sales_bom.get(item_code):
|
||||
# sales bom item
|
||||
buying_amount = 0.0
|
||||
for bom_item in item_sales_bom[item_code]:
|
||||
buying_amount += _get_buying_amount(voucher_no, "[** No Item Row **]",
|
||||
item_code, warehouse, bom_item.qty * qty, stock_ledger_entries)
|
||||
return buying_amount
|
||||
else:
|
||||
# doesn't have sales bom
|
||||
return _get_buying_amount(voucher_no, voucher_detail_no, item_code, warehouse, qty,
|
||||
stock_ledger_entries)
|
||||
|
||||
def _get_buying_amount(voucher_no, item_row, item_code, warehouse, qty, stock_ledger_entries):
|
||||
for i, sle in enumerate(stock_ledger_entries):
|
||||
if sle.voucher_type == "Delivery Note" and sle.voucher_no == voucher_no:
|
||||
if (sle.voucher_detail_no == item_row) or \
|
||||
(sle.item_code == item_code and sle.warehouse == warehouse and \
|
||||
abs(flt(sle.qty)) == qty):
|
||||
buying_amount = flt(stock_ledger_entries[i+1].stock_value) - flt(sle.stock_value)
|
||||
|
||||
return buying_amount
|
||||
|
||||
return 0.0
|
||||
|
||||
def get_sales_bom():
|
||||
item_sales_bom = {}
|
||||
for r in webnotes.conn.sql("""select parent, item_code, qty from `tabSales BOM Item`""",
|
||||
as_dict=1):
|
||||
item_sales_bom.setdefault(r.parent, []).append(r)
|
||||
|
||||
return item_sales_bom
|
||||
Reference in New Issue
Block a user