@@ -107,13 +107,14 @@ export class ExpensesService {
107107 payerId : dto . payerId ,
108108 totalAmountCents : totalAmount . toString ( ) ,
109109 category : dto . category ?? null ,
110+ currency : dto . currency ,
110111 } ,
111112 } ,
112113 } ) ;
113114
114115 return tx . expense . findUniqueOrThrow ( {
115116 where : { id : createdExpense . id } ,
116- include : { splits : true } ,
117+ include : { splits : true , receipt : true } ,
117118 } ) ;
118119 } ) ;
119120
@@ -133,7 +134,8 @@ export class ExpensesService {
133134 expenseId : expense . id ,
134135 payerId : expense . payerId ,
135136 totalAmountCents : expense . totalAmountCents . toString ( ) ,
136- category : expense . category as ExpenseDto [ 'category' ] ,
137+ category : expense . category ,
138+ currency : expense . currency ,
137139 } ) ;
138140 incrementExpenseCreated ( groupId ) ;
139141
@@ -152,7 +154,7 @@ export class ExpensesService {
152154 } else {
153155 const rows = await this . prisma . expense . findMany ( {
154156 where : { groupId } ,
155- include : { splits : true } ,
157+ include : { splits : true , receipt : true } ,
156158 orderBy : { createdAt : 'desc' } ,
157159 } ) ;
158160 expenses = rows . map ( ( row ) => this . toExpenseDto ( row ) ) ;
@@ -170,7 +172,7 @@ export class ExpensesService {
170172 }
171173
172174 async getById ( id : string ) : Promise < ExpenseDto > {
173- const expense = await this . prisma . expense . findUnique ( { where : { id } , include : { splits : true } } ) ;
175+ const expense = await this . prisma . expense . findUnique ( { where : { id } , include : { splits : true , receipt : true } } ) ;
174176 if ( ! expense ) {
175177 throw new NotFoundException ( 'Expense not found' ) ;
176178 }
@@ -185,15 +187,15 @@ export class ExpensesService {
185187 description : dto . description ,
186188 category : dto . category ,
187189 } ,
188- include : { splits : true } ,
190+ include : { splits : true , receipt : true } ,
189191 } ) ;
190192
191193 await this . activityService . log ( {
192194 groupId : expense . groupId ,
193195 actorUserId,
194196 type : 'expense_updated' ,
195197 entityId : expense . id ,
196- metadata : { description : dto . description ?? null , category : dto . category ?? null } ,
198+ metadata : { description : dto . description ?? null , category : dto . category ?? null , currency : expense . currency } ,
197199 } ) ;
198200
199201 await this . redis . invalidateGroupCache ( expense . groupId ) ;
@@ -218,6 +220,7 @@ export class ExpensesService {
218220 entityId : expense . id ,
219221 metadata : {
220222 totalAmountCents : expense . totalAmountCents . toString ( ) ,
223+ currency : expense . currency ,
221224 } ,
222225 } ,
223226 } ) ;
@@ -257,6 +260,9 @@ export class ExpensesService {
257260 owedAmountCents : bigint ;
258261 paidAmountCents : bigint ;
259262 } > ;
263+ receipt : {
264+ fileKey : string ;
265+ } | null ;
260266 } ) : ExpenseDto {
261267 return {
262268 id : expense . id ,
@@ -266,6 +272,7 @@ export class ExpensesService {
266272 totalAmountCents : expense . totalAmountCents . toString ( ) ,
267273 currency : expense . currency as 'USD' | 'EUR' | 'INR' ,
268274 category : expense . category as ExpenseDto [ 'category' ] ,
275+ receiptFileKey : expense . receipt ?. fileKey ?? null ,
269276 createdAt : expense . createdAt . toISOString ( ) ,
270277 splits : expense . splits . map ( ( split ) => ( {
271278 id : split . id ,
@@ -276,4 +283,3 @@ export class ExpensesService {
276283 } ;
277284 }
278285}
279-
0 commit comments