Merge pull request #37229 from FHenry/dev_remove_regional_france
refactor!: Remove Regionalisation of France as now there is an App ERPNext France to manage it
This commit is contained in:
commit
559466e1ef
@ -10,7 +10,7 @@ from erpnext import get_region
|
||||
|
||||
def check_deletion_permission(doc, method):
|
||||
region = get_region(doc.company)
|
||||
if region in ["Nepal", "France"] and doc.docstatus != 0:
|
||||
if region in ["Nepal"] and doc.docstatus != 0:
|
||||
frappe.throw(_("Deletion is not permitted for country {0}").format(region))
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ def create_transaction_log(doc, method):
|
||||
Called on submit of Sales Invoice and Payment Entry.
|
||||
"""
|
||||
region = get_region()
|
||||
if region not in ["France", "Germany"]:
|
||||
if region not in ["Germany"]:
|
||||
return
|
||||
|
||||
data = str(doc.as_dict())
|
||||
|
@ -1,5 +0,0 @@
|
||||
{% if address_line1 %}{{ address_line1 }}{% endif -%}
|
||||
{% if address_line2 %}<br>{{ address_line2 }}{% endif -%}
|
||||
{% if pincode %}<br>{{ pincode }}{% endif -%}
|
||||
{% if city %} {{ city }}{% endif -%}
|
||||
{% if country %}<br>{{ country }}{% endif -%}
|
@ -1,30 +0,0 @@
|
||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
|
||||
import frappe
|
||||
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
|
||||
|
||||
|
||||
def setup(company=None, patch=True):
|
||||
make_custom_fields()
|
||||
add_custom_roles_for_reports()
|
||||
|
||||
|
||||
def make_custom_fields():
|
||||
custom_fields = {
|
||||
"Company": [
|
||||
dict(fieldname="siren_number", label="SIREN Number", fieldtype="Data", insert_after="website")
|
||||
]
|
||||
}
|
||||
|
||||
create_custom_fields(custom_fields)
|
||||
|
||||
|
||||
def add_custom_roles_for_reports():
|
||||
report_name = "Fichier des Ecritures Comptables [FEC]"
|
||||
|
||||
if not frappe.db.get_value("Custom Role", dict(report=report_name)):
|
||||
frappe.get_doc(
|
||||
dict(doctype="Custom Role", report=report_name, roles=[dict(role="Accounts Manager")])
|
||||
).insert()
|
@ -1,8 +0,0 @@
|
||||
# Copyright (c) 2018, Frappe Technologies and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
|
||||
# don't remove this function it is used in tests
|
||||
def test_method():
|
||||
"""test function"""
|
||||
return "overridden"
|
@ -1,97 +0,0 @@
|
||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
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": erpnext.utils.get_fiscal_year(frappe.datetime.get_today()),
|
||||
"reqd": 1
|
||||
}
|
||||
],
|
||||
onload: function(query_report) {
|
||||
query_report.page.add_inner_button(__("Export"), function() {
|
||||
fec_export(query_report);
|
||||
});
|
||||
|
||||
query_report.add_make_chart_button = function() {
|
||||
//
|
||||
};
|
||||
|
||||
query_report.export_report = function() {
|
||||
fec_export(query_report);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
let fec_export = function(query_report) {
|
||||
const fiscal_year = query_report.get_values().fiscal_year;
|
||||
const company = query_report.get_values().company;
|
||||
|
||||
frappe.db.get_value("Company", company, "siren_number", (value) => {
|
||||
const company_data = value.siren_number;
|
||||
if (company_data === null || company_data === undefined) {
|
||||
frappe.msgprint(__("Please register the SIREN number in the company information file"));
|
||||
} else {
|
||||
frappe.db.get_value("Fiscal Year", fiscal_year, "year_end_date", (r) => {
|
||||
const fy = r.year_end_date;
|
||||
const title = company_data + "FEC" + moment(fy).format('YYYYMMDD');
|
||||
const column_row = query_report.columns.map(col => col.label);
|
||||
const column_data = query_report.get_data_for_csv(false);
|
||||
const result = [column_row].concat(column_data);
|
||||
downloadify(result, null, title);
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
let downloadify = function(data, roles, title) {
|
||||
if (roles && roles.length && !has_common(roles, roles)) {
|
||||
frappe.msgprint(__("Export not allowed. You need {0} role to export.", [frappe.utils.comma_or(roles)]));
|
||||
return;
|
||||
}
|
||||
|
||||
const filename = title + ".txt";
|
||||
let csv_data = to_tab_csv(data);
|
||||
const a = document.createElement('a');
|
||||
|
||||
if ("download" in a) {
|
||||
// Used Blob object, because it can handle large files
|
||||
let blob_object = new Blob([csv_data], {
|
||||
type: 'text/csv;charset=UTF-8'
|
||||
});
|
||||
a.href = URL.createObjectURL(blob_object);
|
||||
a.download = filename;
|
||||
|
||||
} else {
|
||||
// use old method
|
||||
a.href = 'data:attachment/csv,' + encodeURIComponent(csv_data);
|
||||
a.download = filename;
|
||||
a.target = "_blank";
|
||||
}
|
||||
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
|
||||
document.body.removeChild(a);
|
||||
};
|
||||
|
||||
let to_tab_csv = function(data) {
|
||||
let res = [];
|
||||
$.each(data, function(i, row) {
|
||||
res.push(row.join("\t"));
|
||||
});
|
||||
return res.join("\n");
|
||||
};
|
@ -1,19 +0,0 @@
|
||||
{
|
||||
"add_total_row": 0,
|
||||
"apply_user_permissions": 0,
|
||||
"creation": "2018-01-10 15:10:16.650129",
|
||||
"disabled": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "Report",
|
||||
"idx": 0,
|
||||
"is_standard": "Yes",
|
||||
"modified": "2018-01-11 10:27:25.595485",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Regional",
|
||||
"name": "Fichier des Ecritures Comptables [FEC]",
|
||||
"owner": "Administrator",
|
||||
"ref_doctype": "GL Entry",
|
||||
"report_name": "Fichier des Ecritures Comptables [FEC]",
|
||||
"report_type": "Script Report",
|
||||
"roles": []
|
||||
}
|
@ -1,339 +0,0 @@
|
||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
import re
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import format_datetime
|
||||
|
||||
COLUMNS = [
|
||||
{
|
||||
"label": "JournalCode",
|
||||
"fieldname": "JournalCode",
|
||||
"fieldtype": "Data",
|
||||
"width": 90,
|
||||
},
|
||||
{
|
||||
"label": "JournalLib",
|
||||
"fieldname": "JournalLib",
|
||||
"fieldtype": "Data",
|
||||
"width": 90,
|
||||
},
|
||||
{
|
||||
"label": "EcritureNum",
|
||||
"fieldname": "EcritureNum",
|
||||
"fieldtype": "Data",
|
||||
"width": 90,
|
||||
},
|
||||
{
|
||||
"label": "EcritureDate",
|
||||
"fieldname": "EcritureDate",
|
||||
"fieldtype": "Data",
|
||||
"width": 90,
|
||||
},
|
||||
{
|
||||
"label": "CompteNum",
|
||||
"fieldname": "CompteNum",
|
||||
"fieldtype": "Link",
|
||||
"options": "Account",
|
||||
"width": 100,
|
||||
},
|
||||
{
|
||||
"label": "CompteLib",
|
||||
"fieldname": "CompteLib",
|
||||
"fieldtype": "Link",
|
||||
"options": "Account",
|
||||
"width": 200,
|
||||
},
|
||||
{
|
||||
"label": "CompAuxNum",
|
||||
"fieldname": "CompAuxNum",
|
||||
"fieldtype": "Data",
|
||||
"width": 90,
|
||||
},
|
||||
{
|
||||
"label": "CompAuxLib",
|
||||
"fieldname": "CompAuxLib",
|
||||
"fieldtype": "Data",
|
||||
"width": 90,
|
||||
},
|
||||
{
|
||||
"label": "PieceRef",
|
||||
"fieldname": "PieceRef",
|
||||
"fieldtype": "Data",
|
||||
"width": 90,
|
||||
},
|
||||
{
|
||||
"label": "PieceDate",
|
||||
"fieldname": "PieceDate",
|
||||
"fieldtype": "Data",
|
||||
"width": 90,
|
||||
},
|
||||
{
|
||||
"label": "EcritureLib",
|
||||
"fieldname": "EcritureLib",
|
||||
"fieldtype": "Data",
|
||||
"width": 90,
|
||||
},
|
||||
{
|
||||
"label": "Debit",
|
||||
"fieldname": "Debit",
|
||||
"fieldtype": "Data",
|
||||
"width": 90,
|
||||
},
|
||||
{
|
||||
"label": "Credit",
|
||||
"fieldname": "Credit",
|
||||
"fieldtype": "Data",
|
||||
"width": 90,
|
||||
},
|
||||
{
|
||||
"label": "EcritureLet",
|
||||
"fieldname": "EcritureLet",
|
||||
"fieldtype": "Data",
|
||||
"width": 90,
|
||||
},
|
||||
{
|
||||
"label": "DateLet",
|
||||
"fieldname": "DateLet",
|
||||
"fieldtype": "Data",
|
||||
"width": 90,
|
||||
},
|
||||
{
|
||||
"label": "ValidDate",
|
||||
"fieldname": "ValidDate",
|
||||
"fieldtype": "Data",
|
||||
"width": 90,
|
||||
},
|
||||
{
|
||||
"label": "Montantdevise",
|
||||
"fieldname": "Montantdevise",
|
||||
"fieldtype": "Data",
|
||||
"width": 90,
|
||||
},
|
||||
{
|
||||
"label": "Idevise",
|
||||
"fieldname": "Idevise",
|
||||
"fieldtype": "Data",
|
||||
"width": 90,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def execute(filters=None):
|
||||
validate_filters(filters)
|
||||
return COLUMNS, get_result(
|
||||
company=filters["company"],
|
||||
fiscal_year=filters["fiscal_year"],
|
||||
)
|
||||
|
||||
|
||||
def validate_filters(filters):
|
||||
if not filters.get("company"):
|
||||
frappe.throw(_("{0} is mandatory").format(_("Company")))
|
||||
|
||||
if not filters.get("fiscal_year"):
|
||||
frappe.throw(_("{0} is mandatory").format(_("Fiscal Year")))
|
||||
|
||||
|
||||
def get_gl_entries(company, fiscal_year):
|
||||
gle = frappe.qb.DocType("GL Entry")
|
||||
sales_invoice = frappe.qb.DocType("Sales Invoice")
|
||||
purchase_invoice = frappe.qb.DocType("Purchase Invoice")
|
||||
journal_entry = frappe.qb.DocType("Journal Entry")
|
||||
payment_entry = frappe.qb.DocType("Payment Entry")
|
||||
customer = frappe.qb.DocType("Customer")
|
||||
supplier = frappe.qb.DocType("Supplier")
|
||||
employee = frappe.qb.DocType("Employee")
|
||||
|
||||
debit = frappe.query_builder.functions.Sum(gle.debit).as_("debit")
|
||||
credit = frappe.query_builder.functions.Sum(gle.credit).as_("credit")
|
||||
debit_currency = frappe.query_builder.functions.Sum(gle.debit_in_account_currency).as_(
|
||||
"debitCurr"
|
||||
)
|
||||
credit_currency = frappe.query_builder.functions.Sum(gle.credit_in_account_currency).as_(
|
||||
"creditCurr"
|
||||
)
|
||||
|
||||
query = (
|
||||
frappe.qb.from_(gle)
|
||||
.left_join(sales_invoice)
|
||||
.on(gle.voucher_no == sales_invoice.name)
|
||||
.left_join(purchase_invoice)
|
||||
.on(gle.voucher_no == purchase_invoice.name)
|
||||
.left_join(journal_entry)
|
||||
.on(gle.voucher_no == journal_entry.name)
|
||||
.left_join(payment_entry)
|
||||
.on(gle.voucher_no == payment_entry.name)
|
||||
.left_join(customer)
|
||||
.on(gle.party == customer.name)
|
||||
.left_join(supplier)
|
||||
.on(gle.party == supplier.name)
|
||||
.left_join(employee)
|
||||
.on(gle.party == employee.name)
|
||||
.select(
|
||||
gle.posting_date.as_("GlPostDate"),
|
||||
gle.name.as_("GlName"),
|
||||
gle.account,
|
||||
gle.transaction_date,
|
||||
debit,
|
||||
credit,
|
||||
debit_currency,
|
||||
credit_currency,
|
||||
gle.voucher_type,
|
||||
gle.voucher_no,
|
||||
gle.against_voucher_type,
|
||||
gle.against_voucher,
|
||||
gle.account_currency,
|
||||
gle.against,
|
||||
gle.party_type,
|
||||
gle.party,
|
||||
sales_invoice.name.as_("InvName"),
|
||||
sales_invoice.title.as_("InvTitle"),
|
||||
sales_invoice.posting_date.as_("InvPostDate"),
|
||||
purchase_invoice.name.as_("PurName"),
|
||||
purchase_invoice.title.as_("PurTitle"),
|
||||
purchase_invoice.posting_date.as_("PurPostDate"),
|
||||
journal_entry.cheque_no.as_("JnlRef"),
|
||||
journal_entry.posting_date.as_("JnlPostDate"),
|
||||
journal_entry.title.as_("JnlTitle"),
|
||||
payment_entry.name.as_("PayName"),
|
||||
payment_entry.posting_date.as_("PayPostDate"),
|
||||
payment_entry.title.as_("PayTitle"),
|
||||
customer.customer_name,
|
||||
customer.name.as_("cusName"),
|
||||
supplier.supplier_name,
|
||||
supplier.name.as_("supName"),
|
||||
employee.employee_name,
|
||||
employee.name.as_("empName"),
|
||||
)
|
||||
.where((gle.company == company) & (gle.fiscal_year == fiscal_year))
|
||||
.groupby(gle.voucher_type, gle.voucher_no, gle.account)
|
||||
.orderby(gle.posting_date, gle.voucher_no)
|
||||
)
|
||||
|
||||
return query.run(as_dict=True)
|
||||
|
||||
|
||||
def get_result(company, fiscal_year):
|
||||
data = get_gl_entries(company, fiscal_year)
|
||||
|
||||
result = []
|
||||
|
||||
company_currency = frappe.get_cached_value("Company", company, "default_currency")
|
||||
accounts = frappe.get_all(
|
||||
"Account", filters={"Company": company}, fields=["name", "account_number"]
|
||||
)
|
||||
|
||||
for d in data:
|
||||
JournalCode = re.split("-|/|[0-9]", d.get("voucher_no"))[0]
|
||||
|
||||
if d.get("voucher_no").startswith("{0}-".format(JournalCode)) or d.get("voucher_no").startswith(
|
||||
"{0}/".format(JournalCode)
|
||||
):
|
||||
EcritureNum = re.split("-|/", d.get("voucher_no"))[1]
|
||||
else:
|
||||
EcritureNum = re.search(r"{0}(\d+)".format(JournalCode), d.get("voucher_no"), re.IGNORECASE)[1]
|
||||
|
||||
EcritureDate = format_datetime(d.get("GlPostDate"), "yyyyMMdd")
|
||||
|
||||
account_number = [
|
||||
account.account_number for account in accounts if account.name == d.get("account")
|
||||
]
|
||||
if account_number[0] is not None:
|
||||
CompteNum = account_number[0]
|
||||
else:
|
||||
frappe.throw(
|
||||
_(
|
||||
"Account number for account {0} is not available.<br> Please setup your Chart of Accounts correctly."
|
||||
).format(d.get("account"))
|
||||
)
|
||||
|
||||
if d.get("party_type") == "Customer":
|
||||
CompAuxNum = d.get("cusName")
|
||||
CompAuxLib = d.get("customer_name")
|
||||
|
||||
elif d.get("party_type") == "Supplier":
|
||||
CompAuxNum = d.get("supName")
|
||||
CompAuxLib = d.get("supplier_name")
|
||||
|
||||
elif d.get("party_type") == "Employee":
|
||||
CompAuxNum = d.get("empName")
|
||||
CompAuxLib = d.get("employee_name")
|
||||
|
||||
elif d.get("party_type") == "Student":
|
||||
CompAuxNum = d.get("stuName")
|
||||
CompAuxLib = d.get("student_name")
|
||||
|
||||
elif d.get("party_type") == "Member":
|
||||
CompAuxNum = d.get("memName")
|
||||
CompAuxLib = d.get("member_name")
|
||||
|
||||
else:
|
||||
CompAuxNum = ""
|
||||
CompAuxLib = ""
|
||||
|
||||
ValidDate = format_datetime(d.get("GlPostDate"), "yyyyMMdd")
|
||||
|
||||
PieceRef = d.get("voucher_no") or "Sans Reference"
|
||||
|
||||
# EcritureLib is the reference title unless it is an opening entry
|
||||
if d.get("is_opening") == "Yes":
|
||||
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:
|
||||
EcritureLib = d.get("voucher_type")
|
||||
|
||||
PieceDate = format_datetime(d.get("GlPostDate"), "yyyyMMdd")
|
||||
|
||||
debit = "{:.2f}".format(d.get("debit")).replace(".", ",")
|
||||
|
||||
credit = "{:.2f}".format(d.get("credit")).replace(".", ",")
|
||||
|
||||
Idevise = d.get("account_currency")
|
||||
|
||||
if Idevise != company_currency:
|
||||
Montantdevise = (
|
||||
"{:.2f}".format(d.get("debitCurr")).replace(".", ",")
|
||||
if d.get("debitCurr") != 0
|
||||
else "{:.2f}".format(d.get("creditCurr")).replace(".", ",")
|
||||
)
|
||||
else:
|
||||
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,
|
||||
EcritureLib,
|
||||
debit,
|
||||
credit,
|
||||
"",
|
||||
"",
|
||||
ValidDate,
|
||||
Montantdevise,
|
||||
Idevise,
|
||||
]
|
||||
|
||||
result.append(row)
|
||||
|
||||
return result
|
@ -14,6 +14,3 @@ class TestInit(unittest.TestCase):
|
||||
def test_regional_overrides(self):
|
||||
frappe.flags.country = "Maldives"
|
||||
self.assertEqual(test_method(), "original")
|
||||
|
||||
frappe.flags.country = "France"
|
||||
self.assertEqual(test_method(), "overridden")
|
||||
|
Loading…
Reference in New Issue
Block a user