Skip to content
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
20503a5
feat: e-Waybill bulk actions in Delivery Note
ljain112 Dec 12, 2025
fd8f30a
refactor: better code organization and consistent naming
ljain112 Dec 13, 2025
5e1e3a0
fix: ensure callback is only called with non-empty submitted document…
ljain112 Dec 13, 2025
6cfd72f
fix: always parse values for converting it to frappe._dict
ljain112 Dec 13, 2025
53974cd
fix: enhance e-Waybill validation for sub_supply_type and add tests f…
ljain112 Dec 13, 2025
79f17c7
fix: update sub_supply_type in test e-Waybill
ljain112 Dec 13, 2025
65b7fa8
fix: remove unnecessary call to send_updated_doc in generate_e_waybil…
ljain112 Dec 13, 2025
e301f4e
fix: update subSupplyType value in test e-Waybill
ljain112 Dec 13, 2025
ac1503d
fix: correct setting fields
ljain112 Dec 13, 2025
1acc4fc
fix: refactor get_sub_supply_type_options and related functions for c…
ljain112 Dec 13, 2025
e654e84
fix: add is_foreign_transaction function in e_waybill actions
ljain112 Dec 13, 2025
5a9ea84
fix: translation
ljain112 Dec 13, 2025
0e928db
fix: option to update transporter details while generating e-waybill
ljain112 Jan 5, 2026
bbeaea2
fix: changes as per review
ljain112 Jan 5, 2026
26eb20c
refactor: double translation
ljain112 Jan 5, 2026
c8b3690
refactor: refactor transporter fields to separate part A and part B a…
ljain112 Jan 5, 2026
6c44a4c
refactor: move bulk e-invoice actions from e-waybill script to e-invo…
ljain112 Jan 6, 2026
f92114f
test: fix test case
ljain112 Jan 6, 2026
411ecc3
refactor: use existing util for generating e-waybill
ljain112 Jan 20, 2026
7500ca2
fix: update transporter details conditionally
ljain112 Jan 20, 2026
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
95 changes: 95 additions & 0 deletions india_compliance/gst_india/client_scripts/bulk_actions_utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/********
* Shared Utility Functions for Bulk Actions
*******/

function add_bulk_action_for_documents(list_view, label, callback, allowed_status) {
if (!allowed_status) allowed_status = [1];
list_view.page.add_actions_menu_item(label, async () => {
const selected_docs = list_view.get_checked_items();
const submitted_docs = await validate_doc_status(selected_docs, allowed_status);
if (submitted_docs && submitted_docs.length > 0) {
callback(submitted_docs);
}
});
}

async function enqueue_bulk_generation(method, args) {
const job_id = await frappe.xcall(method, args);

const now = frappe.datetime.system_datetime();
const creation_filter = `[">", "${now}"]`;
const api_requests_link = frappe.utils.generate_route({
type: "doctype",
name: "Integration Request",
route_options: {
integration_request_service: "India Compliance API",
creation: creation_filter,
},
});
const error_logs_link = frappe.utils.generate_route({
type: "doctype",
name: "Error Log",
route_options: {
creation: creation_filter,
},
});

frappe.msgprint(
__(
`Bulk Generation has been queued. You can track the
<a href='{0}'>Background Job</a>,
<a href='{1}'>API Request(s)</a>,
and <a href='{2}'>Error Log(s)</a>.`,
[
frappe.utils.get_form_link("RQ Job", job_id),
api_requests_link,
error_logs_link,
]
)
);
}

async function validate_doc_status(selected_docs, allowed_status) {
const valid_docs = [];
const invalid_docs = [];
const status_map = {
0: "draft",
1: "submitted",
2: "cancelled",
};

for (const doc of selected_docs) {
if (!allowed_status.includes(doc.docstatus)) {
invalid_docs.push(doc.name);
} else {
valid_docs.push(doc.name);
}
}

if (!invalid_docs.length) return valid_docs;

const allowed_status_str = allowed_status
.map(status => status_map[status])
.join(" or ");

if (!valid_docs.length) {
frappe.throw(
__("This action can only be performed on {0} documents", [
allowed_status_str,
])
);
}

const confirmed = await new Promise(resolve => {
frappe.confirm(
__(
"This action can only be performed on {0} documents. Do you want to continue without the following documents?<br><br><strong>{1}</strong>",
[allowed_status_str, invalid_docs.join("<br>")]
),
() => resolve(true),
() => resolve(false)
);
});

return confirmed ? valid_docs : false;
}
10 changes: 10 additions & 0 deletions india_compliance/gst_india/client_scripts/delivery_note_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const DOCTYPE = "Delivery Note";

const erpnext_onload = frappe.listview_settings[DOCTYPE].onload;
frappe.listview_settings[DOCTYPE].onload = function (list_view) {
if (erpnext_onload) {
erpnext_onload(list_view);
}

setup_bulk_e_waybill_actions(DOCTYPE, list_view);
};
28 changes: 28 additions & 0 deletions india_compliance/gst_india/client_scripts/e_invoice_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,31 @@ function is_valid_e_invoice_applicability_date(frm) {
? true
: false;
}

/********
* Bulk Operations for List Views
*******/

function setup_bulk_e_invoice_actions(doctype, list_view) {
if (!frappe.perm.has_perm(doctype, 0, "submit")) return;
if (!india_compliance.is_e_invoice_enabled()) return;

setup_bulk_e_invoice_generation_action(doctype, list_view);
}

function setup_bulk_e_invoice_generation_action(doctype, list_view) {
if (doctype !== "Sales Invoice") return;

add_bulk_action_for_documents(
list_view,
__("Enqueue Bulk e-Invoice Generation"),
enqueue_bulk_e_invoice_generation
);
}

async function enqueue_bulk_e_invoice_generation(docnames) {
enqueue_bulk_generation(
"india_compliance.gst_india.utils.e_invoice.enqueue_bulk_e_invoice_generation",
{ docnames }
);
}
Loading