Merge pull request #9772 from tundebabzy/issue-9595
Wrong Exchange Rate when making payment against Journal Entry (#9595)
diff --git a/erpnext/accounts/doctype/budget/budget.py b/erpnext/accounts/doctype/budget/budget.py
index a6348f1..f99d0bb 100644
--- a/erpnext/accounts/doctype/budget/budget.py
+++ b/erpnext/accounts/doctype/budget/budget.py
@@ -83,7 +83,7 @@
budget_records = frappe.db.sql("""
select
- b.{budget_against_field}, ba.budget_amount, b.monthly_distribution,
+ b.{budget_against_field} as budget_against, ba.budget_amount, b.monthly_distribution,
b.action_if_annual_budget_exceeded,
b.action_if_accumulated_monthly_budget_exceeded
from
@@ -111,15 +111,15 @@
args["month_end_date"] = get_last_day(args.posting_date)
compare_expense_with_budget(args, budget_amount,
- _("Accumulated Monthly"), monthly_action)
+ _("Accumulated Monthly"), monthly_action, budget.budget_against)
if yearly_action in ("Stop", "Warn") and monthly_action != "Stop" \
and yearly_action != monthly_action:
compare_expense_with_budget(args, flt(budget.budget_amount),
- _("Annual"), yearly_action)
+ _("Annual"), yearly_action, budget.budget_against)
-def compare_expense_with_budget(args, budget_amount, action_for, action):
+def compare_expense_with_budget(args, budget_amount, action_for, action, budget_against):
actual_expense = get_actual_expense(args)
if actual_expense > budget_amount:
diff = actual_expense - budget_amount
@@ -127,7 +127,7 @@
msg = _("{0} Budget for Account {1} against {2} {3} is {4}. It will exceed by {5}").format(
_(action_for), frappe.bold(args.account), args.budget_against_field,
- frappe.bold(args.budget_against),
+ frappe.bold(budget_against),
frappe.bold(fmt_money(budget_amount, currency=currency)),
frappe.bold(fmt_money(diff, currency=currency)))
diff --git a/erpnext/accounts/doctype/budget/test_budget.py b/erpnext/accounts/doctype/budget/test_budget.py
index 15895dc..f6849ba 100644
--- a/erpnext/accounts/doctype/budget/test_budget.py
+++ b/erpnext/accounts/doctype/budget/test_budget.py
@@ -140,6 +140,33 @@
budget.load_from_db()
budget.cancel()
+ def test_monthly_budget_against_parent_group_cost_center(self):
+ cost_center = "_Test Cost Center 3 - _TC"
+
+ if not frappe.db.exists("Cost Center", cost_center):
+ frappe.get_doc({
+ 'doctype': 'Cost Center',
+ 'cost_center_name': '_Test Cost Center 3',
+ 'parent_cost_center': "_Test Company - _TC",
+ 'company': '_Test Company',
+ 'is_group': 0
+ }).insert(ignore_permissions=True)
+
+ budget = make_budget("Cost Center", cost_center)
+ frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop")
+
+ jv = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
+ "_Test Bank - _TC", 40000, cost_center)
+
+ self.assertRaises(BudgetError, jv.submit)
+
+ budget.load_from_db()
+ budget.cancel()
+ jv.cancel()
+
+ frappe.delete_doc('Journal Entry', jv.name)
+ frappe.delete_doc('Cost Center', cost_center)
+
def set_total_expense_zero(posting_date, budget_against_field=None, budget_against_CC=None):
if budget_against_field == "Project":
budget_against = "_Test Project"
@@ -167,7 +194,8 @@
if budget_against == "Project":
budget_list = frappe.get_all("Budget", fields=["name"], filters = {"name": ("like", "_Test Project/_Test Fiscal Year 2013%")})
else:
- budget_list = frappe.get_all("Budget", fields=["name"], filters = {"name": ("like", "_Test Cost Center - _TC/_Test Fiscal Year 2013%")})
+ cost_center_name = "{0}%".format(cost_center or "_Test Cost Center - _TC/_Test Fiscal Year 2013")
+ budget_list = frappe.get_all("Budget", fields=["name"], filters = {"name": ("like", cost_center_name)})
for d in budget_list:
frappe.db.sql("delete from `tabBudget` where name = %(name)s", d)
frappe.db.sql("delete from `tabBudget Account` where parent = %(name)s", d)
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js
index 5bfd4d9..63832fa 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.js
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js
@@ -291,37 +291,39 @@
set_account_currency_and_balance: function(frm, account, currency_field,
balance_field, callback_function) {
- frappe.call({
- method: "erpnext.accounts.doctype.payment_entry.payment_entry.get_account_details",
- args: {
- "account": account,
- "date": frm.doc.posting_date
- },
- callback: function(r, rt) {
- if(r.message) {
- frm.set_value(currency_field, r.message['account_currency']);
- frm.set_value(balance_field, r.message['account_balance']);
+ if (frm.doc.posting_date) {
+ frappe.call({
+ method: "erpnext.accounts.doctype.payment_entry.payment_entry.get_account_details",
+ args: {
+ "account": account,
+ "date": frm.doc.posting_date
+ },
+ callback: function(r, rt) {
+ if(r.message) {
+ frm.set_value(currency_field, r.message['account_currency']);
+ frm.set_value(balance_field, r.message['account_balance']);
- if(frm.doc.payment_type=="Receive" && currency_field=="paid_to_account_currency") {
- frm.toggle_reqd(["reference_no", "reference_date"],
- (r.message['account_type'] == "Bank" ? 1 : 0));
- if(!frm.doc.received_amount && frm.doc.paid_amount)
- frm.events.paid_amount(frm);
- } else if(frm.doc.payment_type=="Pay" && currency_field=="paid_from_account_currency") {
- frm.toggle_reqd(["reference_no", "reference_date"],
- (r.message['account_type'] == "Bank" ? 1 : 0));
+ if(frm.doc.payment_type=="Receive" && currency_field=="paid_to_account_currency") {
+ frm.toggle_reqd(["reference_no", "reference_date"],
+ (r.message['account_type'] == "Bank" ? 1 : 0));
+ if(!frm.doc.received_amount && frm.doc.paid_amount)
+ frm.events.paid_amount(frm);
+ } else if(frm.doc.payment_type=="Pay" && currency_field=="paid_from_account_currency") {
+ frm.toggle_reqd(["reference_no", "reference_date"],
+ (r.message['account_type'] == "Bank" ? 1 : 0));
- if(!frm.doc.paid_amount && frm.doc.received_amount)
- frm.events.received_amount(frm);
+ if(!frm.doc.paid_amount && frm.doc.received_amount)
+ frm.events.received_amount(frm);
+ }
+
+ if(callback_function) callback_function(frm);
+
+ frm.events.hide_unhide_fields(frm);
+ frm.events.set_dynamic_labels(frm);
}
-
- if(callback_function) callback_function(frm);
-
- frm.events.hide_unhide_fields(frm);
- frm.events.set_dynamic_labels(frm);
}
- }
- });
+ });
+ }
},
paid_from_account_currency: function(frm) {
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice_dashboard.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice_dashboard.py
index bfe00ef..bc9d766 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice_dashboard.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice_dashboard.py
@@ -11,8 +11,7 @@
'Sales Invoice': 'return_against'
},
'internal_links': {
- 'Sales Order': ['items', 'sales_order'],
- 'Delivery Note': ['items', 'delivery_note']
+ 'Sales Order': ['items', 'sales_order']
},
'transactions': [
{
diff --git a/erpnext/docs/assets/img/setup/sms-setting2.jpg b/erpnext/docs/assets/img/setup/sms-settings2.jpg
similarity index 100%
rename from erpnext/docs/assets/img/setup/sms-setting2.jpg
rename to erpnext/docs/assets/img/setup/sms-settings2.jpg
Binary files differ
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.json b/erpnext/manufacturing/doctype/production_order/production_order.json
index ee033c4..e56e5a1 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.json
+++ b/erpnext/manufacturing/doctype/production_order/production_order.json
@@ -1358,7 +1358,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2017-06-13 14:29:00.457874",
+ "modified": "2017-07-10 14:29:00.457874",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Production Order",
diff --git a/erpnext/manufacturing/doctype/production_order_item/production_order_item.json b/erpnext/manufacturing/doctype/production_order_item/production_order_item.json
index 06a7876..00e3adf 100644
--- a/erpnext/manufacturing/doctype/production_order_item/production_order_item.json
+++ b/erpnext/manufacturing/doctype/production_order_item/production_order_item.json
@@ -353,7 +353,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2017-05-15 17:37:20.212361",
+ "modified": "2017-07-10 17:37:20.212361",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Production Order Item",
diff --git a/erpnext/patches/v8_0/merge_student_batch_and_student_group.py b/erpnext/patches/v8_0/merge_student_batch_and_student_group.py
index 7cfdf60..c5654eb 100644
--- a/erpnext/patches/v8_0/merge_student_batch_and_student_group.py
+++ b/erpnext/patches/v8_0/merge_student_batch_and_student_group.py
@@ -9,8 +9,8 @@
def execute():
# for converting student batch into student group
- for doctype in ["Student Group", "Student Group Student", "Student Group Instructor", "Student Attendance"]:
- frappe.reload_doc("schools", "doctype", doctype)
+ for doctype in ["Student Group", "Student Group Student", "Student Group Instructor", "Student Attendance", "Student"]:
+ frappe.reload_doc("schools", "doctype", frappe.scrub(doctype))
if frappe.db.table_exists("Student Batch"):
student_batches = frappe.db.sql('''select name as student_group_name, student_batch_name as batch,
diff --git a/erpnext/patches/v8_1/setup_gst_india.py b/erpnext/patches/v8_1/setup_gst_india.py
index ce27d37..5660693 100644
--- a/erpnext/patches/v8_1/setup_gst_india.py
+++ b/erpnext/patches/v8_1/setup_gst_india.py
@@ -5,6 +5,7 @@
frappe.reload_doc('regional', 'doctype', 'gst_settings')
frappe.reload_doc('regional', 'doctype', 'gst_hsn_code')
frappe.reload_doc('stock', 'doctype', 'item')
+ frappe.reload_doc("stock", "doctype", "customs_tariff_number")
for report_name in ('GST Sales Register', 'GST Purchase Register',
'GST Itemised Sales Register', 'GST Itemised Purchase Register'):
diff --git a/erpnext/schools/doctype/program_enrollment/program_enrollment.json b/erpnext/schools/doctype/program_enrollment/program_enrollment.json
index 0203b2c..f8a3b9e 100644
--- a/erpnext/schools/doctype/program_enrollment/program_enrollment.json
+++ b/erpnext/schools/doctype/program_enrollment/program_enrollment.json
@@ -143,9 +143,10 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "default": "Today",
- "fieldname": "enrollment_date",
- "fieldtype": "Date",
+ "default": "0",
+ "description": "Check this if the Student is residing at the Institute's Hostel.",
+ "fieldname": "boarding_student",
+ "fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@@ -153,9 +154,10 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
- "label": "Enrollment Date",
+ "label": "Boarding Student",
"length": 0,
"no_copy": 0,
+ "options": "",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@@ -163,7 +165,7 @@
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
- "reqd": 1,
+ "reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
@@ -325,6 +327,37 @@
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "default": "Today",
+ "fieldname": "enrollment_date",
+ "fieldtype": "Date",
+ "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": "Enrollment Date",
+ "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": 1,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
"collapsible": 1,
"collapsible_depends_on": "vehicle_no",
"columns": 0,
@@ -370,7 +403,7 @@
"label": "Mode of Transportation",
"length": 0,
"no_copy": 0,
- "options": "\nSchool Bus\nPublic Transport\nSelf-Driving Vehicle\nPick/Drop by Guardian",
+ "options": "\nWalking\nSchool Bus\nPublic Transport\nSelf-Driving Vehicle\nPick/Drop by Guardian",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@@ -638,7 +671,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2017-06-30 08:21:49.430996",
+ "modified": "2017-07-10 18:16:15.810616",
"modified_by": "Administrator",
"module": "Schools",
"name": "Program Enrollment",
diff --git a/erpnext/schools/doctype/student/student.json b/erpnext/schools/doctype/student/student.json
index fa6db0d..75cb758 100644
--- a/erpnext/schools/doctype/student/student.json
+++ b/erpnext/schools/doctype/student/student.json
@@ -595,67 +595,6 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fieldname": "section_break_18",
- "fieldtype": "Section Break",
- "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": "Guardian Details",
- "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
- },
- {
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "guardians",
- "fieldtype": "Table",
- "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": "Guardians",
- "length": 0,
- "no_copy": 0,
- "options": "Student Guardian",
- "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
- },
- {
- "allow_bulk_edit": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
"fieldname": "section_break_22",
"fieldtype": "Section Break",
"hidden": 0,
@@ -863,6 +802,67 @@
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "section_break_18",
+ "fieldtype": "Section Break",
+ "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": "Guardian Details",
+ "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
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "guardians",
+ "fieldtype": "Table",
+ "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": "Guardians",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Student Guardian",
+ "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
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
"collapsible": 1,
"columns": 0,
"fieldname": "section_break_20",
@@ -1114,7 +1114,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2017-06-30 08:21:50.423784",
+ "modified": "2017-07-07 16:30:08.930882",
"modified_by": "Administrator",
"module": "Schools",
"name": "Student",
diff --git a/erpnext/schools/doctype/student/student_dashboard.py b/erpnext/schools/doctype/student/student_dashboard.py
index cd2314e..b36599c 100644
--- a/erpnext/schools/doctype/student/student_dashboard.py
+++ b/erpnext/schools/doctype/student/student_dashboard.py
@@ -7,10 +7,24 @@
'fieldname': 'student',
'transactions': [
{
- 'items': ['Student Log', 'Student Group', 'Program Enrollment']
+ 'label': _('Admission'),
+ 'items': ['Program Enrollment']
},
{
- 'items': ['Fees', 'Assessment Result', 'Student Attendance', 'Student Leave Application']
+ 'label': _('Student Activity'),
+ 'items': ['Student Log', 'Student Group', ]
+ },
+ {
+ 'label': _('Assessment'),
+ 'items': ['Assessment Result']
+ },
+ {
+ 'label': _('Attendance'),
+ 'items': ['Student Attendance', 'Student Leave Application']
+ },
+ {
+ 'label': _('Fee'),
+ 'items': ['Fees']
}
]
}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
index 5f1e944..aca77a5 100755
--- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
+++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
@@ -1597,7 +1597,7 @@
"collapsible": 0,
"columns": 0,
"default": ":Company",
- "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)",
+ "depends_on": "eval:cint(erpnext.is_perpetual_inventory_enabled(parent.company))",
"fieldname": "cost_center",
"fieldtype": "Link",
"hidden": 0,
@@ -2044,7 +2044,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2017-06-16 17:23:01.404744",
+ "modified": "2017-07-10 06:31:31.457497",
"modified_by": "Administrator",
"module": "Stock",
"name": "Purchase Receipt Item",
diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py
index 8420c9b..fe158c9 100644
--- a/erpnext/stock/doctype/serial_no/serial_no.py
+++ b/erpnext/stock/doctype/serial_no/serial_no.py
@@ -85,6 +85,10 @@
self.supplier, self.supplier_name = \
frappe.db.get_value("Purchase Receipt", purchase_sle.voucher_no,
["supplier", "supplier_name"])
+
+ # If sales return entry
+ if self.purchase_document_type == 'Delivery Note':
+ self.sales_invoice = None
else:
for fieldname in ("purchase_document_type", "purchase_document_no",
"purchase_date", "purchase_time", "purchase_rate", "supplier", "supplier_name"):
diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
index ec14aab..6afb54e 100644
--- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
+++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
@@ -960,7 +960,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "depends_on": "eval:cint(frappe.sys_defaults.auto_accounting_for_stock)",
+ "depends_on": "eval:cint(erpnext.is_perpetual_inventory_enabled(parent.company))",
"fieldname": "expense_account",
"fieldtype": "Link",
"hidden": 0,
@@ -1020,7 +1020,7 @@
"collapsible": 0,
"columns": 0,
"default": ":Company",
- "depends_on": "eval:cint(frappe.sys_defaults.auto_accounting_for_stock)",
+ "depends_on": "eval:cint(erpnext.is_perpetual_inventory_enabled(parent.company))",
"fieldname": "cost_center",
"fieldtype": "Link",
"hidden": 0,
@@ -1266,7 +1266,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
- "modified": "2017-06-16 17:32:56.989049",
+ "modified": "2017-07-10 06:29:22.805345",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Entry Detail",