ArboreumDev / credit-union-frontend

Frontend in Next.js + Typescript + GraphQL
https://frontend-two-sandy.vercel.app
1 stars 0 forks source link

dbclient- and swarmai method for repayment #120

Closed djudjuu closed 3 years ago

djudjuu commented 3 years ago

_whenever we get a loan-offer we store it on risk_calc_result when it is accepted or a repayment is made, we store the latest loaninfo json on a newly created 'loan' field in the loan-requests-table-entry


This would be useful as a template of todos, we need to do in order to account for changes in swarmai schema:


- [ ] update payables and receivables based on it --> created #122

djudjuu commented 3 years ago

so i just needed to not use the hotel wifi, then everything worked as expected.

@gparuthi , I added the necessary info from the db to the system-state summary. Now we can go ahead and merge it, or also include the gql-api-action in this pr (I think you can wire that up faster than I do, but if you got other things to do I can take it over as well)

ON MAKING THE TESTS PASS: one other thing though, with the refactor the swarmai-client is now always pointing to localhost:3001, I guess we need to reroute it to ec2 (and also need to redeploy the latest development branch there)

gparuthi commented 3 years ago

@djudjuu the test is failing for me with localhost swarmai


● Loan Request Flow: confirm loan offer › balances of borrower is decreased and  supporter/lender balance is increased

    expect(received).toBeLessThan(expected)

    Expected: < 380
    Received:   380

      142 |       balancesAfter[LENDER1.id].cash
      143 |     )
    > 144 |     expect(balancesBefore[SUPPORTER2.id].cash).toBeLessThan(
          |                                                ^
      145 |       balancesAfter[SUPPORTER2.id].cash
      146 |     )
      147 |     expect(balancesBefore[BORROWER1.id].cash).toBeGreaterThan(

      at Object.<anonymous> (tests/src/loan/loan-confirm.integration.test.ts:144:48)```
gparuthi commented 3 years ago

I disabled integration tests for test:ci It is quite difficult to know which version of swarmai should be hosted for a github branch, so its best to disable ci tests. In the future, we should publish swarmai docker image somewhere and use that specific image to run the ci tests.

djudjuu commented 3 years ago

the test is failing for me with localhost swarmai

I assume you did run make-dev on the latest development-branch? strange it does work for me... I will try to reproduce it again..

gparuthi commented 3 years ago

Strange, but the test is passing now.

gparuthi commented 3 years ago

Now, the only thing left is seeing the changes in the UI for the repayments. And then we are set to merge. Slack message:

I don't see the loan_request.risk_calc_result being updated for the borrower after repayment. Can you check and maybe add a test?

gparuthi commented 3 years ago

Nice refactoring. Looking good.

gparuthi commented 3 years ago
Actually the UI still doesn't update for me on repayment.
image image
djudjuu commented 3 years ago

Need to update types so that demo fixture can be updated accordingly.

I did update it. I thought we keep the original sent-request under the key 'request_data' and store the offered-loan under the 'latestOffer'.

Once the loan is accepted, we store it on the 'loan' entry (new field not inside the risk_calc_result-json but on the same level. (see hasura-console)

gparuthi commented 3 years ago

This is probably on swarmai side. I am looking at the loan schedule calc. Is the decimal places normal? I thought we round it to 2 decimal places? Do they add up? We should probably add a test for repayment calculations that check if they add up exactly. image