Giter Site home page Giter Site logo

Comments (3)

bdoherty avatar bdoherty commented on July 23, 2024

Here are a few examples that I have documented.

Total Amount per Payee between 6 Apr 2020 and 5 Apr 2021

(await $query($q('transactions')
.filter({ $and: [ {date: { $gte: '2020-04-06'}}, {date: {$lte: '2021-04-05'}}]})
.groupBy('payee.name')
.orderBy('payee.name')
.select(['payee.name', {'amount': {$sum: '$amount'}}])
)).data.map((row) => { console.log(`${row['payee.name']}: ${row.amount/100}`) })

Total Amount of all transactions with Note containing #interest (P) between 6 Apr 2020 and 5 Apr 2021

(await $query($q('transactions')
.filter({ '$and': [ 
  {'date': { '$gte': '2020-04-06'}}, 
  {'date': {'$lte': '2021-04-05'}}, 
  {'notes': {'$like': '%#interest (P)%'}} ]
})
.calculate({ '$sum': '$amount' })
)).data/100

or

(await $query($q('transactions')
.filter({ '$and': [ 
  {'date': { '$gte': '2020-04-06'}}, 
  {'date': {'$lte': '2021-04-05'}}, 
  {'notes': {'$like': '%#interest (P)%'}} 
]})
.select({ 'total': { '$sum': '$amount' } })
)).data[0].total/100

Total Amount per Category between 6 Apr 2020 and 5 Apr 2021

(await $query($q('transactions')
.filter({ $and: [ {date: { $gte: '2020-04-06'}}, {date: {$lte: '2021-04-05'}}]})
.groupBy('category.name')
.orderBy(['category.group.sort_order','category.sort_order'])
.select(['category.group.name','category.name', {'amount': {$sum: '$amount'}}])
)).data.map((row) => { console.log(`${row['category.group.name']}/${row['category.name']}: ${row.amount/100}`) })

from docs.

rich-howell avatar rich-howell commented on July 23, 2024

Hey @bdoherty

Thanks for this, we have added this to the documentation, which is available here #35

Thanks again
Rich

from docs.

MatissJanis avatar MatissJanis commented on July 23, 2024

Closing as DONE

from docs.

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.