-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #350 from aakvatech/version-14
v15.0.0
- Loading branch information
Showing
70 changed files
with
2,562 additions
and
383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
from selcom_apigw_client import apigwClient | ||
import json | ||
import frappe | ||
from frappe import _ | ||
|
||
|
||
def create_order_log(method, status, request_json, response, reference): | ||
doc = frappe.new_doc("Selcom Order Log") | ||
doc.date = frappe.utils.today() | ||
doc.time = frappe.utils.nowtime() | ||
doc.method = method | ||
doc.status = status | ||
doc.reference = reference | ||
doc.request_data = json.dumps(request_json, indent=4) | ||
doc.response_data = json.dumps(response, indent=4) | ||
doc.insert(ignore_permissions=True) | ||
frappe.db.commit() | ||
|
||
|
||
@frappe.whitelist() | ||
def create_order_minimal(): | ||
# Initialize API client | ||
apiKey = "" | ||
apiSecret = "" | ||
baseUrl = "https://apigw.selcommobile.com/v1" | ||
|
||
client = apigwClient.Client(baseUrl, apiKey, apiSecret) | ||
|
||
# Order data | ||
orderDict = { | ||
"vendor": "TILL61056542", | ||
"order_id": "1218d5Qb", | ||
"buyer_email": "john@example.com", | ||
"buyer_name": "John Joh", | ||
"buyer_phone": "255789968024", | ||
"amount": 8000, | ||
"currency": "TZS", | ||
"buyer_remarks": "None", | ||
"merchant_remarks": "None", | ||
"no_of_items": 1, | ||
} | ||
|
||
# API endpoint | ||
orderPath = "/checkout/create-order-minimal" | ||
|
||
# Send order request | ||
try: | ||
response = client.postFunc(orderPath, orderDict) | ||
if response.get("resultcode") != "000": | ||
frappe.log_error( | ||
f"Error on Create Order {response.get('reference')} to Payment Gateway", | ||
response, | ||
) | ||
create_order_log( | ||
"Create Order Minimal", | ||
"Failed", | ||
orderDict, | ||
response, | ||
reference=response.get("reference"), | ||
) | ||
else: | ||
frappe.msgprint(_("Order created successfully"), alert=True) | ||
create_order_log( | ||
"Create Order Minimal", | ||
"Success", | ||
orderDict, | ||
response, | ||
reference=response.get("reference"), | ||
) | ||
return response | ||
|
||
except Exception as e: | ||
frappe.log_error( | ||
f"Error on Create Order {response.get('reference')} to Payment Gateway", | ||
str(e), | ||
) | ||
create_order_log( | ||
"Create Order Minimal", | ||
"Failed", | ||
orderDict, | ||
str(e), | ||
reference=response.get("reference"), | ||
) | ||
frappe.throw( | ||
_("Failed to create order, please try again, or contact the administrator") | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
frappe.listview_settings['Custom Field'] = { | ||
onload: function (listview) { | ||
listview.page.add_menu_item(__('Export Selected'), async function () { | ||
const selected_docs = listview.get_checked_items(); | ||
if (selected_docs.length === 0) { | ||
frappe.msgprint(__('Please select at least one document.')); | ||
return; | ||
} | ||
|
||
const detailed_docs = await Promise.all(selected_docs.map(doc => | ||
fetch(`/api/resource/Custom Field/${doc.name}`) | ||
.then(response => response.json()) | ||
.then(data => data.data) | ||
)); | ||
|
||
const data_to_export = detailed_docs.map(doc => { | ||
return { | ||
name: doc.name, | ||
owner: doc.owner, | ||
creation: doc.creation, | ||
modified: doc.modified, | ||
modified_by: doc.modified_by, | ||
docstatus: doc.docstatus, | ||
idx: doc.idx, | ||
is_system_generated: doc.is_system_generated, | ||
dt: doc.dt, | ||
label: doc.label, | ||
fieldname: doc.fieldname, | ||
insert_after: doc.insert_after, | ||
length: doc.length, | ||
fieldtype: doc.fieldtype, | ||
precision: doc.precision, | ||
hide_seconds: doc.hide_seconds, | ||
hide_days: doc.hide_days, | ||
options: doc.options, | ||
sort_options: doc.sort_options, | ||
fetch_if_empty: doc.fetch_if_empty, | ||
fetch_from: doc.fetch_from, | ||
collapsible: doc.collapsible, | ||
non_negative: doc.non_negative, | ||
reqd: doc.reqd, | ||
unique: doc.unique, | ||
is_virtual: doc.is_virtual, | ||
read_only: doc.read_only, | ||
ignore_user_permissions: doc.ignore_user_permissions, | ||
hidden: doc.hidden, | ||
print_hide: doc.print_hide, | ||
print_hide_if_no_value: doc.print_hide_if_no_value, | ||
no_copy: doc.no_copy, | ||
allow_on_submit: doc.allow_on_submit, | ||
in_list_view: doc.in_list_view, | ||
in_standard_filter: doc.in_standard_filter, | ||
in_global_search: doc.in_global_search, | ||
in_preview: doc.in_preview, | ||
bold: doc.bold, | ||
report_hide: doc.report_hide, | ||
search_index: doc.search_index, | ||
allow_in_quick_entry: doc.allow_in_quick_entry, | ||
ignore_xss_filter: doc.ignore_xss_filter, | ||
translatable: doc.translatable, | ||
hide_border: doc.hide_border, | ||
show_dashboard: doc.show_dashboard, | ||
permlevel: doc.permlevel, | ||
columns: doc.columns, | ||
doctype: doc.doctype, | ||
__last_sync_on: doc.__last_sync_on | ||
}; | ||
}); | ||
|
||
const jsonStr = JSON.stringify(data_to_export); | ||
let blob = new Blob([jsonStr], { type: "application/json" }); | ||
let a = document.createElement("a"); | ||
a.href = URL.createObjectURL(blob); | ||
a.download = "exported_custom_fields.json"; | ||
a.click(); | ||
URL.revokeObjectURL(a.href); | ||
a.remove(); | ||
}); | ||
} | ||
}; |
Empty file.
8 changes: 8 additions & 0 deletions
8
csf_tz/csf_tz/doctype/csf_tz_bank_charges/csf_tz_bank_charges.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright (c) 2024, Aakvatech and contributors | ||
// For license information, please see license.txt | ||
|
||
frappe.ui.form.on('CSF TZ Bank Charges', { | ||
// refresh: function(frm) { | ||
|
||
// } | ||
}); |
144 changes: 144 additions & 0 deletions
144
csf_tz/csf_tz/doctype/csf_tz_bank_charges/csf_tz_bank_charges.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
{ | ||
"actions": [], | ||
"allow_rename": 1, | ||
"autoname": "format:CTBC-{###}", | ||
"creation": "2024-03-08 09:00:14.016189", | ||
"default_view": "List", | ||
"doctype": "DocType", | ||
"editable_grid": 1, | ||
"engine": "InnoDB", | ||
"field_order": [ | ||
"posting_date", | ||
"bank_account", | ||
"currency", | ||
"company", | ||
"column_break_ttbjl", | ||
"account", | ||
"bank_supplier", | ||
"exchange_rate", | ||
"section_break_31h9g", | ||
"csf_tz_bank_charges_detail", | ||
"total_bank_charges", | ||
"ref_pi", | ||
"section_break_x1dgr", | ||
"amended_from" | ||
], | ||
"fields": [ | ||
{ | ||
"fieldname": "bank_account", | ||
"fieldtype": "Link", | ||
"in_list_view": 1, | ||
"label": "Bank Account", | ||
"options": "Bank Account", | ||
"reqd": 1 | ||
}, | ||
{ | ||
"fieldname": "currency", | ||
"fieldtype": "Link", | ||
"label": "Bank Account Currency", | ||
"options": "Currency" | ||
}, | ||
{ | ||
"fieldname": "column_break_ttbjl", | ||
"fieldtype": "Column Break" | ||
}, | ||
{ | ||
"fetch_from": "bank_account.custom_bank_supplier", | ||
"fieldname": "bank_supplier", | ||
"fieldtype": "Data", | ||
"label": "Bank Supplier", | ||
"read_only": 1 | ||
}, | ||
{ | ||
"default": "1", | ||
"fieldname": "exchange_rate", | ||
"fieldtype": "Currency", | ||
"label": "Exchange Rate" | ||
}, | ||
{ | ||
"fieldname": "section_break_31h9g", | ||
"fieldtype": "Section Break", | ||
"label": "CSF TZ Bank Charges Detail" | ||
}, | ||
{ | ||
"allow_bulk_edit": 1, | ||
"fieldname": "csf_tz_bank_charges_detail", | ||
"fieldtype": "Table", | ||
"options": "CSF TZ Bank Charges Detail" | ||
}, | ||
{ | ||
"default": "0", | ||
"fieldname": "total_bank_charges", | ||
"fieldtype": "Currency", | ||
"label": "Total Bank Charges", | ||
"options": "currency", | ||
"read_only": 1 | ||
}, | ||
{ | ||
"fieldname": "section_break_x1dgr", | ||
"fieldtype": "Section Break" | ||
}, | ||
{ | ||
"fetch_from": "bank_account.account", | ||
"fieldname": "account", | ||
"fieldtype": "Link", | ||
"label": "Account", | ||
"options": "Account" | ||
}, | ||
{ | ||
"default": "Today", | ||
"fieldname": "posting_date", | ||
"fieldtype": "Date", | ||
"label": "Posting Date" | ||
}, | ||
{ | ||
"fieldname": "ref_pi", | ||
"fieldtype": "Data", | ||
"label": " Ref PI", | ||
"read_only": 1 | ||
}, | ||
{ | ||
"fetch_from": "bank_account.company", | ||
"fieldname": "company", | ||
"fieldtype": "Link", | ||
"label": "Company", | ||
"options": "Company" | ||
}, | ||
{ | ||
"fieldname": "amended_from", | ||
"fieldtype": "Link", | ||
"label": "Amended From", | ||
"no_copy": 1, | ||
"options": "CSF TZ Bank Charges", | ||
"print_hide": 1, | ||
"read_only": 1, | ||
"search_index": 1 | ||
} | ||
], | ||
"index_web_pages_for_search": 1, | ||
"is_submittable": 1, | ||
"links": [], | ||
"modified": "2024-05-03 18:07:21.621574", | ||
"modified_by": "Administrator", | ||
"module": "CSF TZ", | ||
"name": "CSF TZ Bank Charges", | ||
"naming_rule": "Expression", | ||
"owner": "Administrator", | ||
"permissions": [ | ||
{ | ||
"create": 1, | ||
"delete": 1, | ||
"email": 1, | ||
"export": 1, | ||
"print": 1, | ||
"read": 1, | ||
"report": 1, | ||
"role": "System Manager", | ||
"share": 1, | ||
"write": 1 | ||
} | ||
], | ||
"sort_field": "modified", | ||
"sort_order": "DESC", | ||
"states": [] | ||
} |
Oops, something went wrong.