Skip to content

Commit

Permalink
#18 OK generacion multiples pdf para Payment Entry con standard format
Browse files Browse the repository at this point in the history
  • Loading branch information
monroy95 committed Jan 5, 2021
1 parent e6a4f3a commit a8cbfa7
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,7 @@ frappe.ui.form.on('Cambiare Cheque Print Set', {
currency: frm.doc.currency
},
},
// freeze: true,
// freeze_message: __('Generando reporte, por favor espere...'),
callback: function (r) {
// if (!r.exc) {
// clearInterval(frm.page['interval']);
// frm.reload_doc();
// }
console.log(r.message);

frm.doc.cheque_to_print = []
frm.refresh_field("cheque_to_print");

Expand All @@ -47,13 +39,78 @@ frappe.ui.form.on('Cambiare Cheque Print Set', {
cheque_no: element.cheque_no,
amount: element.amount,
party_type: element.party_type,
third_party: element.third_party
third_party: element.third_party,
id: element.id
});
});
frm.refresh_field("cheque_to_print");

frm.save();
}
});
},
refresh: function (frm) {
frm.add_custom_button(__('TEST'), () => {
let data_je = [];
let data_pe = [];

frm.doc.cheque_to_print.forEach(element => {
if (element.transaction_id == 'Journal Entry') {
data_je.push(element.id);
}

if (element.transaction_id == 'Payment Entry') {
data_pe.push(element.id);
}
});

console.log(data_je, data_pe);



const dialog = new frappe.ui.Dialog({
title: __('Print Documents'),
fields: [{
'fieldtype': 'Check',
'label': __('With Letterhead'),
'fieldname': 'with_letterhead'
},
{
'fieldtype': 'Select',
'label': __('Print Format'),
'fieldname': 'print_sel',
options: frappe.meta.get_print_formats(frm.doc.doctype)
}]
});

dialog.set_primary_action(__('Print'), args => {
if (!args) return;

// Primero se imprimen los cheques para payment entry
for (const iterator of ['Payment Entry', 'Journal Entry']) {
console.log(iterator)

const default_print_format = 'Standard'; // frappe.get_meta(iterator).default_print_format;
const with_letterhead = args.with_letterhead ? 1 : 0;
const print_format = args.print_sel ? args.print_sel : 'Standard'; //default_print_format;
const json_string = JSON.stringify(data_pe);

const w = window.open('/api/method/frappe.utils.print_format.download_multi_pdf?' +
'doctype=' + encodeURIComponent(iterator) +
'&name=' + encodeURIComponent(json_string) +
'&format=' + encodeURIComponent(print_format) +
'&no_letterhead=' + (with_letterhead ? '0' : '1'));
if (!w) {
frappe.msgprint(__('Please enable pop-ups'));
return;
}

}
});

dialog.show();


}).addClass('btn btn-primary');
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_data_of_payment_entry(filters):

data = frappe.db.sql(
f"""
SELECT 'Payment Entry' AS transaction_id, reference_no AS cheque_no,
SELECT name AS id, 'Payment Entry' AS transaction_id, reference_no AS cheque_no,
paid_amount AS amount, party_type, party AS third_party
FROM `tabPayment Entry`
WHERE mode_of_payment='Cheque' AND company='{filters.company}'
Expand Down Expand Up @@ -100,6 +100,7 @@ def get_data_of_journal_entry(filters):
'party_type': ['!=', '']},
fieldname=['party_type', 'party'], as_dict=1)[0]
all_data.append({
'id': data_je.get('id'),
'transaction_id': 'Journal Entry',
'cheque_no': cheque_no,
'amount': amount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"cheque_no",
"amount",
"party_type",
"third_party"
"third_party",
"id"
],
"fields": [
{
Expand Down Expand Up @@ -50,10 +51,16 @@
"options": "Payment Entry\nJournal Entry",
"read_only": 1,
"translatable": 1
},
{
"fieldname": "id",
"fieldtype": "Data",
"label": "ID",
"read_only": 1
}
],
"istable": 1,
"modified": "2021-01-04 16:38:50.122641",
"modified": "2021-01-05 11:04:07.383002",
"modified_by": "Administrator",
"module": "Cambiare GTQ",
"name": "Cheque To Print",
Expand Down

0 comments on commit a8cbfa7

Please sign in to comment.