FEC report corrections (#14741)

* Report corrections to match government requirements

* Untranslatable headers

* Remove unused onchange logic
This commit is contained in:
Charles-Henri Decultot 2018-07-01 13:16:48 +02:00 committed by Nabin Hait
parent dfe897b888
commit f02bef78f0
2 changed files with 62 additions and 89 deletions

View File

@ -4,35 +4,21 @@
frappe.query_reports["Fichier des Ecritures Comptables [FEC]"] = {
"filters": [{
"fieldname": "company",
"label": __("Company"),
"fieldtype": "Link",
"options": "Company",
"default": frappe.defaults.get_user_default("Company"),
"reqd": 1
},
{
"fieldname": "fiscal_year",
"label": __("Fiscal Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
"default": frappe.defaults.get_user_default("fiscal_year"),
"reqd": 1,
"on_change": function(query_report) {
var fiscal_year = query_report.get_values().fiscal_year;
if (!fiscal_year) {
return;
}
frappe.model.with_doc("Fiscal Year", fiscal_year, function(r) {
var fy = frappe.model.get_doc("Fiscal Year", fiscal_year);
frappe.query_report_filters_by_name.from_date.set_input(fy.year_start_date);
frappe.query_report_filters_by_name.to_date.set_input(fy.year_end_date);
query_report.trigger_refresh();
});
}
}
],
"fieldname": "company",
"label": __("Company"),
"fieldtype": "Link",
"options": "Company",
"default": frappe.defaults.get_user_default("Company"),
"reqd": 1
},
{
"fieldname": "fiscal_year",
"label": __("Fiscal Year"),
"fieldtype": "Link",
"options": "Fiscal Year",
"default": frappe.defaults.get_user_default("fiscal_year"),
"reqd": 1
}],
onload: function(query_report) {
query_report.page.add_inner_button(__("Export"), function() {
@ -51,7 +37,7 @@ frappe.query_reports["Fichier des Ecritures Comptables [FEC]"] = {
callback: function(data) {
var company_data = data.message.siren_number;
if (company_data === null || company_data === undefined) {
msgprint(__("Please register the SIREN number in the company information file"))
frappe.msgprint(__("Please register the SIREN number in the company information file"))
} else {
frappe.call({
method: "frappe.client.get_value",
@ -83,7 +69,7 @@ frappe.query_reports["Fichier des Ecritures Comptables [FEC]"] = {
var downloadify = function(data, roles, title) {
if (roles && roles.length && !has_common(roles, roles)) {
msgprint(__("Export not allowed. You need {0} role to export.", [frappe.utils.comma_or(roles)]));
frappe.msgprint(__("Export not allowed. You need {0} role to export.", [frappe.utils.comma_or(roles)]));
return;
}
@ -115,9 +101,6 @@ var downloadify = function(data, roles, title) {
var to_tab_csv = function(data) {
var res = [];
$.each(data, function(i, row) {
row = $.map(row, function(col) {
return typeof(col) === "string" ? ('"' + col.replace(/"/g, '""') + '"') : col;
});
res.push(row.join("\t"));
});
return res.join("\n");

View File

@ -40,15 +40,15 @@ def set_account_currency(filters):
def get_columns(filters):
columns = [
_("JournalCode") + "::90", _("JournalLib") + "::90",
_("EcritureNum") + ":Dynamic Link:90", _("EcritureDate") + "::90",
_("CompteNum") + ":Link/Account:100", _("CompteLib") + ":Link/Account:200",
_("CompAuxNum") + "::90", _("CompAuxLib") + "::90",
_("PieceRef") + "::90", _("PieceDate") + "::90",
_("EcritureLib") + "::90", _("Debit") + "::90", _("Credit") + "::90",
_("EcritureLet") + "::90", _("DateLet") +
"::90", _("ValidDate") + "::90",
_("Montantdevise") + "::90", _("Idevise") + "::90"
"JournalCode" + "::90", "JournalLib" + "::90",
"EcritureNum" + ":Dynamic Link:90", "EcritureDate" + "::90",
"CompteNum" + ":Link/Account:100", "CompteLib" + ":Link/Account:200",
"CompAuxNum" + "::90", "CompAuxLib" + "::90",
"PieceRef" + "::90", "PieceDate" + "::90",
"EcritureLib" + "::90", "Debit" + "::90", "Credit" + "::90",
"EcritureLet" + "::90", "DateLet" +
"::90", "ValidDate" + "::90",
"Montantdevise" + "::90", "Idevise" + "::90"
]
return columns
@ -69,30 +69,30 @@ def get_gl_entries(filters):
gl_entries = frappe.db.sql("""
select
gl.posting_date as GlPostDate, gl.account, gl.transaction_date,
gl.posting_date as GlPostDate, gl.name as GlName, gl.account, gl.transaction_date,
sum(gl.debit) as debit, sum(gl.credit) as credit,
sum(gl.debit_in_account_currency) as debitCurr, sum(gl.credit_in_account_currency) as creditCurr,
gl.voucher_type, gl.voucher_no, gl.against_voucher_type,
gl.against_voucher, gl.account_currency, gl.against,
gl.party_type, gl.party, gl.is_opening,
inv.name as InvName, inv.posting_date as InvPostDate,
pur.name as PurName, inv.posting_date as PurPostDate,
jnl.cheque_no as JnlRef, jnl.posting_date as JnlPostDate,
pay.name as PayName, pay.posting_date as PayPostDate,
cus.customer_name, cus.name as cusName,
sup.supplier_name, sup.name as supName
sum(gl.debit_in_account_currency) as debitCurr, sum(gl.credit_in_account_currency) as creditCurr,
gl.voucher_type, gl.voucher_no, gl.against_voucher_type,
gl.against_voucher, gl.account_currency, gl.against,
gl.party_type, gl.party,
inv.name as InvName, inv.title as InvTitle, inv.posting_date as InvPostDate,
pur.name as PurName, pur.title as PurTitle, pur.posting_date as PurPostDate,
jnl.cheque_no as JnlRef, jnl.posting_date as JnlPostDate, jnl.title as JnlTitle,
pay.name as PayName, pay.posting_date as PayPostDate, pay.title as PayTitle,
cus.customer_name, cus.name as cusName,
sup.supplier_name, sup.name as supName
from `tabGL Entry` gl
left join `tabSales Invoice` inv on gl.against_voucher = inv.name
left join `tabPurchase Invoice` pur on gl.against_voucher = pur.name
left join `tabJournal Entry` jnl on gl.against_voucher = jnl.name
left join `tabPayment Entry` pay on gl.against_voucher = pay.name
left join `tabCustomer` cus on gl.party = cus.customer_name
left join `tabSupplier` sup on gl.party = sup.supplier_name
left join `tabSales Invoice` inv on gl.voucher_no = inv.name
left join `tabPurchase Invoice` pur on gl.voucher_no = pur.name
left join `tabJournal Entry` jnl on gl.voucher_no = jnl.name
left join `tabPayment Entry` pay on gl.voucher_no = pay.name
left join `tabCustomer` cus on gl.party = cus.customer_name
left join `tabSupplier` sup on gl.party = sup.supplier_name
where gl.company=%(company)s and gl.fiscal_year=%(fiscal_year)s
{group_by_condition}
order by GlPostDate, voucher_no"""
.format(group_by_condition=group_by_condition), filters, as_dict=1)
order by GlPostDate, voucher_no"""\
.format(group_by_condition=group_by_condition), filters, as_dict=1)
return gl_entries
@ -131,33 +131,23 @@ def get_result_as_list(data, filters):
ValidDate = format_datetime(d.get("GlPostDate"), "yyyyMMdd")
PieceRef = d.get("voucher_no") if d.get("voucher_no") else "Sans Reference"
# EcritureLib is the reference title unless it is an opening entry
if d.get("is_opening") == "Yes":
PieceRef = _("Opening Entry Journal")
PieceDate = format_datetime(d.get("GlPostDate"), "yyyyMMdd")
elif d.get("against_voucher_type") == "Sales Invoice":
PieceRef = _(d.get("InvName"))
PieceDate = format_datetime(d.get("InvPostDate"), "yyyyMMdd")
elif d.get("against_voucher_type") == "Purchase Invoice":
PieceRef = _(d.get("PurName"))
PieceDate = format_datetime(d.get("PurPostDate"), "yyyyMMdd")
elif d.get("against_voucher_type") == "Journal Entry":
PieceRef = _(d.get("JnlRef"))
PieceDate = format_datetime(d.get("JnlPostDate"), "yyyyMMdd")
elif d.get("against_voucher_type") == "Payment Entry":
PieceRef = _(d.get("PayName"))
PieceDate = format_datetime(d.get("PayPostDate"), "yyyyMMdd")
elif d.get("voucher_type") == "Period Closing Voucher":
PieceRef = _("Period Closing Journal")
PieceDate = format_datetime(d.get("GlPostDate"), "yyyyMMdd")
EcritureLib = _("Opening Entry Journal")
if d.get("voucher_type") == "Sales Invoice":
EcritureLib = d.get("InvTitle")
elif d.get("voucher_type") == "Purchase Invoice":
EcritureLib = d.get("PurTitle")
elif d.get("voucher_type") == "Journal Entry":
EcritureLib = d.get("JnlTitle")
elif d.get("voucher_type") == "Payment Entry":
EcritureLib = d.get("PayTitle")
else:
PieceRef = _("No Reference")
PieceDate = format_datetime(d.get("GlPostDate"), "yyyyMMdd")
EcritureLib = d.get("voucher_type")
PieceDate = format_datetime(d.get("GlPostDate"), "yyyyMMdd")
debit = '{:.2f}'.format(d.get("debit")).replace(".", ",")
@ -171,7 +161,7 @@ def get_result_as_list(data, filters):
Montantdevise = '{:.2f}'.format(d.get("debit")).replace(".", ",") if d.get("debit") != 0 else '{:.2f}'.format(d.get("credit")).replace(".", ",")
row = [JournalCode, d.get("voucher_type"), EcritureNum, EcritureDate, CompteNum, d.get("account"), CompAuxNum, CompAuxLib,
PieceRef, PieceDate, d.get("voucher_no"), debit, credit, "", "", ValidDate, Montantdevise, Idevise]
PieceRef, PieceDate, EcritureLib, debit, credit, "", "", ValidDate, Montantdevise, Idevise]
result.append(row)