Skip to content

Commit 532fa1d

Browse files
authored
Batch transfer fixes (#274)
* Fix typo in account.id * Map transfers and bookings for list endpoint response * 1.0.183
1 parent 8c35349 commit 532fa1d

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

npm-shrinkwrap.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kontist/mock-solaris",
3-
"version": "1.0.182",
3+
"version": "1.0.183",
44
"description": "Mock Service for Solaris API",
55
"main": "dist/src/index.js",
66
"types": "dist/src/index.d.ts",

src/routes/batchTransfers.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
184211
export 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

Comments
 (0)