Code Monkey home page Code Monkey logo

Comments (4)

theperu avatar theperu commented on July 22, 2024 1

Hi! If you want I can assign this issue to you while you try to figure out the root cause of the bug. Since the issue might go unnoticed for a bit if you want you can try asking the same question also in the Discord channel since it is a bit more active

from sossoldi.

jackrua avatar jackrua commented on July 22, 2024

Finally found it! It took me more than I would like to admit. But contrary to my first hunch, the issue was in the SQL query in the selectAll() method in BankAccountMethods.
This method launches an SQL query that looks something like this:

SELECT b.*, (b.startingValue +
      SUM(CASE WHEN t.type = 'IN' OR t.type = 'TRSF' AND t.idBankAccountTransfer = b.id THEN t.amount
               ELSE 0 END) -
      SUM(CASE WHEN t.type = 'OUT' OR t.type = 'TRSF' AND t.idBankAccount = b.id THEN t.amount
               ELSE 0 END)
    ) as total
      FROM bankAccount as b
      LEFT JOIN "transaction" as t ON t.idBankAccount = b.id OR t.idBankAccountTransfer = b.id
      WHERE active = 1 AND recurring = 0
      GROUP BY b.id
      ORDER BY createdAt AS

Now, focusing on the LEFT JOIN part of the query, you see that the WHERE clause filters out rows after the join is done, hence filtering out all bank accounts that have a transaction with the recurring field different from 0.
Practically speaking, if I add a new bank account that has no transactions (i.e. I add a row to the bankAccount table) this is correctly saved by the left join but is lost after it meets the WHERE clause.

Hopefully, I will fix it tomorrow!

from sossoldi.

jackrua avatar jackrua commented on July 22, 2024

This issue has already been fixed in #134, forgot to git pull and have been using an older version of the repo.

from sossoldi.

mikev-cw avatar mikev-cw commented on July 22, 2024

Good catch by the way!

from sossoldi.

Related Issues (20)

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.