mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 05:39:12 +00:00
restructured erpnext and deleted unwanted
This commit is contained in:
0
stock/search_criteria/__init__.py
Normal file
0
stock/search_criteria/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
report.customize_filters = function() {
|
||||
this.filter_fields_dict['Item'+FILTER_SEP +'ID'].df.in_first_page = 1;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
'add_col': None,
|
||||
'add_cond': None,
|
||||
'add_tab': None,
|
||||
'columns': 'Item\x01Item Name,Item\x01Item Group,Ref Rate Detail\x01Price List Name,Ref Rate Detail\x01Ref Rate,Ref Rate Detail\x01Currency',
|
||||
'creation': '2010-08-20 12:20:55',
|
||||
'criteria_name': 'Itemwise Price List',
|
||||
'custom_query': '',
|
||||
'description': None,
|
||||
'dis_filters': None,
|
||||
'disabled': None,
|
||||
'doc_type': 'Ref Rate Detail',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Item\x01Saved':1,'Ref Rate Detail\x01Price List Name':'','Ref Rate Detail\x01Currency':''}",
|
||||
'graph_series': None,
|
||||
'graph_values': None,
|
||||
'group_by': None,
|
||||
'idx': None,
|
||||
'modified': '2010-08-20 12:15:17',
|
||||
'modified_by': 'Administrator',
|
||||
'module': 'Material Management',
|
||||
'name': 'itemwise_price_list',
|
||||
'owner': 'harshada@webnotestech.com',
|
||||
'page_len': 50,
|
||||
'parent': None,
|
||||
'parent_doc_type': 'Item',
|
||||
'parentfield': None,
|
||||
'parenttype': None,
|
||||
'report_script': None,
|
||||
'server_script': None,
|
||||
'sort_by': '`tabItem`.`item_name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,11 @@
|
||||
report.customize_filters = function() {
|
||||
|
||||
this.add_filter({fieldname:'posting_date', label:'Posting Date', fieldtype:'Date', ignore : 1, parent:'Item'});
|
||||
//this.add_filter({fieldname:'weekly_working_days', label:'Weekly Working Days', fieldtype:'Select', options:NEWLINE+1+NEWLINE+2+NEWLINE+3+NEWLINE+4+NEWLINE+5+NEWLINE+6+NEWLINE+7, ignore : 1, parent:'Item'});
|
||||
|
||||
this.filter_fields_dict['Item'+FILTER_SEP +'From Posting Date'].df.in_first_page = 1;
|
||||
this.filter_fields_dict['Item'+FILTER_SEP +'To Posting Date'].df.in_first_page = 1;
|
||||
//this.filter_fields_dict['Item'+FILTER_SEP +'Weekly Working Days'].df.in_first_page = 1;
|
||||
|
||||
|
||||
}
|
||||
132
stock/search_criteria/shortage_to_indent/shortage_to_indent.py
Normal file
132
stock/search_criteria/shortage_to_indent/shortage_to_indent.py
Normal file
@@ -0,0 +1,132 @@
|
||||
mon_list = []
|
||||
data = {'start_date':0, 'end_date':1, 'working_days': 2}
|
||||
|
||||
def make_month_list(start_date, end_date, mon_list, colnames, coltypes, colwidths, coloptions, col_idx):
|
||||
|
||||
# get period between from date and to date
|
||||
|
||||
period_diff = sql("select PERIOD_DIFF('%s','%s')"% (('').join( end_date.split('-')[i] for i in range(len(end_date.split('-')) - 1)),('').join(start_date.split('-')[i] for i in range(len(start_date.split('-')) - 1))))
|
||||
period_diff = period_diff and int(period_diff[0][0])
|
||||
|
||||
for pd in range(int(period_diff) + 1):
|
||||
# get last date
|
||||
last_date = str(sql("select LAST_DAY('%s')" % start_date)[0][0])
|
||||
|
||||
# get no of days in the month
|
||||
if not int(sql("select DATEDIFF('%s','%s')" % (end_date, last_date))[0][0]) >0:
|
||||
last_date = end_date
|
||||
diff = int(sql("select DATEDIFF('%s','%s')" % (last_date, start_date))[0][0]) + 1
|
||||
|
||||
# make mon_list
|
||||
mon_list.append([start_date, last_date, (diff > 26) and 26 or diff])
|
||||
|
||||
# add months as Column names
|
||||
month_name = sql("select MONTHNAME('%s')" % start_date)[0][0]
|
||||
|
||||
colnames.append(str(str(month_name)[:3])+ '-'+ str(start_date[:4]))
|
||||
coltypes.append('Currency')
|
||||
colwidths.append('150px')
|
||||
coloptions.append('')
|
||||
col_idx[str(str(month_name)[:3])+ '-'+ str(start_date[:4])] = len(colnames) - 1
|
||||
|
||||
# get start date
|
||||
start_date = str(sql("select DATE_ADD('%s',INTERVAL 1 DAY)" % last_date)[0][0])
|
||||
|
||||
# Validation for 'ID' and 'Lead Time Days' Column Name
|
||||
if 'ID' not in colnames or 'Lead Time Days' not in colnames:
|
||||
msgprint("Please select Id and Lead Time Days in 'Select Columns' tab Else Report will not be generated")
|
||||
raise Exception
|
||||
|
||||
# Validation for Posting Date Filters
|
||||
if not filter_values.get('posting_date') or not filter_values.get('posting_date1'):
|
||||
msgprint("Please select From Posting Date and To Posting Date")
|
||||
raise Exception
|
||||
else:
|
||||
from_date = str(filter_values.get('posting_date'))
|
||||
to_date = str(filter_values.get('posting_date1'))
|
||||
|
||||
|
||||
# Call Make Month List Function
|
||||
make_month_list(from_date, to_date, mon_list, colnames, coltypes, colwidths, coloptions, col_idx)
|
||||
|
||||
|
||||
# Add Column names
|
||||
col = [['Total Daily Consumption','Currency','150px','']
|
||||
,['MIL(Min Inv. Level)','Currency','150px','']
|
||||
,['ROL(Re-Order Level)','Currency','150px','']
|
||||
,['Actual Quantity','Currency','150px','']
|
||||
,['Indented Quantity','Currency','150px','']
|
||||
,['Ordered Quantity','Currency','150px','']
|
||||
,['Shortage To Indent','Currency','150px','']
|
||||
,['MAR','Currency','100px','']
|
||||
,['LPR','Currency','100px','']]
|
||||
|
||||
for c in col:
|
||||
colnames.append(c[0])
|
||||
coltypes.append(c[1])
|
||||
colwidths.append(c[2])
|
||||
coloptions.append(c[3])
|
||||
col_idx[c[0]] = len(colnames) - 1
|
||||
|
||||
for r in res:
|
||||
|
||||
# calculate Total Daily Consumption Monthly
|
||||
count, tot_consumption, tot_days = 0, 0, 1
|
||||
#for idx in range(col_idx['Stock Unit of Measurement'] + 1 , col_idx['Total Daily Consumption'] ):
|
||||
for idx in range(col_idx['Lead Time Days'] + 1 , col_idx['Total Daily Consumption'] ):
|
||||
|
||||
# As Consumption Means:= Adding Qty Transfered to WIP Warehouse ++ Qty Issued directly warehouse whose waraehouse_type != WIP Warehouse and Subtracting Qty Issued from WIP Warehouse
|
||||
#Capture item qty coming to WIP Warehouse for production purpose which means consuming that items
|
||||
add_con = sql("select ifnull(sum(t1.actual_qty),0) from `tabStock Ledger Entry` t1 where t1.item_code = '%s' and t1.is_cancelled = 'No' and t1.posting_date >= '%s' and t1.posting_date <= '%s' and t1.warehouse_type = 'WIP Warehouse' and t1.actual_qty > 0 " % (r[col_idx['ID']],mon_list[count][data['start_date']],mon_list[count][data['end_date']]))
|
||||
|
||||
# This is Stock Entry which is of Type Material Issue also to mention that Source Warehouse should not be WIP WArehouse
|
||||
#Transfering items to Internal Other Warehouse but not to WIP Warehouse
|
||||
dir_con = sql("select ifnull(sum(t1.actual_qty),0) from `tabStock Ledger Entry` t1, `tabStock Entry Detail` t2 where t1.item_code = '%s' and t1.is_cancelled = 'No' and t1.posting_date >= '%s' and t1.posting_date <= '%s' and t1.warehouse_type != 'WIP Warehouse' and t1.actual_qty < 0 and t1.voucher_type = 'Stock Entry' and t1.voucher_detail_no = t2.name and ifnull(t2.t_warehouse, '') = ''"%(r[col_idx['ID']],mon_list[count][data['start_date']],mon_list[count][data['end_date']]))
|
||||
|
||||
# This is Stock Entry which is of Type MAterial TRansfer also to mention that Source Warehouse should be WIP WArhouse
|
||||
#like, transfering items from internal warehouse to customer
|
||||
red_con = sql("select ifnull(sum(t1.actual_qty),0) from `tabStock Ledger Entry` t1, `tabStock Entry Detail` t2 where t1.item_code = '%s' and t1.is_cancelled = 'No' and t1.posting_date >= '%s' and t1.posting_date <= '%s' and t1.warehouse_type = 'WIP Warehouse' and t1.actual_qty < 0 and t1.voucher_type = 'Stock Entry' and t1.voucher_detail_no = t2.name and ifnull(t2.t_warehouse, '') != ''"%(r[col_idx['ID']],mon_list[count][data['start_date']],mon_list[count][data['end_date']]))
|
||||
#msgprint(str(add_con[0][0]) + "~~~" + str(dir_con[0][0]) + "~~~" + str(red_con[0][0]))
|
||||
|
||||
add_con = add_con and add_con[0][0] or 0.00
|
||||
dir_con = dir_con and ((-1) * dir_con[0][0]) or 0.00
|
||||
red_con = red_con and red_con[0][0] or 0.00
|
||||
tot_con = flt(add_con) + flt(dir_con) + flt(red_con)
|
||||
#tot_con = add_con and add_con[0][0] or 0 + dir_con and (-1) * dir_con[0][0] or 0 + red_con and red_con[0][0] or 0
|
||||
tot_con = flt(r[col_idx['Lead Time Days']] and tot_con or 0)
|
||||
|
||||
|
||||
# monthly avg consumption
|
||||
r.append(flt(tot_con / mon_list[count][data['working_days']]))
|
||||
|
||||
# calculate tot_consumption and tot_days
|
||||
tot_consumption = flt(tot_consumption) + flt(tot_con)
|
||||
tot_days = (tot_days == 1) and flt(mon_list[count][data['working_days']]) or (flt(tot_days) + flt(mon_list[count][data['working_days']]))
|
||||
count = count + 1
|
||||
|
||||
# Calculate Daily Consumption
|
||||
r.append(tot_consumption and flt(tot_consumption /tot_days) or 0)
|
||||
|
||||
# Calculate Minimum Inventory Level
|
||||
r.append(flt(r[col_idx['Total Daily Consumption']]) * flt(r[col_idx['Lead Time Days']]))
|
||||
|
||||
# Calculate Re-Order Level
|
||||
r.append(flt(r[col_idx['MIL(Min Inv. Level)']] * 2))
|
||||
|
||||
# get stock level
|
||||
stock_level = sql("select sum(t1.actual_qty), sum(t1.indented_qty), sum(t1.ordered_qty) from `tabBin` t1, `tabWarehouse` t2 where t1.warehouse = t2.name and t2.warehouse_type != 'WIP Warehouse' and t1.item_code = '%s'"%(r[col_idx['ID']]))
|
||||
|
||||
r.append(stock_level and flt(stock_level[0][0]) or 0) # Actual Qty
|
||||
r.append(stock_level and flt(stock_level[0][1]) or 0) # Indented Qty
|
||||
r.append(stock_level and flt(stock_level[0][2]) or 0) # Ordered Qty
|
||||
|
||||
# calculate shortage
|
||||
r.append((r[col_idx['ROL(Re-Order Level)']] > 0) and flt(flt(r[col_idx['ROL(Re-Order Level)']]) - flt(r[col_idx['Actual Quantity']]) - flt(r[col_idx['Indented Quantity']]) - flt(r[col_idx['Ordered Quantity']])) or 0)
|
||||
|
||||
# get moving average rate
|
||||
m_a_r = sql("select ifnull(sum(t1.ma_rate), 0)/ ifnull(count(t1.name),1) from `tabBin` t1, `tabWarehouse` t2 where t1.item_code = '%s' and ifnull(t1.ma_rate, 0) > 0 and t1.warehouse = t2.name and t2.warehouse_type != 'WIP Warehouse'" % r[col_idx['ID']])
|
||||
r.append(m_a_r and flt(m_a_r[0][0]) or 0)
|
||||
|
||||
# get recent last purchase rate
|
||||
lpr_rate = flt(sql("select last_purchase_rate from `tabItem` where name = '%s'" %r[col_idx['ID']])[0][0]) or 0.00
|
||||
r.append(lpr_rate)
|
||||
@@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
'add_col': None,
|
||||
'add_cond': None,
|
||||
'add_tab': None,
|
||||
'columns': 'Item\x01ID,Item\x01Item Name,Item\x01Description,Item\x01Lead Time Days',
|
||||
'creation': '2011-05-25 12:44:22',
|
||||
'criteria_name': 'Shortage To Indent',
|
||||
'custom_query': '',
|
||||
'description': None,
|
||||
'dis_filters': None,
|
||||
'disabled': None,
|
||||
'doc_type': 'Item',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Item\x01Saved':1}",
|
||||
'graph_series': None,
|
||||
'graph_values': None,
|
||||
'group_by': None,
|
||||
'idx': None,
|
||||
'modified': '2011-05-18 11:52:59',
|
||||
'modified_by': 'Guest',
|
||||
'module': 'Material Management',
|
||||
'name': 'shortage_to_indent',
|
||||
'owner': 'wasim@webnotestech.com',
|
||||
'page_len': 50,
|
||||
'parent': None,
|
||||
'parent_doc_type': None,
|
||||
'parentfield': None,
|
||||
'parenttype': None,
|
||||
'report_script': None,
|
||||
'server_script': None,
|
||||
'sort_by': '`tabItem`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,12 @@
|
||||
report.customize_filters = function() {
|
||||
//this.hide_all_filters();
|
||||
|
||||
this.filter_fields_dict['Serial No'+FILTER_SEP +'Status'].df.filter_hide = 1;
|
||||
|
||||
this.filter_fields_dict['Serial No'+FILTER_SEP +'ID'].df.in_first_page = 1;
|
||||
this.filter_fields_dict['Serial No'+FILTER_SEP +'From Purchase Date'].df.in_first_page = 1;
|
||||
this.filter_fields_dict['Serial No'+FILTER_SEP +'To Purchase Date'].df.in_first_page = 1;
|
||||
}
|
||||
|
||||
//this.mytabs.items['Select Columns'].hide();
|
||||
this.mytabs.items['More Filters'].hide();
|
||||
@@ -0,0 +1,15 @@
|
||||
col = [['In Store Period (in days)', 'Data', '']]
|
||||
for c in col:
|
||||
colnames.append(str(c[0]))
|
||||
coltypes.append(str(c[1]))
|
||||
colwidths.append('150px')
|
||||
coloptions.append(str(c[2]))
|
||||
col_idx[str(c)] = len(colnames) - 1
|
||||
|
||||
import datetime
|
||||
for r in res:
|
||||
if r[col_idx['Purchase Date']]:
|
||||
dt = (datetime.date.today() - getdate(r[col_idx['Purchase Date']])).days
|
||||
else:
|
||||
dt = ''
|
||||
r.append(dt)
|
||||
@@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
'add_col': '',
|
||||
'add_cond': "`tabSerial No`.status = 'In Store'",
|
||||
'add_tab': None,
|
||||
'columns': 'Serial No\x01ID,Serial No\x01Item Code,Serial No\x01Description,Serial No\x01Item Group,Serial No\x01Purchase Date',
|
||||
'creation': '2010-09-01 15:47:57',
|
||||
'criteria_name': 'Stock Aging Report',
|
||||
'custom_query': '',
|
||||
'description': None,
|
||||
'dis_filters': None,
|
||||
'disabled': None,
|
||||
'doc_type': 'Serial No',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Serial No\x01Saved':1,'Serial No\x01Submitted':1,'Serial No\x01Status':'In Store','Serial No\x01Maintenance Status':''}",
|
||||
'graph_series': None,
|
||||
'graph_values': None,
|
||||
'group_by': None,
|
||||
'idx': None,
|
||||
'modified': '2010-08-16 13:42:24',
|
||||
'modified_by': 'Administrator',
|
||||
'module': 'Material Management',
|
||||
'name': 'stock_aging_report',
|
||||
'owner': 'ashwini@webnotestech.com',
|
||||
'page_len': 1000,
|
||||
'parent': None,
|
||||
'parent_doc_type': None,
|
||||
'parentfield': None,
|
||||
'parenttype': None,
|
||||
'report_script': None,
|
||||
'server_script': None,
|
||||
'sort_by': '`tabSerial No`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
}
|
||||
]
|
||||
0
stock/search_criteria/stock_ledger/__init__.py
Normal file
0
stock/search_criteria/stock_ledger/__init__.py
Normal file
4
stock/search_criteria/stock_ledger/stock_ledger.js
Normal file
4
stock/search_criteria/stock_ledger/stock_ledger.js
Normal file
@@ -0,0 +1,4 @@
|
||||
report.customize_filters = function() {
|
||||
this.add_filter({fieldname:'item_name', label:'Item Name', fieldtype:'Data', options:'', parent:'Item'});
|
||||
this.add_filter({fieldname:'description', label:'Description', fieldtype:'Small Text', options: '', parent:'Item'});
|
||||
}
|
||||
37
stock/search_criteria/stock_ledger/stock_ledger.txt
Normal file
37
stock/search_criteria/stock_ledger/stock_ledger.txt
Normal file
@@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
'add_col': '`tabItem`.`item_name`\n`tabItem`.`description`',
|
||||
'add_cond': '`tabItem`.`name` = `tabStock Ledger Entry`.`item_code`',
|
||||
'add_tab': '`tabItem`',
|
||||
'columns': 'Stock Ledger Entry\x01Item Code,Stock Ledger Entry\x01Warehouse,Stock Ledger Entry\x01Posting Date,Stock Ledger Entry\x01Voucher Detail No,Stock Ledger Entry\x01Actual Quantity,Stock Ledger Entry\x01Bin Actual Qty After Transaction',
|
||||
'creation': '2010-10-14 08:43:04',
|
||||
'criteria_name': 'Stock Ledger',
|
||||
'custom_query': '',
|
||||
'description': None,
|
||||
'dis_filters': None,
|
||||
'disabled': None,
|
||||
'doc_type': 'Stock Ledger Entry',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Stock Ledger Entry\x01Is Cancelled':'','Stock Ledger Entry\x01Is Stock Entry':''}",
|
||||
'graph_series': None,
|
||||
'graph_values': None,
|
||||
'group_by': None,
|
||||
'idx': None,
|
||||
'modified': '2010-10-14 08:31:40',
|
||||
'modified_by': 'Administrator',
|
||||
'module': 'Material Management',
|
||||
'name': 'stock_ledger',
|
||||
'owner': 'Administrator',
|
||||
'page_len': None,
|
||||
'parent': None,
|
||||
'parent_doc_type': None,
|
||||
'parentfield': None,
|
||||
'parenttype': None,
|
||||
'report_script': None,
|
||||
'server_script': None,
|
||||
'sort_by': None,
|
||||
'sort_order': None,
|
||||
'standard': 'Yes'
|
||||
}
|
||||
]
|
||||
0
stock/search_criteria/stock_level/__init__.py
Normal file
0
stock/search_criteria/stock_level/__init__.py
Normal file
4
stock/search_criteria/stock_level/stock_level.js
Normal file
4
stock/search_criteria/stock_level/stock_level.js
Normal file
@@ -0,0 +1,4 @@
|
||||
report.customize_filters = function() {
|
||||
this.add_filter({fieldname:'item_name', label:'Item Name', fieldtype:'Data', options:'', parent:'Item', in_first_page : 1});
|
||||
this.add_filter({fieldname:'description', label:'Description', fieldtype:'Small Text', options: '', parent:'Item', in_first_page : 1});
|
||||
}
|
||||
2
stock/search_criteria/stock_level/stock_level.py
Normal file
2
stock/search_criteria/stock_level/stock_level.py
Normal file
@@ -0,0 +1,2 @@
|
||||
colwidths[col_idx['Reserved Quantity']]= "120px"
|
||||
colwidths[col_idx['Ordered Quantity']] = "120px"
|
||||
37
stock/search_criteria/stock_level/stock_level.txt
Normal file
37
stock/search_criteria/stock_level/stock_level.txt
Normal file
@@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
'add_col': '`tabItem`.`item_name`\n`tabItem`.`description`',
|
||||
'add_cond': '`tabItem`.name = `tabBin`.item_code',
|
||||
'add_tab': '`tabItem`',
|
||||
'columns': 'Bin\x01Warehouse,Bin\x01Item Code,Bin\x01UOM,Bin\x01Reserved Quantity,Bin\x01Actual Quantity,Bin\x01Ordered Quantity,Bin\x01Planned Qty,Bin\x01Projected Qty,Bin\x01Indented Quantity,Bin\x01Valuation Rate,Bin\x01Stock Value',
|
||||
'creation': '2010-12-14 10:33:08',
|
||||
'criteria_name': 'Stock Level',
|
||||
'custom_query': '',
|
||||
'description': None,
|
||||
'dis_filters': None,
|
||||
'disabled': None,
|
||||
'doc_type': 'Bin',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': '{}',
|
||||
'graph_series': None,
|
||||
'graph_values': None,
|
||||
'group_by': None,
|
||||
'idx': None,
|
||||
'modified': '2010-10-20 16:51:11',
|
||||
'modified_by': 'Administrator',
|
||||
'module': 'Material Management',
|
||||
'name': 'stock_level',
|
||||
'owner': 'Administrator',
|
||||
'page_len': 50,
|
||||
'parent': None,
|
||||
'parent_doc_type': None,
|
||||
'parentfield': None,
|
||||
'parenttype': None,
|
||||
'report_script': None,
|
||||
'server_script': None,
|
||||
'sort_by': '`tabBin`.`warehouse`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
}
|
||||
]
|
||||
0
stock/search_criteria/stock_report/__init__.py
Normal file
0
stock/search_criteria/stock_report/__init__.py
Normal file
74
stock/search_criteria/stock_report/stock_report.js
Normal file
74
stock/search_criteria/stock_report/stock_report.js
Normal file
@@ -0,0 +1,74 @@
|
||||
//233
|
||||
report.customize_filters = function() {
|
||||
this.mytabs.items['Select Columns'].hide()
|
||||
this.mytabs.items['More Filters'].hide()
|
||||
this.hide_all_filters();
|
||||
this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Warehouse'+NEWLINE+'Item Code',report_default:'Warehouse',ignore : 1,parent:'Stock Ledger Entry'});
|
||||
this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'To Posting Date'].df.filter_hide = 0;
|
||||
this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Item Code'].df.filter_hide = 0;
|
||||
this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Warehouse'].df.filter_hide = 0;
|
||||
this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Warehouse Type'].df.filter_hide = 0;
|
||||
this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'From Posting Date'].df.filter_hide = 1;
|
||||
|
||||
this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Item Code'].df.in_first_page = 1;
|
||||
this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Warehouse'].df.in_first_page = 1;
|
||||
this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Based On'].df.in_first_page = 1;
|
||||
this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Warehouse Type'].df.in_first_page = 1;
|
||||
this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'To Posting Date'].df.in_first_page = 1;
|
||||
}
|
||||
|
||||
|
||||
report.get_query = function(){
|
||||
based_on = this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP+'Based On'].get_value();
|
||||
as_on = this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP+'To Posting Date'].get_value();
|
||||
warehouse = this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP+'Warehouse'].get_value();
|
||||
warehouse_type = this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP+'Warehouse Type'].get_value();
|
||||
item_code = this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP+'Item Code'].get_value();
|
||||
|
||||
cond = '';
|
||||
date_cond = '';
|
||||
tables = '';
|
||||
cols = '';
|
||||
group_by = '';
|
||||
ware_type_cond = '';
|
||||
war = '';
|
||||
if(!as_on) as_on = get_today();
|
||||
|
||||
date_cond = repl(' AND `tabStock Ledger Entry`.posting_date <= "%(as_on)s" ', {as_on:as_on});
|
||||
|
||||
if(warehouse_type.length > 0 && warehouse_type != ''){
|
||||
for(var i = 0; i<warehouse_type.length; i++) war += "'"+warehouse_type[i]+"',";
|
||||
ware_type_cond = repl(' AND `tabWarehouse`.warehouse_type IN (%(war)s)', {war: war.substr(0,war.length-1)})
|
||||
}
|
||||
|
||||
if(based_on.length == 1){
|
||||
if(based_on == 'Item Code'){
|
||||
cols = '`tabItem`.name AS "Item Code", `tabItem`.item_name AS "Item Name", `tabItem`.description AS "Description", `tabItem`.stock_uom AS "Stock UOM"';
|
||||
cond = '(IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND `tabItem`.is_stock_item = "Yes"';
|
||||
if(item_code) cond += repl(' AND `tabItem`.name = %(item)s', {item:'"'+item_code+'"'});
|
||||
cond += ' AND `tabStock Ledger Entry`.item_code = `tabItem`.name'
|
||||
tables = '`tabItem`';
|
||||
group_by = '`tabStock Ledger Entry`.item_code';
|
||||
}
|
||||
else if(based_on == 'Warehouse'){
|
||||
cols = '`tabWarehouse`.name AS "Warehouse", `tabWarehouse`.warehouse_type AS "Warehouse Type"';
|
||||
cond = '`tabWarehouse`.docstatus < 2'
|
||||
if(warehouse) cond += repl(' AND `tabWarehouse`.name = %(warehouse)s', {warehouse:'"'+warehouse+'"'});
|
||||
cond += repl(' AND `tabStock Ledger Entry`.warehouse = `tabWarehouse`.name %(ware_type_cond)s', {ware_type_cond:ware_type_cond})
|
||||
tables = '`tabWarehouse`';
|
||||
group_by = '`tabStock Ledger Entry`.warehouse';
|
||||
}
|
||||
}
|
||||
else if(based_on.length == 2){
|
||||
cols = '`tabItem`.name AS "Item Code", `tabItem`.item_name AS "Item Name", `tabItem`.description AS "Description", `tabItem`.stock_uom AS "Stock UOM", `tabWarehouse`.name AS "Warehouse", `tabWarehouse`.warehouse_type AS "Warehouse Type"';
|
||||
cond = '(IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND `tabItem`.is_stock_item = "Yes" AND `tabWarehouse`.docstatus < 2';
|
||||
if(item_code) cond += repl(" AND `tabItem`.name = %(item)s", {item:"'"+item_code+"'"});
|
||||
if(warehouse) cond += repl(" AND `tabWarehouse`.name = %(warehouse)s", {warehouse:"'"+warehouse+"'"});
|
||||
cond += repl(' AND `tabStock Ledger Entry`.item_code = `tabItem`.name AND `tabStock Ledger Entry`.warehouse = `tabWarehouse`.name %(ware_type_cond)s', {ware_type_cond:ware_type_cond})
|
||||
tables = '`tabItem`, `tabWarehouse`';
|
||||
group_by = '`tabStock Ledger Entry`.item_code, `tabStock Ledger Entry`.warehouse';
|
||||
}
|
||||
|
||||
q = repl("SELECT %(cols)s FROM %(tables)s, `tabStock Ledger Entry` WHERE %(cond)s %(date_cond)s GROUP BY %(group_by)s", {cols:cols, tables:tables, cond:cond, date_cond:date_cond, group_by:group_by});
|
||||
return q;
|
||||
}
|
||||
74
stock/search_criteria/stock_report/stock_report.py
Normal file
74
stock/search_criteria/stock_report/stock_report.py
Normal file
@@ -0,0 +1,74 @@
|
||||
if not filter_values.get('based_on'):
|
||||
msgprint("Please Select Based On")
|
||||
raise Exception
|
||||
cols, columns = [], []
|
||||
# Add columns
|
||||
# ------------
|
||||
based_on = filter_values.get('based_on').split(NEWLINE)
|
||||
if len(based_on) == 1:
|
||||
if based_on[0] == 'Item Code':
|
||||
cols = ["Item Code", "Item Name", "Description", "Stock UOM"]
|
||||
elif based_on[0] == 'Warehouse':
|
||||
cols = ["Warehouse", "Warehouse Type"]
|
||||
elif len(based_on) == 2:
|
||||
cols = ["Item Code", "Item Name", "Description", "Stock UOM", "Warehouse", "Warehouse Type"]
|
||||
|
||||
for d in cols:
|
||||
columns.append([d,'Data','150px',''])
|
||||
|
||||
columns.append(['Closing Balance','Currency','200px',''])
|
||||
columns.append(['Stock Value','Currency','150px',''])
|
||||
|
||||
posting_date = filter_values.get('posting_date1')
|
||||
if not posting_date: posting_date = nowdate()
|
||||
|
||||
for c in columns:
|
||||
colnames.append(c[0])
|
||||
coltypes.append(c[1])
|
||||
colwidths.append(c[2])
|
||||
coloptions.append(c[3])
|
||||
col_idx[c[0]] = len(colnames)-1
|
||||
|
||||
def get_values(msgprint, flt, posting_date, item_code = '', warehouse = ''):
|
||||
cl_bal, stock_val = 0,0
|
||||
if item_code and not warehouse:
|
||||
war_list = sql("select distinct warehouse from `tabStock Ledger Entry` where item_code = %s", item_code)
|
||||
for d in war_list:
|
||||
act = sql("select bin_aqat, stock_value from `tabStock Ledger Entry` where item_code = %s and warehouse = %s and ifnull(is_cancelled, 'No') = 'No' and timestamp(posting_date, posting_time) <= timestamp(%s, %s) Order by timestamp(posting_date, posting_time) DESC, name DESC LIMIT 1", (item_code, d[0], posting_date, '23:55'))
|
||||
cl_bal += act and flt(act[0][0]) or 0.00
|
||||
stock_val += act and flt(act[0][1]) or 0.00
|
||||
elif warehouse and not item_code:
|
||||
item_list = sql("select distinct item_code from `tabStock Ledger Entry` where warehouse = %s", warehouse)
|
||||
for d in item_list:
|
||||
act = sql("select bin_aqat, stock_value from `tabStock Ledger Entry` where item_code = %s and warehouse = %s and ifnull(is_cancelled, 'No') = 'No' and timestamp(posting_date, posting_time) <= timestamp(%s, %s) Order by timestamp(posting_date, posting_time) DESC, name DESC LIMIT 1", (d[0], warehouse, posting_date, '23:55'))
|
||||
cl_bal += act and flt(act[0][0]) or 0.00
|
||||
stock_val += act and flt(act[0][1]) or 0.00
|
||||
return cl_bal, stock_val
|
||||
|
||||
out=[]
|
||||
cl_bal,tot_stock = 0,0
|
||||
|
||||
for r in res:
|
||||
if len(based_on) == 1:
|
||||
if based_on[0] == 'Item Code': closing_balance, stock_value = get_values(msgprint, flt, posting_date, item_code = r[col_idx['Item Code']])
|
||||
elif based_on[0] == 'Warehouse': closing_balance, stock_value = get_values(msgprint, flt, posting_date, warehouse = r[col_idx['Warehouse']])
|
||||
r.append(closing_balance)
|
||||
r.append(stock_value)
|
||||
else:
|
||||
det = sql("select bin_aqat, stock_value from `tabStock Ledger Entry` where item_code = %s and warehouse = %s and ifnull(is_cancelled, 'No') = 'No' and timestamp(posting_date, posting_time) <= timestamp(%s, %s) Order by timestamp(posting_date, posting_time) DESC, name DESC LIMIT 1", (r[col_idx['Item Code']], r[col_idx['Warehouse']], posting_date, '23:55'))
|
||||
|
||||
r.append(det and flt(det[0][0]) or 0.00)
|
||||
r.append(det and flt(det[0][1]) or 0.00)
|
||||
cl_bal += flt(r[col_idx['Closing Balance']])
|
||||
tot_stock += flt(r[col_idx['Stock Value']])
|
||||
out.append(r)
|
||||
|
||||
# Add the totals row
|
||||
l_row = ['' for i in range(len(colnames))]
|
||||
if len(based_on) == 1 and based_on[0] == 'Warehouse':
|
||||
l_row[col_idx['Warehouse Type']] = '<b>TOTALS</b>'
|
||||
else:
|
||||
l_row[col_idx['Stock UOM']] = '<b>TOTALS</b>'
|
||||
l_row[col_idx['Closing Balance']] = cl_bal
|
||||
l_row[col_idx['Stock Value']] = tot_stock
|
||||
out.append(l_row)
|
||||
37
stock/search_criteria/stock_report/stock_report.txt
Normal file
37
stock/search_criteria/stock_report/stock_report.txt
Normal file
@@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
'add_col': None,
|
||||
'add_cond': None,
|
||||
'add_tab': None,
|
||||
'columns': 'Stock Ledger Entry\x01ID',
|
||||
'creation': '2010-11-02 15:37:36',
|
||||
'criteria_name': 'Stock Report',
|
||||
'custom_query': '',
|
||||
'description': None,
|
||||
'dis_filters': None,
|
||||
'disabled': None,
|
||||
'doc_type': 'Stock Ledger Entry',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Stock Ledger Entry\x01Is Cancelled':'','Stock Ledger Entry\x01Is Stock Entry':''}",
|
||||
'graph_series': None,
|
||||
'graph_values': None,
|
||||
'group_by': None,
|
||||
'idx': None,
|
||||
'modified': '2010-11-02 15:35:12',
|
||||
'modified_by': 'Administrator',
|
||||
'module': 'Material Management',
|
||||
'name': 'stock_report',
|
||||
'owner': 'Administrator',
|
||||
'page_len': 50,
|
||||
'parent': None,
|
||||
'parent_doc_type': None,
|
||||
'parentfield': None,
|
||||
'parenttype': None,
|
||||
'report_script': None,
|
||||
'server_script': None,
|
||||
'sort_by': '`tabStock Ledger Entry`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user