             headers:
                 'User-Agent': userAgent
 
+        log.info 'Successfully logged in.'
         request loginOptions, (err, res, body) ->
             return next err if err
 
+            log.info 'Download bill HTML page...'
             # Third request to build the links of the bills
             options =
                 method: 'GET'

            request options, (err, res, body) ->
                return next err if err
                data.html = body
                next()


# Procedure to extract bill data from the page.
parsePage = (requiredFields, bills, data, next) ->
    baseDlUrl = 'https://www.bouyguestelecom.fr/mon-compte/suiviconso' + \
                '/index/facturepdf'
    bills.fetched = []

    # Load page to make it browseable easily.
    $ = cheerio.load data.html

    # We browse the bills table by processing each line one by one.
    $('.historique tr').each ->

        # If we find download information, it's a row with bill information
        urlData = $(this).find('.voirMaFacture a').attr('onclick')
        if urlData?

            # We get directly from the first field.
            date =  $(this).find('.eccogrisc:first-child').html()

            # Amount is in a weird field that contains nested spans. We only
            # get the five first chars of the element text.
            amount =  $(this).find('td:nth-child(2) span').text().substring 0, 5
            amount = amount.replace '€', ','

            # Build download url from data contained in the javascript code run
            # when the link is clicked.
            dataArray = urlData.split ','
            params =
                id: dataArray[4].replace /[\/'\s]/g, ''
                date: dataArray[5].replace /[\/'\s]/g, ''
                type: dataArray[6].replace /[\/'\s]/g, ''
                no_reference:dataArray[7].replace /[\/)']/g, ''
            url = "#{baseDlUrl}?#{qs.stringify params}"

            if params.type is 'Mobile'
                # Build bill object.
                bill =
                    date: moment date, 'DD/MM/YYYY'
                    amount: amount.replace ',', '.'
                    pdfurl: url
                bills.fetched.push bill
    next()

    amount: Number
    fileId: String
    binaryId: String
    pdfurl: String

PhoneBill.all = (callback) ->
    PhoneBill.request 'byDate', callback
