mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-25 20:08:34 +00:00
fix: show contextual balance label on party dashboard for net balances
(cherry picked from commit 3251b40365)
This commit is contained in:
@@ -922,6 +922,15 @@ def get_dashboard_info(party_type, party, loyalty_program=None):
|
||||
if party_type == "Supplier":
|
||||
info["total_unpaid"] = -1 * info["total_unpaid"]
|
||||
|
||||
if info["total_unpaid"] < 0:
|
||||
info["balance_label"] = (
|
||||
"Total Advance Paid" if party_type == "Supplier" else "Total Advance Received"
|
||||
)
|
||||
info["balance_amount"] = abs(info["total_unpaid"])
|
||||
else:
|
||||
info["balance_label"] = "Total Unpaid"
|
||||
info["balance_amount"] = info["total_unpaid"]
|
||||
|
||||
company_wise_info.append(info)
|
||||
|
||||
return company_wise_info
|
||||
|
||||
@@ -93,11 +93,19 @@ $.extend(erpnext.utils, {
|
||||
]),
|
||||
"blue"
|
||||
);
|
||||
var info = company_wise_info[0];
|
||||
var is_advance = info.balance_label !== "Total Unpaid";
|
||||
var indicator_label =
|
||||
info.balance_label === "Total Advance Paid"
|
||||
? __("Total Advance Paid: {0}", [format_currency(info.balance_amount, info.currency)])
|
||||
: info.balance_label === "Total Advance Received"
|
||||
? __("Total Advance Received: {0}", [
|
||||
format_currency(info.balance_amount, info.currency),
|
||||
])
|
||||
: __("Total Unpaid: {0}", [format_currency(info.balance_amount, info.currency)]);
|
||||
frm.dashboard.add_indicator(
|
||||
__("Total Unpaid: {0}", [
|
||||
format_currency(company_wise_info[0].total_unpaid, company_wise_info[0].currency),
|
||||
]),
|
||||
company_wise_info[0].total_unpaid ? "orange" : "green"
|
||||
indicator_label,
|
||||
is_advance ? "green" : info.balance_amount ? "orange" : "green"
|
||||
);
|
||||
|
||||
if (company_wise_info[0].loyalty_points) {
|
||||
@@ -140,7 +148,14 @@ $.extend(erpnext.utils, {
|
||||
frm.dashboard.stats_area_row.addClass("flex");
|
||||
frm.dashboard.stats_area_row.css("flex-wrap", "wrap");
|
||||
|
||||
var color = info.total_unpaid ? "orange" : "green";
|
||||
var is_advance = info.balance_label !== "Total Unpaid";
|
||||
var color = is_advance ? "green" : info.balance_amount ? "orange" : "green";
|
||||
var balance_label_text =
|
||||
info.balance_label === "Total Advance Paid"
|
||||
? __("Total Advance Paid")
|
||||
: info.balance_label === "Total Advance Received"
|
||||
? __("Total Advance Received")
|
||||
: __("Total Unpaid");
|
||||
|
||||
var indicator = $(
|
||||
'<div class="flex-column col-xs-6">' +
|
||||
@@ -154,8 +169,10 @@ $.extend(erpnext.utils, {
|
||||
'<div class="badge-link small" style="margin-bottom:10px">' +
|
||||
'<span class="indicator ' +
|
||||
color +
|
||||
'">Total Unpaid: ' +
|
||||
format_currency(info.total_unpaid, info.currency) +
|
||||
'">' +
|
||||
balance_label_text +
|
||||
": " +
|
||||
format_currency(info.balance_amount, info.currency) +
|
||||
"</span></div>" +
|
||||
"</div>"
|
||||
).appendTo(frm.dashboard.stats_area_row);
|
||||
|
||||
Reference in New Issue
Block a user