Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #194 from AppliedIS/issue103
Browse files Browse the repository at this point in the history
Issue103
  • Loading branch information
jefferey committed Dec 1, 2016
2 parents 9864fb0 + 71bfbee commit db260a0
Show file tree
Hide file tree
Showing 9 changed files with 285 additions and 4 deletions.
8 changes: 8 additions & 0 deletions DOL.WHD.Section14c.Business/Services/ApplicationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ private void SetDefaults(ApplicationSubmission model)
{
model.Employer.SendMailToParent = null;
}

// default to false if no value was passed
model.Employer.HasMailingAddress = model.Employer.HasMailingAddress ?? false;
if (!model.Employer.HasMailingAddress.GetValueOrDefault())
{
// remove mailing address if hasMailingAddress == false
model.Employer.MailingAddress = null;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@
<Compile Include="Migrations\201611301612331_InitialApplicationRequiredFields.Designer.cs">
<DependentUpon>201611301612331_InitialApplicationRequiredFields.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201611301931465_AddEmployerMailingAddress.cs" />
<Compile Include="Migrations\201611301931465_AddEmployerMailingAddress.Designer.cs">
<DependentUpon>201611301931465_AddEmployerMailingAddress.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Repositories\ApplicationRepository.cs" />
Expand Down Expand Up @@ -382,6 +386,9 @@
<EmbeddedResource Include="Migrations\201611301612331_InitialApplicationRequiredFields.resx">
<DependentUpon>201611301612331_InitialApplicationRequiredFields.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\201611301931465_AddEmployerMailingAddress.resx">
<DependentUpon>201611301931465_AddEmployerMailingAddress.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace DOL.WHD.Section14c.DataAccess.Migrations
{
using System;
using System.Data.Entity.Migrations;

public partial class AddEmployerMailingAddress : DbMigration
{
public override void Up()
{
AddColumn("dbo.EmployerInfoes", "HasMailingAddress", c => c.Boolean());
AddColumn("dbo.EmployerInfoes", "MailingAddress_Id", c => c.Guid());
CreateIndex("dbo.EmployerInfoes", "MailingAddress_Id");
AddForeignKey("dbo.EmployerInfoes", "MailingAddress_Id", "dbo.Addresses", "Id");
}

public override void Down()
{
DropForeignKey("dbo.EmployerInfoes", "MailingAddress_Id", "dbo.Addresses");
DropIndex("dbo.EmployerInfoes", new[] { "MailingAddress_Id" });
DropColumn("dbo.EmployerInfoes", "MailingAddress_Id");
DropColumn("dbo.EmployerInfoes", "HasMailingAddress");
}
}
}

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions DOL.WHD.Section14c.Domain/Models/Submission/EmployerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public EmployerInfo()

public virtual Address PhysicalAddress { get; set; }

public bool? HasMailingAddress { get; set; }

public virtual Address MailingAddress { get; set; }

public bool? HasParentOrg { get; set; }

public string ParentLegalName { get; set; }
Expand Down
26 changes: 26 additions & 0 deletions DOL.WHD.Section14c.Test/Business/ApplicationServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,5 +333,31 @@ public void ApplicationService_Does_Not_CleanUp_Renewal_Application()
Assert.IsNotNull(obj.WorkSites.ElementAt(0).NumEmployees);
Assert.IsNotNull(obj.WorkSites.ElementAt(0).Employees);
}

[TestMethod]
public void ApplicationService_Defaults_HasMailingAddress_Null()
{
// Arrange
var obj = new ApplicationSubmission { Employer = new EmployerInfo { HasMailingAddress = null } };

// Act
_applicationService.ProcessModel(obj);

// Assert
Assert.IsFalse(obj.Employer.HasMailingAddress.Value);
}

[TestMethod]
public void ApplicationService_Defaults_HasMailingAddress_NotNull()
{
// Arrange
var obj = new ApplicationSubmission { Employer = new EmployerInfo { HasMailingAddress = true } };

// Act
_applicationService.ProcessModel(obj);

// Assert
Assert.IsTrue(obj.Employer.HasMailingAddress.Value);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,54 @@ <h3>Employer Information</h3>
<input id="county" name="county" type="text" ng-model="formData.employer.physicalAddress.county">
</div>

<div class="usa-input-grid usa-input-grid-large">
<input id="hasMailingAddress" type="checkbox" name="hasMailingAddress" value="true" ng-model="formData.employer.hasMailingAddress">
<label for="hasMailingAddress">Mailing Address is different from Physical Address</label>
</div>
</fieldset>
</div>

<div class="form-question-block" ng-show="formData.employer.hasMailingAddress === true">
<div class="form-question-text">Mailing Address of Employer's Main Establishment</div>
<fieldset>
<div class="usa-form-large">
<div ng-class="validate('employer.mailingAddress.streetAddress') ? 'usa-input-error' : ''">
<label for="mailingAddressStreet">Street Address</label>
<span class="usa-input-error-message" role="alert" ng-show="validate('employer.mailingAddress.streetAddress')">{{ validate('employer.mailingAddress.streetAddress') }}</span>
<input id="mailingAddressStreet" name="mailingAddressStreet" type="text" ng-model="formData.employer.mailingAddress.streetAddress">
</div>

<div class="clearer" ng-class="validate(['employer.mailingAddress.city', 'employer.mailingAddress.state']) ? 'usa-input-error' : ''">
<div class="usa-input-grid usa-input-grid-medium">
<label for="mailingAddressCity">City</label>
<span class="usa-input-error-message" role="alert" ng-show="validate('employer.mailingAddress.city')">{{ validate('employer.mailingAddress.city') }}</span>
<input id="mailingAddressCity" name="mailingAddressCity" type="text" ng-model="formData.employer.mailingAddress.city">
</div>

<div class="usa-input-grid usa-input-grid-small">
<label for="mailingAddressState">State</label>
<span class="usa-input-error-message" role="alert" ng-show="validate('employer.mailingAddress.state')">{{ validate('employer.mailingAddress.state') }}</span>
<state-field name="mailingAddressState" selected-state="formData.employer.mailingAddress.state"></state-field>
</div>
</div>

<div ng-class="validate('employer.mailingAddress.zipCode') ? 'usa-input-error' : ''">
<label for="mailingAddressZipCode">Zip Code</label>
<span class="usa-input-error-message" role="alert" ng-show="validate('employer.mailingAddress.zipCode')">{{ validate('employer.mailingAddress.zipCode') }}</span>
<input class="usa-input-medium" id="mailingAddressZipCode" name="mailingAddressZipCode" type="text" mask="99999-?9?9?9?9?" pattern="[\d]{5}(-[\d]{4})?" data-grouplength="5,4" data-delimiter="-" data-politespace ng-model="formData.employer.mailingAddress.zipCode">
</div>

<div ng-class="validate('employer.mailingAddress.county') ? 'usa-input-error' : ''">
<label for="mailingAddressCounty">County</label>
<span class="usa-input-error-message" role="alert" ng-show="validate('employer.mailingAddress.county')">{{ validate('employer.mailingAddress.county') }}</span>
<input id="mailingAddressCounty" name="mailingAddressCounty" type="text" ng-model="formData.employer.mailingAddress.county">
</div>
</div>

</fieldset>
</div>


<div class="form-question-block" ng-class="validate('employer.hasParentOrg') ? 'usa-input-error' : ''">
<div class="form-question-text">Does the Employer have a Parent Organization?
<helplink></helplink>
Expand Down
19 changes: 15 additions & 4 deletions DOL.WHD.Section14c.Web/src/modules/services/validationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ module.exports = function(ngModule) {
}

this.checkIsInitial = function() {
return this.checkRequiredMultipleChoice("applicationTypeId") === _constants.responses.applicationType.initial;
return this.getFormValue("applicationTypeId") === _constants.responses.applicationType.initial;
}


Expand All @@ -201,7 +201,7 @@ module.exports = function(ngModule) {
this.checkRequiredDateComponent("signature.date", "Please provide the date");
}

/* eslint-disable complexity */
/* eslint-disable complexity, max-statements */
this.validateAppInfo = function() {
section = "__appinfo";

Expand Down Expand Up @@ -262,6 +262,19 @@ module.exports = function(ngModule) {

this.checkRequiredString("employer.physicalAddress.county", "Please provide the county for the employer's main establishment");

let hasMailingAddress = this.getFormValue("employer.hasMailingAddress");
if(hasMailingAddress === true) {
this.checkRequiredString("employer.mailingAddress.streetAddress", "Please provide the street address for the employer's mailing address");
this.checkRequiredString("employer.mailingAddress.city", "Please provide the city for the employer's mailing address");
this.checkRequiredValue("employer.mailingAddress.state", "Please select a state or territory for the employer's mailing address");

if (!this.validateZipCode(this.getFormValue("employer.mailingAddress.zipCode"))) {
this.setValidationError("employer.mailingAddress.zipCode", "Please provide a valid zip code for the employer's mailing address");
}

this.checkRequiredString("employer.mailingAddress.county", "Please provide the county for the employer's mailing address");
}

let hasParentOrg = this.checkRequiredMultipleChoice("employer.hasParentOrg", "Please indicate if the employer has a Parent Organization");
if (hasParentOrg === true) {
this.checkRequiredString("employer.parentLegalName", "Please provide the Parent Organization's legal name");
Expand Down Expand Up @@ -508,15 +521,13 @@ module.exports = function(ngModule) {
// main method to be called for application validation
this.validateForm = function() {
this.resetState();

this.validateAssurances();
this.validateAppInfo();
this.validateEmployer();

if (!this.checkIsInitial()) {
this.validateWageData();
}

this.validateWorkSites();
this.validateWIOA();

Expand Down

0 comments on commit db260a0

Please sign in to comment.