diff --git a/src/accounting/static/js/journal-entry-editor.js b/src/accounting/static/js/journal-entry-editor.js index 7e9b544..9041fea 100644 --- a/src/accounting/static/js/journal-entry-editor.js +++ b/src/accounting/static/js/journal-entry-editor.js @@ -259,10 +259,8 @@ class JournalEntryEditor { */ #initializeSummaryEditors() { const editors = {}; - const forms = Array.from(document.getElementsByClassName("accounting-summary-editor")); - for (const form of forms) { - const summaryEditor = new SummaryEditor(this, form); - editors[summaryEditor.entryType] = summaryEditor; + for (const entryType of ["debit", "credit"]) { + editors[entryType] = new SummaryEditor(this, entryType); } return editors; } diff --git a/src/accounting/static/js/summary-editor.js b/src/accounting/static/js/summary-editor.js index 6e93ed4..dad7d2f 100644 --- a/src/accounting/static/js/summary-editor.js +++ b/src/accounting/static/js/summary-editor.js @@ -110,13 +110,13 @@ class SummaryEditor { * Constructs a summary editor. * * @param entryEditor {JournalEntryEditor} the journal entry editor - * @param form {HTMLFormElement} the summary editor form + * @param entryType {string} the entry type, either "debit" or "credit" */ - constructor(entryEditor, form) { + constructor(entryEditor, entryType) { this.#entryEditor = entryEditor; - this.#form = form; - this.entryType = form.dataset.entryType; - this.prefix = "accounting-summary-editor-" + form.dataset.entryType; + this.entryType = entryType; + this.prefix = "accounting-summary-editor-" + entryType; + this.#form = document.getElementById(this.prefix); this.#modal = document.getElementById(this.prefix + "-modal"); this.summary = document.getElementById(this.prefix + "-summary"); this.#offsetButton = document.getElementById(this.prefix + "-offset"); diff --git a/src/accounting/templates/accounting/transaction/include/summary-editor-modal.html b/src/accounting/templates/accounting/transaction/include/summary-editor-modal.html index 67a1aa2..559a2b0 100644 --- a/src/accounting/templates/accounting/transaction/include/summary-editor-modal.html +++ b/src/accounting/templates/accounting/transaction/include/summary-editor-modal.html @@ -19,7 +19,7 @@ summary-editor-modal.html: The modal of the summary editor Author: imacat@mail.imacat.idv.tw (imacat) First written: 2023/2/28 #} -
+