Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Loan interest paid at end of quarter is accounted in next quarter's expenses #10917

Closed
James103 opened this issue Jun 3, 2023 · 1 comment · Fixed by #11040
Closed
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@James103
Copy link
Contributor

James103 commented Jun 3, 2023

Version of OpenTTD

Since before svn r1 (via git blame)

Expected result

Loan interest paid at the end of a quarter should be accounted for in the quarterly operating expenses for that quarter.
For example, loan interest paid for March 2022 should be accounted for in the quarterly operating expenses for Q1 2022.

Actual result

Loan interest paid at the end of a quarter is accounted for in the quarterly operating expenses for next quarter.
For example, loan interest paid for March 2022 is accounted for in the quarterly operating expenses for Q2 2022.
Furthermore, if loan interest is paid for December of a given year, that interest gets accounted for in the yearly totals for that year but the quarterly expenses for next year, causing a discrepancy between the annual totals and the quarterly totals (the sum of the quarterlies don't add up to the annual).

Steps to reproduce

  1. Take out a loan in December of a given year.
  2. Wait until the following January, then repay the loan in full.

This is best reproduced in a scenario where you otherwise would not need a loan (such as in an established company or in a new game with the money cheat).

See JGRennison/OpenTTD-patches#524 for more detailed reproduction steps and a screenshot of the erroneous accounting. One fix, as implemented in JGRPP by @JGRennison, is simply to move CompaniesPayInterest() such that it occurs before CompaniesGenStatistics().

The alternative fix would be to somehow make the loan interest paid for December of a given year to be posted in the annual totals for next year. That would also solve the discrepancy, but in the other direction (loan interest payments for a given month are reported at the beginning of the month after).

@2TallTyler 2TallTyler added good first issue Good for newcomers bug Something isn't working labels Jun 5, 2023
@Swastik-Chakravorty
Copy link

I wanna work on this issue, can anyone help me, where I can get the code and how can I solve this. If you help me, this is going to be my first contribution in open-source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants