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

Feat: Label updates for Part 3 Awards, File Submissions - 2491 2492 #2587

Merged
merged 2 commits into from
Sep 5, 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
25 changes: 12 additions & 13 deletions frontend/src/compliance_reporting/ScheduleBContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ScheduleBContainer extends Component {
readOnly: true,
value: (
<div>
{props.period < COMPLIANCE_YEAR ? 'CREDIT/DEBIT CALCULATION ': 'COMPLIANCE UNITS CALCULATION '}
{props.period < COMPLIANCE_YEAR ? 'CREDIT/DEBIT CALCULATION ' : 'COMPLIANCE UNITS CALCULATION '}
<Tooltip
className="info left"
show
Expand Down Expand Up @@ -591,19 +591,18 @@ class ScheduleBContainer extends Component {
grid[row][SCHEDULE_B.CARBON_INTENSITY_FUEL].value = response.outputs.carbonIntensityFuel
grid[row][SCHEDULE_B.CARBON_INTENSITY_FUEL].readOnly = true
}
console.log(grid[row][SCHEDULE_B.CARBON_INTENSITY_FUEL], "597")
console.log(grid[row][SCHEDULE_B.CARBON_INTENSITY_FUEL], '597')
grid[row][SCHEDULE_B.CARBON_INTENSITY_FUEL].customIntensityValue =
response.outputs.customIntensityValue

grid[row][SCHEDULE_B.ENERGY_CONTENT].value = response.outputs.energyContent
if (context.compliancePeriod < COMPLIANCE_YEAR ) {
grid[row][SCHEDULE_B.CREDIT].value = response.outputs.credits
grid[row][SCHEDULE_B.DEBIT].value = response.outputs.debits
}
else {
const complinaceUnits = response.outputs.credits - response.outputs.debits
grid[row][SCHEDULE_B.COMPLIANCE_UNITS].value = complinaceUnits
}
grid[row][SCHEDULE_B.ENERGY_CONTENT].value = response.outputs.energyContent
if (context.compliancePeriod < COMPLIANCE_YEAR) {
grid[row][SCHEDULE_B.CREDIT].value = response.outputs.credits
grid[row][SCHEDULE_B.DEBIT].value = response.outputs.debits
} else {
const complinaceUnits = response.outputs.credits - response.outputs.debits
grid[row][SCHEDULE_B.COMPLIANCE_UNITS].value = complinaceUnits
}

if (!this.props.validating) {
grid[row] = this._validate(grid[row], row - 2)
Expand Down Expand Up @@ -943,10 +942,10 @@ class ScheduleBContainer extends Component {
grid[row][SCHEDULE_B.CARBON_INTENSITY_FUEL].value = null
grid[row][SCHEDULE_B.CARBON_INTENSITY_LIMIT].value = null
grid[row][SCHEDULE_B.CREDIT].value = null
if(grid[row][SCHEDULE_B.DEBIT]){
if (grid[row][SCHEDULE_B.DEBIT]) {
grid[row][SCHEDULE_B.DEBIT].value = null
}
if(grid[row][SCHEDULE_B.COMPLIANCE_UNITS]){
if (grid[row][SCHEDULE_B.COMPLIANCE_UNITS]) {
grid[row][SCHEDULE_B.COMPLIANCE_UNITS].value = null
}
// grid[row][SCHEDULE_B.DEBIT].value = null
Expand Down
27 changes: 15 additions & 12 deletions frontend/src/compliance_reporting/ScheduleDContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,16 +541,18 @@ class ScheduleDContainer extends Component {
}

_handleDeleteSheet (id) {
const filterData = this.state.sheets.filter(items => items.id != id)

this.setState({
sheets:filterData
})
if(filterData.length > 0)
this._gridStateToPayload({
sheets:filterData
})
}
const filterData = this.state.sheets.filter(items => items.id !== id)

this.setState({
sheets: filterData
})
if (filterData.length > 0) {
this._gridStateToPayload({
sheets: filterData
})
}
}

_validate (_sheet, sheetIndex) {
const sheet = _sheet

Expand Down Expand Up @@ -702,7 +704,7 @@ class ScheduleDContainer extends Component {
sheets={sheets}
setActiveSheet={this._setActiveSheet}
handleDeleteSheet={this._handleDeleteSheet}
reportStatus={this.props.complianceReport.status}
reportStatus={this.props.complianceReport.status}
/>

{sheets.map(sheet => (
Expand Down Expand Up @@ -753,7 +755,8 @@ ScheduleDContainer.defaultProps = {
ScheduleDContainer.propTypes = {
complianceReport: PropTypes.shape({
compliancePeriod: PropTypes.shape(),
scheduleD: PropTypes.shape()
scheduleD: PropTypes.shape(),
status: PropTypes.shape()
}),
match: PropTypes.shape({}),
readOnly: PropTypes.bool.isRequired,
Expand Down
12 changes: 7 additions & 5 deletions frontend/src/compliance_reporting/components/ScheduleDTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ const ScheduleDTabs = (props) => {
sheets,
handleDeleteSheet,
reportStatus

} = props

const handleDelete = (id) => {
handleDeleteSheet(id)
}

const renderTabs = (active) => {
const elements = []

Expand Down Expand Up @@ -59,15 +59,15 @@ const ScheduleDTabs = (props) => {
>
<div>
<button type="button" onClick={() => setActiveSheet(sheet.id)}>{label}</button>
{(active === sheet.id) && (reportStatus.fuelSupplierStatus === 'Draft' ) &&
{(active === sheet.id) && (reportStatus.fuelSupplierStatus === 'Draft') &&
!inUsed &&
<button
className="delete"
data-toggle="modal"
data-target="#confirmDelete"
type="button"
onClick={() => handleDelete(sheet.id)}

>
<FontAwesomeIcon icon="minus-circle" />
</button>
Expand Down Expand Up @@ -122,7 +122,9 @@ ScheduleDTabs.propTypes = {
scheduleB: PropTypes.shape(),
setActiveSheet: PropTypes.func.isRequired,
sheets: PropTypes.arrayOf(PropTypes.shape()).isRequired,
complianceReport: PropTypes.object.isRequired
complianceReport: PropTypes.object.isRequired,
handleDeleteSheet: PropTypes.func,
reportStatus: PropTypes.shape()
}

export default ScheduleDTabs
7 changes: 3 additions & 4 deletions frontend/src/constants/langEnUs.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const BTN_REFUSE = 'Refuse'
export const BTN_REJECT = 'Reject'
export const BTN_CANCEL = 'Cancel'
export const BTN_RECOMMEND_FOR_ACCEPTANCE = 'Recommend for Acceptance'
export const BTN_RECOMMEND_FOR_DECISION = 'Recommend for Approval'
export const BTN_RECOMMEND_FOR_DECISION = 'Recommend issuance'
export const BTN_RECOMMEND_FOR_REJECTION = 'Recommend for Rejection'
export const BTN_REQUEST_SUPPLEMENTAL = 'Request Supplemental'
export const BTN_RESCIND = 'Rescind'
Expand Down Expand Up @@ -60,11 +60,10 @@ export const TEXT_COMMENT_PLACEHOLDER = 'Use this field to communicate relevant
export const TEXT_COMMENT_PLACEHOLDER_PRIVILEGED = 'Use this field to provide background for ' +
'recommendations or decisions'
export const TEXT_COMMENT_DISCLOSURE = 'Information entered in this comment field will be ' +
'visible to both parties of the transaction and ' +
'visible to both the organization and ' +
'government.'
export const TEXT_COMMENT_DISCLOSURE_PRIVILEGED = 'Information entered in this comment field ' +
'will be visible only to government users and ' +
'not shared with fuel suppliers'
'will only be visible to government.'
export const TEXT_ADD_COMMENT_HEADING = 'Add Comment Form'
export const TEXT_EDIT_COMMENT_HEADING = 'Editing Comment'
export const TEXT_ADD_INITIAL_COMMENT = 'Add Comment'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class CreditTransferAddContainer extends Component {
isCommenting={this.state.isCommenting}
isCreatingPrivilegedComment={this.state.isCreatingPrivilegedComment}
key="creditTransferForm"
title="New Part 3 Award"
title="New Initiative Agreement Issuance"
validationErrors={this.state.validationErrors}
/>,
<Modal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ describe('CreditTransferSigningHistory', () => {
const props = {
history: historyMock,
dateOfWrittenAgreement: moment().format('LL'),
categoryDSelected: false
categoryDSelected: false,
loggedInUser: {
isGovernmentUser: true
}
}

const component = renderer.create(
Expand Down Expand Up @@ -73,30 +76,31 @@ describe('CreditTransferSigningHistory', () => {
expect(tree).toMatchSnapshot()
})

const sumbmissionDate = new Date()
let agreementDate = new Date()

test('returns category A if differenceInMonths <= 6', () => {
agreementDate.setMonth(agreementDate.getMonth() - 5) // Five months ago
const result = CreditTransferSigningHistory.calculateTransferCategoryAndNextChange(agreementDate, false)
expect(result).toEqual({ category: 'A', nextChangeInMonths: 2 })
agreementDate.setMonth(agreementDate.getMonth() - 2) // 2 months ago
const result = CreditTransferSigningHistory.calculateTransferCategoryAndNextChange(agreementDate, sumbmissionDate, false)
expect(result).toEqual({ category: 'A', nextChangeInMonths: 6 })
})

test('returns category B if differenceInMonths > 6 and differenceInMonths <= 12', () => {
agreementDate = new Date()
agreementDate.setMonth(agreementDate.getMonth() - 7) // Seven months ago
const result = CreditTransferSigningHistory.calculateTransferCategoryAndNextChange(agreementDate, false)
expect(result).toEqual({ category: 'B', nextChangeInMonths: 6 })
agreementDate.setMonth(agreementDate.getMonth() - 8) // 8 months ago
const result = CreditTransferSigningHistory.calculateTransferCategoryAndNextChange(agreementDate, sumbmissionDate, false)
expect(result).toEqual({ category: 'B', nextChangeInMonths: 12 })
})

test('returns category C if differenceInMonths > 12', () => {
agreementDate = new Date()
agreementDate.setFullYear(agreementDate.getFullYear() - 2) // Two years ago
const result = CreditTransferSigningHistory.calculateTransferCategoryAndNextChange(agreementDate, false)
const result = CreditTransferSigningHistory.calculateTransferCategoryAndNextChange(agreementDate, sumbmissionDate, false)
expect(result).toEqual({ category: 'C', nextChangeInMonths: null })
})

test('returns category D if categoryDSelected is true', () => {
const result = CreditTransferSigningHistory.calculateTransferCategoryAndNextChange(agreementDate, true)
const result = CreditTransferSigningHistory.calculateTransferCategoryAndNextChange(agreementDate, sumbmissionDate, true)
expect(result).toEqual({ category: 'D', nextChangeInMonths: null })
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ exports[`CreditTransferSigningHistory renders the component correctly 1`] = `
<p>
<li>
<span>
Date of written agreement reached between the two suppliers:
Date of written agreement reached between the two organizations:
</span>
<strong>
July 11, 2023
September 1, 2023
</strong>
<span>
(proposal falls under
Expand All @@ -28,7 +28,7 @@ exports[`CreditTransferSigningHistory renders the component correctly 1`] = `
<span>
if approved by:
<strong>
February 11, 2024
March 1, 2024
</strong>
)
</span>
Expand All @@ -43,7 +43,7 @@ exports[`CreditTransferSigningHistory renders the component correctly 1`] = `
<span>
on
</span>
July 11, 2023
September 1, 2023
<span>
by
</span>
Expand Down Expand Up @@ -73,31 +73,6 @@ exports[`CreditTransferSigningHistory should render the component with dateOfWri
>
Transaction History
</h3>
<p>
<li>
<span>
Date of written agreement reached between the two suppliers:
</span>
<strong>
July 11, 2023
</strong>
<span>
(proposal falls under
<strong>
Category
A
</strong>

</span>
<span>
if approved by:
<strong>
February 11, 2024
</strong>
)
</span>
</li>
</p>
<p>
<li>
<strong>
Expand All @@ -107,7 +82,7 @@ exports[`CreditTransferSigningHistory should render the component with dateOfWri
<span>
on
</span>
July 11, 2023
September 1, 2023
<span>
by
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import InputWithTooltip from '../../app/components/InputWithTooltip'

class CreditTransferFormDetails extends Component {
enableZeroReason () {
console.log(this.props, "1414")
console.log(this.props, '1414')
return (
(this.props.fields.tradeType.id === CREDIT_TRANSFER_TYPES.sell.id ||
this.props.fields.tradeType.id === CREDIT_TRANSFER_TYPES.buy.id) &&
this.props.fields.fairMarketValuePerCredit !== null &&
parseFloat(this.props.fields.fairMarketValuePerCredit) === 0
)
}

render () {
return (
<div className="credit-transfer-details">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PropTypes from 'prop-types'
import React, { useState } from 'react'
import React from 'react'
import CheckBox from '../../app/components/CheckBox'

const CreditTransferTerms = props => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ const GovernmentTransferFormDetails = props => (
<div className="form-group col-md-6">
<label htmlFor="transfer-type">Transaction Type:
<div className="form-control">
Part 3 Award
Initiative Agreement
</div>
</label>
</div>
</div>

<div className="row">
<div className="form-group col-md-6">
<label htmlFor="respondent">Credits To:
<label htmlFor="respondent">Compliance units to:
<select
className="form-control"
id="respondent"
Expand All @@ -30,7 +30,7 @@ const GovernmentTransferFormDetails = props => (
onChange={props.handleInputChange}
required="required"
>
<option key="0" value="" default>Select a Fuel Supplier</option>
<option key="0" value="" default>Select an organization</option>
{props.fuelSuppliers &&
props.fuelSuppliers.map(organization => (
<option key={organization.id} value={organization.id}>
Expand All @@ -44,7 +44,7 @@ const GovernmentTransferFormDetails = props => (

<div className="row">
<div className="form-group col-md-6">
<label htmlFor="number-of-credits">Number of Credits:
<label htmlFor="number-of-credits">Number of compliance units
<InputWithTooltip
handleInputChange={props.handleInputChange}
id="number-of-credits"
Expand All @@ -60,7 +60,7 @@ const GovernmentTransferFormDetails = props => (

<div className="row">
<div className="form-group col-md-6">
<label htmlFor="compliance-period">Compliance Period:
<label htmlFor="compliance-period">Compliance period:
<select
className="form-control"
id="compliance-period"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('OrganizationEditForm', () => {
<OrganizationEditForm {...props} />
</BrowserRouter>
)
const statusEl = screen.getByLabelText('Active')
const statusEl = screen.getByLabelText('Yes')
expect(statusEl).toBeInTheDocument()
})
test('Supplier Status should not be in the DOM', () => {
Expand All @@ -103,7 +103,7 @@ describe('OrganizationEditForm', () => {
<OrganizationEditForm {...props} />
</BrowserRouter>
)
const statusEl1 = screen.queryByLabelText('Active')
const statusEl1 = screen.queryByLabelText('Yes')
expect(statusEl1).not.toBeInTheDocument()
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class SecureFileSubmissionContainer extends Component {
handlePageSizeChange={this.handlePageSizeChange}
handleFiltersChange={this.handleFiltersChange}
handleSortChange={this.handleSortChange}
title="Secure File Submissions"
title="File Submissions"
/>
)
}
Expand Down
Loading