item-wise price list rate, editable report
This commit is contained in:
parent
04a3feecf6
commit
625da79e9f
@ -19,10 +19,9 @@ class DocType:
|
|||||||
webnotes.conn.get_value("Account", self.doc.account, "debit_or_credit").lower() or ""
|
webnotes.conn.get_value("Account", self.doc.account, "debit_or_credit").lower() or ""
|
||||||
|
|
||||||
def get_voucher_details(self):
|
def get_voucher_details(self):
|
||||||
|
|
||||||
total_amount = webnotes.conn.sql("""select sum(%s) from `tabGL Entry`
|
total_amount = webnotes.conn.sql("""select sum(%s) from `tabGL Entry`
|
||||||
where voucher_type = %s and voucher_no = %s
|
where voucher_type = %s and voucher_no = %s
|
||||||
and account = %s and ifnull(is_cancelled, 'No') = 'No'""" %
|
and account = %s""" %
|
||||||
(self.doc.account_type, '%s', '%s', '%s'),
|
(self.doc.account_type, '%s', '%s', '%s'),
|
||||||
(self.doc.voucher_type, self.doc.voucher_no, self.doc.account))
|
(self.doc.voucher_type, self.doc.voucher_no, self.doc.account))
|
||||||
|
|
||||||
|
@ -52,8 +52,7 @@ def get_stock_ledger_entries(filters):
|
|||||||
query = """select item_code, voucher_type, voucher_no,
|
query = """select item_code, voucher_type, voucher_no,
|
||||||
voucher_detail_no, posting_date, posting_time, stock_value,
|
voucher_detail_no, posting_date, posting_time, stock_value,
|
||||||
warehouse, actual_qty as qty
|
warehouse, actual_qty as qty
|
||||||
from `tabStock Ledger Entry`
|
from `tabStock Ledger Entry`"""
|
||||||
where ifnull(`is_cancelled`, 'No') = No'"""
|
|
||||||
|
|
||||||
if filters.get("company"):
|
if filters.get("company"):
|
||||||
query += """ and company=%(company)s"""
|
query += """ and company=%(company)s"""
|
||||||
|
@ -268,17 +268,15 @@ def get_stock_and_account_difference(account_list=None, posting_date=None):
|
|||||||
|
|
||||||
if not posting_date: posting_date = nowdate()
|
if not posting_date: posting_date = nowdate()
|
||||||
|
|
||||||
account_warehouse_map = {}
|
|
||||||
difference = {}
|
difference = {}
|
||||||
warehouse_account = webnotes.conn.sql("""select name, account from tabWarehouse
|
|
||||||
where account in (%s)""" % ', '.join(['%s']*len(account_list)), account_list, as_dict=1)
|
account_warehouse = dict(webnotes.conn.sql("""select name, master_name from tabAccount
|
||||||
|
where account_type = 'Warehouse' and ifnull(master_name, '') != ''
|
||||||
for wh in warehouse_account:
|
and name in (%s)""" % ', '.join(['%s']*len(account_list)), account_list))
|
||||||
account_warehouse_map.setdefault(wh.account, []).append(wh.name)
|
|
||||||
|
|
||||||
for account, warehouse_list in account_warehouse_map.items():
|
for account, warehouse in account_warehouse.items():
|
||||||
account_balance = get_balance_on(account, posting_date)
|
account_balance = get_balance_on(account, posting_date)
|
||||||
stock_value = get_stock_balance_on(warehouse_list, posting_date)
|
stock_value = get_stock_balance_on(warehouse, posting_date)
|
||||||
if abs(flt(stock_value) - flt(account_balance)) > 0.005:
|
if abs(flt(stock_value) - flt(account_balance)) > 0.005:
|
||||||
difference.setdefault(account, flt(stock_value) - flt(account_balance))
|
difference.setdefault(account, flt(stock_value) - flt(account_balance))
|
||||||
|
|
||||||
|
0
setup/report/item_wise_price_list/__init__.py
Normal file
0
setup/report/item_wise_price_list/__init__.py
Normal file
22
setup/report/item_wise_price_list/item_wise_price_list.txt
Normal file
22
setup/report/item_wise_price_list/item_wise_price_list.txt
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"creation": "2013-09-25 10:29:04",
|
||||||
|
"docstatus": 0,
|
||||||
|
"modified": "2013-09-25 10:29:04",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"owner": "Administrator"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Report",
|
||||||
|
"is_standard": "Yes",
|
||||||
|
"json": "{\"filters\":[[\"Item Price\",\"item_code\",\"like\",\"%\"],[\"Price List\",\"price_list_name\",\"like\",\"%\"]],\"columns\":[[\"item_code\",\"Item Price\"],[\"price_list_name\",\"Price List\"],[\"currency\",\"Price List\"],[\"ref_rate\",\"Item Price\"],[\"buying_or_selling\",\"Price List\"],[\"name\",\"Price List\"]],\"sort_by\":\"Price List.modified\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}",
|
||||||
|
"name": "__common__",
|
||||||
|
"ref_doctype": "Price List",
|
||||||
|
"report_name": "Item-Wise Price List",
|
||||||
|
"report_type": "Report Builder"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Report",
|
||||||
|
"name": "Item-Wise Price List"
|
||||||
|
}
|
||||||
|
]
|
0
setup/report/item_wise_price_list_rate/__init__.py
Normal file
0
setup/report/item_wise_price_list_rate/__init__.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"creation": "2013-09-25 10:21:15",
|
||||||
|
"docstatus": 0,
|
||||||
|
"modified": "2013-09-25 10:24:57",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"owner": "Administrator"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Report",
|
||||||
|
"is_standard": "Yes",
|
||||||
|
"json": "{\"filters\":[[\"Item Price\",\"item_code\",\"like\",\"%\"],[\"Price List\",\"price_list_name\",\"like\",\"%\"]],\"columns\":[[\"item_code\",\"Item Price\"],[\"price_list_name\",\"Price List\"],[\"currency\",\"Price List\"],[\"ref_rate\",\"Item Price\"],[\"buying_or_selling\",\"Price List\"],[\"name\",\"Price List\"]],\"sort_by\":\"Price List.modified\",\"sort_order\":\"desc\",\"sort_by_next\":\"\",\"sort_order_next\":\"desc\"}",
|
||||||
|
"name": "__common__",
|
||||||
|
"ref_doctype": "Price List",
|
||||||
|
"report_name": "Item-wise Price List Rate",
|
||||||
|
"report_type": "Report Builder"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Report",
|
||||||
|
"name": "Item-wise Price List Rate"
|
||||||
|
}
|
||||||
|
]
|
@ -67,7 +67,7 @@ class DocType(DocListController):
|
|||||||
if not self.doc.fields.get("__islocal"):
|
if not self.doc.fields.get("__islocal"):
|
||||||
matched=True
|
matched=True
|
||||||
ref_uom = webnotes.conn.get_value("Stock Ledger Entry",
|
ref_uom = webnotes.conn.get_value("Stock Ledger Entry",
|
||||||
{"item_code": self.doc.name, "is_cancelled": "No"}, "stock_uom")
|
{"item_code": self.doc.name}, "stock_uom")
|
||||||
if ref_uom:
|
if ref_uom:
|
||||||
if cstr(ref_uom) != cstr(self.doc.stock_uom):
|
if cstr(ref_uom) != cstr(self.doc.stock_uom):
|
||||||
matched = False
|
matched = False
|
||||||
|
@ -7,8 +7,6 @@ import unittest
|
|||||||
import webnotes
|
import webnotes
|
||||||
import webnotes.defaults
|
import webnotes.defaults
|
||||||
from webnotes.utils import cint
|
from webnotes.utils import cint
|
||||||
from accounts.utils import get_stock_and_account_difference
|
|
||||||
|
|
||||||
|
|
||||||
class TestPurchaseReceipt(unittest.TestCase):
|
class TestPurchaseReceipt(unittest.TestCase):
|
||||||
def test_make_purchase_invoice(self):
|
def test_make_purchase_invoice(self):
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes, unittest
|
import webnotes, unittest
|
||||||
from accounts.utils import get_stock_and_account_difference
|
|
||||||
|
|
||||||
test_dependencies = ["Item"]
|
test_dependencies = ["Item"]
|
||||||
test_records = []
|
test_records = []
|
||||||
|
@ -22,7 +22,6 @@ class DocType(StockController):
|
|||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
self.insert_stock_ledger_entries()
|
self.insert_stock_ledger_entries()
|
||||||
self.set_stock_value_difference()
|
|
||||||
self.make_gl_entries()
|
self.make_gl_entries()
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
@ -275,26 +274,6 @@ class DocType(StockController):
|
|||||||
"posting_time": self.doc.posting_time
|
"posting_time": self.doc.posting_time
|
||||||
})
|
})
|
||||||
|
|
||||||
def set_stock_value_difference(self):
|
|
||||||
"""stock_value_difference is the increment in the stock value"""
|
|
||||||
from stock.utils import get_buying_amount
|
|
||||||
|
|
||||||
item_list = [d.item_code for d in self.entries]
|
|
||||||
warehouse_list = [d.warehouse for d in self.entries]
|
|
||||||
if not (item_list and warehouse_list):
|
|
||||||
webnotes.throw(_("Invalid Item or Warehouse Data"))
|
|
||||||
|
|
||||||
stock_ledger_entries = self.get_stock_ledger_entries(item_list, warehouse_list)
|
|
||||||
|
|
||||||
stock_value_difference = {}
|
|
||||||
for d in self.entries:
|
|
||||||
diff = get_buying_amount(self.doc.doctype, self.doc.name, d.voucher_detail_no,
|
|
||||||
stock_ledger_entries.get((d.item_code, d.warehouse), []))
|
|
||||||
stock_value_difference.setdefault(d.warehouse, 0.0)
|
|
||||||
stock_value_difference[d.warehouse] -= diff
|
|
||||||
|
|
||||||
webnotes.conn.set(self.doc, "stock_value_difference", json.dumps(stock_value_difference))
|
|
||||||
|
|
||||||
def get_gl_entries_for_stock(self, warehouse_account=None):
|
def get_gl_entries_for_stock(self, warehouse_account=None):
|
||||||
if not self.doc.cost_center:
|
if not self.doc.cost_center:
|
||||||
msgprint(_("Please enter Cost Center"), raise_exception=1)
|
msgprint(_("Please enter Cost Center"), raise_exception=1)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-03-28 10:35:31",
|
"creation": "2013-03-28 10:35:31",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-08-29 16:46:33",
|
"modified": "2013-09-24 15:35:12",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@ -155,15 +155,6 @@
|
|||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"fieldname": "stock_value_difference",
|
|
||||||
"fieldtype": "Long Text",
|
|
||||||
"hidden": 1,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Stock Value Difference",
|
|
||||||
"print_hide": 1
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"doctype": "DocPerm"
|
"doctype": "DocPerm"
|
||||||
}
|
}
|
||||||
|
@ -201,9 +201,9 @@ wn.module_page["Stock"] = [
|
|||||||
doctype: "Serial No"
|
doctype: "Serial No"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Item-Wise Price List"),
|
"label":wn._("Item-wise Price List Rate"),
|
||||||
route: "query-report/Item-Wise Price List",
|
route: "Report/Price List/Item-Wise Price List",
|
||||||
doctype: "Item"
|
doctype: "Price List"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Purchase In Transit"),
|
"label":wn._("Purchase In Transit"),
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"creation": "2013-02-22 18:01:55",
|
|
||||||
"docstatus": 0,
|
|
||||||
"modified": "2013-09-10 15:50:26",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"owner": "Administrator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Report",
|
|
||||||
"is_standard": "Yes",
|
|
||||||
"name": "__common__",
|
|
||||||
"query": "select\n item.name as \"ID:Link/Item:120\", \n item.item_name as \"Item Name::120\", \n item_price.parent as \"Price List::80\",\n price_list.currency as \"Currency::40\", \n item_price.ref_rate as \"Rate:Float:80\",\n item.description as \"Description::160\",\n item.item_group as \"Item Group:Link/Item Group:100\",\n item.brand as \"Brand::100\"\nfrom `tabItem` item, `tabItem Price` item_price, `tabPrice List` price_list\nwhere\n item_price.item_code = item.name and\n item_price.parent = price_list.name",
|
|
||||||
"ref_doctype": "Item",
|
|
||||||
"report_name": "Item-Wise Price List",
|
|
||||||
"report_type": "Query Report"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "Report",
|
|
||||||
"name": "Item-Wise Price List"
|
|
||||||
}
|
|
||||||
]
|
|
@ -10,26 +10,24 @@ from webnotes.utils.email_lib import sendmail
|
|||||||
|
|
||||||
class UserNotAllowedForWarehouse(webnotes.ValidationError): pass
|
class UserNotAllowedForWarehouse(webnotes.ValidationError): pass
|
||||||
|
|
||||||
def get_stock_balance_on(warehouse_list, posting_date=None):
|
def get_stock_balance_on(warehouse, posting_date=None):
|
||||||
if not posting_date: posting_date = nowdate()
|
if not posting_date: posting_date = nowdate()
|
||||||
|
|
||||||
stock_ledger_entries = webnotes.conn.sql("""
|
stock_ledger_entries = webnotes.conn.sql("""
|
||||||
SELECT
|
SELECT
|
||||||
item_code, warehouse, stock_value
|
item_code, stock_value
|
||||||
FROM
|
FROM
|
||||||
`tabStock Ledger Entry`
|
`tabStock Ledger Entry`
|
||||||
WHERE
|
WHERE
|
||||||
warehouse in (%s)
|
warehouse=%s AND posting_date <= %s
|
||||||
AND posting_date <= %s
|
|
||||||
ORDER BY timestamp(posting_date, posting_time) DESC, name DESC
|
ORDER BY timestamp(posting_date, posting_time) DESC, name DESC
|
||||||
""" % (', '.join(['%s']*len(warehouse_list)), '%s'),
|
""", (warehouse, posting_date), as_dict=1)
|
||||||
tuple(warehouse_list + [posting_date]), as_dict=1)
|
|
||||||
|
|
||||||
sle_map = {}
|
sle_map = {}
|
||||||
for sle in stock_ledger_entries:
|
for sle in stock_ledger_entries:
|
||||||
sle_map.setdefault(sle.warehouse, {}).setdefault(sle.item_code, flt(sle.stock_value))
|
sle_map.setdefault(sle.item_code, flt(sle.stock_value))
|
||||||
|
|
||||||
return sum([sum(item_dict.values()) for item_dict in sle_map.values()])
|
return sum(sle_map.values())
|
||||||
|
|
||||||
def get_latest_stock_balance():
|
def get_latest_stock_balance():
|
||||||
bin_map = {}
|
bin_map = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user