Untitled
unknown
plain_text
a year ago
16 kB
4
Indexable
import groupBy from "lodash/groupBy"; import forEach from "lodash/forEach"; const a = [ { "encodedKey": "8a8e862a8df5386f018df8cc3f6e65f2", "id": "262120", "creationDate": "2024-03-01T16:11:52+08:00", "valueDate": "2024-03-01T16:11:52+08:00", "bookingDate": "2024-03-01T16:11:52+08:00", "parentAccountKey": "8a8e87a48d76a14e018d7875a4020e56", "type": "DEPOSIT", "amount": 123.4000000000, "currencyCode": "USD", "affectedAmounts": { "fundsAmount": 123.4000000000, "interestAmount": 0, "feesAmount": 0, "overdraftAmount": 0, "overdraftFeesAmount": 0, "overdraftInterestAmount": 0, "technicalOverdraftAmount": 0, "technicalOverdraftInterestAmount": 0, "fractionAmount": 0 }, "taxes": {}, "accountBalances": { "totalBalance": 437.2400000000 }, "userKey": "8a8e87d084f58db1018504e0441a0087", "terms": { "interestSettings": {}, "overdraftInterestSettings": {}, "overdraftSettings": {} }, "transactionDetails": { "transactionChannelKey": "8a8e8f98843e337a01845a8ee0f4038c", "transactionChannelId": "DBS_SGD" }, "transferDetails": {}, "fees": [], "_FX": { "accountHolderKey": "123", "counterAccount": "8a8e86ca8c849b59018c87fd6a4821db", "exchangeRateDate": "2024-01-22T07:00:00.000+00:00", "exchangeRate": "1.234", "counterAccountCurrency": "SGD", "fee": "0.41", "fxId": "222-111", "fxTransactionId": "8f32d6fb-a5d7-42aa-abef-e4216d61ff84", "exchangeRateValidTo": "2024-03-22T07:00:00.000+00:00" } }, { "encodedKey": "8a8e861b8df7f34e018df8c130c01305", "id": "262119", "creationDate": "2024-03-01T16:11:52+08:00", "valueDate": "2024-03-01T16:11:52+08:00", "bookingDate": "2024-03-01T16:11:52+08:00", "parentAccountKey": "8a8e86ca8c849b59018c87fd6a4821db", "type": "WITHDRAWAL", "amount": -100.0000000000, "currencyCode": "SGD", "affectedAmounts": { "fundsAmount": 100.0000000000, "interestAmount": 0, "feesAmount": 0, "overdraftAmount": 0, "overdraftFeesAmount": 0, "overdraftInterestAmount": 0, "technicalOverdraftAmount": 0, "technicalOverdraftInterestAmount": 0, "fractionAmount": 0 }, "taxes": {}, "accountBalances": { "totalBalance": 500576.0500000000 }, "userKey": "8a8e87d084f58db1018504e0441a0087", "terms": { "interestSettings": {}, "overdraftInterestSettings": {}, "overdraftSettings": {} }, "transactionDetails": { "transactionChannelKey": "8a8e8f98843e337a01845a8ee0f4038c", "transactionChannelId": "DBS_SGD" }, "transferDetails": {}, "fees": [], "_FX": { "accountHolderKey": "123", "counterAccount": "8a8e87a48d76a14e018d7875a4020e56", "exchangeRateDate": "2024-01-22T07:00:00.000+00:00", "exchangeRate": "1.234", "counterAccountCurrency": "USD", "fee": "0.5", "fxId": "222-111", "fxTransactionId": "8f32d6fb-a5d7-42aa-abef-e4216d61ff84", "exchangeRateValidTo": "2024-03-22T07:00:00.000+00:00" } }, { "encodedKey": "8a8e862a8df5386f018df85ed9c861f9", "id": "262116", "creationDate": "2024-03-01T14:43:47+08:00", "valueDate": "2024-03-01T14:43:47+08:00", "bookingDate": "2024-03-01T14:43:47+08:00", "parentAccountKey": "8a8e87a48d76a14e018d7875a4020e56", "type": "DEPOSIT", "amount": 123.4000000000, "currencyCode": "USD", "affectedAmounts": { "fundsAmount": 123.4000000000, "interestAmount": 0, "feesAmount": 0, "overdraftAmount": 0, "overdraftFeesAmount": 0, "overdraftInterestAmount": 0, "technicalOverdraftAmount": 0, "technicalOverdraftInterestAmount": 0, "fractionAmount": 0 }, "taxes": {}, "accountBalances": { "totalBalance": 313.8400000000 }, "userKey": "8a8e87d084f58db1018504e0441a0087", "terms": { "interestSettings": {}, "overdraftInterestSettings": {}, "overdraftSettings": {} }, "transactionDetails": { "transactionChannelKey": "8a8e8f98843e337a01845a8ee0f4038c", "transactionChannelId": "DBS_SGD" }, "transferDetails": {}, "fees": [], "_FX": { "accountHolderKey": "123", "counterAccount": "8a8e86ca8c849b59018c87fd6a4821db", "exchangeRateDate": "2024-01-22T07:00:00.000+00:00", "exchangeRate": "1.234", "counterAccountCurrency": "SGD", "fee": "0.41", "fxId": "222-111", "fxTransactionId": "527b6586-d846-4e7b-9dea-e5e8772ada07", "exchangeRateValidTo": "2024-03-22T07:00:00.000+00:00" } }, { "encodedKey": "8a8e861b8df7f34e018df85f2e6b0e57", "id": "262115", "creationDate": "2024-03-01T14:43:47+08:00", "valueDate": "2024-03-01T14:43:47+08:00", "bookingDate": "2024-03-01T14:43:47+08:00", "parentAccountKey": "8a8e86ca8c849b59018c87fd6a4821db", "type": "WITHDRAWAL", "amount": -100.0000000000, "currencyCode": "SGD", "affectedAmounts": { "fundsAmount": 100.0000000000, "interestAmount": 0, "feesAmount": 0, "overdraftAmount": 0, "overdraftFeesAmount": 0, "overdraftInterestAmount": 0, "technicalOverdraftAmount": 0, "technicalOverdraftInterestAmount": 0, "fractionAmount": 0 }, "taxes": {}, "accountBalances": { "totalBalance": 500676.0500000000 }, "userKey": "8a8e87d084f58db1018504e0441a0087", "terms": { "interestSettings": {}, "overdraftInterestSettings": {}, "overdraftSettings": {} }, "transactionDetails": { "transactionChannelKey": "8a8e8f98843e337a01845a8ee0f4038c", "transactionChannelId": "DBS_SGD" }, "transferDetails": {}, "fees": [], "_FX": { "accountHolderKey": "123", "counterAccount": "8a8e87a48d76a14e018d7875a4020e56", "exchangeRateDate": "2024-01-22T07:00:00.000+00:00", "exchangeRate": "1.234", "counterAccountCurrency": "USD", "fee": "0.5", "fxId": "222-111", "fxTransactionId": "527b6586-d846-4e7b-9dea-e5e8772ada07", "exchangeRateValidTo": "2024-03-22T07:00:00.000+00:00" } }, { "encodedKey": "8a8e87968df538a3018df8231ebc631f", "id": "262107", "creationDate": "2024-03-01T11:51:08+08:00", "valueDate": "2024-03-01T11:51:08+08:00", "bookingDate": "2024-03-01T11:51:08+08:00", "parentAccountKey": "8a8e87a48d76a14e018d7875a4020e56", "type": "WITHDRAWAL", "amount": -100.0000000000, "currencyCode": "USD", "affectedAmounts": { "fundsAmount": 100.0000000000, "interestAmount": 0, "feesAmount": 0, "overdraftAmount": 0, "overdraftFeesAmount": 0, "overdraftInterestAmount": 0, "technicalOverdraftAmount": 0, "technicalOverdraftInterestAmount": 0, "fractionAmount": 0 }, "taxes": {}, "accountBalances": { "totalBalance": 190.4400000000 }, "userKey": "8a8e87d084f58db1018504e0441a0087", "terms": { "interestSettings": {}, "overdraftInterestSettings": {}, "overdraftSettings": {} }, "transactionDetails": { "transactionChannelKey": "8a8e8f98843e337a01845a8ee0f4038c", "transactionChannelId": "DBS_SGD" }, "transferDetails": {}, "fees": [], "_FX": { "accountHolderKey": "123", "counterAccount": "8a8e86ca8c849b59018c87fd6a4821db", "exchangeRateDate": "2024-01-22T07:00:00.000+00:00", "exchangeRate": "1.234", "counterAccountCurrency": "SGD", "fee": "0.5", "fxId": "222-111", "fxTransactionId": "0abb4a61-fd75-45a5-b6af-ea472615fa80", "exchangeRateValidTo": "2024-03-22T07:00:00.000+00:00" } }, { "encodedKey": "8a8e872c8df760c9018df823218440ba", "id": "262108", "creationDate": "2024-03-01T11:51:08+08:00", "valueDate": "2024-03-01T11:51:08+08:00", "bookingDate": "2024-03-01T11:51:08+08:00", "parentAccountKey": "8a8e86ca8c849b59018c87fd6a4821db", "type": "DEPOSIT", "amount": 123.4000000000, "currencyCode": "SGD", "affectedAmounts": { "fundsAmount": 123.4000000000, "interestAmount": 0, "feesAmount": 0, "overdraftAmount": 0, "overdraftFeesAmount": 0, "overdraftInterestAmount": 0, "technicalOverdraftAmount": 0, "technicalOverdraftInterestAmount": 0, "fractionAmount": 0 }, "taxes": {}, "accountBalances": { "totalBalance": 500776.0500000000 }, "userKey": "8a8e87d084f58db1018504e0441a0087", "terms": { "interestSettings": {}, "overdraftInterestSettings": {}, "overdraftSettings": {} }, "transactionDetails": { "transactionChannelKey": "8a8e8f98843e337a01845a8ee0f4038c", "transactionChannelId": "DBS_SGD" }, "transferDetails": {}, "fees": [], "_FX": { "accountHolderKey": "123", "counterAccount": "8a8e87a48d76a14e018d7875a4020e56", "exchangeRateDate": "2024-01-22T07:00:00.000+00:00", "exchangeRate": "1.234", "counterAccountCurrency": "USD", "fee": "0.62", "fxId": "222-111", "fxTransactionId": "0abb4a61-fd75-45a5-b6af-ea472615fa80", "exchangeRateValidTo": "2024-03-22T07:00:00.000+00:00" } }, { "encodedKey": "8a8e86798deb2130018def20feee0e4c", "id": "259926", "creationDate": "2024-02-28T17:52:14+08:00", "valueDate": "2024-02-28T17:52:14+08:00", "bookingDate": "2024-02-28T17:52:14+08:00", "parentAccountKey": "8a8e86ca8c849b59018c87fd6a4821db", "type": "DEPOSIT", "amount": 78.4000000000, "currencyCode": "SGD", "affectedAmounts": { "fundsAmount": 78.4000000000, "interestAmount": 0, "feesAmount": 0, "overdraftAmount": 0, "overdraftFeesAmount": 0, "overdraftInterestAmount": 0, "technicalOverdraftAmount": 0, "technicalOverdraftInterestAmount": 0, "fractionAmount": 0 }, "taxes": {}, "accountBalances": { "totalBalance": 500647.7100000000 }, "userKey": "8a8e87d084f58db1018504e0441a0087", "terms": { "interestSettings": {}, "overdraftInterestSettings": {}, "overdraftSettings": {} }, "transactionDetails": { "transactionChannelKey": "8a8e8f98843e337a01845a8ee0f4038c", "transactionChannelId": "DBS_SGD" }, "transferDetails": {}, "fees": [], "_FX": { "accountHolderKey": "123", "counterAccount": "8a8e87a48d76a14e018d7875a4020e56", "exchangeRateDate": "2024-01-22T00:00:00.000+00:00", "exchangeRate": "0.784", "counterAccountCurrency": "USD", "fee": "0.003", "fxId": "111-222", "fxTransactionId": "f93dcc42-e0cc-49c8-8fb8-cba70b196997", "exchangeRateValidTo": "2024-05-22T00:00:00.000+00:00" } }, { "encodedKey": "8a8e866c8deb2131018deed63adf0b44", "id": "259925", "creationDate": "2024-02-28T17:52:13+08:00", "valueDate": "2024-02-28T17:52:13+08:00", "bookingDate": "2024-02-28T17:52:13+08:00", "parentAccountKey": "8a8e87a48d76a14e018d7875a4020e56", "type": "WITHDRAWAL", "amount": -100.0000000000, "currencyCode": "USD", "affectedAmounts": { "fundsAmount": 100.0000000000, "interestAmount": 0, "feesAmount": 0, "overdraftAmount": 0, "overdraftFeesAmount": 0, "overdraftInterestAmount": 0, "technicalOverdraftAmount": 0, "technicalOverdraftInterestAmount": 0, "fractionAmount": 0 }, "taxes": {}, "accountBalances": { "totalBalance": 290.4400000000 }, "userKey": "8a8e87d084f58db1018504e0441a0087", "terms": { "interestSettings": {}, "overdraftInterestSettings": {}, "overdraftSettings": {} }, "transactionDetails": { "transactionChannelKey": "8a8e8f98843e337a01845a8ee0f4038c", "transactionChannelId": "DBS_SGD" }, "transferDetails": {}, "fees": [], "_FX": { "accountHolderKey": "123", "counterAccount": "8a8e86ca8c849b59018c87fd6a4821db", "exchangeRateDate": "2024-01-22T00:00:00.000+00:00", "exchangeRate": "0.784", "counterAccountCurrency": "SGD", "fee": "0.003", "fxId": "111-222", "fxTransactionId": "f93dcc42-e0cc-49c8-8fb8-cba70b196997", "exchangeRateValidTo": "2024-05-22T00:00:00.000+00:00" } }, { "encodedKey": "8a8e87308deb2154018deed63a180ca6", "id": "259924", "creationDate": "2024-02-28T17:38:29+08:00", "valueDate": "2024-02-28T17:38:29+08:00", "bookingDate": "2024-02-28T17:38:29+08:00", "parentAccountKey": "8a8e87a48d76a14e018d7875a4020e56", "type": "DEPOSIT", "amount": 78.4000000000, "currencyCode": "USD", "affectedAmounts": { "fundsAmount": 78.4000000000, "interestAmount": 0, "feesAmount": 0, "overdraftAmount": 0, "overdraftFeesAmount": 0, "overdraftInterestAmount": 0, "technicalOverdraftAmount": 0, "technicalOverdraftInterestAmount": 0, "fractionAmount": 0 }, "taxes": {}, "accountBalances": { "totalBalance": 390.4400000000 }, "userKey": "8a8e87d084f58db1018504e0441a0087", "terms": { "interestSettings": {}, "overdraftInterestSettings": {}, "overdraftSettings": {} }, "transactionDetails": { "transactionChannelKey": "8a8e8f98843e337a01845a8ee0f4038c", "transactionChannelId": "DBS_SGD" }, "transferDetails": {}, "fees": [], "_FX": { "accountHolderKey": "123", "counterAccount": "8a8e86ca8c849b59018c87fd6a4821db", "exchangeRateDate": "2024-01-22T00:00:00.000+00:00", "exchangeRate": "0.784", "counterAccountCurrency": "SGD", "fee": "0.003", "fxId": "111-222", "fxTransactionId": "a54daa2c-a0b4-44ad-a375-e9a721bf7f00", "exchangeRateValidTo": "2024-05-22T00:00:00.000+00:00" } }, { "encodedKey": "8a8e86798deb2130018deed6338d0b8a", "id": "259923", "creationDate": "2024-02-28T17:38:28+08:00", "valueDate": "2024-02-28T17:38:28+08:00", "bookingDate": "2024-02-28T17:38:28+08:00", "parentAccountKey": "8a8e86ca8c849b59018c87fd6a4821db", "type": "WITHDRAWAL", "amount": -100.0000000000, "currencyCode": "SGD", "affectedAmounts": { "fundsAmount": 100.0000000000, "interestAmount": 0, "feesAmount": 0, "overdraftAmount": 0, "overdraftFeesAmount": 0, "overdraftInterestAmount": 0, "technicalOverdraftAmount": 0, "technicalOverdraftInterestAmount": 0, "fractionAmount": 0 }, "taxes": {}, "accountBalances": { "totalBalance": 500569.3100000000 }, "userKey": "8a8e87d084f58db1018504e0441a0087", "terms": { "interestSettings": {}, "overdraftInterestSettings": {}, "overdraftSettings": {} }, "transactionDetails": { "transactionChannelKey": "8a8e8f98843e337a01845a8ee0f4038c", "transactionChannelId": "DBS_SGD" }, "transferDetails": {}, "fees": [], "_FX": { "accountHolderKey": "123", "counterAccount": "8a8e87a48d76a14e018d7875a4020e56", "exchangeRateDate": "2024-01-22T00:00:00.000+00:00", "exchangeRate": "0.784", "counterAccountCurrency": "USD", "fee": "0.003", "fxId": "111-222", "fxTransactionId": "a54daa2c-a0b4-44ad-a375-e9a721bf7f00", "exchangeRateValidTo": "2024-05-22T00:00:00.000+00:00" } } ] const groupByFnaStatus = groupBy(a, (item) => { return item._FX.fxTransactionId; }); // console.log(groupByFnaStatus) let finalStructure: any = {} const b = forEach(groupByFnaStatus, (value, key) => { finalStructure[key] = {}; value.forEach(transaction => { if (!finalStructure[key][transaction.type]) { finalStructure[key][transaction.type] = []; } finalStructure[key][transaction.type].push(transaction); }); console.log(finalStructure) }) // console.log(b) b
Editor is loading...
Leave a Comment