Revised the JavaScript journal entry editor and summary editor so that the summary editor work with the journal entry editor and does not get into the detail of the journal entry editor.
This commit is contained in:
@ -793,6 +793,12 @@ class JournalEntryEditor {
|
||||
*/
|
||||
#modal;
|
||||
|
||||
/**
|
||||
* The entry type, either "debit" or "credit"
|
||||
* @type {string}
|
||||
*/
|
||||
entryType;
|
||||
|
||||
/**
|
||||
* The control of the account
|
||||
* @type {HTMLDivElement}
|
||||
@ -868,6 +874,9 @@ class JournalEntryEditor {
|
||||
this.#summaryError = document.getElementById("accounting-entry-editor-summary-error");
|
||||
this.#amount = document.getElementById("accounting-entry-editor-amount");
|
||||
this.#amountError = document.getElementById("accounting-entry-editor-amount-error");
|
||||
this.#summaryControl.onclick = () => {
|
||||
SummaryEditor.start(this, this.#summary.dataset.value);
|
||||
};
|
||||
this.#element.onsubmit = () => {
|
||||
if (this.#validate()) {
|
||||
if (this.#entry === null) {
|
||||
@ -882,6 +891,38 @@ class JournalEntryEditor {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the summary from the summary editor.
|
||||
*
|
||||
* @param summary {string} the summary
|
||||
*/
|
||||
saveSummary(summary) {
|
||||
if (summary === "") {
|
||||
this.#summaryControl.classList.remove("accounting-not-empty");
|
||||
} else {
|
||||
this.#summaryControl.classList.add("accounting-not-empty");
|
||||
}
|
||||
this.#summary.dataset.value = summary;
|
||||
this.#summary.innerText = summary;
|
||||
bootstrap.Modal.getOrCreateInstance(this.#modal).show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the summary with the suggested account from the summary editor.
|
||||
*
|
||||
* @param summary {string} the summary
|
||||
* @param accountCode {string} the account code
|
||||
* @param accountText {string} the account text
|
||||
*/
|
||||
saveSummaryWithAccount(summary, accountCode, accountText) {
|
||||
this.#accountControl.classList.add("accounting-not-empty");
|
||||
this.#account.dataset.code = accountCode;
|
||||
this.#account.dataset.text = accountText;
|
||||
this.#account.innerText = accountText;
|
||||
this.#validateAccount();
|
||||
this.saveSummary(summary)
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the form.
|
||||
*
|
||||
@ -950,6 +991,7 @@ class JournalEntryEditor {
|
||||
#onAddNew(side) {
|
||||
this.#entry = null;
|
||||
this.#side = side;
|
||||
this.entryType = this.#side.entryType;
|
||||
this.#element.dataset.entryType = side.entryType;
|
||||
this.#accountControl.classList.remove("accounting-not-empty");
|
||||
this.#accountControl.classList.remove("is-invalid");
|
||||
@ -980,6 +1022,7 @@ class JournalEntryEditor {
|
||||
#onEdit(entry, accountCode, accountText, summary, amount) {
|
||||
this.#entry = entry;
|
||||
this.#side = entry.side;
|
||||
this.entryType = this.#side.entryType;
|
||||
this.#element.dataset.entryType = entry.entryType;
|
||||
if (accountCode === "") {
|
||||
this.#accountControl.classList.remove("accounting-not-empty");
|
||||
|
Reference in New Issue
Block a user