function FinanceDetails(product_type, cost_of_goods, deposit_percentage, deposit_amount) {

    deposit_amount = typeof deposit_amount !== 'undefined' ? deposit_amount : 0;

    var rateCards = {
  "ONIB24-19.90-18693": {
    "Id": "6e46a65b-a47e-43a6-bccc-5e0d03778149",
    "apr": 19.90,
    "rate_of_interest": "19.90% (Fixed)",
    "term": 24,
    "p_name": "24 months interest bearing (19.90%)",
    "subsidy_lower": 1.0,
    "subsidy_upper": 1.0,
    "p4l_min_fee": 0.0,
    "lender_min_fee": 0.0,
    "l_min": 250.00,
    "l_max": 15000.00,
    "factor": 0.050040141717906910,
    "fees": 1,
    "round_repayments": "round",
    "repayments_spread": "first"
  },
  "ONIB36-19.90-18695": {
    "Id": "5099c913-78cf-4de7-bacf-1fbc57258188",
    "apr": 19.90,
    "rate_of_interest": "19.90% (Fixed)",
    "term": 36,
    "p_name": "36 months interest bearing (19.90%)",
    "subsidy_lower": 1.0,
    "subsidy_upper": 1.0,
    "p4l_min_fee": 0.0,
    "lender_min_fee": 0.0,
    "l_min": 250.00,
    "l_max": 15000.00,
    "factor": 0.036272905236999345,
    "fees": 1,
    "round_repayments": "round",
    "repayments_spread": "first"
  },
  "ONIB60-19.90-18699": {
    "Id": "fd55be51-0e2c-490e-8606-d79de2acb6ae",
    "apr": 19.90,
    "rate_of_interest": "19.90% (Fixed)",
    "term": 60,
    "p_name": "60 months interest bearing (19.90%)",
    "subsidy_lower": 1.0,
    "subsidy_upper": 1.0,
    "p4l_min_fee": 0.0,
    "lender_min_fee": 0.0,
    "l_min": 250.00,
    "l_max": 15000.00,
    "factor": 0.025524167453134660,
    "fees": 1,
    "round_repayments": "round",
    "repayments_spread": "first"
  },
  "ONIB48-19.90-18697": {
    "Id": "1c5b0f45-cd7c-41ed-b8c9-4628d77f638f",
    "apr": 19.90,
    "rate_of_interest": "19.90% (Fixed)",
    "term": 48,
    "p_name": "48 months interest bearing (19.90%)",
    "subsidy_lower": 1.0,
    "subsidy_upper": 1.0,
    "p4l_min_fee": 0.0,
    "lender_min_fee": 0.0,
    "l_min": 250.00,
    "l_max": 15000.00,
    "factor": 0.029500558690308046,
    "fees": 1,
    "round_repayments": "round",
    "repayments_spread": "first"
  },
  "ONIB12-19.90-18690": {
    "Id": "66f170f7-46d8-495c-a3b9-8824e7445b94",
    "apr": 19.90,
    "rate_of_interest": "19.90% (Fixed)",
    "term": 12,
    "p_name": "12 months interest bearing (19.90%)",
    "subsidy_lower": 1.0,
    "subsidy_upper": 1.0,
    "p4l_min_fee": 0.0,
    "lender_min_fee": 0.0,
    "l_min": 250.00,
    "l_max": 15000.00,
    "factor": 0.091794250845464910,
    "fees": 1,
    "round_repayments": "round",
    "repayments_spread": "first"
  }
};

    Object.assign(this, rateCards[product_type]);

    // cost of goods
    this.goods_val = cost_of_goods * 100;
    // in the event that a deposit amount is being set instead of a deposit percentage
    if (deposit_percentage > 0) {
        // deposit percentage
        this.d_pc = deposit_percentage;
        // deposit amount
        this.d_amount = Math.round((this.goods_val / 100) * this.d_pc);
    } else {
        // deposit amount
        this.d_amount = deposit_amount * 100;
        // deposit percentage
        this.d_pc = (this.d_amount / this.goods_val) * 100;
    }
    // amount of credit
    this.l_amount = (this.goods_val - this.d_amount) * this.fees;

    this.m_full_inst = this.l_amount * this.factor;

    if (product_type.toString().substring(0, 2) === 'BL' || product_type.toString().substring(0, 2) === 'PB') {
        this.firstRepayment = 0;
        this.last_repayment = this.credit;
    } else if (this.apr > 0) {
        switch (this.round_repayments) {
            case 'floor':
                this.m_inst = Math.floor(this.m_full_inst + 0.0001);
                break;
            case 'round':
            case 'round_all':
                this.m_inst = Math.round(this.m_full_inst);
                break;
            default:
                return null;
        }
    } else {
        this.m_inst = Math.floor(this.m_full_inst + (this.round_repayments === 'round_all' ? 0.0001 : 0));
    }

    switch (this.repayments_spread) {
        case 'first':
            var diff = (this.m_full_inst - this.m_inst) * this.term;
            this.first_repayment = Math.round(this.m_inst + diff);
            this.last_repayment = this.m_inst;
            break;
        case 'equal':
            this.first_repayment = this.m_inst;
            this.last_repayment = this.m_inst;
            break;
        case 'equal_except_last_interest_free':
            if (this.apr == 0) {
                var diff = (this.m_full_inst - this.m_inst) * this.term;
                this.first_repayment = this.m_inst;
                this.last_repayment = Math.round(this.m_inst + diff);
            } else {
                this.first_repayment = this.m_inst;
                this.last_repayment = this.m_inst;
            }
            break;
        default:
            return null;
    }

    if (product_type.toString().substring(0, 2) === 'BL' || product_type.toString().substring(0, 2) === 'PB') {
        this.first_repayment = 0;
        this.last_repayment = this.credit;
    }

    this.l_repay = this.first_repayment + (this.m_inst * (this.term - 2)) + this.last_repayment;

    // total cost
    this.total = this.l_repay + this.d_amount;
    // display 'incorrect' total (goods amount) for interest free
    if (this.apr == 0) {
        this.total = this.goods_val;
    }
    // cost of loan
    this.l_cost = this.l_repay - this.l_amount;
    // retailer subsidy
    if ((this.l_amount / 100) <= 1250) {
        this.r_subsidy = (this.l_amount / 100) * ((parseFloat(this.subsidy_upper)) / 100);
    } else {
        this.r_subsidy = (this.l_amount / 100) * ((parseFloat(this.subsidy_lower)) / 100);
    }
    if (this.r_subsidy < 0) {
        this.r_subsidy = 0;
    }
    if (this.r_subsidy < (this.lender_min_fee + this.p4l_min_fee)) {
        this.r_subsidy = (this.lender_min_fee + this.p4l_min_fee);
    }
    // formatting values
    this.goods_val = (this.goods_val / 100).toFixed(2);
    this.d_pc = this.d_pc.toFixed(2);
    this.d_amount = (Math.ceil(this.d_amount) / 100).toFixed(2);
    this.l_amount = (this.l_amount / 100).toFixed(2);
    this.m_inst = Math.round(this.m_inst) / 100;
    this.l_repay = (this.l_repay / 100).toFixed(2);
    this.total = (this.total / 100).toFixed(2);
    this.l_truecost = (this.l_cost / 100).toFixed(2);
    this.l_cost = (this.l_cost < 0) ? (0) : (this.l_cost / 100);
    this.l_cost = this.l_cost.toFixed(2);
    this.r_subsidy = this.r_subsidy.toFixed(2);

    this.valid = true;
    if (this.l_amount > this.l_max || this.l_amount < this.l_min) {
        this.valid = false;
    }
}


