Skip to content

Commit

Permalink
WANN-531: Adds Seizure Protection section to mock solaris backoffice (#…
Browse files Browse the repository at this point in the history
…70)

* WANN-531: Adds isPKonto flag to mock solaris backoffice

* WANN-531: Fixes inconsistencies in code

* WANN-531: Modifies the isPKonto implementation, fixes bugs and modifies version

* WANN-531: Modifies seizure protection implementation and removes webhook approach

* WANN-531: Removes default seizure protection object

* WANN-531: Uses email instead of personId for API

* WANN-531: Adds seizure protection delete API and modifies returned values to accept json

* Update README.md

* Updates the package version for release
  • Loading branch information
DanaNussair authored Sep 13, 2022
1 parent ec48307 commit 6f13e0b
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 53 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ curl TODO

## Backoffice screenshots

![mockSolarisPerson](https://user-images.githubusercontent.com/6367201/179481833-0d7087cc-1682-435d-94f5-ed316140eaa2.png)
![mockSolarisPerson](https://user-images.githubusercontent.com/47757191/189340823-2b200e6f-5068-4a32-8936-9b7b4d7ae38e.png)


### Persons and accounts
Expand Down Expand Up @@ -61,6 +61,16 @@ You can set screening values from the "Person data" section ([More info](https:/

<img width="532" alt="Screen Shot 2022-07-18 at 11 38 55 AM" src="https://user-images.githubusercontent.com/6367201/179475427-58af2c02-b229-4cab-96a2-089f45356e60.png">

### Seizure Protection
When querying the balance for P-konto accounts, you will get a `seizure_protection` object as stated in this [API](https://docs.solarisgroup.com/api-reference/digital-banking/account-management/#tag/Accounts/paths/~1v1~1accounts~1{account_id}~1balance/get). Since solaris does not support changing an account to P-konto; we mocked the existence of seizure protection.

You can modify the values of seizure protection in this section:

![seizure-protection](https://user-images.githubusercontent.com/47757191/189342102-a69a6a30-bc25-4fc1-bf9a-ba6ee45a76ff.png)

You can also delete the object afterwards:

![allow-delete-seizure-protection](https://user-images.githubusercontent.com/47757191/189342305-284ebf13-af56-4166-b71a-8591eea0f82a.png)

## Configuration

Expand Down
20 changes: 6 additions & 14 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kontist/mock-solaris",
"version": "1.0.49",
"version": "1.0.54",
"description": "Mock Service for Solaris API",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down
10 changes: 10 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,16 @@ app.post(
safeRequestHandler(standingOrdersAPI.triggerStandingOrderRequestHandler)
);

// BACKOFFICE - SEIZURES PROTECTION
app.post(
"/__BACKOFFICE__/addAccountSeizureProtection/:email",
safeRequestHandler(backofficeAPI.addAccountSeizureProtectionHandler)
);
app.post(
"/__BACKOFFICE__/deleteAccountSeizureProtection/:email",
safeRequestHandler(backofficeAPI.deleteAccountSeizureProtectionHandler)
);

// BACKOFFICE - SEIZURES
app.post(
"/__BACKOFFICE__/createSeizure/:person_id",
Expand Down
7 changes: 6 additions & 1 deletion src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import Promise from "bluebird";

import * as log from "./logger";
import { calculateOverdraftInterest } from "./helpers/overdraft";
import { CustomerVettingStatus, RiskClarificationStatus, ScreeningProgress } from "./helpers/types";
import {
CustomerVettingStatus,
RiskClarificationStatus,
ScreeningProgress,
} from "./helpers/types";

let redis;

Expand Down Expand Up @@ -111,6 +115,7 @@ export const migrate = async () => {
available_balance: {
value: 100,
},
seizure_protection: null,
},
billing_account: {
id: process.env.SOLARIS_KONTIST_BILLING_ACCOUNT_ID,
Expand Down
14 changes: 8 additions & 6 deletions src/routes/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const DEFAULT_ACCOUNT = {
person_id: "66a692fdddc32c05ebe1c1f1c3145a3bcper",
status: "ACTIVE",
closure_reasons: null,
seizure_protection: null,
};

const requestAccountFields = [
Expand Down Expand Up @@ -73,17 +74,14 @@ export const showAccountBookings = async (req, res) => {
export const showAccountReservations = async (req, res) => {
const {
page: { size, number },
filter: {
reservation_type: reservationType,
},
filter: { reservation_type: reservationType },
} = req.query;

const { account_id: accountId } = req.params;
const person = await findPersonByAccountId(accountId);


const reservations = _.get(person.account, "reservations", [])
.filter(reservation => reservation.reservation_type === reservationType)
.filter((reservation) => reservation.reservation_type === reservationType)
.slice((number - 1) * size, number * size);

res.status(200).send(reservations);
Expand Down Expand Up @@ -206,7 +204,11 @@ export const createAccountSnapshot = async (req, res) => {
export const showAccountBalance = async (req, res) => {
const { account_id: accountId } = req.params;
const person = await findPersonByAccountId(accountId);
const balance = _.pick(person.account, ["balance", "available_balance"]);
const balance = _.pick(person.account, [
"balance",
"available_balance",
"seizure_protection",
]);

res.status(200).send(balance);
};
Loading

0 comments on commit 6f13e0b

Please sign in to comment.