Skip to content

Commit

Permalink
UIU-2469: fix issue when a fee/fine is refunded due to a CLAIMED RETU…
Browse files Browse the repository at this point in the history
…RNED, the refund amount does not appear in User Details
  • Loading branch information
arigatopavel authored and zburke committed Nov 12, 2021
1 parent 113a47a commit 3d8011d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Fix FeeFineAction and FeeFineCharge notice templates not appearing in Manual Charges settings. Refs UIU-2452.
* Do not label fees without loans as "Anonymized". Refs UIU-2449.
* Fix the issue when fee/fine is partially paid, then refunded, User Details show the full amount of the fee/fine as refunded. Refs UIU-2455.
* Fix the issue when a fee/fine is refunded due to a CLAIMED RETURNED, the refund amount does not appear in User Details. Refs UIU-2469.

## [7.0.2](https://github.com/folio-org/ui-users/tree/v7.0.2) (2021-10-25)
[Full Changelog](https://github.com/folio-org/ui-users/compare/v7.0.1...v7.0.2)
Expand Down
12 changes: 10 additions & 2 deletions src/components/UserDetailSections/UserAccounts/UserAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import {
} from '@folio/stripes/components';
import { useStripes } from '@folio/stripes/core';

import { accountStatuses, refundStatuses, loanActions } from '../../../constants';
import {
accountStatuses,
refundStatuses,
refundClaimReturned,
loanActions,
} from '../../../constants';


/**
Expand Down Expand Up @@ -64,7 +69,10 @@ const UserAccounts = ({
const closed = records.filter(account => account?.status?.name === accountStatuses.CLOSED);

// get refunded actions and refunds total amount
const refundStatusesValues = Object.values(refundStatuses);
const refundStatusesValues = [
...Object.values(refundStatuses),
refundClaimReturned.REFUNDED_ACTION,
];
const feeFineActions = resources.feefineactions.records ?? [];
const refunded = feeFineActions.filter((feeFineAction) => refundStatusesValues.includes(feeFineAction.typeAction));
const refundedTotal = refunded.reduce((acc, { amountAction }) => (acc + amountAction), 0);
Expand Down
6 changes: 4 additions & 2 deletions src/components/util/refundTransferClaimReturned.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ refundTransfers = async (loan, props) => {
const {
okapi: {
currentUser: {
id: currentUserId,
curServicePoint: {
id: servicePointId
}
},
},
user: {
id: userId,
},
} = props;

if (actions[0].typeAction.startsWith(refundClaimReturned.TRANSFERRED_ACTION) ||
Expand Down Expand Up @@ -136,7 +138,7 @@ refundTransfers = async (loan, props) => {
source: orderedActions[0].source,
paymentMethod: '',
accountId: orderedActions[0].accountId,
userId: currentUserId,
userId,
createdAt: servicePointId,
};
return persistRefundAction(newAction);
Expand Down
35 changes: 34 additions & 1 deletion test/jest/__mock__/stripesCore.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,38 @@ jest.mock('@folio/stripes/core', () => {
},
withOkapi: true,
};

// eslint-disable-next-line react/prop-types
const stripesConnect = Component => ({ mutator, resources, stripes, ...rest }) => {
const fakeMutator = mutator || Object.keys(Component.manifest || {}).reduce((acc, mutatorName) => {
const returnValue = Component.manifest[mutatorName].records ? [] : {};

acc[mutatorName] = {
GET: jest.fn().mockReturnValue(Promise.resolve(returnValue)),
PUT: jest.fn().mockReturnValue(Promise.resolve()),
POST: jest.fn().mockReturnValue(Promise.resolve()),
DELETE: jest.fn().mockReturnValue(Promise.resolve()),
reset: jest.fn(),
update: jest.fn(),
replace: jest.fn(),
};

return acc;
}, {});

const fakeResources = resources || Object.keys(Component.manifest || {}).reduce((acc, resourceName) => {
acc[resourceName] = {
records: [],
};

return acc;
}, {});

const fakeStripes = stripes || STRIPES;

return <Component {...rest} mutator={fakeMutator} resources={fakeResources} stripes={fakeStripes} />;
};

return {
AppIcon: jest.fn(({ ariaLabel }) => <span>{ariaLabel}</span>),
TitleManager: jest.fn(({ children, ...rest }) => (
Expand All @@ -53,7 +85,8 @@ jest.mock('@folio/stripes/core', () => {
}
}),
Pluggable: jest.fn(({ children }) => [children]),
stripesConnect: (Component) => (props) => <Component {...props} />,
connect: stripesConnect,
stripesConnect,
useStripes: () => STRIPES,
withStripes:
// eslint-disable-next-line react/prop-types
Expand Down

0 comments on commit 3d8011d

Please sign in to comment.