Merge pull request #6489 from nabinhait/leave_application_fix
[fix] Validate leave application period with salary slip only if leave type is LWP
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index 685b8a7..db811cf 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -218,14 +218,16 @@
conditions, values = self.prepare_conditions(party_type)
if self.filters.get(scrub(party_type)):
- select_fields = "debit_in_account_currency as debit, credit_in_account_currency as credit"
+ select_fields = "sum(debit_in_account_currency) as debit, sum(credit_in_account_currency) as credit"
else:
- select_fields = "debit, credit"
+ select_fields = "sum(debit) as debit, sum(credit) as credit"
- self.gl_entries = frappe.db.sql("""select name, posting_date, account, party_type, party,
- voucher_type, voucher_no, against_voucher_type, against_voucher, account_currency, remarks, {0}
+ self.gl_entries = frappe.db.sql("""select name, posting_date, account, party_type, party,
+ voucher_type, voucher_no, against_voucher_type, against_voucher,
+ account_currency, remarks, {0}
from `tabGL Entry`
where docstatus < 2 and party_type=%s and (party is not null and party != '') {1}
+ group by voucher_type, voucher_no, against_voucher_type, against_voucher
order by posting_date, party"""
.format(select_fields, conditions), values, as_dict=True)
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index be0013e..253b319 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -308,6 +308,7 @@
erpnext.patches.v7_0.set_material_request_type_in_item
erpnext.patches.v7_0.rename_examination_to_assessment
erpnext.patches.v7_0.set_portal_settings
+erpnext.patches.v7_0.update_change_amount_account
erpnext.patches.v7_0.repost_future_gle_for_purchase_invoice
erpnext.patches.v7_0.fix_duplicate_icons
erpnext.patches.v7_0.repost_gle_for_pos_sales_return
diff --git a/erpnext/patches/v7_0/update_change_amount_account.py b/erpnext/patches/v7_0/update_change_amount_account.py
new file mode 100644
index 0000000..1741095
--- /dev/null
+++ b/erpnext/patches/v7_0/update_change_amount_account.py
@@ -0,0 +1,19 @@
+from __future__ import unicode_literals
+import frappe
+from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account
+
+def execute():
+ frappe.reload_doc('accounts', 'doctype', 'sales_invoice')
+
+ for company in frappe.db.sql("""select company from `tabSales Invoice`
+ where change_amount <> 0 and account_for_change_amount is null group by company""", as_list = 1):
+ cash_account = get_default_bank_cash_account(company[0], 'Cash').get('account')
+ if not cash_account:
+ bank_account = get_default_bank_cash_account(company[0], 'Bank').get('account')
+ cash_account = bank_account
+
+ if cash_account:
+ frappe.db.sql("""update `tabSales Invoice`
+ set account_for_change_amount = %(cash_account)s where change_amount <> 0
+ and company = %(company)s and account_for_change_amount is null""",
+ {'cash_account': cash_account, 'company': company[0]})