diff --git a/src/accounting/static/js/journal-entry-editor.js b/src/accounting/static/js/journal-entry-editor.js index 6ac41d2..1f9eb09 100644 --- a/src/accounting/static/js/journal-entry-editor.js +++ b/src/accounting/static/js/journal-entry-editor.js @@ -238,8 +238,8 @@ class JournalEntryEditor { this.#amountError = document.getElementById(this.#prefix + "-amount-error"); this.#summaryEditors = SummaryEditor.getInstances(this); this.#accountSelectors = AccountSelector.getInstances(this); - this.originalEntrySelector = new OriginalEntrySelector(); - this.#originalEntryControl.onclick = () => this.originalEntrySelector.onOpen(this, this.originalEntryId) + this.originalEntrySelector = new OriginalEntrySelector(this); + this.#originalEntryControl.onclick = () => this.originalEntrySelector.onOpen(this.originalEntryId) this.#originalEntryDelete.onclick = () => this.clearOriginalEntry(); this.#summaryControl.onclick = () => this.#summaryEditors[this.entryType].onOpen(); this.#accountControl.onclick = () => this.#accountSelectors[this.entryType].onOpen(); diff --git a/src/accounting/static/js/original-entry-selector.js b/src/accounting/static/js/original-entry-selector.js index f7eb2db..b006128 100644 --- a/src/accounting/static/js/original-entry-selector.js +++ b/src/accounting/static/js/original-entry-selector.js @@ -28,6 +28,12 @@ */ class OriginalEntrySelector { + /** + * The journal entry editor + * @type {JournalEntryEditor} + */ + entryEditor; + /** * The prefix of the HTML ID and class * @type {string} @@ -64,12 +70,6 @@ class OriginalEntrySelector { */ #optionById; - /** - * The journal entry editor - * @type {JournalEntryEditor} - */ - entryEditor; - /** * The currency code * @type {string} @@ -84,8 +84,10 @@ class OriginalEntrySelector { /** * Constructs an original entry selector. * + * @param entryEditor {JournalEntryEditor} the journal entry editor */ - constructor() { + constructor(entryEditor) { + this.entryEditor = entryEditor; this.#query = document.getElementById(this.#prefix + "-query"); this.#queryNoResult = document.getElementById(this.#prefix + "-option-no-result"); this.#optionList = document.getElementById(this.#prefix + "-option-list"); @@ -174,13 +176,11 @@ class OriginalEntrySelector { /** * The callback when the original entry selector is shown. * - * @param entryEditor {JournalEntryEditor} the journal entry editor * @param originalEntryId {string|null} the ID of the original entry */ - onOpen(entryEditor, originalEntryId = null) { - this.entryEditor = entryEditor - this.#currencyCode = entryEditor.getCurrencyCode(); - this.#entryType = entryEditor.entryType; + onOpen(originalEntryId = null) { + this.#currencyCode = this.entryEditor.getCurrencyCode(); + this.#entryType = this.entryEditor.entryType; for (const option of this.#options) { option.setActive(option.id === originalEntryId); } diff --git a/src/accounting/static/js/summary-editor.js b/src/accounting/static/js/summary-editor.js index 404e60f..9dc07e8 100644 --- a/src/accounting/static/js/summary-editor.js +++ b/src/accounting/static/js/summary-editor.js @@ -132,7 +132,7 @@ class SummaryEditor { this.currentTab = this.tabPlanes.general; this.#initializeSuggestedAccounts(); this.summary.onchange = () => this.#onSummaryChange(); - this.#offsetButton.onclick = () => this.#entryEditor.originalEntrySelector.onOpen(this.#entryEditor); + this.#offsetButton.onclick = () => this.#entryEditor.originalEntrySelector.onOpen(); this.#form.onsubmit = () => { if (this.currentTab.validate()) { this.#submit();