diff --git a/src/components/mobile/NumberPadSheet.vue b/src/components/mobile/NumberPadSheet.vue index dbd5cef2..48a58d9a 100644 --- a/src/components/mobile/NumberPadSheet.vue +++ b/src/components/mobile/NumberPadSheet.vue @@ -3,6 +3,9 @@ :opened="show" @sheet:open="onSheetOpen" @sheet:closed="onSheetClosed">
+
+ {{ hint }} +
{{ currentDisplay }}
@@ -80,6 +83,7 @@ const props = defineProps<{ maxValue?: number; currency?: string; flipNegative?: boolean; + hint?: string; show: boolean; }>(); diff --git a/src/views/mobile/accounts/ReconciliationStatementPage.vue b/src/views/mobile/accounts/ReconciliationStatementPage.vue index ab750f93..6095da11 100644 --- a/src/views/mobile/accounts/ReconciliationStatementPage.vue +++ b/src/views/mobile/accounts/ReconciliationStatementPage.vue @@ -238,10 +238,22 @@ @dateRange:change="changeCustomDateFilter"> + + {{ tt('Add Transaction') }} + + {{ tt('Update Closing Balance') }} + {{ tt('Refresh') }} @@ -277,9 +289,12 @@ import { useTransactionsStore } from '@/stores/transaction.ts'; import { type TimeRangeAndDateType, DateRange, DateRangeScene } from '@/core/datetime.ts'; import { AccountType } from '@/core/account.ts'; import { TransactionType } from '@/core/transaction.ts'; +import { TRANSACTION_MIN_AMOUNT, TRANSACTION_MAX_AMOUNT } from '@/consts/transaction.ts'; import { type TransactionReconciliationStatementResponseItem } from '@/models/transaction.ts'; +import { isDefined } from '@/lib/common.ts'; import { + getCurrentUnixTime, getDateTypeByDateRange, getDateTypeByBillingCycleDateRange, getDateRangeByDateType, @@ -344,7 +359,9 @@ const loading = ref(false); const loadingError = ref(null); const queryDateRangeType = ref(DateRange.ThisMonth.type); const transactionToDelete = ref(null); +const newClosingBalance = ref(0); const showCustomDateRangeSheet = ref(false); +const showNewClosingBalanceSheet = ref(false); const showMoreActionSheet = ref(false); const showDeleteActionSheet = ref(false); const virtualDataItems = ref({ @@ -490,6 +507,46 @@ function editTransaction(transaction: TransactionReconciliationStatementResponse props.f7router.navigate(`/transaction/edit?id=${transaction.id}&type=${transaction.type}`); } +function updateClosingBalance(balance?: number): void { + let currentClosingBalance = reconciliationStatements.value?.closingBalance ?? 0; + + if (isCurrentLiabilityAccount.value) { + currentClosingBalance = -currentClosingBalance; + } + + if (!isDefined(balance)) { + newClosingBalance.value = currentClosingBalance; + showNewClosingBalanceSheet.value = true; + return; + } + + const currentUnixTime = getCurrentUnixTime(); + let setTransactionTime = false; + let newTransactionTime: number | undefined = undefined; + + if (endTime.value < currentUnixTime) { + setTransactionTime = true; + newTransactionTime = endTime.value; + } else if (currentUnixTime < startTime.value) { + setTransactionTime = true; + newTransactionTime = startTime.value; + } + + let newTransactionType: TransactionType = isCurrentLiabilityAccount.value ? TransactionType.Expense : TransactionType.Income; + let newTransactionAmount: number = balance - currentClosingBalance; + + if (newTransactionAmount < 0) { + newTransactionType = isCurrentLiabilityAccount.value ? TransactionType.Income : TransactionType.Expense; + newTransactionAmount = -newTransactionAmount; + } + + if (setTransactionTime) { + props.f7router.navigate(`/transaction/add?time=${newTransactionTime}&type=${newTransactionType}&amount=${newTransactionAmount}&accountId=${accountId.value}&withAmount=true&withTime=true`); + } else { + props.f7router.navigate(`/transaction/add?type=${newTransactionType}&amount=${newTransactionAmount}&accountId=${accountId.value}&withAmount=true`); + } +} + function removeTransaction(transaction: TransactionReconciliationStatementResponseItem | null, confirm: boolean): void { if (!transaction) { showAlert('An error occurred'); diff --git a/src/views/mobile/transactions/EditPage.vue b/src/views/mobile/transactions/EditPage.vue index 3054c169..f4e35a54 100644 --- a/src/views/mobile/transactions/EditPage.vue +++ b/src/views/mobile/transactions/EditPage.vue @@ -509,6 +509,7 @@ import { TransactionTemplate } from '@/models/transaction_template.ts'; import type { TransactionPictureInfoBasicResponse } from '@/models/transaction_picture_info.ts'; import { Transaction } from '@/models/transaction.ts'; +import { isDefined } from '@/lib/common.ts'; import { getActualUnixTimeForStore, getBrowserTimezoneOffsetMinutes, @@ -962,6 +963,14 @@ function init(): void { } (transaction.value as TransactionTemplate).fillFrom(template); + } else { + if (query['withAmount'] && query['withAmount'] === 'true' && isDefined(query['amount']) && parseInt(query['amount'])) { + transaction.value.sourceAmount = parseInt(query['amount']); + } + + if (query['withTime'] && query['withTime'] === 'true' && isDefined(query['time']) && parseInt(query['time'])) { + transaction.value.time = parseInt(query['time']); + } } loading.value = false;