Revised the account selector to find the account codes from the form through the TransactionForm class, but not finding the codes by itself.
This commit is contained in:
parent
cdd31b1047
commit
82a6a53dc4
@ -150,14 +150,10 @@ class AccountSelector {
|
||||
* @return {string[]} the account codes that are used in the form
|
||||
*/
|
||||
#getCodesUsedInForm() {
|
||||
const accountCodes = Array.from(document.getElementsByClassName("accounting-" + this.#prefix + "-account-code"));
|
||||
const inUse = [];
|
||||
const inUse = TransactionForm.getAccountCodesUsed(this.#entryType);
|
||||
if (this.#entryEditor.getAccountCode() !== null) {
|
||||
inUse.push(this.#entryEditor.getAccountCode());
|
||||
}
|
||||
for (const accountCode of accountCodes) {
|
||||
inUse.push(accountCode.value);
|
||||
}
|
||||
return inUse
|
||||
}
|
||||
|
||||
|
@ -178,6 +178,20 @@ class TransactionForm {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the account codes used in the form.
|
||||
*
|
||||
* @param entryType {string} the entry type, either "debit" or "credit"
|
||||
* @return {string[]} the account codes used in the form
|
||||
*/
|
||||
#getAccountCodesUsed(entryType) {
|
||||
let inUse = [];
|
||||
for (const currency of this.#currencies) {
|
||||
inUse = inUse.concat(currency.getAccountCodesUsed(entryType));
|
||||
}
|
||||
return inUse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the form.
|
||||
*
|
||||
@ -266,6 +280,16 @@ class TransactionForm {
|
||||
static initialize() {
|
||||
this.#form = new TransactionForm()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the account codes used in the form.
|
||||
*
|
||||
* @param entryType {string} the entry type, either "debit" or "credit"
|
||||
* @return {string[]} the account codes used in the form
|
||||
*/
|
||||
static getAccountCodesUsed(entryType) {
|
||||
return this.#form.#getAccountCodesUsed(entryType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -359,6 +383,21 @@ class CurrencySubForm {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the account codes used in the form.
|
||||
*
|
||||
* @param entryType {string} the entry type, either "debit" or "credit"
|
||||
* @return {string[]} the account codes used in the form
|
||||
*/
|
||||
getAccountCodesUsed(entryType) {
|
||||
if (entryType === "debit") {
|
||||
return this.#debit.getAccountCodesUsed();
|
||||
} else if (entryType === "credit") {
|
||||
return this.#credit.getAccountCodesUsed();
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the form.
|
||||
*
|
||||
@ -577,6 +616,15 @@ class DebitCreditSideSubForm {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the account codes used in the form.
|
||||
*
|
||||
* @return {string[]} the account codes used in the form
|
||||
*/
|
||||
getAccountCodesUsed() {
|
||||
return this.#entries.filter((entry) => entry.getAccountCode() !== null).map((entry) => entry.getAccountCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the form.
|
||||
*
|
||||
@ -735,6 +783,15 @@ class JournalEntrySubForm {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the account code.
|
||||
*
|
||||
* @return {string|null} the account code
|
||||
*/
|
||||
getAccountCode() {
|
||||
return this.#accountCode.value === ""? null: this.#accountCode.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the form.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user