DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Projection Queries: A Way to Optimize Data Traffic
  • Microservices in Practice: Deployment Shouldn't Be an Afterthought
  • Moving PeopleSoft ERP Data Between Databases With Data Mover Scripts
  • Understanding Multi-Leader Replication for Distributed Data

Trending

  • Doris: Unifying SQL Dialects for a Seamless Data Query Ecosystem
  • How the Go Runtime Preempts Goroutines for Efficient Concurrency
  • Overcoming React Development Hurdles: A Guide for Developers
  • Simplify Authorization in Ruby on Rails With the Power of Pundit Gem
  1. DZone
  2. Data Engineering
  3. Databases
  4. Making the County List Dynamic

Making the County List Dynamic

A Zone Leader continues his case study of building a new application for a family member. In this article, read how different tax rates by county and for a particular time span introduced a challenge.

By 
John Vester user avatar
John Vester
DZone Core CORE ·
Dec. 11, 18 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
10.6K Views

Join the DZone community and get the full member experience.

Join For Free

As a follow-up to my "New Application Journey" article, I wanted to talk about an interesting requirement that I encountered while gathering information for my mother-in-law's application.

Recap

As a TL;DR ("too long; didn't read") to the original article, I wasn't happy with the application my mother-in-law was using for her very small business in the southeast section of the United States. So, I used her business needs to create a new application from scratch using Angular, mySQL, and the AWS environment. As I started building out the main form for data entry, I noticed an interesting requirement around the county tax rates.

The County Table

As one might imagine, the homes being sold and tracked by the application reside in a particular county within the state of Florida. As a result, county taxes are applied based upon a percentage calculation from the total sales price. Since each county is their own municipality, they have different tax rates.

This was a pretty simple design. I would build a County table that listed each county and included the tax rate for that county.

When I asked my mother-in-law for a listing of the current taxes, she pointed me to a form that provided information I was not expecting. There were effective dates for the tax rates. As an example, Dade County might have a tax rate of 1% from 2015 through 2017, but bump up to 1.5% starting on January 1 of 2018.

My county table started to get a little more complicated.

Instead of simply maintaining a table with a county name and county tax rate, I created the table with the following attributes:

private Integer id;
private String name;
private BigDecimal rate;
private Timestamp effectiveDate;

Using the example above, I would now have two records for Dade County, as shown below:

{
  "id" : 1,
  "name" : "Dade",
  "rate" : 0.01,
  "effectiveDate" : "2015-01-01"
},
{
  "id" : 2,
  "name" : "Dade",
  "rate" : 0.015,
  "effectiveDate" : "2018-01-01"
}

On the Property record, I needed to build the pick-list for the county using a query similar to what is displayed below:

SELECT c.* FROM county c 
INNER JOIN (SELECT name, MAX(effective_date) maxDate FROM county 
WHERE effective_date <= ?1 GROUP BY name) b ON c.name = b.name 
  AND c.effective_date = b.maxDate  
ORDER BY c.name";

Within the Angular client, the Closing Date field calls the  refreshCountyList() method when the ngbDatePicker value changes:

<input id="closingDate" class="form-control text-right" placeholder="mm/dd/yyyy" 
      formControlName="closingDate" #closingDate
       name="closingDate" ngbDatepicker #d1="ngbDatepicker" readonly
       (dateSelect)="refreshCountyList()">

Within the Angular component for the property-edit functionality, this calls the following function:

refreshCountyList() {
  let thisDate = new Date();
  if (this.propertyForm.value.closingDate) {
    thisDate = new Date(this.propertyForm.value.closingDate.year,
      this.propertyForm.value.closingDate.month - 1, this.propertyForm.value.closingDate.day);
  }

  const currentCounty = this.property.county;

  this.countyService.getActiveCounties(thisDate.getTime())
    .subscribe(data => {
      this.counties = data;

      const newCounty: County = this.getNewCounty(currentCounty);

      if (newCounty) {
        this.property.county = newCounty;
      } else {
        this.property.county = null;
        this._error.next('Please select a County from the drop-down list.');
      }

      this.computeFinancialData();
      this.propertyForm.patchValue({property: this.property});
    });
}

The process uses the date value to get a list of counties that fall into the appropriate range. Then determines if the currently selected county still exists in the list of counties. From there, the form is updated and the computeFinancialData() method is called to recompute the tax amounts and other financial information stored on the form.

As a result, the correct tax rate is used for the given county based upon the closing date of the property sale.

Looking Ahead

This article is a continuation of a multi-part series that I am putting together regarding my new application journey to providing a better application experience for my mother-in-law. Below is a list of the current and planned articles, if you are interested in reading more:

  • New Application Journey

  • Okta, a Nice Solution — Even for Small Apps

  • FormBuilder in Angular 6

  • The Challenge of the Commission Report

  • Making the County List Dynamic (this article)

  • New Version of the Commission Report

  • What I Learned After Initial Deployment

Have a really great day!

Listing (computer) application Database

Opinions expressed by DZone contributors are their own.

Related

  • Projection Queries: A Way to Optimize Data Traffic
  • Microservices in Practice: Deployment Shouldn't Be an Afterthought
  • Moving PeopleSoft ERP Data Between Databases With Data Mover Scripts
  • Understanding Multi-Leader Replication for Distributed Data

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!