GithubHelp home page GithubHelp logo

peti / hledger-interest Goto Github PK

View Code? Open in Web Editor NEW
27.0 27.0 10.0 115 KB

compute interest for hledger accounts

Home Page: http://hackage.haskell.org/package/hledger-interest

License: BSD 3-Clause "New" or "Revised" License

Haskell 100.00%

hledger-interest's People

Contributors

adept avatar albertov avatar peti avatar ryantm avatar solpeth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

hledger-interest's Issues

Question on usage

Hi, cool and essential add-on for hledger! I just don't understand how I could use it in a practical application:

In my understanding, at the end of the year, I would use hledeger interest to rewrite the journal like:

hledger-interest -f my.journal [...] > tmp && mv tmp my.journal

(with git version control, of course)

But when I do the same thing at the end of the next year, hledger-interest duplicates the interest book entries of the first year.

How can I avoid or handle this? Thank you!

End of day balances should be used for interest

hledger-interest version 1.55 pays the interest on improper balances.

NOTE THAT INTEREST SHOULD BE PAID ON THE BALANCE IN THE ACCOUNT AT THE END OF THE DAY

By way of example say that interest is compounded daily and paid monthly. [Lots of UK bank accounts do interest this way.] Interest is 12% pa nominal and so 12%/365 is paid daily and this works out at about 12.75% when compounded daily.

The balance 1-Jan is £1000. Every month of the 1st of the month paid in is an £100 extra savings. Neglecting interest the balance on 1-Feb is £1100, on 1-Mar is £1200 etc. How much interest will hledger-interest calculate and what dates will it pay it?

Problem: You will see that first interest calculated by hledger-interest is 32 days on £1000 not 31 days. The interest should be paid up to the last day in which the balance remains £1000 not for the day after.

Problem, restated: Note that the interest on the £1000 balance is paid for 32 days although the balance is only that for 31 days.

Here are the files and the output.

$ cat journal.hledger 
D £1,000,000.00
commodity £1,000,000.00

2022-01-01 Open savings account
        assets:cash:bank            1000
        assets:cash:other bank

2022-02-01 Savings top up 1
        assets:cash:bank             100
        income:general

2022-03-01 Savings top up 2
        assets:cash:bank             100
        income:general
$ cat interest.sh 
#! /bin/sh

hledger-interest -q -f journal.hledger --act --annual=0.12 \
        -t assets:cash:bank -s income:general \
        assets:cash:bank

and here is the output

$ ./interest.sh
2022-02-01 12% interest for £1,000.00 over 32 days
    assets:cash:bank          £10.52
    income:general           £-10.52

2022-03-01 12% interest for £1,110.52 over 28 days
    assets:cash:bank          £10.22
    income:general           £-10.22`

Note that the output should be (but is not) as follows:

$ ./interest.sh
2022-02-01 12% interest for £1,000.00 over 31 days
    assets:cash:bank          £10.50
    income:general           £-10.50

2022-03-01 12% interest for £1,110.50 over 28 days
    assets:cash:bank          £10.21
    income:general           £-10.21`

Support --until=DATE besides --today

Hey @peti, I'm using your hledger-interest tool and it's great!

Sometimes I would like to generate interest transactions for the previous month and have them dated on the last day of the month. However when I'm already in the new month the --today option generates a transaction for the current day which is too late.

For this situation it would be nice to have a --until=DATE option which works the same as --today instead that you can specify the date.

WDYT?

Fails for multi-currency journals

With the current version of hledger-interest from stackage, it fails for multi-currency journals.

As a minimal example, I provide a shelltest file:

<
2021-01-01 deposit
  assets   100 €
  income

2021-01-01 deposit
  assets   100 $
  income

2021-07-01 deposit
  assets   100 €
  income

$ hledger-interest -f- -s income:interest -t assets:interest --act --constant=0.01 --quiet assets
>
2021/07/01 1% interest for 100 $, 100 € over 181 days
    assets:interest               0
    assets:interest               0
    income:interest               0
    income:interest               0

Install shelltestrunner und run with shelltest this-file.test. The problematic output of hledger-interest is this:

2021/07/01 1% interest for 100 $
100 € over 181 days
    assets:interest               0
    assets:interest               0
    income:interest               0
    income:interest               0

It's obviously not a valid hledger journal file.

build fails with ghc-9.6

       Building executable 'hledger-interest' for hledger-interest-1.6.5..                                               [68/163062]
       [1 of 5] Compiling Hledger.Interest.DayCountConvention                                                                       
       [2 of 5] Compiling Hledger.Interest.Rate                                                                                     
       [3 of 5] Compiling Hledger.Interest                                                                                          
                                                                                                                                    
       /var/stackage/work/unpack-dir/unpacked/hledger-interest-1.6.5-09f94ca91e865ba8527e60cfa72bb3f7fe61e4944eac8684959cf7deedf2ab0
0/Hledger/Interest.hs:54:3: error: [GHC-88464]
           Variable not in scope:                                                                                                   
             forM_                                                                                                                                 :: [Posting]                                       
                  -> (Posting -> m0 ())                                                                                             
                  -> RWST                                                                                                           
                       Config                                                                                                       
                       [Transaction]                                                                                                
                       InterestState                                                                                                
                       Data.Functor.Identity.Identity                                                                               
                       ()                                                                                                           
          |                                                                                                                         
       54 |   forM_ posts $ \p -> do                                                                                                
          |   ^^^^^              
                                                                                                                                    
       /var/stackage/work/unpack-dir/unpacked/hledger-interest-1.6.5-09f94ca91e865ba8527e60cfa72bb3f7fe61e4944eac8684959cf7deedf2ab0
0/Hledger/Interest.hs:67:3: error: [GHC-88464]                                                                                      
           Variable not in scope:                                                                                                                when                                                                                                                   
               :: Bool       
                  -> RWST                                                                                                           
                       Config    
                       [Transaction]                                                                                                
                       InterestState                                                                                                
                       Data.Functor.Identity.Identity                                                                               
                       ()
                  -> RWST
                       Config
                       [Transaction]                                                                                                
                       InterestState                                                                                                
                       Data.Functor.Identity.Identity                                                                               
                       a0
          |                      
       67 |   when (to >= from && not (mixedAmountIsZero bal)) $ do                                                                 
          |   ^^^^
:
:

If you can open a stackage PR to re-enable once fixed that would be welcome.

Publish binaries in GitHub Releases

Thank you for making this!

It would be great if we could download ready-made binaries for hledger-interest, as we can with hledger and hledger-flow.

I don't have the Haskell toolchain setup on all my machines, so would be very convenient to download binaries.

Could use github actions to produce the binaries in the release, as hledger does?

Partial Period Interest 12/31

I have a loan that assesses and capitalizes interest on the 10th of each month. Is there a way to ignore the 12/31 end of year interest assessment that hledger-interest calculates? Because of the capitalization, all of the values are incorrect beginning January 10th.

hledger-interest -f personal_loan.csv --act --annual=0.0674 -s Expenses:Loan:Personal -t Liabilities:Loan:Personal Liabilities:Loan:Personal --today

2021/12/10 6.74% interest for $-18251.54 over 30 days Correct
Liabilities:Loan:Personal $-101.11
Expenses:Loan:Personal $101.11

2021/12/31 6.74% interest for $-17873.71 over 21 days Partial: This starts the deviation from actual
Liabilities:Loan:Personal $-69.31
Expenses:Loan:Personal $69.31

2022/01/10 6.74% interest for $-17943.02 over 10 days Incorrect interest amount due to 21 day capitalization
Liabilities:Loan:Personal $-33.13
Expenses:Loan:Personal $33.13

2022/02/10 6.74% interest for $-17497.21 over 31 days off by $0.12
Liabilities:Loan:Personal $-100.16
Expenses:Loan:Personal $100.16

...

2022/06/25 6.74% interest for $-15568.83 over 15 days Off by $28.33 should be 15597.16
Liabilities:Loan:Personal $-43.12
Expenses:Loan:Personal $43.12

The --annual-schedule is ignored unless there is a balance change

Version 1.55

The --annual-schedule option is intended to allow an interest rate change to occur. However unless there is a balance change the new interest percentage change is ignored. For example

If the command line specifies --annual-schedule="[(2020-01-01,0.05),(2023-02-09,0.07)]" then the interest rate only changes on the first posting after 9-Feb, not on 9-Feb.

Interest rate shown is wrong by factor 100

With hledger-interest version 1.4.4 (on Debian Stretch), a call of

$ hledger-interest -f myloan.ledger --30E-360isda --annual=0.10 --today -s Einnahmen:Zinsen -t Aktiva:Darlehen Aktiva:Darlehen

leads to the output

2016/11/17 0.10% interest for € 7340 over 317 days
    Aktiva:Darlehen         € 646
    Einnahmen:Zinsen              € -646

I believe the string describing the interest positions should read 10.00% instead of 0.10%.

hledger-interest fails to parse some journals

Hi!

hledger-interest fails to parse some journals that hledger does not have any issues with, like this one:

commodity 1000.00 USD

Or this one:

2019-02-20 Reconciliation
  assets:a    = $100
   expenses:misc

Perhaps this is because it links against hledger-lib that is older than the one used by most recent hledger.

I appreciate that it might not be an easy change to make to update hledger-interest to hledger-lib 1.13.1 (and then keep it in sync). Would you be happy (or not opposed) for hledger-interest functionality to be merged into hledger itself?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.