merge conflict fixed

This commit is contained in:
Akhilesh Darjee 2014-01-03 18:18:31 +05:30
commit e27717261d
108 changed files with 758 additions and 3617 deletions

View File

@ -42,7 +42,6 @@ class DocType(AccountsController):
def on_submit(self):
if self.doc.voucher_type in ['Bank Voucher', 'Contra Voucher', 'Journal Entry']:
self.check_credit_days()
self.check_account_against_entries()
self.make_gl_entries()
self.check_credit_limit()
@ -232,14 +231,20 @@ class DocType(AccountsController):
for d in self.doclist.get({"parentfield": "entries"}):
if d.against_invoice and webnotes.conn.get_value("Sales Invoice",
d.against_invoice, "debit_to") != d.account:
webnotes.throw(_("Credited account (Customer) is not matching with Sales Invoice"))
webnotes.throw(_("Row #") + cstr(d.idx) + ": " +
_("Account is not matching with Debit To account of Sales Invoice"))
if d.against_voucher and webnotes.conn.get_value("Purchase Invoice",
d.against_voucher, "credit_to") != d.account:
webnotes.throw(_("Debited account (Supplier) is not matching with Purchase Invoice"))
d.against_voucher, "credit_to") != d.account:
webnotes.throw(_("Row #") + cstr(d.idx) + ": " +
_("Account is not matching with Credit To account of Purchase Invoice"))
def make_gl_entries(self, cancel=0, adv_adj=0):
from erpnext.accounts.general_ledger import make_gl_entries
if not cancel:
self.check_account_against_entries()
gl_map = []
for d in self.doclist.get({"parentfield": "entries"}):
if d.debit or d.credit:

View File

@ -74,5 +74,5 @@ cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn)
cur_frm.fields_dict.user.get_query = function(doc,cdt,cdn) {
return{ query:"core.doctype.profile.profile.profile_query"}
return{ query:"webnotes.core.doctype.profile.profile.profile_query"}
}

View File

@ -2,7 +2,7 @@
{
"creation": "2013-02-22 01:27:41",
"docstatus": 0,
"modified": "2013-12-20 19:21:40",
"modified": "2013-12-31 18:29:19",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -15,7 +15,6 @@
{
"doctype": "DocField",
"name": "__common__",
"no_copy": 1,
"parent": "Sales Invoice Advance",
"parentfield": "fields",
"parenttype": "DocType",
@ -31,6 +30,7 @@
"fieldtype": "Link",
"in_list_view": 1,
"label": "Journal Voucher",
"no_copy": 1,
"oldfieldname": "journal_voucher",
"oldfieldtype": "Link",
"options": "Journal Voucher",
@ -38,26 +38,13 @@
"read_only": 1,
"width": "250px"
},
{
"doctype": "DocField",
"fieldname": "jv_detail_no",
"fieldtype": "Data",
"hidden": 1,
"in_list_view": 0,
"label": "Journal Voucher Detail No",
"oldfieldname": "jv_detail_no",
"oldfieldtype": "Data",
"print_hide": 1,
"print_width": "120px",
"read_only": 1,
"width": "120px"
},
{
"doctype": "DocField",
"fieldname": "advance_amount",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Advance amount",
"no_copy": 1,
"oldfieldname": "advance_amount",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
@ -71,22 +58,44 @@
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Allocated amount",
"no_copy": 1,
"oldfieldname": "allocated_amount",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_width": "120px",
"width": "120px"
},
{
"doctype": "DocField",
"fieldname": "col_break1",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "remarks",
"fieldtype": "Small Text",
"in_list_view": 1,
"label": "Remarks",
"no_copy": 1,
"oldfieldname": "remarks",
"oldfieldtype": "Small Text",
"print_width": "150px",
"read_only": 1,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "jv_detail_no",
"fieldtype": "Data",
"hidden": 1,
"in_list_view": 0,
"label": "Journal Voucher Detail No",
"no_copy": 1,
"oldfieldname": "jv_detail_no",
"oldfieldtype": "Data",
"print_hide": 1,
"print_width": "120px",
"read_only": 1,
"width": "120px"
}
]

View File

@ -2,7 +2,7 @@
{
"creation": "2013-06-04 11:02:19",
"docstatus": 0,
"modified": "2013-12-20 19:21:40",
"modified": "2013-12-31 18:27:41",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -49,16 +49,6 @@
"reqd": 0,
"search_index": 1
},
{
"doctype": "DocField",
"fieldname": "customer_item_code",
"fieldtype": "Data",
"hidden": 1,
"in_list_view": 0,
"label": "Customer's Item Code",
"print_hide": 1,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "item_name",
@ -73,6 +63,21 @@
"reqd": 1,
"search_index": 0
},
{
"doctype": "DocField",
"fieldname": "col_break1",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "customer_item_code",
"fieldtype": "Data",
"hidden": 1,
"in_list_view": 0,
"label": "Customer's Item Code",
"print_hide": 1,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "description",
@ -104,15 +109,6 @@
"read_only": 0,
"reqd": 0
},
{
"doctype": "DocField",
"fieldname": "stock_uom",
"fieldtype": "Link",
"in_list_view": 0,
"label": "UOM",
"options": "UOM",
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "ref_rate",
@ -137,6 +133,37 @@
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "col_break2",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "stock_uom",
"fieldtype": "Link",
"in_list_view": 0,
"label": "UOM",
"options": "UOM",
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "base_ref_rate",
"fieldtype": "Currency",
"in_list_view": 0,
"label": "Price List Rate (Company Currency)",
"oldfieldname": "base_ref_rate",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "section_break1",
"fieldtype": "Section Break"
},
{
"doctype": "DocField",
"fieldname": "export_rate",
@ -163,15 +190,8 @@
},
{
"doctype": "DocField",
"fieldname": "base_ref_rate",
"fieldtype": "Currency",
"in_list_view": 0,
"label": "Price List Rate (Company Currency)",
"oldfieldname": "base_ref_rate",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
"read_only": 1
"fieldname": "col_break3",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
@ -237,6 +257,11 @@
"read_only": 0,
"width": "120px"
},
{
"doctype": "DocField",
"fieldname": "col_break4",
"fieldtype": "Column Break"
},
{
"default": ":Company",
"doctype": "DocField",
@ -322,6 +347,22 @@
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "item_tax_rate",
"fieldtype": "Small Text",
"hidden": 1,
"label": "Item Tax Rate",
"oldfieldname": "item_tax_rate",
"oldfieldtype": "Small Text",
"print_hide": 1,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "col_break5",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "actual_qty",
@ -334,13 +375,11 @@
},
{
"doctype": "DocField",
"fieldname": "delivered_qty",
"fieldtype": "Float",
"label": "Delivered Qty",
"oldfieldname": "delivered_qty",
"oldfieldtype": "Currency",
"print_hide": 1,
"read_only": 1
"fieldname": "time_log_batch",
"fieldtype": "Link",
"label": "Time Log Batch",
"options": "Time Log Batch",
"read_only": 0
},
{
"doctype": "DocField",
@ -400,20 +439,11 @@
},
{
"doctype": "DocField",
"fieldname": "time_log_batch",
"fieldtype": "Link",
"label": "Time Log Batch",
"options": "Time Log Batch",
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "item_tax_rate",
"fieldtype": "Small Text",
"hidden": 1,
"label": "Item Tax Rate",
"oldfieldname": "item_tax_rate",
"oldfieldtype": "Small Text",
"fieldname": "delivered_qty",
"fieldtype": "Float",
"label": "Delivered Qty",
"oldfieldname": "delivered_qty",
"oldfieldtype": "Currency",
"print_hide": 1,
"read_only": 1
},

View File

@ -46,6 +46,24 @@
"oldfieldname": "row_id",
"oldfieldtype": "Data"
},
{
"doctype": "DocField",
"fieldname": "description",
"fieldtype": "Small Text",
"in_list_view": 1,
"label": "Description",
"oldfieldname": "description",
"oldfieldtype": "Small Text",
"print_width": "300px",
"reqd": 1,
"width": "300px"
},
{
"doctype": "DocField",
"fieldname": "col_break_1",
"fieldtype": "Column Break",
"width": "50%"
},
{
"doctype": "DocField",
"fieldname": "account_head",
@ -69,36 +87,6 @@
"oldfieldtype": "Link",
"options": "Cost Center"
},
{
"doctype": "DocField",
"fieldname": "description",
"fieldtype": "Small Text",
"in_list_view": 1,
"label": "Description",
"oldfieldname": "description",
"oldfieldtype": "Small Text",
"print_width": "300px",
"reqd": 1,
"width": "300px"
},
{
"allow_on_submit": 0,
"description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount",
"doctype": "DocField",
"fieldname": "included_in_print_rate",
"fieldtype": "Check",
"label": "Is this Tax included in Basic Rate?",
"no_copy": 0,
"print_hide": 1,
"print_width": "150px",
"report_hide": 1,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "section_break_6",
"fieldtype": "Section Break"
},
{
"doctype": "DocField",
"fieldname": "rate",
@ -131,6 +119,19 @@
"options": "Company:company:default_currency",
"read_only": 1
},
{
"allow_on_submit": 0,
"description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount",
"doctype": "DocField",
"fieldname": "included_in_print_rate",
"fieldtype": "Check",
"label": "Is this Tax included in Basic Rate?",
"no_copy": 0,
"print_hide": 1,
"print_width": "150px",
"report_hide": 1,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "tax_amount_after_discount_amount",

View File

@ -14,9 +14,4 @@ class DocType(DocListController):
(self.doc.name, self.doc.company))
# at least one territory
self.validate_table_has_rows("valid_for_territories")
def on_update(self):
cart_settings = webnotes.get_obj("Shopping Cart Settings")
if cint(cart_settings.doc.enabled):
cart_settings.validate_tax_masters()
self.validate_table_has_rows("valid_for_territories")

View File

@ -19,8 +19,8 @@ def execute(filters=None):
for gle in get_gl_entries(filters, before_report_date=False)]
account_supplier_type_map = get_account_supplier_type_map()
pi_map = get_pi_map()
voucher_detail_map = get_voucher_details()
# Age of the invoice on this date
age_on = getdate(filters.get("report_date")) > getdate(nowdate()) \
and nowdate() or filters.get("report_date")
@ -29,14 +29,8 @@ def execute(filters=None):
for gle in entries:
if cstr(gle.against_voucher) == gle.voucher_no or not gle.against_voucher \
or [gle.against_voucher_type, gle.against_voucher] in entries_after_report_date:
if gle.voucher_type == "Purchase Invoice":
pi_info = pi_map.get(gle.voucher_no)
due_date = pi_info.get("due_date")
bill_no = pi_info.get("bill_no")
bill_date = pi_info.get("bill_date")
else:
due_date = bill_no = bill_date = ""
voucher_details = voucher_detail_map.get(gle.voucher_type, {}).get(gle.voucher_no, {})
invoiced_amount = gle.credit > 0 and gle.credit or 0
outstanding_amount = get_outstanding_amount(gle,
filters.get("report_date") or nowdate())
@ -44,13 +38,15 @@ def execute(filters=None):
if abs(flt(outstanding_amount)) > 0.01:
paid_amount = invoiced_amount - outstanding_amount
row = [gle.posting_date, gle.account, account_supplier.get(gle.account, ""),
gle.voucher_type, gle.voucher_no,
gle.remarks, account_supplier_type_map.get(gle.account), due_date, bill_no,
bill_date, invoiced_amount, paid_amount, outstanding_amount]
gle.voucher_type, gle.voucher_no, gle.remarks,
account_supplier_type_map.get(gle.account),
voucher_details.get("due_date", ""), voucher_details.get("bill_no", ""),
voucher_details.get("bill_date", ""), invoiced_amount,
paid_amount, outstanding_amount]
# Ageing
if filters.get("ageing_based_on") == "Due Date":
ageing_based_on_date = due_date
ageing_based_on_date = voucher_details.get("due_date", "")
else:
ageing_based_on_date = gle.posting_date
@ -111,14 +107,15 @@ def get_account_supplier_type_map():
return account_supplier_type_map
def get_pi_map():
""" get due_date from sales invoice """
pi_map = {}
for t in webnotes.conn.sql("""select name, due_date, bill_no, bill_date
from `tabPurchase Invoice`""", as_dict=1):
pi_map[t.name] = t
def get_voucher_details():
voucher_details = {}
for dt in ["Purchase Invoice", "Journal Voucher"]:
voucher_details.setdefault(dt, webnotes._dict())
for t in webnotes.conn.sql("""select name, due_date, bill_no, bill_date
from `tab%s`""" % dt, as_dict=1):
voucher_details[dt].setdefault(t.name, t)
return pi_map
return voucher_details
def get_outstanding_amount(gle, report_date):
payment_amount = webnotes.conn.sql("""

View File

@ -1,111 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import flt, add_days
from webnotes import _
from erpnext.accounts.utils import get_balance_on
def execute(filters=None):
account_details = webnotes.conn.get_value("Account", filters["account"],
["debit_or_credit", "group_or_ledger"], as_dict=True) if filters.get("account") else None
validate_filters(filters, account_details)
columns = get_columns()
data = []
if filters.get("group_by"):
data += get_grouped_gle(filters)
else:
data += get_gl_entries(filters)
if data:
data.append(get_total_row(data))
if account_details:
data = [get_opening_balance_row(filters, account_details.debit_or_credit)] + data + \
[get_closing_balance_row(filters, account_details.debit_or_credit)]
return columns, data
def validate_filters(filters, account_details):
if account_details and account_details.group_or_ledger == "Ledger" \
and filters.get("group_by") == "Group by Account":
webnotes.throw(_("Can not filter based on Account, if grouped by Account"))
if filters.get("voucher_no") and filters.get("group_by") == "Group by Voucher":
webnotes.throw(_("Can not filter based on Voucher No, if grouped by Voucher"))
def get_columns():
return ["Posting Date:Date:100", "Account:Link/Account:200", "Debit:Float:100",
"Credit:Float:100", "Voucher Type::120", "Voucher No::160", "Link::20",
"Cost Center:Link/Cost Center:100", "Remarks::200"]
def get_opening_balance_row(filters, debit_or_credit):
opening_balance = get_balance_on(filters["account"], add_days(filters["from_date"], -1))
return get_balance_row(opening_balance, debit_or_credit, "Opening Balance")
def get_closing_balance_row(filters, debit_or_credit):
closing_balance = get_balance_on(filters["account"], filters["to_date"])
return get_balance_row(closing_balance, debit_or_credit, "Closing Balance")
def get_balance_row(balance, debit_or_credit, balance_label):
if debit_or_credit == "Debit":
return ["", balance_label, balance, 0.0, "", "", ""]
else:
return ["", balance_label, 0.0, balance, "", "", ""]
def get_gl_entries(filters):
gl_entries = webnotes.conn.sql("""select
posting_date, account, debit, credit, voucher_type, voucher_no, cost_center, remarks
from `tabGL Entry`
where company=%(company)s
and posting_date between %(from_date)s and %(to_date)s
{conditions}
order by posting_date, account"""\
.format(conditions=get_conditions(filters)), filters, as_list=1)
for d in gl_entries:
icon = """<a href="%s"><i class="icon icon-share" style="cursor: pointer;"></i></a>""" \
% ("/".join(["#Form", d[4], d[5]]),)
d.insert(6, icon)
return gl_entries
def get_conditions(filters):
conditions = []
if filters.get("account"):
lft, rgt = webnotes.conn.get_value("Account", filters["account"], ["lft", "rgt"])
conditions.append("""account in (select name from tabAccount
where lft>=%s and rgt<=%s and docstatus<2)""" % (lft, rgt))
if filters.get("voucher_no"):
conditions.append("voucher_no=%(voucher_no)s")
return "and {}".format(" and ".join(conditions)) if conditions else ""
def get_grouped_gle(filters):
gle_map = {}
gle = get_gl_entries(filters)
for d in gle:
gle_map.setdefault(d[1 if filters["group_by"]=="Group by Account" else 5], []).append(d)
data = []
for entries in gle_map.values():
subtotal_debit = subtotal_credit = 0.0
for entry in entries:
data.append(entry)
subtotal_debit += flt(entry[2])
subtotal_credit += flt(entry[3])
data.append(["", "Total", subtotal_debit, subtotal_credit, "", "", ""])
if data:
data.append(get_total_row(gle))
return data
def get_total_row(gle):
total_debit = total_credit = 0.0
for d in gle:
total_debit += flt(d[2])
total_credit += flt(d[3])
return ["", "Total Debit/Credit", total_debit, total_credit, "", "", ""]

View File

@ -11,26 +11,6 @@ wn.query_reports["General Ledger"] = {
"default": wn.defaults.get_user_default("company"),
"reqd": 1
},
{
"fieldname":"account",
"label": wn._("Account"),
"fieldtype": "Link",
"options": "Account"
},
{
"fieldname":"voucher_no",
"label": wn._("Voucher No"),
"fieldtype": "Data",
},
{
"fieldname":"group_by",
"label": wn._("Group by"),
"fieldtype": "Select",
"options": "\nGroup by Account\nGroup by Voucher"
},
{
"fieldtype": "Break",
},
{
"fieldname":"from_date",
"label": wn._("From Date"),
@ -46,6 +26,40 @@ wn.query_reports["General Ledger"] = {
"default": wn.datetime.get_today(),
"reqd": 1,
"width": "60px"
},
{
"fieldtype": "Break",
},
{
"fieldname":"account",
"label": wn._("Account"),
"fieldtype": "Link",
"options": "Account",
"get_query": function() {
var company = wn.query_report.filters_by_name.company.get_value();
return {
"doctype": "Account",
"filters": {
"company": company,
}
}
}
},
{
"fieldname":"voucher_no",
"label": wn._("Voucher No"),
"fieldtype": "Data",
},
{
"fieldname":"group_by_voucher",
"label": wn._("Group by Voucher"),
"fieldtype": "Check",
"default": 1
},
{
"fieldname":"group_by_account",
"label": wn._("Group by Account"),
"fieldtype": "Check",
}
]
}

View File

@ -0,0 +1,172 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, flt
from webnotes import _
def execute(filters=None):
account_details = {}
for acc in webnotes.conn.sql("""select name, debit_or_credit, group_or_ledger
from tabAccount""", as_dict=1):
account_details.setdefault(acc.name, acc)
validate_filters(filters, account_details)
columns = get_columns()
res = get_result(filters, account_details)
return columns, res
def validate_filters(filters, account_details):
if filters.get("account") and filters.get("group_by_account") \
and account_details[filters.account].group_or_ledger == "Ledger":
webnotes.throw(_("Can not filter based on Account, if grouped by Account"))
if filters.get("voucher_no") and filters.get("group_by_voucher"):
webnotes.throw(_("Can not filter based on Voucher No, if grouped by Voucher"))
if filters.from_date > filters.to_date:
webnotes.throw(_("From Date must be before To Date"))
def get_columns():
return ["Posting Date:Date:100", "Account:Link/Account:200", "Debit:Float:100",
"Credit:Float:100", "Voucher Type::120", "Voucher No::160", "Link::20",
"Against Account::120", "Cost Center:Link/Cost Center:100", "Remarks::200"]
def get_result(filters, account_details):
gl_entries = get_gl_entries(filters)
data = get_data_with_opening_closing(filters, account_details, gl_entries)
result = get_result_as_list(data)
return result
def get_gl_entries(filters):
group_by_condition = "group by voucher_type, voucher_no, account" \
if filters.get("group_by_voucher") else "group by name"
gl_entries = webnotes.conn.sql("""select posting_date, account,
sum(ifnull(debit, 0)) as debit, sum(ifnull(credit, 0)) as credit,
voucher_type, voucher_no, cost_center, remarks, is_advance, against
from `tabGL Entry`
where company=%(company)s {conditions}
{group_by_condition}
order by posting_date, account"""\
.format(conditions=get_conditions(filters), group_by_condition=group_by_condition),
filters, as_dict=1)
return gl_entries
def get_conditions(filters):
conditions = []
if filters.get("account"):
lft, rgt = webnotes.conn.get_value("Account", filters["account"], ["lft", "rgt"])
conditions.append("""account in (select name from tabAccount
where lft>=%s and rgt<=%s and docstatus<2)""" % (lft, rgt))
else:
conditions.append("posting_date between %(from_date)s and %(to_date)s")
if filters.get("voucher_no"):
conditions.append("voucher_no=%(voucher_no)s")
return "and {}".format(" and ".join(conditions)) if conditions else ""
def get_data_with_opening_closing(filters, account_details, gl_entries):
data = []
gle_map = initialize_gle_map(gl_entries)
opening, total_debit, total_credit, gle_map = get_accountwise_gle(filters, gl_entries, gle_map)
# Opening for filtered account
if filters.get("account"):
data += [get_balance_row("Opening", account_details[filters.account].debit_or_credit,
opening), {}]
for acc, acc_dict in gle_map.items():
if acc_dict.entries:
# Opening for individual ledger, if grouped by account
if filters.get("group_by_account"):
data.append(get_balance_row("Opening", account_details[acc].debit_or_credit,
acc_dict.opening))
data += acc_dict.entries
# Totals and closing for individual ledger, if grouped by account
if filters.get("group_by_account"):
data += [{"account": "Totals", "debit": acc_dict.total_debit,
"credit": acc_dict.total_credit},
get_balance_row("Closing (Opening + Totals)",
account_details[acc].debit_or_credit, (acc_dict.opening
+ acc_dict.total_debit - acc_dict.total_credit)), {}]
# Total debit and credit between from and to date
if total_debit or total_credit:
data.append({"account": "Totals", "debit": total_debit, "credit": total_credit})
# Closing for filtered account
if filters.get("account"):
data.append(get_balance_row("Closing (Opening + Totals)",
account_details[filters.account].debit_or_credit,
(opening + total_debit - total_credit)))
return data
def initialize_gle_map(gl_entries):
gle_map = webnotes._dict()
for gle in gl_entries:
gle_map.setdefault(gle.account, webnotes._dict({
"opening": 0,
"entries": [],
"total_debit": 0,
"total_credit": 0,
"closing": 0
}))
return gle_map
def get_accountwise_gle(filters, gl_entries, gle_map):
opening, total_debit, total_credit = 0, 0, 0
for gle in gl_entries:
amount = flt(gle.debit) - flt(gle.credit)
if filters.get("account") and (gle.posting_date < filters.from_date
or cstr(gle.is_advance) == "Yes"):
gle_map[gle.account].opening += amount
opening += amount
elif gle.posting_date < filters.to_date:
gle_map[gle.account].entries.append(gle)
gle_map[gle.account].total_debit += flt(gle.debit)
gle_map[gle.account].total_credit += flt(gle.credit)
total_debit += flt(gle.debit)
total_credit += flt(gle.credit)
return opening, total_debit, total_credit, gle_map
def get_balance_row(label, debit_or_credit, balance):
return {
"account": label,
"debit": balance if debit_or_credit=="Debit" else 0,
"credit": -1*balance if debit_or_credit=="Credit" else 0,
}
def get_result_as_list(data):
result = []
for d in data:
result.append([d.get("posting_date"), d.get("account"), d.get("debit"),
d.get("credit"), d.get("voucher_type"), d.get("voucher_no"),
get_voucher_link(d.get("voucher_type"), d.get("voucher_no")),
d.get("against"), d.get("cost_center"), d.get("remarks")])
return result
def get_voucher_link(voucher_type, voucher_no):
icon = ""
if voucher_type and voucher_no:
icon = """<a href="%s"><i class="icon icon-share" style="cursor: pointer;">
</i></a>""" % ("/".join(["#Form", voucher_type, voucher_no]))
return icon

View File

@ -21,7 +21,6 @@ update_website_context = erpnext.startup.webutils.update_website_context
mail_footer = erpnext.startup.mail_footer
on_session_creation = erpnext.startup.event_handlers.on_session_creation
on_logout = erpnext.startup.event_handlers.on_logut
# Boot Events
# -------------------------
@ -37,7 +36,6 @@ bean_event = *:on_trash:webnotes.core.doctype.notification_count.notification_co
bean_event = Stock Entry:on_submit:erpnext.stock.doctype.material_request.material_request.update_completed_qty
bean_event = Stock Entry:on_cancel:erpnext.stock.doctype.material_request.material_request.update_completed_qty
standard_queries = Warehouse:erpnext.stock.utils.get_warehouse_list
standard_queries = Customer:erpnext.selling.utils.get_customer_list
# Schedulers

View File

@ -5,7 +5,7 @@ wn.provide("erpnext.hr");
erpnext.hr.EmployeeController = wn.ui.form.Controller.extend({
setup: function() {
this.frm.fields_dict.user_id.get_query = function(doc,cdt,cdn) {
return { query:"core.doctype.profile.profile.profile_query"} }
return { query:"webnotes.core.doctype.profile.profile.profile_query"} }
this.frm.fields_dict.reports_to.get_query = function(doc,cdt,cdn) {
return{ query: "erpnext.controllers.queries.employee_query"} }
},

View File

@ -1,14 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
import webnotes
def execute():
webnotes.reload_doc("selling", "doctype", "shopping_cart_settings")
# create two default territories, one for home country and one named Rest of the World
from erpnext.setup.page.setup_wizard.setup_wizard import create_territories
create_territories()
webnotes.conn.set_value("Shopping Cart Settings", None, "default_territory", "Rest of the World")

View File

@ -161,7 +161,6 @@ patch_list = [
"execute:webnotes.delete_doc('Report', 'Sales Orders Pending To Be Delivered')",
"patches.june_2013.p05_remove_unused_doctypes",
"patches.june_2013.p06_drop_unused_tables",
"patches.june_2013.p08_shopping_cart_settings",
"patches.june_2013.p09_update_global_defaults",
"patches.june_2013.p10_lead_address",
"patches.july_2013.p01_remove_doctype_mappers",

View File

@ -28,7 +28,7 @@ class DocType:
})
def validate_time_log_is_submitted(self, tl):
if tl.status != "Submitted":
if tl.status != "Submitted" and self.doc.docstatus == 0:
webnotes.msgprint(_("Time Log must have status 'Submitted'") + \
" :" + tl.name + " (" + _(tl.status) + ")", raise_exception=True)
@ -57,7 +57,4 @@ class DocType:
tl = webnotes.bean("Time Log", d.time_log)
tl.doc.time_log_batch = time_log_batch
tl.doc.sales_invoice = self.doc.sales_invoice
tl.update_after_submit()
tl.update_after_submit()

View File

@ -8,7 +8,7 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) {
} else if(d.account_head && d.charge_type!=="Actual") {
wn.call({
type:"GET",
method: "controllers.accounts_controller.get_tax_rate",
method: "erpnext.controllers.accounts_controller.get_tax_rate",
args: {"account_head":d.account_head},
callback: function(r) {
wn.model.set_value(cdt, cdn, "rate", r.message || 0);

View File

@ -5,7 +5,7 @@
wn.provide("erpnext.queries");
$.extend(erpnext.queries, {
profile: function() {
return { query: "core.doctype.profile.profile.profile_query" };
return { query: "webnotes.core.doctype.profile.profile.profile_query" };
},
lead: function() {

View File

@ -1,14 +1,14 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
if(!window.erpnext) erpnext = {};
if(!window.erpnext) window.erpnext = {};
// Add / update a new Lead / Communication
// subject, sender, description
wn.send_message = function(opts, btn) {
return wn.call({
type: "POST",
method: "erpnext.portal.utils.send_message",
method: "erpnext.templates.utils.send_message",
btn: btn,
args: opts,
callback: opts.callback
@ -16,71 +16,4 @@ wn.send_message = function(opts, btn) {
};
// for backward compatibility
erpnext.send_message = wn.send_message;
// Setup the user tools
//
$(document).ready(function() {
// update login
erpnext.cart.set_cart_count();
// update profile
if(full_name) {
$('.navbar li[data-label="Profile"] a')
.html('<i class="icon-fixed-width icon-user"></i> ' + full_name);
}
});
// shopping cart
if(!erpnext.cart) erpnext.cart = {};
$.extend(erpnext.cart, {
update_cart: function(opts) {
if(!full_name) {
if(localStorage) {
localStorage.setItem("last_visited", window.location.href.split("/").slice(-1)[0]);
localStorage.setItem("pending_add_to_cart", opts.item_code);
}
window.location.href = "login";
} else {
return wn.call({
type: "POST",
method: "erpnext.selling.utils.cart.update_cart",
args: {
item_code: opts.item_code,
qty: opts.qty,
with_doclist: opts.with_doclist
},
btn: opts.btn,
callback: function(r) {
if(opts.callback)
opts.callback(r);
erpnext.cart.set_cart_count();
}
});
}
},
set_cart_count: function() {
var cart_count = getCookie("cart_count");
var $cart = $("#website-post-login").find('[data-label="Cart"]');
var $badge = $cart.find(".badge");
var $cog = $("#website-post-login").find(".dropdown-toggle");
var $cog_count = $cog.find(".cart-count");
if(cart_count) {
if($badge.length === 0) {
var $badge = $('<span class="badge pull-right"></span>').appendTo($cart.find("a"));
}
$badge.html(cart_count);
if($cog_count.length === 0) {
var $cog_count = $('<sup class="cart-count"></span>').insertAfter($cog.find(".icon-cog"));
}
$cog_count.html(cart_count);
} else {
$badge.remove();
$cog_count.remove();
}
}
});
erpnext.send_message = wn.send_message;

View File

@ -14,12 +14,12 @@ erpnext.LeadController = wn.ui.form.Controller.extend({
onload: function() {
if(cur_frm.fields_dict.lead_owner.df.options.match(/^Profile/)) {
cur_frm.fields_dict.lead_owner.get_query = function(doc,cdt,cdn) {
return { query:"core.doctype.profile.profile.profile_query" } }
return { query:"webnotes.core.doctype.profile.profile.profile_query" } }
}
if(cur_frm.fields_dict.contact_by.df.options.match(/^Profile/)) {
cur_frm.fields_dict.contact_by.get_query = function(doc,cdt,cdn) {
return { query:"core.doctype.profile.profile.profile_query" } }
return { query:"webnotes.core.doctype.profile.profile.profile_query" } }
}
if(in_list(user_roles,'System Manager')) {

View File

@ -2,7 +2,7 @@
{
"creation": "2013-03-07 11:42:57",
"docstatus": 0,
"modified": "2013-12-20 19:23:41",
"modified": "2013-12-31 18:12:09",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -69,6 +69,11 @@
"search_index": 1,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "col_break1",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "description",
@ -106,21 +111,6 @@
"search_index": 0,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "stock_uom",
"fieldtype": "Link",
"in_list_view": 0,
"label": "UOM",
"oldfieldname": "stock_uom",
"oldfieldtype": "Data",
"options": "UOM",
"print_hide": 0,
"print_width": "100px",
"read_only": 1,
"reqd": 0,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "ref_rate",
@ -149,6 +139,45 @@
"read_only": 0,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "col_break2",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "stock_uom",
"fieldtype": "Link",
"in_list_view": 0,
"label": "UOM",
"oldfieldname": "stock_uom",
"oldfieldtype": "Data",
"options": "UOM",
"print_hide": 0,
"print_width": "100px",
"read_only": 1,
"reqd": 0,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "base_ref_rate",
"fieldtype": "Currency",
"in_list_view": 0,
"label": "Price List Rate (Company Currency)",
"oldfieldname": "base_ref_rate",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
"print_width": "100px",
"read_only": 1,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "Section_break1",
"fieldtype": "Section Break"
},
{
"doctype": "DocField",
"fieldname": "export_rate",
@ -185,17 +214,8 @@
},
{
"doctype": "DocField",
"fieldname": "base_ref_rate",
"fieldtype": "Currency",
"in_list_view": 0,
"label": "Price List Rate (Company Currency)",
"oldfieldname": "base_ref_rate",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
"print_width": "100px",
"read_only": 1,
"width": "100px"
"fieldname": "col_break3",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
@ -238,6 +258,70 @@
"in_list_view": 0,
"label": "Reference"
},
{
"doctype": "DocField",
"fieldname": "prevdoc_doctype",
"fieldtype": "Data",
"hidden": 1,
"in_list_view": 0,
"label": "Against Doctype",
"no_copy": 1,
"oldfieldname": "prevdoc_doctype",
"oldfieldtype": "Data",
"print_hide": 1,
"print_width": "150px",
"read_only": 1,
"report_hide": 0,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "prevdoc_docname",
"fieldtype": "Data",
"in_list_view": 0,
"label": "Against Docname",
"no_copy": 1,
"oldfieldname": "prevdoc_docname",
"oldfieldtype": "Data",
"print_hide": 1,
"print_width": "150px",
"read_only": 1,
"report_hide": 0,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "item_tax_rate",
"fieldtype": "Small Text",
"hidden": 1,
"in_list_view": 0,
"label": "Item Tax Rate",
"oldfieldname": "item_tax_rate",
"oldfieldtype": "Small Text",
"print_hide": 1,
"read_only": 1,
"report_hide": 1
},
{
"doctype": "DocField",
"fieldname": "col_break4",
"fieldtype": "Column Break"
},
{
"allow_on_submit": 1,
"doctype": "DocField",
"fieldname": "page_break",
"fieldtype": "Check",
"hidden": 0,
"in_list_view": 0,
"label": "Page Break",
"no_copy": 1,
"oldfieldname": "page_break",
"oldfieldtype": "Check",
"print_hide": 1,
"read_only": 0,
"report_hide": 1
},
{
"description": "<a href=\"#Sales Browser/Item Group\">Add / Edit</a>",
"doctype": "DocField",
@ -270,64 +354,5 @@
"read_only": 1,
"search_index": 1,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "item_tax_rate",
"fieldtype": "Small Text",
"hidden": 1,
"in_list_view": 0,
"label": "Item Tax Rate",
"oldfieldname": "item_tax_rate",
"oldfieldtype": "Small Text",
"print_hide": 1,
"read_only": 1,
"report_hide": 1
},
{
"doctype": "DocField",
"fieldname": "prevdoc_docname",
"fieldtype": "Data",
"in_list_view": 0,
"label": "Against Docname",
"no_copy": 1,
"oldfieldname": "prevdoc_docname",
"oldfieldtype": "Data",
"print_hide": 1,
"print_width": "150px",
"read_only": 1,
"report_hide": 0,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "prevdoc_doctype",
"fieldtype": "Data",
"hidden": 1,
"in_list_view": 0,
"label": "Against Doctype",
"no_copy": 1,
"oldfieldname": "prevdoc_doctype",
"oldfieldtype": "Data",
"print_hide": 1,
"print_width": "150px",
"read_only": 1,
"report_hide": 0,
"width": "150px"
},
{
"allow_on_submit": 1,
"doctype": "DocField",
"fieldname": "page_break",
"fieldtype": "Check",
"hidden": 0,
"in_list_view": 0,
"label": "Page Break",
"no_copy": 1,
"oldfieldname": "page_break",
"oldfieldtype": "Check",
"print_hide": 1,
"read_only": 0,
"report_hide": 1
}
]

View File

@ -1,5 +0,0 @@
{% extends "templates/sale.html" %}
{% block status -%}
{% if doc.status %}{{ doc.status }}{% endif %}
{%- endblock %}

View File

@ -1,32 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import _
no_cache = True
def get_context():
from erpnext.templates.utils import get_transaction_context
context = get_transaction_context("Sales Order", webnotes.form_dict.name)
modify_status(context.get("doc"))
context.update({
"parent_link": "orders",
"parent_title": "My Orders"
})
return context
def modify_status(doc):
doc.status = []
if 0 < doc.per_billed < 100:
doc.status.append(("label-warning", "icon-ok", _("Partially Billed")))
elif doc.per_billed == 100:
doc.status.append(("label-success", "icon-ok", _("Billed")))
if 0 < doc.per_delivered < 100:
doc.status.append(("label-warning", "icon-truck", _("Partially Delivered")))
elif doc.per_delivered == 100:
doc.status.append(("label-success", "icon-truck", _("Delivered")))
doc.status = " " + " ".join(('<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % s
for s in doc.status))

View File

@ -1 +0,0 @@
{% extends "templates/sales_transactions.html" %}

View File

@ -1,30 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
no_cache = True
def get_context():
from erpnext.templates.utils import get_currency_context
context = get_currency_context()
context.update({
"title": "My Orders",
"method": "selling.doctype.sales_order.templates.pages.orders.get_orders",
"icon": "icon-list",
"empty_list_message": "No Orders Yet",
"page": "order",
})
return context
@webnotes.whitelist()
def get_orders(start=0):
from erpnext.templates.utils import get_transaction_list
from erpnext.selling.doctype.sales_order.templates.pages.order import modify_status
orders = get_transaction_list("Sales Order", start, ["per_billed", "per_delivered"])
for d in orders:
modify_status(d)
return orders

View File

@ -2,7 +2,7 @@
{
"creation": "2013-03-07 11:42:58",
"docstatus": 0,
"modified": "2013-12-20 19:21:43",
"modified": "2013-12-31 18:07:50",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -65,6 +65,11 @@
"reqd": 1,
"width": "150"
},
{
"doctype": "DocField",
"fieldname": "col_break1",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "description",
@ -100,21 +105,6 @@
"reqd": 1,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "stock_uom",
"fieldtype": "Link",
"hidden": 0,
"in_list_view": 0,
"label": "UOM",
"oldfieldname": "stock_uom",
"oldfieldtype": "Data",
"options": "UOM",
"print_width": "70px",
"read_only": 1,
"reqd": 0,
"width": "70px"
},
{
"doctype": "DocField",
"fieldname": "ref_rate",
@ -143,6 +133,45 @@
"read_only": 0,
"width": "70px"
},
{
"doctype": "DocField",
"fieldname": "col_break2",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "stock_uom",
"fieldtype": "Link",
"hidden": 0,
"in_list_view": 0,
"label": "UOM",
"oldfieldname": "stock_uom",
"oldfieldtype": "Data",
"options": "UOM",
"print_width": "70px",
"read_only": 1,
"reqd": 0,
"width": "70px"
},
{
"doctype": "DocField",
"fieldname": "base_ref_rate",
"fieldtype": "Currency",
"in_list_view": 0,
"label": "Price List Rate (Company Currency)",
"oldfieldname": "base_ref_rate",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
"print_width": "100px",
"read_only": 1,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "section_break_simple1",
"fieldtype": "Section Break"
},
{
"doctype": "DocField",
"fieldname": "export_rate",
@ -174,17 +203,8 @@
},
{
"doctype": "DocField",
"fieldname": "base_ref_rate",
"fieldtype": "Currency",
"in_list_view": 0,
"label": "Price List Rate (Company Currency)",
"oldfieldname": "base_ref_rate",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
"print_width": "100px",
"read_only": 1,
"width": "100px"
"fieldname": "col_break3",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
@ -240,6 +260,71 @@
"reqd": 0,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "prevdoc_docname",
"fieldtype": "Link",
"hidden": 0,
"in_filter": 1,
"in_list_view": 0,
"label": "Quotation",
"no_copy": 1,
"oldfieldname": "prevdoc_docname",
"oldfieldtype": "Link",
"options": "Quotation",
"print_hide": 1,
"read_only": 1,
"search_index": 1
},
{
"doctype": "DocField",
"fieldname": "brand",
"fieldtype": "Link",
"hidden": 1,
"in_filter": 1,
"in_list_view": 0,
"label": "Brand Name",
"oldfieldname": "brand",
"oldfieldtype": "Link",
"options": "Brand",
"print_hide": 1,
"read_only": 1,
"search_index": 1
},
{
"description": "<a href=\"#Sales Browser/Item Group\">Add / Edit</a>",
"doctype": "DocField",
"fieldname": "item_group",
"fieldtype": "Link",
"hidden": 1,
"in_filter": 1,
"in_list_view": 0,
"label": "Item Group",
"oldfieldname": "item_group",
"oldfieldtype": "Link",
"options": "Item Group",
"print_hide": 1,
"read_only": 1,
"search_index": 1
},
{
"allow_on_submit": 1,
"doctype": "DocField",
"fieldname": "page_break",
"fieldtype": "Check",
"in_list_view": 0,
"label": "Page Break",
"oldfieldname": "page_break",
"oldfieldtype": "Check",
"print_hide": 1,
"read_only": 0,
"report_hide": 1
},
{
"doctype": "DocField",
"fieldname": "col_break4",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "projected_qty",
@ -328,66 +413,6 @@
"report_hide": 1,
"width": "50px"
},
{
"doctype": "DocField",
"fieldname": "brand",
"fieldtype": "Link",
"hidden": 1,
"in_filter": 1,
"in_list_view": 0,
"label": "Brand Name",
"oldfieldname": "brand",
"oldfieldtype": "Link",
"options": "Brand",
"print_hide": 1,
"read_only": 1,
"search_index": 1
},
{
"description": "<a href=\"#Sales Browser/Item Group\">Add / Edit</a>",
"doctype": "DocField",
"fieldname": "item_group",
"fieldtype": "Link",
"hidden": 1,
"in_filter": 1,
"in_list_view": 0,
"label": "Item Group",
"oldfieldname": "item_group",
"oldfieldtype": "Link",
"options": "Item Group",
"print_hide": 1,
"read_only": 1,
"search_index": 1
},
{
"doctype": "DocField",
"fieldname": "prevdoc_docname",
"fieldtype": "Link",
"hidden": 0,
"in_filter": 1,
"in_list_view": 0,
"label": "Quotation",
"no_copy": 1,
"oldfieldname": "prevdoc_docname",
"oldfieldtype": "Link",
"options": "Quotation",
"print_hide": 1,
"read_only": 1,
"search_index": 1
},
{
"allow_on_submit": 1,
"doctype": "DocField",
"fieldname": "page_break",
"fieldtype": "Check",
"in_list_view": 0,
"label": "Page Break",
"oldfieldname": "page_break",
"oldfieldtype": "Check",
"print_hide": 1,
"read_only": 0,
"report_hide": 1
},
{
"doctype": "DocField",
"fieldname": "item_tax_rate",

View File

@ -2,7 +2,7 @@
{
"creation": "2013-04-19 13:30:51",
"docstatus": 0,
"modified": "2013-12-20 19:21:46",
"modified": "2013-12-31 19:00:14",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -63,6 +63,11 @@
"print_width": "100px",
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "col_break1",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "allocated_percentage",
@ -89,6 +94,16 @@
"reqd": 0,
"width": "120px"
},
{
"doctype": "DocField",
"fieldname": "incentives",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Incentives",
"oldfieldname": "incentives",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency"
},
{
"doctype": "DocField",
"fieldname": "parenttype",
@ -101,15 +116,5 @@
"oldfieldtype": "Data",
"print_hide": 1,
"search_index": 1
},
{
"doctype": "DocField",
"fieldname": "incentives",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Incentives",
"oldfieldname": "incentives",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency"
}
]

View File

@ -1,11 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
# For license information, please see license.txt
from __future__ import unicode_literals
import webnotes
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl

View File

@ -1,36 +0,0 @@
[
{
"creation": "2013-06-20 16:00:18",
"docstatus": 0,
"modified": "2013-12-20 19:21:47",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "DocType",
"istable": 1,
"module": "Selling",
"name": "__common__"
},
{
"doctype": "DocField",
"fieldname": "selling_price_list",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Price List",
"name": "__common__",
"options": "Price List",
"parent": "Shopping Cart Price List",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0,
"reqd": 1
},
{
"doctype": "DocType",
"name": "Shopping Cart Price List"
},
{
"doctype": "DocField"
}
]

View File

@ -1,10 +0,0 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
$.extend(cur_frm.cscript, {
onload: function() {
if(cur_frm.doc.__quotation_series) {
cur_frm.fields_dict.quotation_series.df.options = cur_frm.doc.__quotation_series;
}
}
});

View File

@ -1,154 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
# For license information, please see license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import _, msgprint
from webnotes.utils import comma_and
from webnotes.model.controller import DocListController
class ShoppingCartSetupError(webnotes.ValidationError): pass
class DocType(DocListController):
def onload(self):
self.doc.fields["__quotation_series"] = webnotes.get_doctype("Quotation").get_options("naming_series")
def validate(self):
if self.doc.enabled:
self.validate_price_lists()
self.validate_tax_masters()
self.validate_exchange_rates_exist()
def on_update(self):
webnotes.conn.set_default("shopping_cart_enabled", self.doc.fields.get("enabled") or 0)
webnotes.conn.set_default("shopping_cart_quotation_series", self.doc.fields.get("quotation_series"))
def validate_overlapping_territories(self, parentfield, fieldname):
# for displaying message
doctype = self.meta.get_field(parentfield).options
# specify atleast one entry in the table
self.validate_table_has_rows(parentfield, raise_exception=ShoppingCartSetupError)
territory_name_map = self.get_territory_name_map(parentfield, fieldname)
for territory, names in territory_name_map.items():
if len(names) > 1:
msgprint(_("Error for") + " " + _(doctype) + ": " + comma_and(names) +
" " + _("have a common territory") + ": " + territory,
raise_exception=ShoppingCartSetupError)
return territory_name_map
def validate_price_lists(self):
territory_name_map = self.validate_overlapping_territories("price_lists",
"selling_price_list")
# validate that a Shopping Cart Price List exists for the root territory
# as a catch all!
from erpnext.setup.utils import get_root_of
root_territory = get_root_of("Territory")
if root_territory not in territory_name_map.keys():
msgprint(_("Please specify a Price List which is valid for Territory") +
": " + root_territory, raise_exception=ShoppingCartSetupError)
def validate_tax_masters(self):
self.validate_overlapping_territories("sales_taxes_and_charges_masters",
"sales_taxes_and_charges_master")
def get_territory_name_map(self, parentfield, fieldname):
territory_name_map = {}
# entries in table
names = [doc.fields.get(fieldname) for doc in self.doclist.get({"parentfield": parentfield})]
if names:
# for condition in territory check
parenttype = self.meta.get_field(fieldname, parentfield=parentfield).options
# to validate territory overlap
# make a map of territory: [list of names]
# if list against each territory has more than one element, raise exception
territory_name = webnotes.conn.sql("""select `territory`, `parent`
from `tabApplicable Territory`
where `parenttype`=%s and `parent` in (%s)""" %
("%s", ", ".join(["%s"]*len(names))), tuple([parenttype] + names))
for territory, name in territory_name:
territory_name_map.setdefault(territory, []).append(name)
if len(territory_name_map[territory]) > 1:
territory_name_map[territory].sort(key=lambda val: names.index(val))
return territory_name_map
def validate_exchange_rates_exist(self):
"""check if exchange rates exist for all Price List currencies (to company's currency)"""
company_currency = webnotes.conn.get_value("Company", self.doc.company, "default_currency")
if not company_currency:
msgprint(_("Please specify currency in Company") + ": " + self.doc.company,
raise_exception=ShoppingCartSetupError)
price_list_currency_map = webnotes.conn.get_values("Price List",
[d.selling_price_list for d in self.doclist.get({"parentfield": "price_lists"})],
"currency")
# check if all price lists have a currency
for price_list, currency in price_list_currency_map.items():
if not currency:
webnotes.throw("%s: %s" % (_("Currency is missing for Price List"), price_list))
expected_to_exist = [currency + "-" + company_currency
for currency in price_list_currency_map.values()
if currency != company_currency]
if expected_to_exist:
exists = webnotes.conn.sql_list("""select name from `tabCurrency Exchange`
where name in (%s)""" % (", ".join(["%s"]*len(expected_to_exist)),),
tuple(expected_to_exist))
missing = list(set(expected_to_exist).difference(exists))
if missing:
msgprint(_("Missing Currency Exchange Rates for" + ": " + comma_and(missing)),
raise_exception=ShoppingCartSetupError)
def get_name_from_territory(self, territory, parentfield, fieldname):
name = None
territory_name_map = self.get_territory_name_map(parentfield, fieldname)
if territory_name_map.get(territory):
name = territory_name_map.get(territory)
else:
territory_ancestry = self.get_territory_ancestry(territory)
for ancestor in territory_ancestry:
if territory_name_map.get(ancestor):
name = territory_name_map.get(ancestor)
break
return name
def get_price_list(self, billing_territory):
price_list = self.get_name_from_territory(billing_territory, "price_lists", "selling_price_list")
return price_list and price_list[0] or None
def get_tax_master(self, billing_territory):
tax_master = self.get_name_from_territory(billing_territory, "sales_taxes_and_charges_masters",
"sales_taxes_and_charges_master")
return tax_master and tax_master[0] or None
def get_shipping_rules(self, shipping_territory):
return self.get_name_from_territory(shipping_territory, "shipping_rules", "shipping_rule")
def get_territory_ancestry(self, territory):
from erpnext.setup.utils import get_ancestors_of
if not hasattr(self, "_territory_ancestry"):
self._territory_ancestry = {}
if not self._territory_ancestry.get(territory):
self._territory_ancestry[territory] = get_ancestors_of("Territory", territory)
return self._territory_ancestry[territory]

View File

@ -1,129 +0,0 @@
[
{
"creation": "2013-06-19 15:57:32",
"docstatus": 0,
"modified": "2013-12-20 19:21:47",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"description": "Default settings for Shopping Cart",
"doctype": "DocType",
"icon": "icon-shopping-cart",
"issingle": 1,
"module": "Selling",
"name": "__common__"
},
{
"doctype": "DocField",
"name": "__common__",
"parent": "Shopping Cart Settings",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0
},
{
"create": 1,
"doctype": "DocPerm",
"email": 1,
"name": "__common__",
"parent": "Shopping Cart Settings",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"print": 1,
"read": 1,
"role": "Website Manager",
"write": 1
},
{
"doctype": "DocType",
"name": "Shopping Cart Settings"
},
{
"doctype": "DocField",
"fieldname": "enabled",
"fieldtype": "Check",
"label": "Enable Shopping Cart"
},
{
"doctype": "DocField",
"fieldname": "section_break_2",
"fieldtype": "Section Break"
},
{
"doctype": "DocField",
"fieldname": "company",
"fieldtype": "Link",
"label": "Company",
"options": "Company",
"reqd": 1
},
{
"description": "<a href=\"#Sales Browser/Territory\">Add / Edit</a>",
"doctype": "DocField",
"fieldname": "default_territory",
"fieldtype": "Link",
"label": "Default Territory",
"options": "Territory",
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "column_break_4",
"fieldtype": "Column Break"
},
{
"description": "<a href=\"#Sales Browser/Customer Group\">Add / Edit</a>",
"doctype": "DocField",
"fieldname": "default_customer_group",
"fieldtype": "Link",
"label": "Default Customer Group",
"options": "Customer Group",
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "quotation_series",
"fieldtype": "Select",
"label": "Quotation Series",
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "section_break_6",
"fieldtype": "Section Break"
},
{
"doctype": "DocField",
"fieldname": "price_lists",
"fieldtype": "Table",
"label": "Shopping Cart Price Lists",
"options": "Shopping Cart Price List",
"reqd": 0
},
{
"doctype": "DocField",
"fieldname": "shipping_rules",
"fieldtype": "Table",
"label": "Shopping Cart Shipping Rules",
"options": "Shopping Cart Shipping Rule",
"reqd": 0
},
{
"doctype": "DocField",
"fieldname": "column_break_10",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "sales_taxes_and_charges_masters",
"fieldtype": "Table",
"label": "Shopping Cart Taxes and Charges Masters",
"options": "Shopping Cart Taxes and Charges Master",
"reqd": 0
},
{
"doctype": "DocPerm"
}
]

View File

@ -1,81 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
# For license information, please see license.txt
from __future__ import unicode_literals
import webnotes
import unittest
from erpnext.selling.doctype.shopping_cart_settings.shopping_cart_settings import ShoppingCartSetupError
class TestShoppingCartSettings(unittest.TestCase):
def setUp(self):
webnotes.conn.sql("""delete from `tabSingles` where doctype="Shipping Cart Settings" """)
webnotes.conn.sql("""delete from `tabShopping Cart Price List`""")
webnotes.conn.sql("""delete from `tabShopping Cart Taxes and Charges Master`""")
webnotes.conn.sql("""delete from `tabShopping Cart Shipping Rule`""")
def get_cart_settings(self):
return webnotes.bean({"doctype": "Shopping Cart Settings",
"company": "_Test Company"})
def test_price_list_territory_overlap(self):
cart_settings = self.get_cart_settings()
def _add_price_list(price_list):
cart_settings.doclist.append({
"doctype": "Shopping Cart Price List",
"parentfield": "price_lists",
"selling_price_list": price_list
})
for price_list in ("_Test Price List Rest of the World", "_Test Price List India",
"_Test Price List"):
_add_price_list(price_list)
controller = cart_settings.make_controller()
controller.validate_overlapping_territories("price_lists", "selling_price_list")
_add_price_list("_Test Price List 2")
controller = cart_settings.make_controller()
self.assertRaises(ShoppingCartSetupError, controller.validate_overlapping_territories,
"price_lists", "selling_price_list")
return cart_settings
def test_taxes_territory_overlap(self):
cart_settings = self.get_cart_settings()
def _add_tax_master(tax_master):
cart_settings.doclist.append({
"doctype": "Shopping Cart Taxes and Charges Master",
"parentfield": "sales_taxes_and_charges_masters",
"sales_taxes_and_charges_master": tax_master
})
for tax_master in ("_Test Sales Taxes and Charges Master", "_Test India Tax Master"):
_add_tax_master(tax_master)
controller = cart_settings.make_controller()
controller.validate_overlapping_territories("sales_taxes_and_charges_masters",
"sales_taxes_and_charges_master")
_add_tax_master("_Test Sales Taxes and Charges Master 2")
controller = cart_settings.make_controller()
self.assertRaises(ShoppingCartSetupError, controller.validate_overlapping_territories,
"sales_taxes_and_charges_masters", "sales_taxes_and_charges_master")
def test_exchange_rate_exists(self):
webnotes.conn.sql("""delete from `tabCurrency Exchange`""")
cart_settings = self.test_price_list_territory_overlap()
controller = cart_settings.make_controller()
self.assertRaises(ShoppingCartSetupError, controller.validate_exchange_rates_exist)
from erpnext.setup.doctype.currency_exchange.test_currency_exchange import test_records as \
currency_exchange_records
webnotes.bean(currency_exchange_records[0]).insert()
controller.validate_exchange_rates_exist()

View File

@ -1,11 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
# For license information, please see license.txt
from __future__ import unicode_literals
import webnotes
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl

View File

@ -1,36 +0,0 @@
[
{
"creation": "2013-07-03 13:15:34",
"docstatus": 0,
"modified": "2013-12-20 19:21:47",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "DocType",
"istable": 1,
"module": "Selling",
"name": "__common__"
},
{
"doctype": "DocField",
"fieldname": "shipping_rule",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Shipping Rule",
"name": "__common__",
"options": "Shipping Rule",
"parent": "Shopping Cart Shipping Rule",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0,
"reqd": 1
},
{
"doctype": "DocType",
"name": "Shopping Cart Shipping Rule"
},
{
"doctype": "DocField"
}
]

View File

@ -1,11 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
# For license information, please see license.txt
from __future__ import unicode_literals
import webnotes
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl

View File

@ -1,36 +0,0 @@
[
{
"creation": "2013-06-20 16:57:03",
"docstatus": 0,
"modified": "2013-12-20 19:21:47",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "DocType",
"istable": 1,
"module": "Selling",
"name": "__common__"
},
{
"doctype": "DocField",
"fieldname": "sales_taxes_and_charges_master",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Tax Master",
"name": "__common__",
"options": "Sales Taxes and Charges Master",
"parent": "Shopping Cart Taxes and Charges Master",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0,
"reqd": 1
},
{
"doctype": "DocType",
"name": "Shopping Cart Taxes and Charges Master"
},
{
"doctype": "DocField"
}
]

View File

@ -65,12 +65,6 @@ wn.module_page["Selling"] = [
"doctype":"Selling Settings",
"description": wn._("Settings for Selling Module")
},
{
"route":"Form/Shopping Cart Settings",
"label":wn._("Shopping Cart Settings"),
"description":wn._("Setup of Shopping Cart."),
doctype:"Shopping Cart Settings"
},
{
label: wn._("Sales Taxes and Charges Master"),
description: wn._("Sales taxes template."),

View File

@ -207,4 +207,4 @@ def apply_pos_settings(pos_settings, opts):
if out.get("warehouse"):
out["actual_qty"] = get_available_qty(opts.item_code, out.get("warehouse")).get("actual_qty")
return out
return out

View File

@ -1,462 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes, json
from webnotes import msgprint, _
import webnotes.defaults
from webnotes.utils import flt, get_fullname, fmt_money, cstr
class WebsitePriceListMissingError(webnotes.ValidationError): pass
def set_cart_count(quotation=None):
if not quotation:
quotation = _get_cart_quotation()
cart_count = cstr(len(quotation.doclist.get({"parentfield": "quotation_details"})))
webnotes._response.set_cookie("cart_count", cart_count)
@webnotes.whitelist()
def get_cart_quotation(doclist=None):
party = get_lead_or_customer()
if not doclist:
quotation = _get_cart_quotation(party)
doclist = quotation.doclist
set_cart_count(quotation)
return {
"doclist": decorate_quotation_doclist(doclist),
"addresses": [{"name": address.name, "display": address.display}
for address in get_address_docs(party)],
"shipping_rules": get_applicable_shipping_rules(party)
}
@webnotes.whitelist()
def place_order():
quotation = _get_cart_quotation()
controller = quotation.make_controller()
for fieldname in ["customer_address", "shipping_address_name"]:
if not quotation.doc.fields.get(fieldname):
msgprint(_("Please select a") + " " + _(controller.meta.get_label(fieldname)), raise_exception=True)
quotation.ignore_permissions = True
quotation.submit()
from erpnext.selling.doctype.quotation.quotation import _make_sales_order
sales_order = webnotes.bean(_make_sales_order(quotation.doc.name, ignore_permissions=True))
sales_order.ignore_permissions = True
sales_order.insert()
sales_order.submit()
webnotes._response.set_cookie("cart_count", "")
return sales_order.doc.name
@webnotes.whitelist()
def update_cart(item_code, qty, with_doclist=0):
quotation = _get_cart_quotation()
qty = flt(qty)
if qty == 0:
quotation.set_doclist(quotation.doclist.get({"item_code": ["!=", item_code]}))
if not quotation.doclist.get({"parentfield": "quotation_details"}) and \
not quotation.doc.fields.get("__islocal"):
quotation.__delete = True
else:
quotation_items = quotation.doclist.get({"item_code": item_code})
if not quotation_items:
quotation.doclist.append({
"doctype": "Quotation Item",
"parentfield": "quotation_details",
"item_code": item_code,
"qty": qty
})
else:
quotation_items[0].qty = qty
apply_cart_settings(quotation=quotation)
if hasattr(quotation, "__delete"):
webnotes.delete_doc("Quotation", quotation.doc.name, ignore_permissions=True)
quotation = _get_cart_quotation()
else:
quotation.ignore_permissions = True
quotation.save()
set_cart_count(quotation)
if with_doclist:
return get_cart_quotation(quotation.doclist)
else:
return quotation.doc.name
@webnotes.whitelist()
def update_cart_address(address_fieldname, address_name):
from erpnext.utilities.transaction_base import get_address_display
quotation = _get_cart_quotation()
address_display = get_address_display(webnotes.doc("Address", address_name).fields)
if address_fieldname == "shipping_address_name":
quotation.doc.shipping_address_name = address_name
quotation.doc.shipping_address = address_display
if not quotation.doc.customer_address:
address_fieldname == "customer_address"
if address_fieldname == "customer_address":
quotation.doc.customer_address = address_name
quotation.doc.address_display = address_display
apply_cart_settings(quotation=quotation)
quotation.ignore_permissions = True
quotation.save()
return get_cart_quotation(quotation.doclist)
@webnotes.whitelist()
def get_addresses():
return [d.fields for d in get_address_docs()]
@webnotes.whitelist()
def save_address(fields, address_fieldname=None):
party = get_lead_or_customer()
fields = json.loads(fields)
if fields.get("name"):
bean = webnotes.bean("Address", fields.get("name"))
else:
bean = webnotes.bean({"doctype": "Address", "__islocal": 1})
bean.doc.fields.update(fields)
party_fieldname = party.doctype.lower()
bean.doc.fields.update({
party_fieldname: party.name,
(party_fieldname + "_name"): party.fields[party_fieldname + "_name"]
})
bean.ignore_permissions = True
bean.save()
if address_fieldname:
update_cart_address(address_fieldname, bean.doc.name)
return bean.doc.name
def get_address_docs(party=None):
from webnotes.model.doclist import objectify
from erpnext.utilities.transaction_base import get_address_display
if not party:
party = get_lead_or_customer()
address_docs = objectify(webnotes.conn.sql("""select * from `tabAddress`
where `%s`=%s order by name""" % (party.doctype.lower(), "%s"), party.name,
as_dict=True, update={"doctype": "Address"}))
for address in address_docs:
address.display = get_address_display(address.fields)
address.display = (address.display).replace("\n", "<br>\n")
return address_docs
def get_lead_or_customer():
customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, "customer")
if customer:
return webnotes.doc("Customer", customer)
lead = webnotes.conn.get_value("Lead", {"email_id": webnotes.session.user})
if lead:
return webnotes.doc("Lead", lead)
else:
lead_bean = webnotes.bean({
"doctype": "Lead",
"email_id": webnotes.session.user,
"lead_name": get_fullname(webnotes.session.user),
"territory": guess_territory(),
"status": "Open" # TODO: set something better???
})
if webnotes.session.user != "Guest":
lead_bean.ignore_permissions = True
lead_bean.insert()
return lead_bean.doc
def guess_territory():
territory = None
geoip_country = webnotes.session.get("session_country")
if geoip_country:
territory = webnotes.conn.get_value("Territory", geoip_country)
return territory or \
webnotes.conn.get_value("Shopping Cart Settings", None, "territory") or \
"All Territories"
def decorate_quotation_doclist(doclist):
for d in doclist:
if d.item_code:
d.fields.update(webnotes.conn.get_value("Item", d.item_code,
["website_image", "description", "page_name"], as_dict=True))
d.formatted_rate = fmt_money(d.export_rate, currency=doclist[0].currency)
d.formatted_amount = fmt_money(d.export_amount, currency=doclist[0].currency)
elif d.charge_type:
d.formatted_tax_amount = fmt_money(d.tax_amount / doclist[0].conversion_rate,
currency=doclist[0].currency)
doclist[0].formatted_grand_total_export = fmt_money(doclist[0].grand_total_export,
currency=doclist[0].currency)
return [d.fields for d in doclist]
def _get_cart_quotation(party=None):
if not party:
party = get_lead_or_customer()
quotation = webnotes.conn.get_value("Quotation",
{party.doctype.lower(): party.name, "order_type": "Shopping Cart", "docstatus": 0})
if quotation:
qbean = webnotes.bean("Quotation", quotation)
else:
qbean = webnotes.bean({
"doctype": "Quotation",
"naming_series": webnotes.defaults.get_user_default("shopping_cart_quotation_series") or "QTN-CART-",
"quotation_to": party.doctype,
"company": webnotes.defaults.get_user_default("company"),
"order_type": "Shopping Cart",
"status": "Draft",
"docstatus": 0,
"__islocal": 1,
(party.doctype.lower()): party.name
})
if party.doctype == "Customer":
qbean.doc.contact_person = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user,
"customer": party.name})
qbean.run_method("set_contact_fields")
qbean.run_method("onload_post_render")
apply_cart_settings(party, qbean)
return qbean
def update_party(fullname, company_name=None, mobile_no=None, phone=None):
party = get_lead_or_customer()
if party.doctype == "Lead":
party.company_name = company_name
party.lead_name = fullname
party.mobile_no = mobile_no
party.phone = phone
else:
party.customer_name = company_name or fullname
party.customer_type == "Company" if company_name else "Individual"
contact_name = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user,
"customer": party.name})
contact = webnotes.bean("Contact", contact_name)
contact.doc.first_name = fullname
contact.doc.last_name = None
contact.doc.customer_name = party.customer_name
contact.doc.mobile_no = mobile_no
contact.doc.phone = phone
contact.ignore_permissions = True
contact.save()
party_bean = webnotes.bean(party.fields)
party_bean.ignore_permissions = True
party_bean.save()
qbean = _get_cart_quotation(party)
if not qbean.doc.fields.get("__islocal"):
qbean.doc.customer_name = company_name or fullname
qbean.run_method("set_contact_fields")
qbean.ignore_permissions = True
qbean.save()
def apply_cart_settings(party=None, quotation=None):
if not party:
party = get_lead_or_customer()
if not quotation:
quotation = _get_cart_quotation(party)
cart_settings = webnotes.get_obj("Shopping Cart Settings")
billing_territory = get_address_territory(quotation.doc.customer_address) or \
party.territory or "All Territories"
set_price_list_and_rate(quotation, cart_settings, billing_territory)
quotation.run_method("calculate_taxes_and_totals")
set_taxes(quotation, cart_settings, billing_territory)
_apply_shipping_rule(party, quotation, cart_settings)
def set_price_list_and_rate(quotation, cart_settings, billing_territory):
"""set price list based on billing territory"""
quotation.doc.selling_price_list = cart_settings.get_price_list(billing_territory)
# reset values
quotation.doc.price_list_currency = quotation.doc.currency = \
quotation.doc.plc_conversion_rate = quotation.doc.conversion_rate = None
for item in quotation.doclist.get({"parentfield": "quotation_details"}):
item.ref_rate = item.adj_rate = item.export_rate = item.export_amount = None
# refetch values
quotation.run_method("set_price_list_and_item_details")
# set it in cookies for using in product page
webnotes.local._response.set_cookie("selling_price_list", quotation.doc.selling_price_list)
def set_taxes(quotation, cart_settings, billing_territory):
"""set taxes based on billing territory"""
quotation.doc.charge = cart_settings.get_tax_master(billing_territory)
# clear table
quotation.set_doclist(quotation.doclist.get({"parentfield": ["!=", "other_charges"]}))
# append taxes
controller = quotation.make_controller()
controller.append_taxes_from_master("other_charges", "charge")
quotation.set_doclist(controller.doclist)
@webnotes.whitelist()
def apply_shipping_rule(shipping_rule):
quotation = _get_cart_quotation()
quotation.doc.shipping_rule = shipping_rule
apply_cart_settings(quotation=quotation)
quotation.ignore_permissions = True
quotation.save()
return get_cart_quotation(quotation.doclist)
def _apply_shipping_rule(party=None, quotation=None, cart_settings=None):
shipping_rules = get_shipping_rules(party, quotation, cart_settings)
if not shipping_rules:
return
elif quotation.doc.shipping_rule not in shipping_rules:
quotation.doc.shipping_rule = shipping_rules[0]
quotation.run_method("apply_shipping_rule")
quotation.run_method("calculate_taxes_and_totals")
def get_applicable_shipping_rules(party=None, quotation=None):
shipping_rules = get_shipping_rules(party, quotation)
if shipping_rules:
rule_label_map = webnotes.conn.get_values("Shipping Rule", shipping_rules, "label")
# we need this in sorted order as per the position of the rule in the settings page
return [[rule, rule_label_map.get(rule)] for rule in shipping_rules]
def get_shipping_rules(party=None, quotation=None, cart_settings=None):
if not party:
party = get_lead_or_customer()
if not quotation:
quotation = _get_cart_quotation()
if not cart_settings:
cart_settings = webnotes.get_obj("Shopping Cart Settings")
# set shipping rule based on shipping territory
shipping_territory = get_address_territory(quotation.doc.shipping_address_name) or \
party.territory
shipping_rules = cart_settings.get_shipping_rules(shipping_territory)
return shipping_rules
def get_address_territory(address_name):
"""Tries to match city, state and country of address to existing territory"""
territory = None
if address_name:
address_fields = webnotes.conn.get_value("Address", address_name,
["city", "state", "country"])
for value in address_fields:
territory = webnotes.conn.get_value("Territory", value)
if territory:
break
return territory
import unittest
test_dependencies = ["Item", "Price List", "Contact", "Shopping Cart Settings"]
class TestCart(unittest.TestCase):
def tearDown(self):
return
cart_settings = webnotes.bean("Shopping Cart Settings")
cart_settings.ignore_permissions = True
cart_settings.doc.enabled = 0
cart_settings.save()
def enable_shopping_cart(self):
return
if not webnotes.conn.get_value("Shopping Cart Settings", None, "enabled"):
cart_settings = webnotes.bean("Shopping Cart Settings")
cart_settings.ignore_permissions = True
cart_settings.doc.enabled = 1
cart_settings.save()
def test_get_lead_or_customer(self):
webnotes.session.user = "test@example.com"
party1 = get_lead_or_customer()
party2 = get_lead_or_customer()
self.assertEquals(party1.name, party2.name)
self.assertEquals(party1.doctype, "Lead")
webnotes.session.user = "test_contact_customer@example.com"
party = get_lead_or_customer()
self.assertEquals(party.name, "_Test Customer")
def test_add_to_cart(self):
self.enable_shopping_cart()
webnotes.session.user = "test@example.com"
update_cart("_Test Item", 1)
quotation = _get_cart_quotation()
quotation_items = quotation.doclist.get({"parentfield": "quotation_details", "item_code": "_Test Item"})
self.assertTrue(quotation_items)
self.assertEquals(quotation_items[0].qty, 1)
return quotation
def test_update_cart(self):
self.test_add_to_cart()
update_cart("_Test Item", 5)
quotation = _get_cart_quotation()
quotation_items = quotation.doclist.get({"parentfield": "quotation_details", "item_code": "_Test Item"})
self.assertTrue(quotation_items)
self.assertEquals(quotation_items[0].qty, 5)
return quotation
def test_remove_from_cart(self):
quotation0 = self.test_add_to_cart()
update_cart("_Test Item", 0)
quotation = _get_cart_quotation()
self.assertEquals(quotation0.doc.name, quotation.doc.name)
quotation_items = quotation.doclist.get({"parentfield": "quotation_details", "item_code": "_Test Item"})
self.assertEquals(quotation_items, [])
def test_place_order(self):
quotation = self.test_update_cart()
sales_order_name = place_order()
sales_order = webnotes.bean("Sales Order", sales_order_name)
self.assertEquals(sales_order.doclist.getone({"item_code": "_Test Item"}).prevdoc_docname, quotation.doc.name)

View File

@ -1,128 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, cint, fmt_money
from webnotes.webutils import delete_page_cache
from erpnext.selling.utils.cart import _get_cart_quotation
@webnotes.whitelist(allow_guest=True)
def get_product_info(item_code):
"""get product price / stock info"""
if not cint(webnotes.conn.get_default("shopping_cart_enabled")):
return {}
cart_quotation = _get_cart_quotation()
price_list = webnotes.local.request.cookies.get("selling_price_list")
warehouse = webnotes.conn.get_value("Item", item_code, "website_warehouse")
if warehouse:
in_stock = webnotes.conn.sql("""select actual_qty from tabBin where
item_code=%s and warehouse=%s""", (item_code, warehouse))
if in_stock:
in_stock = in_stock[0][0] > 0 and 1 or 0
else:
in_stock = -1
price = price_list and webnotes.conn.sql("""select ref_rate, currency from
`tabItem Price` where item_code=%s and price_list=%s""",
(item_code, price_list), as_dict=1) or []
price = price and price[0] or None
qty = 0
if price:
price["formatted_price"] = fmt_money(price["ref_rate"], currency=price["currency"])
price["currency"] = not cint(webnotes.conn.get_default("hide_currency_symbol")) \
and (webnotes.conn.get_value("Currency", price.currency, "symbol") or price.currency) \
or ""
if webnotes.session.user != "Guest":
item = cart_quotation.doclist.get({"item_code": item_code})
if item:
qty = item[0].qty
return {
"price": price,
"stock": in_stock,
"uom": webnotes.conn.get_value("Item", item_code, "stock_uom"),
"qty": qty
}
@webnotes.whitelist(allow_guest=True)
def get_product_list(search=None, start=0, limit=10):
# base query
query = """select name, item_name, page_name, website_image, item_group,
web_long_description as website_description
from `tabItem` where docstatus = 0 and show_in_website = 1 """
# search term condition
if search:
query += """and (web_long_description like %(search)s or
item_name like %(search)s or name like %(search)s)"""
search = "%" + cstr(search) + "%"
# order by
query += """order by weightage desc, modified desc limit %s, %s""" % (start, limit)
data = webnotes.conn.sql(query, {
"search": search,
}, as_dict=1)
return [get_item_for_list_in_html(r) for r in data]
def get_product_list_for_group(product_group=None, start=0, limit=10):
child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(product_group)])
# base query
query = """select name, item_name, page_name, website_image, item_group,
web_long_description as website_description
from `tabItem` where docstatus = 0 and show_in_website = 1
and (item_group in (%s)
or name in (select parent from `tabWebsite Item Group` where item_group in (%s))) """ % (child_groups, child_groups)
query += """order by weightage desc, modified desc limit %s, %s""" % (start, limit)
data = webnotes.conn.sql(query, {"product_group": product_group}, as_dict=1)
return [get_item_for_list_in_html(r) for r in data]
def get_child_groups(item_group_name):
item_group = webnotes.doc("Item Group", item_group_name)
return webnotes.conn.sql("""select name
from `tabItem Group` where lft>=%(lft)s and rgt<=%(rgt)s
and show_in_website = 1""", item_group.fields)
def get_group_item_count(item_group):
child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(item_group)])
return webnotes.conn.sql("""select count(*) from `tabItem`
where docstatus = 0 and show_in_website = 1
and (item_group in (%s)
or name in (select parent from `tabWebsite Item Group`
where item_group in (%s))) """ % (child_groups, child_groups))[0][0]
def get_item_for_list_in_html(context):
return webnotes.get_template("templates/includes/product_in_grid.html").render(context)
def scrub_item_for_list(r):
if not r.website_description:
r.website_description = "No description given"
if len(r.website_description.split(" ")) > 24:
r.website_description = " ".join(r.website_description.split(" ")[:24]) + "..."
def get_parent_item_groups(item_group_name):
item_group = webnotes.doc("Item Group", item_group_name)
return webnotes.conn.sql("""select name, page_name from `tabItem Group`
where lft <= %s and rgt >= %s
and ifnull(show_in_website,0)=1
order by lft asc""", (item_group.lft, item_group.rgt), as_dict=True)
def invalidate_cache_for(item_group):
for i in get_parent_item_groups(item_group):
if i.page_name:
delete_page_cache(i.page_name)

View File

@ -69,10 +69,10 @@ cur_frm.cscript.transaction = function(doc,cdt,cdn){
cur_frm.fields_dict.system_user.get_query = function(doc,cdt,cdn) {
return{ query:"core.doctype.profile.profile.profile_query" } }
return{ query:"webnotes.core.doctype.profile.profile.profile_query" } }
cur_frm.fields_dict.approving_user.get_query = function(doc,cdt,cdn) {
return{ query:"core.doctype.profile.profile.profile_query" } }
return{ query:"webnotes.core.doctype.profile.profile.profile_query" } }
cur_frm.fields_dict['approving_role'].get_query = cur_frm.fields_dict['system_role'].get_query;

View File

@ -6,6 +6,7 @@ import webnotes
from webnotes.utils.nestedset import DocTypeNestedSet
from webnotes.webutils import WebsiteGenerator
from webnotes.webutils import delete_page_cache
class DocType(DocTypeNestedSet, WebsiteGenerator):
def __init__(self, doc, doclist=[]):
@ -19,7 +20,6 @@ class DocType(DocTypeNestedSet, WebsiteGenerator):
self.validate_name_with_item()
from erpnext.selling.utils.product import invalidate_cache_for
invalidate_cache_for(self.doc.name)
self.validate_one_root()
@ -29,22 +29,22 @@ class DocType(DocTypeNestedSet, WebsiteGenerator):
webnotes.msgprint("An item exists with same name (%s), please change the \
item group name or rename the item" % self.doc.name, raise_exception=1)
def get_context(self):
from erpnext.selling.utils.product import get_product_list_for_group, \
get_parent_item_groups, get_group_item_count
def get_group_item_count(item_group):
child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(item_group)])
return webnotes.conn.sql("""select count(*) from `tabItem`
where docstatus = 0 and show_in_website = 1
and (item_group in (%s)
or name in (select parent from `tabWebsite Item Group`
where item_group in (%s))) """ % (child_groups, child_groups))[0][0]
self.doc.sub_groups = webnotes.conn.sql("""select name, page_name
from `tabItem Group` where parent_item_group=%s
and ifnull(show_in_website,0)=1""", self.doc.name, as_dict=1)
for d in self.doc.sub_groups:
d.count = get_group_item_count(d.name)
self.doc.items = get_product_list_for_group(product_group = self.doc.name, limit=100)
self.parent_groups = get_parent_item_groups(self.doc.name)
self.doc.title = self.doc.name
if self.doc.slideshow:
from webnotes.website.doctype.website_slideshow.website_slideshow import get_slideshow
get_slideshow(self)
def get_parent_item_groups(item_group_name):
item_group = webnotes.doc("Item Group", item_group_name)
return webnotes.conn.sql("""select name, page_name from `tabItem Group`
where lft <= %s and rgt >= %s
and ifnull(show_in_website,0)=1
order by lft asc""", (item_group.lft, item_group.rgt), as_dict=True)
def invalidate_cache_for(item_group):
for i in get_parent_item_groups(item_group):
if i.page_name:
delete_page_cache(i.page_name)

View File

@ -26,18 +26,3 @@ class DocType(WebsiteGenerator):
return contact_details
else:
return ''
def get_context(self):
address = webnotes.conn.get_value("Address",
{"sales_partner": self.doc.name, "is_primary_address": 1},
"*", as_dict=True)
if address:
city_state = ", ".join(filter(None, [address.city, address.state]))
address_rows = [address.address_line1, address.address_line2,
city_state, address.pincode, address.country]
self.doc.fields.update({
"email": address.email_id,
"partner_address": filter_strip_join(address_rows, "\n<br>"),
"phone": filter_strip_join(cstr(address.phone).split(","), "\n<br>")
})

View File

@ -1,26 +0,0 @@
{% extends base_template %}
{% block content %}
<div class="container content" itemscope itemtype="http://schema.org/Organization">
<div class="row">
<div class="col-md-4">
{% if logo -%}
<img itemprop="brand" src="{{ logo }}" class="partner-logo"
alt="{{ partner_name }}" title="{{ partner_name }}" />
<br><br>
{%- endif %}
<address>
{% if partner_website -%}<p><a href="{{ partner_website }}"
target="_blank">{{ partner_website }}</a></p>{%- endif %}
{% if partner_address -%}<p itemprop="address">{{ partner_address }}</p>{%- endif %}
{% if phone -%}<p itemprop="telephone">{{ phone }}</p>{%- endif %}
{% if email -%}<p itemprop="email"><span class="icon-envelope"></span> {{ email }}</p>{%- endif %}
</address>
</div>
<div class="col-md-8">
<h3 itemprop="name" style="margin-top: 0px;">{{ partner_name }}</h3>
<p>{{ description }}</p>
</div>
</div>
</div>
{% endblock %}

View File

@ -1,2 +0,0 @@
doctype = "Sales Partner"
condition_field = "show_in_website"

View File

@ -1,30 +0,0 @@
{% extends base_template %}
{% set title="Partners" %}
{% block content %}
<div class="container content">
<h2 id="blog-title">{{ title }}</h2>
<hr>
{% for partner_info in partners %}
<div class="row">
<div class="col-md-3">
{% if partner_info.logo -%}
<a href="{{ partner_info.page_name }}">
<img itemprop="brand" src="{{ partner_info.logo }}" class="partner-logo"
alt="{{ partner_info.partner_name }}" title="{{ partner_info.partner_name }}" />
</a>
{%- endif %}
</div>
<div class="col-md-9">
<a href="{{ partner_info.page_name }}">
<h4>{{ partner_info.partner_name }}</h4>
</a>
<p style="color: #999">{{ partner_info.territory }} - {{ partner_info.partner_type }}</p>
<p>{{ partner_info.introduction }}</p>
</div>
</div>
<hr>
{% endfor %}
</div>
{% endblock %}

View File

@ -1,7 +0,0 @@
import webnotes
def get_context():
return {
"partners": webnotes.conn.sql("""select * from `tabSales Partner`
where show_in_website=1 order by name asc""", as_dict=True),
}

View File

@ -29,13 +29,6 @@ def on_session_creation(login_manager):
login_manager.user=='Administrator' and '#8CA2B3' or '#1B750D')
webnotes.conn.commit()
if webnotes.conn.get_value("Profile", webnotes.session.user, "user_type") == "Website User":
from erpnext.selling.utils.cart import set_cart_count
set_cart_count()
def on_logout(login_manager):
webnotes._response.set_cookie("cart_count", "")
def check_if_expired():
"""check if account is expired. If expired, do not allow login"""
from webnotes import conf

View File

@ -1,29 +1,10 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint
def update_website_context(context):
post_login = []
cart_enabled = cint(webnotes.conn.get_default("shopping_cart_enabled"))
if cart_enabled:
post_login += [{"label": "Cart", "url": "cart", "icon": "icon-shopping-cart", "class": "cart-count"},
{"class": "divider"}]
post_login += [
{"label": "Profile", "url": "profile", "icon": "icon-user"},
{"label": "Addresses", "url": "addresses", "icon": "icon-map-marker"},
{"label": "My Orders", "url": "orders", "icon": "icon-list"},
{"label": "My Tickets", "url": "tickets", "icon": "icon-tags"},
{"label": "Invoices", "url": "invoices", "icon": "icon-file-text"},
{"label": "Shipments", "url": "shipments", "icon": "icon-truck"},
{"class": "divider"}
]
context.update({
"shopping_cart_enabled": cart_enabled,
"post_login": post_login + context.get("post_login", [])
})
if not context.get("favicon"):
context["favicon"] = "app/images/favicon.ico"

View File

@ -2,7 +2,7 @@
{
"creation": "2013-04-22 13:15:44",
"docstatus": 0,
"modified": "2013-12-20 19:23:08",
"modified": "2013-12-31 18:23:03",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -50,16 +50,6 @@
"search_index": 1,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "customer_item_code",
"fieldtype": "Data",
"hidden": 1,
"in_list_view": 0,
"label": "Customer's Item Code",
"print_hide": 1,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "item_name",
@ -74,6 +64,21 @@
"reqd": 1,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "col_break1",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "customer_item_code",
"fieldtype": "Data",
"hidden": 1,
"in_list_view": 0,
"label": "Customer's Item Code",
"print_hide": 1,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "description",
@ -107,21 +112,6 @@
"reqd": 1,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "stock_uom",
"fieldtype": "Link",
"in_list_view": 0,
"label": "UOM",
"oldfieldname": "stock_uom",
"oldfieldtype": "Data",
"options": "UOM",
"print_hide": 0,
"print_width": "50px",
"read_only": 1,
"reqd": 1,
"width": "50px"
},
{
"doctype": "DocField",
"fieldname": "ref_rate",
@ -151,6 +141,45 @@
"read_only": 0,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "col_break2",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "stock_uom",
"fieldtype": "Link",
"in_list_view": 0,
"label": "UOM",
"oldfieldname": "stock_uom",
"oldfieldtype": "Data",
"options": "UOM",
"print_hide": 0,
"print_width": "50px",
"read_only": 1,
"reqd": 1,
"width": "50px"
},
{
"doctype": "DocField",
"fieldname": "base_ref_rate",
"fieldtype": "Currency",
"in_list_view": 0,
"label": "Price List Rate (Company Currency)",
"oldfieldname": "base_ref_rate",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
"print_width": "100px",
"read_only": 1,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "section_break_1",
"fieldtype": "Section Break"
},
{
"doctype": "DocField",
"fieldname": "export_rate",
@ -183,17 +212,8 @@
},
{
"doctype": "DocField",
"fieldname": "base_ref_rate",
"fieldtype": "Currency",
"in_list_view": 0,
"label": "Price List Rate (Company Currency)",
"oldfieldname": "base_ref_rate",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
"print_width": "100px",
"read_only": 1,
"width": "100px"
"fieldname": "col_break3",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
@ -271,31 +291,6 @@
"print_hide": 1,
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "expense_account",
"fieldtype": "Link",
"hidden": 0,
"label": "Expense Account",
"no_copy": 1,
"options": "Account",
"print_hide": 1,
"read_only": 0,
"width": "120px"
},
{
"default": ":Company",
"doctype": "DocField",
"fieldname": "cost_center",
"fieldtype": "Link",
"hidden": 0,
"label": "Cost Center",
"no_copy": 1,
"options": "Cost Center",
"print_hide": 1,
"read_only": 0,
"width": "120px"
},
{
"description": "<a href=\"#Sales Browser/Item Group\">Add / Edit</a>",
"doctype": "DocField",
@ -323,6 +318,22 @@
"read_only": 1,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "item_tax_rate",
"fieldtype": "Small Text",
"hidden": 1,
"label": "Item Tax Rate",
"oldfieldname": "item_tax_rate",
"oldfieldtype": "Small Text",
"print_hide": 1,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "col_break4",
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
"fieldname": "actual_qty",
@ -338,30 +349,44 @@
},
{
"doctype": "DocField",
"fieldname": "installed_qty",
"fieldtype": "Float",
"label": "Installed Qty",
"fieldname": "expense_account",
"fieldtype": "Link",
"hidden": 0,
"label": "Expense Account",
"no_copy": 1,
"oldfieldname": "installed_qty",
"oldfieldtype": "Currency",
"options": "Account",
"print_hide": 1,
"print_width": "150px",
"read_only": 1,
"width": "150px"
"read_only": 0,
"width": "120px"
},
{
"default": ":Company",
"doctype": "DocField",
"fieldname": "cost_center",
"fieldtype": "Link",
"hidden": 0,
"label": "Cost Center",
"no_copy": 1,
"options": "Cost Center",
"print_hide": 1,
"read_only": 0,
"width": "120px"
},
{
"doctype": "DocField",
"fieldname": "against_sales_order",
"fieldtype": "Link",
"label": "Against Sales Order",
"options": "Sales Order"
"options": "Sales Order",
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "against_sales_invoice",
"fieldtype": "Link",
"label": "Against Sales Invoice",
"options": "Sales Invoice"
"options": "Sales Invoice",
"read_only": 1
},
{
"doctype": "DocField",
@ -381,14 +406,16 @@
},
{
"doctype": "DocField",
"fieldname": "item_tax_rate",
"fieldtype": "Small Text",
"hidden": 1,
"label": "Item Tax Rate",
"oldfieldname": "item_tax_rate",
"oldfieldtype": "Small Text",
"fieldname": "installed_qty",
"fieldtype": "Float",
"label": "Installed Qty",
"no_copy": 1,
"oldfieldname": "installed_qty",
"oldfieldtype": "Currency",
"print_hide": 1,
"read_only": 1
"print_width": "150px",
"read_only": 1,
"width": "150px"
},
{
"doctype": "DocField",

View File

@ -198,7 +198,7 @@ class DocType(DocListController, WebsiteGenerator):
self.doc.name, raise_exception=1)
def update_website(self):
from erpnext.selling.utils.product import invalidate_cache_for
from erpnext.setup.doctype.item_group.item_group import invalidate_cache_for
invalidate_cache_for(self.doc.item_group)
[invalidate_cache_for(d.item_group) for d in \
self.doclist.get({"doctype":"Website Item Group"})]
@ -221,15 +221,6 @@ class DocType(DocListController, WebsiteGenerator):
def get_tax_rate(self, tax_type):
return { "tax_rate": webnotes.conn.get_value("Account", tax_type, "tax_rate") }
def get_context(self):
from erpnext.selling.utils.product import get_parent_item_groups
self.parent_groups = get_parent_item_groups(self.doc.item_group) + [{"name":self.doc.name}]
self.doc.title = self.doc.item_name
if self.doc.slideshow:
from webnotes.website.doctype.website_slideshow.website_slideshow import get_slideshow
get_slideshow(self)
def get_file_details(self, arg = ''):
file = webnotes.conn.sql("select file_group, description from tabFile where name = %s", eval(arg)['file_name'], as_dict = 1)

View File

@ -11,7 +11,7 @@ cur_frm.fields_dict['delivery_note'].get_query = function(doc, cdt, cdn) {
cur_frm.fields_dict['item_details'].grid.get_field('item_code').get_query =
function(doc, cdt, cdn) {
return {
query: "stock.doctype.packing_slip.packing_slip.item_details",
query: "erpnext.stock.doctype.packing_slip.packing_slip.item_details",
filters:{ 'delivery_note': doc.delivery_note}
}
}

View File

@ -29,9 +29,6 @@ class DocType(DocListController):
def on_update(self):
self.set_default_if_missing()
self.update_item_price()
cart_settings = webnotes.get_obj("Shopping Cart Settings")
if cint(cart_settings.doc.enabled):
cart_settings.validate_price_lists()
def set_default_if_missing(self):
if self.doc.buying_or_selling=="Selling":

View File

@ -12,7 +12,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
var me = this;
this.frm.fields_dict.delivery_note_no.get_query = function() {
return { query: "stock.doctype.stock_entry.stock_entry.query_sales_return_doc" };
return { query: "erpnext.stock.doctype.stock_entry.stock_entry.query_sales_return_doc" };
};
this.frm.fields_dict.sales_invoice_no.get_query =
@ -28,7 +28,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
if(in_list(["Sales Return", "Purchase Return"], me.frm.doc.purpose) &&
me.get_doctype_docname()) {
return {
query: "stock.doctype.stock_entry.stock_entry.query_return_item",
query: "erpnext.stock.doctype.stock_entry.stock_entry.query_return_item",
filters: {
purpose: me.frm.doc.purpose,
delivery_note_no: me.frm.doc.delivery_note_no,
@ -309,7 +309,7 @@ cur_frm.fields_dict['mtn_details'].grid.get_field('batch_no').get_query = functi
var d = locals[cdt][cdn];
if(d.item_code) {
return{
query: "stock.doctype.stock_entry.stock_entry.get_batch_no",
query: "erpnext.stock.doctype.stock_entry.stock_entry.get_batch_no",
filters:{
'item_code': d.item_code,
's_warehouse': d.s_warehouse,

View File

@ -288,11 +288,12 @@ class DocType(StockController):
if not returnable_qty:
webnotes.throw("{item}: {item_code} {returned}".format(
item=_("Item"), item_code=item.item_code,
returned=_("already returned though some other documents")), StockOverReturnError)
returned=_("already returned though some other documents")),
StockOverReturnError)
elif item.transfer_qty > returnable_qty:
webnotes.throw("{item}: {item_code}, {returned}: {qty}".format(
item=_("Item"), item_code=item.item_code,
returned=_("Max Returnable Qty"), qty=returnable_qty))
returned=_("Max Returnable Qty"), qty=returnable_qty), StockOverReturnError)
def get_already_returned_item_qty(self, ref_fieldname):
return dict(webnotes.conn.sql("""select item_code, sum(transfer_qty) as qty

View File

@ -1,87 +0,0 @@
{% extends base_template %}
{% block javascript %}
<script>
{% include "templates/includes/product_page.js" %}
$(function() {
if(window.logged_in && getCookie("system_user")==="yes") {
wn.has_permission("Item", "{{ name }}", "write", function(r) {
wn.require("assets/webnotes/js/wn/website/editable.js");
wn.make_editable($('[itemprop="description"]'), "Item", "{{ name }}", "web_long_description");
});
}
});
</script>
{% endblock %}
{% block css %}
<style>
{% include "templates/includes/product_page.css" %}
</style>
{% endblock %}
{% block content %}
{% include 'templates/includes/product_search_box.html' %}
{% include 'templates/includes/product_breadcrumbs.html' %}
<div class="container content product-page-content" itemscope itemtype="http://schema.org/Product">
<div class="row">
<div class="col-md-6">
{% if slideshow %}
{% include "templates/includes/slideshow.html" %}
{% else %}
{% if website_image %}
<image itemprop="image" class="item-main-image"
src="{{ website_image }}" />
{% else %}
<div class="img-area">
{% include 'templates/includes/product_missing_image.html' %}
</div>
{% endif %}
{% endif %}
</div>
<div class="col-md-6">
<h3 itemprop="name" style="margin-top: 0px;">{{ item_name }}</h3>
<p class="help">Item Code: <span itemprop="productID">{{ name }}</span></p>
<h4>Product Description</h4>
<div itemprop="description">
{{ web_long_description or description or "[No description given]" }}
</div>
<div style="min-height: 100px; margin: 10px 0;">
<div class="item-price-info" style="display: none;">
<h4 class="item-price" itemprop="price"></h4>
<div class="item-stock" itemprop="availablity"></div>
<div id="item-add-to-cart">
<button class="btn btn-primary">
<i class="icon-shopping-cart"></i> Add to Cart</button>
</div>
<div id="item-update-cart" class="input-group col-md-4" style="display: none;
padding-left: 0px; padding-right: 0px;">
<input class="form-control" type="text">
<div class="input-group-btn">
<button class="btn btn-primary">
<i class="icon-ok"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
{% if obj.doclist.get({"doctype":"Item Website Specification"}) -%}
<div class="row" style="margin-top: 20px">
<div class="col-md-12">
<h4>Specifications</h4>
<table class="table table-bordered" style="width: 100%">
{% for d in obj.doclist.get(
{"doctype":"Item Website Specification"}) -%}
<tr>
<td style="width: 30%;">{{ d.label }}</td>
<td>{{ d.description }}</td>
</tr>
{%- endfor %}
</table>
</div>
</div>
{%- endif %}
</div>
{% endblock %}

View File

@ -1,2 +0,0 @@
doctype = "Item"
condition_field = "show_in_website"

View File

@ -1,52 +0,0 @@
{% extends base_template %}
{% block content %}
{% include 'templates/includes/product_search_box.html' %}
{% include 'templates/includes/product_breadcrumbs.html' %}
<div class="container content">
{% if slideshow %}<!-- slideshow -->
{% include "templates/includes/slideshow.html" %}
{% endif %}
{% if description %}<!-- description -->
<div itemprop="description">{{ description or ""}}</div>
{% else %}
<h3>{{ name }}</h3>
{% endif %}
</div>
<div class="container content">
{% if sub_groups %}
<hr />
<div class="row">
{% for d in sub_groups %}
<div class="col-md-4">
<a href="{{ d.page_name }}">{{ d.name }} ({{ d.count }})</a>
</div>
{% endfor %}
</div>
<hr />
{% endif %}
{% if items %}
<div id="search-list" class="row">
{% for item in items %}
{{ item }}
{% endfor %}
</div>
{% if (items|length)==100 %}
<div class="alert alert-info info">Showing top 100 items.</div>
{% endif %}
{% else %}
<div class="alert alert-warning">No items listed.</div>
{% endif %}
</div>
<script>
$(function() {
if(window.logged_in && getCookie("system_user")==="yes") {
wn.has_permission("Item Group", "{{ name }}", "write", function(r) {
wn.require("assets/webnotes/js/wn/website/editable.js");
wn.make_editable($('[itemprop="description"]'), "Item Group", "{{ name }}", "description");
});
}
});
</script>
{% endblock %}

View File

@ -1,2 +0,0 @@
doctype = "Item Group"
condition_field = "show_in_website"

View File

@ -1,294 +0,0 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
// js inside blog page
$(document).ready(function() {
erpnext.cart.bind_events();
return wn.call({
type: "POST",
method: "erpnext.selling.utils.cart.get_cart_quotation",
callback: function(r) {
$("#cart-container").removeClass("hide");
$(".progress").remove();
if(r.exc) {
if(r.exc.indexOf("WebsitePriceListMissingError")!==-1) {
erpnext.cart.show_error("Oops!", wn._("Price List not configured."));
} else if(r["403"]) {
erpnext.cart.show_error("Hey!", wn._("You need to be logged in to view your cart."));
} else {
erpnext.cart.show_error("Oops!", wn._("Something went wrong."));
}
} else {
erpnext.cart.set_cart_count();
erpnext.cart.render(r.message);
}
}
});
});
// shopping cart
if(!erpnext.cart) erpnext.cart = {};
$.extend(erpnext.cart, {
show_error: function(title, text) {
$("#cart-container").html('<div class="well"><h4>' + title + '</h4> ' + text + '</div>');
},
bind_events: function() {
// bind update button
$(document).on("click", ".item-update-cart button", function() {
var item_code = $(this).attr("data-item-code");
erpnext.cart.update_cart({
item_code: item_code,
qty: $('input[data-item-code="'+item_code+'"]').val(),
with_doclist: 1,
btn: this,
callback: function(r) {
if(!r.exc) {
erpnext.cart.render(r.message);
var $button = $('button[data-item-code="'+item_code+'"]').addClass("btn-success");
setTimeout(function() { $button.removeClass("btn-success"); }, 1000);
}
},
});
});
$("#cart-add-shipping-address").on("click", function() {
window.location.href = "address?address_fieldname=shipping_address_name";
});
$("#cart-add-billing-address").on("click", function() {
window.location.href = "address?address_fieldname=customer_address";
});
$(".btn-place-order").on("click", function() {
erpnext.cart.place_order(this);
});
},
render: function(out) {
var doclist = out.doclist;
var addresses = out.addresses;
var $cart_items = $("#cart-items").empty();
var $cart_taxes = $("#cart-taxes").empty();
var $cart_totals = $("#cart-totals").empty();
var $cart_billing_address = $("#cart-billing-address").empty();
var $cart_shipping_address = $("#cart-shipping-address").empty();
var no_items = $.map(doclist, function(d) { return d.item_code || null;}).length===0;
if(no_items) {
erpnext.cart.show_error("Empty :-(", wn._("Go ahead and add something to your cart."));
$("#cart-addresses").toggle(false);
return;
}
var shipping_rule_added = false;
var taxes_exist = false;
var shipping_rule_labels = $.map(out.shipping_rules || [], function(rule) { return rule[1]; });
$.each(doclist, function(i, doc) {
if(doc.doctype === "Quotation Item") {
erpnext.cart.render_item_row($cart_items, doc);
} else if (doc.doctype === "Sales Taxes and Charges") {
if(out.shipping_rules && out.shipping_rules.length &&
shipping_rule_labels.indexOf(doc.description)!==-1) {
shipping_rule_added = true;
erpnext.cart.render_tax_row($cart_taxes, doc, out.shipping_rules);
} else {
erpnext.cart.render_tax_row($cart_taxes, doc);
}
taxes_exist = true;
}
});
if(out.shipping_rules && out.shipping_rules.length && !shipping_rule_added) {
erpnext.cart.render_tax_row($cart_taxes, {description: "", formatted_tax_amount: ""},
out.shipping_rules);
taxes_exist = true;
}
if(taxes_exist)
$('<hr>').appendTo($cart_taxes);
erpnext.cart.render_tax_row($cart_totals, {
description: "<strong>Total</strong>",
formatted_tax_amount: "<strong>" + doclist[0].formatted_grand_total_export + "</strong>"
});
if(!(addresses && addresses.length)) {
$cart_shipping_address.html('<div class="well">'+wn._("Hey! Go ahead and add an address")+'</div>');
} else {
erpnext.cart.render_address($cart_shipping_address, addresses, doclist[0].shipping_address_name);
erpnext.cart.render_address($cart_billing_address, addresses, doclist[0].customer_address);
}
},
render_item_row: function($cart_items, doc) {
doc.image_html = doc.website_image ?
'<div style="height: 120px; overflow: hidden;"><img src="' + doc.website_image + '" /></div>' :
'{% include "stock/doctype/item/templates/includes/product_missing_image.html" %}';
if(doc.description === doc.item_name) doc.description = "";
$(repl('<div class="row">\
<div class="col-md-9 col-sm-9">\
<div class="row">\
<div class="col-md-3">%(image_html)s</div>\
<div class="col-md-9">\
<h4><a href="%(page_name)s">%(item_name)s</a></h4>\
<p>%(description)s</p>\
</div>\
</div>\
</div>\
<div class="col-md-3 col-sm-3 text-right">\
<div class="input-group item-update-cart">\
<input type="text" placeholder="Qty" value="%(qty)s" \
data-item-code="%(item_code)s" class="text-right form-control">\
<div class="input-group-btn">\
<button class="btn btn-primary" data-item-code="%(item_code)s">\
<i class="icon-ok"></i></button>\
</div>\
</div>\
<p style="margin-top: 10px;">at %(formatted_rate)s</p>\
<small class="text-muted" style="margin-top: 10px;">= %(formatted_amount)s</small>\
</div>\
</div><hr>', doc)).appendTo($cart_items);
},
render_tax_row: function($cart_taxes, doc, shipping_rules) {
var shipping_selector;
if(shipping_rules) {
shipping_selector = '<select class="form-control">' + $.map(shipping_rules, function(rule) {
return '<option value="' + rule[0] + '">' + rule[1] + '</option>' }).join("\n") +
'</select>';
}
var $tax_row = $(repl('<div class="row">\
<div class="col-md-9 col-sm-9">\
<div class="row">\
<div class="col-md-9 col-md-offset-3">' +
(shipping_selector || '<p>%(description)s</p>') +
'</div>\
</div>\
</div>\
<div class="col-md-3 col-sm-3 text-right">\
<p' + (shipping_selector ? ' style="margin-top: 5px;"' : "") + '>%(formatted_tax_amount)s</p>\
</div>\
</div>', doc)).appendTo($cart_taxes);
if(shipping_selector) {
$tax_row.find('select option').each(function(i, opt) {
if($(opt).html() == doc.description) {
$(opt).attr("selected", "selected");
}
});
$tax_row.find('select').on("change", function() {
erpnext.cart.apply_shipping_rule($(this).val(), this);
});
}
},
apply_shipping_rule: function(rule, btn) {
return wn.call({
btn: btn,
type: "POST",
method: "erpnext.selling.utils.cart.apply_shipping_rule",
args: { shipping_rule: rule },
callback: function(r) {
if(!r.exc) {
erpnext.cart.render(r.message);
}
}
});
},
render_address: function($address_wrapper, addresses, address_name) {
$.each(addresses, function(i, address) {
$(repl('<div class="panel panel-default"> \
<div class="panel-heading"> \
<div class="row"> \
<div class="col-md-10 address-title" \
data-address-name="%(name)s"><strong>%(name)s</strong></div> \
<div class="col-md-2"><input type="checkbox" \
data-address-name="%(name)s"></div> \
</div> \
</div> \
<div class="panel-collapse collapse" data-address-name="%(name)s"> \
<div class="panel-body">%(display)s</div> \
</div> \
</div>', address))
.css({"margin": "10px auto"})
.appendTo($address_wrapper);
});
$address_wrapper.find(".panel-heading")
.find(".address-title")
.css({"cursor": "pointer"})
.on("click", function() {
$address_wrapper.find('.panel-collapse[data-address-name="'
+$(this).attr("data-address-name")+'"]').collapse("toggle");
});
$address_wrapper.find('input[type="checkbox"]').on("click", function() {
if($(this).prop("checked")) {
var me = this;
$address_wrapper.find('input[type="checkbox"]').each(function(i, chk) {
if($(chk).attr("data-address-name")!=$(me).attr("data-address-name")) {
$(chk).prop("checked", false);
}
});
return wn.call({
type: "POST",
method: "erpnext.selling.utils.cart.update_cart_address",
args: {
address_fieldname: $address_wrapper.attr("data-fieldname"),
address_name: $(this).attr("data-address-name")
},
callback: function(r) {
if(!r.exc) {
erpnext.cart.render(r.message);
}
}
});
} else {
return false;
}
});
$address_wrapper.find('input[type="checkbox"][data-address-name="'+ address_name +'"]')
.prop("checked", true);
$address_wrapper.find(".panel-collapse").collapse({
parent: $address_wrapper,
toggle: false
});
$address_wrapper.find('.panel-collapse[data-address-name="'+ address_name +'"]')
.collapse("show");
},
place_order: function(btn) {
return wn.call({
type: "POST",
method: "erpnext.selling.utils.cart.place_order",
btn: btn,
callback: function(r) {
if(r.exc) {
var msg = "";
if(r._server_messages) {
msg = JSON.parse(r._server_messages || []).join("<br>");
}
$("#cart-error")
.empty()
.html(msg || wn._("Something went wrong!"))
.toggle(true);
} else {
window.location.href = "order?name=" + encodeURIComponent(r.message);
}
}
});
}
});

View File

@ -1,10 +0,0 @@
{% if obj.parent_groups and (obj.parent_groups|length) > 1 %}
<div class="container">
<ul class="breadcrumb">
{% for ig in obj.parent_groups[:-1] %}
<li><a href="{{ ig.page_name }}.html">{{ ig.name }}</a></li>
{% endfor %}
<li class="active">{{ obj.parent_groups[-1].name }}</li>
</ul>
</div>
{% endif %}

View File

@ -1,14 +0,0 @@
<div class="col-md-3">
<div style="height: 120px; overflow: hidden;">
<a href="{{ page_name }}">
{%- if website_image -%}
<img class="product-image" style="width: 80%; margin: auto;" src="{{ website_image }}">
{%- else -%}
{% include 'stock/doctype/item/templates/includes/product_missing_image.html' %}
{%- endif -%}
</a>
</div>
<div style="height: 100px; overflow: hidden; font-size: 80%;">
<h4 style="margin-bottom: 2px;"><a href="{{ page_name }}">{{ item_name }}</a></h4>
</div>
</div>

View File

@ -1,15 +0,0 @@
<!-- TODO product listing -->
<div class="container content">
<div style="height: 120px; overflow: hidden;">
<a href="{{ page_name }}">
{%- if website_image -%}
<img class="product-image" style="width: 80%; margin: auto;" src="{{ website_image }}">
{%- else -%}
{% include 'website/templates/html/product_missing_image.html' %}
{%- endif -%}
</a>
</div>
<div style="height: 100px; overflow: hidden; font-size: 80%;">
<h4 style="margin-bottom: 2px;"><a href="{{ page_name }}">{{ item_name }}</a></h4>
</div>
</div>

View File

@ -1,52 +0,0 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
window.get_product_list = function() {
$(".more-btn .btn").click(function() {
window.get_product_list()
});
if(window.start==undefined) {
throw "product list not initialized (no start)"
}
$.ajax({
method: "GET",
url: "/",
dataType: "json",
data: {
cmd: "erpnext.selling.utils.product.get_product_list",
start: window.start,
search: window.search,
product_group: window.product_group
},
dataType: "json",
success: function(data) {
window.render_product_list(data.message);
}
})
}
window.render_product_list = function(data) {
if(data.length) {
var table = $("#search-list .table");
if(!table.length)
var table = $("<table class='table'>").appendTo("#search-list");
$.each(data, function(i, d) {
$(d).appendTo(table);
});
}
if(data.length < 10) {
if(!table) {
$(".more-btn")
.replaceWith("<div class='alert alert-warning'>No products found.</div>");
} else {
$(".more-btn")
.replaceWith("<div class='text-muted'>Nothing more to show.</div>");
}
} else {
$(".more-btn").toggle(true)
}
window.start += (data.length || 0);
}

View File

@ -1 +0,0 @@
<div class="missing-image"><i class="icon-camera"></i></div>

View File

@ -1,13 +0,0 @@
<style>
.item-main-image {
max-width: 100%;
margin: auto;
}
.web-long-description {
font-size: 18px;
line-height: 200%;
}
.item-stock {
margin-bottom: 10px !important;
}
</style>

View File

@ -1,78 +0,0 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
$(document).ready(function() {
var item_code = $('[itemscope] [itemprop="productID"]').text().trim();
var qty = 0;
wn.call({
type: "POST",
method: "erpnext.selling.utils.product.get_product_info",
args: {
item_code: "{{ name }}"
},
callback: function(r) {
if(r.message && r.message.price) {
$(".item-price")
.html(r.message.price.formatted_price + " per " + r.message.uom);
if(r.message.stock==0) {
$(".item-stock").html("<div class='help'>Not in stock</div>");
}
else if(r.message.stock==1) {
$(".item-stock").html("<div style='color: green'>\
<i class='icon-check'></i> Available (in stock)</div>");
}
$(".item-price-info").toggle(true);
if(r.message.qty) {
qty = r.message.qty;
toggle_update_cart(qty);
$("#item-update-cart input").val(qty);
}
}
}
})
$("#item-add-to-cart button").on("click", function() {
erpnext.cart.update_cart({
item_code: item_code,
qty: 1,
callback: function(r) {
if(!r.exc) {
toggle_update_cart(1);
qty = 1;
}
},
btn: this,
});
});
$("#item-update-cart button").on("click", function() {
erpnext.cart.update_cart({
item_code: item_code,
qty: $("#item-update-cart input").val(),
btn: this,
callback: function(r) {
if(r.exc) {
$("#item-update-cart input").val(qty);
} else {
qty = $("#item-update-cart input").val();
}
},
});
});
if(localStorage && localStorage.getItem("pending_add_to_cart") && full_name) {
localStorage.removeItem("pending_add_to_cart");
$("#item-add-to-cart button").trigger("click");
}
});
var toggle_update_cart = function(qty) {
$("#item-add-to-cart").toggle(qty ? false : true);
$("#item-update-cart")
.toggle(qty ? true : false)
.find("input").val(qty);
}

View File

@ -1,28 +0,0 @@
<div class="container" style="margin-bottom: 7px;">
<form class="form-inline form-search row">
<div class="input-group col-md-4 col-md-offset-8">
<input class="form-control" type="text" id="product-search" placeholder="Product Search...">
<span class="input-group-btn">
<button class="btn btn-default" type="button" id="btn-product-search">
<i class="icon-search"></i></button>
</span>
</div>
</form>
<script>
// redirect to product search page
$(document).ready(function() {
$('.dropdown-toggle').dropdown();
$("#btn-product-search").click(function() {
var txt = $("#product-search").val();
if(txt) {
window.location.href="product_search?q=" + txt;
}
return false;
});
$("#product-search").keypress(function(e) {
if(e.which==13) $("#btn-product-search").click();
});
$(".form-search").on("submit", function() { return false; });
});
</script>
</div>

View File

@ -1,60 +0,0 @@
{% extends base_template %}
{% block content -%}
<div class="container content">
<ul class="breadcrumb">
<li><a href="index">Home</a></li>
<li class="active"><i class="{{ icon }} icon-fixed-width"></i> {{ title }}</li>
</ul>
<p id="msgprint-alert" class="alert alert-danger"
style="display: none;">&nbsp;</p>
<div class="list-group transaction-list">
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-info" style="width: 100%;"></div>
</div>
</div>
<div class="text-center">
<button class="btn btn-default btn-show-more hide">More</button>
</div>
</div>
{%- endblock %}
{% block javascript -%}
<script>
$(document).ready(function() {
window.start = 0;
window.$list = $(".transaction-list");
window.$show_more = $(".btn-show-more").on("click", function() { get_transactions(this); })
get_transactions();
});
var get_transactions = function(btn) {
wn.call({
method: "{{ method }}",
args: { start: start },
btn: btn,
callback: function(r) {
$list.find(".progress").remove();
$show_more.toggleClass("hide", !(r.message && r.message.length===20));
if(!(r.message && r.message.length)) {
console.log("empty");
if(!$list.html().trim()) {
$list.html("<div class='alert alert-warning'>\
{{ empty_list_message }}</div>");
}
return;
}
start += r.message.length;
$.each(r.message, function(i, doc) {
render(doc);
});
}
})
};
</script>
<!-- // var render = function(doc) { }; -->
{% endblock %}

View File

@ -1,114 +0,0 @@
{% extends base_template %}
{% set title=doc and doc.name or "New Address" %}
{% set docname=(doc and doc.name or "") %}
{% macro render_fields(docfields) -%}
{% for df in docfields -%}
{% if df.fieldtype in ["Data", "Link"] -%}
<fieldset>
<label>{{ df.label }}</label>
<input class="form-control" type="text" placeholder="Type {{ df.label }}"
data-fieldname="{{ df.fieldname }}" data-fieldtype="{{ df.fieldtype }}"
{% if doc and doc.fields.get(df.fieldname) -%} value="{{ doc.fields[df.fieldname] }}" {%- endif %}>
</fieldset>
{% elif df.fieldtype == "Check" -%}
<fieldset class="checkbox">
<label><input type="checkbox" data-fieldname="{{ df.fieldname }}"
data-fieldtype="{{ df.fieldtype }}"
{% if doc and cint(doc.fields.get(df.fieldname)) -%} checked="checked" {%- endif %}>
{{ df.label }}</label>
</fieldset>
{% elif df.fieldtype == "Select" -%}
<fieldset>
<label>{{ df.label }}</label>
<select class="form-control" data-fieldname="{{ df.fieldname }}" data-fieldtype="{{ df.fieldtype }}">
{% for value in df.options.split("\n") -%}
{% if doc and doc.fields.get(df.fieldname) == value -%}
<option selected="selected">{{ value }}</option>
{% else -%}
<option>{{ value }}</option>
{%- endif %}
{%- endfor %}
</select>
</fieldset>
{%- endif %}
{%- endfor %}
{%- endmacro %}
{% block content %}
<div class="container content">
<ul class="breadcrumb">
<li><a href="index">Home</a></li>
<li><a href="addresses">My Addresses</a></li>
<li class="active"><i class="icon-map-marker icon-fixed-width"></i> {{ title }}</li>
</ul>
<h3><i class="icon-map-marker icon-fixed-width"></i> {{ title }}</h3>
<button type="button" class="btn btn-primary pull-right" id="address-save"><i class="icon-ok"></i>
{{ doc and "Save" or "Insert" }}</button>
<div class="clearfix"></div>
<hr>
<div id="address-error" class="alert alert-danger" style="display: none;"></div>
<form autocomplete="on">
<div class="row">
<section class="col-md-6">
{{ render_fields(meta.left_fields) }}
</section>
<section class="col-md-6">
{{ render_fields(meta.right_fields) }}
</section>
</section>
</form>
</div>
<script>
;(function() {
$(document).ready(function() {
bind_save();
});
var bind_save = function() {
$("#address-save").on("click", function() {
var fields = {
name: "{{ docname }}"
};
$("form").find("[data-fieldname]").each(function(i, input) {
var $input = $(input);
var fieldname = $(input).attr("data-fieldname");
var fieldtype = $(input).attr("data-fieldtype");
if(fieldtype == "Check") {
fields[fieldname] = $input.is(":checked") ? 1 : 0;
} else {
fields[fieldname] = $input.val();
}
});
wn.call({
btn: $(this),
type: "POST",
method: "selling.utils.cart.save_address",
args: { fields: fields, address_fieldname: get_url_arg("address_fieldname") },
callback: function(r) {
if(r.exc) {
var msg = "";
if(r._server_messages) {
msg = JSON.parse(r._server_messages || []).join("<br>");
}
$("#address-error")
.html(msg || "Something went wrong!")
.toggle(true);
} else if(get_url_arg("address_fieldname")) {
window.location.href = "cart";
} else {
window.location.href = "address?name=" + encodeURIComponent(r.message);
}
}
});
});
};
})();
</script>
{% endblock %}

View File

@ -1,30 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint
no_cache = True
def get_context():
def _get_fields(fieldnames):
return [webnotes._dict(zip(["label", "fieldname", "fieldtype", "options"],
[df.label, df.fieldname, df.fieldtype, df.options]))
for df in webnotes.get_doctype("Address", processed=True).get({"fieldname": ["in", fieldnames]})]
bean = None
if webnotes.form_dict.name:
bean = webnotes.bean("Address", webnotes.form_dict.name)
return {
"doc": bean.doc if bean else None,
"meta": webnotes._dict({
"left_fields": _get_fields(["address_title", "address_type", "address_line1", "address_line2",
"city", "state", "pincode", "country"]),
"right_fields": _get_fields(["email_id", "phone", "fax", "is_primary_address",
"is_shipping_address"])
}),
"cint": cint
}

View File

@ -1,51 +0,0 @@
{% extends base_template %}
{% set title="My Addresses" %}
{% block content %}
<div class="container content">
<ul class="breadcrumb">
<li><a href="index">Home</a></li>
<li class="active"><i class="icon-map-marker icon-fixed-width"></i> My Addresses</li>
</ul>
<p><a class="btn btn-default" href="address"><i class="icon-plus"> New Address</i></a></p>
<hr>
<div id="address-list">
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-info" style="width: 100%;"></div>
</div>
</div>
</div>
<script>
;(function() {
$(document).ready(function() {
fetch_addresses();
});
var fetch_addresses = function() {
wn.call({
method: "selling.utils.cart.get_addresses",
callback: function(r) {
$("#address-list .progress").remove();
var $list = $("#address-list");
if(!(r.message && r.message.length)) {
$list.html("<div class='alert'>No Addresses Found</div>");
return;
}
$.each(r.message, function(i, address) {
address.url_name = encodeURIComponent(address.name);
$(repl('<div> \
<p><a href="address?name=%(url_name)s">%(name)s</a></p> \
<p>%(display)s</p> \
<hr> \
</div>', address)).appendTo($list);
});
}
});
};
})();
</script>
{% endblock %}

View File

@ -1,6 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
no_cache = True

View File

@ -1,57 +0,0 @@
{% extends base_template %}
{% block javascript %}
<script>{% include "templates/includes/cart.js" %}</script>
{% endblock %}
{% set title="Shopping Cart" %}
{% block content %}
<div class="container content">
<h2><i class="icon-shopping-cart"></i> {{ title }}</h2>
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-info" style="width: 100%;"></div>
</div>
<div id="cart-container" class="hide">
<p class="pull-right"><button class="btn btn-success btn-place-order" type="button">Place Order</button></p>
<div class="clearfix"></div>
<div id="cart-error" class="alert alert-danger" style="display: none;"></div>
<hr>
<div class="row">
<div class="col-md-9 col-sm-9">
<div class="row">
<div class="col-md-9 col-md-offset-3"><h4>Item Details</h4></div>
</div>
</div>
<div class="col-md-3 col-sm-3 text-right"><h4>Qty, Amount</h4></div>
</div><hr>
<div id="cart-items">
</div>
<div id="cart-taxes">
</div>
<div id="cart-totals">
</div>
<hr>
<div id="cart-addresses">
<div class="row">
<div class="col-md-6">
<h4>Shipping Address</h4>
<div id="cart-shipping-address" class="panel-group"
data-fieldname="shipping_address_name"></div>
<button class="btn btn-default" type="button" id="cart-add-shipping-address">
<span class="icon icon-plus"></span> New Shipping Address</button>
</div>
<div class="col-md-6">
<h4>Billing Address</h4>
<div id="cart-billing-address" class="panel-group"
data-fieldname="customer_address"></div>
<button class="btn btn-default" type="button" id="cart-add-billing-address">
<span class="icon icon-plus"></span> New Billing Address</button>
</div>
</div>
<hr>
</div>
<p class="pull-right"><button class="btn btn-success btn-place-order" type="button">Place Order</button></p>
</div>
</div>
{% endblock %}

View File

@ -1,7 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
no_cache = True
no_sitemap = True

View File

@ -1,5 +0,0 @@
{% extends "templates/sale.html" %}
{% block status -%}
{% if doc.status %}{{ doc.status }}{% endif %}
{%- endblock %}

View File

@ -1,30 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import _
from webnotes.utils import flt, fmt_money
no_cache = True
def get_context():
from erpnext.templates.utils import get_transaction_context
context = get_transaction_context("Sales Invoice", webnotes.form_dict.name)
modify_status(context.get("doc"))
context.update({
"parent_link": "invoices",
"parent_title": "Invoices"
})
return context
def modify_status(doc):
doc.status = ""
if flt(doc.outstanding_amount):
doc.status = '<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % \
("label-warning", "icon-exclamation-sign",
_("To Pay") + " = " + fmt_money(doc.outstanding_amount, currency=doc.currency))
else:
doc.status = '<span class="label %s"><i class="icon-fixed-width %s"></i> %s</span>' % \
("label-success", "icon-ok", _("Paid"))

View File

@ -1 +0,0 @@
{% extends "templates/sales_transactions.html" %}

View File

@ -1,28 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
no_cache = True
def get_context():
from erpnext.templates.utils import get_currency_context
context = get_currency_context()
context.update({
"title": "Invoices",
"method": "accounts.doctype.sales_invoice.templates.pages.invoices.get_invoices",
"icon": "icon-file-text",
"empty_list_message": "No Invoices Found",
"page": "invoice"
})
return context
@webnotes.whitelist()
def get_invoices(start=0):
from erpnext.templates.utils import get_transaction_list
from erpnext.accounts.doctype.sales_invoice.templates.pages.invoice import modify_status
invoices = get_transaction_list("Sales Invoice", start, ["outstanding_amount"])
for d in invoices:
modify_status(d)
return invoices

View File

@ -1,33 +0,0 @@
{% extends base_template %}
{% set title="Product Search" %}
{% block javascript %}
<script>{% include "stock/doctype/item/templates/includes/product_list.js" %}</script>
{% endblock %}
{% block content %}
<script>
$(document).ready(function() {
var txt = get_url_arg("q");
$(".search-results").html("Search results for: " + txt);
window.search = txt;
window.start = 0;
window.get_product_list();
});
</script>
{% include "stock/doctype/item/templates/includes/product_search_box.html" %}
<div class="container content">
<h3 class="search-results">Search Results</h3>
<div id="search-list" class="row">
</div>
<div style="text-align: center;">
<div class="more-btn"
style="display: none; text-align: center;">
<button class="btn">More...</button>
</div>
</div>
</div>
{% endblock %}

View File

@ -1,6 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
no_cache = True

View File

@ -1,55 +0,0 @@
{% extends base_template %}
{% set title="My Profile" %}
{% block content %}
<div class="container content">
<ul class="breadcrumb">
<li><a href="index">Home</a></li>
<li class="active"><i class="icon-user icon-fixed-width"></i> My Profile</li>
</ul>
<div class="alert alert-warning" id="message" style="display: none;"></div>
<form>
<fieldset>
<label>Full Name</label>
<input class="form-control" type="text" id="fullname" placeholder="Your Name">
</fieldset>
<fieldset>
<label>Company Name</label>
<input class="form-control" type="text" id="company_name" placeholder="Company Name" value="{{ company_name }}">
</fieldset>
<fieldset>
<label>Mobile No</label>
<input class="form-control" type="text" id="mobile_no" placeholder="Mobile No" value="{{ mobile_no }}">
</fieldset>
<fieldset>
<label>Phone</label>
<input class="form-control" type="text" id="phone" placeholder="Phone" value="{{ phone }}">
</fieldset>
<button id="update_profile" type="submit" class="btn btn-default">Update</button>
</form>
</div>
<script>
$(document).ready(function() {
$("#fullname").val(getCookie("full_name") || "");
$("#update_profile").click(function() {
wn.call({
method: "erpnext.templates.pages.profile.update_profile",
type: "POST",
args: {
fullname: $("#fullname").val(),
company_name: $("#company_name").val(),
mobile_no: $("#mobile_no").val(),
phone: $("#phone").val()
},
btn: this,
msg: $("#message"),
callback: function(r) {
if(!r.exc) $("#user-full-name").html($("#fullname").val());
}
});
return false;
})
})
</script>
{% endblock %}

View File

@ -1,40 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes import _
from webnotes.utils import cstr
no_cache = True
no_sitemap = True
def get_context():
from erpnext.selling.utils.cart import get_lead_or_customer
party = get_lead_or_customer()
if party.doctype == "Lead":
mobile_no = party.mobile_no
phone = party.phone
else:
mobile_no, phone = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user,
"customer": party.name}, ["mobile_no", "phone"])
return {
"company_name": cstr(party.customer_name if party.doctype == "Customer" else party.company_name),
"mobile_no": cstr(mobile_no),
"phone": cstr(phone)
}
@webnotes.whitelist()
def update_profile(fullname, password=None, company_name=None, mobile_no=None, phone=None):
from erpnext.selling.utils.cart import update_party
update_party(fullname, company_name, mobile_no, phone)
if not fullname:
return _("Name is required")
webnotes.conn.set_value("Profile", webnotes.session.user, "first_name", fullname)
webnotes._response.set_cookie("full_name", fullname)
return _("Updated")

View File

@ -1 +0,0 @@
{% extends "templates/sale.html" %}

View File

@ -1,16 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
no_cache = True
def get_context():
from erpnext.templates.utils import get_transaction_context
context = get_transaction_context("Delivery Note", webnotes.form_dict.name)
context.update({
"parent_link": "shipments",
"parent_title": "Shipments"
})
return context

View File

@ -1 +0,0 @@
{% extends "templates/sales_transactions.html" %}

Some files were not shown because too many files have changed in this diff Show More