Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbauskar committed Jul 13, 2017
2 parents a8406e1 + 05d6212 commit 012f5b0
Show file tree
Hide file tree
Showing 95 changed files with 23,374 additions and 14,320 deletions.
2 changes: 1 addition & 1 deletion erpnext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import unicode_literals
import frappe

__version__ = '8.3.6'
__version__ = '8.4.0'

def get_default_company(user=None):
'''Get default company for user'''
Expand Down
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/pricing_rule/pricing_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def get_pricing_rule_for_item(args):
"discount_percentage": 0.0
})
else:
item_details.discount_percentage = pricing_rule.discount_percentage
item_details.discount_percentage = pricing_rule.discount_percentage or args.discount_percentage
elif args.get('pricing_rule'):
item_details = remove_pricing_rule_for_item(args.get("pricing_rule"), item_details)

Expand Down
50 changes: 49 additions & 1 deletion erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import unittest
import frappe
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
from erpnext.stock.get_item_details import get_item_details
from frappe import MandatoryError

Expand Down Expand Up @@ -248,4 +249,51 @@ def test_pricing_rule_for_stock_qty(self):
so.submit()
so = frappe.get_doc('Sales Order', so.name)
self.assertEquals(so.items[0].discount_percentage, 0)
self.assertEquals(so.items[0].rate, 100)
self.assertEquals(so.items[0].rate, 100)

def test_pricing_rule_with_margin_and_discount(self):
make_pricing_rule(selling=1, margin_type="Percentage", margin_rate_or_amount=10)
si = create_sales_invoice(do_not_save=True)
si.items[0].price_list_rate = 1000
si.insert(ignore_permissions=True)

item = si.items[0]
self.assertEquals(item.rate, 1100)
self.assertEquals(item.margin_rate_or_amount, 10)

# With discount
item.discount_percentage = 10
si.save()
item = si.items[0]
self.assertEquals(item.rate, 990)
self.assertEquals(item.discount_percentage, 10)
frappe.db.sql("delete from `tabPricing Rule`")

def make_pricing_rule(**args):
args = frappe._dict(args)

doc = frappe.get_doc({
"doctype": "Pricing Rule",
"title": args.title or "_Test Pricing Rule",
"company": args.company or "_Test Company",
"apply_on": args.apply_on or "Item Code",
"item_code": args.item_code or "_Test Item",
"applicable_for": args.applicable_for,
"selling": args.selling or 0,
"buying": args.buying or 0,
"min_qty": args.min_qty or 0.0,
"max_qty": args.max_qty or 0.0,
"price_or_discount": args.price_or_discount or "Discount Percentage",
"discount_percentage": args.discount_percentage or 0.0,
"price": args.price or 0.0,
"margin_type": args.margin_type,
"margin_rate_or_amount": args.margin_rate_or_amount or 0.0
}).insert(ignore_permissions=True)

apply_on = doc.apply_on.replace(' ', '_').lower()
if args.get(apply_on) and apply_on != "item_code":
doc.db_set(apply_on, args.get(apply_on))

applicable_for = doc.applicable_for.replace(' ', '_').lower()
if args.get(applicable_for):
doc.db_set(applicable_for, args.get(applicable_for))
4 changes: 2 additions & 2 deletions erpnext/accounts/page/pos/pos.js
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
} else if (item.barcode == me.serach_item.$input.val()) {
search_status = false;
return item.barcode == me.serach_item.$input.val();
} else if (reg.test(item.item_code.toLowerCase()) || reg.test(item.description.toLowerCase()) ||
} else if (reg.test(item.item_code.toLowerCase()) || (item.description && reg.test(item.description.toLowerCase())) ||
reg.test(item.item_name.toLowerCase()) || reg.test(item.item_group.toLowerCase())) {
return true
}
Expand Down Expand Up @@ -1351,7 +1351,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
this.child.item_name = this.items[0].item_name;
this.child.stock_uom = this.items[0].stock_uom;
this.child.brand = this.items[0].brand;
this.child.description = this.items[0].description;
this.child.description = this.items[0].description || this.items[0].item_name;
this.child.discount_percentage = 0.0;
this.child.qty = 1;
this.child.item_group = this.items[0].item_group;
Expand Down
12 changes: 7 additions & 5 deletions erpnext/accounts/party.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
from frappe import _, msgprint, scrub
from frappe.defaults import get_user_permissions
from frappe.model.utils import get_fetch_values
from frappe.utils import add_days, getdate, formatdate, get_first_day, date_diff, \
add_years, get_timestamp, nowdate, flt
from frappe.contacts.doctype.address.address import get_address_display, get_default_address
from frappe.utils import (add_days, getdate, formatdate, get_first_day, date_diff,
add_years, get_timestamp, nowdate, flt)
from frappe.contacts.doctype.address.address import (get_address_display,
get_default_address, get_company_address)
from frappe.contacts.doctype.contact.contact import get_contact_details, get_default_contact
from erpnext.exceptions import PartyFrozen, PartyDisabled, InvalidAccountCurrency
from erpnext.accounts.utils import get_fiscal_year
Expand Down Expand Up @@ -77,8 +78,9 @@ def set_address_details(out, party, party_type, doctype=None, company=None):
out.update(get_fetch_values(doctype, 'shipping_address_name', out.shipping_address_name))

if doctype and doctype in ['Sales Invoice']:
out.company_address = get_default_address('Company', company)
out.update(get_fetch_values(doctype, 'company_address', out.company_address))
out.update(get_company_address(company))
if out.company_address:
out.update(get_fetch_values(doctype, 'company_address', out.company_address))

def set_contact_details(out, party, party_type):
out.contact_person = get_default_contact(party_type, party.name)
Expand Down
Loading

0 comments on commit 012f5b0

Please sign in to comment.