Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sf_trading/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"/assets/sf_trading/js/sales_invoice_barcode.js",
"/assets/sf_trading/js/sales_invoice_inter_company.js",
"/assets/sf_trading/js/sales_invoice_pos_total_popup.js",
"/assets/sf_trading/js/work_flow_rejection.js",
"/assets/sf_trading/js/workflow_approval_shortcut.js",
]

# include js, css files in header of web template
Expand Down
62 changes: 62 additions & 0 deletions sf_trading/public/js/workflow_approval_shortcut.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// /sf_trading/sf_trading/public/js/workflow_approval_shortcut.js
// Adds a pending count badge next to the "Work Flow Approval" shortcut
// on any workspace, matching the native ERPNext shortcut count style.

frappe.provide("sf_trading.wf_shortcut");

sf_trading.wf_shortcut.update_count = function() {
let $links = $('.shortcut-widget-box a, .widget.shortcut-widget-box .widget-title')
.filter(function() {
return $(this).text().trim().toLowerCase().includes("work flow approval")
|| $(this).text().trim().toLowerCase().includes("workflow approval");
});

if (!$links.length) return;

frappe.call({
method: "sf_trading.sf_trading.report.work_flow_approval.work_flow_approval.get_pending_approval_count",
callback: function(r) {
let count = r.message || 0;

$('.shortcut-widget-box').each(function() {
let $box = $(this);
let txt = $box.find('.widget-title, a').first().text().trim().toLowerCase();
if (!txt.includes("work flow approval") && !txt.includes("workflow approval")) return;

// Remove any previous injected badge
$box.find('.wf-pending-count').remove();

// Build badge in the same style as ERPNext's native shortcut count
let $badge = $(`<span class="wf-pending-count" style="
display:inline-block;
margin-left:8px;
padding:2px 8px;
background:#f4f5f6;
color:${count > 0 ? '#e24c4c' : '#525252'};
border-radius:8px;
font-size:12px;
font-weight:500;
vertical-align:middle;
">${count}</span>`);

// Append to the title/link
let $target = $box.find('.widget-title').first();
if (!$target.length) $target = $box.find('a').first();
$target.append($badge);
});
}
});
};

// Run after route changes (workspace navigation) and on initial load
$(document).on("page-change app_ready", function() {
setTimeout(sf_trading.wf_shortcut.update_count, 600);
setTimeout(sf_trading.wf_shortcut.update_count, 1500); // retry for slow loads
});

frappe.after_ajax(function() {
setTimeout(sf_trading.wf_shortcut.update_count, 1000);
});

// Refresh every 60 seconds while the page is open
setInterval(sf_trading.wf_shortcut.update_count, 60000);
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (c) 2026, Enfono and contributors
// For license information, please see license.txt

frappe.ui.form.on("Branch Configuration", {
refresh(frm) {
set_child_filters(frm);
},
company(frm) {
set_child_filters(frm);

// Clear warehouse + cost center + account fields when company changes
// (they may belong to the old company)
if (frm.doc.warehouse && frm.doc.warehouse.length) {
frm.clear_table("warehouse");
frm.refresh_field("warehouse");
}
if (frm.doc.cost_center && frm.doc.cost_center.length) {
frm.clear_table("cost_center");
frm.refresh_field("cost_center");
}
// MoPs are global, not company-bound — no need to clear on company change.
}
});

function set_child_filters(frm) {
frm.set_query("warehouse", "warehouse", function () {
return {
filters: {
company: frm.doc.company,
is_group: 0
}
};
});

frm.set_query("cost_center", "cost_center", function () {
return {
filters: {
company: frm.doc.company,
is_group: 0
}
};
});

frm.set_query("mode_of_payment", "mode_of_payment", function () {
return { filters: { type: ["in", ["Cash", "Bank"]] } };
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2026-05-04 18:33:59.085305",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"branch",
"column_break_jvyk",
"company",
"mode_of_payment_section",
"mode_of_payment",
"warehouse",
"cost_center",
"user"
],
"fields": [
{
"fieldname": "branch",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Branch",
"options": "Branch",
"reqd": 1
},
{
"fieldname": "column_break_jvyk",
"fieldtype": "Column Break"
},
{
"fieldname": "company",
"fieldtype": "Link",
"label": "Company",
"options": "Company"
},
{
"fieldname": "mode_of_payment_section",
"fieldtype": "Section Break",
"label": "Mode of Payment"
},
{
"description": "Cash + Bank Modes of Payment allowed for this branch. On Sales Invoice for Branch Users,payment rows whose MoP type is Cash or Bank are constrained to this list (or swapped to the first matching row); BNPL is left untouched.",
"fieldname": "mode_of_payment",
"fieldtype": "Table",
"label": "Mode of Payment",
"options": "Mode of Payment Account"
},
{
"fieldname": "warehouse",
"fieldtype": "Table",
"label": "Warehouse",
"options": "Branch Configuration Warehouse"
},
{
"fieldname": "cost_center",
"fieldtype": "Table",
"label": "Cost Center",
"options": "Branch Configuration Cost Center"
},
{
"fieldname": "user",
"fieldtype": "Table",
"label": "User",
"options": "Branch Configuration User"
}
],
"grid_page_length": 50,
"index_web_pages_for_search": 1,
"links": [],
"modified": "2026-05-04 18:42:48.031006",
"modified_by": "Administrator",
"module": "Sf Trading",
"name": "Branch Configuration",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"row_format": "Dynamic",
"rows_threshold_for_grid_search": 20,
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
Loading
Loading