Skip to content

Instantly share code, notes, and snippets.

View ernestoruiz89's full-sized avatar
🎯
Focusing

Ernesto Ruiz ernestoruiz89

🎯
Focusing
View GitHub Profile
frappe.ui.keys.add_shortcut({
shortcut: 'alt+p',
action: (e) => {
this.$item.find('.print-btn').trigger('click');
e.preventDefault();
return false;
},
condition: () => this.$component.is(':visible') && this.$summary_container.find('.print-btn').is(":visible"), //optional
description: __("Print Receipt"),
page: cur_page.page.page //optional
//Para sumar un rango dinamicamente tomando en cuenta la fecha de analisis con encabezados de fecha
=SUMA(INDIRECTO("F"&FILA()&"C2:F"&FILA()&"C"&COINCIDIR(BUSCARH($L$2,$4:$4,1,1),$4:$4,0),FALSO))
//Validar letra de cédula Nicaragüense
= SI(B2<>"",
SI(LARGO(B2)=14,
SI( IGUAL(
* Calcular la letra al final de la cédula nicaragüense.
* La letra se calcula con el siguiente algoritmo (SQL).
*
* declare @cedula varchar(20),
* @val numeric(13, 0),
* @letra char(1),
* @Letras varchar(20)
*
* select @Letras = 'ABCDEFGHJKLMNPQRSTUVWXY'
* select @cedula = '0012510750012' --PARTE NUMERICA DE LA CEDULA SIN GUIONES
@ernestoruiz89
ernestoruiz89 / dialog_promise.js
Created March 3, 2023 19:39 — forked from barredterra/dialog_promise.js
Comfortably work with dialogs in Frappe Framework
function dialog_promise (title, fields, primary_action_label) {
// Return a function that returns a promise
// The promise resolves when the dialog is submitted and rejects when the dialog is closed
// On resolve, the promise returns the values from the dialog.
return () => new Promise((resolve, reject) => {
const dialog = new frappe.ui.Dialog({
title: title,
fields: fields,
onhide: () => reject(),
primary_action_label: primary_action_label,
frappe.ui.form.on('Issue', {
refresh: function(frm) {
frm.fields_dict['sb_details'].wrapper.css('background-color', 'lightblue');
frm.fields_dict['section_break_19'].wrapper.css('background-color', 'gold');
}
frappe.ui.keys.add_shortcut({
shortcut: "shift+ctrl+d",
action: function () {
// navigate to ask doppio bot page
frappe.set_route("doppio-bot");
},
description: __("Ask DoppioBot"),
});
@frappe.whitelist()
def import_coa_job(file_name, company):
# delete existing data for accounts
unset_existing_data(company)
# create accounts
file_doc, extension = get_file(file_name)
if extension == "csv":
data = generate_data_from_csv(file_doc)
frappe.listview_settings['Journal Entry'] = {
refresh(list) {
frappe.breadcrumbs.clear();
frappe.breadcrumbs.set_custom_breadcrumbs({
route: "/app/support",
label: "Support"
});
SELECT
a.asset_category AS "Category:Data",
a.asset_name AS "Asset Name:Data",
a.name AS "Asset No.:Link/Asset",
a.purchase_date AS "Purchase Date:Date",
ROUND(a.gross_purchase_amount + IFNULL(ava.total_difference, 0), 2) AS "Gross Asset Amount:Float",
SUM(CASE WHEN MONTH(ds.schedule_date) = 1 AND YEAR(ds.schedule_date) = YEAR(%(cutoff_date)s) THEN ds.depreciation_amount ELSE 0 END) AS "January:Float",
SUM(CASE WHEN MONTH(ds.schedule_date) = 2 AND YEAR(ds.schedule_date) = YEAR(%(cutoff_date)s) THEN ds.depreciation_amount ELSE 0 END) AS "February:Float",
SELECT
'Income' AS `Type`,
gl.voucher_type AS `Document Type`,
gl.voucher_no AS `Document Number`,
gl.account AS `Account`,
SUM(gl.credit - gl.debit) AS `Amount`, -- Adjusted to show credit as positive
gl.remarks AS `Remarks`,
1 AS `Order`
FROM
`tabGL Entry` AS gl