mirror of
https://github.com/linuxserver/budge.git
synced 2026-03-09 00:08:38 +08:00
default memo of transfer transactions to tracking accounts is the category, fixed db call from update to insert when updating a transaction and accounts change
This commit is contained in:
parent
51d7a96c18
commit
cb482da465
@ -169,6 +169,14 @@ export class TransactionSubscriber implements EntitySubscriberInterface<Transact
|
||||
|
||||
const account = await manager.getRepository(Account).findOne(transaction.accountId)
|
||||
const payee = await manager.getRepository(Payee).findOne(transaction.payeeId)
|
||||
const transferAccount = await manager.getRepository(Account).findOne(payee.transferAccountId)
|
||||
|
||||
// Set memo to either memo of the original transaction or name of the category it was in
|
||||
let memo = transaction.memo
|
||||
if (!memo && transaction.categoryId && transferAccount.type === AccountTypes.Tracking) {
|
||||
const transactionCategory = await manager.getRepository(Category).findOne(transaction.categoryId)
|
||||
memo = transactionCategory.name
|
||||
}
|
||||
|
||||
const transferTransaction = manager.create(Transaction, {
|
||||
budgetId: transaction.budgetId,
|
||||
@ -179,12 +187,11 @@ export class TransactionSubscriber implements EntitySubscriberInterface<Transact
|
||||
amount: transaction.amount * -1,
|
||||
date: transaction.date,
|
||||
status: TransactionStatus.Pending,
|
||||
memo,
|
||||
})
|
||||
|
||||
await manager.insert(Transaction, transferTransaction)
|
||||
|
||||
const transferAccount = await manager.getRepository(Account).findOne(transferTransaction.accountId)
|
||||
|
||||
transaction.payeeId = transferAccount.transferPayeeId
|
||||
transaction.transferAccountId = transferAccount.id
|
||||
transaction.transferTransactionId = transferTransaction.id
|
||||
@ -323,7 +330,7 @@ export class TransactionSubscriber implements EntitySubscriberInterface<Transact
|
||||
date: transaction.date,
|
||||
status: TransactionStatus.Pending,
|
||||
})
|
||||
await manager.update(Transaction, transferTransaction.id, transferTransaction.getUpdatePayload())
|
||||
await manager.getRepository(Transaction).insert(transferTransaction.getUpdatePayload())
|
||||
transaction.transferTransactionId = transferTransaction.id
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user