Skip to content

Commit

Permalink
feat - let the user enter branch id while fetching Stock count
Browse files Browse the repository at this point in the history
  • Loading branch information
maniamartial committed Nov 29, 2024
1 parent 6edb54c commit 0711d02
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
// const doctypeName = "Navari eTims Registered Stock Movement";

// frappe.listview_settings[doctypeName] = {
// onload: function (listview) {
// const companyName = frappe.boot.sysdefaults.company;

// listview.page.add_inner_button(
// __("Get Stock Movements"),
// function (listview) {
// frappe.call({
// method:
// "kenya_compliance.kenya_compliance.apis.apis.perform_stock_movement_search",
// args: {
// request_data: {
// company_name: companyName,
// branch_id: "",
// },
// },
// callback: (response) => {},
// error: (error) => {
// // Error Handling is Defered to the Server
// },
// });
// },
// );
// },
// };
const doctypeName = "Navari eTims Registered Stock Movement";

frappe.listview_settings[doctypeName] = {
Expand All @@ -6,21 +33,47 @@ frappe.listview_settings[doctypeName] = {

listview.page.add_inner_button(
__("Get Stock Movements"),
function (listview) {
frappe.call({
method:
"kenya_compliance.kenya_compliance.apis.apis.perform_stock_movement_search",
args: {
request_data: {
company_name: companyName,
function () {
// Create a dialog to select a branch
const branchDialog = new frappe.ui.Dialog({
title: __("Select Branch"),
fields: [
{
label: __("Branch"),
fieldname: "branch_id",
fieldtype: "Link",
options: "Branch",
reqd: true,
},
},
callback: (response) => {},
error: (error) => {
// Error Handling is Defered to the Server
],
primary_action_label: __("Submit"),
primary_action: function (data) {
branchDialog.hide();

// Call the server method with the selected branch
frappe.call({
method:
"kenya_compliance.kenya_compliance.apis.apis.perform_stock_movement_search",
args: {
request_data: {
company_name: companyName,
branch_id: data.branch_id,
},
},
callback: (response) => {
frappe.msgprint(__("Stock movements retrieved successfully."));
},
error: (error) => {
frappe.msgprint(__("An error occurred while fetching stock movements."));
},
});
},
});

// Show the dialog
branchDialog.show();
},
);
},
};

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"fieldname": "vendor",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Vendor",
"label": "API Provider",
"options": "\nOSCU KRA\nVSCU Slade 360\nPergamon",
"reqd": 1
},
Expand All @@ -53,7 +53,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-11-28 10:27:29.129037",
"modified": "2024-11-29 08:38:06.929415",
"modified_by": "Administrator",
"module": "Kenya Compliance",
"name": "Navari eTims Routes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
{
"fieldname": "vendor",
"fieldtype": "Select",
"label": "Vendor",
"label": "API Provider",
"options": "\nOSCU KRA\nVSCU Slade 360\nPergamon",
"reqd": 1
}
Expand All @@ -321,7 +321,7 @@
"link_fieldname": "reference_docname"
}
],
"modified": "2024-11-28 10:15:43.219826",
"modified": "2024-11-29 08:37:26.434270",
"modified_by": "Administrator",
"module": "Kenya Compliance",
"name": "Navari KRA eTims Settings",
Expand Down
7 changes: 7 additions & 0 deletions kenya_compliance/kenya_compliance/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,13 @@ def build_headers(company_name: str, vendor:str, branch_id: str = "00") -> dict[

return headers

def get_branch_id(company_name: str, vendor: str) -> str | None:
settings = get_curr_env_etims_settings(company_name, vendor)

if settings:
return settings.bhfid

return None

def extract_document_series_number(document: Document) -> int | None:
split_invoice_name = document.name.split("-")
Expand Down

0 comments on commit 0711d02

Please sign in to comment.