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
103 changes: 103 additions & 0 deletions av_tools/av_tools/delivery_note.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Delivery Note ctrl+q shortcut (moved from csf_tz)

frappe.ui.keys.add_shortcut({
shortcut: "ctrl+q",
action: () => {
const current_doc = $(".data-row.editable-row").parent().attr("data-name");
const item_row = locals["Delivery Note Item"][current_doc];
frappe.call({
method: "csf_tz.custom_api.get_item_info",
args: { item_code: item_row.item_code },
callback: function (r) {
if (r.message.length > 0) {
const d = new frappe.ui.Dialog({
title: __("Item Balance"),
width: 600,
});
$(`<div class="modal-body ui-front">
<h2>${item_row.item_code} : ${item_row.qty}</h2>
<p>Choose Warehouse and click Select :</p>
<table class="table table-bordered">
<thead>
</thead>
<tbody>
</tbody>
</table>
</div>`).appendTo(d.body);
const thead = $(d.body).find("thead");
if (r.message[0].batch_no) {
r.message.sort((a, b) => a.expiry_status - b.expiry_status);
$(`<tr>
<th>Check</th>
<th>Warehouse</th>
<th>Qty</th>
<th>UOM</th>
<th>Batch No</th>
<th>Expires On</th>
<th>Expires in Days</th>
</tr>`).appendTo(thead);
} else {
$(`<tr>
<th>Check</th>
<th>Warehouse</th>
<th>Qty</th>
<th>UOM</th>
</tr>`).appendTo(thead);
}
r.message.forEach((element) => {
const tbody = $(d.body).find("tbody");
const tr = $(`
<tr>
<td><input type="checkbox" class="check-warehouse" data-warehouse="${element.warehouse}"></td>
<td>${element.warehouse}</td>
<td>${element.actual_qty}</td>
<td>${item_row.stock_uom}</td>
</tr>
`).appendTo(tbody);
if (element.batch_no) {
$(`
<td>${element.batch_no}</td>
<td>${element.expires_on}</td>
<td>${element.expiry_status}</td>
`).appendTo(tr);
tr.find(".check-warehouse").attr("data-batch", element.batch_no);
tr.find(".check-warehouse").attr("data-batchQty", element.actual_qty);
}
tbody.find(".check-warehouse").on("change", function () {
$("input.check-warehouse").not(this).prop("checked", false);
});
});
d.set_primary_action("Select", function () {
$(d.body)
.find("input:checked")
.each(function (i, input) {
frappe.model.set_value(
item_row.doctype,
item_row.name,
"warehouse",
$(input).attr("data-warehouse"),
);
if ($(input).attr("data-batch")) {
frappe.model.set_value(
item_row.doctype,
item_row.name,
"batch_no",
$(input).attr("data-batch"),
);
}
});
cur_frm.rec_dialog.hide();
cur_frm.refresh_fields();
});
cur_frm.rec_dialog = d;
d.show();
} else {
frappe.show_alert({ message: __("There is No Records"), indicator: "red" }, 5);
}
},
});
},
page: this.page,
description: __("Select Item Warehouse"),
ignore_inputs: true,
});
15 changes: 15 additions & 0 deletions av_tools/av_tools/material_request.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Material Request ctrl+q shortcut (moved from csf_tz)

frappe.require([
"/assets/av_tools/js/shortcuts.js",
]);

frappe.ui.keys.add_shortcut({
shortcut: "ctrl+q",
action: () => {
ctrlQ("Material Request Item");
},
page: this.page,
description: __("Select Item Warehouse"),
ignore_inputs: true,
});
24 changes: 24 additions & 0 deletions av_tools/av_tools/purchase_order.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
frappe.require([
"/assets/av_tools/js/po_shortcuts.js",
]);

frappe.ui.keys.add_shortcut({
shortcut: "ctrl+i",
action: () => {
ctrlI("Purchase Order Item");
},
page: this.page,
description: __("Select Customer Item Price"),
ignore_inputs: true,
});

frappe.ui.keys.add_shortcut({
shortcut: "ctrl+u",
action: () => {
ctrlU("Purchase Order Item");
},
page: this.page,
description: __("Select Item Price"),
ignore_inputs: true,
});

frappe.ui.form.on("Purchase Order Item", {
item_code: async function (frm, cdt, cdn) {
await set_dynamic_price_list_rate(frm, cdt, cdn);
Expand Down
35 changes: 35 additions & 0 deletions av_tools/av_tools/sales_invoice.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
// Trade In feature for Sales Invoice (moved from csf_tz)

frappe.require([
"/assets/av_tools/js/shortcuts.js",
]);

frappe.ui.keys.add_shortcut({
shortcut: "ctrl+q",
action: () => {
ctrlQ("Sales Invoice Item");
},
page: this.page,
description: __("Select Item Warehouse"),
ignore_inputs: true,
});

frappe.ui.keys.add_shortcut({
shortcut: "ctrl+i",
action: () => {
ctrlI("Sales Invoice Item");
},
page: this.page,
description: __("Select Customer Item Price"),
ignore_inputs: true,
});

frappe.ui.keys.add_shortcut({
shortcut: "ctrl+u",
action: () => {
ctrlU("Sales Invoice Item");
},
page: this.page,
description: __("Select Item Price"),
ignore_inputs: true,
});


frappe.ui.form.on("Sales Invoice", {
refresh: function (frm) {
frm.trigger("set_trade_in_field_visibility");
Expand Down
35 changes: 35 additions & 0 deletions av_tools/av_tools/sales_order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Sales Order shortcut bindings (moved from csf_tz)

frappe.require([
"/assets/av_tools/js/shortcuts.js",
]);

frappe.ui.keys.add_shortcut({
shortcut: "ctrl+q",
action: () => {
ctrlQ("Sales Order Item");
},
page: this.page,
description: __("Select Item Warehouse"),
ignore_inputs: true,
});

frappe.ui.keys.add_shortcut({
shortcut: "ctrl+i",
action: () => {
ctrlI("Sales Order Item");
},
page: this.page,
description: __("Select Customer Item Price"),
ignore_inputs: true,
});

frappe.ui.keys.add_shortcut({
shortcut: "ctrl+u",
action: () => {
ctrlU("Sales Order Item");
},
page: this.page,
description: __("Select Item Price"),
ignore_inputs: true,
});
106 changes: 106 additions & 0 deletions av_tools/av_tools/stock_entry.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,109 @@
frappe.require([
"/assets/av_tools/js/shortcuts.js",
]);

frappe.ui.keys.add_shortcut({
shortcut: "ctrl+q",
action: () => {
const current_doc = $(".data-row.editable-row").parent().attr("data-name");
const item_row = locals["Stock Entry Detail"][current_doc];
frappe.call({
method: "csf_tz.custom_api.get_item_info",
args: { item_code: item_row.item_code },
callback: function (r) {
if (r.message.length > 0) {
const d = new frappe.ui.Dialog({
title: __("Item Balance"),
width: 600,
});
$(`<div class="modal-body ui-front">
<h2>${item_row.item_code} : ${item_row.qty}</h2>
<p>Choose Warehouse and click Select :</p>
<table class="table table-bordered">
<thead>
</thead>
<tbody>
</tbody>
</table>
</div>`).appendTo(d.body);
const thead = $(d.body).find("thead");
if (r.message[0].batch_no) {
r.message.sort((a, b) => a.expiry_status - b.expiry_status);
$(`<tr>
<th>Check</th>
<th>Warehouse</th>
<th>Qty</th>
<th>UOM</th>
<th>Batch No</th>
<th>Expires On</th>
<th>Expires in Days</th>
</tr>`).appendTo(thead);
} else {
$(`<tr>
<th>Check</th>
<th>Warehouse</th>
<th>Qty</th>
<th>UOM</th>
</tr>`).appendTo(thead);
}
r.message.forEach((element) => {
const tbody = $(d.body).find("tbody");
const tr = $(`
<tr>
<td><input type="checkbox" class="check-warehouse" data-warehouse="${element.warehouse}"></td>
<td>${element.warehouse}</td>
<td>${element.actual_qty}</td>
<td>${item_row.stock_uom}</td>
</tr>
`).appendTo(tbody);
if (element.batch_no) {
$(`
<td>${element.batch_no}</td>
<td>${element.expires_on}</td>
<td>${element.expiry_status}</td>
`).appendTo(tr);
tr.find(".check-warehouse").attr("data-batch", element.batch_no);
tr.find(".check-warehouse").attr("data-batchQty", element.actual_qty);
}
tbody.find(".check-warehouse").on("change", function () {
$("input.check-warehouse").not(this).prop("checked", false);
});
});
d.set_primary_action("Select", function () {
$(d.body)
.find("input:checked")
.each(function (i, input) {
frappe.model.set_value(
item_row.doctype,
item_row.name,
"s_warehouse",
$(input).attr("data-warehouse"),
);
if ($(input).attr("data-batch")) {
frappe.model.set_value(
item_row.doctype,
item_row.name,
"batch_no",
$(input).attr("data-batch"),
);
}
});
cur_frm.rec_dialog.hide();
cur_frm.refresh_fields();
});
cur_frm.rec_dialog = d;
d.show();
} else {
frappe.show_alert({ message: __("There is No Records"), indicator: "red" }, 5);
}
},
});
},
page: this.page,
description: __("Select Item Warehouse"),
ignore_inputs: true,
});

frappe.ui.form.on("Stock Entry", {
onload(frm) {
if (frm.doc.docstatus !== 0) {
Expand Down
11 changes: 9 additions & 2 deletions av_tools/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,22 @@
"authotp/api/sales_invoice.js",
"av_tools/sales_invoice.js",
],
"Delivery Note": "weigh_bridge/doctype/delivery_note_weighbridge_ticket.js",
"Sales Order": "weigh_bridge/doctype/sales_order_weighbridge_ticket.js",
"Delivery Note": [
"weigh_bridge/doctype/delivery_note_weighbridge_ticket.js",
"av_tools/delivery_note.js",
],
"Sales Order": [
"weigh_bridge/doctype/sales_order_weighbridge_ticket.js",
"av_tools/sales_order.js",
],
"Purchase Order": [
"weigh_bridge/doctype/purchase_order_weighbridge_ticket.js",
"av_tools/purchase_order.js",
],
"Stock Entry": "av_tools/stock_entry.js",
"Purchase Invoice": "weigh_bridge/doctype/purchase_invoice_weighbridge_ticket.js",
"Purchase Receipt": "weigh_bridge/doctype/purchase_receipt_weighbridge_ticket.js",
"Material Request": "av_tools/material_request.js",
"Customer": "authotp/api/customer.js",
"Account": "av_tools/account.js",
}
Expand Down
Loading
Loading