@@ -160,9 +160,11 @@ export const confirmBatchTransfer = async (person, changeRequestId) => {
160160
161161 await savePerson ( person ) ;
162162
163+ const account = person . accounts ?. length ? person . accounts [ 0 ] : person . account ;
164+
163165 return {
164166 id,
165- account_id : person . accounts [ 0 ] . id ,
167+ account_id : account . id ,
166168 status : "ACCEPTED" ,
167169 transfer_type : transferType ,
168170 description,
@@ -181,6 +183,31 @@ export const confirmBatchTransfer = async (person, changeRequestId) => {
181183 } ;
182184} ;
183185
186+ const mapBatchTransferTransaction = ( item , accountId ) => {
187+ const statusMap = {
188+ accepted : "BOOKED" ,
189+ rejected : "FAILED" ,
190+ } ;
191+
192+ return {
193+ id : item . id ,
194+ account_id : accountId ,
195+ status : statusMap [ item . status ] || item . status ,
196+ type : item . booking_type || item . type ,
197+ creditor_iban : item . recipient_iban || item . creditor_iban ,
198+ creditor_name : item . recipient_name || item . creditor_name ,
199+ amount : item . amount ,
200+ description : item . description ,
201+ end_to_end_id : item . end_to_end_id ,
202+ initiator_reference : item . reference || item . initiator_reference ,
203+ failure_reason : null ,
204+ batch_id : item . batch_id ,
205+ schedule_id : null ,
206+ created_at : item . created_at || item . booking_date ,
207+ updated_at : item . updated_at || item . valuta_date ,
208+ } ;
209+ } ;
210+
184211export const listBatchTransferTransactions = async ( req , res ) => {
185212 const { account_id : accountId , batch_transfer_id : batchTransferId } =
186213 req . params ;
@@ -193,5 +220,10 @@ export const listBatchTransferTransactions = async (req, res) => {
193220 ( transaction ) => transaction . batch_id === batchTransferId
194221 ) ;
195222
196- res . status ( HttpStatusCodes . OK ) . send ( [ ...bookings , ...transfers ] ) ;
223+ const allTransactions = [ ...bookings , ...transfers ] ;
224+ const mappedTransactions = allTransactions . map ( ( item ) =>
225+ mapBatchTransferTransaction ( item , accountId )
226+ ) ;
227+
228+ res . status ( HttpStatusCodes . OK ) . send ( mappedTransactions ) ;
197229} ;
0 commit comments