Mileage Tracker (Tap Forms 5.3)

This topic contains 7 replies, has 4 voices, and was last updated by  Brendan 4 months, 1 week ago.

  • Author
    Posts
  • October 11, 2018 at 10:20 AM #30998

    Brendan
    Keymaster

    I created a mileage tracker form but posted it in the regular forum. Figured I should post it here for everyone to download. It requires Tap Forms 5.3 at a minimum because it uses JavaScript to copy the previous mileage value to a new record. You need to select a record and then run the script. Tap Forms will create a new record and copy over the values from the selected record to the new record.

    Use the Import Tap Forms Archive function to import this file.

    Thanks!

    Brendan

    Attachments:
    You must be logged in to view attached files.
    November 25, 2018 at 9:48 PM #32071

    Ryan M
    Participant

    Thought I’d play around and see if I could come up with a different approach to the same mileage tracker. This would probably be closer to a fuel log rather than a simple mileage tracker.

    The inputs would be:

    – odometer value
    – Price per gallon
    – Gallons filled

    A script would calculate your mileage since last fill up as well as your miles per gallon.

    The script uses the default created date field to sort all records by their created date. This assumes that you’re entering in your mileage log around the time you filled up.

    Here’s the script for those interested

    
    var odometer_id = 'fld-9674e316bfed408ca6710ce81b72bf05';
    var vehicle_id = 'fld-64b0b17a635f49b8b40867e45f8d24db';
    var date_created_id = 'fld-2097149a2eeb4d4e892f13b62de6b5ea';
    
    // sort records in ascending order by date value
    var dateSorter = (a, b) => 
      a.getFieldValue(date_created_id) - b.getFieldValue(date_created_id)
      
    
    var run = () => {
      var vehicle = record.getFieldValue(vehicle_id);
      var odometer = record.getFieldValue(odometer_id);
    
      var records = form.getRecords()
        .filter(r =>  r.getFieldValue(vehicle_id) === vehicle)
        .sort(odometerSorter)
    
      var odometerValues = records.map(r => r.getFieldValue(odometer_id));
      var currentRecordIndex = odometerValues.indexOf(odometer);
      var previousRecordIndex = currentRecordIndex === 0 ? 0 : currentRecordIndex - 1
                     
      var mileageValue = odometerValues[currentRecordIndex] - odometerValues[previousRecordIndex]
    
      return mileageValue;
    }
    
    run();
    
    
    Attachments:
    You must be logged in to view attached files.
    November 25, 2018 at 10:42 PM #32074

    Brendan
    Keymaster

    Hi Ryan,

    For some reason Askimet flagged your response as spam. But I noticed it and marked it as not spam so it shows up now.

    Thanks for posting your alternative for the mileage tracker!

    Brendan

    November 25, 2018 at 10:43 PM #32075

    Ryan M
    Participant

    I was wondering what happened. Thanks, Brenden!

    December 5, 2018 at 11:36 AM #32411

    Chris Stovall
    Participant

    I have TapForms 5.3.4 but I can’t open the attached file. I tried in the finder and also doing a file/open. Not luck either way. What am I missing?

    December 5, 2018 at 2:08 PM #32415

    Brendan
    Keymaster

    Hi Chris,

    This is a Tap Forms Archive file. Use the Import Tap Forms Archive command in the File menu to import it.

    Thanks!

    Brendan

    April 9, 2019 at 6:04 PM #34366

    Tom Mihalic
    Participant

    I’m new here. How do i open the mileage tracker app? Tt is a .tfarc file.

    April 9, 2019 at 6:34 PM #34367

    Brendan
    Keymaster

    Hi Tom,

    Use the Import Archive command to import the mileage tracker .tfarc file. So you must first have a document opened. Then import the file.

    Thanks!

    Brendan

You must be logged in to reply to this topic.