diff --git a/src/pages/Admin/Charity/Dashboard/Loaded.tsx b/src/pages/Admin/Charity/Dashboard/Loaded.tsx index 08c7c87709..e172fd013e 100644 --- a/src/pages/Admin/Charity/Dashboard/Loaded.tsx +++ b/src/pages/Admin/Charity/Dashboard/Loaded.tsx @@ -128,7 +128,6 @@ export function Loaded({ classes = "", ...props }: Props) { amount={props.balances.payoutsPending} periodNext={period.next} periodRemaining={period.distance} - grantFromBal={mov["liq-cash"] + mov["lock-cash"]} allocation={props.allocation} /> diff --git a/src/pages/Admin/Charity/Dashboard/Movements.tsx b/src/pages/Admin/Charity/Dashboard/Movements.tsx index b72b8fff34..feffa625d0 100644 --- a/src/pages/Admin/Charity/Dashboard/Movements.tsx +++ b/src/pages/Admin/Charity/Dashboard/Movements.tsx @@ -53,7 +53,7 @@ export function Movements({ classes = "", ...props }: Props) { return (

- Pending transactions + Pending Transactions

{movs.map((entry) => { diff --git a/src/pages/Admin/Charity/Dashboard/Schedule/Schedule.tsx b/src/pages/Admin/Charity/Dashboard/Schedule/Schedule.tsx index ea3d287111..44e7cebd39 100644 --- a/src/pages/Admin/Charity/Dashboard/Schedule/Schedule.tsx +++ b/src/pages/Admin/Charity/Dashboard/Schedule/Schedule.tsx @@ -6,11 +6,7 @@ import { useAdminContext } from "pages/Admin/Context"; import type { ReactNode } from "react"; import type { Allocation } from "types/aws"; import { Edit } from "./Edit"; -import { - MIN_PROCESSING_AMOUNT, - allocationOptions, - toAllocOptValue, -} from "./common"; +import { allocationOptions, toAllocOptValue } from "./common"; interface Props { amount: number; @@ -18,7 +14,6 @@ interface Props { classes?: string; periodNext: string; periodRemaining: string; - grantFromBal: number; disabled?: boolean; } export function Schedule(props: Props) { @@ -32,7 +27,7 @@ export function Schedule(props: Props) { return (
-

Donations received

+

Current Month Donations

$ {humanize(props.amount)}

@@ -78,28 +73,6 @@ export function Schedule(props: Props) { } pct={props.allocation.cash} amount={props.amount} - tooltip={(val) => - val !== 0 && - /** include additional grant from bal */ - val + props.grantFromBal < MIN_PROCESSING_AMOUNT && ( - - Grant amount of $ {humanize(val)} is less than minimum - processing amount of ${MIN_PROCESSING_AMOUNT} and would be - carried over to the next month. - - - } - > - - - ) - } /> ReactNode; } function Row(props: IRow) { const val = props.amount * (props.pct / 100); @@ -141,7 +113,6 @@ function Row(props: IRow) { {humanize(val)} - {props.tooltip?.(val)}
); } diff --git a/src/pages/Admin/Charity/Dashboard/Summary.tsx b/src/pages/Admin/Charity/Dashboard/Summary.tsx index 1fc60f3c06..d65d7fae10 100644 --- a/src/pages/Admin/Charity/Dashboard/Summary.tsx +++ b/src/pages/Admin/Charity/Dashboard/Summary.tsx @@ -1,7 +1,9 @@ import Icon from "components/Icon"; import { Arrow, Content, Tooltip } from "components/Tooltip"; import { humanize } from "helpers"; +import type { ReactNode } from "react"; import type { Allocation, BalanceMovement, EndowmentBalances } from "types/aws"; +import { MIN_PROCESSING_AMOUNT } from "./Schedule/common"; interface Props { balances: EndowmentBalances; @@ -13,28 +15,50 @@ interface Props { export function Summary({ classes = "", ...props }: Props) { const liqDonation = props.balances.payoutsPending * (props.alloc.liq / 100); const lockDonation = props.balances.payoutsPending * (props.alloc.lock / 100); + const grantDonation = + props.balances.payoutsPending * (props.alloc.cash / 100); const liqItems = [ - ["Donation", liqDonation], - ["Grant", -props.mov["liq-cash"]], - ["Investment", -props.mov["liq-lock"]], - ["Savings", props.mov["lock-liq"]], - ].filter(([, v]) => Math.abs(+v) > 0) as [string, number][]; + ["0", "from Donation", liqDonation] as const, + ["1", "from Investment", props.mov["lock-liq"]] as const, + ["2", "to Investment", -props.mov["liq-lock"]] as const, + ["3", "to Grant", -props.mov["liq-cash"]] as const, + ] + .toSorted(([ka], [kb]) => ka.localeCompare(kb)) + .filter(([, , v]) => Math.abs(+v) > 0) + .map(([, k, v]) => [k, v]); const lockItems = [ - ["Donation", lockDonation], - ["Grant", -props.mov["lock-cash"]], - ["Savings", -props.mov["lock-liq"]], - ["Investment", props.mov["liq-lock"]], - ].filter(([, v]) => Math.abs(+v) > 0) as [string, number][]; + ["0", "from Donation", lockDonation] as const, + ["1", "from Savings", props.mov["liq-lock"]] as const, + ["2", "to Savings", -props.mov["lock-liq"]] as const, + ["3", "to Grant", -props.mov["lock-cash"]] as const, + ] + .toSorted(([ka], [kb]) => ka.localeCompare(kb)) + .filter(([, , v]) => Math.abs(+v) > 0) + .map(([, k, v]) => [k, v]); + + const grantItems = [ + ["0", "from Donations", grantDonation] as const, + ["1", "from Savings", props.mov["liq-cash"]] as const, + ["2", "from Investment", props.mov["lock-cash"]] as const, + ] + .toSorted(([ka], [kb]) => ka.localeCompare(kb)) + .filter(([, , v]) => Math.abs(+v) > 0) + .map(([, k, v]) => [k, v]); //no changes - if (liqItems.length === 0 && lockItems.length === 0) return null; + if ( + liqItems.length === 0 && + lockItems.length === 0 && + grantItems.length === 0 + ) + return null; return (

- Ending balances + Projected Month End Balances @@ -48,15 +72,43 @@ export function Summary({ classes = "", ...props }: Props) {

+ { + if (change === 0) return null; + if (change >= MIN_PROCESSING_AMOUNT) return null; + return ( + + Total Grant is less than minimum processing amount of $ + {MIN_PROCESSING_AMOUNT} and would be carried over to the + next month. + + + } + > + + + ); + }} + />
@@ -66,31 +118,37 @@ export function Summary({ classes = "", ...props }: Props) { interface IItem { title: string; - balance: number; + balance: number | null; changes: [string, number][]; classes?: string; + tooltip?: (change: number) => ReactNode; } function Balance({ classes = "", ...props }: IItem) { const change = props.changes.reduce((sum, [, v]) => v + sum, 0); + + const headerAmount = props.balance === null ? change : props.balance + change; + const changeAmount = props.balance === null ? null : change; + return (

{props.title}

- - $ {humanize(props.balance + change)} - - {change ? ( +

+ $ {humanize(headerAmount)} + {props.tooltip?.(change)} +

+ {changeAmount !== null ? (

0 ? "text-green" : "text-red" + changeAmount > 0 ? "text-green" : "text-red" } flex items-center font-heading text-sm`} > ( - - $ {humanize(Math.abs(change))} ) + + $ {humanize(Math.abs(changeAmount))} )

) : (