This commit is contained in:
Zeeshaun
2026-03-17 11:09:46 -05:00
parent bd1a9744ad
commit 6e7edcfe1b
332 changed files with 64174 additions and 0 deletions
@@ -0,0 +1,229 @@
import {shallow, ShallowWrapper} from "enzyme";
import moment, {Moment} from "moment";
import React from "react";
import {IRepoAccount} from "../../services/service-types/RepoAccountTypes";
import DateCalculations from "../../shared/calculations/DateCalculations";
import AccountDetails from "./AccountDetails";
describe("AccountDetails Container", () => {
let wrapper: ShallowWrapper;
const dummyAccount: IRepoAccount = {
repoId: 476,
accountNo: "string",
status: "string",
memberNo: 1453,
loanNo: 0,
accountTypeCode: "acct-type-code",
origAccountTypeCode: "",
branch: 0,
balance: 0,
dueToPayDate: moment("1941-12-07"),
o4RDate: moment("1945-05-07"),
dateFirstDelinquent: moment("1918-11-11"),
delinquentAmount: 19.45,
daysDelinquent: 101,
paidSkipAmount: 0,
subStatus: "string",
requiredPaymentAmount: 3.14,
lstPmtAmt: 1912.00000,
origAmount: 42,
lastPaymentDate: moment("1865-04-15"),
dateFirstIntellect: moment("1963-11-22"),
primaryIndividualId: "string",
manualRedemptionDate: moment("1812-06-12"),
writtenOffDate: moment("1492-01-01"),
borrowers: [],
collaterals: [],
repoStatusChanges: [],
};
beforeEach(() => {
wrapper = shallow(
<AccountDetails
selectedAccount={dummyAccount}
otherRepos={"0"}
branchMapping={[]}
refreshCollateral={() => {
}}
/>
);
});
it("Renders Select Account Fields Correctly", () => {
const repoDbDate = wrapper.find(`[data-test='repo-db-date']`);
const firstDelinquent = wrapper.find(`[data-test='first-delinquent']`);
const otherRepos = wrapper.find(`[data-test='other-repos']`);
const daysDelqWhenAdded = wrapper.find(`[data-test='days-delq-when-added']`);
const origAmount = wrapper.find(`[data-test='orig-amount']`);
const balance = wrapper.find(`[data-test='balance']`);
const lastPayment = wrapper.find(`[data-test='last-payment']`);
const daysInStatus = wrapper.find(`[data-test='days-in-status']`);
const daysCurrentDelq = wrapper.find(`[data-test='days-current-delq']`);
const accountCode = wrapper.find(`[data-test='account-code']`);
const branch = wrapper.find(`[data-test='branch']`);
const currentDelqAmount = wrapper.find(`[data-test='current-delq-amount']`);
const lastPmtAmount = wrapper.find(`[data-test='last-pmt-amount']`);
const requiredAmount = wrapper.find(`[data-test='required-amount']`);
const bankruptcy = wrapper.find(`[data-test='bankruptcy']`);
expect(repoDbDate.length).toBe(1);
expect(repoDbDate.props().value).toEqual("05/07/1945");
expect(firstDelinquent.length).toBe(1);
expect(firstDelinquent.props().value).toEqual("11/11/1918");
expect(otherRepos.length).toBe(1);
expect(otherRepos.props().value).toEqual("0");
expect(daysDelqWhenAdded.length).toBe(1);
expect(daysDelqWhenAdded.props().value).toEqual(101);
expect(origAmount.length).toBe(1);
expect(origAmount.props().value).toEqual("$42.00");
expect(balance.length).toBe(1);
expect(balance.props().value).toEqual("$0.00");
expect(lastPayment.length).toBe(1);
expect(lastPayment.props().value).toEqual("04/15/1865");
expect(daysInStatus.length).toBe(1);
expect(daysInStatus.props().value).toEqual("Missing");
expect(daysCurrentDelq.length).toBe(1);
expect(daysCurrentDelq.props().value).toEqual(
DateCalculations.DayDifference(moment("1941-12-07"), moment())
);
expect(accountCode.length).toBe(1);
expect(accountCode.props().value).toEqual("(-) / acct-type-code");
expect(branch.length).toBe(1);
expect(branch.props().value).toEqual(0);
expect(currentDelqAmount.length).toBe(1);
expect(currentDelqAmount.props().value).toEqual("$19.45");
expect(lastPmtAmount.length).toBe(1);
expect(lastPmtAmount.props().value).toEqual("$1,912.00");
expect(requiredAmount.length).toBe(1);
expect(requiredAmount.props().value).toEqual("$3.14");
expect(bankruptcy.length).toBe(1);
expect(bankruptcy.props().value).toEqual("No");
});
it("Written Off Date Displays No", () => {
const dummyAccount: IRepoAccount = {
repoId: 476,
accountNo: "string",
status: "string",
memberNo: 1453,
loanNo: 0,
accountTypeCode: "acct-type-code",
origAccountTypeCode: "",
branch: 0,
balance: 0,
dueToPayDate: moment("1941-12-07"),
o4RDate: moment("1945-05-07"),
dateFirstDelinquent: moment("1918-11-11"),
delinquentAmount: 19.45,
daysDelinquent: 101,
paidSkipAmount: 0,
subStatus: "string",
requiredPaymentAmount: 3.14,
lstPmtAmt: 1912.00000,
origAmount: 42,
lastPaymentDate: moment("1865-04-15"),
dateFirstIntellect: moment("1963-11-22"),
primaryIndividualId: "string",
manualRedemptionDate: moment("1812-06-12"),
borrowers: [],
collaterals: [],
repoStatusChanges: [],
};
wrapper = shallow(
<AccountDetails
selectedAccount={dummyAccount}
otherRepos={"0"}
branchMapping={[]}
refreshCollateral={() => {
}}
/>
);
const writtenOffDate = wrapper.find(`[data-test='written-off']`);
expect(writtenOffDate.length).toBe(1);
expect(writtenOffDate.props().value).toBe("No");
});
it("Written Off Date Displays Date", () => {
wrapper = shallow(
<AccountDetails
selectedAccount={dummyAccount}
otherRepos={"0"}
branchMapping={[]}
refreshCollateral={() => {
}}
/>
);
const writtenOffDate = wrapper.find(`[data-test='written-off']`);
expect(writtenOffDate.length).toBe(1);
expect(writtenOffDate.props().value).toBe("01/01/1492");
});
it("Renders Account Code with Original Account Code Properly", () => {
dummyAccount.origAccountTypeCode = "orig-code";
const tempwrapper = shallow(
<AccountDetails
selectedAccount={dummyAccount}
otherRepos={"0"}
branchMapping={[]}
refreshCollateral={() => {
}}
/>
);
const accountCode = tempwrapper.find(`[data-test='account-code']`);
expect(accountCode.props().value).toBe("(orig-code) / acct-type-code");
});
it("Renders the Branch Name when a mapping is available", () => {
const tempwrapper = shallow(
<AccountDetails
selectedAccount={dummyAccount}
otherRepos={"0"}
branchMapping={[{branchId: 0, branchName: "Milwaukee"}]}
refreshCollateral={() => {
}}
/>
);
const branch = tempwrapper.find(`[data-test='branch']`);
expect(branch.props().value).toBe("Milwaukee");
});
it("Renders the Branch Number when branchMapping is undefined", () => {
const tempwrapper = shallow(
<AccountDetails
selectedAccount={dummyAccount}
otherRepos={"0"}
branchMapping={[]}
refreshCollateral={() => {
}}
/>
);
const branch = tempwrapper.find(`[data-test='branch']`);
expect(branch.props().value).toBe(0);
});
});
@@ -0,0 +1,170 @@
import moment from "moment";
import React from "react";
import CollateralDisplay, { ICollateralDisplay } from "../../components/collateral-display/CollateralDisplay";
import { IBranchSetEntry } from "../../reducers/SettingsReducer";
import RepoAccountService from "../../services/RepoAccountService";
import { ICollateral, IRepoAccount } from "../../services/service-types/RepoAccountTypes";
import DateCalculations from "../../shared/calculations/DateCalculations";
import DateFormatting from "../../shared/formatting/DateFormatting";
import MonetaryFormatting from "../../shared/formatting/MonetaryFormatting";
interface IAccountDetailsProps {
selectedAccount?: IRepoAccount;
otherRepos: string;
refreshCollateral: (collateral: ICollateral, memberNo: number, loanNo: number) => any;
branchMapping: IBranchSetEntry[];
}
const AccountDetails: React.FC<IAccountDetailsProps> = (props) => {
const getWrittenOffText = () => {
const writtenOffDate = getAccountField(acc => acc.writtenOffDate);
if (writtenOffDate) {
return DateFormatting.FormatMMDDYYYY(writtenOffDate);
}
return "No";
};
const getAccountField = function<T>(valuePlucker: (repoAccount: IRepoAccount) => T): T | undefined {
if (props.selectedAccount) {
return valuePlucker(props.selectedAccount);
}
};
const getControlledAccountField = function<T>(valuePlucker: (repoAccount: IRepoAccount) => T): T | string {
const pluckedVal = getAccountField(valuePlucker);
return pluckedVal !== undefined ? pluckedVal : "";
};
const getDaysCurrentDelq = (): string | number => {
const dueToPayDate = getAccountField(acc => acc.dueToPayDate);
if (dueToPayDate) {
return DateCalculations.DayDifference(dueToPayDate, moment());
}
return "";
};
const formatAccountTypeCode = (): string => {
const accountTypeCode = getControlledAccountField(acc => acc.accountTypeCode);
let origAccountTypeCode = getControlledAccountField(acc => acc.origAccountTypeCode);
origAccountTypeCode = !origAccountTypeCode ? "-" : origAccountTypeCode;
return "("+origAccountTypeCode+") / " + accountTypeCode;
};
const createCollateralDisplays = (): ICollateralDisplay[] => {
if (props.selectedAccount) {
return props.selectedAccount.collaterals.map((collateral) => {
return {
collateral: collateral,
refreshCollateral: () => {
return props.refreshCollateral(collateral, props.selectedAccount!.memberNo, props.selectedAccount!.loanNo);
},
};
});
} else {
return [];
}
};
const getBranchName = (): string | number =>{
const BranchIdFromAccount = getControlledAccountField(acc => acc.branch);
if(!props.branchMapping){
return BranchIdFromAccount;
}
// eslint-disable-next-line eqeqeq
const mappedEntry = props.branchMapping.find(branch => branch.branchId == BranchIdFromAccount);
return (mappedEntry && mappedEntry.branchName) ? mappedEntry.branchName : BranchIdFromAccount;
};
const getSixtyPlusCollector = (): string | undefined =>{
const SixtyPlusCollector = getAccountField(acct => acct.sixtyPlusCollector);
if(SixtyPlusCollector){
return SixtyPlusCollector.sixtyPlusCollectorName;
}
return "";
}
const isAccountClosed = RepoAccountService.IsAccountClosed(props.selectedAccount);
return (
<div className="account-details-holder container">
<CollateralDisplay isAccountClosed={isAccountClosed} collateral={createCollateralDisplays()} />
<div className="account-page-input-section row">
<div className="col-sm">
<p>Repo DB Date</p>
<input data-test="repo-db-date" className="form-control" value={DateFormatting.FormatMMDDYYYY(getAccountField(acc => acc.o4RDate))} disabled={true} />
<p>Orig Amount</p>
<input data-test="orig-amount" type="text" className="form-control" value={MonetaryFormatting.FormatUSD(getAccountField(acc => acc.origAmount))} disabled={true} />
<p>Account Code</p>
<input data-test="account-code" type="text" className="form-control" value={formatAccountTypeCode()} disabled={true} />
<p>Bankruptcy</p>
<input data-test="bankruptcy" type="text" className="form-control" value={getAccountField(acc => acc.bankruptcy) || "No"} disabled={true} />
</div>
<div className="col-sm">
<p>First Delinquent</p>
<input data-test="first-delinquent" className="form-control" value={DateFormatting.FormatMMDDYYYY(getAccountField(acc => acc.dateFirstDelinquent))} disabled={true} />
<p>Balance</p>
<input data-test="balance" type="text" className="form-control" value={MonetaryFormatting.FormatUSD(getAccountField(acc => acc.balance))} disabled={true} />
<p>Branch</p>
<input data-test="branch" type="text" className="form-control" value={getBranchName()} disabled={true} />
<p>Temenos Account</p>
<input data-test="reference-id" type="text" className="form-control" value={getAccountField(acc => acc.referenceId)} disabled={true}/>
</div>
<div className="col-sm">
<p>Written Off</p>
<input data-test="written-off" type="text" className="form-control" value={getWrittenOffText()} disabled={true} />
<p>Last Payment</p>
<input data-test="last-payment" className="form-control" value={DateFormatting.FormatMMDDYYYY(getAccountField(acc => acc.lastPaymentDate))} disabled={true} />
<p>Current Delq Amount</p>
<input data-test="current-delq-amount" type="text" className="form-control" value={MonetaryFormatting.FormatUSD(getAccountField(acc => acc.delinquentAmount))} disabled={true} />
<p>Temenos Case</p>
<input data-test="reference-case-id" type="text" className="form-control" value={getAccountField(acc => acc.referenceCaseId)} disabled={true}/>
</div>
<div className="col-sm">
<p>Other Repos</p>
<input data-test="other-repos" type="text" className="form-control" value={props.otherRepos} disabled={true} />
<p>Days In Status</p>
<input data-test="days-in-status" type="text" className="form-control" value={RepoAccountService.GetDaysInStatus(props.selectedAccount)} disabled={true} />
<p>Last Pmt Amount</p>
<input data-test="last-pmt-amount" type="text" className="form-control" value={MonetaryFormatting.FormatUSD(getAccountField(acc => acc.lstPmtAmt))} disabled={true} />
<p>Account Last Processed</p>
<input data-test="account-last-proccessed" type="text" className="form-control" value={DateFormatting.FormatMMDDYYYHHMMA(getAccountField(acc => acc.accountLastProcessed ))} disabled={true} />
</div>
<div className="col-sm">
<p>Days Delq When Added</p>
<input data-test="days-delq-when-added" type="text" className="form-control" value={getControlledAccountField(acc => acc.daysDelinquent)} disabled={true} />
<p>Days Current Delq</p>
<input data-test="days-current-delq" type="text" className="form-control" value={getDaysCurrentDelq()} disabled={true} />
<p>Required Amount</p>
<input data-test="required-amount" type="text" className="form-control" value={MonetaryFormatting.FormatUSD(getAccountField(acc => acc.requiredPaymentAmount))} disabled={true} />
<p>60+ User Assigned</p>
<input data-test="sixty-plus-collector" type="text" className="form-control" value={getSixtyPlusCollector()} disabled={true} />
</div>
</div>
</div>
);
};
export default AccountDetails;