flash-oss / medici

Double-entry accounting system for nodejs + mongoose
MIT License
309 stars 85 forks source link

List of Journal Entries #6

Closed zenners closed 7 years ago

zenners commented 7 years ago

Hello,

I've been playing around your lib and like it a lot. I was wondering how I would go about adding a method to get the journal entries and populate those with the debits and credits. I have a usecase where I would need to upload the entries to an external accounting system.

I looked into the source and saw the this.journalModel = mongoose.model('Medici_Journal');

and of course have used the ledger() method.

Would I just follow the same style of the ledger method and populate the ID's normally in mongodb?

Kindly advise, I can even put in a PR if this feature is warranted. :)

zenners commented 7 years ago

never mind :)

const mongoose = require('mongoose');
var journal = mongoose.model('Medici_Journal');

router.get('/journal', function(req,res,next){
  journal.find({})
  .populate('_transactions')
  .exec(function(err,entries){
    res.send(entries)
  })
})

does the trick