diff --git a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt
index 5de944204c0..9aa70536610 100644
--- a/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt
+++ b/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-01-10 16:34:09",
"docstatus": 0,
- "modified": "2013-06-20 16:49:12",
+ "modified": "2013-06-25 12:06:45",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -30,8 +30,7 @@
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
- "report": 1,
- "submit": 0
+ "report": 1
},
{
"doctype": "DocType",
@@ -101,21 +100,20 @@
"create": 0,
"doctype": "DocPerm",
"role": "Sales User",
+ "submit": 0,
"write": 0
},
+ {
+ "doctype": "DocPerm",
+ "role": "Accounts User"
+ },
{
"amend": 0,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Accounts Manager",
- "write": 1
- },
- {
- "cancel": 1,
- "create": 1,
- "doctype": "DocPerm",
- "role": "System Manager",
+ "submit": 0,
"write": 1
},
{
@@ -124,6 +122,7 @@
"create": 1,
"doctype": "DocPerm",
"role": "Sales Master Manager",
+ "submit": 0,
"write": 1
}
]
\ No newline at end of file
diff --git a/selling/report/sales_person_target_variance_(item_group_wise)/__init__.py b/accounts/doctype/shipping_rule/__init__.py
similarity index 100%
rename from selling/report/sales_person_target_variance_(item_group_wise)/__init__.py
rename to accounts/doctype/shipping_rule/__init__.py
diff --git a/accounts/doctype/shipping_rule/shipping_rule.py b/accounts/doctype/shipping_rule/shipping_rule.py
new file mode 100644
index 00000000000..87148656dfb
--- /dev/null
+++ b/accounts/doctype/shipping_rule/shipping_rule.py
@@ -0,0 +1,82 @@
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import webnotes
+from webnotes import _, msgprint
+from webnotes.utils import flt, fmt_money
+from webnotes.model.controller import DocListController
+from setup.utils import get_company_currency
+
+class OverlappingConditionError(webnotes.ValidationError): pass
+class FromGreaterThanToError(webnotes.ValidationError): pass
+class ManyBlankToValuesError(webnotes.ValidationError): pass
+
+class DocType(DocListController):
+ def __init__(self, d, dl):
+ self.doc, self.doclist = d, dl
+
+ def validate(self):
+ self.shipping_rule_conditions = self.doclist.get({"parentfield": "shipping_rule_conditions"})
+ self.validate_from_to_values()
+ self.sort_shipping_rule_conditions()
+ self.validate_overlapping_shipping_rule_conditions()
+
+ def validate_from_to_values(self):
+ zero_to_values = []
+
+ for d in self.shipping_rule_conditions:
+ self.round_floats_in(d)
+
+ # values cannot be negative
+ self.validate_value("from_value", ">=", 0.0, d)
+ self.validate_value("to_value", ">=", 0.0, d)
+
+ if d.to_value == 0:
+ zero_to_values.append(d)
+ elif d.from_value >= d.to_value:
+ msgprint(_("Error") + ": " + _("Row") + " # %d: " % d.idx +
+ _("From Value should be less than To Value"),
+ raise_exception=FromGreaterThanToError)
+
+ # check if more than two or more rows has To Value = 0
+ if len(zero_to_values) >= 2:
+ msgprint(_('''There can only be one Shipping Rule Condition with 0 or blank value for "To Value"'''),
+ raise_exception=ManyBlankToValuesError)
+
+ def sort_shipping_rule_conditions(self):
+ """Sort Shipping Rule Conditions based on increasing From Value"""
+ self.shipping_rules_conditions = sorted(self.shipping_rule_conditions, key=lambda d: flt(d.from_value))
+ for i, d in enumerate(self.shipping_rule_conditions):
+ d.idx = i + 1
+
+ def validate_overlapping_shipping_rule_conditions(self):
+ def overlap_exists_between((x1, x2), (y1, y2)):
+ """
+ (x1, x2) and (y1, y2) are two ranges
+ if condition x = 100 to 300
+ then condition y can only be like 50 to 99 or 301 to 400
+ hence, non-overlapping condition = (x1 <= x2 < y1 <= y2) or (y1 <= y2 < x1 <= x2)
+ """
+ separate = (x1 <= x2 < y1 <= y2) or (y1 <= y2 < x1 <= x2)
+ return (not separate)
+
+ overlaps = []
+ for i in xrange(0, len(self.shipping_rule_conditions)):
+ for j in xrange(i+1, len(self.shipping_rule_conditions)):
+ d1, d2 = self.shipping_rule_conditions[i], self.shipping_rule_conditions[j]
+ if d1.fields != d2.fields:
+ # in our case, to_value can be zero, hence pass the from_value if so
+ range_a = (d1.from_value, d1.to_value or d1.from_value)
+ range_b = (d2.from_value, d2.to_value or d2.from_value)
+ if overlap_exists_between(range_a, range_b):
+ overlaps.append([d1, d2])
+
+ if overlaps:
+ company_currency = get_company_currency(self.doc.company)
+ msgprint(_("Error") + ": " + _("Overlapping Conditions found between") + ":")
+ messages = []
+ for d1, d2 in overlaps:
+ messages.append("%s-%s = %s " % (d1.from_value, d1.to_value, fmt_money(d1.shipping_amount, currency=company_currency)) +
+ _("and") + " %s-%s = %s" % (d2.from_value, d2.to_value, fmt_money(d2.shipping_amount, currency=company_currency)))
+
+ msgprint("\n".join(messages), raise_exception=OverlappingConditionError)
\ No newline at end of file
diff --git a/accounts/doctype/shipping_rule/shipping_rule.txt b/accounts/doctype/shipping_rule/shipping_rule.txt
new file mode 100644
index 00000000000..dd4fe8dfed2
--- /dev/null
+++ b/accounts/doctype/shipping_rule/shipping_rule.txt
@@ -0,0 +1,151 @@
+[
+ {
+ "creation": "2013-06-25 11:48:03",
+ "docstatus": 0,
+ "modified": "2013-06-25 12:15:21",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "description": "Specify conditions to calculate shipping amount",
+ "doctype": "DocType",
+ "module": "Accounts",
+ "name": "__common__"
+ },
+ {
+ "doctype": "DocField",
+ "name": "__common__",
+ "parent": "Shipping Rule",
+ "parentfield": "fields",
+ "parenttype": "DocType",
+ "permlevel": 0
+ },
+ {
+ "doctype": "DocPerm",
+ "name": "__common__",
+ "parent": "Shipping Rule",
+ "parentfield": "permissions",
+ "parenttype": "DocType",
+ "permlevel": 0,
+ "read": 1,
+ "report": 1
+ },
+ {
+ "doctype": "DocType",
+ "name": "Shipping Rule"
+ },
+ {
+ "description": "example: Next Day Shipping",
+ "doctype": "DocField",
+ "fieldname": "shipping_rule_label",
+ "fieldtype": "Data",
+ "in_list_view": 1,
+ "label": "Shipping Rule Label",
+ "reqd": 1
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "column_break_2",
+ "fieldtype": "Column Break"
+ },
+ {
+ "default": "Amount",
+ "doctype": "DocField",
+ "fieldname": "calculate_based_on",
+ "fieldtype": "Select",
+ "in_list_view": 1,
+ "label": "Calculate Based On",
+ "options": "Amount\nNet Weight",
+ "reqd": 1
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "rule_conditions_section",
+ "fieldtype": "Section Break",
+ "label": "Shipping Rule Conditions"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "shipping_rule_conditions",
+ "fieldtype": "Table",
+ "label": "Shipping Rule Conditions",
+ "options": "Shipping Rule Condition",
+ "reqd": 1
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "section_break_6",
+ "fieldtype": "Section Break"
+ },
+ {
+ "description": "Specify a list of Territories, for which, this Shipping Rule is valid",
+ "doctype": "DocField",
+ "fieldname": "valid_for_territories",
+ "fieldtype": "Table",
+ "label": "Valid For Territories",
+ "options": "For Territory",
+ "reqd": 1
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "column_break_8",
+ "fieldtype": "Column Break"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "company",
+ "fieldtype": "Link",
+ "in_list_view": 0,
+ "label": "Company",
+ "options": "Company",
+ "reqd": 1
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "section_break_10",
+ "fieldtype": "Section Break"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "account",
+ "fieldtype": "Link",
+ "label": "Shipping Account",
+ "options": "Account",
+ "reqd": 1
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "column_break_12",
+ "fieldtype": "Column Break"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "cost_center",
+ "fieldtype": "Link",
+ "label": "Cost Center",
+ "options": "Cost Center",
+ "reqd": 1
+ },
+ {
+ "doctype": "DocPerm",
+ "role": "Accounts User"
+ },
+ {
+ "doctype": "DocPerm",
+ "role": "Sales User"
+ },
+ {
+ "cancel": 1,
+ "create": 1,
+ "doctype": "DocPerm",
+ "role": "Accounts Manager",
+ "write": 1
+ },
+ {
+ "cancel": 1,
+ "create": 1,
+ "doctype": "DocPerm",
+ "role": "Sales Master Manager",
+ "write": 1
+ }
+]
\ No newline at end of file
diff --git a/accounts/doctype/shipping_rule/test_shipping_rule.py b/accounts/doctype/shipping_rule/test_shipping_rule.py
new file mode 100644
index 00000000000..ff217bc5a76
--- /dev/null
+++ b/accounts/doctype/shipping_rule/test_shipping_rule.py
@@ -0,0 +1,66 @@
+import webnotes
+import unittest
+from accounts.doctype.shipping_rule.shipping_rule import FromGreaterThanToError, ManyBlankToValuesError, OverlappingConditionError
+
+class TestShippingRule(unittest.TestCase):
+ def test_from_greater_than_to(self):
+ shipping_rule = webnotes.bean(copy=test_records[0])
+ shipping_rule.doclist[1].from_value = 101
+ self.assertRaises(FromGreaterThanToError, shipping_rule.insert)
+
+ def test_many_zero_to_values(self):
+ shipping_rule = webnotes.bean(copy=test_records[0])
+ shipping_rule.doclist[1].to_value = 0
+ self.assertRaises(ManyBlankToValuesError, shipping_rule.insert)
+
+ def test_overlapping_conditions(self):
+ for range_a, range_b in [
+ ((50, 150), (0, 100)),
+ ((50, 150), (100, 200)),
+ ((50, 150), (75, 125)),
+ ((50, 150), (25, 175)),
+ ((50, 150), (50, 150)),
+ ]:
+ shipping_rule = webnotes.bean(copy=test_records[0])
+ shipping_rule.doclist[1].from_value = range_a[0]
+ shipping_rule.doclist[1].to_value = range_a[1]
+ shipping_rule.doclist[2].from_value = range_b[0]
+ shipping_rule.doclist[2].to_value = range_b[1]
+ self.assertRaises(OverlappingConditionError, shipping_rule.insert)
+
+test_records = [
+ [
+ {
+ "doctype": "Shipping Rule",
+ "calculate_based_on": "Amount",
+ "company": "_Test Company",
+ "account": "_Test Account Shipping Charges - _TC",
+ "cost_center": "_Test Cost Center - _TC"
+ },
+ {
+ "doctype": "Shipping Rule Condition",
+ "parentfield": "shipping_rule_conditions",
+ "from_value": 0,
+ "to_value": 100,
+ "shipping_amount": 50.0
+ },
+ {
+ "doctype": "Shipping Rule Condition",
+ "parentfield": "shipping_rule_conditions",
+ "from_value": 101,
+ "to_value": 200,
+ "shipping_amount": 100.0
+ },
+ {
+ "doctype": "Shipping Rule Condition",
+ "parentfield": "shipping_rule_conditions",
+ "from_value": 201,
+ "shipping_amount": 0.0
+ },
+ {
+ "doctype": "For Territory",
+ "parentfield": "valid_for_territories",
+ "territory": "_Test Territory"
+ }
+ ]
+]
\ No newline at end of file
diff --git a/selling/report/territory_target_variance_(item_group_wise)/__init__.py b/accounts/doctype/shipping_rule_condition/__init__.py
similarity index 100%
rename from selling/report/territory_target_variance_(item_group_wise)/__init__.py
rename to accounts/doctype/shipping_rule_condition/__init__.py
diff --git a/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py b/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py
new file mode 100644
index 00000000000..928aa9ff9f2
--- /dev/null
+++ b/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py
@@ -0,0 +1,8 @@
+# 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
\ No newline at end of file
diff --git a/accounts/doctype/shipping_rule_condition/shipping_rule_condition.txt b/accounts/doctype/shipping_rule_condition/shipping_rule_condition.txt
new file mode 100644
index 00000000000..2fe43db24d8
--- /dev/null
+++ b/accounts/doctype/shipping_rule_condition/shipping_rule_condition.txt
@@ -0,0 +1,50 @@
+[
+ {
+ "creation": "2013-06-25 11:54:50",
+ "docstatus": 0,
+ "modified": "2013-06-25 11:58:04",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "description": "A condition for a Shipping Rule",
+ "doctype": "DocType",
+ "istable": 1,
+ "module": "Accounts",
+ "name": "__common__"
+ },
+ {
+ "doctype": "DocField",
+ "name": "__common__",
+ "parent": "Shipping Rule Condition",
+ "parentfield": "fields",
+ "parenttype": "DocType",
+ "permlevel": 0
+ },
+ {
+ "doctype": "DocType",
+ "name": "Shipping Rule Condition"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "from_value",
+ "fieldtype": "Float",
+ "label": "From Value",
+ "reqd": 1
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "to_value",
+ "fieldtype": "Float",
+ "label": "To Value",
+ "reqd": 0
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "shipping_amount",
+ "fieldtype": "Currency",
+ "label": "Shipping Amount",
+ "options": "Company:company:default_currency",
+ "reqd": 1
+ }
+]
\ No newline at end of file
diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js
index a998818767f..f7e476af30c 100644
--- a/accounts/page/accounts_home/accounts_home.js
+++ b/accounts/page/accounts_home/accounts_home.js
@@ -100,6 +100,11 @@ wn.module_page["Accounts"] = [
"doctype":"Purchase Taxes and Charges Master",
"description": wn._("Tax Template for Purchase")
},
+ {
+ "label": wn._("Shipping Rules"),
+ "doctype":"Shipping Rule",
+ "description": wn._("Rules to calculate shipping amount for a sale")
+ },
{
"label": wn._("Point-of-Sale Setting"),
"doctype":"POS Setting",
diff --git a/accounts/page/general_ledger/general_ledger.js b/accounts/page/general_ledger/general_ledger.js
index ff72104e08f..1f8618f20a7 100644
--- a/accounts/page/general_ledger/general_ledger.js
+++ b/accounts/page/general_ledger/general_ledger.js
@@ -232,7 +232,6 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
grouped_ledgers[item.account].totals.debit += item.debit;
grouped_ledgers[item.account].totals.credit += item.credit;
-
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]
.totals.debit += item.debit;
grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]
@@ -248,8 +247,8 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
grouped_ledgers[item.account].entries.push(item);
if(grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no].row){
- grouped_ledgers[item.account].
- entries_group_by_voucher[item.voucher_no].row = item;
+ grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]
+ .row = jQuery.extend({}, item);
}
}
}
@@ -320,13 +319,14 @@ erpnext.GeneralLedger = wn.views.GridReport.extend({
var out = []
$.each(Object.keys(grouped_ledgers).sort(), function(i, account) {
if(grouped_ledgers[account].entries.length) {
- $.each(Object.keys(grouped_ledgers[account].entries_group_by_voucher).sort(),
- function(j, voucher) {
+ $.each(Object.keys(grouped_ledgers[account].entries_group_by_voucher),
+ function(j, voucher) {
voucher_dict = grouped_ledgers[account].entries_group_by_voucher[voucher];
- if(voucher_dict.totals.debit || voucher_dict.totals.credit) {
+ if(voucher_dict &&
+ (voucher_dict.totals.debit || voucher_dict.totals.credit)) {
voucher_dict.row.debit = voucher_dict.totals.debit;
voucher_dict.row.credit = voucher_dict.totals.credit;
- voucher_dict.row.id = "entry" + voucher
+ voucher_dict.row.id = "entry_grouped_by_" + voucher
out = out.concat(voucher_dict.row);
}
});
diff --git a/accounts/report/budget_variance_report/budget_variance_report.py b/accounts/report/budget_variance_report/budget_variance_report.py
index 99e303bd204..42bc6639edb 100644
--- a/accounts/report/budget_variance_report/budget_variance_report.py
+++ b/accounts/report/budget_variance_report/budget_variance_report.py
@@ -16,18 +16,21 @@
from __future__ import unicode_literals
import webnotes
-import calendar
from webnotes import _, msgprint
from webnotes.utils import flt
import time
+from accounts.utils import get_fiscal_year
+from controllers.trends import get_period_date_ranges, get_period_month_ranges
def execute(filters=None):
if not filters: filters = {}
columns = get_columns(filters)
- period_month_ranges = get_period_month_ranges(filters)
+ period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"])
cam_map = get_costcenter_account_month_map(filters)
+ precision = webnotes.conn.get_value("Global Defaults", None, "float_precision") or 2
+
data = []
for cost_center, cost_center_items in cam_map.items():
@@ -39,7 +42,7 @@ def execute(filters=None):
for month in relevant_months:
month_data = monthwise_data.get(month, {})
for i, fieldname in enumerate(["target", "actual", "variance"]):
- value = flt(month_data.get(fieldname))
+ value = flt(month_data.get(fieldname), precision)
period_data[i] += value
totals[i] += value
period_data[2] = period_data[0] - period_data[1]
@@ -61,7 +64,7 @@ def get_columns(filters):
group_months = False if filters["period"] == "Monthly" else True
- for from_date, to_date in get_period_date_ranges(filters):
+ for from_date, to_date in get_period_date_ranges(filters["period"], filters["fiscal_year"]):
for label in ["Target (%s)", "Actual (%s)", "Variance (%s)"]:
if group_months:
columns.append(label % (from_date.strftime("%b") + " - " + to_date.strftime("%b")))
@@ -70,41 +73,6 @@ def get_columns(filters):
return columns + ["Total Target::80", "Total Actual::80", "Total Variance::80"]
-def get_period_date_ranges(filters):
- from dateutil.relativedelta import relativedelta
-
- year_start_date, year_end_date = get_year_start_end_date(filters)
-
- increment = {
- "Monthly": 1,
- "Quarterly": 3,
- "Half-Yearly": 6,
- "Yearly": 12
- }.get(filters["period"])
-
- period_date_ranges = []
- for i in xrange(1, 13, increment):
- period_end_date = year_start_date + relativedelta(months=increment,
- days=-1)
- period_date_ranges.append([year_start_date, period_end_date])
- year_start_date = period_end_date + relativedelta(days=1)
-
- return period_date_ranges
-
-def get_period_month_ranges(filters):
- from dateutil.relativedelta import relativedelta
- period_month_ranges = []
-
- for start_date, end_date in get_period_date_ranges(filters):
- months_in_this_period = []
- while start_date <= end_date:
- months_in_this_period.append(start_date.strftime("%B"))
- start_date += relativedelta(months=1)
- period_month_ranges.append(months_in_this_period)
-
- return period_month_ranges
-
-
#Get cost center & target details
def get_costcenter_target_details(filters):
return webnotes.conn.sql("""select cc.name, cc.distribution_id,
@@ -122,7 +90,7 @@ def get_target_distribution_details(filters):
for d in webnotes.conn.sql("""select bdd.month, bdd.percentage_allocation \
from `tabBudget Distribution Detail` bdd, `tabBudget Distribution` bd, \
`tabCost Center` cc where bdd.parent=bd.name and cc.distribution_id=bd.name and \
- bd.fiscal_year=%s""" % ('%s'), (filters.get("fiscal_year")), as_dict=1):
+ bd.fiscal_year=%s""", (filters["fiscal_year"]), as_dict=1):
target_details.setdefault(d.month, d)
return target_details
@@ -147,22 +115,16 @@ def get_costcenter_account_month_map(filters):
for month in tdd:
cam_map.setdefault(ccd.name, {}).setdefault(ccd.account, {})\
.setdefault(month, webnotes._dict({
- "target": 0.0, "actual": 0.0, "variance": 0.0
+ "target": 0.0, "actual": 0.0
}))
tav_dict = cam_map[ccd.name][ccd.account][month]
- tav_dict.target = ccd.budget_allocated*(tdd[month]["percentage_allocation"]/100)
+ tav_dict.target = flt(ccd.budget_allocated) * \
+ (tdd[month]["percentage_allocation"]/100)
for ad in actual_details:
if ad.month_name == month and ad.account == ccd.account \
and ad.cost_center == ccd.name:
tav_dict.actual += ad.debit - ad.credit
- return cam_map
-
-def get_year_start_end_date(filters):
- return webnotes.conn.sql("""select year_start_date,
- subdate(adddate(year_start_date, interval 1 year), interval 1 day)
- as year_end_date
- from `tabFiscal Year`
- where name=%s""", filters["fiscal_year"])[0]
\ No newline at end of file
+ return cam_map
\ No newline at end of file
diff --git a/accounts/report/purchase_register/purchase_register.py b/accounts/report/purchase_register/purchase_register.py
index 548b5613440..d6233a41e0d 100644
--- a/accounts/report/purchase_register/purchase_register.py
+++ b/accounts/report/purchase_register/purchase_register.py
@@ -38,11 +38,12 @@ def execute(filters=None):
data = []
for inv in invoice_list:
# invoice details
- purchase_order = ", ".join(invoice_po_pr_map.get(inv.name, {}).get("purchase_order", []))
- purchase_receipt = ", ".join(invoice_po_pr_map.get(inv.name, {}).get("purchase_receipt", []))
+ purchase_order = list(set(invoice_po_pr_map.get(inv.name, {}).get("purchase_order", [])))
+ purchase_receipt = list(set(invoice_po_pr_map.get(inv.name, {}).get("purchase_receipt", [])))
+
row = [inv.name, inv.posting_date, inv.supplier, inv.credit_to,
account_map.get(inv.credit_to), inv.project_name, inv.bill_no, inv.bill_date,
- inv.remarks, purchase_order, purchase_receipt]
+ inv.remarks, ", ".join(purchase_order), ", ".join(purchase_receipt)]
# map expense values
for expense_acc in expense_accounts:
@@ -55,8 +56,9 @@ def execute(filters=None):
for tax_acc in tax_accounts:
row.append(invoice_tax_map.get(inv.name, {}).get(tax_acc))
- # total tax, grand total
- row += [inv.total_tax, inv.grand_total]
+ # total tax, grand total, outstanding amount & rounded total
+ row += [inv.other_charges_total, inv.grand_total, flt(inv.grand_total, 2), \
+ inv.outstanding_amount]
data.append(row)
return columns, data
@@ -85,7 +87,8 @@ def get_columns(invoice_list):
columns = columns + [(account + ":Currency:120") for account in expense_accounts] + \
["Net Total:Currency:120"] + [(account + ":Currency:120") for account in tax_accounts] + \
- ["Total Tax:Currency:120"] + ["Grand Total:Currency:120"]
+ ["Total Tax:Currency:120"] + ["Grand Total:Currency:120"] + \
+ ["Rounded Total:Currency:120"] + ["Outstanding Amount:Currency:120"]
return columns, expense_accounts, tax_accounts
@@ -102,9 +105,11 @@ def get_conditions(filters):
def get_invoices(filters):
conditions = get_conditions(filters)
- return webnotes.conn.sql("""select name, posting_date, credit_to, project_name, supplier,
- bill_no, bill_date, remarks, net_total, total_tax, grand_total
- from `tabPurchase Invoice` where docstatus = 1 %s
+ return webnotes.conn.sql("""select pi.name, pi.posting_date, pi.credit_to,
+ pii.project_name, pi.supplier, pi.bill_no, pi.bill_date, pi.remarks, pi.net_total,
+ pi.total_tax, pi.grand_total, pi.outstanding_amount
+ from `tabPurchase Invoice` pi, `tabPurchase Invoice Item` pii
+ where pii.parent = pi.name and pi.docstatus = 1 %s
order by posting_date desc, name desc""" % conditions, filters, as_dict=1)
diff --git a/accounts/report/sales_register/sales_register.py b/accounts/report/sales_register/sales_register.py
index 99057f9a2eb..3eebc33e9ca 100644
--- a/accounts/report/sales_register/sales_register.py
+++ b/accounts/report/sales_register/sales_register.py
@@ -39,12 +39,12 @@ def execute(filters=None):
data = []
for inv in invoice_list:
# invoice details
- sales_order = ", ".join(invoice_so_dn_map.get(inv.name, {}).get("sales_order", []))
- delivery_note = ", ".join(invoice_so_dn_map.get(inv.name, {}).get("delivery_note", []))
+ sales_order = list(set(invoice_so_dn_map.get(inv.name, {}).get("sales_order", [])))
+ delivery_note = list(set(invoice_so_dn_map.get(inv.name, {}).get("delivery_note", [])))
row = [inv.name, inv.posting_date, inv.customer, inv.debit_to,
account_map.get(inv.debit_to), customer_map.get(inv.customer), inv.project_name,
- inv.remarks, sales_order, delivery_note]
+ inv.remarks, ", ".join(sales_order), ", ".join(delivery_note)]
# map income values
for income_acc in income_accounts:
@@ -57,8 +57,8 @@ def execute(filters=None):
for tax_acc in tax_accounts:
row.append(invoice_tax_map.get(inv.name, {}).get(tax_acc))
- # total tax, grand total
- row += [inv.other_charges_total, inv.grand_total]
+ # total tax, grand total, outstanding amount & rounded total
+ row += [inv.other_charges_total, inv.grand_total, inv.rounded_total, inv.outstanding_amount]
data.append(row)
@@ -88,7 +88,8 @@ def get_columns(invoice_list):
columns = columns + [(account + ":Currency:120") for account in income_accounts] + \
["Net Total:Currency:120"] + [(account + ":Currency:120") for account in tax_accounts] + \
- ["Total Tax:Currency:120"] + ["Grand Total:Currency:120"]
+ ["Total Tax:Currency:120"] + ["Grand Total:Currency:120"] + \
+ ["Rounded Total:Currency:120"] + ["Outstanding Amount:Currency:120"]
return columns, income_accounts, tax_accounts
@@ -106,7 +107,8 @@ def get_conditions(filters):
def get_invoices(filters):
conditions = get_conditions(filters)
return webnotes.conn.sql("""select name, posting_date, debit_to, project_name, customer,
- remarks, net_total, other_charges_total, grand_total from `tabSales Invoice`
+ remarks, net_total, other_charges_total, grand_total, rounded_total,
+ outstanding_amount from `tabSales Invoice`
where docstatus = 1 %s order by posting_date desc, name desc""" %
conditions, filters, as_dict=1)
diff --git a/patches/june_2013/p01_update_bom_exploded_items.py b/patches/june_2013/p01_update_bom_exploded_items.py
index eff0931e4d9..f53eb5bc68b 100644
--- a/patches/june_2013/p01_update_bom_exploded_items.py
+++ b/patches/june_2013/p01_update_bom_exploded_items.py
@@ -23,7 +23,7 @@ def execute():
if bom[0] not in updated_bom:
try:
bom_obj = webnotes.get_obj("BOM", bom[0], with_children=1)
- updated_bom = bom_obj.update_cost_and_exploded_items(updated_bom)
+ updated_bom += bom_obj.update_cost_and_exploded_items(bom[0])
webnotes.conn.commit()
except:
pass
\ No newline at end of file
diff --git a/public/js/stock_analytics.js b/public/js/stock_analytics.js
index c3ed1cb232f..91384f61ed9 100644
--- a/public/js/stock_analytics.js
+++ b/public/js/stock_analytics.js
@@ -162,6 +162,8 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({
} else {
break;
}
+
+ me.round_item_values(item);
}
}
},
diff --git a/stock/doctype/sales_bom/__init__.py b/selling/doctype/sales_bom/__init__.py
similarity index 100%
rename from stock/doctype/sales_bom/__init__.py
rename to selling/doctype/sales_bom/__init__.py
diff --git a/stock/doctype/sales_bom/sales_bom.js b/selling/doctype/sales_bom/sales_bom.js
similarity index 100%
rename from stock/doctype/sales_bom/sales_bom.js
rename to selling/doctype/sales_bom/sales_bom.js
diff --git a/stock/doctype/sales_bom/sales_bom.py b/selling/doctype/sales_bom/sales_bom.py
similarity index 100%
rename from stock/doctype/sales_bom/sales_bom.py
rename to selling/doctype/sales_bom/sales_bom.py
diff --git a/stock/doctype/sales_bom/sales_bom.txt b/selling/doctype/sales_bom/sales_bom.txt
similarity index 94%
rename from stock/doctype/sales_bom/sales_bom.txt
rename to selling/doctype/sales_bom/sales_bom.txt
index 031f2559196..bf8fa479c22 100644
--- a/stock/doctype/sales_bom/sales_bom.txt
+++ b/selling/doctype/sales_bom/sales_bom.txt
@@ -1,8 +1,8 @@
[
{
- "creation": "2013-01-10 16:34:29",
+ "creation": "2013-06-20 11:53:21",
"docstatus": 0,
- "modified": "2013-01-22 14:57:23",
+ "modified": "2013-06-25 16:43:18",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -11,7 +11,7 @@
"doctype": "DocType",
"document_type": "Master",
"is_submittable": 0,
- "module": "Stock",
+ "module": "Selling",
"name": "__common__"
},
{
@@ -23,7 +23,6 @@
"permlevel": 0
},
{
- "amend": 0,
"doctype": "DocPerm",
"name": "__common__",
"parent": "Sales BOM",
@@ -74,6 +73,7 @@
"reqd": 1
},
{
+ "amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
@@ -81,6 +81,7 @@
"write": 1
},
{
+ "amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
@@ -88,6 +89,7 @@
"write": 0
},
{
+ "amend": 0,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
diff --git a/stock/doctype/sales_bom/test_sales_bom.py b/selling/doctype/sales_bom/test_sales_bom.py
similarity index 100%
rename from stock/doctype/sales_bom/test_sales_bom.py
rename to selling/doctype/sales_bom/test_sales_bom.py
diff --git a/stock/doctype/sales_bom_item/__init__.py b/selling/doctype/sales_bom_item/__init__.py
similarity index 100%
rename from stock/doctype/sales_bom_item/__init__.py
rename to selling/doctype/sales_bom_item/__init__.py
diff --git a/stock/doctype/sales_bom_item/sales_bom_item.py b/selling/doctype/sales_bom_item/sales_bom_item.py
similarity index 100%
rename from stock/doctype/sales_bom_item/sales_bom_item.py
rename to selling/doctype/sales_bom_item/sales_bom_item.py
diff --git a/stock/doctype/sales_bom_item/sales_bom_item.txt b/selling/doctype/sales_bom_item/sales_bom_item.txt
similarity index 93%
rename from stock/doctype/sales_bom_item/sales_bom_item.txt
rename to selling/doctype/sales_bom_item/sales_bom_item.txt
index 98285af1048..f7906b72d8b 100644
--- a/stock/doctype/sales_bom_item/sales_bom_item.txt
+++ b/selling/doctype/sales_bom_item/sales_bom_item.txt
@@ -1,15 +1,15 @@
[
{
- "creation": "2013-02-22 01:28:03",
+ "creation": "2013-05-23 16:55:51",
"docstatus": 0,
- "modified": "2013-03-07 07:03:30",
+ "modified": "2013-06-26 13:45:41",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "DocType",
"istable": 1,
- "module": "Stock",
+ "module": "Selling",
"name": "__common__"
},
{
diff --git a/selling/doctype/sms_center/sms_center.py b/selling/doctype/sms_center/sms_center.py
index c5db7383f72..7d50e712326 100644
--- a/selling/doctype/sms_center/sms_center.py
+++ b/selling/doctype/sms_center/sms_center.py
@@ -24,7 +24,7 @@ from webnotes.model.code import get_obj
from webnotes import msgprint
sql = webnotes.conn.sql
-
+
# ----------
class DocType:
@@ -45,17 +45,16 @@ class DocType:
elif self.doc.send_to == 'All Lead (Open)':
rec = sql("select lead_name, mobile_no from tabLead where ifnull(mobile_no,'')!='' and docstatus != 2 and status = 'Open'")
elif self.doc.send_to == 'All Employee (Active)':
- where_clause = self.doc.department and " and t1.department = '%s'" % self.doc.department or ""
- where_clause += self.doc.branch and " and t1.branch = '%s'" % self.doc.branch or ""
- rec = sql("select t1.employee_name, t2.cell_number from `tabEmployee` t1, `tabEmployee Profile` t2 where t2.employee = t1.name and t1.status = 'Active' and t1.docstatus != 2 and ifnull(t2.cell_number,'')!='' %s" % where_clause)
+ where_clause = self.doc.department and " and department = '%s'" % self.doc.department or ""
+ where_clause += self.doc.branch and " and branch = '%s'" % self.doc.branch or ""
+ rec = sql("select employee_name, cell_number from `tabEmployee` where status = 'Active' and docstatus < 2 and ifnull(cell_number,'')!='' %s" % where_clause)
elif self.doc.send_to == 'All Sales Person':
rec = sql("select sales_person_name, mobile_no from `tabSales Person` where docstatus != 2 and ifnull(mobile_no,'')!=''")
-
rec_list = ''
for d in rec:
rec_list += d[0] + ' - ' + d[1] + '\n'
self.doc.receiver_list = rec_list
-
+ webnotes.errprint(rec_list)
def get_receiver_nos(self):
receiver_nos = []
for d in self.doc.receiver_list.split('\n'):
diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js
index ef419c5ed19..388fa42f847 100644
--- a/selling/page/selling_home/selling_home.js
+++ b/selling/page/selling_home/selling_home.js
@@ -69,6 +69,11 @@ wn.module_page["Selling"] = [
description: wn._("Sales taxes template."),
doctype:"Sales Taxes and Charges Master"
},
+ {
+ label: wn._("Shipping Rules"),
+ description: wn._("Rules to calculate shipping amount for a sale"),
+ doctype:"Shipping Rule"
+ },
{
label: wn._("Price List"),
description: wn._("Mupltiple Item prices."),
@@ -168,13 +173,11 @@ wn.module_page["Selling"] = [
},
{
"label":wn._("Territory Target Variance (Item Group-Wise)"),
- route: "query-report/Territory Target Variance (Item Group-Wise)",
- doctype: "Sales Order"
+ route: "query-report/Territory Target Variance Item Group-Wise"
},
{
"label":wn._("Sales Person Target Variance (Item Group-Wise)"),
- route: "query-report/Sales Person Target Variance (Item Group-Wise)",
- doctype: "Sales Order"
+ route: "query-report/Sales Person Target Variance Item Group-Wise"
},
{
"label":wn._("Customers Not Buying Since Long Time"),
@@ -191,6 +194,10 @@ wn.module_page["Selling"] = [
route: "query-report/Sales Order Trends",
doctype: "Sales Order"
},
+ {
+ "label":wn._("Available Stock for Packing Items"),
+ route: "query-report/Available Stock for Packing Items",
+ },
{
"label":wn._("Pending SO Items For Purchase Request"),
route: "query-report/Pending SO Items For Purchase Request"
diff --git a/selling/report/available_stock_for_packing_items/__init__.py b/selling/report/available_stock_for_packing_items/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.py b/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.py
new file mode 100644
index 00000000000..171c3bb8d9a
--- /dev/null
+++ b/selling/report/available_stock_for_packing_items/available_stock_for_packing_items.py
@@ -0,0 +1,92 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see