diff --git a/erpnext/regional/doctype/fec_import/fec_import.py b/erpnext/regional/doctype/fec_import/fec_import.py index 086d7d9f1350afc25f7c20d870e2f079bcf97572..534ba489bc5f8ab152a72602f5971d317d9ea6da 100644 --- a/erpnext/regional/doctype/fec_import/fec_import.py +++ b/erpnext/regional/doctype/fec_import/fec_import.py @@ -93,9 +93,9 @@ class FECImport(Document): frappe.throw(_("Please select an import settings document")) self.db_set("error", "") - data = self.get_data() - try: + data = self.get_data() + import_in_progress = FECImportDocumentCreator(settings=self, data=data) import_in_progress.import_data() except Exception: @@ -425,6 +425,7 @@ class FECImportDocumentCreator: if iter_next: continue + print(f"{current_index}/{total_elements}") doc.insert() def process_fec_import_documents(self): @@ -459,25 +460,21 @@ class FECImportDocumentCreator: dokos_journals = { x.journal_code: x.name for x in frappe.get_all( - "Accounting Journal", filters={"disabled": 0}, fields=["journal_code", "name"] + "Accounting Journal", + filters={"disabled": 0, "company": self.settings.company}, + fields=["journal_code", "name"], ) } company_settings = frappe.get_doc("FEC Import Settings", self.settings.import_settings) - journals = {} - mapped_journals = dokos_journals - for mapping in company_settings.get("accounting_journal_mapping", []): - for j in mapped_journals: - if j == mapping.accounting_journal_in_dokos: - journals[mapping.accounting_journal_in_fec] = mapped_journals[j] - continue - - journals[j] = mapped_journals[j] - - mapped_journals = journals + if custom_journals := { + m.accounting_journal_in_fec: m.accounting_journal_in_dokos + for m in company_settings.get("accounting_journal_mapping", []) + }: + dokos_journals = dict(dokos_journals, **custom_journals) - return journals or dokos_journals + return dokos_journals def hash_line(data): diff --git a/erpnext/regional/doctype/fec_import_document/fec_import_document.py b/erpnext/regional/doctype/fec_import_document/fec_import_document.py index e97cec0deda24363bcec0691047b712c9a0191d0..115f3e69fa2fe11d4521bb4368e05b54339a3d79 100644 --- a/erpnext/regional/doctype/fec_import_document/fec_import_document.py +++ b/erpnext/regional/doctype/fec_import_document/fec_import_document.py @@ -94,25 +94,21 @@ class FECImportDocument(Document): dokos_journals = { x.journal_code: x.name for x in frappe.get_all( - "Accounting Journal", filters={"disabled": 0}, fields=["journal_code", "name"] + "Accounting Journal", + filters={"disabled": 0, "company": self.company}, + fields=["journal_code", "name"], ) } company_settings = frappe.get_doc("FEC Import Settings", self.settings) - journals = {} - mapped_journals = dokos_journals - for mapping in company_settings.get("accounting_journal_mapping", []): - for j in mapped_journals: - if j == mapping.accounting_journal_in_dokos: - journals[mapping.accounting_journal_in_fec] = mapped_journals[j] - continue - - journals[j] = mapped_journals[j] - - mapped_journals = journals + if custom_journals := { + m.accounting_journal_in_fec: m.accounting_journal_in_dokos + for m in company_settings.get("accounting_journal_mapping", []) + }: + dokos_journals = dict(dokos_journals, **custom_journals) - return journals or dokos_journals + return dokos_journals def get_gl_account(self, row): if row.account: