Javascript Conditional Statement

  • Posted:
  • Proposals: 6
  • Remote
  • #700212
  • Awarded
Hafiz M.
Dev S.Sunil S.Rahul N.Indi S. + 1 other have already sent a proposal.
  • 0

Description

Experience Level: Intermediate
General information for the website: Bond Calculator
Num. of web pages/modules: 1
Description of every page/module: I am looking to achieve this.

For a date of the 27 Feb 2015 I need to calculate whether this is before / after or equal to the following variables, all are strings and formatted in DD-MM

var settlement_date = '27 Feb 2015'; //This is the exception to the above formatting
var first_payment = '24-01';
var first_record_date = '17-01';
var second_payment = '24-07';
var second_record_date = '17-07';
var next_entitlement_date;
The logic is as follows

// if the settlement date is after the first_payment date

// if the settlement date is before the second_payment date

// last_coupon_payment = first_payment
// next_coupon_payment = second_payment
// record_date = second_record_date

// if the settlement date is after the second_payment date

// last_coupon_payment = second_payment - 1 Year
// next_coupon_payment = first_payment
// record_date = first_record_date

// if the settlement date is equal to the second_payment date

// last_coupon_payment = first_payment
// next_coupon_payment = second_payment
// record_date = second_record_date

// if the settlement date is before the first_payment date

// if the settlement date is before the second_payment date

// last_coupon_payment = first_payment
// next_coupon_payment = second_payment
// record_date = second_record_date

// if the settlement date is after the second_payment date

// last_coupon_payment = second_payment - 1 Year
// next_coupon_payment = first_payment
// record_date = first_record_date

// if the settlement date is equal to the second_payment date

// last_coupon_payment = second_payment
// next_coupon_payment = first_payment
// record_date = first_record_date

Also I need to evaluate the settlement_date relative to the *_record_date and set the variable next_entitlement_date to either the first_payment or second_payment depending on the outcome.

I have included a JSBin (http://jsbin.com/setehatuxo/2/edit) of my existing code which is I feel overly complex and I need some help to resolve this conditional pit that I am in.
Description of requirements/features: To make the conditional work in all circumstances
Extra notes:

New Proposal

Create an account now and send a proposal now to get this job.

Sign up

Clarification Board Ask a Question

    There are no clarification messages.