Skip to content

Commit

Permalink
Use paid amounts in cash flow statement (#2206)
Browse files Browse the repository at this point in the history
* Use paid amounts in cash flow statement

* Filter empty tx
  • Loading branch information
hieronx authored Jun 7, 2024
1 parent 3497def commit 0da1120
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ export const TransactionHistoryTable = ({
transactions
?.filter(
(transaction) =>
transaction.type !== 'CREATED' && transaction.type !== 'CLOSED' && transaction.type !== 'PRICED'
transaction.type !== 'CREATED' &&
transaction.type !== 'CLOSED' &&
transaction.type !== 'PRICED' &&
!transaction.amount.isZero()
)
.sort((a, b) => (a.timestamp > b.timestamp ? -1 : 1)) || []

Expand Down
6 changes: 3 additions & 3 deletions centrifuge-app/src/components/Report/CashflowStatement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export function CashflowStatement({ pool }: { pool: Pool }) {
return [
{
name: 'Fees paid',
value: poolStates?.map(({ poolState }) => poolState.sumPoolFeesChargedAmountByPeriod.toDecimal()) || [],
value: poolStates?.map(({ poolState }) => poolState.sumPoolFeesPaidAmountByPeriod.toDecimal()) || [],
heading: false,
formatter: (v: any) => `${v.isZero() ? '' : '-'}${formatBalance(v, pool.currency.displayName, 2)}`,
},
Expand All @@ -182,7 +182,7 @@ export function CashflowStatement({ pool }: { pool: Pool }) {
.sub(poolState.sumBorrowedAmountByPeriod.toDecimal())
.add(poolState.sumInterestRepaidAmountByPeriod.toDecimal())
.add(poolState.sumUnscheduledRepaidAmountByPeriod.toDecimal())
.sub(poolState.sumPoolFeesChargedAmountByPeriod.toDecimal())
.sub(poolState.sumPoolFeesPaidAmountByPeriod.toDecimal())
) || [],
formatter: (v: any) => (v ? formatBalance(v, pool.currency.displayName, 2) : ''),
heading: false,
Expand Down Expand Up @@ -229,7 +229,7 @@ export function CashflowStatement({ pool }: { pool: Pool }) {
.sub(poolState.sumBorrowedAmountByPeriod.toDecimal())
.add(poolState.sumInterestRepaidAmountByPeriod.toDecimal())
.add(poolState.sumUnscheduledRepaidAmountByPeriod.toDecimal())
.sub(poolState.sumPoolFeesChargedAmountByPeriod.toDecimal())
.sub(poolState.sumPoolFeesPaidAmountByPeriod.toDecimal())
.add(poolState.sumInvestedAmountByPeriod.toDecimal())
.sub(poolState.sumRedeemedAmountByPeriod.toDecimal())
) || [],
Expand Down
7 changes: 7 additions & 0 deletions centrifuge-js/src/modules/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ export type DailyPoolState = {
sumBorrowedAmountByPeriod: CurrencyBalance
sumRepaidAmountByPeriod: CurrencyBalance
sumPoolFeesChargedAmountByPeriod: CurrencyBalance
sumPoolFeesPaidAmountByPeriod: CurrencyBalance
sumPrincipalRepaidAmountByPeriod: CurrencyBalance
sumInterestRepaidAmountByPeriod: CurrencyBalance
sumUnscheduledRepaidAmountByPeriod: CurrencyBalance
Expand All @@ -591,6 +592,7 @@ export type DailyPoolState = {
tranches: { [trancheId: string]: DailyTrancheState }
sumPoolFeesChargedAmountByPeriod: string | null
sumPoolFeesAccruedAmountByPeriod: string | null
sumPoolFeesPaidAmountByPeriod: string | null
sumBorrowedAmountByPeriod: string
sumPrincipalRepaidAmountByPeriod: string
sumInterestRepaidAmountByPeriod: string
Expand Down Expand Up @@ -2245,6 +2247,7 @@ export function getPoolsModule(inst: Centrifuge) {
blockNumber
sumPoolFeesChargedAmountByPeriod
sumPoolFeesAccruedAmountByPeriod
sumPoolFeesPaidAmountByPeriod
sumPoolFeesPendingAmount
sumBorrowedAmountByPeriod
sumRepaidAmountByPeriod
Expand Down Expand Up @@ -2444,6 +2447,10 @@ export function getPoolsModule(inst: Centrifuge) {
state.sumPoolFeesAccruedAmountByPeriod ?? 0,
poolCurrency.decimals
),
sumPoolFeesPaidAmountByPeriod: new CurrencyBalance(
state.sumPoolFeesPaidAmountByPeriod ?? 0,
poolCurrency.decimals
),
sumBorrowedAmountByPeriod: new CurrencyBalance(state.sumBorrowedAmountByPeriod, poolCurrency.decimals),
sumPrincipalRepaidAmountByPeriod: new CurrencyBalance(
state.sumPrincipalRepaidAmountByPeriod,
Expand Down
1 change: 1 addition & 0 deletions centrifuge-js/src/types/subquery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type SubqueryPoolSnapshot = {
portfolioValuation: number
sumPoolFeesChargedAmountByPeriod: string | null
sumPoolFeesAccruedAmountByPeriod: string | null
sumPoolFeesPaidAmountByPeriod: string | null
sumBorrowedAmountByPeriod: string
sumPrincipalRepaidAmountByPeriod: string
sumInterestRepaidAmountByPeriod: string
Expand Down

0 comments on commit 0da1120

Please sign in to comment.