Lease vs. Buy android app

I concentrated on this Lease Vs. Buy app for a few reasons: 

Hopefully, users will download this app, use it and provide comments back so that I can improve on it.

Brief introduction to the analysis approach

A lease is a contractual arrangement by which the owner of the asset (the lessor) rents the asset to the customer (the lessee).  Instead of buying equipment with a large upfront payment, the customer is able to lease it with smaller periodic payments.  At the end of the lease term, customer has an option to return the equipment, buy it at a previously agreed upon price, or continue to rent.  For the lessee, the lease is an alternative to purchasing the asset with debt, and the lessor understands that it is essentially providing financing for the lessee.

This analysis concentrates purely on cash flows. The decision to lease is viewed as a purely financing decision, assuming that all operational factors between leasing and buying are equivalent.  I have implemented the equivalent loan method as described in Simon Benninga's Financial Modeling book.

The equivalent loan method constructs a hypothetical loan that is somehow equivalent to the lease, which then allows us to determine the better option.   We first calculate the after-tax cash flows of the lease and that of the buy, writing cash out-flows with minus sign and in-flows with a plus sign.  The after-tax lease cash flows minus after-tax buy cash flows gives us the differential cash flows, which indicate the cash saved by leasing compared to buying.  Next the internal rate of return (IRR) of these differential cash flows is calculated. If this IRR is greater than the after-tax cost of borrowing then buying is preferable to leasing or vice-versa.

Looking at the differential cash flows, we see that leasing instead of buying the asset is similar to getting a loan at the beginning of the term with after-tax repayments in the following periods.  Therefore the lease can be viewed as an alternate method of financing the asset.  In order to compare the lease to the buy, we should compare the cost of this financing with the cost of alternate financing.

How implemented in the application

The app can help one make lease or buy decisions for two completely different types of assets:

Equipment lease:  Here several parameters govern the after-tax cash flows including federal and state tax deductions related to depreciation of the owned asset (buy case) or rental expense of the leased asset (lease case).   The timing of tax payments, the depreciation schedule used (MACRS or straightline), the residual value, security deposits, upfront fees, and many more inputs affect the cash flows.  All these elaborate inputs are organized within groups that are easy to follow. 

It is assumed that the lease payments are tax deductible each period and the actual tax benefit impacting the cash flows occurs when the tax payment is due.  Depreciation schedules contribute to the tax deductions every period, however tax payments affecting cash flows occur when cash taxes are due.  The upfront fees paid during leasing are also amortized over the term of the lease and contribute to tax deductions.  State taxes paid cannot be claimed for federal deductions.  

For the buy case, it is assumed that the equipment can be sold at the residual value at the end of the lease term.  For tax deduction calculations the book value of the equipment at the end of the lease term is subtracted from the residual value.

Consumer auto lease:  Determining cash flows in this case is simpler because no tax deductions are allowed.  However, various types of fees makes the semantics and terms different enough that a new solution category deemed necessary.  In this approach the cost of getting a loan is assumed to be known in terms of the annual interest rate charged.  The lease amount can be specified as a specific dollar amount (this may be a number that the dealer gives you), or one can specify the relevant annual lease interest rate.  A down payment (such as the destination charge) applies to both lease and buy options equally.  Security deposit and other upfront fees (such as acquisition fees) are due at the inception of the lease.  A security deposit is returned back at the end of the lease term.  If the vehicle is being purchased,  there could be other buy specific upfront fees which can be specified.

In addition to the equivalent loan method, here we also calculate and compare the net present value (NPV) of lease and buy cash flows.  Note that the NPVs will be negative since there is a net cash outflow in both cases.  The less negative the NPV better the option because this means that the cost is lower. 

Tutorial on using the app

Below is the UI when "Equipment Lease" or "Consumer Auto Lease" are clicked.  

One can expand each input group by clicking on the group heading, which will expand the form.  Clicking on the heading again will collapse the group.  

Any modification to the input values are automatically saved.  If you want to restore default values in the UI form, click on the menu option, and choose "Set Defaults".  The "Exit" button closes the application (i.e. moves it to the background)

    

 

Closer look at consumer auto lease

The input groups are "Vehicle Info", "Lease Option" and "Buy Option" and the relevant forms are shown below.  

    

At any point if you need help on the specific input, just long press the relevant text field.  For example, in the picture below the text "Residual (% of MSRP)" was long pressed and a toast with relevant description appears.

Clicking on the red checkmark floating action button at the bottom of the screen submits the input and generates the report as shown below.

  

This report is in HTML format and can be easily used for further analysis in Excel.

Clicking on the red email floating action button at the bottom enables the user to email the results to oneself or others as shown below

Closer look at equipment lease

The input groups are "Basic Info", "Rent Schedule", "Depreciation Info" and "Tax info" and the relevant forms are shown below.  

   

Each of these screens have nifty user interface components that are self explanatory.  If one desires further help, they can longpress the relevant text fields.  For example, long pressing the "Depreciation Type" gives the following toast output.

Clicking on the red checkmark floating action button at the bottom of the screen submits the input and generates a report as shown below.

  This report is in HTML format and can be easily used for further analysis in Excel.

Clicking on the red email floating action button at the bottom enables the user to email the results to oneself or others as shown below

Simple Example Problem

Default values have already been setup in the app so that if one just clicks on the red checkmark floating action button, relevant output will be generated. The default values can also be reset by selecting the 'Set Defaults' menu option.  This by itself would serve as an example program.

However, let's go through a more simple example to understand how the app can be used.  Consider the following equipment lease decision problem:

Equipment cost: $600,000

Interest rate / Cost of debt: 12% (before tax)

Lease rental payment: $140,000

Lease period: 5 years

Depreciation period: 6 years

Federal tax rate: 40%

Which is a better option, lease or buy?

Inputs are keyed in the app as follows for the "Equipment Lease" option

Clicking on the red checkmark floating action button at the bottom of the screen submits the input and generates the report as shown below.  Click on the image to see the actual HTML output.

In this case it is better to buy the equipment.

Notes on development approach

I took quite some time (almost a few months) implementing the mathematical library to perform various financial calculations.  My intention was to develop a library that could be used for other financial calculators besides this tool.  I have to admit that this library now contains several hundred lines of code that is completely unused.  JUnit framework was used extensively to test the proper functioning of this library.  The output values obtained for various inputs were also compared to relevant calculations done in Excel.  I wanted to make sure that the calculations were correct.  

I had started developing the library on the Eclipse platform since I was more familiar with that environment.  I soon realized that Android Studio is where my UI development would need to take place given its functional superiority compared to Eclipse.  It took me some additional time to get familiar with the Android Studio and transfer all my code.  I also got busy at work (my regular finance job) and did not have too much free time to concentrate on this coding project.  Had to re-familiarize myself with the code quite a few times when I got back to it after long breaks.   All this added to the delay.  Anyway, my JUnit strategy paid off since I could rely on at least my calculations being correct.  

I concentrated quite a lot of time on the UI design.  If I wanted to create a leave vs. buy tool with more complex use cases, I knew that there would be lots of input values that the tool would need to handle.  Having a long form to key-in and submit would make it quite cumbersome for a user.   Therefore I wanted to group inputs in categories that could be easily understood/followed.  Implementing the expanding form capability took me some time to research on the web and experiment.   This also being the first UI feature I started developing in android, there was a bit of a learning curve that I had to overcome.  Even though other implementations were quite challenging such as those needed for step-lease,  dynamic formatting of input values in the text fields, auto-saving of input values, output report generation in HTML, they weren't as time consuming because I had by then become quite familiar with android programming.

At some point in the near future, I hope I will have more time to develop other tools utilizing concepts that I learnt during this development effort.