Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Nabin Hait 2013-01-07 15:00:08 +05:30 committed by Anand Doshi
commit 4fb4659a03
17 changed files with 272 additions and 202 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
*.pyc
*.py~
*.comp.js
.DS_Store
patch.log

View File

@ -2,9 +2,9 @@
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-07-03 13:29:48",
"creation": "2012-12-19 22:38:53",
"modified_by": "Administrator",
"modified": "2012-12-19 11:57:47"
"modified": "2013-01-04 13:15:09"
},
{
"istable": 1,
@ -40,17 +40,18 @@
},
{
"oldfieldtype": "Data",
"search_index": 0,
"doctype": "DocField",
"label": "Item Name",
"oldfieldname": "item_name",
"fieldname": "item_name",
"fieldtype": "Data",
"search_index": 0,
"reqd": 1,
"permlevel": 0,
"in_filter": 0
},
{
"print_width": "300px",
"oldfieldtype": "Text",
"doctype": "DocField",
"label": "Description",
@ -71,6 +72,15 @@
"reqd": 1,
"permlevel": 0
},
{
"print_hide": 1,
"doctype": "DocField",
"label": "UOM",
"options": "UOM",
"fieldname": "uom",
"fieldtype": "Link",
"permlevel": 0
},
{
"print_hide": 1,
"doctype": "DocField",
@ -140,19 +150,21 @@
},
{
"print_hide": 1,
"print_width": "120px",
"permlevel": 0,
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "Expense Head",
"oldfieldname": "expense_head",
"width": "120px",
"options": "Account",
"fieldname": "expense_head",
"fieldtype": "Link",
"reqd": 1
"reqd": 1,
"options": "Account"
},
{
"print_hide": 1,
"print_width": "120px",
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "Cost Center",
@ -173,15 +185,6 @@
"permlevel": 0,
"in_filter": 1
},
{
"print_hide": 1,
"doctype": "DocField",
"label": "UOM",
"options": "UOM",
"fieldname": "uom",
"fieldtype": "Link",
"permlevel": 0
},
{
"print_hide": 1,
"oldfieldtype": "Data",
@ -200,35 +203,35 @@
"label": "Item Group",
"oldfieldname": "item_group",
"permlevel": 1,
"options": "Item Group",
"fieldname": "item_group",
"fieldtype": "Link",
"search_index": 1,
"hidden": 1,
"options": "Item Group",
"in_filter": 1
},
{
"print_hide": 1,
"oldfieldtype": "Link",
"search_index": 1,
"doctype": "DocField",
"label": "Pur Order",
"oldfieldname": "purchase_order",
"options": "Purchase Order",
"fieldname": "purchase_order",
"fieldtype": "Link",
"search_index": 1,
"permlevel": 1,
"in_filter": 1
},
{
"print_hide": 1,
"oldfieldtype": "Data",
"search_index": 1,
"doctype": "DocField",
"label": "Purchase Order Item",
"oldfieldname": "po_detail",
"fieldname": "po_detail",
"fieldtype": "Data",
"search_index": 1,
"hidden": 1,
"permlevel": 1,
"in_filter": 1
@ -236,25 +239,25 @@
{
"print_hide": 1,
"oldfieldtype": "Link",
"search_index": 1,
"doctype": "DocField",
"label": "Pur Receipt",
"oldfieldname": "purchase_receipt",
"options": "Purchase Receipt",
"fieldname": "purchase_receipt",
"fieldtype": "Link",
"search_index": 1,
"permlevel": 1,
"in_filter": 1
},
{
"print_hide": 1,
"oldfieldtype": "Data",
"search_index": 1,
"doctype": "DocField",
"label": "PR Detail",
"oldfieldname": "pr_detail",
"fieldname": "pr_detail",
"fieldtype": "Data",
"search_index": 1,
"hidden": 1,
"permlevel": 1,
"in_filter": 1

View File

@ -28,8 +28,8 @@ def get_fiscal_year(date, verbose=1):
subdate(adddate(year_start_date, interval 1 year), interval 1 day)
as year_end_date
from `tabFiscal Year`
where %s >= year_start_date and %s < adddate(year_start_date, interval 1 year)""",
(date, date))
where %s >= year_start_date and %s < adddate(year_start_date, interval 1 year)
order by year_start_date desc""", (date, date))
if not fy:
error_msg = """%s not in any Fiscal Year""" % formatdate(date)

View File

@ -2,9 +2,9 @@
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-08-06 20:00:38",
"creation": "2012-12-19 22:38:55",
"modified_by": "Administrator",
"modified": "2012-12-19 11:57:28"
"modified": "2013-01-04 13:13:47"
},
{
"istable": 1,
@ -78,6 +78,7 @@
"in_filter": 1
},
{
"print_width": "300px",
"oldfieldtype": "Small Text",
"doctype": "DocField",
"label": "Description",
@ -89,6 +90,7 @@
"permlevel": 0
},
{
"print_width": "60px",
"default": "0.00",
"oldfieldtype": "Currency",
"doctype": "DocField",
@ -100,6 +102,20 @@
"reqd": 1,
"permlevel": 0
},
{
"print_hide": 0,
"print_width": "100px",
"permlevel": 0,
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "UOM",
"oldfieldname": "uom",
"width": "100px",
"fieldname": "uom",
"fieldtype": "Link",
"reqd": 1,
"options": "UOM"
},
{
"print_hide": 1,
"doctype": "DocField",
@ -146,6 +162,7 @@
},
{
"print_hide": 1,
"print_width": "100px",
"default": "0.00",
"oldfieldtype": "Currency",
"doctype": "DocField",
@ -193,21 +210,9 @@
"report_hide": 0,
"in_filter": 1
},
{
"print_hide": 0,
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "UOM",
"oldfieldname": "uom",
"width": "100px",
"options": "UOM",
"fieldname": "uom",
"fieldtype": "Link",
"reqd": 1,
"permlevel": 0
},
{
"print_hide": 1,
"print_width": "100px",
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "UOM Conversion Factor",
@ -221,6 +226,7 @@
},
{
"print_hide": 1,
"print_width": "100px",
"oldfieldtype": "Data",
"doctype": "DocField",
"label": "Stock UOM",
@ -247,6 +253,7 @@
{
"print_hide": 1,
"permlevel": 1,
"print_width": "120px",
"no_copy": 0,
"oldfieldtype": "Link",
"doctype": "DocField",
@ -263,12 +270,12 @@
{
"print_hide": 1,
"oldfieldtype": "Date",
"search_index": 0,
"doctype": "DocField",
"label": "Purchase Request Date",
"oldfieldname": "prevdoc_date",
"fieldname": "prevdoc_date",
"fieldtype": "Date",
"search_index": 0,
"hidden": 1,
"permlevel": 1,
"in_filter": 1
@ -326,15 +333,16 @@
"label": "Item Group",
"oldfieldname": "item_group",
"permlevel": 1,
"options": "Item Group",
"fieldname": "item_group",
"fieldtype": "Link",
"search_index": 0,
"hidden": 1,
"options": "Item Group",
"in_filter": 1
},
{
"print_hide": 1,
"print_width": "100px",
"no_copy": 1,
"oldfieldtype": "Currency",
"doctype": "DocField",
@ -361,11 +369,11 @@
{
"print_hide": 1,
"default": "0.00",
"no_copy": 1,
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "Billed Quantity",
"oldfieldname": "billed_qty",
"no_copy": 1,
"fieldname": "billed_qty",
"fieldtype": "Currency",
"hidden": 0,

View File

@ -2,9 +2,9 @@
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-08-06 20:00:36",
"creation": "2012-12-19 22:38:54",
"modified_by": "Administrator",
"modified": "2012-12-19 11:56:59"
"modified": "2013-01-04 13:14:13"
},
{
"istable": 1,
@ -63,6 +63,7 @@
"in_filter": 1
},
{
"print_width": "300px",
"oldfieldtype": "Small Text",
"doctype": "DocField",
"label": "Description",
@ -74,6 +75,7 @@
"permlevel": 0
},
{
"print_width": "60px",
"default": "0.00",
"oldfieldtype": "Currency",
"doctype": "DocField",
@ -85,6 +87,20 @@
"reqd": 1,
"permlevel": 0
},
{
"print_hide": 0,
"print_width": "100px",
"permlevel": 0,
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "UOM",
"oldfieldname": "uom",
"width": "100px",
"fieldname": "uom",
"fieldtype": "Link",
"reqd": 1,
"options": "UOM"
},
{
"print_hide": 1,
"doctype": "DocField",
@ -131,6 +147,7 @@
},
{
"print_hide": 1,
"print_width": "100px",
"default": "0.00",
"oldfieldtype": "Currency",
"doctype": "DocField",
@ -160,11 +177,11 @@
"doctype": "DocField",
"label": "Warehouse",
"oldfieldname": "warehouse",
"options": "Warehouse",
"fieldname": "warehouse",
"fieldtype": "Link",
"reqd": 0,
"hidden": 0,
"options": "Warehouse",
"permlevel": 0
},
{
@ -178,19 +195,6 @@
"report_hide": 0,
"in_filter": 1
},
{
"print_hide": 0,
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "UOM",
"oldfieldname": "uom",
"width": "100px",
"options": "UOM",
"fieldname": "uom",
"fieldtype": "Link",
"reqd": 1,
"permlevel": 0
},
{
"print_hide": 1,
"no_copy": 0,
@ -206,6 +210,7 @@
{
"print_hide": 1,
"permlevel": 1,
"print_width": "120px",
"no_copy": 0,
"oldfieldtype": "Link",
"doctype": "DocField",
@ -222,12 +227,12 @@
{
"print_hide": 1,
"oldfieldtype": "Date",
"search_index": 0,
"doctype": "DocField",
"label": "Purchase Request Date",
"oldfieldname": "prevdoc_date",
"fieldname": "prevdoc_date",
"fieldtype": "Date",
"search_index": 0,
"hidden": 1,
"permlevel": 1,
"in_filter": 1
@ -265,11 +270,11 @@
"label": "Item Group",
"oldfieldname": "item_group",
"permlevel": 1,
"options": "Item Group",
"fieldname": "item_group",
"fieldtype": "Link",
"search_index": 0,
"hidden": 1,
"options": "Item Group",
"in_filter": 1
},
{

View File

@ -1,4 +1,8 @@
erpnext.updates = [
["4th January 2013", [
"Support Analytics: Simple Tool to Plot Number Tickets and time to Closing",
"Workflow: Added Workflow Help",
]],
["2nd January 2013", [
"Permission Manager: New Design with better help and better advanced permission selection.",
"User Properties: Better way to set User Properties (defaults).",

View File

@ -32,10 +32,6 @@ class DocType:
def validate(self):
# if self.doc.exp_approver == self.doc.owner:
# webnotes.msgprint("""Self Approval is not allowed.""", raise_exception=1)
import utilities
utilities.validate_status(self.doc.approval_status, ["Draft", "Approved", "Rejected"])
self.validate_fiscal_year()
self.validate_exp_details()

View File

@ -32,10 +32,6 @@ class DocType:
def validate(self):
# if self.doc.leave_approver == self.doc.owner:
# webnotes.msgprint("""Self Approval is not allowed.""", raise_exception=1)
import utilities
utilities.validate_status(self.doc.status, ["Open", "Approved", "Rejected"])
self.validate_to_date()
self.validate_balance_leaves()
self.validate_leave_overlap()
@ -43,7 +39,7 @@ class DocType:
def on_submit(self):
if self.doc.status != "Approved":
webnotes.msgprint("""Only Approved Leave Applications can be Submitted.""",
webnotes.msgprint("""Only Leave Applications with status 'Approved' can be Submitted.""",
raise_exception=True)
def get_holidays(self):

View File

@ -215,6 +215,13 @@ data_map = {
"parent": ["Purchase Invoice", "name"],
"item_code": ["Item", "name"]
}
},
# Support
"Support Ticket": {
"columns": ["name","status","creation","modified"],
"conditions": ["docstatus < 2"],
"order_by": "creation"
}
}

View File

@ -2,9 +2,9 @@
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-07-03 13:30:42",
"creation": "2012-12-03 10:25:00",
"modified_by": "Administrator",
"modified": "2012-12-03 10:20:11"
"modified": "2013-01-04 13:14:40"
},
{
"istable": 1,
@ -25,13 +25,13 @@
"doctype": "DocType"
},
{
"print_width": "100px",
"permlevel": 0,
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "Item Code",
"oldfieldname": "item_code",
"width": "100px",
"trigger": "Client",
"fieldname": "item_code",
"fieldtype": "Link",
"search_index": 1,
@ -53,6 +53,7 @@
"in_filter": 0
},
{
"print_width": "300px",
"oldfieldtype": "Text",
"doctype": "DocField",
"label": "Description",
@ -65,45 +66,59 @@
},
{
"print_hide": 1,
"print_width": "100px",
"default": "0.00",
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "Recd Quantity",
"oldfieldname": "received_qty",
"width": "100px",
"trigger": "Client",
"fieldname": "received_qty",
"fieldtype": "Currency",
"reqd": 1,
"permlevel": 0
},
{
"print_width": "100px",
"default": "0.00",
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "Accepted Quantity",
"oldfieldname": "qty",
"width": "100px",
"trigger": "Client",
"fieldname": "qty",
"fieldtype": "Currency",
"permlevel": 0
},
{
"print_hide": 1,
"print_width": "100px",
"default": "0.00",
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "Rejected Quantity",
"oldfieldname": "rejected_qty",
"width": "100px",
"trigger": "Client",
"fieldname": "rejected_qty",
"fieldtype": "Currency",
"search_index": 0,
"permlevel": 0,
"in_filter": 0
},
{
"print_hide": 1,
"print_width": "100px",
"permlevel": 0,
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "UOM",
"oldfieldname": "uom",
"width": "100px",
"fieldname": "uom",
"fieldtype": "Link",
"reqd": 1,
"options": "UOM"
},
{
"print_hide": 1,
"doctype": "DocField",
@ -122,14 +137,13 @@
},
{
"print_hide": 0,
"print_width": "100px",
"default": "0.00",
"oldfieldtype": "Currency",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Rate",
"oldfieldname": "import_rate",
"width": "100px",
"trigger": "Client",
"fieldname": "import_rate",
"fieldtype": "Currency",
"permlevel": 0
@ -153,14 +167,13 @@
},
{
"print_hide": 1,
"print_width": "100px",
"default": "0.00",
"oldfieldtype": "Currency",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Rate *(Default Curr.)",
"oldfieldname": "purchase_rate",
"width": "100px",
"trigger": "Client",
"fieldname": "purchase_rate",
"fieldtype": "Currency",
"reqd": 1,
@ -168,13 +181,13 @@
},
{
"print_hide": 1,
"print_width": "100px",
"default": "0.00",
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "Amount (Default Curr.)",
"oldfieldname": "amount",
"width": "100px",
"trigger": "Client",
"fieldname": "amount",
"fieldtype": "Currency",
"reqd": 0,
@ -182,40 +195,26 @@
},
{
"print_hide": 1,
"print_width": "100px",
"permlevel": 0,
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "Accepted Warehouse",
"oldfieldname": "warehouse",
"width": "100px",
"options": "Warehouse",
"fieldname": "warehouse",
"fieldtype": "Link",
"hidden": 0,
"permlevel": 0
},
{
"print_hide": 1,
"permlevel": 0,
"oldfieldtype": "Link",
"colour": "White:FFF",
"doctype": "DocField",
"label": "UOM",
"oldfieldname": "uom",
"width": "100px",
"trigger": "Client",
"fieldname": "uom",
"fieldtype": "Link",
"reqd": 1,
"options": "UOM"
"options": "Warehouse"
},
{
"print_hide": 1,
"print_width": "100px",
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "Conversion Factor",
"oldfieldname": "conversion_factor",
"width": "100px",
"trigger": "Client",
"fieldname": "conversion_factor",
"fieldtype": "Currency",
"reqd": 1,
@ -223,6 +222,7 @@
},
{
"print_hide": 1,
"print_width": "100px",
"oldfieldtype": "Data",
"doctype": "DocField",
"label": "Stock UOM",
@ -237,7 +237,6 @@
"print_hide": 0,
"no_copy": 1,
"oldfieldtype": "Text",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Serial No",
"oldfieldname": "serial_no",
@ -258,22 +257,20 @@
{
"print_hide": 1,
"oldfieldtype": "Link",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Batch No",
"oldfieldname": "batch_no",
"trigger": "Client",
"options": "Batch",
"fieldname": "batch_no",
"fieldtype": "Link",
"options": "Batch",
"permlevel": 0
},
{
"print_hide": 1,
"permlevel": 1,
"print_width": "100px",
"no_copy": 1,
"oldfieldtype": "Link",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Rejected Warehouse",
"oldfieldname": "rejected_warehouse",
@ -287,7 +284,6 @@
"print_hide": 1,
"no_copy": 1,
"oldfieldtype": "Date",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Required By",
"oldfieldname": "schedule_date",
@ -299,7 +295,6 @@
},
{
"print_hide": 1,
"colour": "White:FFF",
"doctype": "DocField",
"label": "Project Name",
"options": "Project",
@ -312,7 +307,6 @@
"print_hide": 1,
"no_copy": 1,
"oldfieldtype": "Link",
"colour": "White:FFF",
"doctype": "DocField",
"label": "QA No",
"oldfieldname": "qa_no",
@ -349,12 +343,12 @@
},
{
"print_hide": 1,
"print_width": "100px",
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "Stock Qty",
"oldfieldname": "stock_qty",
"width": "100px",
"trigger": "Client",
"fieldname": "stock_qty",
"fieldtype": "Currency",
"permlevel": 0
@ -362,7 +356,6 @@
{
"print_hide": 1,
"oldfieldtype": "Data",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Prevdoc Doctype",
"oldfieldname": "prevdoc_doctype",
@ -374,9 +367,9 @@
{
"print_hide": 1,
"permlevel": 1,
"print_width": "150px",
"no_copy": 0,
"oldfieldtype": "Link",
"colour": "White:FFF",
"doctype": "DocField",
"label": "PO No",
"oldfieldname": "prevdoc_docname",
@ -403,6 +396,7 @@
},
{
"print_hide": 1,
"print_width": "150px",
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "Raw Materials Supplied Cost",
@ -416,9 +410,9 @@
},
{
"print_hide": 1,
"print_width": "150px",
"no_copy": 1,
"oldfieldtype": "Currency",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Item Tax Amount",
"oldfieldname": "item_tax_amount",
@ -432,9 +426,9 @@
},
{
"print_hide": 1,
"print_width": "150px",
"no_copy": 0,
"oldfieldtype": "Data",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Purchase Order Item No",
"oldfieldname": "prevdoc_detail_docname",
@ -448,22 +442,23 @@
},
{
"print_hide": 1,
"permlevel": 1,
"print_width": "100px",
"default": "0.00",
"oldfieldtype": "Currency",
"doctype": "DocField",
"no_copy": 1,
"label": "Billed Quantity",
"oldfieldname": "billed_qty",
"width": "100px",
"no_copy": 1,
"fieldname": "billed_qty",
"fieldtype": "Currency",
"permlevel": 1
"width": "100px"
},
{
"print_hide": 1,
"print_width": "80px",
"no_copy": 1,
"oldfieldtype": "Currency",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Valuation Rate",
"oldfieldname": "valuation_rate",
@ -478,7 +473,6 @@
"print_hide": 1,
"description": "Tax detail table fetched from item master as a string and stored in this field.\nUsed for Taxes and Charges",
"oldfieldtype": "Small Text",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Item Tax Rate",
"oldfieldname": "item_tax_rate",
@ -491,8 +485,8 @@
},
{
"print_hide": 1,
"oldfieldtype": "Check",
"allow_on_submit": 1,
"oldfieldtype": "Check",
"doctype": "DocField",
"label": "Page Break",
"oldfieldname": "page_break",

View File

@ -1,87 +0,0 @@
# Please edit this list and import only required elements
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
from webnotes.model.doclist import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, is_testing, msgprint, errprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
# Get FIFO Rate from Stack
# -------------------------
def get_fifo_rate(self, fcfs_stack, qty):
fcfs_val = 0
withdraw = flt(qty)
while withdraw:
batch = fcfs_stack[0]
if batch[0] <= withdraw:
# not enough or exactly same qty in current batch, clear batch
withdraw -= batch[0]
fcfs_val += (flt(batch[0]) * flt(batch[1]))
fcfs_stack.pop(0)
else:
# all from current batch
fcfs_val += (flt(withdraw) * flt(batch[1]))
batch[0] -= withdraw
withdraw = 0
fcfs_rate = flt(fcfs_val) / flt(qty)
return fcfs_rate
# --------------------------------
# get serializable inventory rate
# --------------------------------
def get_serializable_inventory_rate(self, serial_no):
sr_nos = get_obj("Stock Ledger").get_sr_no_list(serial_no)
tot = 0
for s in sr_nos:
serial_no = s.strip()
tot += flt(webnotes.conn.get_value('Serial No', serial_no, 'purchase_rate'))
return tot / len(sr_nos)
# ---------------------
# get valuation method
# ---------------------
def get_valuation_method(self, item_code):
val_method = webnotes.conn.get_value('Item', item_code, 'valuation_method')
if not val_method:
val_method = get_defaults().get('valuation_method', 'FIFO')
return val_method
# Get Incoming Rate based on valuation method
# --------------------------------------------
def get_incoming_rate(self, posting_date, posting_time, item, warehouse, qty = 0, serial_no = ''):
msgprint(1)
in_rate = 0
val_method = self.get_valuation_method(item)
bin_obj = get_obj('Warehouse',warehouse).get_bin(item)
if serial_no:
in_rate = self.get_serializable_inventory_rate(serial_no)
elif val_method == 'FIFO':
in_rate = 0
if qty:
prev_sle = bin_obj.get_prev_sle(posting_date, posting_time)
msgprint(prev_sle)
fcfs_stack = eval(prev_sle.get('fcfs_stack', '[]') or '[]')
msgprint(fcfs_stack)
in_rate = fcfs_stack and self.get_fifo_rate(fcfs_stack, qty) or 0
msgprint(in_rate)
elif val_method == 'Moving Average':
prev_sle = bin_obj.get_prev_sle(posting_date, posting_time)
in_rate = prev_sle and prev_sle.get('valuation_rate', 0) or 0
return in_rate

View File

@ -130,6 +130,12 @@ erpnext.StockBalance = erpnext.StockAnalytics.extend({
}
}
}
// opening + diff = closing
// adding opening, since diff already added to closing
$.each(me.item_by_name, function(key, item) {
item.closing += item.opening;
});
},
update_groups: function() {

View File

@ -0,0 +1,91 @@
wn.pages['support-analytics'].onload = function(wrapper) {
wn.ui.make_app_page({
parent: wrapper,
title: 'Support Analytics',
single_column: true
});
new erpnext.SupportAnalytics(wrapper);
wrapper.appframe.add_home_breadcrumb()
wrapper.appframe.add_module_breadcrumb("Support")
wrapper.appframe.add_breadcrumb("icon-bar-chart")
}
erpnext.SupportAnalytics = wn.views.GridReportWithPlot.extend({
init: function(wrapper) {
this._super({
title: "Support Analtyics",
page: wrapper,
parent: $(wrapper).find('.layout-main'),
appframe: wrapper.appframe,
doctypes: ["Support Ticket", "Fiscal Year"],
});
},
filters: [
{fieldtype:"Select", label: "Fiscal Year", link:"Fiscal Year",
default_value: "Select Fiscal Year..."},
{fieldtype:"Date", label: "From Date"},
{fieldtype:"Label", label: "To"},
{fieldtype:"Date", label: "To Date"},
{fieldtype:"Select", label: "Range",
options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]},
{fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
{fieldtype:"Button", label: "Reset Filters"}
],
setup_columns: function() {
var std_columns = [
{id: "check", name: "Plot", field: "check", width: 30,
formatter: this.check_formatter},
{id: "status", name: "Status", field: "status", width: 100},
];
this.make_date_range_columns();
this.columns = std_columns.concat(this.columns);
},
prepare_data: function() {
// add Opening, Closing, Totals rows
// if filtered by account and / or voucher
var me = this;
var total_tickets = {status:"All Tickets", "id": "all-tickets",
checked:true};
var days_to_close = {status:"Days to Close", "id":"days-to-close",
checked:false};
var hours_to_close = {status:"Hours to Close", "id":"hours-to-close",
checked:false};
$.each(wn.report_dump.data["Support Ticket"], function(i, d) {
var dateobj = dateutil.str_to_obj(d.creation);
var date = d.creation.split(" ")[0];
var col = me.column_map[date];
if(col) {
// just count
var day_diff = dateutil.get_diff(d.modified, d.creation);
var hour_diff = dateutil.get_hour_diff(d.modified, d.creation);
total_tickets[col.field] = flt(total_tickets[col.field]) + 1;
days_to_close[col.field] = flt(days_to_close[col.field]) + day_diff;
hours_to_close[col.field] = flt(hours_to_close[col.field]) + hour_diff;
}
});
// make averages
$.each(this.columns, function(i, col) {
if(col.formatter==me.currency_formatter && total_tickets[col.field]) {
days_to_close[col.field] = flt(days_to_close[col.field]) / flt(total_tickets[col.field]);
hours_to_close[col.field] = flt(hours_to_close[col.field]) / flt(total_tickets[col.field]);
}
})
this.data = [total_tickets, days_to_close, hours_to_close];
},
get_plot_points: function(item, col, idx) {
return [[dateutil.str_to_obj(col.id).getTime(), item[col.field]],
[dateutil.user_to_obj(col.name).getTime(), item[col.field]]];
}
});

View File

@ -0,0 +1,32 @@
[
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2013-01-04 15:31:45",
"modified_by": "Administrator",
"modified": "2013-01-04 15:38:44"
},
{
"name": "__common__",
"title": "Support Analytics",
"doctype": "Page",
"module": "Support",
"standard": "Yes",
"page_name": "support-analytics"
},
{
"name": "__common__",
"parent": "support-analytics",
"doctype": "Page Role",
"parenttype": "Page",
"role": "Support Team",
"parentfield": "roles"
},
{
"name": "support-analytics",
"doctype": "Page"
},
{
"doctype": "Page Role"
}
]

View File

@ -26,6 +26,16 @@
</div>
<div style="clear: both"></div>
<hr>
<div style="width: 48%; float: left;">
<h5><a href="#support-analytics" data-role="Analytics, Support Manager">
Support Analytics</a>
</h5>
<p class="help">Support Ticket trends and response.</p>
</div>
<div style="width: 48%; float: right;">
</div>
<div style="clear: both;"></div>
<hr>
<h4>Reports</h4>
<div class="reports-list"></div>
</div>

View File

@ -11,3 +11,7 @@ class DocType:
"""clear web cache"""
from website.utils import clear_cache
clear_cache()
if self.doc.default_product_category:
webnotes.model_wrapper("Item Group",
self.doc.default_product_category).save()