Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[statistics] feat: include canceled payments #45

Merged
merged 5 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/components/DashboardAnalytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ export const DashboardAnalytics = () => {
</div>
</div>

<div className="StatCards__card__item StatCards__card__item--inline">
<label className="StatCards__card__item__label">
Canceled payments
</label>
<div className="StatCards__card__item__value">
{renderNumberOrDash(stats?.paymentsCanceledCount)}
</div>
</div>

<div className="StatCards__card__item StatCards__card__item--inline">
<label className="StatCards__card__item__label">
Remaining payments
Expand Down
4 changes: 4 additions & 0 deletions src/components/DisbursementsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const DisbursementsTable: React.FC<DisbursementsTableProps> = ({
<Table.HeaderCell>Total payments</Table.HeaderCell>
<Table.HeaderCell>Successful</Table.HeaderCell>
<Table.HeaderCell>Failed</Table.HeaderCell>
<Table.HeaderCell>Canceled</Table.HeaderCell>
<Table.HeaderCell>Remaining</Table.HeaderCell>
<Table.HeaderCell
sortDirection={
Expand Down Expand Up @@ -149,6 +150,9 @@ export const DisbursementsTable: React.FC<DisbursementsTableProps> = ({
<Table.BodyCell width="2.25rem" textAlign="right">
{renderNumberOrDash(d.stats?.paymentsFailedCount)}
</Table.BodyCell>
<Table.BodyCell width="3.4rem" textAlign="right">
{renderNumberOrDash(d.stats?.paymentsCanceledCount)}
</Table.BodyCell>
<Table.BodyCell width="3.75rem" textAlign="right">
{renderNumberOrDash(d.stats?.paymentsRemainingCount)}
</Table.BodyCell>
Expand Down
1 change: 1 addition & 0 deletions src/helpers/formatDisbursements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const formatDisbursement = (
stats: {
paymentsSuccessfulCount: disbursement.total_payments_sent,
paymentsFailedCount: disbursement.total_payments_failed,
paymentsCanceledCount: disbursement.total_payments_canceled,
paymentsRemainingCount: disbursement.total_payments_remaining,
paymentsTotalCount: disbursement.total_payments,
totalAmount: disbursement.total_amount,
Expand Down
1 change: 1 addition & 0 deletions src/helpers/formatReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const formatReceiver = (receiver: ApiReceiver): ReceiverDetails => ({
paymentsTotalCount: Number(receiver.total_payments),
paymentsSuccessfulCount: Number(receiver.successful_payments),
paymentsFailedCount: Number(receiver.failed_payments),
paymentsCanceledCount: Number(receiver.canceled_payments),
paymentsRemainingCount: Number(receiver.remaining_payments),
},
wallets: receiver.wallets.map((w) => ({
Expand Down
4 changes: 3 additions & 1 deletion src/helpers/formatStatistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ export const formatStatistics = (statistics: ApiStatistics): HomeStatistics => {
return {
paymentsSuccessfulCounts: statistics.payment_counters.success,
paymentsFailedCount: statistics.payment_counters.failed,
paymentsCanceledCount: statistics.payment_counters.canceled,
paymentsRemainingCount: Number(
statistics.payment_counters.total -
statistics.payment_counters.success -
statistics.payment_counters.failed,
statistics.payment_counters.failed -
statistics.payment_counters.canceled,
),
paymentsTotalCount: statistics.payment_counters.total,
walletsTotalCount: statistics.receiver_wallets_counters.total,
Expand Down
11 changes: 11 additions & 0 deletions src/pages/DisbursementDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,17 @@ export const DisbursementDetails = () => {
</div>
</div>

<div className="StatCards__card__item StatCards__card__item--inline">
<label className="StatCards__card__item__label">
Canceled payments
</label>
<div className="StatCards__card__item__value">
{renderNumberOrDash(
disbursementDetails.details.stats?.paymentsCanceledCount,
)}
</div>
</div>

<div className="StatCards__card__item StatCards__card__item--inline">
<label className="StatCards__card__item__label">
Remaining payments
Expand Down
11 changes: 11 additions & 0 deletions src/pages/ReceiverDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,17 @@ export const ReceiverDetails = () => {
</div>
</div>

<div className="StatCards__card__item StatCards__card__item--inline">
<label className="StatCards__card__item__label">
Canceled payments
</label>
<div className="StatCards__card__item__value">
{renderNumberOrDash(
receiverDetails.stats.paymentsCanceledCount,
)}
</div>
</div>

<div className="StatCards__card__item StatCards__card__item--inline">
<label className="StatCards__card__item__label">
Remaining payments
Expand Down
1 change: 1 addition & 0 deletions src/store/ducks/disbursementDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const initialState: DisbursementDetailsInitialState = {
stats: {
paymentsSuccessfulCount: 0,
paymentsFailedCount: 0,
paymentsCanceledCount: 0,
paymentsRemainingCount: 0,
paymentsTotalCount: 0,
totalAmount: "",
Expand Down
7 changes: 7 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ export interface DisbursementDraftRejectMessage extends RejectMessage {
export type DisbursementDetailsStats = {
paymentsSuccessfulCount: number;
paymentsFailedCount: number;
paymentsCanceledCount: number;
paymentsRemainingCount: number;
paymentsTotalCount: number;
totalAmount: string;
Expand Down Expand Up @@ -411,6 +412,7 @@ export type ReceiverDetails = {
paymentsTotalCount: number;
paymentsSuccessfulCount: number;
paymentsFailedCount: number;
paymentsCanceledCount: number;
paymentsRemainingCount: number;
};
wallets: ReceiverWallet[];
Expand All @@ -428,6 +430,7 @@ export type ReceiverEditFields = {
export type HomeStatistics = {
paymentsSuccessfulCounts: number;
paymentsFailedCount: number;
paymentsCanceledCount: number;
paymentsRemainingCount: number;
paymentsTotalCount: number;
walletsTotalCount: number;
Expand Down Expand Up @@ -551,6 +554,7 @@ export type ApiDisbursement = {
total_payments: number;
total_payments_sent: number;
total_payments_failed: number;
total_payments_canceled: number;
total_payments_remaining: number;
amount_disbursed: string;
total_amount: string;
Expand Down Expand Up @@ -618,6 +622,7 @@ export type ApiPayments = {
export type ApiStatisticsAsset = {
asset_code: string;
payment_amounts: {
canceled: number;
draft: number;
ready: number;
pending: number;
Expand All @@ -631,6 +636,7 @@ export type ApiStatisticsAsset = {

export type ApiStatistics = {
payment_counters: {
canceled: number;
draft: number;
ready: number;
pending: number;
Expand Down Expand Up @@ -725,6 +731,7 @@ export type ApiReceiver = {
total_payments: string | number;
successful_payments: string | number;
failed_payments: string | number;
canceled_payments: string | number;
remaining_payments: string | number;
received_amounts?: {
asset_code: string;
Expand Down