Compare commits
6 Commits
884e37fe1b
...
d4b3fe67b9
Author | SHA1 | Date | |
---|---|---|---|
d4b3fe67b9 | |||
5d0757c845 | |||
b69a519904 | |||
122b7b059c | |||
4977847dd8 | |||
b9b197ea27 |
@ -38,7 +38,7 @@ class AccountSelector {
|
|||||||
* The entry type
|
* The entry type
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
entryType;
|
#entryType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The prefix of the HTML ID and class
|
* The prefix of the HTML ID and class
|
||||||
@ -90,7 +90,7 @@ class AccountSelector {
|
|||||||
*/
|
*/
|
||||||
constructor(entryEditor, entryType) {
|
constructor(entryEditor, entryType) {
|
||||||
this.#entryEditor = entryEditor
|
this.#entryEditor = entryEditor
|
||||||
this.entryType = entryType;
|
this.#entryType = entryType;
|
||||||
this.#prefix = "accounting-account-selector-" + entryType;
|
this.#prefix = "accounting-account-selector-" + entryType;
|
||||||
this.#query = document.getElementById(this.#prefix + "-query");
|
this.#query = document.getElementById(this.#prefix + "-query");
|
||||||
this.#queryNoResult = document.getElementById(this.#prefix + "-option-no-result");
|
this.#queryNoResult = document.getElementById(this.#prefix + "-option-no-result");
|
||||||
@ -143,7 +143,7 @@ class AccountSelector {
|
|||||||
* @return {string[]} the account codes that are used in the form
|
* @return {string[]} the account codes that are used in the form
|
||||||
*/
|
*/
|
||||||
#getCodesUsedInForm() {
|
#getCodesUsedInForm() {
|
||||||
const inUse = this.#entryEditor.form.getAccountCodesUsed(this.entryType);
|
const inUse = this.#entryEditor.form.getAccountCodesUsed(this.#entryType);
|
||||||
if (this.#entryEditor.accountCode !== null) {
|
if (this.#entryEditor.accountCode !== null) {
|
||||||
inUse.push(this.#entryEditor.accountCode);
|
inUse.push(this.#entryEditor.accountCode);
|
||||||
}
|
}
|
||||||
|
@ -238,8 +238,8 @@ class JournalEntryEditor {
|
|||||||
this.#amountError = document.getElementById(this.#prefix + "-amount-error");
|
this.#amountError = document.getElementById(this.#prefix + "-amount-error");
|
||||||
this.#summaryEditors = SummaryEditor.getInstances(this);
|
this.#summaryEditors = SummaryEditor.getInstances(this);
|
||||||
this.#accountSelectors = AccountSelector.getInstances(this);
|
this.#accountSelectors = AccountSelector.getInstances(this);
|
||||||
this.originalEntrySelector = new OriginalEntrySelector();
|
this.originalEntrySelector = new OriginalEntrySelector(this);
|
||||||
this.#originalEntryControl.onclick = () => this.originalEntrySelector.onOpen(this, this.originalEntryId)
|
this.#originalEntryControl.onclick = () => this.originalEntrySelector.onOpen()
|
||||||
this.#originalEntryDelete.onclick = () => this.clearOriginalEntry();
|
this.#originalEntryDelete.onclick = () => this.clearOriginalEntry();
|
||||||
this.#summaryControl.onclick = () => this.#summaryEditors[this.entryType].onOpen();
|
this.#summaryControl.onclick = () => this.#summaryEditors[this.entryType].onOpen();
|
||||||
this.#accountControl.onclick = () => this.#accountSelectors[this.entryType].onOpen();
|
this.#accountControl.onclick = () => this.#accountSelectors[this.entryType].onOpen();
|
||||||
|
@ -28,18 +28,18 @@
|
|||||||
*/
|
*/
|
||||||
class OriginalEntrySelector {
|
class OriginalEntrySelector {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The journal entry editor
|
||||||
|
* @type {JournalEntryEditor}
|
||||||
|
*/
|
||||||
|
entryEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The prefix of the HTML ID and class
|
* The prefix of the HTML ID and class
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
#prefix = "accounting-original-entry-selector";
|
#prefix = "accounting-original-entry-selector";
|
||||||
|
|
||||||
/**
|
|
||||||
* The modal of the original entry editor
|
|
||||||
* @type {HTMLDivElement}
|
|
||||||
*/
|
|
||||||
#modal;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The query input
|
* The query input
|
||||||
* @type {HTMLInputElement}
|
* @type {HTMLInputElement}
|
||||||
@ -70,12 +70,6 @@ class OriginalEntrySelector {
|
|||||||
*/
|
*/
|
||||||
#optionById;
|
#optionById;
|
||||||
|
|
||||||
/**
|
|
||||||
* The journal entry editor
|
|
||||||
* @type {JournalEntryEditor}
|
|
||||||
*/
|
|
||||||
entryEditor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The currency code
|
* The currency code
|
||||||
* @type {string}
|
* @type {string}
|
||||||
@ -90,9 +84,10 @@ class OriginalEntrySelector {
|
|||||||
/**
|
/**
|
||||||
* Constructs an original entry selector.
|
* Constructs an original entry selector.
|
||||||
*
|
*
|
||||||
|
* @param entryEditor {JournalEntryEditor} the journal entry editor
|
||||||
*/
|
*/
|
||||||
constructor() {
|
constructor(entryEditor) {
|
||||||
this.#modal = document.getElementById(this.#prefix + "-modal");
|
this.entryEditor = entryEditor;
|
||||||
this.#query = document.getElementById(this.#prefix + "-query");
|
this.#query = document.getElementById(this.#prefix + "-query");
|
||||||
this.#queryNoResult = document.getElementById(this.#prefix + "-option-no-result");
|
this.#queryNoResult = document.getElementById(this.#prefix + "-option-no-result");
|
||||||
this.#optionList = document.getElementById(this.#prefix + "-option-list");
|
this.#optionList = document.getElementById(this.#prefix + "-option-list");
|
||||||
@ -181,15 +176,12 @@ class OriginalEntrySelector {
|
|||||||
/**
|
/**
|
||||||
* The callback when the original entry selector is shown.
|
* 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) {
|
onOpen() {
|
||||||
this.entryEditor = entryEditor
|
this.#currencyCode = this.entryEditor.getCurrencyCode();
|
||||||
this.#currencyCode = entryEditor.getCurrencyCode();
|
this.#entryType = this.entryEditor.entryType;
|
||||||
this.#entryType = entryEditor.entryType;
|
|
||||||
for (const option of this.#options) {
|
for (const option of this.#options) {
|
||||||
option.setActive(option.id === originalEntryId);
|
option.setActive(option.id === this.entryEditor.originalEntryId);
|
||||||
}
|
}
|
||||||
this.#query.value = "";
|
this.#query.value = "";
|
||||||
this.#updateNetBalances();
|
this.#updateNetBalances();
|
||||||
|
@ -175,7 +175,7 @@ class MonthTab extends TabPlane {
|
|||||||
let start = monthChooser.dataset.start;
|
let start = monthChooser.dataset.start;
|
||||||
this.#monthChooser = new tempusDominus.TempusDominus(monthChooser, {
|
this.#monthChooser = new tempusDominus.TempusDominus(monthChooser, {
|
||||||
restrictions: {
|
restrictions: {
|
||||||
minDate: start,
|
minDate: new Date(start),
|
||||||
},
|
},
|
||||||
display: {
|
display: {
|
||||||
inline: true,
|
inline: true,
|
||||||
@ -184,7 +184,7 @@ class MonthTab extends TabPlane {
|
|||||||
clock: false,
|
clock: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
defaultDate: monthChooser.dataset.default,
|
defaultDate: new Date(monthChooser.dataset.default),
|
||||||
});
|
});
|
||||||
monthChooser.addEventListener(tempusDominus.Namespace.events.change, (e) => {
|
monthChooser.addEventListener(tempusDominus.Namespace.events.change, (e) => {
|
||||||
const date = e.detail.date;
|
const date = e.detail.date;
|
||||||
|
@ -132,7 +132,7 @@ class SummaryEditor {
|
|||||||
this.currentTab = this.tabPlanes.general;
|
this.currentTab = this.tabPlanes.general;
|
||||||
this.#initializeSuggestedAccounts();
|
this.#initializeSuggestedAccounts();
|
||||||
this.summary.onchange = () => this.#onSummaryChange();
|
this.summary.onchange = () => this.#onSummaryChange();
|
||||||
this.#offsetButton.onclick = () => this.#entryEditor.originalEntrySelector.onOpen(this.#entryEditor);
|
this.#offsetButton.onclick = () => this.#entryEditor.originalEntrySelector.onOpen();
|
||||||
this.#form.onsubmit = () => {
|
this.#form.onsubmit = () => {
|
||||||
if (this.currentTab.validate()) {
|
if (this.currentTab.validate()) {
|
||||||
this.#submit();
|
this.#submit();
|
||||||
|
@ -32,7 +32,7 @@ First written: 2023/1/27
|
|||||||
<script src="{{ url_for("babel_catalog") }}"></script>
|
<script src="{{ url_for("babel_catalog") }}"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/decimal.js-light@2.5.1/decimal.min.js" integrity="sha384-QdsxGEq4Y0erX8WUIsZJDtfoSSyBF6dmNCnzRNYCa2AOM/xzNsyhHu0RbdFBAm+l" crossorigin="anonymous"></script>
|
<script src="https://cdn.jsdelivr.net/npm/decimal.js-light@2.5.1/decimal.min.js" integrity="sha384-QdsxGEq4Y0erX8WUIsZJDtfoSSyBF6dmNCnzRNYCa2AOM/xzNsyhHu0RbdFBAm+l" crossorigin="anonymous"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.2.10/dist/js/tempus-dominus.min.js" integrity="sha384-BiIgBzfRUwCKCLJTFUfZPl8n4yeDooQYkgtJBNVI4Gg6OAfIFO6FhEK6KiO1dvhA" crossorigin="anonymous"></script>
|
<script src="https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.4.3/dist/js/tempus-dominus.min.js" integrity="sha384-2MkID2vkc9sxBCqs2us3mB8fV+c0o7uPtOvAPjaC8gKv9Bk21UHT0r2Q7Kv70+zO" crossorigin="anonymous"></script>
|
||||||
{% block scripts %}{% endblock %}
|
{% block scripts %}{% endblock %}
|
||||||
<title>{% block title %}{% endblock %}</title>
|
<title>{% block title %}{% endblock %}</title>
|
||||||
</head>
|
</head>
|
||||||
|
Loading…
Reference in New Issue
Block a user