Merge branch 'develop' of https://github.com/frappe/erpnext into deferred_revenue_multi_currency_jv
diff --git a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.js b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.js
index 305cddb..715cd64 100644
--- a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.js
+++ b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.js
@@ -117,6 +117,11 @@
"label": __("Show Future Payments"),
"fieldtype": "Check",
},
+ {
+ "fieldname":"show_gl_balance",
+ "label": __("Show GL Balance"),
+ "fieldtype": "Check",
+ },
],
onload: function(report) {
diff --git a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
index 3c94629..4559fa9 100644
--- a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
+++ b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
@@ -4,7 +4,8 @@
import frappe
from frappe import _, scrub
-from frappe.utils import cint
+from frappe.utils import cint, flt
+from six import iteritems
from erpnext.accounts.party import get_partywise_advanced_payment_amount
from erpnext.accounts.report.accounts_receivable.accounts_receivable import ReceivablePayableReport
@@ -36,7 +37,10 @@
party_advance_amount = get_partywise_advanced_payment_amount(self.party_type,
self.filters.report_date, self.filters.show_future_payments, self.filters.company) or {}
- for party, party_dict in self.party_total.items():
+ if self.filters.show_gl_balance:
+ gl_balance_map = get_gl_balance(self.filters.report_date)
+
+ for party, party_dict in iteritems(self.party_total):
if party_dict.outstanding == 0:
continue
@@ -55,6 +59,10 @@
# but in summary report advance shown in separate column
row.paid -= row.advance
+ if self.filters.show_gl_balance:
+ row.gl_balance = gl_balance_map.get(party)
+ row.diff = flt(row.outstanding) - flt(row.gl_balance)
+
self.data.append(row)
def get_party_total(self, args):
@@ -114,6 +122,10 @@
self.add_column(_(credit_debit_label), fieldname='credit_note')
self.add_column(_('Outstanding Amount'), fieldname='outstanding')
+ if self.filters.show_gl_balance:
+ self.add_column(_('GL Balance'), fieldname='gl_balance')
+ self.add_column(_('Difference'), fieldname='diff')
+
self.setup_ageing_columns()
if self.party_type == "Customer":
@@ -140,3 +152,7 @@
# Add column for total due amount
self.add_column(label="Total Amount Due", fieldname='total_due')
+
+def get_gl_balance(report_date):
+ return frappe._dict(frappe.db.get_all("GL Entry", fields=['party', 'sum(debit - credit)'],
+ filters={'posting_date': ("<=", report_date), 'is_cancelled': 0}, group_by='party', as_list=1))
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index ce5d5dc..eab9e12 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -113,7 +113,7 @@
_('{0} is blocked so this transaction cannot proceed').format(supplier_name), raise_exception=1)
def validate(self):
- if not self.get('is_return'):
+ if not self.get('is_return') and not self.get('is_debit_note'):
self.validate_qty_is_not_zero()
if self.get("_action") and self._action != "update_after_submit":
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 987fd31..075e3e3 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -139,6 +139,8 @@
if not item.qty and self.doc.get("is_return"):
item.amount = flt(-1 * item.rate, item.precision("amount"))
+ elif not item.qty and self.doc.get("is_debit_note"):
+ item.amount = flt(item.rate, item.precision("amount"))
else:
item.amount = flt(item.rate * item.qty, item.precision("amount"))
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 268db40..99741eb 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -165,7 +165,6 @@
erpnext.patches.v12_0.set_default_payroll_based_on
erpnext.patches.v12_0.repost_stock_ledger_entries_for_target_warehouse
erpnext.patches.v12_0.update_end_date_and_status_in_email_campaign
-erpnext.patches.v13_0.validate_options_for_data_field
erpnext.patches.v13_0.move_tax_slabs_from_payroll_period_to_income_tax_slab #123
erpnext.patches.v12_0.fix_quotation_expired_status
erpnext.patches.v12_0.rename_pos_closing_doctype
diff --git a/erpnext/patches/v13_0/validate_options_for_data_field.py b/erpnext/patches/v13_0/validate_options_for_data_field.py
deleted file mode 100644
index ad777b8..0000000
--- a/erpnext/patches/v13_0/validate_options_for_data_field.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (c) 2021, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-
-import frappe
-from frappe.model import data_field_options
-
-
-def execute():
-
- for field in frappe.get_all('Custom Field',
- fields = ['name'],
- filters = {
- 'fieldtype': 'Data',
- 'options': ['!=', None]
- }):
-
- if field not in data_field_options:
- frappe.db.sql("""
- UPDATE
- `tabCustom Field`
- SET
- options=NULL
- WHERE
- name=%s
- """, (field))
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index ff56be9..ae0e2a3 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -114,6 +114,8 @@
if ((!item.qty) && me.frm.doc.is_return) {
item.amount = flt(item.rate * -1, precision("amount", item));
+ } else if ((!item.qty) && me.frm.doc.is_debit_note) {
+ item.amount = flt(item.rate, precision("amount", item));
} else {
item.amount = flt(item.rate * item.qty, precision("amount", item));
}