mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 13:09:17 +00:00
[Reprots][No Sales Order From Customer] and [Item Reorder Level]
This commit is contained in:
@@ -149,11 +149,6 @@ wn.module_page["Selling"] = [
|
|||||||
right: true,
|
right: true,
|
||||||
icon: "icon-list",
|
icon: "icon-list",
|
||||||
items: [
|
items: [
|
||||||
{
|
|
||||||
"label":wn._("No Sales Order from Customers (Since 2 months)"),
|
|
||||||
route: "query-report/No Sales Order from Customers (Since 2 months)",
|
|
||||||
doctype: "Sales Order"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"label":wn._("Customer Addresses And Contacts"),
|
"label":wn._("Customer Addresses And Contacts"),
|
||||||
route: "query-report/Customer Addresses And Contacts"
|
route: "query-report/Customer Addresses And Contacts"
|
||||||
@@ -170,6 +165,11 @@ wn.module_page["Selling"] = [
|
|||||||
"label":wn._("Item-wise Sales History"),
|
"label":wn._("Item-wise Sales History"),
|
||||||
route: "query-report/Item-wise Sales History",
|
route: "query-report/Item-wise Sales History",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label":wn._("No Sales Order from Customers (Since 2 months)"),
|
||||||
|
route: "query-report/No Sales Order from Customers",
|
||||||
|
doctype: "Sales Order"
|
||||||
|
},
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
|
|
||||||
columns = get_columns()
|
columns = get_columns()
|
||||||
customers = get_so_details()
|
customers = get_so_details()
|
||||||
|
|
||||||
@@ -25,7 +24,6 @@ def execute(filters=None):
|
|||||||
if cust[8] >= 60: # days_since_last_order
|
if cust[8] >= 60: # days_since_last_order
|
||||||
cust.insert(7,get_last_so_amt(cust[0]))
|
cust.insert(7,get_last_so_amt(cust[0]))
|
||||||
data.append(cust)
|
data.append(cust)
|
||||||
|
|
||||||
return columns, data
|
return columns, data
|
||||||
|
|
||||||
def get_so_details():
|
def get_so_details():
|
||||||
@@ -40,19 +38,18 @@ def get_so_details():
|
|||||||
so.net_total * so.per_delivered/100,
|
so.net_total * so.per_delivered/100,
|
||||||
so.net_total)) as 'total_order_considered',
|
so.net_total)) as 'total_order_considered',
|
||||||
max(so.transaction_date) as 'last_sales_order_date',
|
max(so.transaction_date) as 'last_sales_order_date',
|
||||||
DATEDIFF(CURDATE(),max(so.transaction_date)) as 'days_since_last_order'
|
DATEDIFF(CURDATE(), max(so.transaction_date)) as 'days_since_last_order'
|
||||||
from `tabCustomer` cust, `tabSales Order` so
|
from `tabCustomer` cust, `tabSales Order` so
|
||||||
where cust.name = so.customer and so.docstatus = 1
|
where cust.name = so.customer and so.docstatus = 1
|
||||||
group by cust.name
|
group by cust.name
|
||||||
order by 'days_since_last_order' desc """,as_list=1)
|
order by 'days_since_last_order' desc """,as_list=1)
|
||||||
|
|
||||||
def get_last_so_amt(customer):
|
def get_last_so_amt(customer):
|
||||||
return webnotes.conn.sql("""select net_total from `tabSales Order`
|
res = webnotes.conn.sql("""select net_total from `tabSales Order`
|
||||||
where customer ='%(customer)s' and docstatus = 1 and
|
where customer ='%(customer)s' and docstatus = 1 order by transaction_date desc
|
||||||
transaction_date = (select max(transaction_date)
|
limit 1""" % {'customer':customer})
|
||||||
from `tabSales Order`
|
|
||||||
where customer = '%(customer)s')
|
return res and res[0][0] or 0
|
||||||
"""%{'customer':customer})
|
|
||||||
|
|
||||||
def get_columns():
|
def get_columns():
|
||||||
return [
|
return [
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"creation": "2013-06-05 11:40:49",
|
"creation": "2013-06-06 19:15:50",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-06-05 11:40:49",
|
"modified": "2013-06-06 19:15:51",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@@ -11,11 +11,11 @@
|
|||||||
"is_standard": "Yes",
|
"is_standard": "Yes",
|
||||||
"name": "__common__",
|
"name": "__common__",
|
||||||
"ref_doctype": "Sales Order",
|
"ref_doctype": "Sales Order",
|
||||||
"report_name": "No Sales Order from Customers (Since 2 months)",
|
"report_name": "No Sales Order from Customers",
|
||||||
"report_type": "Script Report"
|
"report_type": "Script Report"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "Report",
|
"doctype": "Report",
|
||||||
"name": "No Sales Order from Customers (Since 2 months)"
|
"name": "No Sales Order from Customers"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -128,11 +128,6 @@ wn.module_page["Stock"] = [
|
|||||||
right: true,
|
right: true,
|
||||||
icon: "icon-table",
|
icon: "icon-table",
|
||||||
items: [
|
items: [
|
||||||
{
|
|
||||||
"label":wn._("Item Reorder Level"),
|
|
||||||
route: "query-report/Item Reorder Level",
|
|
||||||
doctype: "Item"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"label":wn._("Stock Ledger"),
|
"label":wn._("Stock Ledger"),
|
||||||
page: "stock-ledger"
|
page: "stock-ledger"
|
||||||
@@ -210,6 +205,11 @@ wn.module_page["Stock"] = [
|
|||||||
"label":wn._("Requested Items To Be Transferred"),
|
"label":wn._("Requested Items To Be Transferred"),
|
||||||
route: "query-report/Requested Items To Be Transferred",
|
route: "query-report/Requested Items To Be Transferred",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label":wn._("Item Reorder Level"),
|
||||||
|
route: "query-report/Item Reorder Level",
|
||||||
|
doctype: "Item"
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -15,27 +15,30 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import webnotes
|
import webnotes
|
||||||
from webnotes.utils import getdate, flt, cint
|
from webnotes.utils import getdate, flt
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
if not filters: filters = {}
|
if not filters: filters = {}
|
||||||
|
float_preceision = webnotes.conn.get_default("float_preceision")
|
||||||
|
|
||||||
|
condition =get_condition(filters)
|
||||||
|
|
||||||
|
avg_daily_outgoing = 0
|
||||||
|
diff = ((getdate(filters.get("to_date")) - getdate(filters.get("from_date"))).days)+1
|
||||||
|
if diff <= 0:
|
||||||
|
webnotes.msgprint("To Date should not be less than eual to From Date",raise_exception=1)
|
||||||
|
|
||||||
columns = get_columns()
|
columns = get_columns()
|
||||||
items = get_item_info()
|
items = get_item_info()
|
||||||
consumed_item_map = get_consumed_items(filters)
|
consumed_item_map = get_consumed_items(condition)
|
||||||
delivered_item_map = get_delivered_items(filters)
|
delivered_item_map = get_delivered_items(condition)
|
||||||
|
|
||||||
avg_daily_outgoing = 0
|
|
||||||
diff = (getdate(filters.get("to_date")) - getdate(filters.get("from_date"))).days
|
|
||||||
if diff <= 0:
|
|
||||||
webnotes.msgprint("To Date should not be less than eual to From Date",raise_exception=1)
|
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
for item in items:
|
for item in items:
|
||||||
|
|
||||||
total_outgoing = consumed_item_map.get(item.name, 0)+delivered_item_map.get(item.name,0)
|
total_outgoing = consumed_item_map.get(item.name, 0)+delivered_item_map.get(item.name,0)
|
||||||
avg_daily_outgoing = cint(total_outgoing/diff)
|
avg_daily_outgoing = flt(total_outgoing/diff, float_preceision)
|
||||||
reorder_level = (avg_daily_outgoing * item.lead_time_days) + item.min_order_qty
|
reorder_level = (avg_daily_outgoing * flt(item.lead_time_days)) + flt(item.min_order_qty)
|
||||||
|
|
||||||
data.append([item.name, item.item_name, item.description, item.min_order_qty, item.lead_time_days,
|
data.append([item.name, item.item_name, item.description, item.min_order_qty, item.lead_time_days,
|
||||||
consumed_item_map.get(item.name, 0), delivered_item_map.get(item.name,0), total_outgoing,
|
consumed_item_map.get(item.name, 0), delivered_item_map.get(item.name,0), total_outgoing,
|
||||||
@@ -44,20 +47,24 @@ def execute(filters=None):
|
|||||||
return columns , data
|
return columns , data
|
||||||
|
|
||||||
def get_columns():
|
def get_columns():
|
||||||
return["Item:Link/Item:120", "Item name:Data:120", "description::160", "minimum inventory level::120",
|
return[
|
||||||
"lead time days::120", "consumed::120", "delivered::120", "total outgoing::120",
|
"Item:Link/Item:120", "Item name:Data:120", "Description::160",
|
||||||
"avg daily outgoing::120", "reorder level::120"]
|
"Minimum Inventory Level:Float:160", "Lead Time Days:Float:120", "Consumed:Float:120",
|
||||||
|
"Delivered:Float:120", "Total Outgoing:Float:120", "Avg Daily Outgoing:Float:160",
|
||||||
|
"Reorder Level:Float:120"
|
||||||
|
]
|
||||||
|
|
||||||
def get_item_info():
|
def get_item_info():
|
||||||
return webnotes.conn.sql("""select name, item_name, description, min_order_qty, lead_time_days
|
return webnotes.conn.sql("""select name, item_name, description, min_order_qty,
|
||||||
from tabItem""",as_dict=1)
|
lead_time_days from tabItem""", as_dict=1)
|
||||||
|
|
||||||
def get_consumed_items(filters):
|
def get_consumed_items(condition):
|
||||||
condition = get_condition(filters)
|
|
||||||
|
|
||||||
cn_items = webnotes.conn.sql("""select se_item.item_code, sum(se_item.actual_qty) as 'consume_qty'
|
cn_items = webnotes.conn.sql("""select se_item.item_code,
|
||||||
|
sum(se_item.actual_qty) as 'consume_qty'
|
||||||
from `tabStock Entry` se, `tabStock Entry Detail` se_item
|
from `tabStock Entry` se, `tabStock Entry Detail` se_item
|
||||||
where se.name = se_item.parent and se.docstatus = 1 and ifnull(se_item.t_warehouse, '') = '' %s
|
where se.name = se_item.parent and se.docstatus = 1
|
||||||
|
and ifnull(se_item.t_warehouse, '') = '' %s
|
||||||
group by se_item.item_code""" % (condition), as_dict=1)
|
group by se_item.item_code""" % (condition), as_dict=1)
|
||||||
|
|
||||||
cn_items_map = {}
|
cn_items_map = {}
|
||||||
@@ -66,18 +73,18 @@ def get_consumed_items(filters):
|
|||||||
|
|
||||||
return cn_items_map
|
return cn_items_map
|
||||||
|
|
||||||
def get_delivered_items(filters):
|
def get_delivered_items(condition):
|
||||||
condition = get_condition(filters)
|
|
||||||
|
|
||||||
dn_items = webnotes.conn.sql("""select dn_item.item_code, sum(dn_item.qty) as dn_qty
|
dn_items = webnotes.conn.sql("""select dn_item.item_code, sum(dn_item.qty) as dn_qty
|
||||||
from `tabDelivery Note` dn, `tabDelivery Note Item` dn_item
|
from `tabDelivery Note` dn, `tabDelivery Note Item` dn_item
|
||||||
where dn.name = dn_item.parent and dn.docstatus = 1 %s group by dn_item.item_code""" % (condition)
|
where dn.name = dn_item.parent and dn.docstatus = 1 %s
|
||||||
, as_dict=1)
|
group by dn_item.item_code""" % (condition), as_dict=1)
|
||||||
|
|
||||||
si_items = webnotes.conn.sql("""select si_item.item_name, sum(si_item.qty) as si_qty
|
si_items = webnotes.conn.sql("""select si_item.item_name, sum(si_item.qty) as si_qty
|
||||||
from `tabSales Invoice` si, `tabSales Invoice Item` si_item
|
from `tabSales Invoice` si, `tabSales Invoice Item` si_item
|
||||||
where si.name = si_item.parent and si.docstatus = 1 and ifnull(si.update_stock, 0) = 1
|
where si.name = si_item.parent and si.docstatus = 1 and
|
||||||
and ifnull(si.is_pos, 0) = 1 %s group by si_item.item_name""" % (condition), as_dict=1)
|
ifnull(si.update_stock, 0) = 1 and ifnull(si.is_pos, 0) = 1 %s
|
||||||
|
group by si_item.item_name""" % (condition), as_dict=1)
|
||||||
|
|
||||||
dn_item_map = {}
|
dn_item_map = {}
|
||||||
for item in dn_items:
|
for item in dn_items:
|
||||||
|
|||||||
Reference in New Issue
Block a user