mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 00:34:28 +08:00
update closing balance in reconciliation statement page
This commit is contained in:
@@ -3,6 +3,9 @@
|
|||||||
:opened="show" @sheet:open="onSheetOpen" @sheet:closed="onSheetClosed">
|
:opened="show" @sheet:open="onSheetOpen" @sheet:closed="onSheetClosed">
|
||||||
<div class="swipe-handler" style="z-index: 10"></div>
|
<div class="swipe-handler" style="z-index: 10"></div>
|
||||||
<f7-page-content class="margin-top no-padding-top">
|
<f7-page-content class="margin-top no-padding-top">
|
||||||
|
<div class="margin-top padding-horizontal" v-if="hint">
|
||||||
|
<span>{{ hint }}</span>
|
||||||
|
</div>
|
||||||
<div class="numpad-values">
|
<div class="numpad-values">
|
||||||
<span class="numpad-value" :class="currentDisplayNumClass">{{ currentDisplay }}</span>
|
<span class="numpad-value" :class="currentDisplayNumClass">{{ currentDisplay }}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -80,6 +83,7 @@ const props = defineProps<{
|
|||||||
maxValue?: number;
|
maxValue?: number;
|
||||||
currency?: string;
|
currency?: string;
|
||||||
flipNegative?: boolean;
|
flipNegative?: boolean;
|
||||||
|
hint?: string;
|
||||||
show: boolean;
|
show: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
|||||||
@@ -238,10 +238,22 @@
|
|||||||
@dateRange:change="changeCustomDateFilter">
|
@dateRange:change="changeCustomDateFilter">
|
||||||
</date-range-selection-sheet>
|
</date-range-selection-sheet>
|
||||||
|
|
||||||
|
<number-pad-sheet :min-value="TRANSACTION_MIN_AMOUNT"
|
||||||
|
:max-value="TRANSACTION_MAX_AMOUNT"
|
||||||
|
:currency="currentAccountCurrency"
|
||||||
|
:hint="tt('Please enter the new closing balance for the account')"
|
||||||
|
v-model:show="showNewClosingBalanceSheet"
|
||||||
|
v-model="newClosingBalance"
|
||||||
|
@update:model-value="updateClosingBalance"
|
||||||
|
></number-pad-sheet>
|
||||||
|
|
||||||
<f7-actions close-by-outside-click close-on-escape :opened="showMoreActionSheet" @actions:closed="showMoreActionSheet = false">
|
<f7-actions close-by-outside-click close-on-escape :opened="showMoreActionSheet" @actions:closed="showMoreActionSheet = false">
|
||||||
<f7-actions-group>
|
<f7-actions-group>
|
||||||
<f7-actions-button :class="{ 'disabled': loading }" @click="addTransaction()">{{ tt('Add Transaction') }}</f7-actions-button>
|
<f7-actions-button :class="{ 'disabled': loading }" @click="addTransaction()">{{ tt('Add Transaction') }}</f7-actions-button>
|
||||||
</f7-actions-group>
|
</f7-actions-group>
|
||||||
|
<f7-actions-group>
|
||||||
|
<f7-actions-button :class="{ 'disabled': loading }" @click="updateClosingBalance(undefined)">{{ tt('Update Closing Balance') }}</f7-actions-button>
|
||||||
|
</f7-actions-group>
|
||||||
<f7-actions-group>
|
<f7-actions-group>
|
||||||
<f7-actions-button :class="{ 'disabled': loading }" @click="reload(true)">{{ tt('Refresh') }}</f7-actions-button>
|
<f7-actions-button :class="{ 'disabled': loading }" @click="reload(true)">{{ tt('Refresh') }}</f7-actions-button>
|
||||||
</f7-actions-group>
|
</f7-actions-group>
|
||||||
@@ -277,9 +289,12 @@ import { useTransactionsStore } from '@/stores/transaction.ts';
|
|||||||
import { type TimeRangeAndDateType, DateRange, DateRangeScene } from '@/core/datetime.ts';
|
import { type TimeRangeAndDateType, DateRange, DateRangeScene } from '@/core/datetime.ts';
|
||||||
import { AccountType } from '@/core/account.ts';
|
import { AccountType } from '@/core/account.ts';
|
||||||
import { TransactionType } from '@/core/transaction.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 { type TransactionReconciliationStatementResponseItem } from '@/models/transaction.ts';
|
||||||
|
|
||||||
|
import { isDefined } from '@/lib/common.ts';
|
||||||
import {
|
import {
|
||||||
|
getCurrentUnixTime,
|
||||||
getDateTypeByDateRange,
|
getDateTypeByDateRange,
|
||||||
getDateTypeByBillingCycleDateRange,
|
getDateTypeByBillingCycleDateRange,
|
||||||
getDateRangeByDateType,
|
getDateRangeByDateType,
|
||||||
@@ -344,7 +359,9 @@ const loading = ref<boolean>(false);
|
|||||||
const loadingError = ref<unknown | null>(null);
|
const loadingError = ref<unknown | null>(null);
|
||||||
const queryDateRangeType = ref<number>(DateRange.ThisMonth.type);
|
const queryDateRangeType = ref<number>(DateRange.ThisMonth.type);
|
||||||
const transactionToDelete = ref<TransactionReconciliationStatementResponseItem | null>(null);
|
const transactionToDelete = ref<TransactionReconciliationStatementResponseItem | null>(null);
|
||||||
|
const newClosingBalance = ref<number>(0);
|
||||||
const showCustomDateRangeSheet = ref<boolean>(false);
|
const showCustomDateRangeSheet = ref<boolean>(false);
|
||||||
|
const showNewClosingBalanceSheet = ref<boolean>(false);
|
||||||
const showMoreActionSheet = ref<boolean>(false);
|
const showMoreActionSheet = ref<boolean>(false);
|
||||||
const showDeleteActionSheet = ref<boolean>(false);
|
const showDeleteActionSheet = ref<boolean>(false);
|
||||||
const virtualDataItems = ref<ReconciliationStatementVirtualListData>({
|
const virtualDataItems = ref<ReconciliationStatementVirtualListData>({
|
||||||
@@ -490,6 +507,46 @@ function editTransaction(transaction: TransactionReconciliationStatementResponse
|
|||||||
props.f7router.navigate(`/transaction/edit?id=${transaction.id}&type=${transaction.type}`);
|
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 {
|
function removeTransaction(transaction: TransactionReconciliationStatementResponseItem | null, confirm: boolean): void {
|
||||||
if (!transaction) {
|
if (!transaction) {
|
||||||
showAlert('An error occurred');
|
showAlert('An error occurred');
|
||||||
|
|||||||
@@ -509,6 +509,7 @@ import { TransactionTemplate } from '@/models/transaction_template.ts';
|
|||||||
import type { TransactionPictureInfoBasicResponse } from '@/models/transaction_picture_info.ts';
|
import type { TransactionPictureInfoBasicResponse } from '@/models/transaction_picture_info.ts';
|
||||||
import { Transaction } from '@/models/transaction.ts';
|
import { Transaction } from '@/models/transaction.ts';
|
||||||
|
|
||||||
|
import { isDefined } from '@/lib/common.ts';
|
||||||
import {
|
import {
|
||||||
getActualUnixTimeForStore,
|
getActualUnixTimeForStore,
|
||||||
getBrowserTimezoneOffsetMinutes,
|
getBrowserTimezoneOffsetMinutes,
|
||||||
@@ -962,6 +963,14 @@ function init(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
(transaction.value as TransactionTemplate).fillFrom(template);
|
(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;
|
loading.value = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user