/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function final_store()
    {
        $swaps = inboundFpmlSwap::where('message_type', 'consent requested')->get();
        //read requests and issue new fpml messages for consent accepted
        foreach ($swaps as $swap) {
            $swap->message_type = 'read and accepted';
            //'read and accepted' is just marking a message as read by the system
            $s = new fpmlSwap();
            $trader = User::findOrFail(\Auth::user()->id);
            $s->trader_name = $trader->first_name . ' ' . $trader->last_name;
            $s->message_type = 'consent accepted';
            $swap->save();
            $swap->fpml_message = '<?xml version="1.0" encoding="UTF-8"?>
            <consentGranted fpmlversion=”5-0”>

            <header>
            <messageId>' . $s->id . '</messageId>
            <sentBy>' . $trader->company . '</sentBy>
            <sendTo>Exchange</sendTo>
            <creationTimestamp>' . Carbon::now() . '</creationTimestamp>
            </header>

            <party id="sideA">
            <partyId>RBC</partyId>
            </party>

            </consentGranted>';
            $s->update();
        }
        //if accepted store in table
        $accepted = inboundFpmlSwap::where('message_type', 'consent accepted')->get();
        foreach ($accepted as $s) {
            $s->message_type = 'read';
            //mark as 'read'
            $trader = User::findOrFail(\Auth::user()->id);
            $swap = new Swap();
            $swap->trader_id = $trader->id;
            $swap->company = $trader->company;
            $start_date = Carbon::parse(SwapsController::parse($swap->fpml_message, '<effectiveDate>'));
            $swap->start_date = $start_date;
            $end_date = Carbon::parse(SwapsController::parse($swap->fpml_message, '<terminationDate>'));
            $swap->end_date = $end_date;
            $fixed_rate = Carbon::parse(SwapsController::parse($swap->fpml_message, '<initialValue>'));
            $swap->fixed_rate = $fixed_rate;
            $floating_rate = Carbon::parse(SwapsController::parse($swap->fpml_message, '<floatingRateIndex>'));
            $swap->floating_rate = $floating_rate;
            $floating_spread = '1.3';
            //Carbon::parse(SwapsController::parse($swap->fpml_message,'<terminationDate>'));
            $swap->floating_spread = $floating_spread;
            $payer_fixed = SwapsController::parse($swap->fpml_message, '<party id="sideA"><partyId>');
            $swap->payer_fixed = $payer_fixed;
            $payer_float = SwapsController::parse($swap->fpml_message, '<party id="sideB"><partyId>');
            $swap->payer_float = $payer_float;
            $swap->business_date = Carbon::now();
            $swap->save();
            $next_day = Carbon::now();
            $next_day->hour = 16;
            $next_day->minute = 0;
            $next_day->second = 0;
            if (Carbon::parse($swap->created_at)->diffInMinutes($next_day) > 0) {
                $next_day->addWeekday();
                $next_day->hour = 9;
                $next_day->minute = 30;
                $swap->created_at = $next_day;
                $swap->update();
            }
        }
        return;
    }