mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-16 07:57:33 +08:00
code refactor
This commit is contained in:
@@ -442,14 +442,11 @@ function updateClosingBalance(): void {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -466,8 +463,6 @@ function updateClosingBalance(): void {
|
||||
type: newTransactionType,
|
||||
amount: newTransactionAmount,
|
||||
accountId: accountId.value,
|
||||
setAmount: true,
|
||||
setTransactionTime: setTransactionTime,
|
||||
noTransactionDraft: true
|
||||
}).then(result => {
|
||||
if (result && result.message) {
|
||||
|
||||
@@ -1580,15 +1580,12 @@ function changeAmountFilter(filterType: string): void {
|
||||
function add(template?: TransactionTemplate): void {
|
||||
const currentUnixTime = getCurrentUnixTime();
|
||||
|
||||
let setTransactionTime = false;
|
||||
let newTransactionTime: number | undefined = undefined;
|
||||
|
||||
if (query.value.maxTime && query.value.minTime) {
|
||||
if (query.value.maxTime < currentUnixTime) {
|
||||
setTransactionTime = true;
|
||||
newTransactionTime = query.value.maxTime;
|
||||
} else if (currentUnixTime < query.value.minTime) {
|
||||
setTransactionTime = true;
|
||||
newTransactionTime = query.value.minTime;
|
||||
}
|
||||
}
|
||||
@@ -1599,8 +1596,7 @@ function add(template?: TransactionTemplate): void {
|
||||
categoryId: queryAllFilterCategoryIdsCount.value === 1 ? query.value.categoryIds : '',
|
||||
accountId: queryAllFilterAccountIdsCount.value === 1 ? query.value.accountIds : '',
|
||||
tagIds: query.value.tagIds || '',
|
||||
template: template,
|
||||
setTransactionTime: setTransactionTime
|
||||
template: template
|
||||
}).then(result => {
|
||||
if (result && result.message) {
|
||||
snackbar.value?.showMessage(result.message);
|
||||
|
||||
@@ -497,7 +497,6 @@ 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 {
|
||||
getTimezoneOffsetMinutes,
|
||||
getCurrentUnixTime
|
||||
@@ -538,9 +537,6 @@ export interface TransactionEditOptions extends SetTransactionOptions {
|
||||
template?: TransactionTemplate;
|
||||
currentTransaction?: Transaction;
|
||||
currentTemplate?: TransactionTemplate;
|
||||
time?: number;
|
||||
setAmount?: boolean;
|
||||
setTransactionTime?: boolean;
|
||||
noTransactionDraft?: boolean;
|
||||
}
|
||||
|
||||
@@ -688,6 +684,7 @@ function setTransaction(newTransaction: Transaction | null, options: SetTransact
|
||||
allTagsMap.value,
|
||||
defaultAccountId.value,
|
||||
{
|
||||
time: options.time,
|
||||
type: options.type,
|
||||
categoryId: options.categoryId,
|
||||
accountId: options.accountId,
|
||||
@@ -714,10 +711,7 @@ function open(options: TransactionEditOptions): Promise<TransactionEditResponse
|
||||
originalTransactionEditable.value = false;
|
||||
noTransactionDraft.value = options.noTransactionDraft || false;
|
||||
|
||||
if (options.setAmount) {
|
||||
initAmount.value = options.amount;
|
||||
}
|
||||
|
||||
initAmount.value = options.amount;
|
||||
initCategoryId.value = options.categoryId;
|
||||
initAccountId.value = options.accountId;
|
||||
initTagIds.value = options.tagIds;
|
||||
@@ -828,14 +822,6 @@ function open(options: TransactionEditOptions): Promise<TransactionEditResponse
|
||||
(transaction.value as TransactionTemplate).fillFrom(template);
|
||||
} else {
|
||||
setTransaction(null, options, true, true);
|
||||
|
||||
if (options.setAmount && isDefined(options.amount)) {
|
||||
transaction.value.sourceAmount = options.amount;
|
||||
}
|
||||
|
||||
if (options.setTransactionTime && isDefined(options.time)) {
|
||||
transaction.value.time = options.time;
|
||||
}
|
||||
}
|
||||
|
||||
loading.value = false;
|
||||
|
||||
Reference in New Issue
Block a user