Skip to content

Commit

Permalink
Merge pull request #3300 from HHS/OPS-310/3236_prev_FY_carry_forward_…
Browse files Browse the repository at this point in the history
…card

feat: ✨ adds prev fy carry forward card
  • Loading branch information
fpigeonjr authored Jan 16, 2025
2 parents 48296c3 + bcb44d9 commit bffe70a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 20 deletions.
9 changes: 8 additions & 1 deletion frontend/cypress/e2e/canDetail.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ describe("CAN detail page", () => {
cy.visit(`/cans/${can504.number}/funding`);
cy.get("#fiscal-year-select").select(currentFiscalYear);
cy.get("#edit").click();
cy.get("#carry-forward-card").should("contain", "$ 10,000,000.00");
cy.get("#save-changes").should("be.disabled");
cy.get("#add-fy-budget").should("be.disabled");
cy.get("#carry-forward-card").should("contain", "0");
Expand Down Expand Up @@ -237,7 +238,7 @@ describe("CAN detail page", () => {
cy.visit(`/cans/${can504.number}/funding`);
cy.get("#fiscal-year-select").select(currentFiscalYear);
cy.get("#edit").click();
cy.get("#carry-forward-card").should("contain", "$ 5,000,000.00");
cy.get("#carry-forward-card").should("contain", "$ 10,000,000.00");
cy.get("[data-cy='can-budget-fy-card']").should("contain", "5,000,000.00");
cy.get("#budget-amount").type("6_000_000");
cy.get("#add-fy-budget").click();
Expand Down Expand Up @@ -265,4 +266,10 @@ describe("CAN detail page", () => {
// check table has one row
cy.get("tbody").children().should("have.length", 1);
});
it("handles not showing carry forward card", () => {
cy.visit(`/cans/500/funding`);
cy.get("#fiscal-year-select").select(currentFiscalYear);
cy.get("#edit").click();
cy.get("#carry-forward-card").should("not.exist");
});
});
15 changes: 13 additions & 2 deletions frontend/src/components/CANs/CANBudgetForm/CANBudgetForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import icons from "../../../uswds/img/sprite.svg";

/**
* @typedef {Object} CANBudgetFormProps
* @property {boolean} showCarryForwardCard
* @property {string} totalFunding
* @property {string} budgetAmount
* @property {(arg: string) => string} cn
Expand All @@ -18,7 +19,17 @@ import icons from "../../../uswds/img/sprite.svg";
* @param {CANBudgetFormProps} props
* @returns {JSX.Element} - The component JSX.
*/
const CANBudgetForm = ({ totalFunding, budgetAmount, cn, res, fiscalYear, handleAddBudget, runValidate, setBudgetAmount }) => {
const CANBudgetForm = ({
totalFunding,
showCarryForwardCard,
budgetAmount,
cn,
res,
fiscalYear,
handleAddBudget,
runValidate,
setBudgetAmount
}) => {
const fillColor = budgetAmount ? "#005ea2" : "#757575";

return (
Expand All @@ -27,7 +38,7 @@ const CANBudgetForm = ({ totalFunding, budgetAmount, cn, res, fiscalYear, handle
handleAddBudget(e);
}}
>
<div style={{ width: "383px" }}>
<div style={{ width: "383px", marginTop: `${showCarryForwardCard ? "0" : "-24px"}` }}>
<CurrencyInput
name="budget-amount"
label={`FY ${fiscalYear} CAN Budget`}
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/pages/cans/detail/Can.hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export default function useCan() {
refetchOnMountOrArgChange: true
});

const { data: previousFYfundingSummary } = useGetCanFundingSummaryQuery({
ids: [canId],
fiscalYear: fiscalYear - 1
});

const budgetLineItemsByFiscalYear = React.useMemo(() => {
if (!fiscalYear || !can) return [];

Expand Down Expand Up @@ -106,7 +111,7 @@ export default function useCan() {
inExecutionFunding: CANFunding?.in_execution_funding ?? "0",
inDraftFunding: CANFunding?.in_draft_funding ?? "0",
receivedFunding: CANFunding?.received_funding ?? "0",
carryForwardFunding: CANFunding?.carry_forward_funding ?? "0",
carryForwardFunding: previousFYfundingSummary?.available_funding ?? 0,
subTitle: can?.nick_name ?? "",
projectTypesCount,
budgetLineTypesCount,
Expand Down
40 changes: 24 additions & 16 deletions frontend/src/pages/cans/detail/CanFunding.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ const CanFunding = ({
return <div>No funding information available for this CAN.</div>;
}

const showCarryForwardCard = funding.active_period != 1 && fiscalYear > funding.fiscal_year;

return (
<div>
{showModal && (
Expand Down Expand Up @@ -167,22 +169,25 @@ const CanFunding = ({
className="border-right-1px border-base-light"
style={{ minWidth: "46%" }}
>
<RoundedBox
className="font-12px"
style={{ minHeight: "69px", width: "313px", padding: "17px 0 0 13px" }}
id="carry-forward-card"
>
<p className="margin-0 text-base-dark">Previous FYs Carry Forward</p>
<CurrencyFormat
value={carryForwardFunding}
displayType="text"
thousandSeparator={true}
decimalScale={2}
fixedDecimalScale={true}
prefix="$ "
/>
</RoundedBox>
{showCarryForwardCard && (
<RoundedBox
className="font-12px"
style={{ minHeight: "69px", width: "313px", padding: "17px 0 0 13px" }}
id="carry-forward-card"
>
<p className="margin-0 text-base-dark">Previous FYs Carry Forward</p>
<CurrencyFormat
value={carryForwardFunding}
displayType="text"
thousandSeparator={true}
decimalScale={2}
fixedDecimalScale={true}
prefix="$ "
/>
</RoundedBox>
)}
<CANBudgetForm
showCarryForwardCard={showCarryForwardCard}
totalFunding={
budgetForm.submittedAmount ? budgetForm.submittedAmount : totalFunding
}
Expand All @@ -202,7 +207,10 @@ const CanFunding = ({
/>
</div>
</section>
<section id="can-funding-received-form-section" className="margin-bottom-4">
<section
id="can-funding-received-form-section"
className="margin-bottom-4"
>
<h2>{`Add FY ${fiscalYear} Funding Received YTD`}</h2>
<p>{`Add funding received towards the Total FY ${fiscalYear} Budget or come back to add funding later. Funding Received means the money is in OPRE’s hands and ready to spend against.`}</p>
<div className="display-flex flex-justify margin-top-4">
Expand Down

0 comments on commit bffe70a

Please sign in to comment.