@@ -14,7 +14,12 @@ import {
1414import { AccountModel } from "@/models/Account" ;
1515import { TransactionModel } from "@/models/Transaction" ;
1616
17- type TransactionType = "earning" | "expense" ;
17+ type EditableTransactionType = "earning" | "expense" ;
18+ type TransactionType =
19+ | EditableTransactionType
20+ | "transfer"
21+ | "transfer_fee"
22+ | "loan_repayment" ;
1823
1924export type TransactionListItem = {
2025 id : string ;
@@ -27,7 +32,7 @@ export type TransactionListItem = {
2732 createdAt : string ;
2833} ;
2934
30- function effectFor ( type : TransactionType , amount : number ) {
35+ function effectFor ( type : EditableTransactionType , amount : number ) {
3136 return type === "earning" ? amount : - amount ;
3237}
3338
@@ -207,11 +212,11 @@ export async function updateTransactionForTenant(
207212 await applyBalanceEffectOrThrow (
208213 existing . accountId . toString ( ) ,
209214 tenantId ,
210- - effectFor ( existing . type as TransactionType , existing . amount ) ,
215+ - effectFor ( existing . type as EditableTransactionType , existing . amount ) ,
211216 ) ;
212217
213218 const nextAccountId = payload . accountId ?? existing . accountId . toString ( ) ;
214- const nextType = ( payload . type ?? existing . type ) as TransactionType ;
219+ const nextType = ( payload . type ?? existing . type ) as EditableTransactionType ;
215220 const nextAmount = payload . amount ?? existing . amount ;
216221
217222 await applyBalanceEffectOrThrow (
@@ -276,7 +281,7 @@ export async function deleteTransactionForTenant(
276281 await applyBalanceEffectOrThrow (
277282 existing . accountId . toString ( ) ,
278283 tenantId ,
279- - effectFor ( existing . type as TransactionType , existing . amount ) ,
284+ - effectFor ( existing . type as EditableTransactionType , existing . amount ) ,
280285 ) ;
281286
282287 await existing . deleteOne ( ) ;
0 commit comments