Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nabinhait committed Apr 20, 2017
2 parents ed01912 + 9afb532 commit 5650bf9
Show file tree
Hide file tree
Showing 46 changed files with 406 additions and 108 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.0.13'
__version__ = '8.0.14'

def get_default_company(user=None):
'''Get default company for user'''
Expand Down
64 changes: 60 additions & 4 deletions erpnext/accounts/doctype/accounts_settings/accounts_settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"beta": 0,
Expand All @@ -25,14 +26,17 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Make Accounting Entry For Every Stock Movement",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
Expand All @@ -51,14 +55,17 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Accounts Frozen Upto",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
Expand All @@ -77,7 +84,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Role Allowed to Set Frozen Accounts & Edit Frozen Entries",
"length": 0,
"no_copy": 0,
Expand All @@ -86,6 +95,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
Expand All @@ -103,14 +113,17 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
Expand All @@ -129,7 +142,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Credit Controller",
"length": 0,
"no_copy": 0,
Expand All @@ -138,6 +153,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
Expand All @@ -155,7 +171,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Check Supplier Invoice Number Uniqueness",
"length": 0,
"no_copy": 0,
Expand All @@ -164,6 +182,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
Expand All @@ -181,7 +200,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Make Payment via Journal Entry",
"length": 0,
"no_copy": 0,
Expand All @@ -190,6 +211,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
Expand All @@ -208,7 +230,9 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Unlink Payment on Cancellation of Invoice",
"length": 0,
"no_copy": 0,
Expand All @@ -217,25 +241,56 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "1",
"fieldname": "book_asset_depreciation_entry_automatically",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Book Asset Depreciation Entry Automatically",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "fa fa-cog",
"icon": "icon-cog",
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 1,
"istable": 0,
"max_attachments": 0,
"modified": "2016-10-20 16:12:38.595075",
"modified": "2017-04-18 13:35:59.166250",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounts Settings",
Expand All @@ -251,7 +306,6 @@
"export": 0,
"if_owner": 0,
"import": 0,
"is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
Expand All @@ -266,6 +320,8 @@
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_order": "ASC",
"track_changes": 1,
"track_seen": 0
}
4 changes: 4 additions & 0 deletions erpnext/accounts/doctype/asset/depreciation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
from frappe.utils import flt, today, getdate

def post_depreciation_entries(date=None):
# Return if automatic booking of asset depreciation is disabled
if not frappe.db.get_value("Accounts Settings", None, "book_asset_depreciation_entry_automatically"):
return

if not date:
date = today()
for asset in get_depreciable_assets(date):
Expand Down
22 changes: 21 additions & 1 deletion erpnext/accounts/doctype/asset/test_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,23 @@ def test_depreciation(self):

self.assertEqual(gle, expected_gle)
self.assertEqual(asset.get("value_after_depreciation"), 70000)

def test_depreciation_entry_cancellation(self):
asset = frappe.get_doc("Asset", "Macbook Pro 1")
asset.submit()
post_depreciation_entries(date="2021-01-01")

asset.load_from_db()

# cancel depreciation entry
depr_entry = asset.get("schedules")[0].journal_entry
self.assertTrue(depr_entry)
frappe.get_doc("Journal Entry", depr_entry).cancel()

asset.load_from_db()
depr_entry = asset.get("schedules")[0].journal_entry
self.assertFalse(depr_entry)


def test_scrap_asset(self):
asset = frappe.get_doc("Asset", "Macbook Pro 1")
Expand Down Expand Up @@ -297,4 +314,7 @@ def set_depreciation_settings_in_company():
company.depreciation_expense_account = "_Test Depreciations - _TC"
company.disposal_account = "_Test Gain/Loss on Asset Disposal - _TC"
company.depreciation_cost_center = "_Test Cost Center - _TC"
company.save()
company.save()

# Enable booking asset depreciation entry automatically
frappe.db.set_value("Accounts Settings", None, "book_asset_depreciation_entry_automatically", 1)
13 changes: 13 additions & 0 deletions erpnext/accounts/doctype/journal_entry/journal_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def on_cancel(self):
self.update_expense_claim()
self.update_employee_loan()
self.unlink_advance_entry_reference()
self.unlink_asset_reference()

def unlink_advance_entry_reference(self):
for d in self.get("accounts"):
Expand All @@ -81,6 +82,18 @@ def unlink_advance_entry_reference(self):
d.reference_type = ''
d.reference_name = ''
d.db_update()

def unlink_asset_reference(self):
for d in self.get("accounts"):
if d.reference_type=="Asset" and d.reference_name:
asset = frappe.get_doc("Asset", d.reference_name)
for s in asset.get("schedules"):
if s.journal_entry == self.name:
s.db_set("journal_entry", None)
asset.value_after_depreciation += s.depreciation_amount

asset.db_set("value_after_depreciation", asset.value_after_depreciation)
asset.set_status()

def validate_party(self):
for d in self.get("accounts"):
Expand Down
6 changes: 4 additions & 2 deletions erpnext/accounts/doctype/pricing_rule/pricing_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def validate(self):
self.validate_price_or_discount()
self.validate_max_discount()

if not self.margin_type: self.margin_rate_or_amount = 0.0

def validate_mandatory(self):
for field in ["apply_on", "applicable_for"]:
tocheck = frappe.scrub(self.get(field) or "")
Expand Down Expand Up @@ -143,7 +145,7 @@ def get_pricing_rule_for_item(args):
})

if args.ignore_pricing_rule or not args.item_code:
if frappe.db.exists(args.doctype, args.name) and args.get("pricing_rule"):
if args.get("pricing_rule"):
item_details = remove_pricing_rule(args, item_details)
return item_details

Expand Down Expand Up @@ -178,7 +180,7 @@ def get_pricing_rule_for_item(args):
item_details.margin_rate_or_amount = pricing_rule.margin_rate_or_amount
if pricing_rule.price_or_discount == "Price":
item_details.update({
"price_list_rate": pricing_rule.price/flt(args.conversion_rate) \
"price_list_rate": (pricing_rule.price/flt(args.conversion_rate)) * args.conversion_factor or 1.0 \
if args.conversion_rate else 0.0,
"discount_percentage": 0.0
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@
"unique": 0
},
{
"allow_on_submit": 1,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
Expand Down Expand Up @@ -1508,7 +1508,7 @@
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
Expand Down Expand Up @@ -1939,7 +1939,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2017-04-17 13:44:17.460674",
"modified": "2017-04-19 11:54:16.112134",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice Item",
Expand All @@ -1953,4 +1953,4 @@
"sort_order": "DESC",
"track_changes": 0,
"track_seen": 0
}
}
Loading

0 comments on commit 5650bf9

Please sign in to comment.